@kubb/plugin-zod 5.1.0 → 5.1.2

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 CHANGED
@@ -789,68 +789,6 @@ function shouldCoerce(coercion, type) {
789
789
  return !!coercion[type];
790
790
  }
791
791
  /**
792
- * Registered codecs, checked in order.
793
- */
794
- const codecs = [{
795
- matches(node) {
796
- return node.type === "date" && node.representation === "date";
797
- },
798
- decode(node) {
799
- return node.format === "date" ? "z.iso.date().transform((value) => new Date(value))" : "z.iso.datetime().transform((value) => new Date(value))";
800
- },
801
- encode(node) {
802
- return node.format === "date" ? "z.date().transform((value) => value.toISOString().slice(0, 10))" : "z.date().transform((value) => value.toISOString())";
803
- }
804
- }];
805
- /**
806
- * Returns the codec for this node, or `undefined` when the node needs no
807
- * encode/decode (its wire and runtime types match).
808
- */
809
- function getCodec(node) {
810
- if (!node) return void 0;
811
- return codecs.find((codec) => codec.matches(node));
812
- }
813
- /**
814
- * Returns `true` when the node itself is encoded/decoded by a codec.
815
- */
816
- function hasCodec(node) {
817
- return getCodec(node) !== void 0;
818
- }
819
- /**
820
- * Returns `true` when the schema transitively contains a codec node —
821
- * a value whose runtime type differs from its wire type (see {@link hasCodec}),
822
- * so it must be decoded (response) or encoded (request) at the validation boundary.
823
- * `$ref`s are followed via their resolved schema; a `seen` set guards cycles.
824
- */
825
- function containsCodec(node, seen = /* @__PURE__ */ new Set()) {
826
- if (!node) return false;
827
- if (hasCodec(node)) return true;
828
- if (node.type === "ref") {
829
- if (!node.ref) return false;
830
- const refName = (0, kubb_kit.extractRefName)(node.ref);
831
- if (refName) {
832
- if (seen.has(refName)) return false;
833
- seen.add(refName);
834
- }
835
- const resolved = (0, kubb_kit.syncSchemaRef)(node);
836
- if (resolved.type === "ref") return false;
837
- return containsCodec(resolved, seen);
838
- }
839
- const children = [];
840
- if ("properties" in node && node.properties) children.push(...node.properties.map((prop) => prop.schema));
841
- if ("items" in node && node.items) children.push(...node.items);
842
- if ("members" in node && node.members) children.push(...node.members);
843
- if ("additionalProperties" in node && node.additionalProperties && node.additionalProperties !== true) children.push(node.additionalProperties);
844
- return children.some((child) => containsCodec(child, seen));
845
- }
846
- /**
847
- * Collects the names of `$ref` schemas that transitively contain a codec, so the generator can route
848
- * them to their input (encode) variant.
849
- */
850
- function collectCodecRefNames(node) {
851
- return kubb_kit.ast.collectSync(node, { schema: (n) => n.type === "ref" && n.ref && containsCodec(n) ? kubb_kit.ast.resolveRefName(n) ?? void 0 : void 0 });
852
- }
853
- /**
854
792
  * Whether the node is a plain inline object whose shape can be lifted into an `.extend({ … })`
855
793
  * argument. A catchall, `patternProperties`, or a nullable/optional wrapper cannot, so those stay
856
794
  * on `.and(…)`.
@@ -892,10 +830,12 @@ function isObjectComposableIntersection(node, cyclicSchemas) {
892
830
  }
893
831
  /**
894
832
  * Format a default value as a code-level literal.
895
- * Objects become `{}`, primitives become their string representation, strings are quoted.
833
+ * Arrays keep their contents, other objects become `{}`, primitives become their string
834
+ * representation, strings are quoted.
896
835
  */
897
836
  function formatDefault(value) {
898
837
  if (typeof value === "string") return stringify(value);
838
+ if (Array.isArray(value)) return JSON.stringify(value);
899
839
  if (typeof value === "object" && value !== null) return "{}";
900
840
  return String(value ?? "");
901
841
  }
