@kubb/plugin-zod 5.0.0-beta.81 → 5.0.0-beta.84
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/index.cjs +94 -90
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +48 -44
- package/dist/index.js.map +1 -1
- package/package.json +3 -7
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { Exclude, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ast } from "
|
|
2
|
+
import { Exclude, Group, Include, Output, OutputOptions, Override, PluginFactoryOptions, Resolver, ast } from "kubb/kit";
|
|
3
3
|
import { AdapterOas } from "@kubb/adapter-oas";
|
|
4
4
|
|
|
5
5
|
//#region ../../internals/shared/src/operation.d.ts
|
|
@@ -451,7 +451,7 @@ declare global {
|
|
|
451
451
|
* When `mini: true`, schemas use the Zod Mini functional API instead of
|
|
452
452
|
* chainable methods.
|
|
453
453
|
*/
|
|
454
|
-
declare const zodGenerator: import("
|
|
454
|
+
declare const zodGenerator: import("kubb/kit").Generator<PluginZod, unknown>;
|
|
455
455
|
//#endregion
|
|
456
456
|
//#region src/plugin.d.ts
|
|
457
457
|
/**
|
|
@@ -468,7 +468,7 @@ declare const pluginZodName = "plugin-zod";
|
|
|
468
468
|
*
|
|
469
469
|
* @example
|
|
470
470
|
* ```ts
|
|
471
|
-
* import { defineConfig } from 'kubb'
|
|
471
|
+
* import { defineConfig } from 'kubb/config'
|
|
472
472
|
* import { pluginTs } from '@kubb/plugin-ts'
|
|
473
473
|
* import { pluginZod } from '@kubb/plugin-zod'
|
|
474
474
|
*
|
|
@@ -485,7 +485,7 @@ declare const pluginZodName = "plugin-zod";
|
|
|
485
485
|
* })
|
|
486
486
|
* ```
|
|
487
487
|
*/
|
|
488
|
-
declare const pluginZod: (options?: Options | undefined) => import("
|
|
488
|
+
declare const pluginZod: (options?: Options | undefined) => import("kubb/kit").Plugin<PluginZod>;
|
|
489
489
|
//#endregion
|
|
490
490
|
//#region src/resolvers/resolverZod.d.ts
|
|
491
491
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { t as __name } from "./rolldown-runtime-C0LytTxp.js";
|
|
2
|
-
import { ast, defineGenerator, definePlugin, defineResolver } from "
|
|
3
|
-
import { Const, File, Type, jsxRenderer } from "
|
|
4
|
-
import { Fragment, jsx, jsxs } from "
|
|
5
|
-
import { buildList, buildObject, containsCircularRef, extractRefName, lazyGetter, mapSchemaItems, mapSchemaMembers, mapSchemaProperties, objectKey, stringify, syncSchemaRef, toRegExpString } from "@kubb/ast/utils";
|
|
2
|
+
import { ast, defineGenerator, definePlugin, defineResolver } from "kubb/kit";
|
|
3
|
+
import { Const, File, Type, jsxRenderer } from "kubb/jsx";
|
|
4
|
+
import { Fragment, jsx, jsxs } from "kubb/jsx/jsx-runtime";
|
|
6
5
|
//#region ../../internals/utils/src/casing.ts
|
|
7
6
|
/**
|
|
8
7
|
* Shared implementation for camelCase and PascalCase conversion.
|
|
@@ -386,12 +385,12 @@ function containsCodec(node, seen = /* @__PURE__ */ new Set()) {
|
|
|
386
385
|
if (hasCodec(node)) return true;
|
|
387
386
|
if (node.type === "ref") {
|
|
388
387
|
if (!node.ref) return false;
|
|
389
|
-
const refName = extractRefName(node.ref);
|
|
388
|
+
const refName = ast.extractRefName(node.ref);
|
|
390
389
|
if (refName) {
|
|
391
390
|
if (seen.has(refName)) return false;
|
|
392
391
|
seen.add(refName);
|
|
393
392
|
}
|
|
394
|
-
const resolved = syncSchemaRef(node);
|
|
393
|
+
const resolved = ast.syncSchemaRef(node);
|
|
395
394
|
if (resolved.type === "ref") return false;
|
|
396
395
|
return containsCodec(resolved, seen);
|
|
397
396
|
}
|
|
@@ -407,7 +406,7 @@ function containsCodec(node, seen = /* @__PURE__ */ new Set()) {
|
|
|
407
406
|
* them to their input (encode) variant.
|
|
408
407
|
*/
|
|
409
408
|
function collectCodecRefNames(node) {
|
|
410
|
-
return ast.collect(node, { schema: (n) => n.type === "ref" && n.ref && containsCodec(n) ? extractRefName(n.ref) ?? void 0 : void 0 });
|
|
409
|
+
return ast.collect(node, { schema: (n) => n.type === "ref" && n.ref && containsCodec(n) ? ast.extractRefName(n.ref) ?? void 0 : void 0 });
|
|
411
410
|
}
|
|
412
411
|
/**
|
|
413
412
|
* Whether the node is a plain inline object whose shape can be lifted into an `.extend({ … })`
|
|
@@ -428,9 +427,9 @@ function isObjectSchemaNode(node, cyclicSchemas) {
|
|
|
428
427
|
if (node.nullable || node.optional || node.nullish) return false;
|
|
429
428
|
if (node.type === "object") return true;
|
|
430
429
|
if (node.type === "ref") {
|
|
431
|
-
const refName = (node.ref ? extractRefName(node.ref) : void 0) ?? node.name;
|
|
430
|
+
const refName = (node.ref ? ast.extractRefName(node.ref) : void 0) ?? node.name;
|
|
432
431
|
if (refName && cyclicSchemas?.has(refName)) return false;
|
|
433
|
-
const resolved = syncSchemaRef(node);
|
|
432
|
+
const resolved = ast.syncSchemaRef(node);
|
|
434
433
|
return resolved.type === "ref" || isObjectSchemaNode(resolved, cyclicSchemas);
|
|
435
434
|
}
|
|
436
435
|
if (node.type === "union") {
|
|
@@ -454,7 +453,7 @@ function isObjectComposableIntersection(node, cyclicSchemas) {
|
|
|
454
453
|
* Objects become `{}`, primitives become their string representation, strings are quoted.
|
|
455
454
|
*/
|
|
456
455
|
function formatDefault(value) {
|
|
457
|
-
if (typeof value === "string") return stringify(value);
|
|
456
|
+
if (typeof value === "string") return ast.stringify(value);
|
|
458
457
|
if (typeof value === "object" && value !== null) return "{}";
|
|
459
458
|
return String(value ?? "");
|
|
460
459
|
}
|
|
@@ -490,7 +489,7 @@ function defaultLiteral(node, value) {
|
|
|
490
489
|
* Strings are quoted; numbers and booleans are emitted raw.
|
|
491
490
|
*/
|
|
492
491
|
function formatLiteral(v) {
|
|
493
|
-
if (typeof v === "string") return stringify(v);
|
|
492
|
+
if (typeof v === "string") return ast.stringify(v);
|
|
494
493
|
return String(v);
|
|
495
494
|
}
|
|
496
495
|
/**
|
|
@@ -532,7 +531,8 @@ function patternKeySchemaMini({ patterns, regexType }) {
|
|
|
532
531
|
})}))`;
|
|
533
532
|
}
|
|
534
533
|
function patternKeySource({ patterns, regexType }) {
|
|
535
|
-
|
|
534
|
+
const source = patterns.length === 1 ? patterns[0] : patterns.map((pattern) => `(${pattern})`).join("|");
|
|
535
|
+
return ast.toRegExpString(source, regexFunc(regexType));
|
|
536
536
|
}
|
|
537
537
|
/**
|
|
538
538
|
* Build `.min()` / `.max()` / `.gt()` / `.lt()` constraint chains for numbers
|
|
@@ -555,7 +555,7 @@ function lengthConstraints({ min, max, pattern, regexType }) {
|
|
|
555
555
|
return [
|
|
556
556
|
min !== void 0 ? `.min(${min})` : "",
|
|
557
557
|
max !== void 0 ? `.max(${max})` : "",
|
|
558
|
-
pattern !== void 0 ? `.regex(${toRegExpString(pattern, regexFunc(regexType))})` : ""
|
|
558
|
+
pattern !== void 0 ? `.regex(${ast.toRegExpString(pattern, regexFunc(regexType))})` : ""
|
|
559
559
|
].join("");
|
|
560
560
|
}
|
|
561
561
|
/**
|
|
@@ -577,7 +577,7 @@ function lengthChecksMini({ min, max, pattern, regexType }) {
|
|
|
577
577
|
const checks = [];
|
|
578
578
|
if (min !== void 0) checks.push(`z.minLength(${min})`);
|
|
579
579
|
if (max !== void 0) checks.push(`z.maxLength(${max})`);
|
|
580
|
-
if (pattern !== void 0) checks.push(`z.regex(${toRegExpString(pattern, regexFunc(regexType))})`);
|
|
580
|
+
if (pattern !== void 0) checks.push(`z.regex(${ast.toRegExpString(pattern, regexFunc(regexType))})`);
|
|
581
581
|
return checks.length ? `.check(${checks.join(", ")})` : "";
|
|
582
582
|
}
|
|
583
583
|
/**
|
|
@@ -593,7 +593,7 @@ function applyModifiers({ value, schema, nullable, optional, nullish, defaultVal
|
|
|
593
593
|
})();
|
|
594
594
|
const literal = defaultValue !== void 0 ? defaultLiteral(schema, defaultValue) : null;
|
|
595
595
|
const withDefault = literal !== null ? `${withModifier}.default(${literal})` : withModifier;
|
|
596
|
-
const withDescription = description ? `${withDefault}.describe(${stringify(description)})` : withDefault;
|
|
596
|
+
const withDescription = description ? `${withDefault}.describe(${ast.stringify(description)})` : withDefault;
|
|
597
597
|
return examples?.length ? `${withDescription}.meta({ examples: [${examples.map(formatDefault).join(", ")}] })` : withDescription;
|
|
598
598
|
}
|
|
599
599
|
function modifierDepth(schema) {
|
|
@@ -636,9 +636,9 @@ function strictOneOfMember$1(member, node, cyclicSchemas) {
|
|
|
636
636
|
if (node.type === "object" && node.additionalProperties === void 0) return `${member}.strict()`;
|
|
637
637
|
if (node.type === "ref") {
|
|
638
638
|
if (member.startsWith("z.lazy(")) return member;
|
|
639
|
-
const refName = (node.ref ? extractRefName(node.ref) : void 0) ?? node.name;
|
|
639
|
+
const refName = (node.ref ? ast.extractRefName(node.ref) : void 0) ?? node.name;
|
|
640
640
|
if (refName && cyclicSchemas?.has(refName)) return member;
|
|
641
|
-
const schema = syncSchemaRef(node);
|
|
641
|
+
const schema = ast.syncSchemaRef(node);
|
|
642
642
|
if (schema.nullable || schema.optional || node.nullable || node.optional) return member;
|
|
643
643
|
if (schema.type === "object" && (schema.additionalProperties === void 0 || schema.additionalProperties === false)) return `${member}.strict()`;
|
|
644
644
|
}
|
|
@@ -663,8 +663,8 @@ function getMemberConstraint({ member, regexType }) {
|
|
|
663
663
|
function buildZodObjectShape(ctx, node) {
|
|
664
664
|
const objectNode = ast.narrowSchema(node, "object");
|
|
665
665
|
if (!objectNode) return "{}";
|
|
666
|
-
const isCyclic = (schema) => ctx.options.cyclicSchemas != null && containsCircularRef(schema, { circularSchemas: ctx.options.cyclicSchemas });
|
|
667
|
-
|
|
666
|
+
const isCyclic = (schema) => ctx.options.cyclicSchemas != null && ast.containsCircularRef(schema, { circularSchemas: ctx.options.cyclicSchemas });
|
|
667
|
+
const entries = ast.mapSchemaProperties(objectNode, (schema) => {
|
|
668
668
|
const hasSelfRef = isCyclic(schema);
|
|
669
669
|
const savedCyclicSchemas = ctx.options.cyclicSchemas;
|
|
670
670
|
if (hasSelfRef) ctx.options.cyclicSchemas = void 0;
|
|
@@ -673,7 +673,7 @@ function buildZodObjectShape(ctx, node) {
|
|
|
673
673
|
return baseOutput;
|
|
674
674
|
}).map(({ name: propName, property, output: baseOutput }) => {
|
|
675
675
|
const { schema } = property;
|
|
676
|
-
const meta = syncSchemaRef(schema);
|
|
676
|
+
const meta = ast.syncSchemaRef(schema);
|
|
677
677
|
const descriptionToApply = schema.type !== "ref" && meta.type === "ref" ? void 0 : meta.description;
|
|
678
678
|
const value = applyModifiers({
|
|
679
679
|
value: baseOutput,
|
|
@@ -685,11 +685,12 @@ function buildZodObjectShape(ctx, node) {
|
|
|
685
685
|
description: descriptionToApply,
|
|
686
686
|
examples: meta.examples
|
|
687
687
|
});
|
|
688
|
-
return isCyclic(schema) ? lazyGetter({
|
|
688
|
+
return isCyclic(schema) ? ast.lazyGetter({
|
|
689
689
|
name: propName,
|
|
690
690
|
body: value
|
|
691
|
-
}) : `${objectKey(propName)}: ${value}`;
|
|
692
|
-
})
|
|
691
|
+
}) : `${ast.objectKey(propName)}: ${value}`;
|
|
692
|
+
});
|
|
693
|
+
return ast.buildObject(entries);
|
|
693
694
|
}
|
|
694
695
|
/**
|
|
695
696
|
* Zod v4 printer built with `definePrinter`.
|
|
@@ -781,7 +782,7 @@ const printerZod = ast.createPrinter((options) => {
|
|
|
781
782
|
},
|
|
782
783
|
ref(node) {
|
|
783
784
|
if (!node.name) return null;
|
|
784
|
-
const refName = node.ref ? this.options.nameMapping?.get(node.ref) ?? extractRefName(node.ref) ?? node.name : node.name;
|
|
785
|
+
const refName = node.ref ? this.options.nameMapping?.get(node.ref) ?? ast.extractRefName(node.ref) ?? node.name : node.name;
|
|
785
786
|
const useInputVariant = node.ref != null && this.options.direction === "input" && containsCodec(node);
|
|
786
787
|
const resolvedName = node.ref ? useInputVariant ? this.options.resolver?.resolveInputSchemaName(refName) ?? refName : this.options.resolver?.default(refName, "function") ?? refName : node.name;
|
|
787
788
|
if (node.ref && this.options.cyclicSchemas?.has(refName)) return `z.lazy(() => ${resolvedName})`;
|
|
@@ -815,23 +816,24 @@ const printerZod = ast.createPrinter((options) => {
|
|
|
815
816
|
})();
|
|
816
817
|
},
|
|
817
818
|
array(node) {
|
|
818
|
-
const base = `z.array(${mapSchemaItems(node, (item) => this.transform(item)).map(({ output }) => output).filter(Boolean).join(", ") || this.transform(ast.factory.createSchema({ type: "unknown" }))})${lengthConstraints({
|
|
819
|
+
const base = `z.array(${ast.mapSchemaItems(node, (item) => this.transform(item)).map(({ output }) => output).filter(Boolean).join(", ") || this.transform(ast.factory.createSchema({ type: "unknown" }))})${lengthConstraints({
|
|
819
820
|
...node,
|
|
820
821
|
regexType: this.options.regexType
|
|
821
822
|
})}`;
|
|
822
823
|
return node.unique ? `${base}.refine(items => new Set(items).size === items.length, { message: "Array entries must be unique" })` : base;
|
|
823
824
|
},
|
|
824
825
|
tuple(node) {
|
|
825
|
-
|
|
826
|
+
const items = ast.mapSchemaItems(node, (item) => this.transform(item)).map(({ output }) => output).filter(Boolean);
|
|
827
|
+
return `z.tuple(${ast.buildList(items)})`;
|
|
826
828
|
},
|
|
827
829
|
union(node) {
|
|
828
830
|
const nodeMembers = node.members ?? [];
|
|
829
|
-
const members = mapSchemaMembers(node, (memberNode) => this.transform(memberNode)).map(({ schema, output }) => output && node.strategy === "one" ? strictOneOfMember$1(output, schema, cyclicSchemaNames) : output).filter(Boolean);
|
|
831
|
+
const members = ast.mapSchemaMembers(node, (memberNode) => this.transform(memberNode)).map(({ schema, output }) => output && node.strategy === "one" ? strictOneOfMember$1(output, schema, cyclicSchemaNames) : output).filter(Boolean);
|
|
830
832
|
if (members.length === 0) return "";
|
|
831
833
|
if (members.length === 1) return members[0];
|
|
832
834
|
const allDiscriminable = nodeMembers.every((m) => isObjectSchemaNode(m, cyclicSchemaNames));
|
|
833
|
-
if (node.discriminatorPropertyName && allDiscriminable) return `z.discriminatedUnion(${stringify(node.discriminatorPropertyName)}, ${buildList(members)})`;
|
|
834
|
-
return `z.union(${buildList(members)})`;
|
|
835
|
+
if (node.discriminatorPropertyName && allDiscriminable) return `z.discriminatedUnion(${ast.stringify(node.discriminatorPropertyName)}, ${ast.buildList(members)})`;
|
|
836
|
+
return `z.union(${ast.buildList(members)})`;
|
|
835
837
|
},
|
|
836
838
|
intersection(node) {
|
|
837
839
|
const members = node.members ?? [];
|
|
@@ -857,7 +859,7 @@ const printerZod = ast.createPrinter((options) => {
|
|
|
857
859
|
const { keysToOmit } = this.options;
|
|
858
860
|
const transformed = this.transform(node);
|
|
859
861
|
if (!transformed) return null;
|
|
860
|
-
const meta = syncSchemaRef(node);
|
|
862
|
+
const meta = ast.syncSchemaRef(node);
|
|
861
863
|
return applyModifiers({
|
|
862
864
|
value: (() => {
|
|
863
865
|
if (!keysToOmit?.length || meta.primitive !== "object" || meta.type === "union" && meta.discriminatorPropertyName) return transformed;
|
|
@@ -902,8 +904,8 @@ function getMemberConstraintMini({ member, regexType }) {
|
|
|
902
904
|
function buildZodMiniObjectShape(ctx, node) {
|
|
903
905
|
const objectNode = ast.narrowSchema(node, "object");
|
|
904
906
|
if (!objectNode) return "{}";
|
|
905
|
-
const isCyclic = (schema) => ctx.options.cyclicSchemas != null && containsCircularRef(schema, { circularSchemas: ctx.options.cyclicSchemas });
|
|
906
|
-
|
|
907
|
+
const isCyclic = (schema) => ctx.options.cyclicSchemas != null && ast.containsCircularRef(schema, { circularSchemas: ctx.options.cyclicSchemas });
|
|
908
|
+
const entries = ast.mapSchemaProperties(objectNode, (schema) => {
|
|
907
909
|
const hasSelfRef = isCyclic(schema);
|
|
908
910
|
const savedCyclicSchemas = ctx.options.cyclicSchemas;
|
|
909
911
|
if (hasSelfRef) ctx.options.cyclicSchemas = void 0;
|
|
@@ -912,7 +914,7 @@ function buildZodMiniObjectShape(ctx, node) {
|
|
|
912
914
|
return baseOutput;
|
|
913
915
|
}).map(({ name: propName, property, output: baseOutput }) => {
|
|
914
916
|
const { schema } = property;
|
|
915
|
-
const meta = syncSchemaRef(schema);
|
|
917
|
+
const meta = ast.syncSchemaRef(schema);
|
|
916
918
|
const value = applyMiniModifiers({
|
|
917
919
|
value: baseOutput,
|
|
918
920
|
schema,
|
|
@@ -921,11 +923,12 @@ function buildZodMiniObjectShape(ctx, node) {
|
|
|
921
923
|
nullish: schema.nullish,
|
|
922
924
|
defaultValue: meta.default
|
|
923
925
|
});
|
|
924
|
-
return isCyclic(schema) ? lazyGetter({
|
|
926
|
+
return isCyclic(schema) ? ast.lazyGetter({
|
|
925
927
|
name: propName,
|
|
926
928
|
body: value
|
|
927
|
-
}) : `${objectKey(propName)}: ${value}`;
|
|
928
|
-
})
|
|
929
|
+
}) : `${ast.objectKey(propName)}: ${value}`;
|
|
930
|
+
});
|
|
931
|
+
return ast.buildObject(entries);
|
|
929
932
|
}
|
|
930
933
|
/**
|
|
931
934
|
* Zod v4 Mini printer built with `definePrinter`.
|
|
@@ -1009,7 +1012,7 @@ const printerZodMini = ast.createPrinter((options) => {
|
|
|
1009
1012
|
},
|
|
1010
1013
|
ref(node) {
|
|
1011
1014
|
if (!node.name) return null;
|
|
1012
|
-
const refName = node.ref ? this.options.nameMapping?.get(node.ref) ?? extractRefName(node.ref) ?? node.name : node.name;
|
|
1015
|
+
const refName = node.ref ? this.options.nameMapping?.get(node.ref) ?? ast.extractRefName(node.ref) ?? node.name : node.name;
|
|
1013
1016
|
const resolvedName = node.ref ? this.options.resolver?.default(refName, "function") ?? refName : node.name;
|
|
1014
1017
|
if (node.ref && this.options.cyclicSchemas?.has(refName)) return `z.lazy(() => ${resolvedName})`;
|
|
1015
1018
|
return resolvedName;
|
|
@@ -1040,23 +1043,24 @@ const printerZodMini = ast.createPrinter((options) => {
|
|
|
1040
1043
|
return objectBase;
|
|
1041
1044
|
},
|
|
1042
1045
|
array(node) {
|
|
1043
|
-
const base = `z.array(${mapSchemaItems(node, (item) => this.transform(item)).map(({ output }) => output).filter(Boolean).join(", ") || this.transform(ast.factory.createSchema({ type: "unknown" }))})${lengthChecksMini({
|
|
1046
|
+
const base = `z.array(${ast.mapSchemaItems(node, (item) => this.transform(item)).map(({ output }) => output).filter(Boolean).join(", ") || this.transform(ast.factory.createSchema({ type: "unknown" }))})${lengthChecksMini({
|
|
1044
1047
|
...node,
|
|
1045
1048
|
regexType: this.options.regexType
|
|
1046
1049
|
})}`;
|
|
1047
1050
|
return node.unique ? `${base}.refine(items => new Set(items).size === items.length, { message: "Array entries must be unique" })` : base;
|
|
1048
1051
|
},
|
|
1049
1052
|
tuple(node) {
|
|
1050
|
-
|
|
1053
|
+
const items = ast.mapSchemaItems(node, (item) => this.transform(item)).map(({ output }) => output).filter(Boolean);
|
|
1054
|
+
return `z.tuple(${ast.buildList(items)})`;
|
|
1051
1055
|
},
|
|
1052
1056
|
union(node) {
|
|
1053
1057
|
const nodeMembers = node.members ?? [];
|
|
1054
|
-
const members = mapSchemaMembers(node, (memberNode) => this.transform(memberNode)).map(({ schema, output }) => output && node.strategy === "one" ? strictOneOfMember(output, schema) : output).filter(Boolean);
|
|
1058
|
+
const members = ast.mapSchemaMembers(node, (memberNode) => this.transform(memberNode)).map(({ schema, output }) => output && node.strategy === "one" ? strictOneOfMember(output, schema) : output).filter(Boolean);
|
|
1055
1059
|
if (members.length === 0) return "";
|
|
1056
1060
|
if (members.length === 1) return members[0];
|
|
1057
1061
|
const allDiscriminable = nodeMembers.every((m) => isObjectSchemaNode(m, cyclicSchemaNames));
|
|
1058
|
-
if (node.discriminatorPropertyName && allDiscriminable) return `z.discriminatedUnion(${stringify(node.discriminatorPropertyName)}, ${buildList(members)})`;
|
|
1059
|
-
return `z.union(${buildList(members)})`;
|
|
1062
|
+
if (node.discriminatorPropertyName && allDiscriminable) return `z.discriminatedUnion(${ast.stringify(node.discriminatorPropertyName)}, ${ast.buildList(members)})`;
|
|
1063
|
+
return `z.union(${ast.buildList(members)})`;
|
|
1060
1064
|
},
|
|
1061
1065
|
intersection(node) {
|
|
1062
1066
|
const members = node.members ?? [];
|
|
@@ -1082,7 +1086,7 @@ const printerZodMini = ast.createPrinter((options) => {
|
|
|
1082
1086
|
const { keysToOmit } = this.options;
|
|
1083
1087
|
const transformed = this.transform(node);
|
|
1084
1088
|
if (!transformed) return null;
|
|
1085
|
-
const meta = syncSchemaRef(node);
|
|
1089
|
+
const meta = ast.syncSchemaRef(node);
|
|
1086
1090
|
return applyMiniModifiers({
|
|
1087
1091
|
value: (() => {
|
|
1088
1092
|
if (!keysToOmit?.length || meta.primitive !== "object" || meta.type === "union" && meta.discriminatorPropertyName) return transformed;
|
|
@@ -1591,7 +1595,7 @@ const pluginZodName = "plugin-zod";
|
|
|
1591
1595
|
*
|
|
1592
1596
|
* @example
|
|
1593
1597
|
* ```ts
|
|
1594
|
-
* import { defineConfig } from 'kubb'
|
|
1598
|
+
* import { defineConfig } from 'kubb/config'
|
|
1595
1599
|
* import { pluginTs } from '@kubb/plugin-ts'
|
|
1596
1600
|
* import { pluginZod } from '@kubb/plugin-zod'
|
|
1597
1601
|
*
|