@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.
- package/README.md +13 -4
- package/dist/OperationGenerator-BgQeGRzk.d.cts +550 -0
- package/dist/OperationGenerator-BgQeGRzk.d.ts +550 -0
- package/dist/Schema-1iM2I0dK.d.ts +22 -0
- package/dist/Schema-5o-c5UOy.d.cts +22 -0
- package/dist/chunk-ABOQ73FL.cjs +36 -0
- package/dist/chunk-ABOQ73FL.cjs.map +1 -0
- package/dist/chunk-BG77DP54.js +30 -0
- package/dist/chunk-BG77DP54.js.map +1 -0
- package/dist/chunk-GF26SDHQ.js +28 -0
- package/dist/chunk-GF26SDHQ.js.map +1 -0
- package/dist/chunk-PADR76WZ.cjs +4 -0
- package/dist/chunk-PADR76WZ.cjs.map +1 -0
- package/dist/chunk-QAFBZLJA.cjs +48 -0
- package/dist/chunk-QAFBZLJA.cjs.map +1 -0
- package/dist/chunk-QT6ZFRNJ.cjs +752 -0
- package/dist/chunk-QT6ZFRNJ.cjs.map +1 -0
- package/dist/chunk-QWO5NQGQ.js +88 -0
- package/dist/chunk-QWO5NQGQ.js.map +1 -0
- package/dist/chunk-R47XMJ32.js +3 -0
- package/dist/chunk-R47XMJ32.js.map +1 -0
- package/dist/chunk-SR63CBLH.cjs +92 -0
- package/dist/chunk-SR63CBLH.cjs.map +1 -0
- package/dist/chunk-V2JO6RHI.js +744 -0
- package/dist/chunk-V2JO6RHI.js.map +1 -0
- package/dist/chunk-XNCEFOE6.js +45 -0
- package/dist/chunk-XNCEFOE6.js.map +1 -0
- package/dist/chunk-ZWHQ54JM.cjs +32 -0
- package/dist/chunk-ZWHQ54JM.cjs.map +1 -0
- package/dist/components.cjs +20 -12
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +4 -7
- package/dist/components.d.ts +4 -7
- package/dist/components.js +3 -12
- package/dist/components.js.map +1 -1
- package/dist/generators.cjs +14 -0
- package/dist/generators.cjs.map +1 -0
- package/dist/generators.d.cts +9 -0
- package/dist/generators.d.ts +9 -0
- package/dist/generators.js +5 -0
- package/dist/generators.js.map +1 -0
- package/dist/hooks.cjs +102 -57
- package/dist/hooks.cjs.map +1 -1
- package/dist/hooks.d.cts +41 -10
- package/dist/hooks.d.ts +41 -10
- package/dist/hooks.js +91 -53
- package/dist/hooks.js.map +1 -1
- package/dist/index.cjs +192 -258
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -6
- package/dist/index.d.ts +3 -6
- package/dist/index.js +135 -228
- package/dist/index.js.map +1 -1
- package/dist/utils.cjs +32 -87
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.d.cts +8 -43
- package/dist/utils.d.ts +8 -43
- package/dist/utils.js +8 -86
- package/dist/utils.js.map +1 -1
- package/package.json +20 -14
- package/src/OperationGenerator.ts +23 -30
- package/src/SchemaGenerator.ts +80 -23
- package/src/SchemaMapper.ts +7 -5
- package/src/components/Oas.tsx +1 -1
- package/src/components/Operation.tsx +1 -1
- package/src/components/Schema.tsx +2 -102
- package/src/{parser.tsx → generator.tsx} +31 -22
- package/src/generators/index.ts +1 -0
- package/src/generators/jsonGenerator.ts +32 -0
- package/src/hooks/index.ts +2 -0
- package/src/hooks/useOperationManager.ts +77 -29
- package/src/hooks/useSchemaManager.ts +77 -0
- package/src/index.ts +3 -3
- package/src/plugin.ts +67 -59
- package/src/types.ts +24 -16
- package/src/utils/getParams.ts +2 -2
- package/src/utils/getSchemaFactory.ts +1 -1
- package/src/utils/index.ts +2 -2
- package/src/utils/parseFromConfig.ts +7 -7
- package/dist/OperationGenerator-D7rSlflc.d.cts +0 -158
- package/dist/OperationGenerator-vw0Zf-Mi.d.ts +0 -158
- package/dist/Schema-DxyOIX7q.d.cts +0 -35
- package/dist/Schema-gHgN14i2.d.ts +0 -35
- package/dist/SchemaMapper-BM1IGWqD.d.cts +0 -248
- package/dist/SchemaMapper-BM1IGWqD.d.ts +0 -248
- package/dist/chunk-264TCCJF.cjs +0 -3973
- package/dist/chunk-264TCCJF.cjs.map +0 -1
- package/dist/chunk-7KIEQOVZ.cjs +0 -7
- package/dist/chunk-7KIEQOVZ.cjs.map +0 -1
- package/dist/chunk-FZN3PBEK.js +0 -3973
- package/dist/chunk-FZN3PBEK.js.map +0 -1
- package/dist/chunk-P42X362U.cjs +0 -101
- package/dist/chunk-P42X362U.cjs.map +0 -1
- package/dist/chunk-QLJIL3U5.cjs +0 -35
- package/dist/chunk-QLJIL3U5.cjs.map +0 -1
- package/dist/chunk-TWKZEVSM.js +0 -7
- package/dist/chunk-TWKZEVSM.js.map +0 -1
- package/dist/chunk-UB552H4J.js +0 -101
- package/dist/chunk-UB552H4J.js.map +0 -1
- package/dist/chunk-Y4V7HHX7.js +0 -35
- package/dist/chunk-Y4V7HHX7.js.map +0 -1
- package/dist/types-C2RXaY0_.d.cts +0 -143
- package/dist/types-C2RXaY0_.d.ts +0 -143
- package/src/utils/getGroupedByTagFiles.ts +0 -82
- package/src/utils/refSorter.ts +0 -13
package/dist/index.cjs
CHANGED
|
@@ -1,53 +1,92 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
require('./chunk-
|
|
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
|
|
21
|
+
return this.#operationsByMethod;
|
|
38
22
|
}
|
|
39
23
|
set operationsByMethod(paths) {
|
|
40
|
-
|
|
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 =
|
|
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(
|
|
60
|
-
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:
|
|
102
|
+
operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
|
|
64
103
|
statusCode: name === "error" ? void 0 : Number(statusCode),
|
|
65
|
-
keys:
|
|
104
|
+
keys: schema?.properties ? Object.keys(schema.properties) : void 0
|
|
66
105
|
};
|
|
67
106
|
});
|
|
68
107
|
return {
|
|
69
108
|
pathParams: pathParamsSchema ? {
|
|
70
|
-
name: resolveName(
|
|
109
|
+
name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} PathParams`)),
|
|
71
110
|
operation,
|
|
72
|
-
operationName:
|
|
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(
|
|
116
|
+
name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} QueryParams`)),
|
|
78
117
|
operation,
|
|
79
|
-
operationName:
|
|
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(
|
|
123
|
+
name: resolveName(transformers__default.default.pascalCase(`${operation.getOperationId()} HeaderParams`)),
|
|
85
124
|
operation,
|
|
86
|
-
operationName:
|
|
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(
|
|
92
|
-
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:
|
|
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 =
|
|
99
|
-
return
|
|
137
|
+
const item = requestSchema.properties?.[key];
|
|
138
|
+
return item?.readOnly;
|
|
100
139
|
}) : void 0
|
|
101
140
|
} : void 0,
|
|
102
141
|
response: {
|
|
103
|
-
name: resolveName(
|
|
104
|
-
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:
|
|
145
|
+
operationName: transformers__default.default.pascalCase(`${operation.getOperationId()}`),
|
|
107
146
|
schema: responseSchema,
|
|
108
147
|
statusCode: Number(responseStatusCode),
|
|
109
|
-
keys:
|
|
110
|
-
keysToOmit:
|
|
111
|
-
const item =
|
|
112
|
-
return
|
|
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) =>
|
|
154
|
+
errors: statusCodes.filter((item) => item.statusCode?.toString().startsWith("4") || item.statusCode?.toString().startsWith("5")),
|
|
116
155
|
statusCodes
|
|
117
156
|
};
|
|
118
157
|
}
|
|
119
|
-
|
|
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 =
|
|
128
|
-
const isIncluded = this.context.include ?
|
|
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 } =
|
|
149
|
-
const options =
|
|
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 =
|
|
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
|
-
|
|
168
|
-
const promise =
|
|
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
|
-
|
|
186
|
-
const promise =
|
|
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 =
|
|
283
|
+
var pluginOas = core.createPlugin((options) => {
|
|
316
284
|
const {
|
|
317
|
-
output = {
|
|
318
|
-
|
|
319
|
-
|
|
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
|
|
294
|
+
const getOas = async ({ config, logger }) => {
|
|
326
295
|
try {
|
|
327
|
-
const oas = await
|
|
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",
|
|
335
|
-
return
|
|
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(
|
|
345
|
-
return getOas({ config, logger
|
|
316
|
+
getOas() {
|
|
317
|
+
return getOas({ config, logger });
|
|
346
318
|
},
|
|
347
319
|
async getSchemas({ includes } = {}) {
|
|
348
320
|
const oas = await this.getOas();
|
|
349
|
-
return
|
|
321
|
+
return chunkQAFBZLJA_cjs.getSchemas({ oas, contentType, includes });
|
|
350
322
|
},
|
|
351
323
|
async getBaseURL() {
|
|
352
324
|
const oasInstance = await this.getOas();
|
|
353
|
-
|
|
354
|
-
return baseURL;
|
|
325
|
+
return oasInstance.api.servers?.at(serverIndex)?.url;
|
|
355
326
|
},
|
|
356
327
|
contentType
|
|
357
328
|
};
|
|
358
329
|
},
|
|
359
|
-
resolvePath(baseName) {
|
|
360
|
-
|
|
361
|
-
|
|
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
|
-
|
|
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
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
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
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
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
|
-
|
|
443
|
-
|
|
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
|
-
|
|
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
|