@kubb/plugin-oas 3.0.0-alpha.3 → 3.0.0-alpha.31

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 (105) hide show
  1. package/README.md +13 -4
  2. package/dist/OperationGenerator-BgQeGRzk.d.cts +550 -0
  3. package/dist/OperationGenerator-BgQeGRzk.d.ts +550 -0
  4. package/dist/Schema-1iM2I0dK.d.ts +22 -0
  5. package/dist/Schema-5o-c5UOy.d.cts +22 -0
  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 +4 -7
  33. package/dist/components.d.ts +4 -7
  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 +192 -258
  49. package/dist/index.cjs.map +1 -1
  50. package/dist/index.d.cts +3 -6
  51. package/dist/index.d.ts +3 -6
  52. package/dist/index.js +135 -228
  53. package/dist/index.js.map +1 -1
  54. package/dist/utils.cjs +32 -87
  55. package/dist/utils.cjs.map +1 -1
  56. package/dist/utils.d.cts +8 -43
  57. package/dist/utils.d.ts +8 -43
  58. package/dist/utils.js +8 -86
  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 +80 -23
  63. package/src/SchemaMapper.ts +7 -5
  64. package/src/components/Oas.tsx +1 -1
  65. package/src/components/Operation.tsx +1 -1
  66. package/src/components/Schema.tsx +2 -102
  67. package/src/{parser.tsx → generator.tsx} +31 -22
  68. package/src/generators/index.ts +1 -0
  69. package/src/generators/jsonGenerator.ts +32 -0
  70. package/src/hooks/index.ts +2 -0
  71. package/src/hooks/useOperationManager.ts +77 -29
  72. package/src/hooks/useSchemaManager.ts +77 -0
  73. package/src/index.ts +3 -3
  74. package/src/plugin.ts +67 -59
  75. package/src/types.ts +24 -16
  76. package/src/utils/getParams.ts +2 -2
  77. package/src/utils/getSchemaFactory.ts +1 -1
  78. package/src/utils/index.ts +2 -2
  79. package/src/utils/parseFromConfig.ts +7 -7
  80. package/dist/OperationGenerator-D7rSlflc.d.cts +0 -158
  81. package/dist/OperationGenerator-vw0Zf-Mi.d.ts +0 -158
  82. package/dist/Schema-DxyOIX7q.d.cts +0 -35
  83. package/dist/Schema-gHgN14i2.d.ts +0 -35
  84. package/dist/SchemaMapper-BM1IGWqD.d.cts +0 -248
  85. package/dist/SchemaMapper-BM1IGWqD.d.ts +0 -248
  86. package/dist/chunk-264TCCJF.cjs +0 -3973
  87. package/dist/chunk-264TCCJF.cjs.map +0 -1
  88. package/dist/chunk-7KIEQOVZ.cjs +0 -7
  89. package/dist/chunk-7KIEQOVZ.cjs.map +0 -1
  90. package/dist/chunk-FZN3PBEK.js +0 -3973
  91. package/dist/chunk-FZN3PBEK.js.map +0 -1
  92. package/dist/chunk-P42X362U.cjs +0 -101
  93. package/dist/chunk-P42X362U.cjs.map +0 -1
  94. package/dist/chunk-QLJIL3U5.cjs +0 -35
  95. package/dist/chunk-QLJIL3U5.cjs.map +0 -1
  96. package/dist/chunk-TWKZEVSM.js +0 -7
  97. package/dist/chunk-TWKZEVSM.js.map +0 -1
  98. package/dist/chunk-UB552H4J.js +0 -101
  99. package/dist/chunk-UB552H4J.js.map +0 -1
  100. package/dist/chunk-Y4V7HHX7.js +0 -35
  101. package/dist/chunk-Y4V7HHX7.js.map +0 -1
  102. package/dist/types-C2RXaY0_.d.cts +0 -143
  103. package/dist/types-C2RXaY0_.d.ts +0 -143
  104. package/src/utils/getGroupedByTagFiles.ts +0 -82
  105. package/src/utils/refSorter.ts +0 -13
