@kubb/plugin-oas 3.0.0-alpha.2 → 3.0.0-alpha.4

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 (50) hide show
  1. package/dist/OperationGenerator-D7rSlflc.d.cts +158 -0
  2. package/dist/OperationGenerator-vw0Zf-Mi.d.ts +158 -0
  3. package/dist/{Schema-an5hOrjZ.d.cts → Schema-DxyOIX7q.d.cts} +1 -1
  4. package/dist/{Schema-DefwBJMc.d.ts → Schema-gHgN14i2.d.ts} +1 -1
  5. package/dist/{SchemaMapper-CsBQ6eEx.d.cts → SchemaMapper-BM1IGWqD.d.cts} +1 -1
  6. package/dist/{SchemaMapper-CsBQ6eEx.d.ts → SchemaMapper-BM1IGWqD.d.ts} +1 -1
  7. package/dist/{chunk-DRLYORTT.cjs → chunk-264TCCJF.cjs} +715 -7
  8. package/dist/chunk-264TCCJF.cjs.map +1 -0
  9. package/dist/chunk-7KIEQOVZ.cjs +7 -0
  10. package/dist/chunk-7KIEQOVZ.cjs.map +1 -0
  11. package/dist/{chunk-LEACSHKT.js → chunk-FZN3PBEK.js} +713 -5
  12. package/dist/chunk-FZN3PBEK.js.map +1 -0
  13. package/dist/chunk-TWKZEVSM.js +7 -0
  14. package/dist/chunk-TWKZEVSM.js.map +1 -0
  15. package/dist/components.cjs +4 -9
  16. package/dist/components.cjs.map +1 -1
  17. package/dist/components.d.cts +12 -6
  18. package/dist/components.d.ts +12 -6
  19. package/dist/components.js +3 -8
  20. package/dist/components.js.map +1 -1
  21. package/dist/hooks.cjs +6 -7
  22. package/dist/hooks.cjs.map +1 -1
  23. package/dist/hooks.d.cts +3 -3
  24. package/dist/hooks.d.ts +3 -3
  25. package/dist/hooks.js +1 -2
  26. package/dist/hooks.js.map +1 -1
  27. package/dist/index.cjs +225 -153
  28. package/dist/index.cjs.map +1 -1
  29. package/dist/index.d.cts +8 -77
  30. package/dist/index.d.ts +8 -77
  31. package/dist/index.js +207 -135
  32. package/dist/index.js.map +1 -1
  33. package/dist/{types-Dte3MA6H.d.cts → types-C2RXaY0_.d.cts} +1 -1
  34. package/dist/{types-Dte3MA6H.d.ts → types-C2RXaY0_.d.ts} +1 -1
  35. package/dist/utils.d.cts +2 -2
  36. package/dist/utils.d.ts +2 -2
  37. package/package.json +9 -9
  38. package/src/OperationGenerator.ts +62 -31
  39. package/src/SchemaGenerator.ts +23 -4
  40. package/src/components/Oas.tsx +8 -2
  41. package/src/index.ts +3 -9
  42. package/src/parser.tsx +120 -0
  43. package/dist/OperationGenerator-CeM_9pxW.d.cts +0 -60
  44. package/dist/OperationGenerator-DhUhvRJE.d.ts +0 -60
  45. package/dist/chunk-CJXRFYEF.cjs +0 -698
  46. package/dist/chunk-CJXRFYEF.cjs.map +0 -1
  47. package/dist/chunk-DRLYORTT.cjs.map +0 -1
  48. package/dist/chunk-K6KUETAI.js +0 -698
  49. package/dist/chunk-K6KUETAI.js.map +0 -1
  50. package/dist/chunk-LEACSHKT.js.map +0 -1
@@ -1,7 +1,8 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); 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; }
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
+
2
4
 
3
5
 
4
- var _chunkCJXRFYEFcjs = require('./chunk-CJXRFYEF.cjs');
5
6
 
6
7
 
7
8
 
@@ -3103,6 +3104,709 @@ var require_jsx_runtime = _chunkP42X362Ucjs.__commonJS.call(void 0, {
3103
3104
  }
3104
3105
  });
3105
3106
 
