@kubb/plugin-oas 3.0.0-alpha.6 → 3.0.0-alpha.8

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 (58) hide show
  1. package/dist/{OperationGenerator-Dzs1oRvm.d.ts → OperationGenerator-DeXrfGDC.d.ts} +2 -2
  2. package/dist/{OperationGenerator-Do52cvD0.d.cts → OperationGenerator-DhJ0MBKc.d.cts} +2 -2
  3. package/dist/{Schema-C90zFdkU.d.ts → Schema-B1vcPGiK.d.ts} +2 -4
  4. package/dist/{Schema-DDVEcNcu.d.cts → Schema-DoSFh7Qd.d.cts} +2 -4
  5. package/dist/{SchemaMapper-BM1IGWqD.d.cts → SchemaMapper-sGcY1xL5.d.cts} +0 -1
  6. package/dist/{SchemaMapper-BM1IGWqD.d.ts → SchemaMapper-sGcY1xL5.d.ts} +0 -1
  7. package/dist/chunk-75BIOXB7.cjs +7 -0
  8. package/dist/{chunk-7KIEQOVZ.cjs.map → chunk-75BIOXB7.cjs.map} +1 -1
  9. package/dist/{chunk-UJNAXXVE.js → chunk-MUI5DWM3.js} +458 -465
  10. package/dist/{chunk-UJNAXXVE.js.map → chunk-MUI5DWM3.js.map} +1 -1
  11. package/dist/{chunk-Y4V7HHX7.js → chunk-N7EEVJA6.js} +3 -3
  12. package/dist/{chunk-P42X362U.cjs → chunk-NU4F7G47.cjs} +4 -16
  13. package/dist/chunk-NU4F7G47.cjs.map +1 -0
  14. package/dist/{chunk-QLJIL3U5.cjs → chunk-O76YQFZB.cjs} +3 -3
  15. package/dist/{chunk-QLJIL3U5.cjs.map → chunk-O76YQFZB.cjs.map} +1 -1
  16. package/dist/{chunk-TWKZEVSM.js → chunk-SQ64ESS4.js} +2 -2
  17. package/dist/{chunk-UB552H4J.js → chunk-SZDO532A.js} +3 -15
  18. package/dist/{chunk-UB552H4J.js.map → chunk-SZDO532A.js.map} +1 -1
  19. package/dist/{chunk-RQZBFORW.cjs → chunk-VSVVTCQB.cjs} +481 -488
  20. package/dist/chunk-VSVVTCQB.cjs.map +1 -0
  21. package/dist/components.cjs +4 -4
  22. package/dist/components.d.cts +4 -4
  23. package/dist/components.d.ts +4 -4
  24. package/dist/components.js +3 -3
  25. package/dist/hooks.cjs +12 -12
  26. package/dist/hooks.cjs.map +1 -1
  27. package/dist/hooks.d.cts +3 -3
  28. package/dist/hooks.d.ts +3 -3
  29. package/dist/hooks.js +2 -2
  30. package/dist/hooks.js.map +1 -1
  31. package/dist/index.cjs +112 -115
  32. package/dist/index.cjs.map +1 -1
  33. package/dist/index.d.cts +4 -4
  34. package/dist/index.d.ts +4 -4
  35. package/dist/index.js +83 -86
  36. package/dist/index.js.map +1 -1
  37. package/dist/{types-C2RXaY0_.d.cts → types-CZTUCaE5.d.cts} +2 -0
  38. package/dist/{types-C2RXaY0_.d.ts → types-CZTUCaE5.d.ts} +2 -0
  39. package/dist/utils.cjs +9 -54
  40. package/dist/utils.cjs.map +1 -1
  41. package/dist/utils.d.cts +5 -35
  42. package/dist/utils.d.ts +5 -35
  43. package/dist/utils.js +2 -47
  44. package/dist/utils.js.map +1 -1
  45. package/package.json +9 -9
  46. package/src/SchemaGenerator.ts +2 -2
  47. package/src/SchemaMapper.ts +1 -1
  48. package/src/components/Schema.tsx +8 -4
  49. package/src/hooks/useOperationManager.ts +1 -0
  50. package/src/plugin.ts +11 -0
  51. package/src/types.ts +2 -0
  52. package/src/utils/index.ts +0 -1
  53. package/dist/chunk-7KIEQOVZ.cjs +0 -7
  54. package/dist/chunk-P42X362U.cjs.map +0 -1
  55. package/dist/chunk-RQZBFORW.cjs.map +0 -1
  56. package/src/utils/getGroupedByTagFiles.ts +0 -84
  57. /package/dist/{chunk-Y4V7HHX7.js.map → chunk-N7EEVJA6.js.map} +0 -0
  58. /package/dist/{chunk-TWKZEVSM.js.map → chunk-SQ64ESS4.js.map} +0 -0
package/dist/index.cjs CHANGED
@@ -1,43 +1,98 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
2
 
3
- var _chunkQLJIL3U5cjs = require('./chunk-QLJIL3U5.cjs');
4
- require('./chunk-7KIEQOVZ.cjs');
3
+ var _chunkO76YQFZBcjs = require('./chunk-O76YQFZB.cjs');
4
+ require('./chunk-75BIOXB7.cjs');
5
5
 
6
6
 
7
7
 
8
8
 
9
9
 
10
10
 
11
- var _chunkRQZBFORWcjs = require('./chunk-RQZBFORW.cjs');
11
+ var _chunkVSVVTCQBcjs = require('./chunk-VSVVTCQB.cjs');
12
12
 
13
13
 
