@kubb/plugin-oas 0.0.0-canary-20240509211223

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 (75) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +44 -0
  3. package/dist/OperationGenerator-DvnXUUp4.d.ts +56 -0
  4. package/dist/OperationGenerator-X6CTMfhG.d.cts +56 -0
  5. package/dist/Schema-BWPWyiQO.d.cts +39 -0
  6. package/dist/Schema-DFZBfjF2.d.ts +39 -0
  7. package/dist/SchemaGenerator-hK5SHxTI.d.ts +316 -0
  8. package/dist/SchemaGenerator-z_7YrAAB.d.cts +316 -0
  9. package/dist/chunk-2MJ2CQMI.js +61 -0
  10. package/dist/chunk-2MJ2CQMI.js.map +1 -0
  11. package/dist/chunk-3RCQ2LNT.js +81 -0
  12. package/dist/chunk-3RCQ2LNT.js.map +1 -0
  13. package/dist/chunk-55NUFNT6.cjs +68 -0
  14. package/dist/chunk-55NUFNT6.cjs.map +1 -0
  15. package/dist/chunk-ECXSQTMV.cjs +81 -0
  16. package/dist/chunk-ECXSQTMV.cjs.map +1 -0
  17. package/dist/chunk-EPTOYYAP.js +3312 -0
  18. package/dist/chunk-EPTOYYAP.js.map +1 -0
  19. package/dist/chunk-H52M2RUX.cjs +3312 -0
  20. package/dist/chunk-H52M2RUX.cjs.map +1 -0
  21. package/dist/chunk-LQ6IAWRX.js +68 -0
  22. package/dist/chunk-LQ6IAWRX.js.map +1 -0
  23. package/dist/chunk-VNFSHGSN.cjs +61 -0
  24. package/dist/chunk-VNFSHGSN.cjs.map +1 -0
  25. package/dist/components.cjs +18 -0
  26. package/dist/components.cjs.map +1 -0
  27. package/dist/components.d.cts +41 -0
  28. package/dist/components.d.ts +41 -0
  29. package/dist/components.js +18 -0
  30. package/dist/components.js.map +1 -0
  31. package/dist/hooks.cjs +152 -0
  32. package/dist/hooks.cjs.map +1 -0
  33. package/dist/hooks.d.cts +76 -0
  34. package/dist/hooks.d.ts +76 -0
  35. package/dist/hooks.js +152 -0
  36. package/dist/hooks.js.map +1 -0
  37. package/dist/index.cjs +985 -0
  38. package/dist/index.cjs.map +1 -0
  39. package/dist/index.d.cts +17 -0
  40. package/dist/index.d.ts +17 -0
  41. package/dist/index.js +985 -0
  42. package/dist/index.js.map +1 -0
  43. package/dist/types-n5zV4Q3s.d.cts +146 -0
  44. package/dist/types-n5zV4Q3s.d.ts +146 -0
  45. package/dist/utils.cjs +126 -0
  46. package/dist/utils.cjs.map +1 -0
  47. package/dist/utils.d.cts +80 -0
  48. package/dist/utils.d.ts +80 -0
  49. package/dist/utils.js +126 -0
  50. package/dist/utils.js.map +1 -0
  51. package/package.json +107 -0
  52. package/src/OperationGenerator.ts +328 -0
  53. package/src/SchemaGenerator.ts +827 -0
  54. package/src/SchemaMapper.ts +145 -0
  55. package/src/components/Oas.tsx +31 -0
  56. package/src/components/Operation.tsx +21 -0
  57. package/src/components/Schema.tsx +156 -0
  58. package/src/components/index.ts +3 -0
  59. package/src/hooks/index.ts +5 -0
  60. package/src/hooks/useOas.ts +15 -0
  61. package/src/hooks/useOperation.ts +18 -0
  62. package/src/hooks/useOperationManager.ts +142 -0
  63. package/src/hooks/useOperations.ts +40 -0
  64. package/src/hooks/useSchema.ts +23 -0
  65. package/src/index.ts +30 -0
  66. package/src/plugin.ts +133 -0
  67. package/src/types.ts +147 -0
  68. package/src/utils/getComments.ts +15 -0
  69. package/src/utils/getGroupedByTagFiles.ts +81 -0
  70. package/src/utils/getParams.ts +57 -0
  71. package/src/utils/getSchemaFactory.ts +33 -0
  72. package/src/utils/getSchemas.ts +45 -0
  73. package/src/utils/index.ts +8 -0
  74. package/src/utils/parseFromConfig.ts +36 -0
  75. package/src/utils/refSorter.ts +13 -0
