@kubb/plugin-oas 3.0.0-alpha.0 → 3.0.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (73) hide show
  1. package/dist/OperationGenerator-By5WOmWB.d.ts +165 -0
  2. package/dist/OperationGenerator-Gd1X7wUz.d.cts +165 -0
  3. package/dist/{Schema-DefwBJMc.d.ts → Schema-B1vcPGiK.d.ts} +3 -5
  4. package/dist/{Schema-an5hOrjZ.d.cts → Schema-DoSFh7Qd.d.cts} +3 -5
  5. package/dist/{SchemaMapper-CsBQ6eEx.d.cts → SchemaMapper-sGcY1xL5.d.cts} +1 -2
  6. package/dist/{SchemaMapper-CsBQ6eEx.d.ts → SchemaMapper-sGcY1xL5.d.ts} +1 -2
  7. package/dist/chunk-75BIOXB7.cjs +7 -0
  8. package/dist/chunk-75BIOXB7.cjs.map +1 -0
  9. package/dist/{chunk-UKUEVTRB.cjs → chunk-IAUV3UKH.cjs} +735 -35
  10. package/dist/chunk-IAUV3UKH.cjs.map +1 -0
  11. package/dist/{chunk-QSM6A5QX.js → chunk-M347763D.js} +714 -14
  12. package/dist/chunk-M347763D.js.map +1 -0
  13. package/dist/{chunk-GUPCIAYT.js → chunk-N7EEVJA6.js} +3 -3
  14. package/dist/{chunk-J7IF3KA3.cjs → chunk-NU4F7G47.cjs} +4 -16
  15. package/dist/chunk-NU4F7G47.cjs.map +1 -0
  16. package/dist/{chunk-3UN2S6P2.cjs → chunk-O76YQFZB.cjs} +3 -3
  17. package/dist/{chunk-3UN2S6P2.cjs.map → chunk-O76YQFZB.cjs.map} +1 -1
  18. package/dist/chunk-SQ64ESS4.js +7 -0
  19. package/dist/chunk-SQ64ESS4.js.map +1 -0
  20. package/dist/{chunk-Y272OQMW.js → chunk-SZDO532A.js} +3 -15
  21. package/dist/chunk-SZDO532A.js.map +1 -0
  22. package/dist/components.cjs +4 -9
  23. package/dist/components.cjs.map +1 -1
  24. package/dist/components.d.cts +13 -7
  25. package/dist/components.d.ts +13 -7
  26. package/dist/components.js +3 -8
  27. package/dist/components.js.map +1 -1
  28. package/dist/hooks.cjs +12 -13
  29. package/dist/hooks.cjs.map +1 -1
  30. package/dist/hooks.d.cts +4 -4
  31. package/dist/hooks.d.ts +4 -4
  32. package/dist/hooks.js +2 -3
  33. package/dist/hooks.js.map +1 -1
  34. package/dist/index.cjs +282 -231
  35. package/dist/index.cjs.map +1 -1
  36. package/dist/index.d.cts +8 -77
  37. package/dist/index.d.ts +8 -77
  38. package/dist/index.js +274 -223
  39. package/dist/index.js.map +1 -1
  40. package/dist/{types-BP45TdiW.d.cts → types-CZTUCaE5.d.cts} +3 -6
  41. package/dist/{types-BP45TdiW.d.ts → types-CZTUCaE5.d.ts} +3 -6
  42. package/dist/utils.cjs +12 -54
  43. package/dist/utils.cjs.map +1 -1
  44. package/dist/utils.d.cts +7 -33
  45. package/dist/utils.d.ts +7 -33
  46. package/dist/utils.js +6 -48
  47. package/dist/utils.js.map +1 -1
  48. package/package.json +12 -11
  49. package/src/OperationGenerator.ts +68 -32
  50. package/src/SchemaGenerator.ts +32 -15
  51. package/src/SchemaMapper.ts +1 -1
  52. package/src/components/Oas.tsx +9 -3
  53. package/src/components/Operation.tsx +1 -1
  54. package/src/components/Schema.tsx +29 -31
  55. package/src/generator.tsx +125 -0
  56. package/src/hooks/useOperationManager.ts +1 -0
  57. package/src/index.ts +3 -9
  58. package/src/plugin.ts +25 -38
  59. package/src/types.ts +2 -6
  60. package/src/utils/getParams.ts +1 -1
  61. package/src/utils/index.ts +2 -1
  62. package/dist/OperationGenerator-B0RLFu4P.d.ts +0 -60
  63. package/dist/OperationGenerator-CrCcKl3S.d.cts +0 -60
  64. package/dist/chunk-J7IF3KA3.cjs.map +0 -1
  65. package/dist/chunk-K4GEQ3C2.cjs +0 -698
  66. package/dist/chunk-K4GEQ3C2.cjs.map +0 -1
  67. package/dist/chunk-QSM6A5QX.js.map +0 -1
  68. package/dist/chunk-UKUEVTRB.cjs.map +0 -1
  69. package/dist/chunk-Y272OQMW.js.map +0 -1
  70. package/dist/chunk-ZZ7ZC4TT.js +0 -698
  71. package/dist/chunk-ZZ7ZC4TT.js.map +0 -1
  72. package/src/utils/getGroupedByTagFiles.ts +0 -82
  73. /package/dist/{chunk-GUPCIAYT.js.map → chunk-N7EEVJA6.js.map} +0 -0