package/dist/index.cjs CHANGED
@@ -1,53 +1,92 @@
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 _chunkQLJIL3U5cjs = require('./chunk-QLJIL3U5.cjs');
4
- require('./chunk-7KIEQOVZ.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 _chunk264TCCJFcjs = require('./chunk-264TCCJF.cjs');
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19
-
20
- var _chunkP42X362Ucjs = require('./chunk-P42X362U.cjs');
21
-
22
- // src/index.ts
23
- _chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
24
-
25
- // src/OperationGenerator.ts
26
- _chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
27
- var _core = require('@kubb/core');
28
- var _transformers = require('@kubb/core/transformers'); var _transformers2 = _interopRequireDefault(_transformers);
29
- var _operationsByMethod, _OperationGenerator_instances, getOptions_fn, isExcluded_fn, isIncluded_fn;
30
- 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
- }
18
+ var OperationGenerator = class extends core.BaseGenerator {
19
+ #operationsByMethod = {};
36
20
  get operationsByMethod() {
37
- return _chunkP42X362Ucjs.__privateGet.call(void 0, this, _operationsByMethod);
21
+ return this.#operationsByMethod;
38
22
  }
39
23
  set operationsByMethod(paths) {
40
- _chunkP42X362Ucjs.__privateSet.call(void 0, this, _operationsByMethod, paths);
24
+ this.#operationsByMethod = paths;
25
+ }
26
+ #getOptions(operation, method) {
27
+ const { override = [] } = this.context;
28
+ return override.find(({ pattern, type }) => {
29
+ if (type === "tag") {
30
+ return !!operation.getTags()[0]?.name.match(pattern);
31
+ }
32
+ if (type === "operationId") {
33
+ return !!operation.getOperationId().match(pattern);
34
+ }
35
+ if (type === "path") {
36
+ return !!operation.path.match(pattern);
37
+ }
38
+ if (type === "method") {
39
+ return !!method.match(pattern);
40
+ }
41
+ return false;
42
+ })?.options || {};
43
+ }
44
+ #isExcluded(operation, method) {
45
+ const { exclude = [] } = this.context;
46
+ let matched = false;
47
+ exclude.forEach(({ pattern, type }) => {
48
+ if (type === "tag" && !matched) {
49
+ matched = !!operation.getTags()[0]?.name.match(pattern);
50
+ }
51
+ if (type === "operationId" && !matched) {
52
+ matched = !!operation.getOperationId().match(pattern);
53
+ }
54
+ if (type === "path" && !matched) {
55
+ matched = !!operation.path.match(pattern);
56
+ }
57
+ if (type === "method" && !matched) {
58
+ matched = !!method.match(pattern);
59
+ }
60
+ });
61
+ return matched;
62
+ }
63
+ #isIncluded(operation, method) {
64
+ const { include = [] } = this.context;
65
+ let matched = false;
66
+ include.forEach(({ pattern, type }) => {
67
+ if (type === "tag" && !matched) {
68
+ matched = !!operation.getTags()[0]?.name.match(pattern);
69
+ }
70
+ if (type === "operationId" && !matched) {
71
+ matched = !!operation.getOperationId().match(pattern);
72
+ }
73
+ if (type === "path" && !matched) {
74
+ matched = !!operation.path.match(pattern);
75
+ }
76
+ if (type === "method" && !matched) {
77
+ matched = !!method.match(pattern);
78
+ }
79
+ });
80
+ return matched;
41
81
  }
42
82
  getSchemas(operation, {
43
- forStatusCode,
44
83
  resolveName = (name) => name
45
84
  } = {}) {
46
85
  const pathParamsSchema = this.context.oas.getParametersSchema(operation, "path");
47
86
  const queryParamsSchema = this.context.oas.getParametersSchema(operation, "query");
48
87
  const headerParamsSchema = this.context.oas.getParametersSchema(operation, "header");
49
88
  const requestSchema = this.context.oas.getRequestSchema(operation);
50
- 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;
51
90
  const responseSchema = this.context.oas.getResponseSchema(operation, responseStatusCode);
52
91
  const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {
53
92
  let name = statusCode;
@@ -56,76 +95,77 @@ var OperationGenerator = class extends _core.Generator {
56
95
  }
57
96
  const schema = this.context.oas.getResponseSchema(operation, statusCode);
58
97
  return {
59
- name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} ${name}`)),
60
- description: _optionalChain([operation, 'access', _ => _.getResponseByStatusCode, 'call', _2 => _2(statusCode), 'optionalAccess', _3 => _3.description]),
98
+ name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} ${name}`)),
99
+ description: operation.getResponseByStatusCode(statusCode)?.description,
61
100
  schema,
62
101
  operation,
63
- operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
102
+ operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
64
103
  statusCode: name === "error" ? void 0 : Number(statusCode),
65
- keys: _optionalChain([schema, 'optionalAccess', _4 => _4.properties]) ? Object.keys(schema.properties) : void 0
104
+ keys: schema?.properties ? Object.keys(schema.properties) : void 0
66
105
  };
67
106
  });
