@kubb/plugin-oas 3.0.0-alpha.9 → 3.0.0-beta.1

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 (99) hide show
  1. package/README.md +14 -5
  2. package/dist/OperationGenerator-BgQeGRzk.d.cts +550 -0
  3. package/dist/OperationGenerator-BgQeGRzk.d.ts +550 -0
  4. package/dist/{Schema-B1vcPGiK.d.ts → Schema-1iM2I0dK.d.ts} +1 -12
  5. package/dist/{Schema-DoSFh7Qd.d.cts → Schema-5o-c5UOy.d.cts} +1 -12
  6. package/dist/chunk-ABOQ73FL.cjs +36 -0
  7. package/dist/chunk-ABOQ73FL.cjs.map +1 -0
  8. package/dist/chunk-BG77DP54.js +30 -0
  9. package/dist/chunk-BG77DP54.js.map +1 -0
  10. package/dist/chunk-GF26SDHQ.js +28 -0
  11. package/dist/chunk-GF26SDHQ.js.map +1 -0
  12. package/dist/chunk-PADR76WZ.cjs +4 -0
  13. package/dist/chunk-PADR76WZ.cjs.map +1 -0
  14. package/dist/chunk-QAFBZLJA.cjs +48 -0
  15. package/dist/chunk-QAFBZLJA.cjs.map +1 -0
  16. package/dist/chunk-QT6ZFRNJ.cjs +752 -0
  17. package/dist/chunk-QT6ZFRNJ.cjs.map +1 -0
  18. package/dist/chunk-QWO5NQGQ.js +88 -0
  19. package/dist/chunk-QWO5NQGQ.js.map +1 -0
  20. package/dist/chunk-R47XMJ32.js +3 -0
  21. package/dist/chunk-R47XMJ32.js.map +1 -0
  22. package/dist/chunk-SR63CBLH.cjs +92 -0
  23. package/dist/chunk-SR63CBLH.cjs.map +1 -0
  24. package/dist/chunk-V2JO6RHI.js +744 -0
  25. package/dist/chunk-V2JO6RHI.js.map +1 -0
  26. package/dist/chunk-XNCEFOE6.js +45 -0
  27. package/dist/chunk-XNCEFOE6.js.map +1 -0
  28. package/dist/chunk-ZWHQ54JM.cjs +32 -0
  29. package/dist/chunk-ZWHQ54JM.cjs.map +1 -0
  30. package/dist/components.cjs +20 -12
  31. package/dist/components.cjs.map +1 -1
  32. package/dist/components.d.cts +3 -6
  33. package/dist/components.d.ts +3 -6
  34. package/dist/components.js +3 -12
  35. package/dist/components.js.map +1 -1
  36. package/dist/generators.cjs +14 -0
  37. package/dist/generators.cjs.map +1 -0
  38. package/dist/generators.d.cts +9 -0
  39. package/dist/generators.d.ts +9 -0
  40. package/dist/generators.js +5 -0
  41. package/dist/generators.js.map +1 -0
  42. package/dist/hooks.cjs +102 -57
  43. package/dist/hooks.cjs.map +1 -1
  44. package/dist/hooks.d.cts +41 -10
  45. package/dist/hooks.d.ts +41 -10
  46. package/dist/hooks.js +91 -53
  47. package/dist/hooks.js.map +1 -1
  48. package/dist/index.cjs +134 -185
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.d.cts +2 -5
  51. package/dist/index.d.ts +2 -5
  52. package/dist/index.js +68 -146
  53. package/dist/index.js.map +1 -1
  54. package/dist/utils.cjs +32 -45
  55. package/dist/utils.cjs.map +1 -1
  56. package/dist/utils.d.cts +4 -13
  57. package/dist/utils.d.ts +4 -13
  58. package/dist/utils.js +8 -44
  59. package/dist/utils.js.map +1 -1
  60. package/package.json +20 -14
  61. package/src/OperationGenerator.ts +11 -23
  62. package/src/SchemaGenerator.ts +68 -9
  63. package/src/SchemaMapper.ts +6 -4
  64. package/src/components/Schema.tsx +1 -99
  65. package/src/generator.tsx +22 -18
  66. package/src/generators/index.ts +1 -0
  67. package/src/generators/jsonGenerator.ts +32 -0
  68. package/src/hooks/index.ts +2 -0
  69. package/src/hooks/useOperationManager.ts +77 -30
  70. package/src/hooks/useSchemaManager.ts +77 -0
  71. package/src/plugin.ts +69 -56
  72. package/src/types.ts +24 -18
  73. package/src/utils/getParams.ts +1 -1
  74. package/src/utils/getSchemaFactory.ts +1 -1
  75. package/src/utils/index.ts +0 -1
  76. package/src/utils/parseFromConfig.ts +7 -7
  77. package/dist/OperationGenerator-By5WOmWB.d.ts +0 -165
  78. package/dist/OperationGenerator-Gd1X7wUz.d.cts +0 -165
  79. package/dist/SchemaMapper-sGcY1xL5.d.cts +0 -247
  80. package/dist/SchemaMapper-sGcY1xL5.d.ts +0 -247
  81. package/dist/chunk-75BIOXB7.cjs +0 -7
  82. package/dist/chunk-75BIOXB7.cjs.map +0 -1
  83. package/dist/chunk-IAUV3UKH.cjs +0 -3965
  84. package/dist/chunk-IAUV3UKH.cjs.map +0 -1
  85. package/dist/chunk-M347763D.js +0 -3965
  86. package/dist/chunk-M347763D.js.map +0 -1
  87. package/dist/chunk-N7EEVJA6.js +0 -35
  88. package/dist/chunk-N7EEVJA6.js.map +0 -1
  89. package/dist/chunk-NU4F7G47.cjs +0 -89
  90. package/dist/chunk-NU4F7G47.cjs.map +0 -1
  91. package/dist/chunk-O76YQFZB.cjs +0 -35
  92. package/dist/chunk-O76YQFZB.cjs.map +0 -1
  93. package/dist/chunk-SQ64ESS4.js +0 -7
  94. package/dist/chunk-SQ64ESS4.js.map +0 -1
  95. package/dist/chunk-SZDO532A.js +0 -89
  96. package/dist/chunk-SZDO532A.js.map +0 -1
  97. package/dist/types-CZTUCaE5.d.cts +0 -145
  98. package/dist/types-CZTUCaE5.d.ts +0 -145
  99. package/src/utils/refSorter.ts +0 -13