3107
+ // src/SchemaMapper.ts
3108
+ _chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
3109
+ var schemaKeywords = {
3110
+ any: "any",
3111
+ strict: "strict",
3112
+ unknown: "unknown",
3113
+ number: "number",
3114
+ integer: "integer",
3115
+ string: "string",
3116
+ boolean: "boolean",
3117
+ undefined: "undefined",
3118
+ nullable: "nullable",
3119
+ null: "null",
3120
+ nullish: "nullish",
3121
+ array: "array",
3122
+ tuple: "tuple",
3123
+ enum: "enum",
3124
+ union: "union",
3125
+ datetime: "datetime",
3126
+ date: "date",
3127
+ email: "email",
3128
+ uuid: "uuid",
3129
+ url: "url",
3130
+ /* intersection */
3131
+ default: "default",
3132
+ const: "const",
3133
+ and: "and",
3134
+ describe: "describe",
3135
+ min: "min",
3136
+ max: "max",
3137
+ optional: "optional",
3138
+ readOnly: "readOnly",
3139
+ // custom ones
3140
+ object: "object",
3141
+ ref: "ref",
3142
+ matches: "matches",
3143
+ firstName: "firstName",
3144
+ lastName: "lastName",
3145
+ password: "password",
3146
+ phone: "phone",
3147
+ blob: "blob",
3148
+ deprecated: "deprecated",
3149
+ example: "example",
3150
+ schema: "schema",
3151
+ catchall: "catchall",
3152
+ time: "time",
3153
+ name: "name"
3154
+ };
3155
+ function isKeyword(meta, keyword) {
3156
+ return meta.keyword === keyword;
3157
+ }
3158
+
3159
+ // src/SchemaGenerator.ts
3160
+ _chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
3161
+ var _core = require('@kubb/core');
3162
+ var _transformers = require('@kubb/core/transformers'); var _transformers2 = _interopRequireDefault(_transformers);
3163
+ var _utils = require('@kubb/core/utils');
3164
+ var _oas = require('@kubb/oas');
3165
+ var _remeda = require('remeda');
3166
+ var _usedAliasNames, _SchemaGenerator_instances, getUsedEnumNames_fn, getOptions_fn, getUnknownReturn_fn, parseProperties_fn, getRefAlias_fn, getParsedSchemaObject_fn, parseSchemaObject_fn;
3167
+ var _SchemaGenerator = class _SchemaGenerator extends _core.Generator {
3168
+ constructor() {
3169
+ super(...arguments);
3170
+ _chunkP42X362Ucjs.__privateAdd.call(void 0, this, _SchemaGenerator_instances);
3171
+ // Collect the types of all referenced schemas, so we can export them later
3172
+ this.refs = {};
3173
+ // Keep track of already used type aliases
3174
+ _chunkP42X362Ucjs.__privateAdd.call(void 0, this, _usedAliasNames, {});
3175
+ }
3176
+ /**
3177
+ * Creates a type node from a given schema.
3178
+ * Delegates to getBaseTypeFromSchema internally and
3179
+ * optionally adds a union with null.
3180
+ */
3181
+ parse(props) {
3182
+ const options = _chunkP42X362Ucjs.__privateMethod.call(void 0, this, _SchemaGenerator_instances, getOptions_fn).call(this, props);
3183
+ const defaultSchemas = _chunkP42X362Ucjs.__privateMethod.call(void 0, this, _SchemaGenerator_instances, parseSchemaObject_fn).call(this, props);
3184
+ const schemas = _optionalChain([options, 'access', _ => _.transformers, 'optionalAccess', _2 => _2.schema, 'optionalCall', _3 => _3(props, defaultSchemas)]) || defaultSchemas || [];
3185
+ return _remeda.uniqueWith.call(void 0, schemas, _remeda.isDeepEqual);
3186
+ }
3187
+ deepSearch(tree, keyword) {
3188
+ return _SchemaGenerator.deepSearch(tree, keyword);
3189
+ }
3190
+ find(tree, keyword) {
3191
+ return _SchemaGenerator.find(tree, keyword);
3192
+ }
3193
+ static deepSearch(tree, keyword) {
3194
+ const foundItems = [];
3195
+ _optionalChain([tree, 'optionalAccess', _4 => _4.forEach, 'call', _5 => _5((schema) => {
3196
+ if (schema.keyword === keyword) {
3197
+ foundItems.push(schema);
3198
+ }
3199
+ if (schema.keyword === schemaKeywords.object) {
3200
+ const subItem = schema;
3201
+ Object.values(_optionalChain([subItem, 'access', _6 => _6.args, 'optionalAccess', _7 => _7.properties]) || {}).forEach((entrySchema) => {
3202
+ foundItems.push(..._SchemaGenerator.deepSearch(entrySchema, keyword));
3203
+ });
3204
+ Object.values(_optionalChain([subItem, 'access', _8 => _8.args, 'optionalAccess', _9 => _9.additionalProperties]) || {}).forEach((entrySchema) => {
3205
+ foundItems.push(..._SchemaGenerator.deepSearch([entrySchema], keyword));
3206
+ });
3207
+ }
3208
+ if (schema.keyword === schemaKeywords.array) {
3209
+ const subItem = schema;
3210
+ subItem.args.items.forEach((entrySchema) => {
3211
+ foundItems.push(..._SchemaGenerator.deepSearch([entrySchema], keyword));
3212
+ });
3213
+ }
3214
+ if (schema.keyword === schemaKeywords.and) {
3215
+ const subItem = schema;
3216
+ subItem.args.forEach((entrySchema) => {
3217
+ foundItems.push(..._SchemaGenerator.deepSearch([entrySchema], keyword));
3218
+ });
3219
+ }
3220
+ if (schema.keyword === schemaKeywords.tuple) {
3221
+ const subItem = schema;
3222
+ subItem.args.items.forEach((entrySchema) => {
3223
+ foundItems.push(..._SchemaGenerator.deepSearch([entrySchema], keyword));
3224
+ });
3225
+ }
3226
+ if (schema.keyword === schemaKeywords.union) {
3227
+ const subItem = schema;
3228
+ subItem.args.forEach((entrySchema) => {
3229
+ foundItems.push(..._SchemaGenerator.deepSearch([entrySchema], keyword));
3230
+ });
3231
+ }
3232
+ })]);
3233
+ return foundItems;
3234
+ }
3235
+ static findInObject(tree, keyword) {
3236
+ let foundItem = void 0;
3237
+ _optionalChain([tree, 'optionalAccess', _10 => _10.forEach, 'call', _11 => _11((schema) => {
3238
+ if (!foundItem && schema.keyword === keyword) {
3239
+ foundItem = schema;
3240
+ }
3241
+ if (schema.keyword === schemaKeywords.object) {
3242
+ const subItem = schema;
3243
+ Object.values(_optionalChain([subItem, 'access', _12 => _12.args, 'optionalAccess', _13 => _13.properties]) || {}).forEach((entrySchema) => {
3244
+ if (!foundItem) {
3245
+ foundItem = _SchemaGenerator.find(entrySchema, keyword);
3246
+ }
3247
+ });
3248
+ Object.values(_optionalChain([subItem, 'access', _14 => _14.args, 'optionalAccess', _15 => _15.additionalProperties]) || {}).forEach((entrySchema) => {
3249
+ if (!foundItem) {
3250
+ foundItem = _SchemaGenerator.find([entrySchema], keyword);
3251
+ }
3252
+ });
3253
+ }
3254
+ })]);
3255
+ return foundItem;
3256
+ }
3257
+ static find(tree, keyword) {
3258
+ let foundItem = void 0;
3259
+ _optionalChain([tree, 'optionalAccess', _16 => _16.forEach, 'call', _17 => _17((schema) => {
3260
+ if (!foundItem && schema.keyword === keyword) {
3261
+ foundItem = schema;
3262
+ }
3263
+ if (schema.keyword === schemaKeywords.array) {
3264
+ const subItem = schema;
3265
+ subItem.args.items.forEach((entrySchema) => {
3266
+ if (!foundItem) {
3267
+ foundItem = _SchemaGenerator.find([entrySchema], keyword);
3268
+ }
3269
+ });
3270
+ }
3271
+ if (schema.keyword === schemaKeywords.and) {
3272
+ const subItem = schema;
3273
+ subItem.args.forEach((entrySchema) => {
3274
+ if (!foundItem) {
3275
+ foundItem = _SchemaGenerator.find([entrySchema], keyword);
3276
+ }
3277
+ });
3278
+ }
3279
+ if (schema.keyword === schemaKeywords.tuple) {
3280
+ const subItem = schema;
3281
+ subItem.args.items.forEach((entrySchema) => {
3282
+ if (!foundItem) {
3283
+ foundItem = _SchemaGenerator.find([entrySchema], keyword);
3284
+ }
3285
+ });
3286
+ }
3287
+ if (schema.keyword === schemaKeywords.union) {
3288
+ const subItem = schema;
3289
+ subItem.args.forEach((entrySchema) => {
3290
+ if (!foundItem) {
3291
+ foundItem = _SchemaGenerator.find([entrySchema], keyword);
3292
+ }
3293
+ });
3294
+ }
3295
+ })]);
3296
+ return foundItem;
3297
+ }
3298
+ async build(...parsers) {
3299
+ const { oas, contentType, include } = this.context;
3300
+ const schemas = _chunkP42X362Ucjs.getSchemas.call(void 0, { oas, contentType, includes: include });
3301
+ const promises = Object.entries(schemas).reduce((acc, [name, schema]) => {
3302
+ const options = _chunkP42X362Ucjs.__privateMethod.call(void 0, this, _SchemaGenerator_instances, getOptions_fn).call(this, { name });
3303
+ const promiseOperation = this.schema.call(this, name, schema, {
3304
+ ...this.options,
3305
+ ...options
3306
+ });
3307
+ if (promiseOperation) {
3308
+ acc.push(promiseOperation);
3309
+ }
3310
+ _optionalChain([parsers, 'optionalAccess', _18 => _18.forEach, 'call', _19 => _19((parser) => {
3311
+ const promise = _optionalChain([parser, 'access', _20 => _20.schema, 'optionalCall', _21 => _21({
3312
+ instance: this,
3313
+ name,
3314
+ schema,
3315
+ options: {
3316
+ ...this.options,
3317
+ ...options
3318
+ }
3319
+ })]);
3320
+ if (promise) {
3321
+ acc.push(promise);
3322
+ }
3323
+ })]);
3324
+ return acc;
3325
+ }, []);
3326
+ const files = await Promise.all(promises);
3327
+ return files.flat().filter(Boolean);
3328
+ }
3329
+ /**
3330
+ * Schema
3331
+ */
3332
+ async schema(name, object, options) {
3333
+ return [];
3334
+ }
3335
+ };
3336
+ _usedAliasNames = new WeakMap();
3337
+ _SchemaGenerator_instances = new WeakSet();
3338
+ getUsedEnumNames_fn = function(props) {
3339
+ const options = _chunkP42X362Ucjs.__privateMethod.call(void 0, this, _SchemaGenerator_instances, getOptions_fn).call(this, props);
3340
+ return options.usedEnumNames || {};
3341
+ };
3342
+ getOptions_fn = function({ name }) {
3343
+ const { override = [] } = this.context;
3344
+ return {
3345
+ ...this.options,
3346
+ ..._optionalChain([override, 'access', _22 => _22.find, 'call', _23 => _23(({ pattern, type }) => {
3347
+ if (name && type === "schemaName") {
3348
+ return !!name.match(pattern);
3349
+ }
3350
+ return false;
3351
+ }), 'optionalAccess', _24 => _24.options]) || {}
3352
+ };
3353
+ };
3354
+ getUnknownReturn_fn = function(props) {
3355
+ const options = _chunkP42X362Ucjs.__privateMethod.call(void 0, this, _SchemaGenerator_instances, getOptions_fn).call(this, props);
3356
+ if (options.unknownType === "any") {
3357
+ return schemaKeywords.any;
3358
+ }
3359
+ return schemaKeywords.unknown;
3360
+ };
3361
+ /**
3362
+ * Recursively creates a type literal with the given props.
3363
+ */
3364
+ parseProperties_fn = function({ schema, name }) {
3365
+ const properties = _optionalChain([schema, 'optionalAccess', _25 => _25.properties]) || {};
3366
+ const additionalProperties = _optionalChain([schema, 'optionalAccess', _26 => _26.additionalProperties]);
3367
+ const required = _optionalChain([schema, 'optionalAccess', _27 => _27.required]);
3368
+ const propertiesSchemas = Object.keys(properties).map((propertyName) => {
3369
+ const validationFunctions = [];
3370
+ const propertySchema = properties[propertyName];
3371
+ const isRequired = Array.isArray(required) ? _optionalChain([required, 'optionalAccess', _28 => _28.includes, 'call', _29 => _29(propertyName)]) : !!required;
3372
+ const nullable = _nullishCoalesce(_nullishCoalesce(propertySchema.nullable, () => ( propertySchema["x-nullable"])), () => ( false));
3373
+ validationFunctions.push(...this.parse({ schema: propertySchema, name: propertyName, parentName: name }));
3374
+ validationFunctions.push({
3375
+ keyword: schemaKeywords.name,
3376
+ args: propertyName
3377
+ });
3378
+ if (!isRequired && nullable) {
3379
+ validationFunctions.push({ keyword: schemaKeywords.nullish });
3380
+ } else if (!isRequired) {
3381
+ validationFunctions.push({ keyword: schemaKeywords.optional });
3382
+ }
3383
+ return {
3384
+ [propertyName]: validationFunctions
3385
+ };
3386
+ }).reduce((acc, curr) => ({ ...acc, ...curr }), {});
3387
+ let additionalPropertiesSchemas = [];
3388
+ if (additionalProperties) {
3389
+ additionalPropertiesSchemas = additionalProperties === true ? [{ keyword: _chunkP42X362Ucjs.__privateMethod.call(void 0, this, _SchemaGenerator_instances, getUnknownReturn_fn).call(this, { schema, name }) }] : this.parse({ schema: additionalProperties, parentName: name });
3390
+ }
3391
+ return [
3392
+ {
3393
+ keyword: schemaKeywords.object,
3394
+ args: {
3395
+ properties: propertiesSchemas,
3396
+ additionalProperties: additionalPropertiesSchemas
3397
+ }
3398
+ }
3399
+ ];
3400
+ };
3401
+ /**
3402
+ * Create a type alias for the schema referenced by the given ReferenceObject
3403
+ */
3404
+ getRefAlias_fn = function(obj) {
3405
+ const { $ref } = obj;
3406
+ let ref = this.refs[$ref];
3407
+ const originalName = _utils.getUniqueName.call(void 0, $ref.replace(/.+\//, ""), _chunkP42X362Ucjs.__privateGet.call(void 0, this, _usedAliasNames));
3408
+ const propertyName = this.context.pluginManager.resolveName({
3409
+ name: originalName,
3410
+ pluginKey: this.context.plugin.key,
3411
+ type: "function"
3412
+ });
3413
+ if (ref) {
3414
+ return [
3415
+ {
3416
+ keyword: schemaKeywords.ref,
3417
+ args: { name: ref.propertyName, path: ref.path }
3418
+ }
3419
+ ];
3420
+ }
3421
+ const fileName = this.context.pluginManager.resolveName({
3422
+ name: originalName,
3423
+ pluginKey: this.context.plugin.key,
3424
+ type: "file"
3425
+ });
3426
+ const file = this.context.pluginManager.getFile({
3427
+ name: fileName,
3428
+ pluginKey: this.context.plugin.key,
3429
+ extName: ".ts"
3430
+ });
3431
+ ref = this.refs[$ref] = {
3432
+ propertyName,
3433
+ originalName,
3434
+ path: file.path
3435
+ };
3436
+ return [
3437
+ {
3438
+ keyword: schemaKeywords.ref,
3439
+ args: { name: ref.propertyName, path: _optionalChain([ref, 'optionalAccess', _30 => _30.path]), isTypeOnly: false }
3440
+ }
3441
+ ];
3442
+ };
3443
+ getParsedSchemaObject_fn = function(schema) {
3444
+ const parsedSchema = _chunkP42X362Ucjs.getSchemaFactory.call(void 0, this.context.oas)(schema);
3445
+ return parsedSchema;
3446
+ };
3447
+ /**
3448
+ * This is the very core of the OpenAPI to TS conversion - it takes a
3449
+ * schema and returns the appropriate type.
3450
+ */
3451
+ parseSchemaObject_fn = function({ schema: _schema, name, parentName }) {
3452
+ const options = _chunkP42X362Ucjs.__privateMethod.call(void 0, this, _SchemaGenerator_instances, getOptions_fn).call(this, { schema: _schema, name });
3453
+ const unknownReturn = _chunkP42X362Ucjs.__privateMethod.call(void 0, this, _SchemaGenerator_instances, getUnknownReturn_fn).call(this, { schema: _schema, name });
3454
+ const { schema, version } = _chunkP42X362Ucjs.__privateMethod.call(void 0, this, _SchemaGenerator_instances, getParsedSchemaObject_fn).call(this, _schema);
3455
+ const resolvedName = this.context.pluginManager.resolveName({
3456
+ name: `${parentName || ""} ${name}`,
3457
+ pluginKey: this.context.plugin.key,
3458
+ type: "type"
3459
+ });
3460
+ if (!schema) {
3461
+ return [{ keyword: unknownReturn }];
3462
+ }
3463
+ const baseItems = [
3464
+ {
3465
+ keyword: schemaKeywords.schema,
3466
+ args: {
3467
+ type: schema.type,
3468
+ format: schema.format
3469
+ }
3470
+ }
3471
+ ];
3472
+ const min = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(schema.minimum, () => ( schema.minLength)), () => ( schema.minItems)), () => ( void 0));
3473
+ const max = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(schema.maximum, () => ( schema.maxLength)), () => ( schema.maxItems)), () => ( void 0));
3474
+ const nullable = _nullishCoalesce(_nullishCoalesce(schema.nullable, () => ( schema["x-nullable"])), () => ( false));
3475
+ if (schema.default !== void 0 && !Array.isArray(schema.default)) {
3476
+ if (typeof schema.default === "string") {
3477
+ baseItems.push({
3478
+ keyword: schemaKeywords.default,
3479
+ args: _transformers2.default.stringify(schema.default)
3480
+ });
3481
+ }
3482
+ if (typeof schema.default === "boolean") {
3483
+ baseItems.push({
3484
+ keyword: schemaKeywords.default,
3485
+ args: _nullishCoalesce(schema.default, () => ( false))
3486
+ });
3487
+ }
3488
+ }
3489
+ if (schema.description) {
3490
+ baseItems.push({
3491
+ keyword: schemaKeywords.describe,
3492
+ args: schema.description
3493
+ });
3494
+ }
3495
+ if (schema.pattern) {
3496
+ baseItems.unshift({
3497
+ keyword: schemaKeywords.matches,
3498
+ args: schema.pattern
3499
+ });
3500
+ }
3501
+ if (max !== void 0) {
3502
+ baseItems.unshift({ keyword: schemaKeywords.max, args: max });
3503
+ }
3504
+ if (min !== void 0) {
3505
+ baseItems.unshift({ keyword: schemaKeywords.min, args: min });
3506
+ }
3507
+ if (nullable) {
3508
+ baseItems.push({ keyword: schemaKeywords.nullable });
3509
+ }
3510
+ if (schema.type && Array.isArray(schema.type)) {
3511
+ const [_schema2, nullable2] = schema.type;
3512
+ if (nullable2 === "null") {
3513
+ baseItems.push({ keyword: schemaKeywords.nullable });
3514
+ }
3515
+ }
3516
+ if (schema.readOnly) {
3517
+ baseItems.push({ keyword: schemaKeywords.readOnly });
3518
+ }
3519
+ if (_oas.isReference.call(void 0, schema)) {
3520
+ return [
3521
+ ..._chunkP42X362Ucjs.__privateMethod.call(void 0, this, _SchemaGenerator_instances, getRefAlias_fn).call(this, schema),
3522
+ nullable && { keyword: schemaKeywords.nullable },
3523
+ {
3524
+ keyword: schemaKeywords.schema,
3525
+ args: {
3526
+ type: schema.type,
3527
+ format: schema.format
3528
+ }
3529
+ }
3530
+ ].filter(Boolean);
3531
+ }
3532
+ if (schema.oneOf) {
3533
+ const schemaWithoutOneOf = { ...schema, oneOf: void 0 };
3534
+ const union = {
3535
+ keyword: schemaKeywords.union,
3536
+ args: schema.oneOf.map((item) => {
3537
+ return item && this.parse({ schema: item, name, parentName })[0];
3538
+ }).filter(Boolean).filter((item) => {
3539
+ return item && item.keyword !== unknownReturn;
3540
+ })
3541
+ };
3542
+ if (schemaWithoutOneOf.properties) {
3543
+ return [...this.parse({ schema: schemaWithoutOneOf, name, parentName }), union, ...baseItems];
3544
+ }
3545
+ return [union, ...baseItems];
3546
+ }
3547
+ if (schema.anyOf) {
3548
+ const schemaWithoutAnyOf = { ...schema, anyOf: void 0 };
3549
+ const union = {
3550
+ keyword: schemaKeywords.union,
3551
+ args: schema.anyOf.map((item) => {
3552
+ return item && this.parse({ schema: item, name, parentName })[0];
3553
+ }).filter(Boolean).filter((item) => {
3554
+ return item && item.keyword !== unknownReturn;
3555
+ }).map((item) => {
3556
+ if (isKeyword(item, schemaKeywords.object)) {
3557
+ return {
3558
+ ...item,
3559
+ args: {
3560
+ ...item.args,
3561
+ strict: true
3562
+ }
3563
+ };
3564
+ }
3565
+ return item;
3566
+ })
3567
+ };
3568
+ if (schemaWithoutAnyOf.properties) {
3569
+ return [...this.parse({ schema: schemaWithoutAnyOf, name, parentName }), union, ...baseItems];
3570
+ }
3571
+ return [union, ...baseItems];
3572
+ }
3573
+ if (schema.allOf) {
3574
+ const schemaWithoutAllOf = { ...schema, allOf: void 0 };
3575
+ const and = {
3576
+ keyword: schemaKeywords.and,
3577
+ args: schema.allOf.map((item) => {
3578
+ return item && this.parse({ schema: item, name, parentName })[0];
3579
+ }).filter(Boolean).filter((item) => {
3580
+ return item && item.keyword !== unknownReturn;
3581
+ })
3582
+ };
3583
+ if (schemaWithoutAllOf.properties) {
3584
+ return [
3585
+ {
3586
+ ...and,
3587
+ args: [...and.args || [], ...this.parse({ schema: schemaWithoutAllOf, name, parentName })]
3588
+ },
3589
+ ...baseItems
3590
+ ];
3591
+ }
3592
+ return [and, ...baseItems];
3593
+ }
3594
+ if (schema.enum) {
3595
+ const enumName = _utils.getUniqueName.call(void 0, _transformers.pascalCase.call(void 0, [parentName, name, options.enumSuffix].join(" ")), _chunkP42X362Ucjs.__privateMethod.call(void 0, this, _SchemaGenerator_instances, getUsedEnumNames_fn).call(this, { schema, name }));
3596
+ const typeName = this.context.pluginManager.resolveName({
3597
+ name: enumName,
3598
+ pluginKey: this.context.plugin.key,
3599
+ type: "type"
3600
+ });
3601
+ const nullableEnum = schema.enum.includes(null);
3602
+ if (nullableEnum) {
3603
+ baseItems.push({ keyword: schemaKeywords.nullable });
3604
+ }
3605
+ const filteredValues = schema.enum.filter((value) => value !== null);
3606
+ const extensionEnums = ["x-enumNames", "x-enum-varnames"].filter((extensionKey) => extensionKey in schema).map((extensionKey) => {
3607
+ return [
3608
+ {
3609
+ keyword: schemaKeywords.enum,
3610
+ args: {
3611
+ name,
3612
+ typeName,
3613
+ asConst: false,
3614
+ items: [...new Set(schema[extensionKey])].map((name2, index) => ({
3615
+ name: _transformers2.default.stringify(name2),
3616
+ value: _optionalChain([schema, 'access', _31 => _31.enum, 'optionalAccess', _32 => _32[index]]),
3617
+ format: _remeda.isNumber.call(void 0, _optionalChain([schema, 'access', _33 => _33.enum, 'optionalAccess', _34 => _34[index]])) ? "number" : "string"
3618
+ }))
3619
+ }
3620
+ },
3621
+ ...baseItems.filter(
3622
+ (item) => item.keyword !== schemaKeywords.min && item.keyword !== schemaKeywords.max && item.keyword !== schemaKeywords.matches
3623
+ )
3624
+ ];
3625
+ });
3626
+ if (schema.type === "number" || schema.type === "integer") {
3627
+ const enumNames = _optionalChain([extensionEnums, 'access', _35 => _35[0], 'optionalAccess', _36 => _36.find, 'call', _37 => _37((item) => isKeyword(item, schemaKeywords.enum))]);
3628
+ return [
3629
+ {
3630
+ keyword: schemaKeywords.enum,
3631
+ args: {
3632
+ name: enumName,
3633
+ typeName,
3634
+ asConst: true,
3635
+ items: _optionalChain([enumNames, 'optionalAccess', _38 => _38.args, 'optionalAccess', _39 => _39.items]) ? [...new Set(enumNames.args.items)].map(({ name: name2, value }) => ({
3636
+ name: name2,
3637
+ value,
3638
+ format: "number"
3639
+ })) : [...new Set(filteredValues)].map((value) => {
3640
+ return {
3641
+ name: value,
3642
+ value,
3643
+ format: "number"
3644
+ };
3645
+ })
3646
+ }
3647
+ },
3648
+ ...baseItems.filter((item) => item.keyword !== schemaKeywords.min && item.keyword !== schemaKeywords.max && item.keyword !== schemaKeywords.matches)
3649
+ ];
3650
+ }
3651
+ if (extensionEnums.length > 0 && extensionEnums[0]) {
3652
+ return extensionEnums[0];
3653
+ }
3654
+ return [
3655
+ {
3656
+ keyword: schemaKeywords.enum,
3657
+ args: {
3658
+ name: enumName,
3659
+ typeName,
3660
+ asConst: false,
3661
+ items: [...new Set(filteredValues)].map((value) => ({
3662
+ name: _transformers2.default.stringify(value),
3663
+ value,
3664
+ format: _remeda.isNumber.call(void 0, value) ? "number" : "string"
3665
+ }))
3666
+ }
3667
+ },
3668
+ ...baseItems.filter((item) => item.keyword !== schemaKeywords.min && item.keyword !== schemaKeywords.max && item.keyword !== schemaKeywords.matches)
3669
+ ];
3670
+ }
3671
+ if ("prefixItems" in schema) {
3672
+ const prefixItems = schema.prefixItems;
3673
+ const min2 = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(schema.minimum, () => ( schema.minLength)), () => ( schema.minItems)), () => ( void 0));
3674
+ const max2 = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(schema.maximum, () => ( schema.maxLength)), () => ( schema.maxItems)), () => ( void 0));
3675
+ return [
3676
+ {
3677
+ keyword: schemaKeywords.tuple,
3678
+ args: {
3679
+ min: min2,
3680
+ max: max2,
3681
+ items: prefixItems.map((item) => {
3682
+ return this.parse({ schema: item, name, parentName })[0];
3683
+ }).filter(Boolean)
3684
+ }
3685
+ },
3686
+ ...baseItems.filter((item) => item.keyword !== schemaKeywords.min && item.keyword !== schemaKeywords.max)
3687
+ ];
3688
+ }
3689
+ if (version === "3.1" && "const" in schema) {
3690
+ if (schema["const"]) {
3691
+ return [
3692
+ {
3693
+ keyword: schemaKeywords.const,
3694
+ args: {
3695
+ name: schema["const"],
3696
+ format: typeof schema["const"] === "number" ? "number" : "string",
3697
+ value: schema["const"]
3698
+ }
3699
+ },
3700
+ ...baseItems
3701
+ ];
3702
+ }
3703
+ return [{ keyword: schemaKeywords.null }];
3704
+ }
3705
+ if (schema.format) {
3706
+ switch (schema.format) {
3707
+ case "binary":
3708
+ baseItems.push({ keyword: schemaKeywords.blob });
3709
+ return baseItems;
3710
+ case "date-time":
3711
+ if (options.dateType) {
3712
+ if (options.dateType === "date") {
3713
+ baseItems.unshift({ keyword: schemaKeywords.date, args: { type: "date" } });
3714
+ return baseItems;
3715
+ }
3716
+ if (options.dateType === "stringOffset") {
3717
+ baseItems.unshift({ keyword: schemaKeywords.datetime, args: { offset: true } });
3718
+ return baseItems;
3719
+ }
3720
+ if (options.dateType === "stringLocal") {
3721
+ baseItems.unshift({ keyword: schemaKeywords.datetime, args: { local: true } });
3722
+ return baseItems;
3723
+ }
3724
+ baseItems.unshift({ keyword: schemaKeywords.datetime, args: { offset: false } });
3725
+ return baseItems;
3726
+ }
3727
+ break;
3728
+ case "date":
3729
+ if (options.dateType) {
3730
+ if (options.dateType === "date") {
3731
+ baseItems.unshift({ keyword: schemaKeywords.date, args: { type: "date" } });
3732
+ return baseItems;
3733
+ }
3734
+ baseItems.unshift({ keyword: schemaKeywords.date, args: { type: "string" } });
3735
+ return baseItems;
3736
+ }
3737
+ break;
3738
+ case "time":
3739
+ if (options.dateType) {
3740
+ if (options.dateType === "date") {
3741
+ baseItems.unshift({ keyword: schemaKeywords.time, args: { type: "date" } });
3742
+ return baseItems;
3743
+ }
3744
+ baseItems.unshift({ keyword: schemaKeywords.time, args: { type: "string" } });
3745
+ return baseItems;
3746
+ }
3747
+ break;
3748
+ case "uuid":
3749
+ baseItems.unshift({ keyword: schemaKeywords.uuid });
3750
+ break;
3751
+ case "email":
3752
+ case "idn-email":
3753
+ baseItems.unshift({ keyword: schemaKeywords.email });
3754
+ break;
3755
+ case "uri":
3756
+ case "ipv4":
3757
+ case "ipv6":
3758
+ case "uri-reference":
3759
+ case "hostname":
3760
+ case "idn-hostname":
3761
+ baseItems.unshift({ keyword: schemaKeywords.url });
3762
+ break;
3763
+ default:
3764
+ break;
3765
+ }
3766
+ }
3767
+ if ("items" in schema || schema.type === "array") {
3768
+ const min2 = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(schema.minimum, () => ( schema.minLength)), () => ( schema.minItems)), () => ( void 0));
3769
+ const max2 = _nullishCoalesce(_nullishCoalesce(_nullishCoalesce(schema.maximum, () => ( schema.maxLength)), () => ( schema.maxItems)), () => ( void 0));
3770
+ const items = this.parse({ schema: "items" in schema ? schema.items : [], name, parentName });
3771
+ return [
3772
+ {
3773
+ keyword: schemaKeywords.array,
3774
+ args: {
3775
+ items,
3776
+ min: min2,
3777
+ max: max2
3778
+ }
3779
+ },
3780
+ ...baseItems.filter((item) => item.keyword !== schemaKeywords.min && item.keyword !== schemaKeywords.max)
3781
+ ];
3782
+ }
3783
+ if (schema.properties || schema.additionalProperties) {
3784
+ return [..._chunkP42X362Ucjs.__privateMethod.call(void 0, this, _SchemaGenerator_instances, parseProperties_fn).call(this, { schema, name }), ...baseItems];
3785
+ }
3786
+ if (schema.type) {
3787
+ if (Array.isArray(schema.type)) {
3788
+ const [type] = schema.type;
3789
+ return [
3790
+ ...this.parse({
3791
+ schema: {
3792
+ ...schema,
3793
+ type
3794
+ },
3795
+ name,
3796
+ parentName
3797
+ }),
3798
+ ...baseItems
3799
+ ].filter(Boolean);
3800
+ }
3801
+ if (!["boolean", "object", "number", "string", "integer"].includes(schema.type)) {
3802
+ this.context.pluginManager.logger.emit("warning", `Schema type '${schema.type}' is not valid for schema ${parentName}.${name}`);
3803
+ }
3804
+ return [{ keyword: schema.type }, ...baseItems];
3805
+ }
3806
+ return [{ keyword: unknownReturn }];
3807
+ };
3808
+ var SchemaGenerator = _SchemaGenerator;
3809
+
3106
3810
  // src/components/Operation.tsx
