@kubb/plugin-zod 5.7.0 → 5.7.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 +9 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -3
- package/dist/index.d.ts +5 -3
- package/dist/index.js +9 -12
- package/dist/index.js.map +1 -1
- package/docs/options.md +9 -9
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -813,9 +813,6 @@ function shouldCoerce(coercion, type) {
|
|
|
813
813
|
if (coercion === true) return true;
|
|
814
814
|
return !!coercion[type];
|
|
815
815
|
}
|
|
816
|
-
function propertyNamesOf(node) {
|
|
817
|
-
return "propertyNames" in node ? node.propertyNames : void 0;
|
|
818
|
-
}
|
|
819
816
|
/**
|
|
820
817
|
* Whether the schema node represents a closed or finite set of keys (e.g. enum, literal,
|
|
821
818
|
* or union of enums/literals).
|
|
@@ -844,7 +841,7 @@ function isPlainInlineObject(node) {
|
|
|
844
841
|
if (node.nullable || node.optional || node.nullish) return false;
|
|
845
842
|
const hasAdditionalProperties = node.additionalProperties !== void 0;
|
|
846
843
|
const hasPatternProperties = Boolean(node.patternProperties);
|
|
847
|
-
return !hasAdditionalProperties && !hasPatternProperties && !
|
|
844
|
+
return !hasAdditionalProperties && !hasPatternProperties && !node.propertyNames;
|
|
848
845
|
}
|
|
849
846
|
/**
|
|
850
847
|
* Whether a node renders as a bare Zod object — one that accepts `.extend(…)` and can be a
|
|
@@ -859,7 +856,7 @@ function isObjectSchemaNode(node, cyclicSchemas) {
|
|
|
859
856
|
const hasProperties = Boolean(node.properties?.length);
|
|
860
857
|
const hasTypedAdditionalProperties = Boolean(node.additionalProperties && node.additionalProperties !== true);
|
|
861
858
|
const hasPatternProperties = Boolean(node.patternProperties);
|
|
862
|
-
return !(!hasProperties && (hasTypedAdditionalProperties || hasPatternProperties ||
|
|
859
|
+
return !(!hasProperties && (hasTypedAdditionalProperties || hasPatternProperties || node.propertyNames));
|
|
863
860
|
}
|
|
864
861
|
if (node.type === "ref") {
|
|
865
862
|
const refName = kubb_kit.ast.resolveRefName(node);
|
|
@@ -1242,7 +1239,7 @@ function containsDirectionalNode({ node, printerOptions, seen = /* @__PURE__ */
|
|
|
1242
1239
|
if ("items" in node && node.items) children.push(...node.items);
|
|
1243
1240
|
if ("members" in node && node.members) children.push(...node.members);
|
|
1244
1241
|
if ("additionalProperties" in node && node.additionalProperties && node.additionalProperties !== true) children.push(node.additionalProperties);
|
|
1245
|
-
const propertyNames =
|
|
1242
|
+
const propertyNames = node.type === "object" ? node.propertyNames : void 0;
|
|
1246
1243
|
if (propertyNames) children.push(propertyNames);
|
|
1247
1244
|
return children.some((child) => containsDirectionalNode({
|
|
1248
1245
|
node: child,
|
|
@@ -1387,7 +1384,7 @@ const printerZod = kubb_kit.ast.createPrinter((options) => {
|
|
|
1387
1384
|
object(node) {
|
|
1388
1385
|
const entries = node.properties ?? [];
|
|
1389
1386
|
const patterns = node.patternProperties ? Object.entries(node.patternProperties) : [];
|
|
1390
|
-
const propertyNamesNode =
|
|
1387
|
+
const propertyNamesNode = node.propertyNames;
|
|
1391
1388
|
const propertyNamesKeySchema = propertyNamesNode ? this.transform(propertyNamesNode) : null;
|
|
1392
1389
|
const isStrict = node.additionalProperties === false && patterns.length === 0;
|
|
1393
1390
|
const isLoose = node.additionalProperties === true;
|
|
@@ -1597,7 +1594,7 @@ const printerZodMini = kubb_kit.ast.createPrinter((options) => {
|
|
|
1597
1594
|
object(node) {
|
|
1598
1595
|
const entries = node.properties ?? [];
|
|
1599
1596
|
const patterns = node.patternProperties ? Object.entries(node.patternProperties) : [];
|
|
1600
|
-
const propertyNamesNode =
|
|
1597
|
+
const propertyNamesNode = node.propertyNames;
|
|
1601
1598
|
const propertyNamesKeySchema = propertyNamesNode ? this.transform(propertyNamesNode) : null;
|
|
1602
1599
|
const isStrict = node.additionalProperties === false && patterns.length === 0;
|
|
1603
1600
|
const isLoose = node.additionalProperties === true;
|
|
@@ -1685,11 +1682,11 @@ const printerZodMini = kubb_kit.ast.createPrinter((options) => {
|
|
|
1685
1682
|
//#endregion
|
|
1686
1683
|
//#region src/generators/zodGenerator.tsx
|
|
1687
1684
|
/**
|
|
1688
|
-
* The helper an inferred alias is printed with. `'
|
|
1685
|
+
* The helper an inferred alias is printed with. `'codec'` reads a request (encode) schema from its
|
|
1689
1686
|
* input and a response (decode) schema from its output; `true` keeps `z.infer` for both.
|
|
1690
1687
|
*/
|
|
1691
1688
|
function aliasKind(inferred, direction) {
|
|
1692
|
-
if (inferred !== "
|
|
1689
|
+
if (inferred !== "codec") return "infer";
|
|
1693
1690
|
return direction === "encode" ? "input" : "output";
|
|
1694
1691
|
}
|
|
1695
1692
|
const zodPrinterCache = /* @__PURE__ */ new WeakMap();
|
|
@@ -2152,7 +2149,7 @@ var compatibility = {
|
|
|
2152
2149
|
};
|
|
2153
2150
|
//#endregion
|
|
2154
2151
|
//#region package.json
|
|
2155
|
-
var version = "5.7.
|
|
2152
|
+
var version = "5.7.2";
|
|
2156
2153
|
//#endregion
|
|
2157
2154
|
//#region src/resolvers/resolverZod.ts
|
|
2158
2155
|
/**
|
|
@@ -2263,7 +2260,7 @@ const pluginZod = (0, kubb_kit.defineExtension)({
|
|
|
2263
2260
|
group: createGroupConfig(group),
|
|
2264
2261
|
importPath,
|
|
2265
2262
|
coercion,
|
|
2266
|
-
inferred,
|
|
2263
|
+
inferred: inferred === "direction" ? "codec" : inferred,
|
|
2267
2264
|
guidType,
|
|
2268
2265
|
regexType,
|
|
2269
2266
|
oneOfType,
|