package/dist/index.cjs ADDED
@@ -0,0 +1,985 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
2
+
3
+
4
+
5
+ var _chunkECXSQTMVcjs = require('./chunk-ECXSQTMV.cjs');
6
+
7
+
8
+
9
+ var _chunkVNFSHGSNcjs = require('./chunk-VNFSHGSN.cjs');
10
+
11
+
12
+
13
+
14
+
15
+
16
+ var _chunk55NUFNT6cjs = require('./chunk-55NUFNT6.cjs');
17
+
18
+ // src/index.ts
19
+ _chunk55NUFNT6cjs.init_cjs_shims.call(void 0, );
20
+
21
+ // src/plugin.ts
22
+ _chunk55NUFNT6cjs.init_cjs_shims.call(void 0, );
23
+ var _path = require('path'); var _path2 = _interopRequireDefault(_path);
24
+ var _core = require('@kubb/core');
25
+ var _transformers = require('@kubb/core/transformers'); var _transformers2 = _interopRequireDefault(_transformers);
26
+ var pluginOasName = "plugin-oas";
27
+ var pluginOas = _core.createPlugin.call(void 0, (options) => {
28
+ const {
29
+ output = { path: "schemas", export: false },
30
+ experimentalFilter: filter,
31
+ experimentalSort: sort,
32
+ validate = true,
33
+ serverIndex = 0,
34
+ contentType
35
+ } = options;
36
+ const getOas = async ({ config, logger, formatOptions }) => {
37
+ try {
38
+ const oas = await _chunkECXSQTMVcjs.parseFromConfig.call(void 0, config, formatOptions);
39
+ if (validate) {
40
+ await oas.valdiate();
41
+ }
42
+ return oas;
43
+ } catch (e) {
44
+ const error = e;
45
+ logger.emit("warning", _optionalChain([error, 'optionalAccess', _ => _.message]));
46
+ return _chunkECXSQTMVcjs.parseFromConfig.call(void 0, config);
47
+ }
48
+ };
49
+ return {
50
+ name: pluginOasName,
51
+ options,
52
+ api() {
53
+ const { config, logger } = this;
54
+ return {
55
+ getOas(formatOptions) {
56
+ return getOas({ config, logger, formatOptions });
57
+ },
58
+ async getSchemas({ includes } = {}) {
59
+ const oas = await this.getOas();
60
+ return _chunkECXSQTMVcjs.getSchemas.call(void 0, { oas, contentType, includes });
61
+ },
62
+ async getBaseURL() {
63
+ const oasInstance = await this.getOas();
64
+ const baseURL = _optionalChain([oasInstance, 'access', _2 => _2.api, 'access', _3 => _3.servers, 'optionalAccess', _4 => _4.at, 'call', _5 => _5(serverIndex), 'optionalAccess', _6 => _6.url]);
65
+ return baseURL;
66
+ },
67
+ contentType
68
+ };
69
+ },
70
+ resolvePath(baseName) {
71
+ if (output === false) {
72
+ return void 0;
73
+ }
74
+ const root = _path2.default.resolve(this.config.root, this.config.output.path);
75
+ return _path2.default.resolve(root, output.path, baseName);
76
+ },
77
+ resolveName(name, type) {
78
+ return _transformers.camelCase.call(void 0, name, { isFile: type === "file" });
79
+ },
80
+ async writeFile(source, writePath) {
81
+ if (!writePath.endsWith(".json") || !source) {
82
+ return;
83
+ }
84
+ return this.fileManager.write(source, writePath, { sanity: false });
85
+ },
86
+ async buildStart() {
87
+ if (!output) {
88
+ return;
89
+ }
90
+ const oas = await getOas({
91
+ config: this.config,
92
+ logger: this.logger,
93
+ formatOptions: {
94
+ filterSet: filter,
95
+ sortSet: sort
96
+ }
97
+ });
98
+ await oas.dereference();
99
+ const schemas = _chunkECXSQTMVcjs.getSchemas.call(void 0, { oas, contentType });
100
+ const mapSchema = async ([name, schema]) => {
101
+ const resolvedPath = this.resolvePath({
102
+ baseName: `${name}.json`,
103
+ pluginKey: this.plugin.key
104
+ });
105
+ const resvoledFileName = this.resolveName({
106
+ name: `${name}.json`,
107
+ pluginKey: [pluginOasName],
108
+ type: "file"
109
+ });
110
+ if (!resolvedPath) {
111
+ return;
112
+ }
113
+ await this.addFile({
114
+ path: resolvedPath,
115
+ baseName: resvoledFileName,
116
+ source: JSON.stringify(schema),
117
+ meta: {
118
+ pluginKey: this.plugin.key
119
+ }
120
+ });
121
+ };
122
+ const promises = Object.entries(schemas).map(mapSchema);
123
+ await Promise.all(promises);
124
+ }
125
+ };
126
+ });
127
+
128
+ // src/OperationGenerator.ts
129
+ _chunk55NUFNT6cjs.init_cjs_shims.call(void 0, );
130
+
131
+
132
+ var _operationsByMethod, _getOptions, getOptions_fn, _isExcluded, isExcluded_fn, _isIncluded, isIncluded_fn, _methods, methods_get;
133
+ var OperationGenerator = class extends _core.Generator {
134
+ constructor() {
135
+ super(...arguments);
136
+ _chunk55NUFNT6cjs.__privateAdd.call(void 0, this, _getOptions);
137
+ /**
138
+ *
139
+ * @deprecated
140
+ */
141
+ _chunk55NUFNT6cjs.__privateAdd.call(void 0, this, _isExcluded);
142
+ /**
143
+ *
144
+ * @deprecated
145
+ */
146
+ _chunk55NUFNT6cjs.__privateAdd.call(void 0, this, _isIncluded);
147
+ _chunk55NUFNT6cjs.__privateAdd.call(void 0, this, _methods);
148
+ _chunk55NUFNT6cjs.__privateAdd.call(void 0, this, _operationsByMethod, {});
149
+ }
150
+ get operationsByMethod() {
151
+ return _chunk55NUFNT6cjs.__privateGet.call(void 0, this, _operationsByMethod);
152
+ }
153
+ set operationsByMethod(paths) {
154
+ _chunk55NUFNT6cjs.__privateSet.call(void 0, this, _operationsByMethod, paths);
155
+ }
156
+ getSchemas(operation, forStatusCode) {
157
+ const pathParamsSchema = this.context.oas.getParametersSchema(operation, "path");
158
+ const queryParamsSchema = this.context.oas.getParametersSchema(operation, "query");
159
+ const headerParamsSchema = this.context.oas.getParametersSchema(operation, "header");
160
+ const requestSchema = this.context.oas.getRequestSchema(operation);
161
+ const responseStatusCode = forStatusCode || operation.schema.responses && Object.keys(operation.schema.responses).find((key) => key.startsWith("2")) || 200;
162
+ const responseSchema = this.context.oas.getResponseSchema(operation, responseStatusCode);
163
+ const statusCodes = operation.getResponseStatusCodes().map((statusCode) => {
164
+ let name = statusCode;
165
+ if (name === "default") {
166
+ name = "error";
167
+ }
168
+ const schema = this.context.oas.getResponseSchema(operation, statusCode);
169
+ return {
170
+ name: _transformers2.default.pascalCase(`${operation.getOperationId()} ${name}`),
171
+ description: _optionalChain([operation, 'access', _7 => _7.getResponseByStatusCode, 'call', _8 => _8(statusCode), 'optionalAccess', _9 => _9.description]),
172
+ schema,
173
+ operation,
174
+ operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
175
+ statusCode: name === "error" ? void 0 : Number(statusCode),
176
+ keys: _optionalChain([schema, 'optionalAccess', _10 => _10.properties]) ? Object.keys(schema.properties) : void 0
177
+ };
178
+ });
179
+ return {
180
+ pathParams: pathParamsSchema ? {
181
+ name: _transformers2.default.pascalCase(`${operation.getOperationId()} PathParams`),
182
+ operation,
183
+ operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
184
+ schema: pathParamsSchema,
185
+ keys: pathParamsSchema.properties ? Object.keys(pathParamsSchema.properties) : void 0
186
+ } : void 0,
187
+ queryParams: queryParamsSchema ? {
188
+ name: _transformers2.default.pascalCase(`${operation.getOperationId()} QueryParams`),
189
+ operation,
190
+ operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
191
+ schema: queryParamsSchema,
192
+ keys: queryParamsSchema.properties ? Object.keys(queryParamsSchema.properties) : []
193
+ } : void 0,
194
+ headerParams: headerParamsSchema ? {
195
+ name: _transformers2.default.pascalCase(`${operation.getOperationId()} HeaderParams`),
196
+ operation,
197
+ operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
198
+ schema: headerParamsSchema,
199
+ keys: headerParamsSchema.properties ? Object.keys(headerParamsSchema.properties) : void 0
200
+ } : void 0,
201
+ request: requestSchema ? {
202
+ name: _transformers2.default.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryRequest" : "mutationRequest"}`),
203
+ description: _optionalChain([operation, 'access', _11 => _11.schema, 'access', _12 => _12.requestBody, 'optionalAccess', _13 => _13.description]),
204
+ operation,
205
+ operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
206
+ schema: requestSchema,
207
+ keys: requestSchema.properties ? Object.keys(requestSchema.properties) : void 0,
208
+ keysToOmit: requestSchema.properties ? Object.keys(requestSchema.properties).filter((key) => {
209
+ const item = _optionalChain([requestSchema, 'access', _14 => _14.properties, 'optionalAccess', _15 => _15[key]]);
210
+ return _optionalChain([item, 'optionalAccess', _16 => _16.readOnly]);
211
+ }) : void 0
212
+ } : void 0,
213
+ response: {
214
+ name: _transformers2.default.pascalCase(`${operation.getOperationId()} ${operation.method === "get" ? "queryResponse" : "mutationResponse"}`),
215
+ description: _optionalChain([operation, 'access', _17 => _17.getResponseAsJSONSchema, 'call', _18 => _18(responseStatusCode), 'optionalAccess', _19 => _19.at, 'call', _20 => _20(0), 'optionalAccess', _21 => _21.description]),
216
+ operation,
217
+ operationName: _transformers2.default.pascalCase(`${operation.getOperationId()}`),
218
+ schema: responseSchema,
219
+ statusCode: Number(responseStatusCode),
220
+ keys: _optionalChain([responseSchema, 'optionalAccess', _22 => _22.properties]) ? Object.keys(responseSchema.properties) : void 0,
221
+ keysToOmit: _optionalChain([responseSchema, 'optionalAccess', _23 => _23.properties]) ? Object.keys(responseSchema.properties).filter((key) => {
222
+ const item = _optionalChain([responseSchema, 'access', _24 => _24.properties, 'optionalAccess', _25 => _25[key]]);
223
+ return _optionalChain([item, 'optionalAccess', _26 => _26.writeOnly]);
224
+ }) : void 0
225
+ },
226
+ errors: statusCodes.filter((item) => _optionalChain([item, 'access', _27 => _27.statusCode, 'optionalAccess', _28 => _28.toString, 'call', _29 => _29(), 'access', _30 => _30.startsWith, 'call', _31 => _31("4")]) || _optionalChain([item, 'access', _32 => _32.statusCode, 'optionalAccess', _33 => _33.toString, 'call', _34 => _34(), 'access', _35 => _35.startsWith, 'call', _36 => _36("5")])),
227
+ statusCodes
228
+ };
229
+ }
230
+ async build() {
231
+ const { oas } = this.context;
232
+ const paths = oas.getPaths();
233
+ this.operationsByMethod = Object.entries(paths).reduce((acc, [path2, method]) => {
234
+ const methods = Object.keys(method);
235
+ methods.forEach((method2) => {
236
+ const operation = oas.operation(path2, method2);
237
+ if (operation && _chunk55NUFNT6cjs.__privateGet.call(void 0, this, _methods, methods_get)[method2]) {
238
+ const isExcluded = _chunk55NUFNT6cjs.__privateMethod.call(void 0, this, _isExcluded, isExcluded_fn).call(this, operation, method2);
239
+ const isIncluded = this.context.include ? _chunk55NUFNT6cjs.__privateMethod.call(void 0, this, _isIncluded, isIncluded_fn).call(this, operation, method2) : true;
240
+ if (isIncluded && !isExcluded) {
241
+ if (!acc[path2]) {
242
+ acc[path2] = {};
243
+ }
244
+ acc[path2] = {
245
+ ...acc[path2],
246
+ [method2]: {
247
+ operation,
248
+ schemas: this.getSchemas(operation)
249
+ }
250
+ };
251
+ }
252
+ }
253
+ });
254
+ return acc;
255
+ }, {});
256
+ const promises = Object.keys(this.operationsByMethod).reduce((acc, path2) => {
257
+ const methods = this.operationsByMethod[path2] ? Object.keys(this.operationsByMethod[path2]) : [];
258
+ methods.forEach((method) => {
259
+ const { operation } = _optionalChain([this, 'access', _37 => _37.operationsByMethod, 'access', _38 => _38[path2], 'optionalAccess', _39 => _39[method]]);
260
+ const options = _chunk55NUFNT6cjs.__privateMethod.call(void 0, this, _getOptions, getOptions_fn).call(this, operation, method);
261
+ const promiseMethod = _optionalChain([_chunk55NUFNT6cjs.__privateGet.call(void 0, this, _methods, methods_get), 'access', _40 => _40[method], 'optionalAccess', _41 => _41.call, 'call', _42 => _42(this, operation, {
262
+ ...this.options,
263
+ ...options
264
+ })]);
265
+ const promiseOperation = this.operation.call(this, operation, {
266
+ ...this.options,
267
+ ...options
268
+ });
269
+ if (promiseMethod) {
270
+ acc.push(promiseMethod);
271
+ }
272
+ if (promiseOperation) {
273
+ acc.push(promiseOperation);
274
+ }
275
+ });
276
+ return acc;
277
+ }, []);
278
+ const operations = Object.values(this.operationsByMethod).map((item) => Object.values(item).map((item2) => item2.operation));
279
+ promises.push(this.all(operations.flat().filter(Boolean), this.operationsByMethod));
280
+ const files = await Promise.all(promises);
281
+ return files.flat().filter(Boolean);
282
+ }
283
+ };
284
+ _operationsByMethod = new WeakMap();
285
+ _getOptions = new WeakSet();
286
+ getOptions_fn = function(operation, method) {
287
+ const { override = [] } = this.context;
288
+ return _optionalChain([override, 'access', _43 => _43.find, 'call', _44 => _44(({ pattern, type }) => {
289
+ if (type === "tag") {
290
+ return !!_optionalChain([operation, 'access', _45 => _45.getTags, 'call', _46 => _46(), 'access', _47 => _47[0], 'optionalAccess', _48 => _48.name, 'access', _49 => _49.match, 'call', _50 => _50(pattern)]);
291
+ }
292
+ if (type === "operationId") {
293
+ return !!operation.getOperationId().match(pattern);
294
+ }
295
+ if (type === "path") {
296
+ return !!operation.path.match(pattern);
297
+ }
298
+ if (type === "method") {
299
+ return !!method.match(pattern);
300
+ }
301
+ return false;
302
+ }), 'optionalAccess', _51 => _51.options]) || {};
303
+ };
304
+ _isExcluded = new WeakSet();
305
+ isExcluded_fn = function(operation, method) {
306
+ const { exclude = [] } = this.context;
307
+ let matched = false;
308
+ exclude.forEach(({ pattern, type }) => {
309
+ if (type === "tag" && !matched) {
310
+ matched = !!_optionalChain([operation, 'access', _52 => _52.getTags, 'call', _53 => _53(), 'access', _54 => _54[0], 'optionalAccess', _55 => _55.name, 'access', _56 => _56.match, 'call', _57 => _57(pattern)]);
311
+ }
312
+ if (type === "operationId" && !matched) {
313
+ matched = !!operation.getOperationId().match(pattern);
314
+ }
315
+ if (type === "path" && !matched) {
316
+ matched = !!operation.path.match(pattern);
317
+ }
318
+ if (type === "method" && !matched) {
319
+ matched = !!method.match(pattern);
320
+ }
321
+ });
322
+ return matched;
323
+ };
324
+ _isIncluded = new WeakSet();
325
+ isIncluded_fn = function(operation, method) {
326
+ const { include = [] } = this.context;
327
+ let matched = false;
328
+ include.forEach(({ pattern, type }) => {
329
+ if (type === "tag" && !matched) {
330
+ matched = !!_optionalChain([operation, 'access', _58 => _58.getTags, 'call', _59 => _59(), 'access', _60 => _60[0], 'optionalAccess', _61 => _61.name, 'access', _62 => _62.match, 'call', _63 => _63(pattern)]);
331
+ }
332
+ if (type === "operationId" && !matched) {
333
+ matched = !!operation.getOperationId().match(pattern);
334
+ }
335
+ if (type === "path" && !matched) {
336
+ matched = !!operation.path.match(pattern);
337
+ }
338
+ if (type === "method" && !matched) {
339
+ matched = !!method.match(pattern);
340
+ }
341
+ });
342
+ return matched;
343
+ };
344
+ _methods = new WeakSet();
345
+ methods_get = function() {
346
+ return {
347
+ get: this.get,
348
+ post: this.post,
349
+ patch: this.patch,
350
+ put: this.put,
351
+ delete: this.delete,
352
+ head: void 0,
353
+ options: void 0,
354
+ trace: void 0
355
+ };
356
+ };
357
+
358
+ // src/SchemaGenerator.ts
359
+ _chunk55NUFNT6cjs.init_cjs_shims.call(void 0, );
360
+
361
+
362
+ var _utils = require('@kubb/core/utils');
363
+ var _oas = require('@kubb/oas');
364
+ var _remeda = require('remeda');
365
+ var _usedAliasNames, _getUsedEnumNames, getUsedEnumNames_fn, _getOptions2, getOptions_fn2, _getUnknownReturn, getUnknownReturn_fn, _parseProperties, parseProperties_fn, _getRefAlias, getRefAlias_fn, _getParsedSchemaObject, getParsedSchemaObject_fn, _parseSchemaObject, parseSchemaObject_fn;
366
+ var _SchemaGenerator = class _SchemaGenerator extends _core.Generator {
367
+ constructor() {
368
+ super(...arguments);
369
+ _chunk55NUFNT6cjs.__privateAdd.call(void 0, this, _getUsedEnumNames);
370
+ _chunk55NUFNT6cjs.__privateAdd.call(void 0, this, _getOptions2);
371
+ _chunk55NUFNT6cjs.__privateAdd.call(void 0, this, _getUnknownReturn);
372
+ /**
373
+ * Recursively creates a type literal with the given props.
374
+ */
375
+ _chunk55NUFNT6cjs.__privateAdd.call(void 0, this, _parseProperties);
376
+ /**
377
+ * Create a type alias for the schema referenced by the given ReferenceObject
378
+ */
379
+ _chunk55NUFNT6cjs.__privateAdd.call(void 0, this, _getRefAlias);
380
+ _chunk55NUFNT6cjs.__privateAdd.call(void 0, this, _getParsedSchemaObject);
381
+ /**
382
+ * This is the very core of the OpenAPI to TS conversion - it takes a
383
+ * schema and returns the appropriate type.
384
+ */
385
+ _chunk55NUFNT6cjs.__privateAdd.call(void 0, this, _parseSchemaObject);
386
+ // Collect the types of all referenced schemas, so we can export them later
387
+ this.refs = {};
388
+ // Keep track of already used type aliases
389
+ _chunk55NUFNT6cjs.__privateAdd.call(void 0, this, _usedAliasNames, {});
390
+ }
391
+ /**
392
+ * Creates a type node from a given schema.
393
+ * Delegates to getBaseTypeFromSchema internally and
394
+ * optionally adds a union with null.
395
+ */
396
+ buildSchemas(props) {
397
+ const options = _chunk55NUFNT6cjs.__privateMethod.call(void 0, this, _getOptions2, getOptions_fn2).call(this, props);
398
+ const defaultSchemas = _chunk55NUFNT6cjs.__privateMethod.call(void 0, this, _parseSchemaObject, parseSchemaObject_fn).call(this, props);
399
+ const schemas = _optionalChain([options, 'access', _64 => _64.transformers, 'optionalAccess', _65 => _65.schema, 'optionalCall', _66 => _66(props, defaultSchemas)]) || defaultSchemas || [];
400
+ return _remeda.uniqueWith.call(void 0, schemas, _remeda.isDeepEqual);
401
+ }
402
+ deepSearch(schemas, keyword) {
403
+ return _SchemaGenerator.deepSearch(schemas, keyword);
404
+ }
405
+ find(schemas, keyword) {
406
+ return _SchemaGenerator.find(schemas, keyword);
407
+ }
408
+ static deepSearch(schemas, keyword) {
409
+ const foundItems = [];
410
+ _optionalChain([schemas, 'optionalAccess', _67 => _67.forEach, 'call', _68 => _68((schema) => {
411
+ if (schema.keyword === keyword) {
412
+ foundItems.push(schema);
413
+ }
414
+ if (schema.keyword === _chunkVNFSHGSNcjs.schemaKeywords.object) {
415
+ const subItem = schema;
416
+ Object.values(_optionalChain([subItem, 'access', _69 => _69.args, 'optionalAccess', _70 => _70.properties]) || {}).forEach((entrySchema) => {
417
+ foundItems.push(..._SchemaGenerator.deepSearch(entrySchema, keyword));
418
+ });
419
+ Object.values(_optionalChain([subItem, 'access', _71 => _71.args, 'optionalAccess', _72 => _72.additionalProperties]) || {}).forEach((entrySchema) => {
420
+ foundItems.push(..._SchemaGenerator.deepSearch([entrySchema], keyword));
421
+ });
422
+ }
423
+ if (schema.keyword === _chunkVNFSHGSNcjs.schemaKeywords.array) {
424
+ const subItem = schema;
425
+ subItem.args.items.forEach((entrySchema) => {
426
+ foundItems.push(..._SchemaGenerator.deepSearch([entrySchema], keyword));
427
+ });
428
+ }
429
+ if (schema.keyword === _chunkVNFSHGSNcjs.schemaKeywords.and) {
430
+ const subItem = schema;
431
+ subItem.args.forEach((entrySchema) => {
432
+ foundItems.push(..._SchemaGenerator.deepSearch([entrySchema], keyword));
433
+ });
434
+ }
435
+ if (schema.keyword === _chunkVNFSHGSNcjs.schemaKeywords.tuple) {
436
+ const subItem = schema;
437
+ subItem.args.forEach((entrySchema) => {
438
+ foundItems.push(..._SchemaGenerator.deepSearch([entrySchema], keyword));
439
+ });
440
+ }
441
+ if (schema.keyword === _chunkVNFSHGSNcjs.schemaKeywords.union) {
442
+ const subItem = schema;
443
+ subItem.args.forEach((entrySchema) => {
444
+ foundItems.push(..._SchemaGenerator.deepSearch([entrySchema], keyword));
445
+ });
446
+ }
447
+ })]);
448
+ return foundItems;
449
+ }
450
+ static findInObject(schemas, keyword) {
451
+ let foundItem = void 0;
452
+ _optionalChain([schemas, 'optionalAccess', _73 => _73.forEach, 'call', _74 => _74((schema) => {
453
+ if (!foundItem && schema.keyword === keyword) {
454
+ foundItem = schema;
455
+ }
456
+ if (schema.keyword === _chunkVNFSHGSNcjs.schemaKeywords.object) {
457
+ const subItem = schema;
458
+ Object.values(_optionalChain([subItem, 'access', _75 => _75.args, 'optionalAccess', _76 => _76.properties]) || {}).forEach((entrySchema) => {
459
+ if (!foundItem) {
460
+ foundItem = _SchemaGenerator.find(entrySchema, keyword);
461
+ }
462
+ });
463
+ Object.values(_optionalChain([subItem, 'access', _77 => _77.args, 'optionalAccess', _78 => _78.additionalProperties]) || {}).forEach((entrySchema) => {
464
+ if (!foundItem) {
465
+ foundItem = _SchemaGenerator.find([entrySchema], keyword);
466
+ }
467
+ });
468
+ }
469
+ })]);
470
+ return foundItem;
471
+ }
472
+ static find(schemas, keyword) {
473
+ let foundItem = void 0;
474
+ _optionalChain([schemas, 'optionalAccess', _79 => _79.forEach, 'call', _80 => _80((schema) => {
475
+ if (!foundItem && schema.keyword === keyword) {
476
+ foundItem = schema;
477
+ }
478
+ if (schema.keyword === _chunkVNFSHGSNcjs.schemaKeywords.array) {
479
+ const subItem = schema;
480
+ subItem.args.items.forEach((entrySchema) => {
481
+ if (!foundItem) {
482
+ foundItem = _SchemaGenerator.find([entrySchema], keyword);
483
+ }
484
+ });
485
+ }
486
+ if (schema.keyword === _chunkVNFSHGSNcjs.schemaKeywords.and) {
487
+ const subItem = schema;
488
+ subItem.args.forEach((entrySchema) => {
489
+ if (!foundItem) {
490
+ foundItem = _SchemaGenerator.find([entrySchema], keyword);
491
+ }
492
+ });
493
+ }
494
+ if (schema.keyword === _chunkVNFSHGSNcjs.schemaKeywords.tuple) {
495
+ const subItem = schema;
496
+ subItem.args.forEach((entrySchema) => {
497
+ if (!foundItem) {
498
+ foundItem = _SchemaGenerator.find([entrySchema], keyword);
499
+ }
500
+ });
501
+ }
502
+ if (schema.keyword === _chunkVNFSHGSNcjs.schemaKeywords.union) {
503
+ const subItem = schema;
504
+ subItem.args.forEach((entrySchema) => {
505
+ if (!foundItem) {
506
+ foundItem = _SchemaGenerator.find([entrySchema], keyword);
507
+ }
508
+ });
509
+ }
510
+ })]);
511
+ return foundItem;
512
+ }
513
+ async build() {
514
+ const { oas, contentType, include } = this.context;
515
+ const schemas = _chunkECXSQTMVcjs.getSchemas.call(void 0, { oas, contentType, includes: include });
516
+ const promises = Object.entries(schemas).reduce((acc, [name, schema]) => {
517
+ const promiseOperation = this.schema.call(this, name, schema);
518
+ if (promiseOperation) {
519
+ acc.push(promiseOperation);
520
+ }
521
+ return acc;
522
+ }, []);
523
+ const files = await Promise.all(promises);
524
+ return files.flat().filter(Boolean);
525
+ }
526
+ };
527
+ _usedAliasNames = new WeakMap();
528
+ _getUsedEnumNames = new WeakSet();
529
+ getUsedEnumNames_fn = function(props) {
530
+ const options = _chunk55NUFNT6cjs.__privateMethod.call(void 0, this, _getOptions2, getOptions_fn2).call(this, props);
531
+ return options.usedEnumNames || {};
532
+ };
533
+ _getOptions2 = new WeakSet();
534
+ getOptions_fn2 = function({ name }) {
535
+ const { override = [] } = this.context;
536
+ return {
537
+ ...this.options,
538
+ ..._optionalChain([override, 'access', _81 => _81.find, 'call', _82 => _82(({ pattern, type }) => {
539
+ if (name && type === "schemaName") {
540
+ return !!name.match(pattern);
541
+ }
542
+ return false;
543
+ }), 'optionalAccess', _83 => _83.options]) || {}
544
+ };
545
+ };
546
+ _getUnknownReturn = new WeakSet();
547
+ getUnknownReturn_fn = function(props) {
548
+ const options = _chunk55NUFNT6cjs.__privateMethod.call(void 0, this, _getOptions2, getOptions_fn2).call(this, props);
549
+ if (options.unknownType === "any") {
550
+ return _chunkVNFSHGSNcjs.schemaKeywords.any;
551
+ }
552
+ return _chunkVNFSHGSNcjs.schemaKeywords.unknown;
553
+ };
554
+ _parseProperties = new WeakSet();
555
+ parseProperties_fn = function({ schema, name }) {
556
+ const properties = _optionalChain([schema, 'optionalAccess', _84 => _84.properties]) || {};
557
+ const additionalProperties = _optionalChain([schema, 'optionalAccess', _85 => _85.additionalProperties]);
558
+ const required = _optionalChain([schema, 'optionalAccess', _86 => _86.required]);
559
+ const propertiesSchemas = Object.keys(properties).map((propertyName) => {
560
+ const validationFunctions = [];
561
+ const propertySchema = properties[propertyName];
562
+ const isRequired = Array.isArray(required) ? _optionalChain([required, 'optionalAccess', _87 => _87.includes, 'call', _88 => _88(propertyName)]) : !!required;
563
+ const nullable = _nullishCoalesce(_nullishCoalesce(propertySchema.nullable, () => ( propertySchema["x-nullable"])), () => ( false));
564
+ validationFunctions.push(...this.buildSchemas({ schema: propertySchema, name: propertyName, parentName: name }));
565
+ validationFunctions.push({
566
+ keyword: _chunkVNFSHGSNcjs.schemaKeywords.name,
567
+ args: propertyName
568
+ });
569
+ if (!isRequired && nullable) {
570
+ validationFunctions.push({ keyword: _chunkVNFSHGSNcjs.schemaKeywords.nullish });
571
+ } else if (!isRequired) {
572
+ validationFunctions.push({ keyword: _chunkVNFSHGSNcjs.schemaKeywords.optional });
573
+ }
574
+ return {
575
+ [propertyName]: validationFunctions
576
+ };
577
+ }).reduce((acc, curr) => ({ ...acc, ...curr }), {});
578
+ let additionalPropertiesSchemas = [];
579
+ if (additionalProperties) {
580
+ additionalPropertiesSchemas = additionalProperties === true ? [{ keyword: _chunk55NUFNT6cjs.__privateMethod.call(void 0, this, _getUnknownReturn, getUnknownReturn_fn).call(this, { schema, name }) }] : this.buildSchemas({ schema: additionalProperties, parentName: name });
581
+ }
582
+ return [
583
+ {
584
+ keyword: _chunkVNFSHGSNcjs.schemaKeywords.object,
585
+ args: {
586
+ properties: propertiesSchemas,
587
+ additionalProperties: additionalPropertiesSchemas
588
+ }
589
+ }
590
+ ];
591
+ };
592
+ _getRefAlias = new WeakSet();
593
+ getRefAlias_fn = function(obj) {
594
+ const { $ref } = obj;
595
+ let ref = this.refs[$ref];
596
+ const originalName = _utils.getUniqueName.call(void 0, $ref.replace(/.+\//, ""), _chunk55NUFNT6cjs.__privateGet.call(void 0, this, _usedAliasNames));
597
+ const propertyName = this.context.pluginManager.resolveName({
598
+ name: originalName,
599
+ pluginKey: this.context.plugin.key,
600
+ type: "function"
601
+ });
602
+ if (ref) {
603
+ return [
604
+ {
605
+ keyword: _chunkVNFSHGSNcjs.schemaKeywords.ref,
606
+ args: { name: ref.propertyName, path: ref.path }
607
+ }
608
+ ];
609
+ }
610
+ const fileName = this.context.pluginManager.resolveName({
611
+ name: originalName,
612
+ pluginKey: this.context.plugin.key,
613
+ type: "file"
614
+ });
615
+ const file = this.context.pluginManager.getFile({
616
+ name: fileName,
617
+ pluginKey: this.context.plugin.key,
618
+ extName: ".ts"
619
+ });
620
+ ref = this.refs[$ref] = {
621
+ propertyName,
622
+ originalName,
623
+ path: file.path
624
+ };
625
+ return [
626
+ {
627
+ keyword: _chunkVNFSHGSNcjs.schemaKeywords.ref,
628
+ args: { name: ref.propertyName, path: _optionalChain([ref, 'optionalAccess', _89 => _89.path]), isTypeOnly: false }
629
+ }
630
+ ];
631
+ };
632
+ _getParsedSchemaObject = new WeakSet();
633
+ getParsedSchemaObject_fn = function(schema) {
634
+ const parsedSchema = _chunkECXSQTMVcjs.getSchemaFactory.call(void 0, this.context.oas)(schema);
635
+ return parsedSchema;
636
+ };
637
+ _parseSchemaObject = new WeakSet();
638
+ parseSchemaObject_fn = function({ schema: _schema, name, parentName }) {
639
+ const options = _chunk55NUFNT6cjs.__privateMethod.call(void 0, this, _getOptions2, getOptions_fn2).call(this, { schema: _schema, name });
640
+ const unknownReturn = _chunk55NUFNT6cjs.__privateMethod.call(void 0, this, _getUnknownReturn, getUnknownReturn_fn).call(this, { schema: _schema, name });
641
+ const { schema, version } = _chunk55NUFNT6cjs.__privateMethod.call(void 0, this, _getParsedSchemaObject, getParsedSchemaObject_fn).call(this, _schema);
642
+ const resolvedName = this.context.pluginManager.resolveName({
643
+ name: `${parentName || ""} ${name}`,
644
+ pluginKey: this.context.plugin.key,
645
+ type: "type"
646
+ });
647
+ if (!schema) {
648
+ return [{ keyword: unknownReturn }];
649
+ }
650
+ const baseItems = [
651
+ {
652
+ keyword: _chunkVNFSHGSNcjs.schemaKeywords.schema,
653
+ args: {
654
+ type: schema.type,
655
+ format: schema.format
656
+ }
657
+ }
658
+ ];
659
+ const min = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(schema.minimum, () => ( schema.minLength)), () => ( schema.minItems)), () => ( void 0));
660
+ const max = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(schema.maximum, () => ( schema.maxLength)), () => ( schema.maxItems)), () => ( void 0));
661
+ const nullable = _nullishCoalesce(_nullishCoalesce(schema.nullable, () => ( schema["x-nullable"])), () => ( false));
662
+ if (schema.default !== void 0 && !Array.isArray(schema.default)) {
663
+ if (typeof schema.default === "string") {
664
+ baseItems.push({
665
+ keyword: _chunkVNFSHGSNcjs.schemaKeywords.default,
666
+ args: _transformers2.default.stringify(schema.default)
667
+ });
668
+ }
669
+ if (typeof schema.default === "boolean") {
670
+ baseItems.push({
671
+ keyword: _chunkVNFSHGSNcjs.schemaKeywords.default,
672
+ args: _nullishCoalesce(schema.default, () => ( false))
673
+ });
674
+ }
675
+ }
676
+ if (schema.description) {
677
+ baseItems.push({
678
+ keyword: _chunkVNFSHGSNcjs.schemaKeywords.describe,
679
+ args: schema.description
680
+ });
681
+ }
682
+ if (schema.pattern) {
683
+ baseItems.unshift({
684
+ keyword: _chunkVNFSHGSNcjs.schemaKeywords.matches,
685
+ args: schema.pattern
686
+ });
687
+ }
688
+ if (max !== void 0) {
689
+ baseItems.unshift({ keyword: _chunkVNFSHGSNcjs.schemaKeywords.max, args: max });
690
+ }
691
+ if (min !== void 0) {
692
+ baseItems.unshift({ keyword: _chunkVNFSHGSNcjs.schemaKeywords.min, args: min });
693
+ }
694
+ if (nullable) {
695
+ baseItems.push({ keyword: _chunkVNFSHGSNcjs.schemaKeywords.nullable });
696
+ }
697
+ if (schema.type && Array.isArray(schema.type)) {
698
+ const [_schema2, nullable2] = schema.type;
699
+ if (nullable2 === "null") {
700
+ baseItems.push({ keyword: _chunkVNFSHGSNcjs.schemaKeywords.nullable });
701
+ }
702
+ }
703
+ if (schema.readOnly) {
704
+ baseItems.push({ keyword: _chunkVNFSHGSNcjs.schemaKeywords.readOnly });
705
+ }
706
+ if (_oas.isReference.call(void 0, schema)) {
707
+ return [..._chunk55NUFNT6cjs.__privateMethod.call(void 0, this, _getRefAlias, getRefAlias_fn).call(this, schema), ...baseItems];
708
+ }
709
+ if (schema.oneOf) {
710
+ const schemaWithoutOneOf = { ...schema, oneOf: void 0 };
711
+ const union = {
712
+ keyword: _chunkVNFSHGSNcjs.schemaKeywords.union,
713
+ args: schema.oneOf.map((item) => {
714
+ return item && this.buildSchemas({ schema: item, name, parentName })[0];
715
+ }).filter(Boolean).filter((item) => {
716
+ return item && item.keyword !== unknownReturn;
717
+ })
718
+ };
719
+ if (schemaWithoutOneOf.properties) {
720
+ return [...this.buildSchemas({ schema: schemaWithoutOneOf, name, parentName }), union, ...baseItems];
721
+ }
722
+ return [union, ...baseItems];
723
+ }
724
+ if (schema.anyOf) {
725
+ const schemaWithoutAnyOf = { ...schema, anyOf: void 0 };
726
+ const union = {
727
+ keyword: _chunkVNFSHGSNcjs.schemaKeywords.union,
728
+ args: schema.anyOf.map((item) => {
729
+ return item && this.buildSchemas({ schema: item, name, parentName })[0];
730
+ }).filter(Boolean).filter((item) => {
731
+ return item && item.keyword !== unknownReturn;
732
+ }).map((item) => {
733
+ if (_chunkVNFSHGSNcjs.isKeyword.call(void 0, item, _chunkVNFSHGSNcjs.schemaKeywords.object)) {
734
+ return {
735
+ ...item,
736
+ args: {
737
+ ...item.args,
738
+ strict: true
739
+ }
740
+ };
741
+ }
742
+ return item;
743
+ })
744
+ };
745
+ if (schemaWithoutAnyOf.properties) {
746
+ return [...this.buildSchemas({ schema: schemaWithoutAnyOf, name, parentName }), union, ...baseItems];
747
+ }
748
+ return [union, ...baseItems];
749
+ }
750
+ if (schema.allOf) {
751
+ const schemaWithoutAllOf = { ...schema, allOf: void 0 };
752
+ const and = {
753
+ keyword: _chunkVNFSHGSNcjs.schemaKeywords.and,
754
+ args: schema.allOf.map((item) => {
755
+ return item && this.buildSchemas({ schema: item, name, parentName })[0];
756
+ }).filter(Boolean).filter((item) => {
757
+ return item && item.keyword !== unknownReturn;
758
+ })
759
+ };
760
+ if (schemaWithoutAllOf.properties) {
761
+ return [
762
+ {
763
+ ...and,
764
+ args: [...and.args || [], ...this.buildSchemas({ schema: schemaWithoutAllOf, name, parentName })]
765
+ },
766
+ ...baseItems
767
+ ];
768
+ }
769
+ return [and, ...baseItems];
770
+ }
771
+ if (schema.enum) {
772
+ const enumName = _utils.getUniqueName.call(void 0, _transformers.pascalCase.call(void 0, [parentName, name, options.enumSuffix].join(" ")), _chunk55NUFNT6cjs.__privateMethod.call(void 0, this, _getUsedEnumNames, getUsedEnumNames_fn).call(this, { schema, name }));
773
+ const typeName = this.context.pluginManager.resolveName({
774
+ name: enumName,
775
+ pluginKey: this.context.plugin.key,
776
+ type: "type"
777
+ });
778
+ const extensionEnums = ["x-enumNames", "x-enum-varnames"].filter((extensionKey) => extensionKey in schema).map((extensionKey) => {
779
+ return [
780
+ {
781
+ keyword: _chunkVNFSHGSNcjs.schemaKeywords.enum,
782
+ args: {
783
+ name,
784
+ typeName,
785
+ asConst: false,
786
+ items: [...new Set(schema[extensionKey])].map((name2, index) => ({
787
+ name: _transformers2.default.stringify(name2),
788
+ value: _optionalChain([schema, 'access', _90 => _90.enum, 'optionalAccess', _91 => _91[index]]),
789
+ format: _remeda.isNumber.call(void 0, _optionalChain([schema, 'access', _92 => _92.enum, 'optionalAccess', _93 => _93[index]])) ? "number" : "string"
790
+ }))
791
+ }
792
+ },
793
+ ...baseItems.filter(
794
+ (item) => item.keyword !== _chunkVNFSHGSNcjs.schemaKeywords.min && item.keyword !== _chunkVNFSHGSNcjs.schemaKeywords.max && item.keyword !== _chunkVNFSHGSNcjs.schemaKeywords.matches
795
+ )
796
+ ];
797
+ });
798
+ if (schema.type === "number" || schema.type === "integer") {
799
+ const enumNames = _optionalChain([extensionEnums, 'access', _94 => _94[0], 'optionalAccess', _95 => _95.find, 'call', _96 => _96((item) => _chunkVNFSHGSNcjs.isKeyword.call(void 0, item, _chunkVNFSHGSNcjs.schemaKeywords.enum))]);
800
+ return [
801
+ {
802
+ keyword: _chunkVNFSHGSNcjs.schemaKeywords.enum,
803
+ args: {
804
+ name: enumName,
805
+ typeName,
806
+ asConst: true,
807
+ items: _optionalChain([enumNames, 'optionalAccess', _97 => _97.args, 'optionalAccess', _98 => _98.items]) ? [...new Set(enumNames.args.items)].map(({ name: name2, value }) => ({
808
+ name: name2,
809
+ value,
810
+ format: "number"
811
+ })) : [...new Set(schema.enum)].map((value) => {
812
+ return {
813
+ name: value,
814
+ value,
815
+ format: "number"
816
+ };
817
+ })
818
+ }
819
+ },
820
+ ...baseItems.filter((item) => item.keyword !== _chunkVNFSHGSNcjs.schemaKeywords.min && item.keyword !== _chunkVNFSHGSNcjs.schemaKeywords.max && item.keyword !== _chunkVNFSHGSNcjs.schemaKeywords.matches)
821
+ ];
822
+ }
823
+ if (extensionEnums.length > 0 && extensionEnums[0]) {
824
+ return extensionEnums[0];
825
+ }
826
+ return [
827
+ {
828
+ keyword: _chunkVNFSHGSNcjs.schemaKeywords.enum,
829
+ args: {
830
+ name: enumName,
831
+ typeName,
832
+ asConst: false,
833
+ items: [...new Set(schema.enum)].map((value) => ({
834
+ name: _transformers2.default.stringify(value),
835
+ value,
836
+ format: _remeda.isNumber.call(void 0, value) ? "number" : "string"
837
+ }))
838
+ }
839
+ },
840
+ ...baseItems.filter((item) => item.keyword !== _chunkVNFSHGSNcjs.schemaKeywords.min && item.keyword !== _chunkVNFSHGSNcjs.schemaKeywords.max && item.keyword !== _chunkVNFSHGSNcjs.schemaKeywords.matches)
841
+ ];
842
+ }
843
+ if ("prefixItems" in schema) {
844
+ const prefixItems = schema.prefixItems;
845
+ return [
846
+ {
847
+ keyword: _chunkVNFSHGSNcjs.schemaKeywords.tuple,
848
+ args: prefixItems.map((item) => {
849
+ return this.buildSchemas({ schema: item, name, parentName })[0];
850
+ }).filter(Boolean)
851
+ },
852
+ ...baseItems
853
+ ];
854
+ }
855
+ if (version === "3.1" && "const" in schema) {
856
+ if (schema["const"]) {
857
+ return [
858
+ {
859
+ keyword: _chunkVNFSHGSNcjs.schemaKeywords.const,
860
+ args: {
861
+ name: schema["const"],
862
+ format: typeof schema["const"] === "number" ? "number" : "string",
863
+ value: schema["const"]
864
+ }
865
+ },
866
+ ...baseItems
867
+ ];
868
+ }
869
+ return [{ keyword: _chunkVNFSHGSNcjs.schemaKeywords.null }];
870
+ }
871
+ if (schema.format) {
872
+ switch (schema.format) {
873
+ case "binary":
874
+ baseItems.push({ keyword: _chunkVNFSHGSNcjs.schemaKeywords.blob });
875
+ return baseItems;
876
+ case "date-time":
877
+ if (options.dateType) {
878
+ if (options.dateType === "date") {
879
+ baseItems.unshift({ keyword: _chunkVNFSHGSNcjs.schemaKeywords.date, args: { type: "date" } });
880
+ return baseItems;
881
+ }
882
+ if (options.dateType === "stringOffset") {
883
+ baseItems.unshift({ keyword: _chunkVNFSHGSNcjs.schemaKeywords.datetime, args: { offset: true } });
884
+ return baseItems;
885
+ }
886
+ if (options.dateType === "stringLocal") {
887
+ baseItems.unshift({ keyword: _chunkVNFSHGSNcjs.schemaKeywords.datetime, args: { local: true } });
888
+ return baseItems;
889
+ }
890
+ baseItems.unshift({ keyword: _chunkVNFSHGSNcjs.schemaKeywords.datetime, args: { offset: false } });
891
+ return baseItems;
892
+ }
893
+ break;
894
+ case "date":
895
+ if (options.dateType) {
896
+ if (options.dateType === "date") {
897
+ baseItems.unshift({ keyword: _chunkVNFSHGSNcjs.schemaKeywords.date, args: { type: "date" } });
898
+ return baseItems;
899
+ }
900
+ baseItems.unshift({ keyword: _chunkVNFSHGSNcjs.schemaKeywords.date, args: { type: "string" } });
901
+ return baseItems;
902
+ }
903
+ break;
904
+ case "time":
905
+ if (options.dateType) {
906
+ if (options.dateType === "date") {
907
+ baseItems.unshift({ keyword: _chunkVNFSHGSNcjs.schemaKeywords.time, args: { type: "date" } });
908
+ return baseItems;
909
+ }
910
+ baseItems.unshift({ keyword: _chunkVNFSHGSNcjs.schemaKeywords.time, args: { type: "string" } });
911
+ return baseItems;
912
+ }
913
+ break;
914
+ case "uuid":
915
+ baseItems.unshift({ keyword: _chunkVNFSHGSNcjs.schemaKeywords.uuid });
916
+ break;
917
+ case "email":
918
+ case "idn-email":
919
+ baseItems.unshift({ keyword: _chunkVNFSHGSNcjs.schemaKeywords.email });
920
+ break;
921
+ case "uri":
922
+ case "ipv4":
923
+ case "ipv6":
924
+ case "uri-reference":
925
+ case "hostname":
926
+ case "idn-hostname":
927
+ baseItems.unshift({ keyword: _chunkVNFSHGSNcjs.schemaKeywords.url });
928
+ break;
929
+ default:
930
+ break;
931
+ }
932
+ }
933
+ if ("items" in schema || schema.type === "array") {
934
+ const min2 = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(schema.minimum, () => ( schema.minLength)), () => ( schema.minItems)), () => ( void 0));
935
+ const max2 = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(schema.maximum, () => ( schema.maxLength)), () => ( schema.maxItems)), () => ( void 0));
936
+ const items = this.buildSchemas({ schema: "items" in schema ? schema.items : [], name, parentName });
937
+ return [
938
+ {
939
+ keyword: _chunkVNFSHGSNcjs.schemaKeywords.array,
940
+ args: {
941
+ items,
942
+ min: min2,
943
+ max: max2
944
+ }
945
+ },
946
+ ...baseItems.filter((item) => item.keyword !== _chunkVNFSHGSNcjs.schemaKeywords.min && item.keyword !== _chunkVNFSHGSNcjs.schemaKeywords.max)
947
+ ];
948
+ }
949
+ if (schema.properties || schema.additionalProperties) {
950
+ return [..._chunk55NUFNT6cjs.__privateMethod.call(void 0, this, _parseProperties, parseProperties_fn).call(this, { schema, name }), ...baseItems];
951
+ }
952
+ if (schema.type) {
953
+ if (Array.isArray(schema.type)) {
954
+ const [type] = schema.type;
955
+ return [
956
+ ...this.buildSchemas({
957
+ schema: {
958
+ ...schema,
959
+ type
960
+ },
961
+ name,
962
+ parentName
963
+ }),
964
+ ...baseItems
965
+ ].filter(Boolean);
966
+ }
967
+ return [{ keyword: schema.type }, ...baseItems];
968
+ }
969
+ return [{ keyword: unknownReturn }];
970
+ };
971
+ var SchemaGenerator = _SchemaGenerator;
972
+
973
+ // src/index.ts
974
+ var definePluginDefault = pluginOas;
975
+ var src_default = definePluginDefault;
976
+
977
+
978
+
979
+
980
+
981
+
982
+
983
+
984
+ exports.OperationGenerator = OperationGenerator; exports.SchemaGenerator = SchemaGenerator; exports.default = src_default; exports.isKeyword = _chunkVNFSHGSNcjs.isKeyword; exports.pluginOas = pluginOas; exports.pluginOasName = pluginOasName; exports.schemaKeywords = _chunkVNFSHGSNcjs.schemaKeywords;
985
+ //# sourceMappingURL=index.cjs.map