package/dist/index.cjs CHANGED
@@ -1,28 +1,21 @@
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; }
1
+ 'use strict';
2
2
 
3
- var _chunkO76YQFZBcjs = require('./chunk-O76YQFZB.cjs');
4
- require('./chunk-75BIOXB7.cjs');
3
+ var chunkABOQ73FL_cjs = require('./chunk-ABOQ73FL.cjs');
4
+ var chunkSR63CBLH_cjs = require('./chunk-SR63CBLH.cjs');
5
+ require('./chunk-PADR76WZ.cjs');
6
+ var chunkQT6ZFRNJ_cjs = require('./chunk-QT6ZFRNJ.cjs');
7
+ var chunkQAFBZLJA_cjs = require('./chunk-QAFBZLJA.cjs');
8
+ require('./chunk-ZWHQ54JM.cjs');
9
+ var core = require('@kubb/core');
10
+ var transformers = require('@kubb/core/transformers');
11
+ var path = require('path');
5
12
 
13
+ function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
6
14
 
15
+ var transformers__default = /*#__PURE__*/_interopDefault(transformers);
16
+ var path__default = /*#__PURE__*/_interopDefault(path);
7
17
 
8
-
9
-
10
-
11
- var _chunkIAUV3UKHcjs = require('./chunk-IAUV3UKH.cjs');
12
-
13
-
14
-
15
-
16
- var _chunkNU4F7G47cjs = require('./chunk-NU4F7G47.cjs');
17
-
18
- // src/index.ts
19
- _chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
20
-
21
- // src/OperationGenerator.ts
22
- _chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
23
- var _core = require('@kubb/core');
24
- var _transformers = require('@kubb/core/transformers'); var _transformers2 = _interopRequireDefault(_transformers);
25
- var OperationGenerator = class extends _core.BaseGenerator {
18
+ var OperationGenerator = class extends core.BaseGenerator {
26
19
  #operationsByMethod = {};
27
20
  get operationsByMethod() {
28
21
  return this.#operationsByMethod;
@@ -32,9 +25,9 @@ var OperationGenerator = class extends _core.BaseGenerator {
32
25
  }
33
26
  #getOptions(operation, method) {
34
27
  const { override = [] } = this.context;
35
- return _optionalChain([override, 'access', _ => _.find, 'call', _2 => _2(({ pattern, type }) => {
28
+ return override.find(({ pattern, type }) => {
36
29
  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)]);
30
+ return !!operation.getTags()[0]?.name.match(pattern);
38
31
  }
39
32
  if (type === "operationId") {
40
33
  return !!operation.getOperationId().match(pattern);
@@ -46,18 +39,14 @@ var OperationGenerator = class extends _core.BaseGenerator {
46
39
  return !!method.match(pattern);
47
40
  }
48
41
  return false;
49
- }), 'optionalAccess', _9 => _9.options]) || {};
42
+ })?.options || {};
50
43
  }
