@kubb/plugin-zod 4.12.2 → 4.12.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.
- package/dist/{components-CCUQHjre.cjs → components-CtNn0D8u.cjs} +117 -117
- package/dist/{components-CCUQHjre.cjs.map → components-CtNn0D8u.cjs.map} +1 -1
- package/dist/components.cjs +1 -1
- package/dist/{generators-taWkjiU5.cjs → generators-B8o3JVus.cjs} +52 -52
- package/dist/{generators-taWkjiU5.cjs.map → generators-B8o3JVus.cjs.map} +1 -1
- package/dist/generators.cjs +1 -1
- package/dist/index.cjs +19 -19
- package/dist/index.cjs.map +1 -1
- package/package.json +7 -8
|
@@ -25,11 +25,11 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
25
25
|
}) : target, mod));
|
|
26
26
|
|
|
27
27
|
//#endregion
|
|
28
|
-
let
|
|
29
|
-
|
|
30
|
-
let
|
|
31
|
-
let
|
|
32
|
-
let
|
|
28
|
+
let _kubb_core_transformers = require("@kubb/core/transformers");
|
|
29
|
+
_kubb_core_transformers = __toESM(_kubb_core_transformers);
|
|
30
|
+
let _kubb_plugin_oas = require("@kubb/plugin-oas");
|
|
31
|
+
let _kubb_react_fabric = require("@kubb/react-fabric");
|
|
32
|
+
let _kubb_react_fabric_jsx_runtime = require("@kubb/react-fabric/jsx-runtime");
|
|
33
33
|
|
|
34
34
|
//#region src/components/Operations.tsx
|
|
35
35
|
function Operations({ name, operations }) {
|
|
@@ -44,12 +44,12 @@ function Operations({ name, operations }) {
|
|
|
44
44
|
};
|
|
45
45
|
return prev;
|
|
46
46
|
}, {});
|
|
47
|
-
return /* @__PURE__ */ (0,
|
|
48
|
-
/* @__PURE__ */ (0,
|
|
47
|
+
return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [
|
|
48
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Source, {
|
|
49
49
|
name: "OperationSchema",
|
|
50
50
|
isExportable: true,
|
|
51
51
|
isIndexable: true,
|
|
52
|
-
children: /* @__PURE__ */ (0,
|
|
52
|
+
children: /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.Type, {
|
|
53
53
|
name: "OperationSchema",
|
|
54
54
|
export: true,
|
|
55
55
|
children: `{
|
|
@@ -69,36 +69,36 @@ function Operations({ name, operations }) {
|
|
|
69
69
|
}`
|
|
70
70
|
})
|
|
71
71
|
}),
|
|
72
|
-
/* @__PURE__ */ (0,
|
|
72
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Source, {
|
|
73
73
|
name: "OperationsMap",
|
|
74
74
|
isExportable: true,
|
|
75
75
|
isIndexable: true,
|
|
76
|
-
children: /* @__PURE__ */ (0,
|
|
76
|
+
children: /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.Type, {
|
|
77
77
|
name: "OperationsMap",
|
|
78
78
|
export: true,
|
|
79
79
|
children: "Record<string, OperationSchema>"
|
|
80
80
|
})
|
|
81
81
|
}),
|
|
82
|
-
/* @__PURE__ */ (0,
|
|
82
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Source, {
|
|
83
83
|
name,
|
|
84
84
|
isExportable: true,
|
|
85
85
|
isIndexable: true,
|
|
86
|
-
children: /* @__PURE__ */ (0,
|
|
86
|
+
children: /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.Const, {
|
|
87
87
|
export: true,
|
|
88
88
|
name,
|
|
89
89
|
asConst: true,
|
|
90
|
-
children: `{${
|
|
90
|
+
children: `{${_kubb_core_transformers.default.stringifyObject(operationsJSON)}}`
|
|
91
91
|
})
|
|
92
92
|
}),
|
|
93
|
-
/* @__PURE__ */ (0,
|
|
93
|
+
/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Source, {
|
|
94
94
|
name: "paths",
|
|
95
95
|
isExportable: true,
|
|
96
96
|
isIndexable: true,
|
|
97
|
-
children: /* @__PURE__ */ (0,
|
|
97
|
+
children: /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.Const, {
|
|
98
98
|
export: true,
|
|
99
99
|
name: "paths",
|
|
100
100
|
asConst: true,
|
|
101
|
-
children: `{${
|
|
101
|
+
children: `{${_kubb_core_transformers.default.stringifyObject(pathsJSON)}}`
|
|
102
102
|
})
|
|
103
103
|
})
|
|
104
104
|
] });
|
|
@@ -352,32 +352,32 @@ const zodKeywordMapper = {
|
|
|
352
352
|
*/
|
|
353
353
|
function sort(items) {
|
|
354
354
|
const order = [
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
355
|
+
_kubb_plugin_oas.schemaKeywords.string,
|
|
356
|
+
_kubb_plugin_oas.schemaKeywords.datetime,
|
|
357
|
+
_kubb_plugin_oas.schemaKeywords.date,
|
|
358
|
+
_kubb_plugin_oas.schemaKeywords.time,
|
|
359
|
+
_kubb_plugin_oas.schemaKeywords.tuple,
|
|
360
|
+
_kubb_plugin_oas.schemaKeywords.number,
|
|
361
|
+
_kubb_plugin_oas.schemaKeywords.object,
|
|
362
|
+
_kubb_plugin_oas.schemaKeywords.enum,
|
|
363
|
+
_kubb_plugin_oas.schemaKeywords.url,
|
|
364
|
+
_kubb_plugin_oas.schemaKeywords.email,
|
|
365
|
+
_kubb_plugin_oas.schemaKeywords.firstName,
|
|
366
|
+
_kubb_plugin_oas.schemaKeywords.lastName,
|
|
367
|
+
_kubb_plugin_oas.schemaKeywords.password,
|
|
368
|
+
_kubb_plugin_oas.schemaKeywords.matches,
|
|
369
|
+
_kubb_plugin_oas.schemaKeywords.uuid,
|
|
370
|
+
_kubb_plugin_oas.schemaKeywords.null,
|
|
371
|
+
_kubb_plugin_oas.schemaKeywords.min,
|
|
372
|
+
_kubb_plugin_oas.schemaKeywords.max,
|
|
373
|
+
_kubb_plugin_oas.schemaKeywords.default,
|
|
374
|
+
_kubb_plugin_oas.schemaKeywords.describe,
|
|
375
|
+
_kubb_plugin_oas.schemaKeywords.optional,
|
|
376
|
+
_kubb_plugin_oas.schemaKeywords.nullable,
|
|
377
|
+
_kubb_plugin_oas.schemaKeywords.nullish
|
|
378
378
|
];
|
|
379
379
|
if (!items) return [];
|
|
380
|
-
return
|
|
380
|
+
return _kubb_core_transformers.default.orderBy(items, [(v) => order.indexOf(v.keyword)], ["asc"]);
|
|
381
381
|
}
|
|
382
382
|
/**
|
|
383
383
|
* Keywords that represent modifiers for mini mode
|
|
@@ -385,11 +385,11 @@ function sort(items) {
|
|
|
385
385
|
* Note: describe is included to filter it out, but won't be wrapped (Zod Mini doesn't support describe)
|
|
386
386
|
*/
|
|
387
387
|
const miniModifierKeywords = [
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
388
|
+
_kubb_plugin_oas.schemaKeywords.optional,
|
|
389
|
+
_kubb_plugin_oas.schemaKeywords.nullable,
|
|
390
|
+
_kubb_plugin_oas.schemaKeywords.nullish,
|
|
391
|
+
_kubb_plugin_oas.schemaKeywords.default,
|
|
392
|
+
_kubb_plugin_oas.schemaKeywords.describe
|
|
393
393
|
];
|
|
394
394
|
/**
|
|
395
395
|
* Extracts mini mode modifiers from a schemas array
|
|
@@ -397,11 +397,11 @@ const miniModifierKeywords = [
|
|
|
397
397
|
* Note: describe is not included as Zod Mini doesn't support it
|
|
398
398
|
*/
|
|
399
399
|
function extractMiniModifiers(schemas) {
|
|
400
|
-
const defaultSchema = schemas.find((item) => (0,
|
|
400
|
+
const defaultSchema = schemas.find((item) => (0, _kubb_plugin_oas.isKeyword)(item, _kubb_plugin_oas.schemaKeywords.default));
|
|
401
401
|
return {
|
|
402
|
-
hasOptional: schemas.some((item) => (0,
|
|
403
|
-
hasNullable: schemas.some((item) => (0,
|
|
404
|
-
hasNullish: schemas.some((item) => (0,
|
|
402
|
+
hasOptional: schemas.some((item) => (0, _kubb_plugin_oas.isKeyword)(item, _kubb_plugin_oas.schemaKeywords.optional)),
|
|
403
|
+
hasNullable: schemas.some((item) => (0, _kubb_plugin_oas.isKeyword)(item, _kubb_plugin_oas.schemaKeywords.nullable)),
|
|
404
|
+
hasNullish: schemas.some((item) => (0, _kubb_plugin_oas.isKeyword)(item, _kubb_plugin_oas.schemaKeywords.nullish)),
|
|
405
405
|
defaultValue: defaultSchema?.args
|
|
406
406
|
};
|
|
407
407
|
}
|
|
@@ -410,7 +410,7 @@ function extractMiniModifiers(schemas) {
|
|
|
410
410
|
* This can be reused by other parsers (e.g., valibot) that need similar functionality
|
|
411
411
|
*/
|
|
412
412
|
function filterMiniModifiers(schemas) {
|
|
413
|
-
return schemas.filter((item) => !miniModifierKeywords.some((keyword) => (0,
|
|
413
|
+
return schemas.filter((item) => !miniModifierKeywords.some((keyword) => (0, _kubb_plugin_oas.isKeyword)(item, keyword)));
|
|
414
414
|
}
|
|
415
415
|
/**
|
|
416
416
|
* Wraps an output string with Zod Mini functional modifiers
|
|
@@ -433,12 +433,12 @@ const shouldCoerce = (coercion, type) => {
|
|
|
433
433
|
if (typeof coercion === "boolean") return coercion;
|
|
434
434
|
return !!coercion[type];
|
|
435
435
|
};
|
|
436
|
-
const parse = (0,
|
|
436
|
+
const parse = (0, _kubb_plugin_oas.createParser)({
|
|
437
437
|
mapper: zodKeywordMapper,
|
|
438
438
|
handlers: {
|
|
439
439
|
union(tree, options) {
|
|
440
440
|
const { current, schema, parent, name, siblings } = tree;
|
|
441
|
-
if (!(0,
|
|
441
|
+
if (!(0, _kubb_plugin_oas.isKeyword)(current, _kubb_plugin_oas.schemaKeywords.union)) return void 0;
|
|
442
442
|
if (Array.isArray(current.args) && current.args.length === 1) return this.parse({
|
|
443
443
|
schema,
|
|
444
444
|
parent,
|
|
@@ -457,9 +457,9 @@ const parse = (0, __kubb_plugin_oas.createParser)({
|
|
|
457
457
|
},
|
|
458
458
|
and(tree, options) {
|
|
459
459
|
const { current, schema, name } = tree;
|
|
460
|
-
if (!(0,
|
|
460
|
+
if (!(0, _kubb_plugin_oas.isKeyword)(current, _kubb_plugin_oas.schemaKeywords.and)) return void 0;
|
|
461
461
|
const items = sort(current.args).filter((schema$1) => {
|
|
462
|
-
return ![
|
|
462
|
+
return ![_kubb_plugin_oas.schemaKeywords.optional, _kubb_plugin_oas.schemaKeywords.describe].includes(schema$1.keyword);
|
|
463
463
|
}).map((it, _index, siblings) => this.parse({
|
|
464
464
|
schema,
|
|
465
465
|
parent: current,
|
|
@@ -471,7 +471,7 @@ const parse = (0, __kubb_plugin_oas.createParser)({
|
|
|
471
471
|
},
|
|
472
472
|
array(tree, options) {
|
|
473
473
|
const { current, schema, name } = tree;
|
|
474
|
-
if (!(0,
|
|
474
|
+
if (!(0, _kubb_plugin_oas.isKeyword)(current, _kubb_plugin_oas.schemaKeywords.array)) return void 0;
|
|
475
475
|
return zodKeywordMapper.array(sort(current.args.items).map((it, _index, siblings) => {
|
|
476
476
|
return this.parse({
|
|
477
477
|
schema,
|
|
@@ -484,11 +484,11 @@ const parse = (0, __kubb_plugin_oas.createParser)({
|
|
|
484
484
|
},
|
|
485
485
|
enum(tree, options) {
|
|
486
486
|
const { current, schema, name } = tree;
|
|
487
|
-
if (!(0,
|
|
487
|
+
if (!(0, _kubb_plugin_oas.isKeyword)(current, _kubb_plugin_oas.schemaKeywords.enum)) return void 0;
|
|
488
488
|
if (current.args.asConst) {
|
|
489
489
|
if (current.args.items.length === 1) {
|
|
490
490
|
const child = {
|
|
491
|
-
keyword:
|
|
491
|
+
keyword: _kubb_plugin_oas.schemaKeywords.const,
|
|
492
492
|
args: current.args.items[0]
|
|
493
493
|
};
|
|
494
494
|
return this.parse({
|
|
@@ -500,7 +500,7 @@ const parse = (0, __kubb_plugin_oas.createParser)({
|
|
|
500
500
|
}, options);
|
|
501
501
|
}
|
|
502
502
|
return zodKeywordMapper.union(current.args.items.map((schema$1) => ({
|
|
503
|
-
keyword:
|
|
503
|
+
keyword: _kubb_plugin_oas.schemaKeywords.const,
|
|
504
504
|
args: schema$1
|
|
505
505
|
})).map((it, _index, siblings) => {
|
|
506
506
|
return this.parse({
|
|
@@ -513,33 +513,33 @@ const parse = (0, __kubb_plugin_oas.createParser)({
|
|
|
513
513
|
}).filter(Boolean));
|
|
514
514
|
}
|
|
515
515
|
return zodKeywordMapper.enum(current.args.items.map((schema$1) => {
|
|
516
|
-
if (schema$1.format === "boolean") return
|
|
517
|
-
if (schema$1.format === "number") return
|
|
518
|
-
return
|
|
516
|
+
if (schema$1.format === "boolean") return _kubb_core_transformers.default.stringify(schema$1.value);
|
|
517
|
+
if (schema$1.format === "number") return _kubb_core_transformers.default.stringify(schema$1.value);
|
|
518
|
+
return _kubb_core_transformers.default.stringify(schema$1.value);
|
|
519
519
|
}));
|
|
520
520
|
},
|
|
521
521
|
ref(tree, options) {
|
|
522
522
|
const { current } = tree;
|
|
523
|
-
if (!(0,
|
|
523
|
+
if (!(0, _kubb_plugin_oas.isKeyword)(current, _kubb_plugin_oas.schemaKeywords.ref)) return void 0;
|
|
524
524
|
if (options.skipLazyForRefs) return current.args?.name;
|
|
525
525
|
return zodKeywordMapper.ref(current.args?.name);
|
|
526
526
|
},
|
|
527
527
|
object(tree, options) {
|
|
528
528
|
const { current, schema, name } = tree;
|
|
529
|
-
if (!(0,
|
|
529
|
+
if (!(0, _kubb_plugin_oas.isKeyword)(current, _kubb_plugin_oas.schemaKeywords.object)) return void 0;
|
|
530
530
|
const properties = Object.entries(current.args?.properties || {}).filter((item) => {
|
|
531
531
|
const schema$1 = item[1];
|
|
532
532
|
return schema$1 && typeof schema$1.map === "function";
|
|
533
533
|
}).map(([propertyName, schemas]) => {
|
|
534
|
-
const nameSchema = schemas.find((it) => it.keyword ===
|
|
535
|
-
const isNullable = schemas.some((it) => (0,
|
|
536
|
-
const isNullish = schemas.some((it) => (0,
|
|
537
|
-
const isOptional = schemas.some((it) => (0,
|
|
538
|
-
const hasRef = !!
|
|
534
|
+
const nameSchema = schemas.find((it) => it.keyword === _kubb_plugin_oas.schemaKeywords.name);
|
|
535
|
+
const isNullable = schemas.some((it) => (0, _kubb_plugin_oas.isKeyword)(it, _kubb_plugin_oas.schemaKeywords.nullable));
|
|
536
|
+
const isNullish = schemas.some((it) => (0, _kubb_plugin_oas.isKeyword)(it, _kubb_plugin_oas.schemaKeywords.nullish));
|
|
537
|
+
const isOptional = schemas.some((it) => (0, _kubb_plugin_oas.isKeyword)(it, _kubb_plugin_oas.schemaKeywords.optional));
|
|
538
|
+
const hasRef = !!_kubb_plugin_oas.SchemaGenerator.find(schemas, _kubb_plugin_oas.schemaKeywords.ref);
|
|
539
539
|
const mappedName = nameSchema?.args || propertyName;
|
|
540
540
|
if (options.mapper?.[mappedName]) return `"${propertyName}": ${options.mapper?.[mappedName]}`;
|
|
541
541
|
const baseSchemaOutput = sort(schemas).filter((schema$1) => {
|
|
542
|
-
return !(0,
|
|
542
|
+
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);
|
|
543
543
|
}).map((it) => {
|
|
544
544
|
const skipLazyForRefs = options.version === "4" && hasRef;
|
|
545
545
|
return this.parse({
|
|
@@ -601,7 +601,7 @@ const parse = (0, __kubb_plugin_oas.createParser)({
|
|
|
601
601
|
},
|
|
602
602
|
tuple(tree, options) {
|
|
603
603
|
const { current, schema, name } = tree;
|
|
604
|
-
if (!(0,
|
|
604
|
+
if (!(0, _kubb_plugin_oas.isKeyword)(current, _kubb_plugin_oas.schemaKeywords.tuple)) return void 0;
|
|
605
605
|
return zodKeywordMapper.tuple(current.args.items.map((it, _index, siblings) => this.parse({
|
|
606
606
|
schema,
|
|
607
607
|
parent: current,
|
|
@@ -612,90 +612,90 @@ const parse = (0, __kubb_plugin_oas.createParser)({
|
|
|
612
612
|
},
|
|
613
613
|
const(tree, _options) {
|
|
614
614
|
const { current } = tree;
|
|
615
|
-
if (!(0,
|
|
615
|
+
if (!(0, _kubb_plugin_oas.isKeyword)(current, _kubb_plugin_oas.schemaKeywords.const)) return void 0;
|
|
616
616
|
if (current.args.format === "number" && current.args.value !== void 0) return zodKeywordMapper.const(Number(current.args.value));
|
|
617
617
|
if (current.args.format === "boolean" && current.args.value !== void 0) return zodKeywordMapper.const(typeof current.args.value === "boolean" ? current.args.value : void 0);
|
|
618
|
-
return zodKeywordMapper.const(
|
|
618
|
+
return zodKeywordMapper.const(_kubb_core_transformers.default.stringify(current.args.value));
|
|
619
619
|
},
|
|
620
620
|
matches(tree, options) {
|
|
621
621
|
const { current, siblings } = tree;
|
|
622
|
-
if (!(0,
|
|
623
|
-
if (siblings.some((it) => (0,
|
|
624
|
-
const minSchema = (0,
|
|
625
|
-
const maxSchema = (0,
|
|
626
|
-
if (current.args) return zodKeywordMapper.matches(
|
|
622
|
+
if (!(0, _kubb_plugin_oas.isKeyword)(current, _kubb_plugin_oas.schemaKeywords.matches)) return void 0;
|
|
623
|
+
if (siblings.some((it) => (0, _kubb_plugin_oas.isKeyword)(it, _kubb_plugin_oas.schemaKeywords.ref))) return;
|
|
624
|
+
const minSchema = (0, _kubb_plugin_oas.findSchemaKeyword)(siblings, "min");
|
|
625
|
+
const maxSchema = (0, _kubb_plugin_oas.findSchemaKeyword)(siblings, "max");
|
|
626
|
+
if (current.args) return zodKeywordMapper.matches(_kubb_core_transformers.default.toRegExpString(current.args, null), shouldCoerce(options.coercion, "strings"), options.mini, minSchema?.args, maxSchema?.args);
|
|
627
627
|
},
|
|
628
628
|
default(tree, options) {
|
|
629
629
|
const { current } = tree;
|
|
630
|
-
if (!(0,
|
|
630
|
+
if (!(0, _kubb_plugin_oas.isKeyword)(current, _kubb_plugin_oas.schemaKeywords.default)) return void 0;
|
|
631
631
|
if (options.mini) return;
|
|
632
632
|
if (current.args !== void 0) return zodKeywordMapper.default(current.args);
|
|
633
633
|
return zodKeywordMapper.default();
|
|
634
634
|
},
|
|
635
635
|
describe(tree, options) {
|
|
636
636
|
const { current } = tree;
|
|
637
|
-
if (!(0,
|
|
638
|
-
if (current.args) return zodKeywordMapper.describe(
|
|
637
|
+
if (!(0, _kubb_plugin_oas.isKeyword)(current, _kubb_plugin_oas.schemaKeywords.describe)) return void 0;
|
|
638
|
+
if (current.args) return zodKeywordMapper.describe(_kubb_core_transformers.default.stringify(current.args.toString()), void 0, options.mini);
|
|
639
639
|
},
|
|
640
640
|
string(tree, options) {
|
|
641
641
|
const { current, siblings } = tree;
|
|
642
|
-
if (!(0,
|
|
643
|
-
const minSchema = (0,
|
|
644
|
-
const maxSchema = (0,
|
|
642
|
+
if (!(0, _kubb_plugin_oas.isKeyword)(current, _kubb_plugin_oas.schemaKeywords.string)) return void 0;
|
|
643
|
+
const minSchema = (0, _kubb_plugin_oas.findSchemaKeyword)(siblings, "min");
|
|
644
|
+
const maxSchema = (0, _kubb_plugin_oas.findSchemaKeyword)(siblings, "max");
|
|
645
645
|
return zodKeywordMapper.string(shouldCoerce(options.coercion, "strings"), minSchema?.args, maxSchema?.args, options.mini);
|
|
646
646
|
},
|
|
647
647
|
uuid(tree, options) {
|
|
648
648
|
const { current, siblings } = tree;
|
|
649
|
-
if (!(0,
|
|
650
|
-
const minSchema = (0,
|
|
651
|
-
const maxSchema = (0,
|
|
649
|
+
if (!(0, _kubb_plugin_oas.isKeyword)(current, _kubb_plugin_oas.schemaKeywords.uuid)) return void 0;
|
|
650
|
+
const minSchema = (0, _kubb_plugin_oas.findSchemaKeyword)(siblings, "min");
|
|
651
|
+
const maxSchema = (0, _kubb_plugin_oas.findSchemaKeyword)(siblings, "max");
|
|
652
652
|
return zodKeywordMapper.uuid(shouldCoerce(options.coercion, "strings"), options.version, minSchema?.args, maxSchema?.args, options.mini);
|
|
653
653
|
},
|
|
654
654
|
email(tree, options) {
|
|
655
655
|
const { current, siblings } = tree;
|
|
656
|
-
if (!(0,
|
|
657
|
-
const minSchema = (0,
|
|
658
|
-
const maxSchema = (0,
|
|
656
|
+
if (!(0, _kubb_plugin_oas.isKeyword)(current, _kubb_plugin_oas.schemaKeywords.email)) return void 0;
|
|
657
|
+
const minSchema = (0, _kubb_plugin_oas.findSchemaKeyword)(siblings, "min");
|
|
658
|
+
const maxSchema = (0, _kubb_plugin_oas.findSchemaKeyword)(siblings, "max");
|
|
659
659
|
return zodKeywordMapper.email(shouldCoerce(options.coercion, "strings"), options.version, minSchema?.args, maxSchema?.args, options.mini);
|
|
660
660
|
},
|
|
661
661
|
url(tree, options) {
|
|
662
662
|
const { current, siblings } = tree;
|
|
663
|
-
if (!(0,
|
|
664
|
-
const minSchema = (0,
|
|
665
|
-
const maxSchema = (0,
|
|
663
|
+
if (!(0, _kubb_plugin_oas.isKeyword)(current, _kubb_plugin_oas.schemaKeywords.url)) return void 0;
|
|
664
|
+
const minSchema = (0, _kubb_plugin_oas.findSchemaKeyword)(siblings, "min");
|
|
665
|
+
const maxSchema = (0, _kubb_plugin_oas.findSchemaKeyword)(siblings, "max");
|
|
666
666
|
return zodKeywordMapper.url(shouldCoerce(options.coercion, "strings"), options.version, minSchema?.args, maxSchema?.args, options.mini);
|
|
667
667
|
},
|
|
668
668
|
number(tree, options) {
|
|
669
669
|
const { current, siblings } = tree;
|
|
670
|
-
if (!(0,
|
|
671
|
-
const minSchema = (0,
|
|
672
|
-
const maxSchema = (0,
|
|
673
|
-
const exclusiveMinimumSchema = (0,
|
|
674
|
-
const exclusiveMaximumSchema = (0,
|
|
670
|
+
if (!(0, _kubb_plugin_oas.isKeyword)(current, _kubb_plugin_oas.schemaKeywords.number)) return void 0;
|
|
671
|
+
const minSchema = (0, _kubb_plugin_oas.findSchemaKeyword)(siblings, "min");
|
|
672
|
+
const maxSchema = (0, _kubb_plugin_oas.findSchemaKeyword)(siblings, "max");
|
|
673
|
+
const exclusiveMinimumSchema = (0, _kubb_plugin_oas.findSchemaKeyword)(siblings, "exclusiveMinimum");
|
|
674
|
+
const exclusiveMaximumSchema = (0, _kubb_plugin_oas.findSchemaKeyword)(siblings, "exclusiveMaximum");
|
|
675
675
|
return zodKeywordMapper.number(shouldCoerce(options.coercion, "numbers"), minSchema?.args, maxSchema?.args, exclusiveMinimumSchema?.args, exclusiveMaximumSchema?.args, options.mini);
|
|
676
676
|
},
|
|
677
677
|
integer(tree, options) {
|
|
678
678
|
const { current, siblings } = tree;
|
|
679
|
-
if (!(0,
|
|
680
|
-
const minSchema = (0,
|
|
681
|
-
const maxSchema = (0,
|
|
682
|
-
const exclusiveMinimumSchema = (0,
|
|
683
|
-
const exclusiveMaximumSchema = (0,
|
|
679
|
+
if (!(0, _kubb_plugin_oas.isKeyword)(current, _kubb_plugin_oas.schemaKeywords.integer)) return void 0;
|
|
680
|
+
const minSchema = (0, _kubb_plugin_oas.findSchemaKeyword)(siblings, "min");
|
|
681
|
+
const maxSchema = (0, _kubb_plugin_oas.findSchemaKeyword)(siblings, "max");
|
|
682
|
+
const exclusiveMinimumSchema = (0, _kubb_plugin_oas.findSchemaKeyword)(siblings, "exclusiveMinimum");
|
|
683
|
+
const exclusiveMaximumSchema = (0, _kubb_plugin_oas.findSchemaKeyword)(siblings, "exclusiveMaximum");
|
|
684
684
|
return zodKeywordMapper.integer(shouldCoerce(options.coercion, "numbers"), minSchema?.args, maxSchema?.args, options.version, exclusiveMinimumSchema?.args, exclusiveMaximumSchema?.args, options.mini);
|
|
685
685
|
},
|
|
686
686
|
datetime(tree, options) {
|
|
687
687
|
const { current } = tree;
|
|
688
|
-
if (!(0,
|
|
688
|
+
if (!(0, _kubb_plugin_oas.isKeyword)(current, _kubb_plugin_oas.schemaKeywords.datetime)) return void 0;
|
|
689
689
|
return zodKeywordMapper.datetime(current.args.offset, current.args.local, options.version, options.mini);
|
|
690
690
|
},
|
|
691
691
|
date(tree, options) {
|
|
692
692
|
const { current } = tree;
|
|
693
|
-
if (!(0,
|
|
693
|
+
if (!(0, _kubb_plugin_oas.isKeyword)(current, _kubb_plugin_oas.schemaKeywords.date)) return void 0;
|
|
694
694
|
return zodKeywordMapper.date(current.args.type, shouldCoerce(options.coercion, "dates"), options.version);
|
|
695
695
|
},
|
|
696
696
|
time(tree, options) {
|
|
697
697
|
const { current } = tree;
|
|
698
|
-
if (!(0,
|
|
698
|
+
if (!(0, _kubb_plugin_oas.isKeyword)(current, _kubb_plugin_oas.schemaKeywords.time)) return void 0;
|
|
699
699
|
return zodKeywordMapper.time(current.args.type, shouldCoerce(options.coercion, "dates"), options.version);
|
|
700
700
|
}
|
|
701
701
|
}
|
|
@@ -704,9 +704,9 @@ const parse = (0, __kubb_plugin_oas.createParser)({
|
|
|
704
704
|
//#endregion
|
|
705
705
|
//#region src/components/Zod.tsx
|
|
706
706
|
function Zod({ name, typeName, tree, schema, inferTypeName, mapper, coercion, keysToOmit, description, wrapOutput, version, emptySchemaType, mini = false }) {
|
|
707
|
-
const hasTuple = !!
|
|
707
|
+
const hasTuple = !!_kubb_plugin_oas.SchemaGenerator.find(tree, _kubb_plugin_oas.schemaKeywords.tuple);
|
|
708
708
|
const schemas = sort(tree).filter((item) => {
|
|
709
|
-
if (hasTuple && ((0,
|
|
709
|
+
if (hasTuple && ((0, _kubb_plugin_oas.isKeyword)(item, _kubb_plugin_oas.schemaKeywords.min) || (0, _kubb_plugin_oas.isKeyword)(item, _kubb_plugin_oas.schemaKeywords.max))) return false;
|
|
710
710
|
return true;
|
|
711
711
|
});
|
|
712
712
|
const baseSchemas = mini ? filterMiniModifiers(schemas) : schemas;
|
|
@@ -729,17 +729,17 @@ function Zod({ name, typeName, tree, schema, inferTypeName, mapper, coercion, ke
|
|
|
729
729
|
let suffix = "";
|
|
730
730
|
const firstSchema = schemas.at(0);
|
|
731
731
|
const lastSchema = schemas.at(-1);
|
|
732
|
-
if (!mini && lastSchema && (0,
|
|
732
|
+
if (!mini && lastSchema && (0, _kubb_plugin_oas.isKeyword)(lastSchema, _kubb_plugin_oas.schemaKeywords.nullable)) if (firstSchema && (0, _kubb_plugin_oas.isKeyword)(firstSchema, _kubb_plugin_oas.schemaKeywords.ref)) if (version === "3") suffix = ".unwrap().schema.unwrap()";
|
|
733
733
|
else suffix = ".unwrap().unwrap()";
|
|
734
734
|
else suffix = ".unwrap()";
|
|
735
735
|
else if (!mini) {
|
|
736
|
-
if (firstSchema && (0,
|
|
736
|
+
if (firstSchema && (0, _kubb_plugin_oas.isKeyword)(firstSchema, _kubb_plugin_oas.schemaKeywords.ref)) if (version === "3") suffix = ".schema";
|
|
737
737
|
else suffix = ".unwrap()";
|
|
738
738
|
}
|
|
739
739
|
const emptyValue = parse({
|
|
740
740
|
schema,
|
|
741
741
|
parent: void 0,
|
|
742
|
-
current: { keyword:
|
|
742
|
+
current: { keyword: _kubb_plugin_oas.schemaKeywords[emptySchemaType] },
|
|
743
743
|
siblings: []
|
|
744
744
|
}, {
|
|
745
745
|
mapper,
|
|
@@ -755,26 +755,26 @@ function Zod({ name, typeName, tree, schema, inferTypeName, mapper, coercion, ke
|
|
|
755
755
|
schema
|
|
756
756
|
}) || baseSchemaOutput : baseSchemaOutput;
|
|
757
757
|
const finalOutput = typeName ? `${wrappedSchemaOutput} as unknown as ${version === "4" ? "z.ZodType" : "ToZod"}<${typeName}>` : wrappedSchemaOutput;
|
|
758
|
-
return /* @__PURE__ */ (0,
|
|
758
|
+
return /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.File.Source, {
|
|
759
759
|
name,
|
|
760
760
|
isExportable: true,
|
|
761
761
|
isIndexable: true,
|
|
762
|
-
children: /* @__PURE__ */ (0,
|
|
762
|
+
children: /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.Const, {
|
|
763
763
|
export: true,
|
|
764
764
|
name,
|
|
765
|
-
JSDoc: { comments: [description ? `@description ${
|
|
765
|
+
JSDoc: { comments: [description ? `@description ${_kubb_core_transformers.default.jsStringEscape(description)}` : void 0].filter(Boolean) },
|
|
766
766
|
children: finalOutput
|
|
767
767
|
})
|
|
768
|
-
}), inferTypeName && /* @__PURE__ */ (0,
|
|
768
|
+
}), inferTypeName && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsxs)(_kubb_react_fabric.File.Source, {
|
|
769
769
|
name: inferTypeName,
|
|
770
770
|
isExportable: true,
|
|
771
771
|
isIndexable: true,
|
|
772
772
|
isTypeOnly: true,
|
|
773
|
-
children: [typeName && /* @__PURE__ */ (0,
|
|
773
|
+
children: [typeName && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.Type, {
|
|
774
774
|
export: true,
|
|
775
775
|
name: inferTypeName,
|
|
776
776
|
children: typeName
|
|
777
|
-
}), !typeName && /* @__PURE__ */ (0,
|
|
777
|
+
}), !typeName && /* @__PURE__ */ (0, _kubb_react_fabric_jsx_runtime.jsx)(_kubb_react_fabric.Type, {
|
|
778
778
|
export: true,
|
|
779
779
|
name: inferTypeName,
|
|
780
780
|
children: `z.infer<typeof ${name}>`
|
|
@@ -801,4 +801,4 @@ Object.defineProperty(exports, '__toESM', {
|
|
|
801
801
|
return __toESM;
|
|
802
802
|
}
|
|
803
803
|
});
|
|
804
|
-
//# sourceMappingURL=components-
|
|
804
|
+
//# sourceMappingURL=components-CtNn0D8u.cjs.map
|