3107
3811
  _chunkP42X362Ucjs.init_cjs_shims.call(void 0, );
3108
3812
  var import_jsx_runtime = _chunkP42X362Ucjs.__toESM.call(void 0, require_jsx_runtime(), 1);
@@ -3182,13 +3886,13 @@ Schema.File = function({ output, isTypeOnly, children }) {
3182
3886
  Schema.Imports = ({ isTypeOnly, extName }) => {
3183
3887
  const { tree } = useSchema();
3184
3888
  const { path: root } = _react.useFile.call(void 0, );
3185
- const refs = _chunkCJXRFYEFcjs.SchemaGenerator.deepSearch(tree, _chunkCJXRFYEFcjs.schemaKeywords.ref);
3186
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: _optionalChain([refs, 'optionalAccess', _ => _.map, 'call', _2 => _2((item, i) => {
3889
+ const refs = SchemaGenerator.deepSearch(tree, schemaKeywords.ref);
3890
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: _optionalChain([refs, 'optionalAccess', _40 => _40.map, 'call', _41 => _41((item, i) => {
3187
3891
  if (!item.args.path) {
3188
3892
  return void 0;
3189
3893
  }
3190
3894
  return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(_react.File.Import, { extName, root, name: [item.args.name], path: item.args.path, isTypeOnly: _nullishCoalesce(item.args.isTypeOnly, () => ( isTypeOnly)) }, i);
3191
- }), 'access', _3 => _3.filter, 'call', _4 => _4(Boolean)]) });
3895
+ }), 'access', _42 => _42.filter, 'call', _43 => _43(Boolean)]) });
3192
3896
  };
3193
3897
  Schema.Context = SchemaContext;
3194
3898
 
@@ -3215,7 +3919,11 @@ Oas.Schema = Schema;
3215
3919
 
3216
3920
 
3217
3921
 
3218
- exports.Operation = Operation; exports.useSchema = useSchema; exports.Schema = Schema; exports.Oas = Oas;
3922
+
3923
+
3924
+
3925
+
3926
+ exports.schemaKeywords = schemaKeywords; exports.isKeyword = isKeyword; exports.SchemaGenerator = SchemaGenerator; exports.require_jsx_runtime = require_jsx_runtime; exports.Operation = Operation; exports.useSchema = useSchema; exports.Schema = Schema; exports.Oas = Oas;
3219
3927
  /*! Bundled license information:
3220
3928
 
3221
3929
  react/cjs/react.production.min.js:
@@ -3262,4 +3970,4 @@ react/cjs/react-jsx-runtime.development.js:
3262
3970
  * LICENSE file in the root directory of this source tree.
3263
3971
  *)
3264
3972
  */
3265
- //# sourceMappingURL=chunk-DRLYORTT.cjs.map
3973
+ //# sourceMappingURL=chunk-264TCCJF.cjs.map