51
- /**
52
- *
53
- * @deprecated
54
- */
55
44
  #isExcluded(operation, method) {
56
45
  const { exclude = [] } = this.context;
57
46
  let matched = false;
58
47
  exclude.forEach(({ pattern, type }) => {
59
48
  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)]);
49
+ matched = !!operation.getTags()[0]?.name.match(pattern);
61
50
  }
62
51
  if (type === "operationId" && !matched) {
63
52
  matched = !!operation.getOperationId().match(pattern);
@@ -71,16 +60,12 @@ var OperationGenerator = class extends _core.BaseGenerator {
71
60
  });
72
61
  return matched;
73
62
  }
74
- /**
75
- *
76
- * @deprecated
77
- */
78
63
  #isIncluded(operation, method) {
79
64
  const { include = [] } = this.context;
80
65
  let matched = false;
81
66
  include.forEach(({ pattern, type }) => {
82
67
  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)]);
68
+ matched = !!operation.getTags()[0]?.name.match(pattern);
84
69
  }
85
70
  if (type === "operationId" && !matched) {
86
71
  matched = !!operation.getOperationId().match(pattern);
@@ -95,14 +80,13 @@ var OperationGenerator = class extends _core.BaseGenerator {
95
80
  return matched;
96
81
  }
97
82
  getSchemas(operation, {
98
- forStatusCode,
99
83
  resolveName = (name) => name
100
84
  } = {}) {
101
85
  const pathParamsSchema = this.context.oas.getParametersSchema(operation, "path");
102
86
  const queryParamsSchema = this.context.oas.getParametersSchema(operation, "query");
103
87
  const headerParamsSchema = this.context.oas.getParametersSchema(operation, "header");
104
88
  const requestSchema = this.context.oas.getRequestSchema(operation);
105
- const responseStatusCode = forStatusCode || operation.schema.responses && Object.keys(operation.schema.responses).find((key) => key.startsWith("2")) || 200;
89
+ const responseStatusCode = operation.schema.responses && Object.keys(operation.schema.responses).find((key) => key.startsWith("2")) || 200;
106
90
  const responseSchema = this.context.oas.getResponseSchema(operation, responseStatusCode);
107
91
  const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {
108
92
  let name = statusCode;
@@ -111,63 +95,63 @@ var OperationGenerator = class extends _core.BaseGenerator {
111
95
  }
112
96
  const schema = this.context.oas.getResponseSchema(operation, statusCode);
113
97
  return {
114
- name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} ${name}`)),
115
- description: _optionalChain([operation, 'access', _22 => _22.getResponseByStatusCode, 'call', _23 => _23(statusCode), 'optionalAccess', _24 => _24.description]),
98
+ name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} ${name}`)),
99
+ description: operation.getResponseByStatusCode(statusCode)?.description,
116
100
  schema,
117
101
  operation,
118
- operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
102
+ operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
119
103
  statusCode: name === "error" ? void 0 : Number(statusCode),
120
- keys: _optionalChain([schema, 'optionalAccess', _25 => _25.properties]) ? Object.keys(schema.properties) : void 0
104
+ keys: schema?.properties ? Object.keys(schema.properties) : void 0
121
105
  };
