@kubb/plugin-oas 3.0.0-alpha.8 → 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 (100) 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 +137 -187
  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 +76 -153
  53. package/dist/index.js.map +1 -1
  54. package/dist/utils.cjs +32 -41
  55. package/dist/utils.cjs.map +1 -1
  56. package/dist/utils.d.cts +5 -13
  57. package/dist/utils.d.ts +5 -13
  58. package/dist/utils.js +8 -40
  59. package/dist/utils.js.map +1 -1
  60. package/package.json +20 -14
  61. package/src/OperationGenerator.ts +23 -30
  62. package/src/SchemaGenerator.ts +79 -22
  63. package/src/SchemaMapper.ts +6 -4
  64. package/src/components/Schema.tsx +1 -99
  65. package/src/{parser.tsx → generator.tsx} +30 -22
  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/index.ts +3 -3
  72. package/src/plugin.ts +69 -56
  73. package/src/types.ts +24 -18
  74. package/src/utils/getParams.ts +1 -1
  75. package/src/utils/getSchemaFactory.ts +1 -1
  76. package/src/utils/index.ts +2 -1
  77. package/src/utils/parseFromConfig.ts +7 -7
  78. package/dist/OperationGenerator-DeXrfGDC.d.ts +0 -158
  79. package/dist/OperationGenerator-DhJ0MBKc.d.cts +0 -158
  80. package/dist/SchemaMapper-sGcY1xL5.d.cts +0 -247
  81. package/dist/SchemaMapper-sGcY1xL5.d.ts +0 -247
  82. package/dist/chunk-75BIOXB7.cjs +0 -7
  83. package/dist/chunk-75BIOXB7.cjs.map +0 -1
  84. package/dist/chunk-MUI5DWM3.js +0 -3966
  85. package/dist/chunk-MUI5DWM3.js.map +0 -1
  86. package/dist/chunk-N7EEVJA6.js +0 -35
  87. package/dist/chunk-N7EEVJA6.js.map +0 -1
  88. package/dist/chunk-NU4F7G47.cjs +0 -89
  89. package/dist/chunk-NU4F7G47.cjs.map +0 -1
  90. package/dist/chunk-O76YQFZB.cjs +0 -35
  91. package/dist/chunk-O76YQFZB.cjs.map +0 -1
  92. package/dist/chunk-SQ64ESS4.js +0 -7
  93. package/dist/chunk-SQ64ESS4.js.map +0 -1
  94. package/dist/chunk-SZDO532A.js +0 -89
  95. package/dist/chunk-SZDO532A.js.map +0 -1
  96. package/dist/chunk-VSVVTCQB.cjs +0 -3966
  97. package/dist/chunk-VSVVTCQB.cjs.map +0 -1
  98. package/dist/types-CZTUCaE5.d.cts +0 -145
  99. package/dist/types-CZTUCaE5.d.ts +0 -145
  100. 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 _chunkVSVVTCQBcjs = require('./chunk-VSVVTCQB.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.Generator {
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.Generator {
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.Generator {
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.Generator {
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.Generator {
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,74 +95,75 @@ var OperationGenerator = class extends _core.Generator {
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
  }
174
- async build(...parsers) {
158
+ #methods = ["get", "post", "patch", "put", "delete"];
159
+ async build(...generators) {
175
160
  const { oas } = this.context;
176
161
  const paths = oas.getPaths();
177
162
  this.operationsByMethod = Object.entries(paths).reduce((acc, [path2, method]) => {
178
163
  const methods = Object.keys(method);
179
164
  methods.forEach((method2) => {
180
165
  const operation = oas.operation(path2, method2);
181
- if (operation) {
166
+ if (operation && [this.#methods].some((methods2) => method2 === operation.method)) {
182
167
  const isExcluded = this.#isExcluded(operation, method2);
183
168
  const isIncluded = this.context.include ? this.#isIncluded(operation, method2) : true;
184
169
  if (isIncluded && !isExcluded) {
@@ -200,14 +185,14 @@ var OperationGenerator = class extends _core.Generator {
200
185
  const promises = Object.keys(this.operationsByMethod).reduce((acc, path2) => {
201
186
  const methods = this.operationsByMethod[path2] ? Object.keys(this.operationsByMethod[path2]) : [];
202
187
  methods.forEach((method) => {
203
- const { operation } = _optionalChain([this, 'access', _52 => _52.operationsByMethod, 'access', _53 => _53[path2], 'optionalAccess', _54 => _54[method]]);
188
+ const { operation } = this.operationsByMethod[path2]?.[method];
204
189
  const options = this.#getOptions(operation, method);
205
190
  const methodToCall = this[method];
206
191
  if (typeof methodToCall === "function") {
207
- const promiseMethod = _optionalChain([methodToCall, 'optionalAccess', _55 => _55.call, 'call', _56 => _56(this, operation, {
192
+ const promiseMethod = methodToCall?.call(this, operation, {
208
193
  ...this.options,
209
194
  ...options
210
- })]);
195
+ });
211
196
  if (promiseMethod) {
212
197
  acc.push(promiseMethod);
213
198
  }
@@ -219,35 +204,35 @@ var OperationGenerator = class extends _core.Generator {
219
204
  if (promiseOperation) {
220
205
  acc.push(promiseOperation);
221
206
  }
222
- _optionalChain([parsers, 'optionalAccess', _57 => _57.forEach, 'call', _58 => _58((parser) => {
223
- const promise = _optionalChain([parser, 'access', _59 => _59.operation, 'optionalCall', _60 => _60({
207
+ generators?.forEach((generator) => {
208
+ const promise = generator.operation?.({
224
209
  instance: this,
225
210
  operation,
226
211
  options: {
227
212
  ...this.options,
228
213
  ...options
229
214
  }
230
- })]);
215
+ });
231
216
  if (promise) {
232
217
  acc.push(promise);
233
218
  }
234
- })]);
219
+ });
235
220
  });
236
221
  return acc;
237
222
  }, []);
238
223
  const operations = Object.values(this.operationsByMethod).map((item) => Object.values(item).map((item2) => item2.operation));
239
224
  promises.push(this.all(operations.flat().filter(Boolean), this.operationsByMethod));
240
- _optionalChain([parsers, 'optionalAccess', _61 => _61.forEach, 'call', _62 => _62((parser) => {
241
- const promise = _optionalChain([parser, 'access', _63 => _63.operations, 'optionalCall', _64 => _64({
225
+ generators?.forEach((generator) => {
226
+ const promise = generator.operations?.({
242
227
  instance: this,
243
228
  operations: operations.flat().filter(Boolean),
244
229
  operationsByMethod: this.operationsByMethod,
245
230
  options: this.options
246
- })]);
231
+ });
247
232
  if (promise) {
248
233
  promises.push(promise);
249
234
  }
250
- })]);
235
+ });
251
236
  const files = await Promise.all(promises);
252
237
  return files.flat().filter(Boolean);
253
238
  }
@@ -294,164 +279,129 @@ var OperationGenerator = class extends _core.Generator {
294
279
  return [];
295
280
  }
296
281
  };
297
-
298
- // src/plugin.ts
299
- _chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
300
- var _path = require('path'); var _path2 = _interopRequireDefault(_path);
301
-
302
-
303
282
  var pluginOasName = "plugin-oas";
304
- var pluginOas = _core.createPlugin.call(void 0, (options) => {
283
+ var pluginOas = core.createPlugin((options) => {
305
284
  const {
306
- output = { path: "schemas", export: false },
307
- experimentalFilter: filter,
308
- experimentalSort: sort,
285
+ output = {
286
+ path: "schemas"
287
+ },
309
288
  validate = true,
289
+ generators = [chunkSR63CBLH_cjs.jsonGenerator],
310
290
  serverIndex = 0,
311
291
  contentType,
312
292
  oasClass
313
293
  } = options;
314
- const getOas = async ({ config, logger, formatOptions }) => {
294
+ const getOas = async ({ config, logger }) => {
315
295
  try {
316
- const oas = await _chunkO76YQFZBcjs.parseFromConfig.call(void 0, config, formatOptions, oasClass);
296
+ const oas = await chunkABOQ73FL_cjs.parseFromConfig(config, oasClass);
317
297
  if (validate) {
318
298
  await oas.valdiate();
319
299
  }
320
300
  return oas;
321
301
  } catch (e) {
322
302
  const error = e;
323
- logger.emit("warning", _optionalChain([error, 'optionalAccess', _65 => _65.message]));
324
- return _chunkO76YQFZBcjs.parseFromConfig.call(void 0, config, {}, oasClass);
303
+ logger.emit("warning", error?.message);
304
+ return chunkABOQ73FL_cjs.parseFromConfig(config, oasClass);
325
305
  }
326
306
  };
327
307
  return {
328
308
  name: pluginOasName,
329
- output: output === false ? {
330
- path: "",
331
- exportType: false
332
- } : {
333
- exportType: "barrelNamed",
334
- ...output
309
+ options: {
310
+ output,
311
+ ...options
335
312
  },
336
- options,
337
313
  context() {
338
314
  const { config, logger } = this;
339
315
  return {
340
- getOas(formatOptions) {
341
- return getOas({ config, logger, formatOptions });
316
+ getOas() {
317
+ return getOas({ config, logger });
342
318
  },
343
319
  async getSchemas({ includes } = {}) {
344
320
  const oas = await this.getOas();
345
- return _chunkNU4F7G47cjs.getSchemas.call(void 0, { oas, contentType, includes });
321
+ return chunkQAFBZLJA_cjs.getSchemas({ oas, contentType, includes });
346
322
  },
347
323
  async getBaseURL() {
348
324
  const oasInstance = await this.getOas();
349
- const baseURL = _optionalChain([oasInstance, 'access', _66 => _66.api, 'access', _67 => _67.servers, 'optionalAccess', _68 => _68.at, 'call', _69 => _69(serverIndex), 'optionalAccess', _70 => _70.url]);
350
- return baseURL;
325
+ return oasInstance.api.servers?.at(serverIndex)?.url;
351
326
  },
352
327
  contentType
353
328
  };
354
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
+ },
355
338
  async buildStart() {
356
339
  if (!output) {
357
340
  return;
358
341
  }
359
342
  const oas = await getOas({
360
343
  config: this.config,
361
- logger: this.logger,
362
- formatOptions: {
363
- filterSet: filter,
364
- sortSet: sort
365
- }
344
+ logger: this.logger
366
345
  });
367
346
  await oas.dereference();
368
- const root = _path2.default.resolve(this.config.root, this.config.output.path);
369
- const schemas = _chunkNU4F7G47cjs.getSchemas.call(void 0, { oas, contentType });
370
- const mapSchema = async ([name, schema]) => {
371
- const baseName = `${_transformers.camelCase.call(void 0, name)}.json`;
372
- const resolvedPath = _path2.default.resolve(root, output.path, baseName);
373
- await this.addFile({
374
- path: resolvedPath,
375
- baseName,
376
- meta: {
377
- pluginKey: this.plugin.key
378
- },
379
- sources: [
380
- {
381
- name: _transformers.camelCase.call(void 0, name),
382
- isExportable: false,
383
- isIndexable: false,
384
- value: JSON.stringify(schema)
385
- }
386
- ]
387
- });
388
- };
389
- const promises = Object.entries(schemas).map(mapSchema);
390
- await Promise.all(promises);
391
- }
392
- };
393
- });
394
-
395
- // src/parser.tsx
396
- _chunkNU4F7G47cjs.init_cjs_shims.call(void 0, );
397
- var _react = require('@kubb/react');
398
- var import_jsx_runtime = _chunkNU4F7G47cjs.__toESM.call(void 0, _chunkVSVVTCQBcjs.require_jsx_runtime.call(void 0, ), 1);
399
- function createParser(parseOptions) {
400
- return parseOptions;
401
- }
402
- function createReactParser(parseOptions) {
403
- return {
404
- ...parseOptions,
405
- async operations({ instance, options, operations, operationsByMethod }) {
406
- if (!parseOptions.Operations) {
407
- return [];
408
- }
409
- const { pluginManager, oas, plugin, mode } = instance.context;
410
- const root = _react.createRoot.call(void 0, {
411
- logger: pluginManager.logger
412
- });
413
- root.render(
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 }) }) })
415
- );
416
- return root.files;
417
- },
418
- async operation({ instance, operation, options }) {
419
- if (!parseOptions.Operation) {
420
- return [];
421
- }
422
- const { pluginManager, oas, plugin, mode } = instance.context;
423
- const root = _react.createRoot.call(void 0, {
424
- logger: pluginManager.logger
425
- });
426
- root.render(
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 }) }) }) })
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
+ }
428
364
  );
429
- return root.files;
430
- },
431
- async schema({ instance, schema, name, options }) {
432
- if (!parseOptions.Schema) {
433
- return [];
434
- }
435
- const { pluginManager, oas, plugin, mode } = instance.context;
436
- const root = _react.createRoot.call(void 0, {
437
- 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"
438
376
  });
439
- const tree = instance.parse({ schema, name });
440
- root.render(
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 }) }) }) })
442
- );
443
- return root.files;
377
+ const operationFiles = await operationGenerator.build(...generators);
378
+ await this.addFile(...operationFiles);
444
379
  }
445
380
  };
446
- }
447
-
448
-
449
-
450
-
451
-
452
-
453
-
454
-
381
+ });
455
382
 
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;
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
457
407
  //# sourceMappingURL=index.cjs.map