14
14
 
15
15
 
16
-
17
-
18
-
19
-
20
- var _chunkP42X362Ucjs = require('./chunk-P42X362U.cjs');
16
+ var _chunkNU4F7G47cjs = require('./chunk-NU4F7G47.cjs');
21
17
 
22
18
  // src/index.ts
23
- _chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
19
+ _chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
24
20
 
25
21
  // src/OperationGenerator.ts
26
- _chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
22
+ _chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
27
23
  var _core = require('@kubb/core');
28
24
  var _transformers = require('@kubb/core/transformers'); var _transformers2 = _interopRequireDefault(_transformers);
29
- var _operationsByMethod, _OperationGenerator_instances, getOptions_fn, isExcluded_fn, isIncluded_fn;
30
25
  var OperationGenerator = class extends _core.Generator {
31
- constructor() {
32
- super(...arguments);
33
- _chunkP42X362Ucjs.__privateAdd.call(void 0, this, _OperationGenerator_instances);
34
- _chunkP42X362Ucjs.__privateAdd.call(void 0, this, _operationsByMethod, {});
35
- }
26
+ #operationsByMethod = {};
36
27
  get operationsByMethod() {
37
- return _chunkP42X362Ucjs.__privateGet.call(void 0, this, _operationsByMethod);
28
+ return this.#operationsByMethod;
38
29
  }
39
30
  set operationsByMethod(paths) {
40
- _chunkP42X362Ucjs.__privateSet.call(void 0, this, _operationsByMethod, paths);
31
+ this.#operationsByMethod = paths;
32
+ }
33
+ #getOptions(operation, method) {
34
+ const { override = [] } = this.context;
35
+ return _optionalChain([override, 'access', _ => _.find, 'call', _2 => _2(({ pattern, type }) => {
36
+ if (type === "tag") {
37
+ return !!_optionalChain([operation, 'access', _3 => _3.getTags, 'call', _4 => _4(), 'access', _5 => _5[0], 'optionalAccess', _6 => _6.name, 'access', _7 => _7.match, 'call', _8 => _8(pattern)]);
38
+ }
39
+ if (type === "operationId") {
40
+ return !!operation.getOperationId().match(pattern);
41
+ }
42
+ if (type === "path") {
43
+ return !!operation.path.match(pattern);
44
+ }
45
+ if (type === "method") {
46
+ return !!method.match(pattern);
47
+ }
48
+ return false;
49
+ }), 'optionalAccess', _9 => _9.options]) || {};
50
+ }
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 = !!_optionalChain([operation, 'access', _10 => _10.getTags, 'call', _11 => _11(), 'access', _12 => _12[0], 'optionalAccess', _13 => _13.name, 'access', _14 => _14.match, 'call', _15 => _15(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;
73
+ }
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 = !!_optionalChain([operation, 'access', _16 => _16.getTags, 'call', _17 => _17(), 'access', _18 => _18[0], 'optionalAccess', _19 => _19.name, 'access', _20 => _20.match, 'call', _21 => _21(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;
41
96
  }
42
97
  getSchemas(operation, {
43
98
  forStatusCode,
@@ -57,12 +112,12 @@ var OperationGenerator = class extends _core.Generator {
57
112
  const schema = this.context.oas.getResponseSchema(operation, statusCode);
58
113
  return {
59
114
  name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} ${name}`)),
60
- description: _optionalChain([operation, 'access', _ => _.getResponseByStatusCode, 'call', _2 => _2(statusCode), 'optionalAccess', _3 => _3.description]),
115
+ description: _optionalChain([operation, 'access', _22 => _22.getResponseByStatusCode, 'call', _23 => _23(statusCode), 'optionalAccess', _24 => _24.description]),
61
116
  schema,
62
117
  operation,
63
118
  operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
64
119
  statusCode: name === "error" ? void 0 : Number(statusCode),
65
- keys: _optionalChain([schema, 'optionalAccess', _4 => _4.properties]) ? Object.keys(schema.properties) : void 0
120
+ keys: _optionalChain([schema, 'optionalAccess', _25 => _25.properties]) ? Object.keys(schema.properties) : void 0
66
121
  };
67
122
  });
68
123
  return {
@@ -89,30 +144,30 @@ var OperationGenerator = class extends _core.Generator {
89
144
  } : void 0,
90
145
  request: requestSchema ? {
91
146
  name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryRequest" : "mutationRequest"}`)),
92
- description: _optionalChain([operation, 'access', _5 => _5.schema, 'access', _6 => _6.requestBody, 'optionalAccess', _7 => _7.description]),
147
+ description: _optionalChain([operation, 'access', _26 => _26.schema, 'access', _27 => _27.requestBody, 'optionalAccess', _28 => _28.description]),
93
148
  operation,
94
149
  operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
95
150
  schema: requestSchema,
96
151
  keys: requestSchema.properties ? Object.keys(requestSchema.properties) : void 0,
97
152
  keysToOmit: requestSchema.properties ? Object.keys(requestSchema.properties).filter((key) => {
98
- const item = _optionalChain([requestSchema, 'access', _8 => _8.properties, 'optionalAccess', _9 => _9[key]]);
99
- return _optionalChain([item, 'optionalAccess', _10 => _10.readOnly]);
153
+ const item = _optionalChain([requestSchema, 'access', _29 => _29.properties, 'optionalAccess', _30 => _30[key]]);
154
+ return _optionalChain([item, 'optionalAccess', _31 => _31.readOnly]);
100
155
  }) : void 0
101
156
  } : void 0,
102
157
  response: {
103
158
  name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryResponse" : "mutationResponse"}`)),
104
- description: _optionalChain([operation, 'access', _11 => _11.getResponseAsJSONSchema, 'call', _12 => _12(responseStatusCode), 'optionalAccess', _13 => _13.at, 'call', _14 => _14(0), 'optionalAccess', _15 => _15.description]),
159
+ description: _optionalChain([operation, 'access', _32 => _32.getResponseAsJSONSchema, 'call', _33 => _33(responseStatusCode), 'optionalAccess', _34 => _34.at, 'call', _35 => _35(0), 'optionalAccess', _36 => _36.description]),
105
160
  operation,
106
161
  operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
107
162
  schema: responseSchema,
108
163
  statusCode: Number(responseStatusCode),
109
- keys: _optionalChain([responseSchema, 'optionalAccess', _16 => _16.properties]) ? Object.keys(responseSchema.properties) : void 0,
110
- keysToOmit: _optionalChain([responseSchema, 'optionalAccess', _17 => _17.properties]) ? Object.keys(responseSchema.properties).filter((key) => {
111
- const item = _optionalChain([responseSchema, 'access', _18 => _18.properties, 'optionalAccess', _19 => _19[key]]);
112
- return _optionalChain([item, 'optionalAccess', _20 => _20.writeOnly]);
164
+ keys: _optionalChain([responseSchema, 'optionalAccess', _37 => _37.properties]) ? Object.keys(responseSchema.properties) : void 0,
165
+ keysToOmit: _optionalChain([responseSchema, 'optionalAccess', _38 => _38.properties]) ? Object.keys(responseSchema.properties).filter((key) => {
166
+ const item = _optionalChain([responseSchema, 'access', _39 => _39.properties, 'optionalAccess', _40 => _40[key]]);
167
+ return _optionalChain([item, 'optionalAccess', _41 => _41.writeOnly]);
113
168
  }) : void 0
114
169
  },
115
- errors: statusCodes.filter((item) => _optionalChain([item, 'access', _21 => _21.statusCode, 'optionalAccess', _22 => _22.toString, 'call', _23 => _23(), 'access', _24 => _24.startsWith, 'call', _25 => _25("4")]) || _optionalChain([item, 'access', _26 => _26.statusCode, 'optionalAccess', _27 => _27.toString, 'call', _28 => _28(), 'access', _29 => _29.startsWith, 'call', _30 => _30("5")])),
170
+ errors: statusCodes.filter((item) => _optionalChain([item, 'access', _42 => _42.statusCode, 'optionalAccess', _43 => _43.toString, 'call', _44 => _44(), 'access', _45 => _45.startsWith, 'call', _46 => _46("4")]) || _optionalChain([item, 'access', _47 => _47.statusCode, 'optionalAccess', _48 => _48.toString, 'call', _49 => _49(), 'access', _50 => _50.startsWith, 'call', _51 => _51("5")])),
116
171
  statusCodes
117
172
  };
118
173
  }
@@ -124,8 +179,8 @@ var OperationGenerator = class extends _core.Generator {
124
179
  methods.forEach((method2) => {
125
180
  const operation = oas.operation(path2, method2);
126
181
  if (operation) {
127
- const isExcluded = _chunkP42X362Ucjs.__privateMethod.call(void 0, this, _OperationGenerator_instances, isExcluded_fn).call(this, operation, method2);
128
- const isIncluded = this.context.include ? _chunkP42X362Ucjs.__privateMethod.call(void 0, this, _OperationGenerator_instances, isIncluded_fn).call(this, operation, method2) : true;
182
+ const isExcluded = this.#isExcluded(operation, method2);
183
+ const isIncluded = this.context.include ? this.#isIncluded(operation, method2) : true;
129
184
  if (isIncluded && !isExcluded) {
130
185
  if (!acc[path2]) {
131
186
  acc[path2] = {};
@@ -145,11 +200,11 @@ var OperationGenerator = class extends _core.Generator {
145
200
  const promises = Object.keys(this.operationsByMethod).reduce((acc, path2) => {
146
201
  const methods = this.operationsByMethod[path2] ? Object.keys(this.operationsByMethod[path2]) : [];
147
202
  methods.forEach((method) => {
148
- const { operation } = _optionalChain([this, 'access', _31 => _31.operationsByMethod, 'access', _32 => _32[path2], 'optionalAccess', _33 => _33[method]]);
149
- const options = _chunkP42X362Ucjs.__privateMethod.call(void 0, this, _OperationGenerator_instances, getOptions_fn).call(this, operation, method);
203
+ const { operation } = _optionalChain([this, 'access', _52 => _52.operationsByMethod, 'access', _53 => _53[path2], 'optionalAccess', _54 => _54[method]]);
204
+ const options = this.#getOptions(operation, method);
150
205
  const methodToCall = this[method];
151
206
  if (typeof methodToCall === "function") {
152
- const promiseMethod = _optionalChain([methodToCall, 'optionalAccess', _34 => _34.call, 'call', _35 => _35(this, operation, {
207
+ const promiseMethod = _optionalChain([methodToCall, 'optionalAccess', _55 => _55.call, 'call', _56 => _56(this, operation, {
153
208
  ...this.options,
154
209
  ...options
155
210
  })]);
@@ -164,8 +219,8 @@ var OperationGenerator = class extends _core.Generator {
164
219
  if (promiseOperation) {
165
220
  acc.push(promiseOperation);
166
221
  }
167
- _optionalChain([parsers, 'optionalAccess', _36 => _36.forEach, 'call', _37 => _37((parser) => {
168
- const promise = _optionalChain([parser, 'access', _38 => _38.operation, 'optionalCall', _39 => _39({
222
+ _optionalChain([parsers, 'optionalAccess', _57 => _57.forEach, 'call', _58 => _58((parser) => {
223
+ const promise = _optionalChain([parser, 'access', _59 => _59.operation, 'optionalCall', _60 => _60({
169
224
  instance: this,
170
225
  operation,
171
226
  options: {
@@ -182,8 +237,8 @@ var OperationGenerator = class extends _core.Generator {
182
237
  }, []);
183
238
  const operations = Object.values(this.operationsByMethod).map((item) => Object.values(item).map((item2) => item2.operation));
184
239
  promises.push(this.all(operations.flat().filter(Boolean), this.operationsByMethod));
185
- _optionalChain([parsers, 'optionalAccess', _40 => _40.forEach, 'call', _41 => _41((parser) => {
186
- const promise = _optionalChain([parser, 'access', _42 => _42.operations, 'optionalCall', _43 => _43({
240
+ _optionalChain([parsers, 'optionalAccess', _61 => _61.forEach, 'call', _62 => _62((parser) => {
241
+ const promise = _optionalChain([parser, 'access', _63 => _63.operations, 'optionalCall', _64 => _64({
187
242
  instance: this,
188
243
  operations: operations.flat().filter(Boolean),
189
244
  operationsByMethod: this.operationsByMethod,
@@ -239,75 +294,9 @@ var OperationGenerator = class extends _core.Generator {
239
294
  return [];
240
295
  }
241
296
  };
242
- _operationsByMethod = new WeakMap();
243
- _OperationGenerator_instances = new WeakSet();
244
- getOptions_fn = function(operation, method) {
245
- const { override = [] } = this.context;
246
- return _optionalChain([override, 'access', _44 => _44.find, 'call', _45 => _45(({ pattern, type }) => {
247
- if (type === "tag") {
248
- return !!_optionalChain([operation, 'access', _46 => _46.getTags, 'call', _47 => _47(), 'access', _48 => _48[0], 'optionalAccess', _49 => _49.name, 'access', _50 => _50.match, 'call', _51 => _51(pattern)]);
249
- }
250
- if (type === "operationId") {
251
- return !!operation.getOperationId().match(pattern);
252
- }
253
- if (type === "path") {
254
- return !!operation.path.match(pattern);
255
- }
256
- if (type === "method") {
257
- return !!method.match(pattern);
258
- }
259
- return false;
260
- }), 'optionalAccess', _52 => _52.options]) || {};
261
- };
262
- /**
263
- *
264
- * @deprecated
265
- */
266
- isExcluded_fn = function(operation, method) {
267
- const { exclude = [] } = this.context;
268
- let matched = false;
269
- exclude.forEach(({ pattern, type }) => {
270
- if (type === "tag" && !matched) {
271
- matched = !!_optionalChain([operation, 'access', _53 => _53.getTags, 'call', _54 => _54(), 'access', _55 => _55[0], 'optionalAccess', _56 => _56.name, 'access', _57 => _57.match, 'call', _58 => _58(pattern)]);
272
- }
273
- if (type === "operationId" && !matched) {
274
- matched = !!operation.getOperationId().match(pattern);
275
- }
276
- if (type === "path" && !matched) {
277
- matched = !!operation.path.match(pattern);
278
- }
279
- if (type === "method" && !matched) {
280
- matched = !!method.match(pattern);
281
- }
282
- });
283
- return matched;
284
- };
285
- /**
286
- *
287
- * @deprecated
288
- */
289
- isIncluded_fn = function(operation, method) {
290
- const { include = [] } = this.context;
291
- let matched = false;
292
- include.forEach(({ pattern, type }) => {
293
- if (type === "tag" && !matched) {
294
- matched = !!_optionalChain([operation, 'access', _59 => _59.getTags, 'call', _60 => _60(), 'access', _61 => _61[0], 'optionalAccess', _62 => _62.name, 'access', _63 => _63.match, 'call', _64 => _64(pattern)]);
295
- }
296
- if (type === "operationId" && !matched) {
297
- matched = !!operation.getOperationId().match(pattern);
298
- }
299
- if (type === "path" && !matched) {
300
- matched = !!operation.path.match(pattern);
301
- }
302
- if (type === "method" && !matched) {
303
- matched = !!method.match(pattern);
304
- }
305
- });
306
- return matched;
307
- };
308
297
 
309
298
  // src/plugin.ts
310
- _chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
299
+ _chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
311
300
  var _path = require('path'); var _path2 = _interopRequireDefault(_path);
312
301
 
313
302
 
@@ -324,7 +313,7 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
324
313
  } = options;
325
314
  const getOas = async ({ config, logger, formatOptions }) => {
326
315
  try {
327
- const oas = await _chunkQLJIL3U5cjs.parseFromConfig.call(void 0, config, formatOptions, oasClass);
316
+ const oas = await _chunkO76YQFZBcjs.parseFromConfig.call(void 0, config, formatOptions, oasClass);
328
317
  if (validate) {
329
318
  await oas.valdiate();
330
319
  }
@@ -332,11 +321,18 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
332
321
  } catch (e) {
333
322
  const error = e;
334
323
  logger.emit("warning", _optionalChain([error, 'optionalAccess', _65 => _65.message]));
335
- return _chunkQLJIL3U5cjs.parseFromConfig.call(void 0, config, {}, oasClass);
324
+ return _chunkO76YQFZBcjs.parseFromConfig.call(void 0, config, {}, oasClass);
336
325
  }
337
326
  };
338
327
  return {
339
328
  name: pluginOasName,
329
+ output: output === false ? {
330
+ path: "",
331
+ exportType: false
332
+ } : {
333
+ exportType: "barrelNamed",
334
+ ...output
335
+ },
340
336
  options,
341
337
  context() {
342
338
  const { config, logger } = this;
@@ -346,7 +342,7 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
346
342
  },
347
343
  async getSchemas({ includes } = {}) {
348
344
  const oas = await this.getOas();
349
- return _chunkP42X362Ucjs.getSchemas.call(void 0, { oas, contentType, includes });
345
+ return _chunkNU4F7G47cjs.getSchemas.call(void 0, { oas, contentType, includes });
350
346
  },
351
347
  async getBaseURL() {
352
348
  const oasInstance = await this.getOas();
@@ -370,7 +366,7 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
370
366
  });
371
367
  await oas.dereference();
372
368
  const root = _path2.default.resolve(this.config.root, this.config.output.path);
373
- const schemas = _chunkP42X362Ucjs.getSchemas.call(void 0, { oas, contentType });
369
+ const schemas = _chunkNU4F7G47cjs.getSchemas.call(void 0, { oas, contentType });
374
370
  const mapSchema = async ([name, schema]) => {
375
371
  const baseName = `${_transformers.camelCase.call(void 0, name)}.json`;
376
372
  const resolvedPath = _path2.default.resolve(root, output.path, baseName);
@@ -384,6 +380,7 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
384
380
  {
385
381
  name: _transformers.camelCase.call(void 0, name),
386
382
  isExportable: false,
383
+ isIndexable: false,
387
384
  value: JSON.stringify(schema)
388
385
  }
389
386
  ]
@@ -396,9 +393,9 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
396
393
  });
397
394
 
398
395
  // src/parser.tsx
399
- _chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
396
+ _chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
400
397
  var _react = require('@kubb/react');
401
- var import_jsx_runtime = _chunkP42X362Ucjs.__toESM.call(void 0, _chunkRQZBFORWcjs.require_jsx_runtime.call(void 0, ), 1);
398
+ var import_jsx_runtime = _chunkNU4F7G47cjs.__toESM.call(void 0, _chunkVSVVTCQBcjs.require_jsx_runtime.call(void 0, ), 1);
402
399
  function createParser(parseOptions) {
403
400
  return parseOptions;
404
401
  }
@@ -414,7 +411,7 @@ function createReactParser(parseOptions) {
414
411
  logger: pluginManager.logger
415
412
  });
416
413
  root.render(
417
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_react.App, { pluginManager, plugin, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunkRQZBFORWcjs.Oas, { oas, operations, generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Operations, { operations, instance, operationsByMethod, options }) }) })
414
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_react.App, { pluginManager, plugin, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunkVSVVTCQBcjs.Oas, { oas, operations, generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Operations, { operations, instance, operationsByMethod, options }) }) })
418
415
  );
419
416
  return root.files;
420
417
  },
@@ -427,7 +424,7 @@ function createReactParser(parseOptions) {
427
424
  logger: pluginManager.logger
428
425
  });
429
426
  root.render(
430
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunkRQZBFORWcjs.Oas, { oas, operations: [operation], generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunkRQZBFORWcjs.Oas.Operation, { operation, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Operation, { operation, options, instance }) }) }) })
427
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunkVSVVTCQBcjs.Oas, { oas, operations: [operation], generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunkVSVVTCQBcjs.Oas.Operation, { operation, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Operation, { operation, options, instance }) }) }) })
431
428
  );
432
429
  return root.files;
433
430
  },
@@ -441,7 +438,7 @@ function createReactParser(parseOptions) {
441
438
  });
442
439
  const tree = instance.parse({ schema, name });
443
440
  root.render(
444
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunkRQZBFORWcjs.Oas, { oas, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunkRQZBFORWcjs.Oas.Schema, { name, value: schema, tree, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Schema, { schema, options, instance, name }) }) }) })
441
+ /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunkVSVVTCQBcjs.Oas, { oas, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunkVSVVTCQBcjs.Oas.Schema, { name, value: schema, tree, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Schema, { schema, options, instance, name }) }) }) })
445
442
  );
446
443
  return root.files;
447
444
  }
@@ -456,5 +453,5 @@ function createReactParser(parseOptions) {
456
453
 
457
454
 
458
455
 
459
- exports.OperationGenerator = OperationGenerator; exports.SchemaGenerator = _chunkRQZBFORWcjs.SchemaGenerator; exports.createParser = createParser; exports.createReactParser = createReactParser; exports.isKeyword = _chunkRQZBFORWcjs.isKeyword; exports.pluginOas = pluginOas; exports.pluginOasName = pluginOasName; exports.schemaKeywords = _chunkRQZBFORWcjs.schemaKeywords;
456
+ exports.OperationGenerator = OperationGenerator; exports.SchemaGenerator = _chunkVSVVTCQBcjs.SchemaGenerator; exports.createParser = createParser; exports.createReactParser = createReactParser; exports.isKeyword = _chunkVSVVTCQBcjs.isKeyword; exports.pluginOas = pluginOas; exports.pluginOasName = pluginOasName; exports.schemaKeywords = _chunkVSVVTCQBcjs.schemaKeywords;
460
457
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-oas/dist/index.cjs","../src/index.ts","../src/OperationGenerator.ts","../src/plugin.ts","../src/parser.tsx"],"names":["method"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACrBA,8CAAA,CAAA;ADuBA;AACA;AExBA,8CAAA,CAAA;AAAA,kCAA6C;AAC7C,mHAAyB;AADzB,IAAA,mBAAA,EAAA,6BAAA,EAAA,aAAA,EAAA,aAAA,EAAA,aAAA;AA6BO,IAAM,mBAAA,EAAN,MAAA,QAIG,gBAAuD;AAAA,EAJ1D,WAAA,CAAA,EAAA;AAAA,IAAA,KAAA,CAAA,GAAA,SAAA,CAAA;AAAA,IAAA,4CAAA,IAAA,EAAA,6BAAA,CAAA;AAKL,IAAA,4CAAA,IAAA,EAAA,mBAAA,EAA0C,CAAC,CAAA,CAAA;AAAA,EAAA;AAAA,EAC3C,IAAI,kBAAA,CAAA,EAAyC;AAC3C,IAAA,OAAO,4CAAA,IAAA,EAAK,mBAAA,CAAA;AAAA,EACd;AAAA,EAEA,IAAI,kBAAA,CAAmB,KAAA,EAA2B;AAChD,IAAA,4CAAA,IAAA,EAAK,mBAAA,EAAsB,KAAA,CAAA;AAAA,EAC7B;AAAA,EAsFA,UAAA,CACE,SAAA,EACA;AAAA,IACE,aAAA;AAAA,IACA,YAAA,EAAc,CAAC,IAAA,EAAA,GAAS;AAAA,EAC1B,EAAA,EAGI,CAAC,CAAA,EACa;AAClB,IAAA,MAAM,iBAAA,EAAmB,IAAA,CAAK,OAAA,CAAQ,GAAA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AA3BiH;AACpH,EAAA;AACT;AASuI;AAC9H,EAAA;AACF,IAAA;AACmC,IAAA;AACN,MAAA;AACpB,QAAA;AACV,MAAA;AAE6C,MAAA;AACrB,MAAA;AACA,QAAA;AACvB,MAAA;AAEI,MAAA;AACH,wBAAA;AAKF,MAAA;AAEY,MAAA;AACd,IAAA;AAC+C,IAAA;AAChB,MAAA;AACnB,QAAA;AACV,MAAA;AAE6C,MAAA;AACrB,MAAA;AACA,QAAA;AACvB,MAAA;AAEI,MAAA;AACH,wBAAA;AAOF,MAAA;AAEY,MAAA;AACd,IAAA;AAC+C,IAAA;AACnB,MAAA;AAChB,QAAA;AACV,MAAA;AAE6C,MAAA;AACrB,MAAA;AACA,QAAA;AACvB,MAAA;AAE2C,MAAA;AAEvC,MAAA;AACH,wBAAA;AAOF,MAAA;AAEY,MAAA;AACd,IAAA;AACF,EAAA;AACF;AJyUmD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/plugin-oas/dist/index.cjs","sourcesContent":[null,"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'\nimport { parseFromConfig } from './utils/parseFromConfig.ts'\n\nimport type { Config } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\nimport type { Oas, OasTypes } from '@kubb/oas'\nimport type { FormatOptions } from '@kubb/oas/parser'\nimport type { PluginOas } from './types.ts'\n\nexport const pluginOasName = 'plugin-oas' satisfies PluginOas['name']\n\nexport const pluginOas = createPlugin<PluginOas>((options) => {\n const {\n output = { path: 'schemas', export: false },\n experimentalFilter: filter,\n experimentalSort: sort,\n validate = true,\n serverIndex = 0,\n contentType,\n oasClass,\n } = options\n\n const getOas = async ({ config, logger, formatOptions }: { config: Config; logger: Logger; formatOptions?: FormatOptions }): Promise<Oas> => {\n try {\n // needs to be in a different variable or the catch here will not work(return of a promise instead)\n const oas = await parseFromConfig(config, formatOptions, oasClass)\n\n if (validate) {\n await oas.valdiate()\n }\n\n return oas\n } catch (e) {\n const error = e as Error\n\n logger.emit('warning', error?.message)\n return parseFromConfig(config, {}, oasClass)\n }\n }\n\n return {\n name: pluginOasName,\n options,\n context() {\n const { config, logger } = this\n\n return {\n getOas(formatOptions) {\n return getOas({ config, logger, formatOptions })\n },\n async getSchemas({ includes } = {}) {\n const oas = await this.getOas()\n return getSchemas({ oas, contentType, includes })\n },\n async getBaseURL() {\n const oasInstance = await this.getOas()\n const baseURL = oasInstance.api.servers?.at(serverIndex)?.url\n return baseURL\n },\n contentType,\n }\n },\n async buildStart() {\n if (!output) {\n return\n }\n\n const oas = await getOas({\n config: this.config,\n logger: this.logger,\n formatOptions: {\n filterSet: filter,\n sortSet: sort,\n },\n })\n await oas.dereference()\n\n const root = path.resolve(this.config.root, this.config.output.path)\n const schemas = getSchemas({ oas, contentType })\n\n const mapSchema = async ([name, schema]: [string, OasTypes.SchemaObject]) => {\n const baseName = `${camelCase(name)}.json` as `${string}.json`\n const resolvedPath = path.resolve(root, output.path, baseName)\n\n await this.addFile({\n path: resolvedPath,\n baseName,\n meta: {\n pluginKey: this.plugin.key,\n },\n sources: [\n {\n name: camelCase(name),\n isExportable: false,\n value: JSON.stringify(schema),\n },\n ],\n })\n }\n\n const promises = Object.entries(schemas).map(mapSchema)\n await Promise.all(promises)\n },\n }\n})\n","import type { PluginFactoryOptions } from '@kubb/core'\nimport type { Operation, SchemaObject } from '@kubb/oas'\nimport { App, createRoot } from '@kubb/react'\nimport type { KubbNode } from '@kubb/react/types'\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>,\n )\n\n return root.files\n },\n }\n}\n"]}
1
+ {"version":3,"sources":["/home/runner/work/kubb/kubb/packages/plugin-oas/dist/index.cjs","../src/index.ts","../src/OperationGenerator.ts","../src/plugin.ts","../src/parser.tsx"],"names":["method"],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B,gCAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACF,wDAA6B;AAC7B;AACA;ACjBA,8CAAA,CAAA;ADmBA;AACA;AEpBA,8CAAA,CAAA;AAAA,kCAA6C;AAC7C,mHAAyB;AA4BlB,IAAM,mBAAA,EAAN,MAAA,QAIG,gBAAuD;AAAA,E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UAAA;AACF,UAAA;AACX,QAAA;AACD,MAAA;AACqB,MAAA;AAEsB,MAAA;AACV,MAAA;AAE2C,MAAA;AACxC,QAAA;AACK,QAAA;AAErB,QAAA;AACX,UAAA;AACN,UAAA;AACM,UAAA;AACmB,YAAA;AACzB,UAAA;AACS,UAAA;AACP,YAAA;AACsB,cAAA;AACN,cAAA;AACD,cAAA;AACe,cAAA;AAC9B,YAAA;AACF,UAAA;AACD,QAAA;AACH,MAAA;AAE6C,MAAA;AACnB,MAAA;AAC5B,IAAA;AACF,EAAA;AACD;AHiRkD;AACA;AI1YnD;AAEgC;AAgEpB;AA3BiH;AACpH,EAAA;AACT;AASuI;AAC9H,EAAA;AACF,IAAA;AACmC,IAAA;AACN,MAAA;AACpB,QAAA;AACV,MAAA;AAE6C,MAAA;AACrB,MAAA;AACA,QAAA;AACvB,MAAA;AAEI,MAAA;AACH,wBAAA;AAKF,MAAA;AAEY,MAAA;AACd,IAAA;AAC+C,IAAA;AAChB,MAAA;AACnB,QAAA;AACV,MAAA;AAE6C,MAAA;AACrB,MAAA;AACA,QAAA;AACvB,MAAA;AAEI,MAAA;AACH,wBAAA;AAOF,MAAA;AAEY,MAAA;AACd,IAAA;AAC+C,IAAA;AACnB,MAAA;AAChB,QAAA;AACV,MAAA;AAE6C,MAAA;AACrB,MAAA;AACA,QAAA;AACvB,MAAA;AAE2C,MAAA;AAEvC,MAAA;AACH,wBAAA;AAOF,MAAA;AAEY,MAAA;AACd,IAAA;AACF,EAAA;AACF;AJsUmD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/home/runner/work/kubb/kubb/packages/plugin-oas/dist/index.cjs","sourcesContent":[null,"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'\nimport { parseFromConfig } from './utils/parseFromConfig.ts'\n\nimport type { Config } from '@kubb/core'\nimport type { Logger } from '@kubb/core/logger'\nimport type { Oas, OasTypes } from '@kubb/oas'\nimport type { FormatOptions } from '@kubb/oas/parser'\nimport type { PluginOas } from './types.ts'\n\nexport const pluginOasName = 'plugin-oas' satisfies PluginOas['name']\n\nexport const pluginOas = createPlugin<PluginOas>((options) => {\n const {\n output = { path: 'schemas', export: false },\n experimentalFilter: filter,\n experimentalSort: sort,\n validate = true,\n serverIndex = 0,\n contentType,\n oasClass,\n } = options\n\n const getOas = async ({ config, logger, formatOptions }: { config: Config; logger: Logger; formatOptions?: FormatOptions }): Promise<Oas> => {\n try {\n // needs to be in a different variable or the catch here will not work(return of a promise instead)\n const oas = await parseFromConfig(config, formatOptions, oasClass)\n\n if (validate) {\n await oas.valdiate()\n }\n\n return oas\n } catch (e) {\n const error = e as Error\n\n logger.emit('warning', error?.message)\n return parseFromConfig(config, {}, oasClass)\n }\n }\n\n return {\n name: pluginOasName,\n output:\n output === false\n ? {\n path: '',\n exportType: false,\n }\n : {\n exportType: 'barrelNamed',\n ...output,\n },\n options,\n context() {\n const { config, logger } = this\n\n return {\n getOas(formatOptions) {\n return getOas({ config, logger, formatOptions })\n },\n async getSchemas({ includes } = {}) {\n const oas = await this.getOas()\n return getSchemas({ oas, contentType, includes })\n },\n async getBaseURL() {\n const oasInstance = await this.getOas()\n const baseURL = oasInstance.api.servers?.at(serverIndex)?.url\n return baseURL\n },\n contentType,\n }\n },\n async buildStart() {\n if (!output) {\n return\n }\n\n const oas = await getOas({\n config: this.config,\n logger: this.logger,\n formatOptions: {\n filterSet: filter,\n sortSet: sort,\n },\n })\n await oas.dereference()\n\n const root = path.resolve(this.config.root, this.config.output.path)\n const schemas = getSchemas({ oas, contentType })\n\n const mapSchema = async ([name, schema]: [string, OasTypes.SchemaObject]) => {\n const baseName = `${camelCase(name)}.json` as `${string}.json`\n const resolvedPath = path.resolve(root, output.path, baseName)\n\n await this.addFile({\n path: resolvedPath,\n baseName,\n meta: {\n pluginKey: this.plugin.key,\n },\n sources: [\n {\n name: camelCase(name),\n isExportable: false,\n isIndexable: false,\n value: JSON.stringify(schema),\n },\n ],\n })\n }\n\n const promises = Object.entries(schemas).map(mapSchema)\n await Promise.all(promises)\n },\n }\n})\n","import type { PluginFactoryOptions } from '@kubb/core'\nimport type { Operation, SchemaObject } from '@kubb/oas'\nimport { App, createRoot } from '@kubb/react'\nimport type { KubbNode } from '@kubb/react/types'\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>,\n )\n\n return root.files\n },\n }\n}\n"]}
package/dist/index.d.cts CHANGED
@@ -1,8 +1,8 @@
1
- export { G as GetOperationGeneratorOptions, b as GetSchemaGeneratorOptions, a as OperationGenerator, O as OperationMethodResult, h as Parser, i as ParserOptions, P as ParserReactOptions, e as SchemaGenerator, S as SchemaGeneratorBuildOptions, c as SchemaGeneratorOptions, d as SchemaMethodResult, f as createParser, g as createReactParser } from './OperationGenerator-Do52cvD0.cjs';
1
+ export { G as GetOperationGeneratorOptions, b as GetSchemaGeneratorOptions, a as OperationGenerator, O as OperationMethodResult, h as Parser, i as ParserOptions, P as ParserReactOptions, e as SchemaGenerator, S as SchemaGeneratorBuildOptions, c as SchemaGeneratorOptions, d as SchemaMethodResult, f as createParser, g as createReactParser } from './OperationGenerator-DhJ0MBKc.cjs';
2
2
  import * as _kubb_core from '@kubb/core';
3
- import { O as Options, P as PluginOas } from './types-C2RXaY0_.cjs';
4
- export { A as API, E as Exclude, I as Include, d as OperationSchema, e as OperationSchemas, f as OperationsByMethod, g as Override, a as Ref, b as Refs, R as ResolvePathOptions, c as Resolver } from './types-C2RXaY0_.cjs';
5
- export { S as Schema, a as SchemaKeyword, b as SchemaKeywordBase, c as SchemaKeywordMapper, d as SchemaMapper, i as isKeyword, s as schemaKeywords } from './SchemaMapper-BM1IGWqD.cjs';
3
+ import { O as Options, P as PluginOas } from './types-CZTUCaE5.cjs';
4
+ export { A as API, E as Exclude, I as Include, d as OperationSchema, e as OperationSchemas, f as OperationsByMethod, g as Override, a as Ref, b as Refs, R as ResolvePathOptions, c as Resolver } from './types-CZTUCaE5.cjs';
5
+ export { S as Schema, a as SchemaKeyword, b as SchemaKeywordBase, c as SchemaKeywordMapper, d as SchemaMapper, i as isKeyword, s as schemaKeywords } from './SchemaMapper-sGcY1xL5.cjs';
6
6
  import '@kubb/fs/types';
7
7
  import '@kubb/oas';
8
8
  import '@kubb/react/types';
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- export { G as GetOperationGeneratorOptions, b as GetSchemaGeneratorOptions, a as OperationGenerator, O as OperationMethodResult, h as Parser, i as ParserOptions, P as ParserReactOptions, e as SchemaGenerator, S as SchemaGeneratorBuildOptions, c as SchemaGeneratorOptions, d as SchemaMethodResult, f as createParser, g as createReactParser } from './OperationGenerator-Dzs1oRvm.js';
1
+ export { G as GetOperationGeneratorOptions, b as GetSchemaGeneratorOptions, a as OperationGenerator, O as OperationMethodResult, h as Parser, i as ParserOptions, P as ParserReactOptions, e as SchemaGenerator, S as SchemaGeneratorBuildOptions, c as SchemaGeneratorOptions, d as SchemaMethodResult, f as createParser, g as createReactParser } from './OperationGenerator-DeXrfGDC.js';
2
2
  import * as _kubb_core from '@kubb/core';
3
- import { O as Options, P as PluginOas } from './types-C2RXaY0_.js';
4
- export { A as API, E as Exclude, I as Include, d as OperationSchema, e as OperationSchemas, f as OperationsByMethod, g as Override, a as Ref, b as Refs, R as ResolvePathOptions, c as Resolver } from './types-C2RXaY0_.js';
5
- export { S as Schema, a as SchemaKeyword, b as SchemaKeywordBase, c as SchemaKeywordMapper, d as SchemaMapper, i as isKeyword, s as schemaKeywords } from './SchemaMapper-BM1IGWqD.js';
3
+ import { O as Options, P as PluginOas } from './types-CZTUCaE5.js';
4
+ export { A as API, E as Exclude, I as Include, d as OperationSchema, e as OperationSchemas, f as OperationsByMethod, g as Override, a as Ref, b as Refs, R as ResolvePathOptions, c as Resolver } from './types-CZTUCaE5.js';
5
+ export { S as Schema, a as SchemaKeyword, b as SchemaKeywordBase, c as SchemaKeywordMapper, d as SchemaMapper, i as isKeyword, s as schemaKeywords } from './SchemaMapper-sGcY1xL5.js';
6
6
  import '@kubb/fs/types';
7
7
  import '@kubb/oas';
8
8
  import '@kubb/react/types';