122
106
  });
123
107
  return {
124
108
  pathParams: pathParamsSchema ? {
125
- name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} PathParams`)),
109
+ name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} PathParams`)),
126
110
  operation,
127
- operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
111
+ operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
128
112
  schema: pathParamsSchema,
129
113
  keys: pathParamsSchema.properties ? Object.keys(pathParamsSchema.properties) : void 0
130
114
  } : void 0,
131
115
  queryParams: queryParamsSchema ? {
132
- name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} QueryParams`)),
116
+ name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} QueryParams`)),
133
117
  operation,
134
- operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
118
+ operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
135
119
  schema: queryParamsSchema,
136
120
  keys: queryParamsSchema.properties ? Object.keys(queryParamsSchema.properties) : []
137
121
  } : void 0,
138
122
  headerParams: headerParamsSchema ? {
139
- name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} HeaderParams`)),
123
+ name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} HeaderParams`)),
140
124
  operation,
141
- operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
125
+ operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
142
126
  schema: headerParamsSchema,
143
127
  keys: headerParamsSchema.properties ? Object.keys(headerParamsSchema.properties) : void 0
144
128
  } : void 0,
145
129
  request: requestSchema ? {
146
- name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryRequest" : "mutationRequest"}`)),
147
- description: _optionalChain([operation, 'access', _26 => _26.schema, 'access', _27 => _27.requestBody, 'optionalAccess', _28 => _28.description]),
130
+ name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryRequest" : "mutationRequest"}`)),
131
+ description: operation.schema.requestBody?.description,
148
132
  operation,
149
- operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
133
+ operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
150
134
  schema: requestSchema,
151
135
  keys: requestSchema.properties ? Object.keys(requestSchema.properties) : void 0,
152
136
  keysToOmit: requestSchema.properties ? Object.keys(requestSchema.properties).filter((key) => {
153
- const item = _optionalChain([requestSchema, 'access', _29 => _29.properties, 'optionalAccess', _30 => _30[key]]);
154
- return _optionalChain([item, 'optionalAccess', _31 => _31.readOnly]);
137
+ const item = requestSchema.properties?.[key];
138
+ return item?.readOnly;
155
139
  }) : void 0
156
140
  } : void 0,
157
141
  response: {
158
- name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryResponse" : "mutationResponse"}`)),
159
- description: _optionalChain([operation, 'access', _32 => _32.getResponseAsJSONSchema, 'call', _33 => _33(responseStatusCode), 'optionalAccess', _34 => _34.at, 'call', _35 => _35(0), 'optionalAccess', _36 => _36.description]),
142
+ name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryResponse" : "mutationResponse"}`)),
143
+ description: operation.getResponseAsJSONSchema(responseStatusCode)?.at(0)?.description,
160
144
  operation,
161
- operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
145
+ operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
162
146
  schema: responseSchema,
163
147
  statusCode: Number(responseStatusCode),
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]);
148
+ keys: responseSchema?.properties ? Object.keys(responseSchema.properties) : void 0,
149
+ keysToOmit: responseSchema?.properties ? Object.keys(responseSchema.properties).filter((key) => {
150
+ const item = responseSchema.properties?.[key];
151
+ return item?.writeOnly;
168
152
  }) : void 0
169
153
  },
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")])),
154
+ errors: statusCodes.filter((item) => item.statusCode?.toString().startsWith("4") || item.statusCode?.toString().startsWith("5")),
171
155
  statusCodes