68
107
  return {
69
108
  pathParams: pathParamsSchema ? {
70
- name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} PathParams`)),
109
+ name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} PathParams`)),
71
110
  operation,
72
- operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
111
+ operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
73
112
  schema: pathParamsSchema,
74
113
  keys: pathParamsSchema.properties ? Object.keys(pathParamsSchema.properties) : void 0
75
114
  } : void 0,
76
115
  queryParams: queryParamsSchema ? {
77
- name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} QueryParams`)),
116
+ name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} QueryParams`)),
78
117
  operation,
79
- operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
118
+ operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
80
119
  schema: queryParamsSchema,
81
120
  keys: queryParamsSchema.properties ? Object.keys(queryParamsSchema.properties) : []
82
121
  } : void 0,
83
122
  headerParams: headerParamsSchema ? {
84
- name: resolveName(_transformers2.default.pascalCase(`${operation.getOperationId()} HeaderParams`)),
123
+ name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} HeaderParams`)),
85
124
  operation,
86
- operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
125
+ operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
87
126
  schema: headerParamsSchema,
88
127
  keys: headerParamsSchema.properties ? Object.keys(headerParamsSchema.properties) : void 0
89
128
  } : void 0,
90
129
  request: requestSchema ? {
91
- 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]),
130
+ name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryRequest" : "mutationRequest"}`)),
131
+ description: operation.schema.requestBody?.description,
93
132
  operation,
94
- operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
133
+ operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
95
134
  schema: requestSchema,
96
135
  keys: requestSchema.properties ? Object.keys(requestSchema.properties) : void 0,
97
136
  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]);
137
+ const item = requestSchema.properties?.[key];
138
+ return item?.readOnly;
100
139
  }) : void 0
101
140
  } : void 0,
102
141
  response: {
103
- 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]),
142
+ name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryResponse" : "mutationResponse"}`)),
143
+ description: operation.getResponseAsJSONSchema(responseStatusCode)?.at(0)?.description,
105
144
  operation,
106
- operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
145
+ operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
107
146
  schema: responseSchema,
108
147
  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]);
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;
113
152
  }) : void 0
114
153
  },
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")])),
154
+ errors: statusCodes.filter((item) => item.statusCode?.toString().startsWith("4") || item.statusCode?.toString().startsWith("5")),
116
155
  statusCodes
117
156
  };
118
157
  }
