@kubb/plugin-zod 4.10.1 → 4.11.0

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.
@@ -258,6 +258,8 @@ const zodKeywordMapper = {
258
258
  default: (value, innerSchema, mini) => {
259
259
  if (mini && innerSchema) return `z._default(${innerSchema}, ${typeof value === "object" ? "{}" : value ?? ""})`;
260
260
  if (typeof value === "object") return ".default({})";
261
+ if (value === void 0) return ".default()";
262
+ if (typeof value === "string" && !value) return `.default('')`;
261
263
  return `.default(${value ?? ""})`;
262
264
  },
263
265
  and: (items = [], mini) => {
@@ -422,226 +424,271 @@ const shouldCoerce = (coercion, type) => {
422
424
  if (typeof coercion === "boolean") return coercion;
423
425
  return !!coercion[type];
424
426
  };
425
- function parse({ schema, parent, current, name, siblings }, options) {
426
- const value = zodKeywordMapper[current.keyword];
427
- const hasMatches = siblings.some((it) => (0, __kubb_plugin_oas.isKeyword)(it, __kubb_plugin_oas.schemaKeywords.matches));
428
- const hasRef = siblings.some((it) => (0, __kubb_plugin_oas.isKeyword)(it, __kubb_plugin_oas.schemaKeywords.ref));
429
- if (hasMatches && hasRef && (0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.matches)) return;
430
- if (!value) return;
431
- if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.union)) {
432
- if (Array.isArray(current.args) && current.args.length === 1) return parse({
433
- schema,
434
- parent,
435
- name,
436
- current: current.args[0],
437
- siblings
438
- }, options);
439
- if (Array.isArray(current.args) && !current.args.length) return "";
440
- return zodKeywordMapper.union(sort(current.args).map((it, _index, siblings$1) => parse({
441
- schema,
442
- parent: current,
443
- name,
444
- current: it,
445
- siblings: siblings$1
446
- }, options)).filter(Boolean));
447
- }
448
- if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.and)) {
449
- const items = sort(current.args).filter((schema$1) => {
450
- return ![__kubb_plugin_oas.schemaKeywords.optional, __kubb_plugin_oas.schemaKeywords.describe].includes(schema$1.keyword);
451
- }).map((it, _index, siblings$1) => parse({
452
- schema,
453
- parent: current,
454
- name,
455
- current: it,
456
- siblings: siblings$1
457
- }, options)).filter(Boolean);
458
- return `${items.slice(0, 1)}${zodKeywordMapper.and(items.slice(1), options.mini)}`;
459
- }
460
- if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.array)) return zodKeywordMapper.array(sort(current.args.items).map((it, _index, siblings$1) => {
461
- return parse({
462
- schema,
463
- parent: current,
464
- name,
465
- current: it,
466
- siblings: siblings$1
467
- }, options);
468
- }).filter(Boolean), current.args.min, current.args.max, current.args.unique, options.mini);
469
- if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.enum)) {
470
- if (current.args.asConst) {
471
- if (current.args.items.length === 1) {
472
- const child = {
473
- keyword: __kubb_plugin_oas.schemaKeywords.const,
474
- args: current.args.items[0]
475
- };
476
- return parse({
477
- schema,
478
- parent: current,
479
- name,
480
- current: child,
481
- siblings: [child]
482
- }, options);
483
- }
484
- return zodKeywordMapper.union(current.args.items.map((schema$1) => ({
485
- keyword: __kubb_plugin_oas.schemaKeywords.const,
486
- args: schema$1
487
- })).map((it, _index, siblings$1) => {
488
- return parse({
427
+ const parse = (0, __kubb_plugin_oas.createParser)({
428
+ mapper: zodKeywordMapper,
429
+ handlers: {
430
+ union(tree, options) {
431
+ const { current, schema, parent, name, siblings } = tree;
432
+ if (!(0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.union)) return void 0;
433
+ if (Array.isArray(current.args) && current.args.length === 1) return this.parse({
434
+ schema,
435
+ parent,
436
+ name,
437
+ current: current.args[0],
438
+ siblings
439
+ }, options);
440
+ if (Array.isArray(current.args) && !current.args.length) return "";
441
+ return zodKeywordMapper.union(sort(current.args).map((it, _index, siblings$1) => this.parse({
442
+ schema,
443
+ parent: current,
444
+ name,
445
+ current: it,
446
+ siblings: siblings$1
447
+ }, options)).filter(Boolean));
448
+ },
449
+ and(tree, options) {
450
+ const { current, schema, name } = tree;
451
+ if (!(0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.and)) return void 0;
452
+ const items = sort(current.args).filter((schema$1) => {
453
+ return ![__kubb_plugin_oas.schemaKeywords.optional, __kubb_plugin_oas.schemaKeywords.describe].includes(schema$1.keyword);
454
+ }).map((it, _index, siblings) => this.parse({
455
+ schema,
456
+ parent: current,
457
+ name,
458
+ current: it,
459
+ siblings
460
+ }, options)).filter(Boolean);
461
+ return `${items.slice(0, 1)}${zodKeywordMapper.and(items.slice(1), options.mini)}`;
462
+ },
463
+ array(tree, options) {
464
+ const { current, schema, name } = tree;
465
+ if (!(0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.array)) return void 0;
466
+ return zodKeywordMapper.array(sort(current.args.items).map((it, _index, siblings) => {
467
+ return this.parse({
489
468
  schema,
490
469
  parent: current,
491
470
  name,
492
471
  current: it,
493
- siblings: siblings$1
472
+ siblings
494
473
  }, options);
495
- }).filter(Boolean));
496
- }
497
- return zodKeywordMapper.enum(current.args.items.map((schema$1) => {
498
- if (schema$1.format === "boolean") return __kubb_core_transformers.default.stringify(schema$1.value);
499
- if (schema$1.format === "number") return __kubb_core_transformers.default.stringify(schema$1.value);
500
- return __kubb_core_transformers.default.stringify(schema$1.value);
501
- }));
502
- }
503
- if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.ref)) {
504
- if (options.skipLazyForRefs) return current.args?.name;
505
- return zodKeywordMapper.ref(current.args?.name);
506
- }
507
- if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.object)) {
508
- const properties = Object.entries(current.args?.properties || {}).filter((item) => {
509
- const schema$1 = item[1];
510
- return schema$1 && typeof schema$1.map === "function";
511
- }).map(([propertyName, schemas]) => {
512
- const nameSchema = schemas.find((it) => it.keyword === __kubb_plugin_oas.schemaKeywords.name);
513
- const isNullable = schemas.some((it) => (0, __kubb_plugin_oas.isKeyword)(it, __kubb_plugin_oas.schemaKeywords.nullable));
514
- const isNullish = schemas.some((it) => (0, __kubb_plugin_oas.isKeyword)(it, __kubb_plugin_oas.schemaKeywords.nullish));
515
- const isOptional = schemas.some((it) => (0, __kubb_plugin_oas.isKeyword)(it, __kubb_plugin_oas.schemaKeywords.optional));
516
- const hasRef$1 = !!__kubb_plugin_oas.SchemaGenerator.find(schemas, __kubb_plugin_oas.schemaKeywords.ref);
517
- const mappedName = nameSchema?.args || propertyName;
518
- if (options.mapper?.[mappedName]) return `"${propertyName}": ${options.mapper?.[mappedName]}`;
519
- const baseSchemaOutput = sort(schemas).filter((schema$1) => {
520
- return !(0, __kubb_plugin_oas.isKeyword)(schema$1, __kubb_plugin_oas.schemaKeywords.optional) && !(0, __kubb_plugin_oas.isKeyword)(schema$1, __kubb_plugin_oas.schemaKeywords.nullable) && !(0, __kubb_plugin_oas.isKeyword)(schema$1, __kubb_plugin_oas.schemaKeywords.nullish);
521
- }).map((it) => {
522
- const skipLazyForRefs = options.version === "4" && hasRef$1;
523
- return parse({
524
- schema,
525
- parent: current,
526
- name,
527
- current: it,
528
- siblings: schemas
529
- }, {
530
- ...options,
531
- skipLazyForRefs
532
- });
533
- }).filter(Boolean).join("");
534
- const objectValue = options.wrapOutput ? options.wrapOutput({
535
- output: baseSchemaOutput,
536
- schema: schema?.properties?.[propertyName]
537
- }) || baseSchemaOutput : baseSchemaOutput;
538
- if (options.version === "4" && hasRef$1) {
539
- if (options.mini) {
540
- if (isNullish) return `get "${propertyName}"(){
474
+ }).filter(Boolean), current.args.min, current.args.max, current.args.unique, options.mini);
475
+ },
476
+ enum(tree, options) {
477
+ const { current, schema, name } = tree;
478
+ if (!(0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.enum)) return void 0;
479
+ if (current.args.asConst) {
480
+ if (current.args.items.length === 1) {
481
+ const child = {
482
+ keyword: __kubb_plugin_oas.schemaKeywords.const,
483
+ args: current.args.items[0]
484
+ };
485
+ return this.parse({
486
+ schema,
487
+ parent: current,
488
+ name,
489
+ current: child,
490
+ siblings: [child]
491
+ }, options);
492
+ }
493
+ return zodKeywordMapper.union(current.args.items.map((schema$1) => ({
494
+ keyword: __kubb_plugin_oas.schemaKeywords.const,
495
+ args: schema$1
496
+ })).map((it, _index, siblings) => {
497
+ return this.parse({
498
+ schema,
499
+ parent: current,
500
+ name,
501
+ current: it,
502
+ siblings
503
+ }, options);
504
+ }).filter(Boolean));
505
+ }
506
+ return zodKeywordMapper.enum(current.args.items.map((schema$1) => {
507
+ if (schema$1.format === "boolean") return __kubb_core_transformers.default.stringify(schema$1.value);
508
+ if (schema$1.format === "number") return __kubb_core_transformers.default.stringify(schema$1.value);
509
+ return __kubb_core_transformers.default.stringify(schema$1.value);
510
+ }));
511
+ },
512
+ ref(tree, options) {
513
+ const { current } = tree;
514
+ if (!(0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.ref)) return void 0;
515
+ if (options.skipLazyForRefs) return current.args?.name;
516
+ return zodKeywordMapper.ref(current.args?.name);
517
+ },
518
+ object(tree, options) {
519
+ const { current, schema, name } = tree;
520
+ if (!(0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.object)) return void 0;
521
+ const properties = Object.entries(current.args?.properties || {}).filter((item) => {
522
+ const schema$1 = item[1];
523
+ return schema$1 && typeof schema$1.map === "function";
524
+ }).map(([propertyName, schemas]) => {
525
+ const nameSchema = schemas.find((it) => it.keyword === __kubb_plugin_oas.schemaKeywords.name);
526
+ const isNullable = schemas.some((it) => (0, __kubb_plugin_oas.isKeyword)(it, __kubb_plugin_oas.schemaKeywords.nullable));
527
+ const isNullish = schemas.some((it) => (0, __kubb_plugin_oas.isKeyword)(it, __kubb_plugin_oas.schemaKeywords.nullish));
528
+ const isOptional = schemas.some((it) => (0, __kubb_plugin_oas.isKeyword)(it, __kubb_plugin_oas.schemaKeywords.optional));
529
+ const hasRef = !!__kubb_plugin_oas.SchemaGenerator.find(schemas, __kubb_plugin_oas.schemaKeywords.ref);
530
+ const mappedName = nameSchema?.args || propertyName;
531
+ if (options.mapper?.[mappedName]) return `"${propertyName}": ${options.mapper?.[mappedName]}`;
532
+ const baseSchemaOutput = sort(schemas).filter((schema$1) => {
533
+ return !(0, __kubb_plugin_oas.isKeyword)(schema$1, __kubb_plugin_oas.schemaKeywords.optional) && !(0, __kubb_plugin_oas.isKeyword)(schema$1, __kubb_plugin_oas.schemaKeywords.nullable) && !(0, __kubb_plugin_oas.isKeyword)(schema$1, __kubb_plugin_oas.schemaKeywords.nullish);
534
+ }).map((it) => {
535
+ const skipLazyForRefs = options.version === "4" && hasRef;
536
+ return this.parse({
537
+ schema,
538
+ parent: current,
539
+ name,
540
+ current: it,
541
+ siblings: schemas
542
+ }, {
543
+ ...options,
544
+ skipLazyForRefs
545
+ });
546
+ }).filter(Boolean).join("");
547
+ const objectValue = options.wrapOutput ? options.wrapOutput({
548
+ output: baseSchemaOutput,
549
+ schema: schema?.properties?.[propertyName]
550
+ }) || baseSchemaOutput : baseSchemaOutput;
551
+ if (options.version === "4" && hasRef) {
552
+ if (options.mini) {
553
+ if (isNullish) return `get "${propertyName}"(){
541
554
  return ${zodKeywordMapper.nullish(objectValue)}
542
555
  }`;
543
- if (isOptional) return `get "${propertyName}"(){
556
+ if (isOptional) return `get "${propertyName}"(){
544
557
  return ${zodKeywordMapper.optional(objectValue)}
545
558
  }`;
546
- if (isNullable) return `get "${propertyName}"(){
559
+ if (isNullable) return `get "${propertyName}"(){
547
560
  return ${zodKeywordMapper.nullable(objectValue)}
548
561
  }`;
549
- return `get "${propertyName}"(){
562
+ return `get "${propertyName}"(){
550
563
  return ${objectValue}
551
564
  }`;
552
- }
553
- if (isNullish) return `get "${propertyName}"(){
565
+ }
566
+ if (isNullish) return `get "${propertyName}"(){
554
567
  return ${objectValue}${zodKeywordMapper.nullish()}
555
568
  }`;
556
- if (isOptional) return `get "${propertyName}"(){
569
+ if (isOptional) return `get "${propertyName}"(){
557
570
  return ${objectValue}${zodKeywordMapper.optional()}
558
571
  }`;
559
- if (isNullable) return `get "${propertyName}"(){
572
+ if (isNullable) return `get "${propertyName}"(){
560
573
  return ${objectValue}${zodKeywordMapper.nullable()}
561
574
  }`;
562
- return `get "${propertyName}"(){
575
+ return `get "${propertyName}"(){
563
576
  return ${objectValue}
564
577
  }`;
565
- }
566
- if (isNullish) return `"${propertyName}": ${objectValue}${zodKeywordMapper.nullish()}`;
567
- if (isOptional) return `"${propertyName}": ${zodKeywordMapper.optional(objectValue)}`;
568
- if (isNullable) return `"${propertyName}": ${zodKeywordMapper.nullable(objectValue)}`;
569
- return `"${propertyName}": ${objectValue}`;
570
- }).join(",\n");
571
- const additionalProperties = current.args?.additionalProperties?.length ? current.args.additionalProperties.map((it, _index, siblings$1) => parse({
572
- schema,
573
- parent: current,
574
- name,
575
- current: it,
576
- siblings: siblings$1
577
- }, options)).filter(Boolean).join("") : void 0;
578
- return [zodKeywordMapper.object(properties, current.args?.strict, options.version), additionalProperties ? zodKeywordMapper.catchall(additionalProperties, options.mini) : void 0].filter(Boolean).join("");
579
- }
580
- if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.tuple)) return zodKeywordMapper.tuple(current.args.items.map((it, _index, siblings$1) => parse({
581
- schema,
582
- parent: current,
583
- name,
584
- current: it,
585
- siblings: siblings$1
586
- }, options)).filter(Boolean));
587
- if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.const)) {
588
- if (current.args.format === "number" && current.args.value !== void 0) return zodKeywordMapper.const(Number(current.args.value));
589
- if (current.args.format === "boolean" && current.args.value !== void 0) return zodKeywordMapper.const(current.args.value);
590
- return zodKeywordMapper.const(__kubb_core_transformers.default.stringify(current.args.value));
591
- }
592
- if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.matches)) {
593
- if (current.args) return zodKeywordMapper.matches(__kubb_core_transformers.default.toRegExpString(current.args, null), shouldCoerce(options.coercion, "strings"), options.mini);
594
- }
595
- if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.default)) {
596
- if (options.mini) return;
597
- if (current.args) return zodKeywordMapper.default(current.args);
598
- }
599
- if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.describe)) {
600
- if (current.args) return zodKeywordMapper.describe(__kubb_core_transformers.default.stringify(current.args.toString()), void 0, options.mini);
601
- }
602
- if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.string)) {
603
- const minSchema = __kubb_plugin_oas.SchemaGenerator.find(siblings, __kubb_plugin_oas.schemaKeywords.min);
604
- const maxSchema = __kubb_plugin_oas.SchemaGenerator.find(siblings, __kubb_plugin_oas.schemaKeywords.max);
605
- return zodKeywordMapper.string(shouldCoerce(options.coercion, "strings"), minSchema?.args, maxSchema?.args, options.mini);
606
- }
607
- if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.uuid)) {
608
- const minSchema = __kubb_plugin_oas.SchemaGenerator.find(siblings, __kubb_plugin_oas.schemaKeywords.min);
609
- const maxSchema = __kubb_plugin_oas.SchemaGenerator.find(siblings, __kubb_plugin_oas.schemaKeywords.max);
610
- return zodKeywordMapper.uuid(shouldCoerce(options.coercion, "strings"), options.version, minSchema?.args, maxSchema?.args, options.mini);
611
- }
612
- if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.email)) {
613
- const minSchema = __kubb_plugin_oas.SchemaGenerator.find(siblings, __kubb_plugin_oas.schemaKeywords.min);
614
- const maxSchema = __kubb_plugin_oas.SchemaGenerator.find(siblings, __kubb_plugin_oas.schemaKeywords.max);
615
- return zodKeywordMapper.email(shouldCoerce(options.coercion, "strings"), options.version, minSchema?.args, maxSchema?.args, options.mini);
616
- }
617
- if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.url)) {
618
- const minSchema = __kubb_plugin_oas.SchemaGenerator.find(siblings, __kubb_plugin_oas.schemaKeywords.min);
619
- const maxSchema = __kubb_plugin_oas.SchemaGenerator.find(siblings, __kubb_plugin_oas.schemaKeywords.max);
620
- return zodKeywordMapper.url(shouldCoerce(options.coercion, "strings"), options.version, minSchema?.args, maxSchema?.args, options.mini);
621
- }
622
- if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.number)) {
623
- const minSchema = __kubb_plugin_oas.SchemaGenerator.find(siblings, __kubb_plugin_oas.schemaKeywords.min);
624
- const maxSchema = __kubb_plugin_oas.SchemaGenerator.find(siblings, __kubb_plugin_oas.schemaKeywords.max);
625
- const exclusiveMinimumSchema = __kubb_plugin_oas.SchemaGenerator.find(siblings, __kubb_plugin_oas.schemaKeywords.exclusiveMinimum);
626
- const exclusiveMaximumSchema = __kubb_plugin_oas.SchemaGenerator.find(siblings, __kubb_plugin_oas.schemaKeywords.exclusiveMaximum);
627
- return zodKeywordMapper.number(shouldCoerce(options.coercion, "numbers"), minSchema?.args, maxSchema?.args, exclusiveMinimumSchema?.args, exclusiveMaximumSchema?.args, options.mini);
628
- }
629
- if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.integer)) {
630
- const minSchema = __kubb_plugin_oas.SchemaGenerator.find(siblings, __kubb_plugin_oas.schemaKeywords.min);
631
- const maxSchema = __kubb_plugin_oas.SchemaGenerator.find(siblings, __kubb_plugin_oas.schemaKeywords.max);
632
- const exclusiveMinimumSchema = __kubb_plugin_oas.SchemaGenerator.find(siblings, __kubb_plugin_oas.schemaKeywords.exclusiveMinimum);
633
- const exclusiveMaximumSchema = __kubb_plugin_oas.SchemaGenerator.find(siblings, __kubb_plugin_oas.schemaKeywords.exclusiveMaximum);
634
- return zodKeywordMapper.integer(shouldCoerce(options.coercion, "numbers"), minSchema?.args, maxSchema?.args, options.version, exclusiveMinimumSchema?.args, exclusiveMaximumSchema?.args, options.mini);
635
- }
636
- if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.datetime)) return zodKeywordMapper.datetime(current.args.offset, current.args.local, options.version, options.mini);
637
- if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.date)) return zodKeywordMapper.date(current.args.type, shouldCoerce(options.coercion, "dates"), options.version);
638
- if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.time)) return zodKeywordMapper.time(current.args.type, shouldCoerce(options.coercion, "dates"), options.version);
639
- if (current.keyword in zodKeywordMapper && "args" in current) {
640
- const value$1 = zodKeywordMapper[current.keyword];
641
- return value$1(current.args);
578
+ }
579
+ if (isNullish) return `"${propertyName}": ${objectValue}${zodKeywordMapper.nullish()}`;
580
+ if (isOptional) return `"${propertyName}": ${zodKeywordMapper.optional(objectValue)}`;
581
+ if (isNullable) return `"${propertyName}": ${zodKeywordMapper.nullable(objectValue)}`;
582
+ return `"${propertyName}": ${objectValue}`;
583
+ }).join(",\n");
584
+ const additionalProperties = current.args?.additionalProperties?.length ? current.args.additionalProperties.map((it, _index, siblings) => this.parse({
585
+ schema,
586
+ parent: current,
587
+ name,
588
+ current: it,
589
+ siblings
590
+ }, options)).filter(Boolean).join("") : void 0;
591
+ return [zodKeywordMapper.object(properties, current.args?.strict, options.version), additionalProperties ? zodKeywordMapper.catchall(additionalProperties, options.mini) : void 0].filter(Boolean).join("");
592
+ },
593
+ tuple(tree, options) {
594
+ const { current, schema, name } = tree;
595
+ if (!(0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.tuple)) return void 0;
596
+ return zodKeywordMapper.tuple(current.args.items.map((it, _index, siblings) => this.parse({
597
+ schema,
598
+ parent: current,
599
+ name,
600
+ current: it,
601
+ siblings
602
+ }, options)).filter(Boolean));
603
+ },
604
+ const(tree, _options) {
605
+ const { current } = tree;
606
+ if (!(0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.const)) return void 0;
607
+ if (current.args.format === "number" && current.args.value !== void 0) return zodKeywordMapper.const(Number(current.args.value));
608
+ if (current.args.format === "boolean" && current.args.value !== void 0) return zodKeywordMapper.const(typeof current.args.value === "boolean" ? current.args.value : void 0);
609
+ return zodKeywordMapper.const(__kubb_core_transformers.default.stringify(current.args.value));
610
+ },
611
+ matches(tree, options) {
612
+ const { current, siblings } = tree;
613
+ if (!(0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.matches)) return void 0;
614
+ if (siblings.some((it) => (0, __kubb_plugin_oas.isKeyword)(it, __kubb_plugin_oas.schemaKeywords.ref))) return;
615
+ if (current.args) return zodKeywordMapper.matches(__kubb_core_transformers.default.toRegExpString(current.args, null), shouldCoerce(options.coercion, "strings"), options.mini);
616
+ },
617
+ default(tree, options) {
618
+ const { current } = tree;
619
+ if (!(0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.default)) return void 0;
620
+ if (options.mini) return;
621
+ if (current.args !== void 0) return zodKeywordMapper.default(current.args);
622
+ return zodKeywordMapper.default();
623
+ },
624
+ describe(tree, options) {
625
+ const { current } = tree;
626
+ if (!(0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.describe)) return void 0;
627
+ if (current.args) return zodKeywordMapper.describe(__kubb_core_transformers.default.stringify(current.args.toString()), void 0, options.mini);
628
+ },
629
+ string(tree, options) {
630
+ const { current, siblings } = tree;
631
+ if (!(0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.string)) return void 0;
632
+ const minSchema = (0, __kubb_plugin_oas.findSchemaKeyword)(siblings, "min");
633
+ const maxSchema = (0, __kubb_plugin_oas.findSchemaKeyword)(siblings, "max");
634
+ return zodKeywordMapper.string(shouldCoerce(options.coercion, "strings"), minSchema?.args, maxSchema?.args, options.mini);
635
+ },
636
+ uuid(tree, options) {
637
+ const { current, siblings } = tree;
638
+ if (!(0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.uuid)) return void 0;
639
+ const minSchema = (0, __kubb_plugin_oas.findSchemaKeyword)(siblings, "min");
640
+ const maxSchema = (0, __kubb_plugin_oas.findSchemaKeyword)(siblings, "max");
641
+ return zodKeywordMapper.uuid(shouldCoerce(options.coercion, "strings"), options.version, minSchema?.args, maxSchema?.args, options.mini);
642
+ },
643
+ email(tree, options) {
644
+ const { current, siblings } = tree;
645
+ if (!(0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.email)) return void 0;
646
+ const minSchema = (0, __kubb_plugin_oas.findSchemaKeyword)(siblings, "min");
647
+ const maxSchema = (0, __kubb_plugin_oas.findSchemaKeyword)(siblings, "max");
648
+ return zodKeywordMapper.email(shouldCoerce(options.coercion, "strings"), options.version, minSchema?.args, maxSchema?.args, options.mini);
649
+ },
650
+ url(tree, options) {
651
+ const { current, siblings } = tree;
652
+ if (!(0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.url)) return void 0;
653
+ const minSchema = (0, __kubb_plugin_oas.findSchemaKeyword)(siblings, "min");
654
+ const maxSchema = (0, __kubb_plugin_oas.findSchemaKeyword)(siblings, "max");
655
+ return zodKeywordMapper.url(shouldCoerce(options.coercion, "strings"), options.version, minSchema?.args, maxSchema?.args, options.mini);
656
+ },
657
+ number(tree, options) {
658
+ const { current, siblings } = tree;
659
+ if (!(0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.number)) return void 0;
660
+ const minSchema = (0, __kubb_plugin_oas.findSchemaKeyword)(siblings, "min");
661
+ const maxSchema = (0, __kubb_plugin_oas.findSchemaKeyword)(siblings, "max");
662
+ const exclusiveMinimumSchema = (0, __kubb_plugin_oas.findSchemaKeyword)(siblings, "exclusiveMinimum");
663
+ const exclusiveMaximumSchema = (0, __kubb_plugin_oas.findSchemaKeyword)(siblings, "exclusiveMaximum");
664
+ return zodKeywordMapper.number(shouldCoerce(options.coercion, "numbers"), minSchema?.args, maxSchema?.args, exclusiveMinimumSchema?.args, exclusiveMaximumSchema?.args, options.mini);
665
+ },
666
+ integer(tree, options) {
667
+ const { current, siblings } = tree;
668
+ if (!(0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.integer)) return void 0;
669
+ const minSchema = (0, __kubb_plugin_oas.findSchemaKeyword)(siblings, "min");
670
+ const maxSchema = (0, __kubb_plugin_oas.findSchemaKeyword)(siblings, "max");
671
+ const exclusiveMinimumSchema = (0, __kubb_plugin_oas.findSchemaKeyword)(siblings, "exclusiveMinimum");
672
+ const exclusiveMaximumSchema = (0, __kubb_plugin_oas.findSchemaKeyword)(siblings, "exclusiveMaximum");
673
+ return zodKeywordMapper.integer(shouldCoerce(options.coercion, "numbers"), minSchema?.args, maxSchema?.args, options.version, exclusiveMinimumSchema?.args, exclusiveMaximumSchema?.args, options.mini);
674
+ },
675
+ datetime(tree, options) {
676
+ const { current } = tree;
677
+ if (!(0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.datetime)) return void 0;
678
+ return zodKeywordMapper.datetime(current.args.offset, current.args.local, options.version, options.mini);
679
+ },
680
+ date(tree, options) {
681
+ const { current } = tree;
682
+ if (!(0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.date)) return void 0;
683
+ return zodKeywordMapper.date(current.args.type, shouldCoerce(options.coercion, "dates"), options.version);
684
+ },
685
+ time(tree, options) {
686
+ const { current } = tree;
687
+ if (!(0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.time)) return void 0;
688
+ return zodKeywordMapper.time(current.args.type, shouldCoerce(options.coercion, "dates"), options.version);
689
+ }
642
690
  }
643
- if (current.keyword in zodKeywordMapper) return value();
644
- }
691
+ });
645
692
 
646
693
  //#endregion
647
694
  //#region src/components/Zod.tsx
@@ -743,4 +790,4 @@ Object.defineProperty(exports, '__toESM', {
743
790
  return __toESM;
744
791
  }
745
792
  });
746
- //# sourceMappingURL=components-CwZBp5_M.cjs.map
793
+ //# sourceMappingURL=components-DaK9uYjS.cjs.map