172
156
  };
173
157
  }
@@ -201,14 +185,14 @@ var OperationGenerator = class extends _core.BaseGenerator {
201
185
  const promises = Object.keys(this.operationsByMethod).reduce((acc, path2) => {
202
186
  const methods = this.operationsByMethod[path2] ? Object.keys(this.operationsByMethod[path2]) : [];
203
187
  methods.forEach((method) => {
204
- const { operation } = _optionalChain([this, 'access', _52 => _52.operationsByMethod, 'access', _53 => _53[path2], 'optionalAccess', _54 => _54[method]]);
188
+ const { operation } = this.operationsByMethod[path2]?.[method];
205
189
  const options = this.#getOptions(operation, method);
206
190
  const methodToCall = this[method];
207
191
  if (typeof methodToCall === "function") {
208
- const promiseMethod = _optionalChain([methodToCall, 'optionalAccess', _55 => _55.call, 'call', _56 => _56(this, operation, {
192
+ const promiseMethod = methodToCall?.call(this, operation, {
209
193
  ...this.options,
210
194
  ...options
211
- })]);
195
+ });
212
196
  if (promiseMethod) {
213
197
  acc.push(promiseMethod);
214
198
  }
@@ -220,35 +204,35 @@ var OperationGenerator = class extends _core.BaseGenerator {
220
204
  if (promiseOperation) {
221
205
  acc.push(promiseOperation);
222
206
  }
223
- _optionalChain([generators, 'optionalAccess', _57 => _57.forEach, 'call', _58 => _58((generator) => {
224
- const promise = _optionalChain([generator, 'access', _59 => _59.operation, 'optionalCall', _60 => _60({
207
+ generators?.forEach((generator) => {
208
+ const promise = generator.operation?.({
225
209
  instance: this,
226
210
  operation,
227
211
  options: {
228
212
  ...this.options,
229
213
  ...options
230
214
  }
231
- })]);
215
+ });
232
216
  if (promise) {
233
217
  acc.push(promise);
234
218
  }
235
- })]);
219
+ });
236
220
  });
237
221
  return acc;
238
222
  }, []);
239
223
  const operations = Object.values(this.operationsByMethod).map((item) => Object.values(item).map((item2) => item2.operation));
240
224
  promises.push(this.all(operations.flat().filter(Boolean), this.operationsByMethod));
241
- _optionalChain([generators, 'optionalAccess', _61 => _61.forEach, 'call', _62 => _62((generator) => {
242
- const promise = _optionalChain([generator, 'access', _63 => _63.operations, 'optionalCall', _64 => _64({
225
+ generators?.forEach((generator) => {
226
+ const promise = generator.operations?.({
243
227
  instance: this,
244
228
  operations: operations.flat().filter(Boolean),
245
229
  operationsByMethod: this.operationsByMethod,
246
230
  options: this.options
247
- })]);
231
+ });
248
232
  if (promise) {
249
233
  promises.push(promise);
250
234
  }
251
- })]);
235
+ });
252
236
  const files = await Promise.all(promises);
253
237
  return files.flat().filter(Boolean);
254
238
  }
@@ -295,164 +279,129 @@ var OperationGenerator = class extends _core.BaseGenerator {
295
279
  return [];
296
280
  }
297
281
  };
298
-
299
- // src/plugin.ts
300
- _chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
301
- var _path = require('path'); var _path2 = _interopRequireDefault(_path);
302
-
303
-
304
282
  var pluginOasName = "plugin-oas";
305
- var pluginOas = _core.createPlugin.call(void 0, (options) => {
283
+ var pluginOas = core.createPlugin((options) => {
306
284
  const {
307
- output = { path: "schemas", export: false },
308
- experimentalFilter: filter,
309
- experimentalSort: sort,
285
+ output = {
286
+ path: "schemas"
287
+ },
310
288
  validate = true,
289
+ generators = [chunkSR63CBLH_cjs.jsonGenerator],
311
290
  serverIndex = 0,
312
291
  contentType,
313
292
  oasClass
314
293
  } = options;
315
- const getOas = async ({ config, logger, formatOptions }) => {
294
+ const getOas = async ({ config, logger }) => {
316
295
  try {
317
- const oas = await _chunkO76YQFZBcjs.parseFromConfig.call(void 0, config, formatOptions, oasClass);
296
+ const oas = await chunkABOQ73FL_cjs.parseFromConfig(config, oasClass);
318
297
  if (validate) {
319
298
  await oas.valdiate();
320
299
  }
321
300
  return oas;
322
301
  } catch (e) {
323
302
  const error = e;
324
- logger.emit("warning", _optionalChain([error, 'optionalAccess', _65 => _65.message]));
325
- return _chunkO76YQFZBcjs.parseFromConfig.call(void 0, config, {}, oasClass);
303
+ logger.emit("warning", error?.message);
304
+ return chunkABOQ73FL_cjs.parseFromConfig(config, oasClass);
326
305
  }
327
306
  };
328
307
  return {
329
308
  name: pluginOasName,
330
- output: output === false ? {
331
- path: "",
332
- exportType: false
333
- } : {
334
- exportType: "barrelNamed",
335
- ...output
309
+ options: {
310
+ output,
311
+ ...options
336
312
  },
337
- options,
338
313
  context() {
339
314
  const { config, logger } = this;
340
315
  return {
341
- getOas(formatOptions) {
342
- return getOas({ config, logger, formatOptions });
316
+ getOas() {
317
+ return getOas({ config, logger });
343
318
  },
344
319
  async getSchemas({ includes } = {}) {
345
320
  const oas = await this.getOas();
346
- return _chunkNU4F7G47cjs.getSchemas.call(void 0, { oas, contentType, includes });
321
+ return chunkQAFBZLJA_cjs.getSchemas({ oas, contentType, includes });
347
322
  },
348
323
  async getBaseURL() {
349
324
  const oasInstance = await this.getOas();
350
- const baseURL = _optionalChain([oasInstance, 'access', _66 => _66.api, 'access', _67 => _67.servers, 'optionalAccess', _68 => _68.at, 'call', _69 => _69(serverIndex), 'optionalAccess', _70 => _70.url]);
351
- return baseURL;
325
+ return oasInstance.api.servers?.at(serverIndex)?.url;
352
326
  },
353
327
  contentType
354
328
  };
355
329
  },
330
+ resolvePath(baseName, pathMode, options2) {
331
+ const root = path__default.default.resolve(this.config.root, this.config.output.path);
332
+ const mode = pathMode ?? core.FileManager.getMode(path__default.default.resolve(root, output.path));
333
+ if (mode === "single") {
334
+ return path__default.default.resolve(root, output.path);
335
+ }
336
+ return path__default.default.resolve(root, output.path, baseName);
337
+ },
356
338
  async buildStart() {
357
339
  if (!output) {
358
340
  return;
359
341
  }
360
342
  const oas = await getOas({
361
343
  config: this.config,
362
- logger: this.logger,
363
- formatOptions: {
364
- filterSet: filter,
365
- sortSet: sort
366
- }
344
+ logger: this.logger
367
345
  });
368
346
  await oas.dereference();
369
- const root = _path2.default.resolve(this.config.root, this.config.output.path);
370
- const schemas = _chunkNU4F7G47cjs.getSchemas.call(void 0, { oas, contentType });
371
- const mapSchema = async ([name, schema]) => {
372
- const baseName = `${_transformers.camelCase.call(void 0, name)}.json`;
373
- const resolvedPath = _path2.default.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: _transformers.camelCase.call(void 0, 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
- }
393
- };
394
- });
395
-
396
- // src/generator.tsx
397
- _chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
398
- var import_jsx_runtime = _chunkNU4F7G47cjs.__toESM.call(void 0, _chunkIAUV3UKHcjs.require_jsx_runtime.call(void 0, ), 1);
399
- var _react = require('@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 = _react.createRoot.call(void 0, {
412
- logger: pluginManager.logger
413
- });
414
- root.render(
415
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_react.App, { pluginManager, plugin, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunkIAUV3UKHcjs.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 = _react.createRoot.call(void 0, {
425
- logger: pluginManager.logger
426
- });
427
- root.render(
428
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunkIAUV3UKHcjs.Oas, { oas, operations: [operation], generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunkIAUV3UKHcjs.Oas.Operation, { operation, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Operation, { operation, options, instance }) }) }) })
347
+ const schemaGenerator = new chunkQT6ZFRNJ_cjs.SchemaGenerator(
348
+ {
349
+ unknownType: "unknown",
350
+ dateType: "date",
351
+ transformers: {},
352
+ ...this.plugin.options
353
+ },
354
+ {
355
+ oas,
356
+ pluginManager: this.pluginManager,
357
+ plugin: this.plugin,
358
+ contentType,
359
+ include: void 0,
360
+ override: void 0,
361
+ mode: "split",
362
+ output: output.path
363
+ }
429
364
  );
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 = _react.createRoot.call(void 0, {
438
- logger: pluginManager.logger
365
+ const schemaFiles = await schemaGenerator.build(...generators);
366
+ await this.addFile(...schemaFiles);
367
+ const operationGenerator = new OperationGenerator(this.plugin.options, {
368
+ oas,
369
+ pluginManager: this.pluginManager,
370
+ plugin: this.plugin,
371
+ contentType,
372
+ exclude: void 0,
373
+ include: void 0,
374
+ override: void 0,
375
+ mode: "split"
439
376
  });
440
- const tree = instance.parse({ schema, name });
441
- root.render(
442
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunkIAUV3UKHcjs.Oas, { oas, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunkIAUV3UKHcjs.Oas.Schema, { name, value: schema, tree, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Schema, { schema, options, instance, name }) }) }) })
443
- );
444
- return root.files;
377
+ const operationFiles = await operationGenerator.build(...generators);
378
+ await this.addFile(...operationFiles);
445
379
  }
446
380
  };