package/dist/index.js CHANGED
@@ -1,149 +1,103 @@
1
1
  import {
2
2
  parseFromConfig
3
- } from "./chunk-GUPCIAYT.js";
3
+ } from "./chunk-N7EEVJA6.js";
4
+ import "./chunk-SQ64ESS4.js";
4
5
  import {
6
+ Oas,
5
7
  SchemaGenerator,
6
8
  isKeyword,
9
+ require_jsx_runtime,
7
10
  schemaKeywords
8
- } from "./chunk-ZZ7ZC4TT.js";
11
+ } from "./chunk-M347763D.js";
9
12
  import {
10
- __privateAdd,
11
- __privateGet,
12
- __privateMethod,
13
- __privateSet,
13
+ __toESM,
14
14
  getSchemas,
15
15
  init_esm_shims
16
- } from "./chunk-Y272OQMW.js";
16
+ } from "./chunk-SZDO532A.js";
17
17
 
18
18
  // src/index.ts
19
19
  init_esm_shims();
20
20
 
21
- // src/plugin.ts
21
+ // src/OperationGenerator.ts
22
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();
23
+ import { BaseGenerator } from "@kubb/core";
24
+ import transformers from "@kubb/core/transformers";
25
+ var OperationGenerator = class extends BaseGenerator {
26
+ #operationsByMethod = {};
27
+ get operationsByMethod() {
28
+ return this.#operationsByMethod;
29
+ }
30
+ set operationsByMethod(paths) {
31
+ this.#operationsByMethod = paths;
32
+ }
33
+ #getOptions(operation, method) {
34
+ const { override = [] } = this.context;
35
+ return override.find(({ pattern, type }) => {
36
+ if (type === "tag") {
37
+ return !!operation.getTags()[0]?.name.match(pattern);
42
38
  }
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;
39
+ if (type === "operationId") {
40
+ return !!operation.getOperationId().match(pattern);
74
41
  }
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;
42
+ if (type === "path") {
43
+ return !!operation.path.match(pattern);
84
44
  }
85
- return this.fileManager.write(path2, source, { sanity: false });
86
- },
87
- async buildStart() {
88
- if (!output) {
89
- return;
45
+ if (type === "method") {
46
+ return !!method.match(pattern);
90
47
  }
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
- // src/OperationGenerator.ts
130
- init_esm_shims();
131
- import { Generator } from "@kubb/core";
132
- import transformers from "@kubb/core/transformers";
133
- var _operationsByMethod, _OperationGenerator_instances, getOptions_fn, isExcluded_fn, isIncluded_fn, methods_get;
134
- var OperationGenerator = class extends Generator {
135
- constructor() {
136
- super(...arguments);
137
- __privateAdd(this, _OperationGenerator_instances);
138
- __privateAdd(this, _operationsByMethod, {});
48
+ return false;
49
+ })?.options || {};
139
50
  }
140
- get operationsByMethod() {
141
- return __privateGet(this, _operationsByMethod);
51
+ /**
52
+ *
53
+ * @deprecated
54
+ */
55
+ #isExcluded(operation, method) {
56
+ const { exclude = [] } = this.context;
57
+ let matched = false;
58
+ exclude.forEach(({ pattern, type }) => {
59
+ if (type === "tag" && !matched) {
60
+ matched = !!operation.getTags()[0]?.name.match(pattern);
61
+ }
62
+ if (type === "operationId" && !matched) {
63
+ matched = !!operation.getOperationId().match(pattern);
64
+ }
65
+ if (type === "path" && !matched) {
66
+ matched = !!operation.path.match(pattern);
67
+ }
68
+ if (type === "method" && !matched) {
69
+ matched = !!method.match(pattern);
70
+ }
71
+ });
72
+ return matched;
142
73
  }
143
- set operationsByMethod(paths) {
144
- __privateSet(this, _operationsByMethod, paths);
74
+ /**
75
+ *
76
+ * @deprecated
77
+ */
78
+ #isIncluded(operation, method) {
79
+ const { include = [] } = this.context;
80
+ let matched = false;
81
+ include.forEach(({ pattern, type }) => {
82
+ if (type === "tag" && !matched) {
83
+ matched = !!operation.getTags()[0]?.name.match(pattern);
84
+ }
85
+ if (type === "operationId" && !matched) {
86
+ matched = !!operation.getOperationId().match(pattern);
87
+ }
88
+ if (type === "path" && !matched) {
89
+ matched = !!operation.path.match(pattern);
90
+ }
91
+ if (type === "method" && !matched) {
92
+ matched = !!method.match(pattern);
93
+ }
94
+ });
95
+ return matched;
145
96
  }
146
- getSchemas(operation, { forStatusCode, resolveName = (name) => name } = {}) {
97
+ getSchemas(operation, {
98
+ forStatusCode,
99
+ resolveName = (name) => name
100
+ } = {}) {
147
101
  const pathParamsSchema = this.context.oas.getParametersSchema(operation, "path");
148
102
  const queryParamsSchema = this.context.oas.getParametersSchema(operation, "query");
149
103
  const headerParamsSchema = this.context.oas.getParametersSchema(operation, "header");
@@ -217,16 +171,17 @@ var OperationGenerator = class extends Generator {
217
171
  statusCodes
218
172
  };
219
173
  }
220
- async build() {
174
+ #methods = ["get", "post", "patch", "put", "delete"];
175
+ async build(...generators) {
221
176
  const { oas } = this.context;
222
177
  const paths = oas.getPaths();
223
178
  this.operationsByMethod = Object.entries(paths).reduce((acc, [path2, method]) => {
224
179
  const methods = Object.keys(method);
225
180
  methods.forEach((method2) => {
226
181
  const operation = oas.operation(path2, method2);
227
- if (operation && __privateGet(this, _OperationGenerator_instances, methods_get)[method2]) {
228
- const isExcluded = __privateMethod(this, _OperationGenerator_instances, isExcluded_fn).call(this, operation, method2);
229
- const isIncluded = this.context.include ? __privateMethod(this, _OperationGenerator_instances, isIncluded_fn).call(this, operation, method2) : true;
182
+ if (operation && [this.#methods].some((methods2) => method2 === operation.method)) {
183
+ const isExcluded = this.#isExcluded(operation, method2);
184
+ const isIncluded = this.context.include ? this.#isIncluded(operation, method2) : true;
230
185
  if (isIncluded && !isExcluded) {
231
186
  if (!acc[path2]) {
232
187
  acc[path2] = {};
@@ -247,26 +202,53 @@ var OperationGenerator = class extends Generator {
247
202
  const methods = this.operationsByMethod[path2] ? Object.keys(this.operationsByMethod[path2]) : [];
248
203
  methods.forEach((method) => {
249
204
  const { operation } = this.operationsByMethod[path2]?.[method];
250
- const options = __privateMethod(this, _OperationGenerator_instances, getOptions_fn).call(this, operation, method);
251
- const promiseMethod = __privateGet(this, _OperationGenerator_instances, methods_get)[method]?.call(this, operation, {
252
- ...this.options,
253
- ...options
254
- });
205
+ const options = this.#getOptions(operation, method);
206
+ const methodToCall = this[method];
207
+ if (typeof methodToCall === "function") {
208
+ const promiseMethod = methodToCall?.call(this, operation, {
209
+ ...this.options,
210
+ ...options
211
+ });
212
+ if (promiseMethod) {
213
+ acc.push(promiseMethod);
214
+ }
215
+ }
255
216
  const promiseOperation = this.operation.call(this, operation, {
256
217
  ...this.options,
257
218
  ...options
258
219
  });
259
- if (promiseMethod) {
260
- acc.push(promiseMethod);
261
- }
262
220
  if (promiseOperation) {
263
221
  acc.push(promiseOperation);
264
222
  }
223
+ generators?.forEach((generator) => {
224
+ const promise = generator.operation?.({
225
+ instance: this,
226
+ operation,
227
+ options: {
228
+ ...this.options,
229
+ ...options
230
+ }
231
+ });
232
+ if (promise) {
233
+ acc.push(promise);
234
+ }
235
+ });
265
236
  });
266
237
  return acc;
267
238
  }, []);
268
239
  const operations = Object.values(this.operationsByMethod).map((item) => Object.values(item).map((item2) => item2.operation));
269
240
  promises.push(this.all(operations.flat().filter(Boolean), this.operationsByMethod));
241
+ generators?.forEach((generator) => {
242
+ const promise = generator.operations?.({
243
+ instance: this,
244
+ operations: operations.flat().filter(Boolean),
245
+ operationsByMethod: this.operationsByMethod,
246
+ options: this.options
247
+ });
248
+ if (promise) {
249
+ promises.push(promise);
250
+ }
251
+ });
270
252
  const files = await Promise.all(promises);
271
253
  return files.flat().filter(Boolean);
272
254
  }
@@ -274,131 +256,200 @@ var OperationGenerator = class extends Generator {
274
256
  * Operation
275
257
  */
276
258
  async operation(operation, options) {
277
- return null;
259
+ return [];
278
260
  }
279
261
  /**
280
262
  * GET
281
263
  */
282
264
  async get(operation, options) {
283
- return null;
265
+ return [];
284
266
  }
285
267
  /**
286
268
  * POST
287
269
  */
288
270
  async post(operation, options) {
289
- return null;
271
+ return [];
290
272
  }
291
273
  /**
292
274
  * PATCH
293
275
  */
294
276
  async patch(operation, options) {
295
- return null;
277
+ return [];
296
278
  }
297
279
  /**
298
280
  * PUT
299
281
  */
300
282
  async put(operation, options) {
301
- return null;
283
+ return [];
302
284
  }
303
285
  /**
304
286
  * DELETE
305
287
  */
306
288
  async delete(operation, options) {
307
- return null;
289
+ return [];
308
290
  }
309
291
  /**
310
292
  * Combination of GET, POST, PATCH, PUT, DELETE
311
293
  */
312
294
  async all(operations, paths) {
313
- return null;
295
+ return [];
314
296
  }
315
297
  };
316
- _operationsByMethod = new WeakMap();
317
- _OperationGenerator_instances = new WeakSet();
318
- getOptions_fn = function(operation, method) {
319
- const { override = [] } = this.context;
320
- return override.find(({ pattern, type }) => {
321
- if (type === "tag") {
322
- return !!operation.getTags()[0]?.name.match(pattern);
323
- }
324
- if (type === "operationId") {
325
- return !!operation.getOperationId().match(pattern);
326
- }
327
- if (type === "path") {
328
- return !!operation.path.match(pattern);
329
- }
330
- if (type === "method") {
331
- return !!method.match(pattern);
332
- }
333
- return false;
334
- })?.options || {};
335
- };
336
- /**
337
- *
338
- * @deprecated
339
- */
340
- isExcluded_fn = function(operation, method) {
341
- const { exclude = [] } = this.context;
342
- let matched = false;
343
- exclude.forEach(({ pattern, type }) => {
344
- if (type === "tag" && !matched) {
345
- matched = !!operation.getTags()[0]?.name.match(pattern);
346
- }
347
- if (type === "operationId" && !matched) {
348
- matched = !!operation.getOperationId().match(pattern);
349
- }
350
- if (type === "path" && !matched) {
351
- matched = !!operation.path.match(pattern);
352
- }
353
- if (type === "method" && !matched) {
354
- matched = !!method.match(pattern);
355
- }
356
- });
357
- return matched;
358
- };
359
- /**
360
- *
361
- * @deprecated
362
- */
363
- isIncluded_fn = function(operation, method) {
364
- const { include = [] } = this.context;
365
- let matched = false;
366
- include.forEach(({ pattern, type }) => {
367
- if (type === "tag" && !matched) {
368
- matched = !!operation.getTags()[0]?.name.match(pattern);
369
- }
370
- if (type === "operationId" && !matched) {
371
- matched = !!operation.getOperationId().match(pattern);
372
- }
373
- if (type === "path" && !matched) {
374
- matched = !!operation.path.match(pattern);
375
- }
376
- if (type === "method" && !matched) {
377
- matched = !!method.match(pattern);
298
+
299
+ // src/plugin.ts
300
+ init_esm_shims();
301
+ import path from "node:path";
302
+ import { createPlugin } from "@kubb/core";
303
+ import { camelCase } from "@kubb/core/transformers";
304
+ var pluginOasName = "plugin-oas";
305
+ var pluginOas = createPlugin((options) => {
306
+ const {
307
+ output = { path: "schemas", export: false },
308
+ experimentalFilter: filter,
309
+ experimentalSort: sort,
310
+ validate = true,
311
+ serverIndex = 0,
312
+ contentType,
313
+ oasClass
314
+ } = options;
315
+ const getOas = async ({ config, logger, formatOptions }) => {
316
+ try {
317
+ const oas = await parseFromConfig(config, formatOptions, oasClass);
318
+ if (validate) {
319
+ await oas.valdiate();
320
+ }
321
+ return oas;
322
+ } catch (e) {
323
+ const error = e;
324
+ logger.emit("warning", error?.message);
325
+ return parseFromConfig(config, {}, oasClass);
378
326
  }
379
- });
380
- return matched;
381
- };
382
- methods_get = function() {
327
+ };
383
328
  return {
384
- get: this.get,
385
- post: this.post,
386
- patch: this.patch,
387
- put: this.put,
388
- delete: this.delete,
389
- head: void 0,
390
- options: void 0,
391
- trace: void 0
329
+ name: pluginOasName,
330
+ output: output === false ? {
331
+ path: "",
332
+ exportType: false
333
+ } : {
334
+ exportType: "barrelNamed",
335
+ ...output
336
+ },
337
+ options,
338
+ context() {
339
+ const { config, logger } = this;
340
+ return {
341
+ getOas(formatOptions) {
342
+ return getOas({ config, logger, formatOptions });
343
+ },
344
+ async getSchemas({ includes } = {}) {
345
+ const oas = await this.getOas();
346
+ return getSchemas({ oas, contentType, includes });
347
+ },
348
+ async getBaseURL() {
349
+ const oasInstance = await this.getOas();
350
+ const baseURL = oasInstance.api.servers?.at(serverIndex)?.url;
351
+ return baseURL;
352
+ },
353
+ contentType
354
+ };
355
+ },
356
+ async buildStart() {
357
+ if (!output) {
358
+ return;
359
+ }
360
+ const oas = await getOas({
361
+ config: this.config,
362
+ logger: this.logger,
363
+ formatOptions: {
364
+ filterSet: filter,
365
+ sortSet: sort
366
+ }
367
+ });
368
+ await oas.dereference();
369
+ const root = path.resolve(this.config.root, this.config.output.path);
370
+ const schemas = getSchemas({ oas, contentType });
371
+ const mapSchema = async ([name, schema]) => {
372
+ const baseName = `${camelCase(name)}.json`;
373
+ const resolvedPath = path.resolve(root, output.path, baseName);
374
+ await this.addFile({
375
+ path: resolvedPath,
376
+ baseName,
377
+ meta: {
378
+ pluginKey: this.plugin.key
379
+ },
380
+ sources: [
381
+ {
382
+ name: camelCase(name),
383
+ isExportable: false,
384
+ isIndexable: false,
385
+ value: JSON.stringify(schema)
386
+ }
387
+ ]
388
+ });
389
+ };
390
+ const promises = Object.entries(schemas).map(mapSchema);
391
+ await Promise.all(promises);
392
+ }
392
393
  };
393
- };
394
+ });
394
395
 
395
- // src/index.ts
396
- var definePluginDefault = pluginOas;
397
- var src_default = definePluginDefault;
396
+ // src/generator.tsx
397
+ init_esm_shims();
398
+ var import_jsx_runtime = __toESM(require_jsx_runtime(), 1);
399
+ import { App, createRoot } from "@kubb/react";
400
+ function createGenerator(parseOptions) {
401
+ return parseOptions;
402
+ }
403
+ function createReactGenerator(parseOptions) {
404
+ return {
405
+ ...parseOptions,
406
+ async operations({ instance, options, operations, operationsByMethod }) {
407
+ if (!parseOptions.Operations) {
408
+ return [];
409
+ }
410
+ const { pluginManager, oas, plugin, mode } = instance.context;
411
+ const root = createRoot({
412
+ logger: pluginManager.logger
413
+ });
414
+ root.render(
415
+ /* @__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 }) }) })
416
+ );
417
+ return root.files;
418
+ },
419
+ async operation({ instance, operation, options }) {
420
+ if (!parseOptions.Operation) {
421
+ return [];
422
+ }
423
+ const { pluginManager, oas, plugin, mode } = instance.context;
424
+ const root = createRoot({
425
+ logger: pluginManager.logger
426
+ });
427
+ root.render(
428
+ /* @__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 }) }) }) })
429
+ );
430
+ return root.files;
431
+ },
432
+ async schema({ instance, schema, name, options }) {
433
+ if (!parseOptions.Schema) {
434
+ return [];
435
+ }
436
+ const { pluginManager, oas, plugin, mode } = instance.context;
437
+ const root = createRoot({
438
+ logger: pluginManager.logger
439
+ });
440
+ const tree = instance.parse({ schema, name });
441
+ root.render(
442
+ /* @__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 }) }) }) })
443
+ );
444
+ return root.files;
445
+ }
446
+ };
447
+ }
398
448
  export {
399
449
  OperationGenerator,
400
450
  SchemaGenerator,
401
- src_default as default,
451
+ createGenerator,
452
+ createReactGenerator,
402
453
  isKeyword,
403
454
  pluginOas,
404
455
  pluginOasName,