@@ -910,13 +850,14 @@ function formatDefault(value) {
910
850
  */
911
851
  function defaultLiteral(node, value) {
912
852
  if (value === null) return null;
913
- if (node && kubb_kit.ast.narrowSchema(node, "bigint")) {
853
+ const resolved = node ? (0, kubb_kit.syncSchemaRef)(node) : void 0;
854
+ if (resolved && kubb_kit.ast.narrowSchema(resolved, "bigint")) {
914
855
  if (typeof value === "bigint") return `BigInt(${value})`;
915
856
  if (typeof value === "number" && Number.isInteger(value)) return `BigInt(${value})`;
916
857
  return null;
917
858
  }
918
- if (node && kubb_kit.ast.narrowSchema(node, "array")) return Array.isArray(value) ? JSON.stringify(value) : null;
919
- const enumNode = node ? kubb_kit.ast.narrowSchema(node, "enum") : void 0;
859
+ if (resolved && kubb_kit.ast.narrowSchema(resolved, "array")) return Array.isArray(value) ? JSON.stringify(value) : null;
860
+ const enumNode = resolved ? kubb_kit.ast.narrowSchema(resolved, "enum") : void 0;
920
861
  if (enumNode) {
921
862
  const values = enumNode.namedEnumValues?.map((member) => member.value) ?? enumNode.enumValues ?? [];
922
863
  if (values.length) {
@@ -1163,6 +1104,168 @@ function buildZodObjectShape(ctx, node) {
1163
1104
  }));
1164
1105
  }
1165
1106
  /**
1107
+ * Types the direction probe skips. They delegate to their children rather than reading
1108
+ * `direction` themselves, so {@link containsDirectionalNode} walks into the children instead.
1109
+ */
1110
+ const CONTAINER_TYPES = /* @__PURE__ */ new Set([
1111
+ "object",
1112
+ "array",
1113
+ "tuple",
1114
+ "union",
1115
+ "intersection",
1116
+ "ref"
1117
+ ]);
1118
+ /**
1119
+ * Runs the node's effective handler (a `printer.nodes` override, else the built-in) once per
1120
+ * direction and reports whether the two disagree. That difference is what makes a component
1121
+ * need an `${name}InputSchema` variant.
1122
+ */
1123
+ function variesByDirection({ node, printerOptions }) {
1124
+ if (CONTAINER_TYPES.has(node.type)) return false;
1125
+ const handler = printerOptions.nodes?.[node.type] ?? scalarNodes[node.type];
1126
+ if (!handler) return false;
1127
+ const call = (direction) => {
1128
+ const context = {
1129
+ options: {
1130
+ ...printerOptions,
1131
+ direction
1132
+ },
1133
+ transform: () => null,
1134
+ base: () => null
1135
+ };
1136
+ return handler.call(context, node);
1137
+ };
1138
+ return call("decode") !== call("encode");
1139
+ }
1140
+ /**
1141
+ * Whether the schema transitively contains a node that prints differently per direction, so it
1142
+ * must decode on responses and encode on requests. Follows `$ref`s through their resolved
1143
+ * schema, with `seen` guarding cycles.
1144
+ */
1145
+ function containsDirectionalNode({ node, printerOptions, seen = /* @__PURE__ */ new Set() }) {
1146
+ if (!node) return false;
1147
+ if (node.type === "ref") {
1148
+ if (!node.ref) return false;
1149
+ const refName = (0, kubb_kit.extractRefName)(node.ref);
1150
+ if (refName) {
1151
+ if (seen.has(refName)) return false;
1152
+ seen.add(refName);
1153
+ }
1154
+ const resolved = (0, kubb_kit.syncSchemaRef)(node);
1155
+ if (resolved.type === "ref") return false;
1156
+ return containsDirectionalNode({
1157
+ node: resolved,
1158
+ printerOptions,
1159
+ seen
1160
+ });
1161
+ }
1162
+ if (variesByDirection({
1163
+ node,
1164
+ printerOptions
1165
+ })) return true;
1166
+ const children = [];
1167
+ if ("properties" in node && node.properties) children.push(...node.properties.map((prop) => prop.schema));
1168
+ if ("items" in node && node.items) children.push(...node.items);
1169
+ if ("members" in node && node.members) children.push(...node.members);
1170
+ if ("additionalProperties" in node && node.additionalProperties && node.additionalProperties !== true) children.push(node.additionalProperties);
1171
+ return children.some((child) => containsDirectionalNode({
1172
+ node: child,
1173
+ printerOptions,
1174
+ seen
1175
+ }));
1176
+ }
1177
+ /**
1178
+ * Names of the `$ref` schemas the generator should route to their input (encode) variant.
1179
+ */
1180
+ function collectDirectionalRefNames({ node, printerOptions }) {
1181
+ return kubb_kit.ast.collectSync(node, { schema: (n) => n.type === "ref" && n.ref && containsDirectionalNode({
1182
+ node: n,
1183
+ printerOptions
1184
+ }) ? kubb_kit.ast.resolveRefName(n) ?? void 0 : void 0 });
1185
+ }
1186
+ /**
1187
+ * Handlers that never recurse into children, so {@link variesByDirection} can call one directly
1188
+ * to probe both directions without building a printer.
1189
+ *
1190
+ * `date` is the built-in two-way conversion, decoding `string → Date` on responses and encoding
1191
+ * back on requests, keeping `date` and `date-time` precision apart. Only `representation: 'date'`
1192
+ * fields convert; ISO-string fields print `z.iso.date()` either way. A `printer.nodes.date`
1193
+ * override replaces the whole handler, direction branch included.
1194
+ */
1195
+ const scalarNodes = {
1196
+ any: () => "z.any()",
1197
+ unknown: () => "z.unknown()",
1198
+ void: () => "z.void()",
1199
+ never: () => "z.never()",
1200
+ boolean: () => "z.boolean()",
1201
+ null: () => "z.null()",
1202
+ string(node) {
1203
+ const base = shouldCoerce(this.options.coercion, "strings") ? "z.coerce.string()" : "z.string()";
1204
+ const pattern = node.pattern ?? integerFormatPattern(node.format);
1205
+ return `${base}${lengthConstraints({
1206
+ ...node,
1207
+ pattern,
1208
+ regexType: this.options.regexType
1209
+ })}`;
1210
+ },
1211
+ number(node) {
1212
+ return `${shouldCoerce(this.options.coercion, "numbers") ? "z.coerce.number()" : "z.number()"}${numberConstraints(node)}`;
1213
+ },
1214
+ integer(node) {
1215
+ return `${shouldCoerce(this.options.coercion, "numbers") ? "z.coerce.number().int()" : "z.int()"}${numberConstraints(node)}`;
1216
+ },
1217
+ bigint() {
1218
+ return "z.coerce.bigint()";
1219
+ },
1220
+ date(node) {
1221
+ if (node.representation !== "date") return "z.iso.date()";
1222
+ if (this.options.direction === "encode") return node.format === "date" ? "z.date().transform((value) => value.toISOString().slice(0, 10))" : "z.date().transform((value) => value.toISOString())";
1223
+ const decoded = node.format === "date" ? "z.iso.date().transform((value) => new Date(value))" : "z.iso.datetime().transform((value) => new Date(value))";
1224
+ return shouldCoerce(this.options.coercion, "dates") ? "z.coerce.date()" : decoded;
1225
+ },
1226
+ datetime(node) {
1227
+ const offset = node.offset || this.options.dateType === "stringOffset";
1228
+ const local = node.local || this.options.dateType === "stringLocal";
1229
+ if (offset) return "z.iso.datetime({ offset: true })";
1230
+ if (local) return "z.iso.datetime({ local: true })";
1231
+ return "z.iso.datetime()";
1232
+ },
1233
+ time(node) {
1234
+ if (node.representation === "string") return "z.iso.time()";
1235
+ return shouldCoerce(this.options.coercion, "dates") ? "z.coerce.date()" : "z.date()";
1236
+ },
1237
+ uuid(node) {
1238
+ return `${this.options.guidType === "guid" ? "z.guid()" : "z.uuid()"}${lengthConstraints({
1239
+ ...node,
1240
+ regexType: this.options.regexType
1241
+ })}`;
1242
+ },
1243
+ email(node) {
1244
+ return `z.email()${lengthConstraints({
1245
+ ...node,
1246
+ regexType: this.options.regexType
1247
+ })}`;
1248
+ },
1249
+ url(node) {
1250
+ return `z.url()${lengthConstraints({
1251
+ ...node,
1252
+ regexType: this.options.regexType
1253
+ })}`;
1254
+ },
1255
+ ipv4: () => "z.ipv4()",
1256
+ ipv6: () => "z.ipv6()",
1257
+ blob: () => "z.instanceof(File)",
1258
+ enum(node) {
1259
+ const nonNullValues = (node.namedEnumValues?.map((v) => v.value) ?? node.enumValues ?? []).filter((v) => v !== null);
1260
+ if (node.namedEnumValues?.length) {
1261
+ const literals = nonNullValues.map((v) => `z.literal(${formatLiteral(v)})`);
1262
+ if (literals.length === 1) return literals[0];
1263
+ return `z.union([${literals.join(", ")}])`;
1264
+ }
1265
+ return buildEnum(nonNullValues);
1266
+ }
1267
+ };
1268
+ /**
1166
1269
  * Zod v4 printer built with `definePrinter`.
1167
1270
  *
1168
1271
  * Converts a `SchemaNode` AST into a Zod v4 code string using the chainable API
@@ -1180,84 +1283,15 @@ const printerZod = kubb_kit.ast.createPrinter((options) => {
1180
1283
  name: "zod",
1181
1284
  options,
1182
1285
  nodes: {
1183
- any: () => "z.any()",
1184
- unknown: () => "z.unknown()",
1185
- void: () => "z.void()",
1186
- never: () => "z.never()",
1187
- boolean: () => "z.boolean()",
1188
- null: () => "z.null()",
1189
- string(node) {
1190
- const base = shouldCoerce(this.options.coercion, "strings") ? "z.coerce.string()" : "z.string()";
1191
- const pattern = node.pattern ?? integerFormatPattern(node.format);
1192
- return `${base}${lengthConstraints({
1193
- ...node,
1194
- pattern,
1195
- regexType: this.options.regexType
1196
- })}`;
1197
- },
1198
- number(node) {
1199
- return `${shouldCoerce(this.options.coercion, "numbers") ? "z.coerce.number()" : "z.number()"}${numberConstraints(node)}`;
1200
- },
1201
- integer(node) {
1202
- return `${shouldCoerce(this.options.coercion, "numbers") ? "z.coerce.number().int()" : "z.int()"}${numberConstraints(node)}`;
1203
- },
1204
- bigint() {
1205
- return shouldCoerce(this.options.coercion, "numbers") ? "z.coerce.bigint()" : "z.bigint()";
1206
- },
1207
- date(node) {
1208
- const codec = getCodec(node);
1209
- if (codec) {
1210
- if (this.options.direction === "input") return codec.encode(node);
1211
- return shouldCoerce(this.options.coercion, "dates") ? "z.coerce.date()" : codec.decode(node);
1212
- }
1213
- return "z.iso.date()";
1214
- },
1215
- datetime(node) {
1216
- const offset = node.offset || this.options.dateType === "stringOffset";
1217
- const local = node.local || this.options.dateType === "stringLocal";
1218
- if (offset) return "z.iso.datetime({ offset: true })";
1219
- if (local) return "z.iso.datetime({ local: true })";
1220
- return "z.iso.datetime()";
1221
- },
1222
- time(node) {
1223
- if (node.representation === "string") return "z.iso.time()";
1224
- return shouldCoerce(this.options.coercion, "dates") ? "z.coerce.date()" : "z.date()";
1225
- },
1226
- uuid(node) {
1227
- return `${this.options.guidType === "guid" ? "z.guid()" : "z.uuid()"}${lengthConstraints({
1228
- ...node,
1229
- regexType: this.options.regexType
1230
- })}`;
1231
- },
1232
- email(node) {
1233
- return `z.email()${lengthConstraints({
1234
- ...node,
1235
- regexType: this.options.regexType
1236
- })}`;
1237
- },
1238
- url(node) {
1239
- return `z.url()${lengthConstraints({
1240
- ...node,
1241
- regexType: this.options.regexType
1242
- })}`;
1243
- },
1244
- ipv4: () => "z.ipv4()",
1245
- ipv6: () => "z.ipv6()",
1246
- blob: () => "z.instanceof(File)",
1247
- enum(node) {
1248
- const nonNullValues = (node.namedEnumValues?.map((v) => v.value) ?? node.enumValues ?? []).filter((v) => v !== null);
1249
- if (node.namedEnumValues?.length) {
1250
- const literals = nonNullValues.map((v) => `z.literal(${formatLiteral(v)})`);
1251
- if (literals.length === 1) return literals[0];
1252
- return `z.union([${literals.join(", ")}])`;
1253
- }
1254
- return buildEnum(nonNullValues);
1255
- },
1286
+ ...scalarNodes,
1256
1287
  ref(node) {
1257
1288
  if (!node.name) return null;
1258
1289
  const refName = kubb_kit.ast.resolveRefName(node);
1259
1290
  if (!refName) return null;
1260
- const useInputVariant = node.ref != null && this.options.direction === "input" && containsCodec(node);
1291
+ const useInputVariant = node.ref != null && this.options.direction === "encode" && containsDirectionalNode({
1292
+ node,
1293
+ printerOptions: this.options
1294
+ });
1261
1295
  const resolvedName = node.ref ? useInputVariant ? this.options.resolver?.schema.inputName(refName) ?? refName : this.options.resolver?.name(refName) ?? refName : node.name;
1262
1296
  if (node.ref && this.options.cyclicSchemas?.has(refName)) return `z.lazy(() => ${resolvedName})`;
1263
1297
  return resolvedName;
@@ -1441,7 +1475,7 @@ const printerZodMini = kubb_kit.ast.createPrinter((options) => {
1441
1475
  return `z.int()${numberChecksMini(node)}`;
1442
1476
  },
1443
1477
  bigint(node) {
1444
- return `z.bigint()${numberChecksMini(node)}`;
1478
+ return `z.coerce.bigint()${numberChecksMini(node)}`;
1445
1479
  },
1446
1480
  date(node) {
1447
1481
  if (node.representation === "string") return "z.iso.date()";
@@ -1584,29 +1618,28 @@ const printerZodMini = kubb_kit.ast.createPrinter((options) => {
1584
1618
  const zodPrinterCache = /* @__PURE__ */ new WeakMap();
1585
1619
  const zodMiniPrinterCache = /* @__PURE__ */ new WeakMap();
1586
1620
  /**
1587
- * Returns the cached `output`/`input` direction printers for a resolver, building them on
1588
- * first use. The `input` printer encodes `Date → string` for request bodies, and `output` decodes
1589
- * `string → Date` for responses. Schemas without `dateType: 'date'` fields print identically.
1621
+ * Cached printer per direction for a resolver, built on first use. Schemas holding nothing that
1622
+ * converts print the same either way.
1590
1623
  */
1591
1624
  function getStdPrinters(resolver, params) {
1592
1625
  const cached = zodPrinterCache.get(resolver);
1593
1626
  if (cached && cached.coercion === params.coercion && cached.guidType === params.guidType && cached.regexType === params.regexType && cached.dateType === params.dateType && cached.nodes === params.nodes) return {
1594
- output: cached.output,
1595
- input: cached.input
1627
+ decode: cached.decode,
1628
+ encode: cached.encode
1596
1629
  };
1597
- const output = printerZod({
1630
+ const decode = printerZod({
1598
1631
  ...params,
1599
1632
  resolver,
1600
- direction: "output"
1633
+ direction: "decode"
1601
1634
  });
1602
- const input = printerZod({
1635
+ const encode = printerZod({
1603
1636
  ...params,
1604
1637
  resolver,
1605
- direction: "input"
1638
+ direction: "encode"
1606
1639
  });
1607
1640
  zodPrinterCache.set(resolver, {
1608
- output,
1609
- input,
1641
+ decode,
1642
+ encode,
1610
1643
  coercion: params.coercion,
1611
1644
  guidType: params.guidType,
1612
1645
  regexType: params.regexType,
@@ -1614,8 +1647,8 @@ function getStdPrinters(resolver, params) {
1614
1647
  nodes: params.nodes
1615
1648
  });
1616
1649
  return {
1617
- output,
1618
- input
1650
+ decode,
1651
+ encode
1619
1652
  };
1620
1653
  }
1621
1654
  function getMiniPrinter(resolver, params) {
@@ -1649,15 +1682,30 @@ const zodGenerator = (0, kubb_kit.defineGenerator)({
1649
1682
  if (!node.name) return;
1650
1683
  const isZodImport = ZOD_NAMESPACE_IMPORTS.has(importPath);
1651
1684
  const cyclicSchemas = new Set(ctx.meta.circularNames);
1652
- const hasCodec = !mini && containsCodec(node);
1653
- const codecRefNames = new Set(hasCodec ? collectCodecRefNames(node) : []);
1685
+ const printerOptions = {
1686
+ coercion,
1687
+ guidType,
1688
+ regexType,
1689
+ dateType,
1690
+ resolver,
1691
+ cyclicSchemas,
1692
+ nodes: printer?.nodes
1693
+ };
1694
+ const hasDirectionalNode = !mini && containsDirectionalNode({
1695
+ node,
1696
+ printerOptions
1697
+ });
1698
+ const directionalRefNames = new Set(hasDirectionalNode ? collectDirectionalRefNames({
1699
+ node,
1700
+ printerOptions
1701
+ }) : []);
1654
1702
  const importEntries = resolver.imports({
1655
1703
  node,
1656
1704
  root,
1657
1705
  output,
1658
1706
  group: group ?? void 0
1659
1707
  });
1660
- const inputImportEntries = hasCodec ? [...codecRefNames].map((schemaName) => ({
1708
+ const inputImportEntries = hasDirectionalNode ? [...directionalRefNames].map((schemaName) => ({
1661
1709
  name: [resolver.schema.inputName(schemaName)],
1662
1710
  path: resolver.file({
1663
1711
  name: schemaName,
@@ -1698,7 +1746,7 @@ const zodGenerator = (0, kubb_kit.defineGenerator)({
1698
1746
  regexType,
1699
1747
  cyclicSchemas,
1700
1748
  nodes: printer?.nodes
1701
- }) : stdPrinters.output;
1749
+ }) : stdPrinters.decode;
1702
1750
  return /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsxs)(kubb_jsx.File, {
1703
1751
  baseName: meta.file.baseName,
1704
1752
  path: meta.file.path,
@@ -1741,10 +1789,10 @@ const zodGenerator = (0, kubb_kit.defineGenerator)({
1741
1789
  inferTypeName,
1742
1790
  cyclic: cyclicSchemas.has(node.name)
1743
1791
  }),
1744
- hasCodec && stdPrinters && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(Zod, {
1792
+ hasDirectionalNode && stdPrinters && /* @__PURE__ */ (0, kubb_jsx_jsx_runtime.jsx)(Zod, {
1745
1793
  name: resolver.schema.inputName(node.name),
1746
1794
  node,
1747
- printer: stdPrinters.input,
1795
+ printer: stdPrinters.encode,
1748
1796
  inferTypeName: inferred ? resolver.schema.inputTypeName(node.name) : null,
1749
1797
  cyclic: cyclicSchemas.has(node.name)
1750
1798
  })
@@ -1767,16 +1815,28 @@ const zodGenerator = (0, kubb_kit.defineGenerator)({
1767
1815
  group: group ?? void 0
1768
1816
  }) };
1769
1817
  const cyclicSchemas = new Set(ctx.meta.circularNames);
1770
- function renderSchemaEntry({ schema, name, keysToOmit, direction = "output" }) {
1818
+ const printerOptions = {
1819
+ coercion,
1820
+ guidType,
1821
+ regexType,
1822
+ dateType,
1823
+ resolver,
1824
+ cyclicSchemas,
1825
+ nodes: printer?.nodes
1826
+ };
1827
+ function renderSchemaEntry({ schema, name, keysToOmit, direction = "decode" }) {
1771
1828
  if (!schema) return null;
1772
1829
  const inferTypeName = inferred ? resolver.schema.type(name) : null;
1773
- const codecRefNames = direction === "input" && !mini ? new Set(collectCodecRefNames(schema)) : null;
1830
+ const directionalRefNames = direction === "encode" && !mini ? new Set(collectDirectionalRefNames({
1831
+ node: schema,
1832
+ printerOptions
1833
+ })) : null;
1774
1834
  const imports = resolver.imports({
1775
1835
  node: schema,
1776
1836
  root,
1777
1837
  output,
1778
1838
  group: group ?? void 0,
1779
- name: (schemaName) => codecRefNames?.has(schemaName) ? resolver.schema.inputName(schemaName) : resolver.name(schemaName)
1839
+ name: (schemaName) => directionalRefNames?.has(schemaName) ? resolver.schema.inputName(schemaName) : resolver.name(schemaName)
1780
1840
  });
1781
1841
  const schemaPrinter = mini ? keysToOmit?.length ? printerZodMini({
1782
1842
  guidType,
@@ -1865,7 +1925,7 @@ const zodGenerator = (0, kubb_kit.defineGenerator)({
1865
1925
  const paramSchemas = node.parameters.map((param) => renderSchemaEntry({
1866
1926
  schema: param.schema,
1867
1927
  name: resolver.param.name(node, param),
1868
- direction: "input"
1928
+ direction: "encode"
1869
1929
  }));
1870
1930
  const responseSchemas = node.responses.map((res) => {
1871
1931
  const variants = (res.content ?? []).filter((entry) => entry.schema);
@@ -1903,13 +1963,13 @@ const zodGenerator = (0, kubb_kit.defineGenerator)({
1903
1963
  },
1904
1964
  name: resolver.response.body(node),
1905
1965
  keysToOmit: entry.keysToOmit,
1906
- direction: "input"
1966
+ direction: "encode"
1907
1967
  });
1908
1968
  }
1909
1969
  return buildContentTypeVariants(requestBodyContent, resolver.response.body(node), (schema) => ({
1910
1970
  ...schema,
1911
1971
  description: node.requestBody.description ?? schema.description
1912
- }), "input");
1972
+ }), "encode");
1913
1973
  })();
1914
1974
  const { path, query, header } = getOperationParameters(node);
1915
1975
  const paramGroupSchemas = inferred ? [
@@ -1928,12 +1988,12 @@ const zodGenerator = (0, kubb_kit.defineGenerator)({
1928
1988
  ].filter(({ params }) => params.length > 0).map(({ kind, params }) => renderSchemaEntry({
1929
1989
  schema: buildGroupedParamsSchema({ params }),
1930
1990
  name: resolver.param[kind](node, params[0]),
1931
- direction: "input"
1991
+ direction: "encode"
1932
1992
  })) : [];
1933
1993
  const optionsSchema = inferred ? renderSchemaEntry({
1934
1994
  schema: buildOptionsSchema(node, resolver),
1935
1995
  name: resolver.name(`${node.operationId} Options`),
1936
- direction: "input"
1996
+ direction: "encode"
1937
1997
  }) : null;
1938
1998
  const responsesSchema = inferred ? renderSchemaEntry({
1939
1999
  schema: buildResponses(node, resolver),