119
- async build(...parsers) {
158
+ #methods = ["get", "post", "patch", "put", "delete"];
159
+ async build(...generators) {
120
160
  const { oas } = this.context;
121
161
  const paths = oas.getPaths();
122
162
  this.operationsByMethod = Object.entries(paths).reduce((acc, [path2, method]) => {
123
163
  const methods = Object.keys(method);
124
164
  methods.forEach((method2) => {
125
165
  const operation = oas.operation(path2, method2);
126
- 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;
166
+ if (operation && [this.#methods].some((methods2) => method2 === operation.method)) {
167
+ const isExcluded = this.#isExcluded(operation, method2);
168
+ const isIncluded = this.context.include ? this.#isIncluded(operation, method2) : true;
129
169
  if (isIncluded && !isExcluded) {
130
170
  if (!acc[path2]) {
131
171
  acc[path2] = {};
@@ -145,14 +185,14 @@ var OperationGenerator = class extends _core.Generator {
145
185
  const promises = Object.keys(this.operationsByMethod).reduce((acc, path2) => {
146
186
  const methods = this.operationsByMethod[path2] ? Object.keys(this.operationsByMethod[path2]) : [];
147
187
  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);
188
+ const { operation } = this.operationsByMethod[path2]?.[method];
189
+ const options = this.#getOptions(operation, method);
150
190
  const methodToCall = this[method];
151
191
  if (typeof methodToCall === "function") {
152
- const promiseMethod = _optionalChain([methodToCall, 'optionalAccess', _34 => _34.call, 'call', _35 => _35(this, operation, {
192
+ const promiseMethod = methodToCall?.call(this, operation, {
153
193
  ...this.options,
154
194
  ...options
155
- })]);
195
+ });
156
196
  if (promiseMethod) {
157
197
  acc.push(promiseMethod);
158
198
  }
@@ -164,35 +204,35 @@ var OperationGenerator = class extends _core.Generator {
164
204
  if (promiseOperation) {
165
205
  acc.push(promiseOperation);
166
206
  }
167
- _optionalChain([parsers, 'optionalAccess', _36 => _36.forEach, 'call', _37 => _37((parser) => {
168
- const promise = _optionalChain([parser, 'access', _38 => _38.operation, 'optionalCall', _39 => _39({
207
+ generators?.forEach((generator) => {
208
+ const promise = generator.operation?.({
169
209
  instance: this,
170
210
  operation,
171
211
  options: {
172
212
  ...this.options,
173
213
  ...options
174
214
  }
175
- })]);
215
+ });
176
216
  if (promise) {
177
217
  acc.push(promise);
178
218
  }
179
- })]);
219
+ });
180
220
  });
181
221
  return acc;
182
222
  }, []);
183
223
  const operations = Object.values(this.operationsByMethod).map((item) => Object.values(item).map((item2) => item2.operation));
184
224
  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({
225
+ generators?.forEach((generator) => {
226
+ const promise = generator.operations?.({
187
227
  instance: this,
188
228
  operations: operations.flat().filter(Boolean),
189
229
  operationsByMethod: this.operationsByMethod,
190
230
  options: this.options
191
- })]);
231
+ });
192
232
  if (promise) {
193
233
  promises.push(promise);
194
234
  }
195
- })]);
235
+ });
196
236
  const files = await Promise.all(promises);
197
237
  return files.flat().filter(Boolean);
198
238
  }
@@ -239,132 +279,61 @@ var OperationGenerator = class extends _core.Generator {
239
279
  return [];
240
280
  }
241
281
  };
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
-
309
- // src/plugin.ts
310
- _chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
311
- var _path = require('path'); var _path2 = _interopRequireDefault(_path);
312
-
313
-
314
282
  var pluginOasName = "plugin-oas";
315
- var pluginOas = _core.createPlugin.call(void 0, (options) => {
283
+ var pluginOas = core.createPlugin((options) => {
316
284
  const {
317
- output = { path: "schemas", export: false },
318
- experimentalFilter: filter,
319
- experimentalSort: sort,
285
+ output = {
286
+ path: "schemas"
287
+ },
320
288
  validate = true,
289
+ generators = [chunkSR63CBLH_cjs.jsonGenerator],
321
290
  serverIndex = 0,
322
291
  contentType,
323
292
  oasClass
324
293
  } = options;
325
- const getOas = async ({ config, logger, formatOptions }) => {
294
+ const getOas = async ({ config, logger }) => {
326
295
  try {
327
- const oas = await _chunkQLJIL3U5cjs.parseFromConfig.call(void 0, config, formatOptions, oasClass);
296
+ const oas = await chunkABOQ73FL_cjs.parseFromConfig(config, oasClass);
328
297
  if (validate) {
329
298
  await oas.valdiate();
330
299
  }
331
300
  return oas;
332
301
  } catch (e) {
333
302
  const error = e;
334
- logger.emit("warning", _optionalChain([error, 'optionalAccess', _65 => _65.message]));
335
- return _chunkQLJIL3U5cjs.parseFromConfig.call(void 0, config, {}, oasClass);
303
+ logger.emit("warning", error?.message);
304
+ return chunkABOQ73FL_cjs.parseFromConfig(config, oasClass);
336
305
  }
337
306
  };
338
307
  return {
339
308
  name: pluginOasName,
340
- options,
309
+ options: {
310
+ output,
311
+ ...options
312
+ },
341
313
  context() {
342
314
  const { config, logger } = this;
343
315
  return {
344
- getOas(formatOptions) {
345
- return getOas({ config, logger, formatOptions });
316
+ getOas() {
317
+ return getOas({ config, logger });
346
318
  },
347
319
  async getSchemas({ includes } = {}) {
348
320
  const oas = await this.getOas();
349
- return _chunkP42X362Ucjs.getSchemas.call(void 0, { oas, contentType, includes });
321
+ return chunkQAFBZLJA_cjs.getSchemas({ oas, contentType, includes });
350
322
  },
351
323
  async getBaseURL() {
352
324
  const oasInstance = await this.getOas();
353
- const baseURL = _optionalChain([oasInstance, 'access', _66 => _66.api, 'access', _67 => _67.servers, 'optionalAccess', _68 => _68.at, 'call', _69 => _69(serverIndex), 'optionalAccess', _70 => _70.url]);
354
- return baseURL;
325
+ return oasInstance.api.servers?.at(serverIndex)?.url;
355
326
  },
356
327
  contentType
357
328
  };
358
329
  },
359
- resolvePath(baseName) {
360
- if (output === false) {
361
- return void 0;
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);
362
335
  }
363
- const root = _path2.default.resolve(this.config.root, this.config.output.path);
364
- return _path2.default.resolve(root, output.path, baseName);
365
- },
366
- resolveName(name, type) {
367
- return _transformers.camelCase.call(void 0, name, { isFile: type === "file" });
336
+ return path__default.default.resolve(root, output.path, baseName);
368
337
  },
369
338
  async buildStart() {
370
339
  if (!output) {
@@ -372,102 +341,67 @@ var pluginOas = _core.createPlugin.call(void 0, (options) => {
372
341
  }
373
342
  const oas = await getOas({
374
343
  config: this.config,
375
- logger: this.logger,
376
- formatOptions: {
377
- filterSet: filter,
378
- sortSet: sort
379
- }
344
+ logger: this.logger
380
345
  });
381
346
  await oas.dereference();
382
- const schemas = _chunkP42X362Ucjs.getSchemas.call(void 0, { oas, contentType });
383
- const mapSchema = async ([name, schema]) => {
384
- const resolvedPath = this.resolvePath({
385
- baseName: `${name}.json`,
386
- pluginKey: this.plugin.key
387
- });
388
- const resvoledFileName = this.resolveName({
389
- name: `${name}.json`,
390
- pluginKey: [pluginOasName],
391
- type: "file"
392
- });
393
- if (!resolvedPath) {
394
- return;
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
395
363
  }
396
- await this.addFile({
397
- path: resolvedPath,
398
- baseName: resvoledFileName,
399
- source: JSON.stringify(schema),
400
- meta: {
401
- pluginKey: this.plugin.key
402
- }
403
- });
404
- };
405
- const promises = Object.entries(schemas).map(mapSchema);
406
- await Promise.all(promises);
407
- }
408
- };
409
- });
410
-
411
- // src/parser.tsx
412
- _chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
413
- var _react = require('@kubb/react');
414
- var import_jsx_runtime = _chunkP42X362Ucjs.__toESM.call(void 0, _chunk264TCCJFcjs.require_jsx_runtime.call(void 0, ), 1);
415
- function createParser(parseOptions) {
416
- return parseOptions;
417
- }
418
- function createReactParser(parseOptions) {
419
- return {
420
- ...parseOptions,
421
- async operations({ instance, options, operations, operationsByMethod }) {
422
- if (!parseOptions.Operations) {
423
- return [];
424
- }
425
- const { pluginManager, oas, plugin, mode } = instance.context;
426
- const root = _react.createRoot.call(void 0, {
427
- logger: pluginManager.logger
428
- });
429
- root.render(
430
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_react.App, { pluginManager, plugin, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunk264TCCJFcjs.Oas, { oas, operations, generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Operations, { operations, instance, operationsByMethod, options }) }) })
431
364
  );
432
- return root.files;
433
- },
434
- async operation({ instance, operation, options }) {
435
- if (!parseOptions.Operation) {
436
- return [];
437
- }
438
- const { pluginManager, oas, plugin, mode } = instance.context;
439
- const root = _react.createRoot.call(void 0, {
440
- 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"
441
376
  });
442
- root.render(
443
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunk264TCCJFcjs.Oas, { oas, operations: [operation], generator: instance, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunk264TCCJFcjs.Oas.Operation, { operation, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Operation, { operation, options, instance }) }) }) })
444
- );
445
- return root.files;
446
- },
447
- async schema({ instance, schema, name, options }) {
448
- if (!parseOptions.Schema) {
449
- return [];
450
- }
451
- const { pluginManager, oas, plugin, mode } = instance.context;
452
- const root = _react.createRoot.call(void 0, {
453
- logger: pluginManager.logger
454
- });
455
- const tree = instance.parse({ schema, name });
456
- root.render(
457
- /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_react.App, { pluginManager, plugin: { ...plugin, options }, mode, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunk264TCCJFcjs.Oas, { oas, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(_chunk264TCCJFcjs.Oas.Schema, { name, value: schema, tree, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(parseOptions.Schema, { schema, options, instance, name }) }) }) })
458
- );
459
- return root.files;
377
+ const operationFiles = await operationGenerator.build(...generators);
378
+ await this.addFile(...operationFiles);
460
379
  }
461
380
  };
462
- }
463
-
464
-
465
-
466
-
467
-
468
-
469
-
470
-
381
+ });
471
382
 
472
- exports.OperationGenerator = OperationGenerator; exports.SchemaGenerator = _chunk264TCCJFcjs.SchemaGenerator; exports.createParser = createParser; exports.createReactParser = createReactParser; exports.isKeyword = _chunk264TCCJFcjs.isKeyword; exports.pluginOas = pluginOas; exports.pluginOasName = pluginOasName; exports.schemaKeywords = _chunk264TCCJFcjs.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
473
407
  //# sourceMappingURL=index.cjs.map