447
- }
448
-
449
-
450
-
451
-
452
-
453
-
454
-
455
-
381
+ });
456
382
 
457
- exports.OperationGenerator = OperationGenerator; exports.SchemaGenerator = _chunkIAUV3UKHcjs.SchemaGenerator; exports.createGenerator = createGenerator; exports.createReactGenerator = createReactGenerator; exports.isKeyword = _chunkIAUV3UKHcjs.isKeyword; exports.pluginOas = pluginOas; exports.pluginOasName = pluginOasName; exports.schemaKeywords = _chunkIAUV3UKHcjs.schemaKeywords;
383
+ Object.defineProperty(exports, "createGenerator", {
384
+ enumerable: true,
385
+ get: function () { return chunkSR63CBLH_cjs.createGenerator; }
386
+ });
387
+ Object.defineProperty(exports, "createReactGenerator", {
388
+ enumerable: true,
389
+ get: function () { return chunkSR63CBLH_cjs.createReactGenerator; }
390
+ });
391
+ Object.defineProperty(exports, "SchemaGenerator", {
392
+ enumerable: true,
393
+ get: function () { return chunkQT6ZFRNJ_cjs.SchemaGenerator; }
394
+ });
395
+ Object.defineProperty(exports, "isKeyword", {
396
+ enumerable: true,
397
+ get: function () { return chunkQT6ZFRNJ_cjs.isKeyword; }
398
+ });
399
+ Object.defineProperty(exports, "schemaKeywords", {
400
+ enumerable: true,
401
+ get: function () { return chunkQT6ZFRNJ_cjs.schemaKeywords; }
402
+ });
403
+ exports.OperationGenerator = OperationGenerator;
404
+ exports.pluginOas = pluginOas;
405
+ exports.pluginOasName = pluginOasName;
406
+ //# sourceMappingURL=index.cjs.map
458
407
  //# sourceMappingURL=index.cjs.map