@kubb/plugin-zod 3.16.2 → 3.16.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-CJ6RN1R2.js +414 -0
- package/dist/components-CJ6RN1R2.js.map +1 -0
- package/dist/components-GvkeO2ig.cjs +454 -0
- package/dist/components-GvkeO2ig.cjs.map +1 -0
- package/dist/components.cjs +3 -15
- package/dist/components.d.cts +56 -26
- package/dist/components.d.ts +56 -26
- package/dist/components.js +3 -3
- package/dist/generators-C3ALr3ph.js +254 -0
- package/dist/generators-C3ALr3ph.js.map +1 -0
- package/dist/generators-D3uH7-vO.cjs +265 -0
- package/dist/generators-D3uH7-vO.cjs.map +1 -0
- package/dist/generators.cjs +4 -16
- package/dist/generators.d.cts +8 -8
- package/dist/generators.d.ts +8 -8
- package/dist/generators.js +4 -4
- package/dist/index.cjs +103 -137
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -7
- package/dist/index.d.ts +6 -7
- package/dist/index.js +103 -131
- package/dist/index.js.map +1 -1
- package/dist/types-B0UqdcbG.d.cts +1237 -0
- package/dist/types-YpNWeJUW.d.ts +1237 -0
- package/dist/utils/v4.cjs +0 -0
- package/dist/utils/v4.d.cts +38 -0
- package/dist/utils/v4.d.ts +38 -0
- package/dist/utils/v4.js +1 -0
- package/dist/utils.cjs +0 -4
- package/dist/utils.d.cts +18 -24
- package/dist/utils.d.ts +18 -24
- package/dist/utils.js +1 -3
- package/package.json +32 -31
- package/src/generators/zodGenerator.tsx +2 -2
- package/src/plugin.ts +2 -3
- package/src/utils/v4/ToZod.ts +61 -0
- package/src/utils/v4/index.ts +1 -0
- package/dist/chunk-4QMHDKCS.js +0 -453
- package/dist/chunk-4QMHDKCS.js.map +0 -1
- package/dist/chunk-6LDDO2JJ.cjs +0 -184
- package/dist/chunk-6LDDO2JJ.cjs.map +0 -1
- package/dist/chunk-FYI4GRXP.cjs +0 -460
- package/dist/chunk-FYI4GRXP.cjs.map +0 -1
- package/dist/chunk-I74P26CO.js +0 -181
- package/dist/chunk-I74P26CO.js.map +0 -1
- package/dist/components.cjs.map +0 -1
- package/dist/components.js.map +0 -1
- package/dist/generators.cjs.map +0 -1
- package/dist/generators.js.map +0 -1
- package/dist/types-BOF1ntMm.d.cts +0 -130
- package/dist/types-BOF1ntMm.d.ts +0 -130
- package/dist/utils.cjs.map +0 -1
- package/dist/utils.js.map +0 -1
|
@@ -0,0 +1,454 @@
|
|
|
1
|
+
//#region rolldown:runtime
|
|
2
|
+
var __create = Object.create;
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
+
var __copyProps = (to, from, except, desc) => {
|
|
9
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
10
|
+
key = keys[i];
|
|
11
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
12
|
+
get: ((k) => from[k]).bind(null, key),
|
|
13
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", {
|
|
19
|
+
value: mod,
|
|
20
|
+
enumerable: true
|
|
21
|
+
}) : target, mod));
|
|
22
|
+
|
|
23
|
+
//#endregion
|
|
24
|
+
const __kubb_core_transformers = __toESM(require("@kubb/core/transformers"));
|
|
25
|
+
const __kubb_plugin_oas = __toESM(require("@kubb/plugin-oas"));
|
|
26
|
+
const __kubb_react = __toESM(require("@kubb/react"));
|
|
27
|
+
const __kubb_react_jsx_runtime = __toESM(require("@kubb/react/jsx-runtime"));
|
|
28
|
+
|
|
29
|
+
//#region src/components/Operations.tsx
|
|
30
|
+
function Operations({ name, operations }) {
|
|
31
|
+
const operationsJSON = operations.reduce((prev, acc) => {
|
|
32
|
+
prev[`"${acc.operation.getOperationId()}"`] = acc.data;
|
|
33
|
+
return prev;
|
|
34
|
+
}, {});
|
|
35
|
+
const pathsJSON = operations.reduce((prev, acc) => {
|
|
36
|
+
prev[`"${acc.operation.path}"`] = {
|
|
37
|
+
...prev[`"${acc.operation.path}"`] || {},
|
|
38
|
+
[acc.operation.method]: `operations["${acc.operation.getOperationId()}"]`
|
|
39
|
+
};
|
|
40
|
+
return prev;
|
|
41
|
+
}, {});
|
|
42
|
+
return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsxs)(__kubb_react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Source, {
|
|
43
|
+
name,
|
|
44
|
+
isExportable: true,
|
|
45
|
+
isIndexable: true,
|
|
46
|
+
children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Const, {
|
|
47
|
+
export: true,
|
|
48
|
+
name,
|
|
49
|
+
asConst: true,
|
|
50
|
+
children: `{${__kubb_core_transformers.default.stringifyObject(operationsJSON)}}`
|
|
51
|
+
})
|
|
52
|
+
}), /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Source, {
|
|
53
|
+
name: "paths",
|
|
54
|
+
isExportable: true,
|
|
55
|
+
isIndexable: true,
|
|
56
|
+
children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Const, {
|
|
57
|
+
export: true,
|
|
58
|
+
name: "paths",
|
|
59
|
+
asConst: true,
|
|
60
|
+
children: `{${__kubb_core_transformers.default.stringifyObject(pathsJSON)}}`
|
|
61
|
+
})
|
|
62
|
+
})] });
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/parser.ts
|
|
67
|
+
const zodKeywordMapper = {
|
|
68
|
+
any: () => "z.any()",
|
|
69
|
+
unknown: () => "z.unknown()",
|
|
70
|
+
void: () => "z.void()",
|
|
71
|
+
number: (coercion, min, max) => {
|
|
72
|
+
return [
|
|
73
|
+
coercion ? "z.coerce.number()" : "z.number()",
|
|
74
|
+
min !== void 0 ? `.min(${min})` : void 0,
|
|
75
|
+
max !== void 0 ? `.max(${max})` : void 0
|
|
76
|
+
].filter(Boolean).join("");
|
|
77
|
+
},
|
|
78
|
+
integer: (coercion, min, max, version = "3") => {
|
|
79
|
+
return [
|
|
80
|
+
coercion ? "z.coerce.number().int()" : version === "4" ? "z.int()" : "z.number().int()",
|
|
81
|
+
min !== void 0 ? `.min(${min})` : void 0,
|
|
82
|
+
max !== void 0 ? `.max(${max})` : void 0
|
|
83
|
+
].filter(Boolean).join("");
|
|
84
|
+
},
|
|
85
|
+
interface: (value, strict) => {
|
|
86
|
+
if (strict) return `z.strictInterface({
|
|
87
|
+
${value}
|
|
88
|
+
})`;
|
|
89
|
+
return `z.interface({
|
|
90
|
+
${value}
|
|
91
|
+
})`;
|
|
92
|
+
},
|
|
93
|
+
object: (value, strict, version = "3") => {
|
|
94
|
+
if (version === "4" && strict) return `z.strictObject({
|
|
95
|
+
${value}
|
|
96
|
+
})`;
|
|
97
|
+
if (strict) return `z.object({
|
|
98
|
+
${value}
|
|
99
|
+
}).strict()`;
|
|
100
|
+
return `z.object({
|
|
101
|
+
${value}
|
|
102
|
+
})`;
|
|
103
|
+
},
|
|
104
|
+
string: (coercion, min, max) => {
|
|
105
|
+
return [
|
|
106
|
+
coercion ? "z.coerce.string()" : "z.string()",
|
|
107
|
+
min !== void 0 ? `.min(${min})` : void 0,
|
|
108
|
+
max !== void 0 ? `.max(${max})` : void 0
|
|
109
|
+
].filter(Boolean).join("");
|
|
110
|
+
},
|
|
111
|
+
boolean: () => "z.boolean()",
|
|
112
|
+
undefined: () => "z.undefined()",
|
|
113
|
+
nullable: () => ".nullable()",
|
|
114
|
+
null: () => "z.null()",
|
|
115
|
+
nullish: () => ".nullish()",
|
|
116
|
+
array: (items = [], min, max, unique) => {
|
|
117
|
+
return [
|
|
118
|
+
`z.array(${items?.join("")})`,
|
|
119
|
+
min !== void 0 ? `.min(${min})` : void 0,
|
|
120
|
+
max !== void 0 ? `.max(${max})` : void 0,
|
|
121
|
+
unique ? `.refine(items => new Set(items).size === items.length, { message: "Array entries must be unique" })` : void 0
|
|
122
|
+
].filter(Boolean).join("");
|
|
123
|
+
},
|
|
124
|
+
tuple: (items = []) => `z.tuple([${items?.join(", ")}])`,
|
|
125
|
+
enum: (items = []) => `z.enum([${items?.join(", ")}])`,
|
|
126
|
+
union: (items = []) => `z.union([${items?.join(", ")}])`,
|
|
127
|
+
const: (value) => `z.literal(${value ?? ""})`,
|
|
128
|
+
datetime: (offset = false, local = false, version = "3") => {
|
|
129
|
+
if (offset) return version === "4" ? `z.iso.datetime({ offset: ${offset} })` : `z.string().datetime({ offset: ${offset} })`;
|
|
130
|
+
if (local) return version === "4" ? `z.iso.datetime({ local: ${local} })` : `z.string().datetime({ local: ${local} })`;
|
|
131
|
+
return "z.string().datetime()";
|
|
132
|
+
},
|
|
133
|
+
date: (type = "string", coercion, version = "3") => {
|
|
134
|
+
if (type === "string") return version === "4" ? "z.iso.date()" : "z.string().date()";
|
|
135
|
+
if (coercion) return "z.coerce.date()";
|
|
136
|
+
return "z.date()";
|
|
137
|
+
},
|
|
138
|
+
time: (type = "string", coercion, version = "3") => {
|
|
139
|
+
if (type === "string") return version === "4" ? "z.iso.time()" : "z.string().time()";
|
|
140
|
+
if (coercion) return "z.coerce.date()";
|
|
141
|
+
return "z.date()";
|
|
142
|
+
},
|
|
143
|
+
uuid: (coercion, version = "3") => version === "4" ? coercion ? "z.coerce.string().uuid()" : "z.uuid()" : coercion ? "z.coerce.string().uuid()" : "z.string().uuid()",
|
|
144
|
+
url: (coercion, version = "3") => version === "4" ? coercion ? "z.coerce.string().url()" : "z.url()" : coercion ? "z.coerce.string().url()" : "z.string().url()",
|
|
145
|
+
default: (value) => {
|
|
146
|
+
if (typeof value === "object") return ".default({})";
|
|
147
|
+
return `.default(${value ?? ""})`;
|
|
148
|
+
},
|
|
149
|
+
and: (items = []) => items?.map((item) => `.and(${item})`).join(""),
|
|
150
|
+
describe: (value = "") => `.describe(${value})`,
|
|
151
|
+
min: (value) => `.min(${value ?? ""})`,
|
|
152
|
+
max: (value) => `.max(${value ?? ""})`,
|
|
153
|
+
optional: () => ".optional()",
|
|
154
|
+
matches: (value = "", coercion) => coercion ? `z.coerce.string().regex(${value})` : `z.string().regex(${value})`,
|
|
155
|
+
email: (coercion, version = "3") => version === "4" ? coercion ? "z.coerce.string().email()" : "z.email()" : coercion ? "z.coerce.string().email()" : "z.string().email()",
|
|
156
|
+
firstName: void 0,
|
|
157
|
+
lastName: void 0,
|
|
158
|
+
password: void 0,
|
|
159
|
+
phone: void 0,
|
|
160
|
+
readOnly: void 0,
|
|
161
|
+
writeOnly: void 0,
|
|
162
|
+
ref: (value, version = "3") => {
|
|
163
|
+
if (!value) return void 0;
|
|
164
|
+
return version === "4" ? value : `z.lazy(() => ${value})`;
|
|
165
|
+
},
|
|
166
|
+
blob: () => "z.instanceof(File)",
|
|
167
|
+
deprecated: void 0,
|
|
168
|
+
example: void 0,
|
|
169
|
+
schema: void 0,
|
|
170
|
+
catchall: (value) => value ? `.catchall(${value})` : void 0,
|
|
171
|
+
name: void 0
|
|
172
|
+
};
|
|
173
|
+
/**
|
|
174
|
+
* @link based on https://github.com/cellular/oazapfts/blob/7ba226ebb15374e8483cc53e7532f1663179a22c/src/codegen/generate.ts#L398
|
|
175
|
+
*/
|
|
176
|
+
function sort(items) {
|
|
177
|
+
const order = [
|
|
178
|
+
__kubb_plugin_oas.schemaKeywords.string,
|
|
179
|
+
__kubb_plugin_oas.schemaKeywords.datetime,
|
|
180
|
+
__kubb_plugin_oas.schemaKeywords.date,
|
|
181
|
+
__kubb_plugin_oas.schemaKeywords.time,
|
|
182
|
+
__kubb_plugin_oas.schemaKeywords.tuple,
|
|
183
|
+
__kubb_plugin_oas.schemaKeywords.number,
|
|
184
|
+
__kubb_plugin_oas.schemaKeywords.object,
|
|
185
|
+
__kubb_plugin_oas.schemaKeywords.enum,
|
|
186
|
+
__kubb_plugin_oas.schemaKeywords.url,
|
|
187
|
+
__kubb_plugin_oas.schemaKeywords.email,
|
|
188
|
+
__kubb_plugin_oas.schemaKeywords.firstName,
|
|
189
|
+
__kubb_plugin_oas.schemaKeywords.lastName,
|
|
190
|
+
__kubb_plugin_oas.schemaKeywords.password,
|
|
191
|
+
__kubb_plugin_oas.schemaKeywords.matches,
|
|
192
|
+
__kubb_plugin_oas.schemaKeywords.uuid,
|
|
193
|
+
__kubb_plugin_oas.schemaKeywords.null,
|
|
194
|
+
__kubb_plugin_oas.schemaKeywords.min,
|
|
195
|
+
__kubb_plugin_oas.schemaKeywords.max,
|
|
196
|
+
__kubb_plugin_oas.schemaKeywords.default,
|
|
197
|
+
__kubb_plugin_oas.schemaKeywords.describe,
|
|
198
|
+
__kubb_plugin_oas.schemaKeywords.optional,
|
|
199
|
+
__kubb_plugin_oas.schemaKeywords.nullable,
|
|
200
|
+
__kubb_plugin_oas.schemaKeywords.nullish
|
|
201
|
+
];
|
|
202
|
+
if (!items) return [];
|
|
203
|
+
return __kubb_core_transformers.default.orderBy(items, [(v) => order.indexOf(v.keyword)], ["asc"]);
|
|
204
|
+
}
|
|
205
|
+
const shouldCoerce = (coercion, type) => {
|
|
206
|
+
if (coercion === void 0) return false;
|
|
207
|
+
if (typeof coercion === "boolean") return coercion;
|
|
208
|
+
return !!coercion[type];
|
|
209
|
+
};
|
|
210
|
+
function parse({ parent, current, name, siblings }, options) {
|
|
211
|
+
const value = zodKeywordMapper[current.keyword];
|
|
212
|
+
const hasMatches = siblings.some((it) => (0, __kubb_plugin_oas.isKeyword)(it, __kubb_plugin_oas.schemaKeywords.matches));
|
|
213
|
+
const hasRef = siblings.some((it) => (0, __kubb_plugin_oas.isKeyword)(it, __kubb_plugin_oas.schemaKeywords.ref));
|
|
214
|
+
if (hasMatches && hasRef && (0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.matches)) return void 0;
|
|
215
|
+
if (!value) return void 0;
|
|
216
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.union)) {
|
|
217
|
+
if (Array.isArray(current.args) && current.args.length === 1) return parse({
|
|
218
|
+
parent,
|
|
219
|
+
name,
|
|
220
|
+
current: current.args[0],
|
|
221
|
+
siblings
|
|
222
|
+
}, options);
|
|
223
|
+
if (Array.isArray(current.args) && !current.args.length) return "";
|
|
224
|
+
return zodKeywordMapper.union(sort(current.args).map((schema, _index, siblings$1) => parse({
|
|
225
|
+
parent: current,
|
|
226
|
+
name,
|
|
227
|
+
current: schema,
|
|
228
|
+
siblings: siblings$1
|
|
229
|
+
}, options)).filter(Boolean));
|
|
230
|
+
}
|
|
231
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.and)) {
|
|
232
|
+
const items = sort(current.args).filter((schema) => {
|
|
233
|
+
return ![__kubb_plugin_oas.schemaKeywords.optional, __kubb_plugin_oas.schemaKeywords.describe].includes(schema.keyword);
|
|
234
|
+
}).map((schema, _index, siblings$1) => parse({
|
|
235
|
+
parent: current,
|
|
236
|
+
name,
|
|
237
|
+
current: schema,
|
|
238
|
+
siblings: siblings$1
|
|
239
|
+
}, options)).filter(Boolean);
|
|
240
|
+
return `${items.slice(0, 1)}${zodKeywordMapper.and(items.slice(1))}`;
|
|
241
|
+
}
|
|
242
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.array)) return zodKeywordMapper.array(sort(current.args.items).map((schemas, _index, siblings$1) => parse({
|
|
243
|
+
parent: current,
|
|
244
|
+
name,
|
|
245
|
+
current: schemas,
|
|
246
|
+
siblings: siblings$1
|
|
247
|
+
}, options)).filter(Boolean), current.args.min, current.args.max, current.args.unique);
|
|
248
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.enum)) {
|
|
249
|
+
if (current.args.asConst) {
|
|
250
|
+
if (current.args.items.length === 1) {
|
|
251
|
+
const child = {
|
|
252
|
+
keyword: __kubb_plugin_oas.schemaKeywords.const,
|
|
253
|
+
args: current.args.items[0]
|
|
254
|
+
};
|
|
255
|
+
return parse({
|
|
256
|
+
parent: current,
|
|
257
|
+
name,
|
|
258
|
+
current: child,
|
|
259
|
+
siblings: [child]
|
|
260
|
+
}, options);
|
|
261
|
+
}
|
|
262
|
+
return zodKeywordMapper.union(current.args.items.map((schema) => ({
|
|
263
|
+
keyword: __kubb_plugin_oas.schemaKeywords.const,
|
|
264
|
+
args: schema
|
|
265
|
+
})).map((schema, _index, siblings$1) => {
|
|
266
|
+
return parse({
|
|
267
|
+
parent: current,
|
|
268
|
+
name,
|
|
269
|
+
current: schema,
|
|
270
|
+
siblings: siblings$1
|
|
271
|
+
}, options);
|
|
272
|
+
}).filter(Boolean));
|
|
273
|
+
}
|
|
274
|
+
return zodKeywordMapper.enum(current.args.items.map((schema) => {
|
|
275
|
+
if (schema.format === "boolean") return __kubb_core_transformers.default.stringify(schema.value);
|
|
276
|
+
if (schema.format === "number") return __kubb_core_transformers.default.stringify(schema.value);
|
|
277
|
+
return __kubb_core_transformers.default.stringify(schema.value);
|
|
278
|
+
}));
|
|
279
|
+
}
|
|
280
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.ref)) return zodKeywordMapper.ref(current.args?.name, options.version);
|
|
281
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.object)) {
|
|
282
|
+
const propertyEntries = Object.entries(current.args?.properties || {}).filter((item) => {
|
|
283
|
+
const schema = item[1];
|
|
284
|
+
return schema && typeof schema.map === "function";
|
|
285
|
+
});
|
|
286
|
+
const properties = propertyEntries.map(([name$1, schemas]) => {
|
|
287
|
+
const nameSchema = schemas.find((schema) => schema.keyword === __kubb_plugin_oas.schemaKeywords.name);
|
|
288
|
+
const mappedName = nameSchema?.args || name$1;
|
|
289
|
+
if (options.mapper?.[mappedName]) return `"${name$1}": ${options.mapper?.[mappedName]}`;
|
|
290
|
+
const baseSchemaOutput = sort(schemas).map((schema) => parse({
|
|
291
|
+
parent: current,
|
|
292
|
+
name: name$1,
|
|
293
|
+
current: schema,
|
|
294
|
+
siblings: schemas
|
|
295
|
+
}, options)).filter(Boolean).join("");
|
|
296
|
+
const objectValue = options.wrapOutput ? options.wrapOutput({
|
|
297
|
+
output: baseSchemaOutput,
|
|
298
|
+
schema: options.rawSchema?.properties?.[name$1]
|
|
299
|
+
}) || baseSchemaOutput : baseSchemaOutput;
|
|
300
|
+
if (options.version === "4" && __kubb_plugin_oas.SchemaGenerator.find(schemas, __kubb_plugin_oas.schemaKeywords.ref)) return `get ${name$1}(){
|
|
301
|
+
return ${objectValue}
|
|
302
|
+
}`;
|
|
303
|
+
return `"${name$1}": ${objectValue}`;
|
|
304
|
+
}).join(",\n");
|
|
305
|
+
const additionalProperties = current.args?.additionalProperties?.length ? current.args.additionalProperties.map((schema, _index, siblings$1) => parse({
|
|
306
|
+
parent: current,
|
|
307
|
+
name,
|
|
308
|
+
current: schema,
|
|
309
|
+
siblings: siblings$1
|
|
310
|
+
}, options)).filter(Boolean).join("") : void 0;
|
|
311
|
+
const text = [zodKeywordMapper.object(properties, current.args?.strict, options.version), additionalProperties ? zodKeywordMapper.catchall(additionalProperties) : void 0].filter(Boolean);
|
|
312
|
+
return text.join("");
|
|
313
|
+
}
|
|
314
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.tuple)) return zodKeywordMapper.tuple(current.args.items.map((schema, _index, siblings$1) => parse({
|
|
315
|
+
parent: current,
|
|
316
|
+
name,
|
|
317
|
+
current: schema,
|
|
318
|
+
siblings: siblings$1
|
|
319
|
+
}, options)).filter(Boolean));
|
|
320
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.const)) {
|
|
321
|
+
if (current.args.format === "number" && current.args.value !== void 0) return zodKeywordMapper.const(Number(current.args.value));
|
|
322
|
+
if (current.args.format === "boolean" && current.args.value !== void 0) return zodKeywordMapper.const(current.args.value);
|
|
323
|
+
return zodKeywordMapper.const(__kubb_core_transformers.default.stringify(current.args.value));
|
|
324
|
+
}
|
|
325
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.matches)) {
|
|
326
|
+
if (current.args) return zodKeywordMapper.matches(__kubb_core_transformers.default.toRegExpString(current.args, null), shouldCoerce(options.coercion, "strings"));
|
|
327
|
+
}
|
|
328
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.default)) {
|
|
329
|
+
if (current.args) return zodKeywordMapper.default(current.args);
|
|
330
|
+
}
|
|
331
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.describe)) {
|
|
332
|
+
if (current.args) return zodKeywordMapper.describe(__kubb_core_transformers.default.stringify(current.args.toString()));
|
|
333
|
+
}
|
|
334
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.string)) return zodKeywordMapper.string(shouldCoerce(options.coercion, "strings"));
|
|
335
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.uuid)) return zodKeywordMapper.uuid(shouldCoerce(options.coercion, "strings"), options.version);
|
|
336
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.email)) return zodKeywordMapper.email(shouldCoerce(options.coercion, "strings"), options.version);
|
|
337
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.url)) return zodKeywordMapper.url(shouldCoerce(options.coercion, "strings"), options.version);
|
|
338
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.number)) return zodKeywordMapper.number(shouldCoerce(options.coercion, "numbers"));
|
|
339
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.integer)) return zodKeywordMapper.integer(shouldCoerce(options.coercion, "numbers"), void 0, void 0, options.version);
|
|
340
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.min)) return zodKeywordMapper.min(current.args);
|
|
341
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.max)) return zodKeywordMapper.max(current.args);
|
|
342
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.datetime)) return zodKeywordMapper.datetime(current.args.offset, current.args.local, options.version);
|
|
343
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.date)) return zodKeywordMapper.date(current.args.type, shouldCoerce(options.coercion, "dates"), options.version);
|
|
344
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.time)) return zodKeywordMapper.time(current.args.type, shouldCoerce(options.coercion, "dates"), options.version);
|
|
345
|
+
if (current.keyword in zodKeywordMapper && "args" in current) {
|
|
346
|
+
const value$1 = zodKeywordMapper[current.keyword];
|
|
347
|
+
return value$1(current.args);
|
|
348
|
+
}
|
|
349
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.optional)) {
|
|
350
|
+
if (siblings.some((schema) => (0, __kubb_plugin_oas.isKeyword)(schema, __kubb_plugin_oas.schemaKeywords.default))) return "";
|
|
351
|
+
return value();
|
|
352
|
+
}
|
|
353
|
+
if (current.keyword in zodKeywordMapper) return value();
|
|
354
|
+
return void 0;
|
|
355
|
+
}
|
|
356
|
+
|
|
357
|
+
//#endregion
|
|
358
|
+
//#region src/components/Zod.tsx
|
|
359
|
+
function Zod({ name, typeName, tree, rawSchema, inferTypeName, mapper, coercion, keysToOmit, description, wrapOutput, version, emptySchemaType }) {
|
|
360
|
+
const hasTuple = !!__kubb_plugin_oas.SchemaGenerator.deepSearch(tree, __kubb_plugin_oas.schemaKeywords.tuple);
|
|
361
|
+
const schemas = sort(tree).filter((item) => {
|
|
362
|
+
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;
|
|
363
|
+
return true;
|
|
364
|
+
});
|
|
365
|
+
const output = schemas.map((schema, _index, siblings) => parse({
|
|
366
|
+
parent: void 0,
|
|
367
|
+
current: schema,
|
|
368
|
+
siblings
|
|
369
|
+
}, {
|
|
370
|
+
name,
|
|
371
|
+
keysToOmit,
|
|
372
|
+
typeName,
|
|
373
|
+
description,
|
|
374
|
+
mapper,
|
|
375
|
+
coercion,
|
|
376
|
+
wrapOutput,
|
|
377
|
+
rawSchema,
|
|
378
|
+
version
|
|
379
|
+
})).filter(Boolean).join("");
|
|
380
|
+
let suffix = "";
|
|
381
|
+
const firstSchema = schemas.at(0);
|
|
382
|
+
const lastSchema = schemas.at(-1);
|
|
383
|
+
if (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()";
|
|
384
|
+
else suffix = ".unwrap().unwrap()";
|
|
385
|
+
else suffix = ".unwrap()";
|
|
386
|
+
else if (firstSchema && (0, __kubb_plugin_oas.isKeyword)(firstSchema, __kubb_plugin_oas.schemaKeywords.ref) && version === "3") suffix = ".schema";
|
|
387
|
+
const emptyValue = parse({
|
|
388
|
+
parent: void 0,
|
|
389
|
+
current: { keyword: __kubb_plugin_oas.schemaKeywords[emptySchemaType] },
|
|
390
|
+
siblings: []
|
|
391
|
+
}, {
|
|
392
|
+
name,
|
|
393
|
+
keysToOmit,
|
|
394
|
+
typeName,
|
|
395
|
+
description,
|
|
396
|
+
mapper,
|
|
397
|
+
coercion,
|
|
398
|
+
wrapOutput,
|
|
399
|
+
rawSchema,
|
|
400
|
+
version
|
|
401
|
+
});
|
|
402
|
+
const baseSchemaOutput = [output, keysToOmit?.length ? `${suffix}.omit({ ${keysToOmit.map((key) => `${key}: true`).join(",")} })` : void 0].filter(Boolean).join("") || emptyValue || "";
|
|
403
|
+
const wrappedSchemaOutput = wrapOutput ? wrapOutput({
|
|
404
|
+
output: baseSchemaOutput,
|
|
405
|
+
schema: rawSchema
|
|
406
|
+
}) || baseSchemaOutput : baseSchemaOutput;
|
|
407
|
+
const finalOutput = typeName ? `${wrappedSchemaOutput} as unknown as ToZod<${typeName}>` : wrappedSchemaOutput;
|
|
408
|
+
return /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsxs)(__kubb_react_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Source, {
|
|
409
|
+
name,
|
|
410
|
+
isExportable: true,
|
|
411
|
+
isIndexable: true,
|
|
412
|
+
children: /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Const, {
|
|
413
|
+
export: true,
|
|
414
|
+
name,
|
|
415
|
+
JSDoc: { comments: [description ? `@description ${__kubb_core_transformers.default.jsStringEscape(description)}` : void 0].filter(Boolean) },
|
|
416
|
+
children: finalOutput
|
|
417
|
+
})
|
|
418
|
+
}), inferTypeName && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsxs)(__kubb_react.File.Source, {
|
|
419
|
+
name: inferTypeName,
|
|
420
|
+
isExportable: true,
|
|
421
|
+
isIndexable: true,
|
|
422
|
+
isTypeOnly: true,
|
|
423
|
+
children: [typeName && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Type, {
|
|
424
|
+
export: true,
|
|
425
|
+
name: inferTypeName,
|
|
426
|
+
children: typeName
|
|
427
|
+
}), !typeName && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.Type, {
|
|
428
|
+
export: true,
|
|
429
|
+
name: inferTypeName,
|
|
430
|
+
children: `z.infer<typeof ${name}>`
|
|
431
|
+
})]
|
|
432
|
+
})] });
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
//#endregion
|
|
436
|
+
Object.defineProperty(exports, 'Operations', {
|
|
437
|
+
enumerable: true,
|
|
438
|
+
get: function () {
|
|
439
|
+
return Operations;
|
|
440
|
+
}
|
|
441
|
+
});
|
|
442
|
+
Object.defineProperty(exports, 'Zod', {
|
|
443
|
+
enumerable: true,
|
|
444
|
+
get: function () {
|
|
445
|
+
return Zod;
|
|
446
|
+
}
|
|
447
|
+
});
|
|
448
|
+
Object.defineProperty(exports, '__toESM', {
|
|
449
|
+
enumerable: true,
|
|
450
|
+
get: function () {
|
|
451
|
+
return __toESM;
|
|
452
|
+
}
|
|
453
|
+
});
|
|
454
|
+
//# sourceMappingURL=components-GvkeO2ig.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-GvkeO2ig.cjs","names":["File","Const","transformers","coercion?: boolean","min?: number","max?: number","version: '3' | '4'","value?: string","strict?: boolean","items: string[]","unique?: boolean","value?: string | number | boolean","type: 'date' | 'string'","value?: string | number | true | object","value?: number","items?: Schema[]","order: string[]","schemaKeywords","transformers","coercion: ParserOptions['coercion'] | undefined","type: 'dates' | 'strings' | 'numbers'","options: ParserOptions","siblings","schema: Schema","name","SchemaGenerator","value","SchemaGenerator","schemaKeywords","File","Const","transformers","Type"],"sources":["../src/components/Operations.tsx","../src/parser.ts","../src/components/Zod.tsx"],"sourcesContent":["import type { SchemaNames } from '@kubb/plugin-oas/hooks'\nimport { Const, File } from '@kubb/react'\n\nimport transformers from '@kubb/core/transformers'\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype Props = {\n name: string\n operations: Array<{ operation: Operation; data: SchemaNames }>\n}\n\nexport function Operations({ name, operations }: Props) {\n const operationsJSON = operations.reduce(\n (prev, acc) => {\n prev[`\"${acc.operation.getOperationId()}\"`] = acc.data\n\n return prev\n },\n {} as Record<string, unknown>,\n )\n\n const pathsJSON = operations.reduce(\n (prev, acc) => {\n prev[`\"${acc.operation.path}\"`] = {\n ...(prev[`\"${acc.operation.path}\"`] || ({} as Record<HttpMethod, string>)),\n [acc.operation.method]: `operations[\"${acc.operation.getOperationId()}\"]`,\n }\n\n return prev\n },\n {} as Record<string, Record<HttpMethod, string>>,\n )\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Const export name={name} asConst>\n {`{${transformers.stringifyObject(operationsJSON)}}`}\n </Const>\n </File.Source>\n <File.Source name={'paths'} isExportable isIndexable>\n <Const export name={'paths'} asConst>\n {`{${transformers.stringifyObject(pathsJSON)}}`}\n </Const>\n </File.Source>\n </>\n )\n}\n","import transformers from '@kubb/core/transformers'\nimport type { SchemaObject } from '@kubb/oas'\n\nimport type { Schema, SchemaKeywordBase, SchemaMapper } from '@kubb/plugin-oas'\nimport { isKeyword, SchemaGenerator, type SchemaKeywordMapper, type SchemaTree, schemaKeywords } from '@kubb/plugin-oas'\n\nconst zodKeywordMapper = {\n any: () => 'z.any()',\n unknown: () => 'z.unknown()',\n void: () => 'z.void()',\n number: (coercion?: boolean, min?: number, max?: number) => {\n return [coercion ? 'z.coerce.number()' : 'z.number()', min !== undefined ? `.min(${min})` : undefined, max !== undefined ? `.max(${max})` : undefined]\n .filter(Boolean)\n .join('')\n },\n integer: (coercion?: boolean, min?: number, max?: number, version: '3' | '4' = '3') => {\n return [\n coercion ? 'z.coerce.number().int()' : version === '4' ? 'z.int()' : 'z.number().int()',\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n interface: (value?: string, strict?: boolean) => {\n if (strict) {\n return `z.strictInterface({\n ${value}\n })`\n }\n return `z.interface({\n ${value}\n })`\n },\n object: (value?: string, strict?: boolean, version: '3' | '4' = '3') => {\n if (version === '4' && strict) {\n return `z.strictObject({\n ${value}\n })`\n }\n\n if (strict) {\n return `z.object({\n ${value}\n }).strict()`\n }\n\n return `z.object({\n ${value}\n })`\n },\n string: (coercion?: boolean, min?: number, max?: number) => {\n return [coercion ? 'z.coerce.string()' : 'z.string()', min !== undefined ? `.min(${min})` : undefined, max !== undefined ? `.max(${max})` : undefined]\n .filter(Boolean)\n .join('')\n },\n //support for discriminatedUnion\n boolean: () => 'z.boolean()',\n undefined: () => 'z.undefined()',\n nullable: () => '.nullable()',\n null: () => 'z.null()',\n nullish: () => '.nullish()',\n array: (items: string[] = [], min?: number, max?: number, unique?: boolean) => {\n return [\n `z.array(${items?.join('')})`,\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n unique ? `.refine(items => new Set(items).size === items.length, { message: \"Array entries must be unique\" })` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n tuple: (items: string[] = []) => `z.tuple([${items?.join(', ')}])`,\n enum: (items: string[] = []) => `z.enum([${items?.join(', ')}])`,\n union: (items: string[] = []) => `z.union([${items?.join(', ')}])`,\n const: (value?: string | number | boolean) => `z.literal(${value ?? ''})`,\n /**\n * ISO 8601\n */\n datetime: (offset = false, local = false, version: '3' | '4' = '3') => {\n if (offset) {\n return version === '4' ? `z.iso.datetime({ offset: ${offset} })` : `z.string().datetime({ offset: ${offset} })`\n }\n\n if (local) {\n return version === '4' ? `z.iso.datetime({ local: ${local} })` : `z.string().datetime({ local: ${local} })`\n }\n\n return 'z.string().datetime()'\n },\n /**\n * Type `'date'` Date\n * Type `'string'` ISO date format (YYYY-MM-DD)\n * @default ISO date format (YYYY-MM-DD)\n */\n date: (type: 'date' | 'string' = 'string', coercion?: boolean, version: '3' | '4' = '3') => {\n if (type === 'string') {\n return version === '4' ? 'z.iso.date()' : 'z.string().date()'\n }\n\n if (coercion) {\n return 'z.coerce.date()'\n }\n\n return 'z.date()'\n },\n /**\n * Type `'date'` Date\n * Type `'string'` ISO time format (HH:mm:ss[.SSSSSS])\n * @default ISO time format (HH:mm:ss[.SSSSSS])\n */\n time: (type: 'date' | 'string' = 'string', coercion?: boolean, version: '3' | '4' = '3') => {\n if (type === 'string') {\n return version === '4' ? 'z.iso.time()' : 'z.string().time()'\n }\n\n if (coercion) {\n return 'z.coerce.date()'\n }\n\n return 'z.date()'\n },\n uuid: (coercion?: boolean, version: '3' | '4' = '3') =>\n version === '4' ? (coercion ? 'z.coerce.string().uuid()' : 'z.uuid()') : coercion ? 'z.coerce.string().uuid()' : 'z.string().uuid()',\n url: (coercion?: boolean, version: '3' | '4' = '3') =>\n version === '4' ? (coercion ? 'z.coerce.string().url()' : 'z.url()') : coercion ? 'z.coerce.string().url()' : 'z.string().url()',\n default: (value?: string | number | true | object) => {\n if (typeof value === 'object') {\n return '.default({})'\n }\n return `.default(${value ?? ''})`\n },\n and: (items: string[] = []) => items?.map((item) => `.and(${item})`).join(''),\n describe: (value = '') => `.describe(${value})`,\n min: (value?: number) => `.min(${value ?? ''})`,\n max: (value?: number) => `.max(${value ?? ''})`,\n optional: () => '.optional()',\n matches: (value = '', coercion?: boolean) => (coercion ? `z.coerce.string().regex(${value})` : `z.string().regex(${value})`),\n email: (coercion?: boolean, version: '3' | '4' = '3') =>\n version === '4' ? (coercion ? 'z.coerce.string().email()' : 'z.email()') : coercion ? 'z.coerce.string().email()' : 'z.string().email()',\n firstName: undefined,\n lastName: undefined,\n password: undefined,\n phone: undefined,\n readOnly: undefined,\n writeOnly: undefined,\n ref: (value?: string, version: '3' | '4' = '3') => {\n if (!value) {\n return undefined\n }\n\n return version === '4' ? value : `z.lazy(() => ${value})`\n },\n blob: () => 'z.instanceof(File)',\n deprecated: undefined,\n example: undefined,\n schema: undefined,\n catchall: (value?: string) => (value ? `.catchall(${value})` : undefined),\n name: undefined,\n} satisfies SchemaMapper<string | null | undefined>\n\n/**\n * @link based on https://github.com/cellular/oazapfts/blob/7ba226ebb15374e8483cc53e7532f1663179a22c/src/codegen/generate.ts#L398\n */\n\nexport function sort(items?: Schema[]): Schema[] {\n const order: string[] = [\n schemaKeywords.string,\n schemaKeywords.datetime,\n schemaKeywords.date,\n schemaKeywords.time,\n schemaKeywords.tuple,\n schemaKeywords.number,\n schemaKeywords.object,\n schemaKeywords.enum,\n schemaKeywords.url,\n schemaKeywords.email,\n schemaKeywords.firstName,\n schemaKeywords.lastName,\n schemaKeywords.password,\n schemaKeywords.matches,\n schemaKeywords.uuid,\n schemaKeywords.null,\n schemaKeywords.min,\n schemaKeywords.max,\n schemaKeywords.default,\n schemaKeywords.describe,\n schemaKeywords.optional,\n schemaKeywords.nullable,\n schemaKeywords.nullish,\n ]\n\n if (!items) {\n return []\n }\n\n return transformers.orderBy(items, [(v) => order.indexOf(v.keyword)], ['asc'])\n}\n\nconst shouldCoerce = (coercion: ParserOptions['coercion'] | undefined, type: 'dates' | 'strings' | 'numbers'): boolean => {\n if (coercion === undefined) {\n return false\n }\n if (typeof coercion === 'boolean') {\n return coercion\n }\n\n return !!coercion[type]\n}\n\ntype ParserOptions = {\n name: string\n typeName?: string\n description?: string\n keysToOmit?: string[]\n mapper?: Record<string, string>\n coercion?: boolean | { dates?: boolean; strings?: boolean; numbers?: boolean }\n wrapOutput?: (opts: { output: string; schema: any }) => string | undefined\n rawSchema: SchemaObject\n version: '3' | '4'\n}\n\nexport function parse({ parent, current, name, siblings }: SchemaTree, options: ParserOptions): string | undefined {\n const value = zodKeywordMapper[current.keyword as keyof typeof zodKeywordMapper]\n\n // Early exit: if siblings contain both matches and ref → skip matches entirely\n const hasMatches = siblings.some((it) => isKeyword(it, schemaKeywords.matches))\n const hasRef = siblings.some((it) => isKeyword(it, schemaKeywords.ref))\n\n if (hasMatches && hasRef && isKeyword(current, schemaKeywords.matches)) {\n return undefined // strip matches\n }\n\n if (!value) {\n return undefined\n }\n\n if (isKeyword(current, schemaKeywords.union)) {\n // zod union type needs at least 2 items\n if (Array.isArray(current.args) && current.args.length === 1) {\n return parse({ parent, name: name, current: current.args[0] as Schema, siblings }, options)\n }\n if (Array.isArray(current.args) && !current.args.length) {\n return ''\n }\n\n return zodKeywordMapper.union(\n sort(current.args)\n .map((schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options))\n .filter(Boolean),\n )\n }\n\n if (isKeyword(current, schemaKeywords.and)) {\n const items = sort(current.args)\n .filter((schema: Schema) => {\n return ![schemaKeywords.optional, schemaKeywords.describe].includes(schema.keyword as typeof schemaKeywords.describe)\n })\n .map((schema: Schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options))\n .filter(Boolean)\n\n return `${items.slice(0, 1)}${zodKeywordMapper.and(items.slice(1))}`\n }\n\n if (isKeyword(current, schemaKeywords.array)) {\n return zodKeywordMapper.array(\n sort(current.args.items)\n .map((schemas, _index, siblings) => parse({ parent: current, name: name, current: schemas, siblings }, options))\n .filter(Boolean),\n current.args.min,\n current.args.max,\n current.args.unique,\n )\n }\n\n if (isKeyword(current, schemaKeywords.enum)) {\n if (current.args.asConst) {\n if (current.args.items.length === 1) {\n const child = {\n keyword: schemaKeywords.const,\n args: current.args.items[0],\n }\n return parse({ parent: current, name: name, current: child, siblings: [child] }, options)\n }\n\n return zodKeywordMapper.union(\n current.args.items\n .map((schema) => ({\n keyword: schemaKeywords.const,\n args: schema,\n }))\n .map((schema, _index, siblings) => {\n return parse({ parent: current, name: name, current: schema, siblings }, options)\n })\n .filter(Boolean),\n )\n }\n\n return zodKeywordMapper.enum(\n current.args.items.map((schema) => {\n if (schema.format === 'boolean') {\n return transformers.stringify(schema.value)\n }\n\n if (schema.format === 'number') {\n return transformers.stringify(schema.value)\n }\n return transformers.stringify(schema.value)\n }),\n )\n }\n\n if (isKeyword(current, schemaKeywords.ref)) {\n return zodKeywordMapper.ref(current.args?.name, options.version)\n }\n\n if (isKeyword(current, schemaKeywords.object)) {\n const propertyEntries = Object.entries(current.args?.properties || {}).filter((item) => {\n const schema = item[1]\n return schema && typeof schema.map === 'function'\n })\n\n const properties = propertyEntries\n .map(([name, schemas]) => {\n const nameSchema = schemas.find((schema) => schema.keyword === schemaKeywords.name) as SchemaKeywordMapper['name']\n const mappedName = nameSchema?.args || name\n\n // custom mapper(pluginOptions)\n if (options.mapper?.[mappedName]) {\n return `\"${name}\": ${options.mapper?.[mappedName]}`\n }\n\n const baseSchemaOutput = sort(schemas)\n .map((schema) => parse({ parent: current, name, current: schema, siblings: schemas }, options))\n .filter(Boolean)\n .join('')\n\n const objectValue = options.wrapOutput\n ? options.wrapOutput({ output: baseSchemaOutput, schema: options.rawSchema?.properties?.[name] }) || baseSchemaOutput\n : baseSchemaOutput\n\n if (options.version === '4' && SchemaGenerator.find(schemas, schemaKeywords.ref)) {\n return `get ${name}(){\n return ${objectValue}\n }`\n }\n\n return `\"${name}\": ${objectValue}`\n })\n .join(',\\n')\n\n const additionalProperties = current.args?.additionalProperties?.length\n ? current.args.additionalProperties\n .map((schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options))\n .filter(Boolean)\n .join('')\n : undefined\n\n const text = [\n zodKeywordMapper.object(properties, current.args?.strict, options.version),\n additionalProperties ? zodKeywordMapper.catchall(additionalProperties) : undefined,\n ].filter(Boolean)\n\n return text.join('')\n }\n\n if (isKeyword(current, schemaKeywords.tuple)) {\n return zodKeywordMapper.tuple(\n current.args.items.map((schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options)).filter(Boolean),\n )\n }\n\n if (isKeyword(current, schemaKeywords.const)) {\n if (current.args.format === 'number' && current.args.value !== undefined) {\n return zodKeywordMapper.const(Number(current.args.value))\n }\n\n if (current.args.format === 'boolean' && current.args.value !== undefined) {\n return zodKeywordMapper.const(current.args.value)\n }\n return zodKeywordMapper.const(transformers.stringify(current.args.value))\n }\n\n if (isKeyword(current, schemaKeywords.matches)) {\n if (current.args) {\n return zodKeywordMapper.matches(transformers.toRegExpString(current.args, null), shouldCoerce(options.coercion, 'strings'))\n }\n }\n\n if (isKeyword(current, schemaKeywords.default)) {\n if (current.args) {\n return zodKeywordMapper.default(current.args)\n }\n }\n\n if (isKeyword(current, schemaKeywords.describe)) {\n if (current.args) {\n return zodKeywordMapper.describe(transformers.stringify(current.args.toString()))\n }\n }\n\n if (isKeyword(current, schemaKeywords.string)) {\n return zodKeywordMapper.string(shouldCoerce(options.coercion, 'strings'))\n }\n\n if (isKeyword(current, schemaKeywords.uuid)) {\n return zodKeywordMapper.uuid(shouldCoerce(options.coercion, 'strings'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.email)) {\n return zodKeywordMapper.email(shouldCoerce(options.coercion, 'strings'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.url)) {\n return zodKeywordMapper.url(shouldCoerce(options.coercion, 'strings'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.number)) {\n return zodKeywordMapper.number(shouldCoerce(options.coercion, 'numbers'))\n }\n\n if (isKeyword(current, schemaKeywords.integer)) {\n return zodKeywordMapper.integer(shouldCoerce(options.coercion, 'numbers'), undefined, undefined, options.version)\n }\n\n if (isKeyword(current, schemaKeywords.min)) {\n return zodKeywordMapper.min(current.args)\n }\n if (isKeyword(current, schemaKeywords.max)) {\n return zodKeywordMapper.max(current.args)\n }\n\n if (isKeyword(current, schemaKeywords.datetime)) {\n return zodKeywordMapper.datetime(current.args.offset, current.args.local, options.version)\n }\n\n if (isKeyword(current, schemaKeywords.date)) {\n return zodKeywordMapper.date(current.args.type, shouldCoerce(options.coercion, 'dates'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.time)) {\n return zodKeywordMapper.time(current.args.type, shouldCoerce(options.coercion, 'dates'), options.version)\n }\n\n if (current.keyword in zodKeywordMapper && 'args' in current) {\n const value = zodKeywordMapper[current.keyword as keyof typeof zodKeywordMapper] as (typeof zodKeywordMapper)['const']\n\n return value((current as SchemaKeywordBase<unknown>).args as any)\n }\n\n if (isKeyword(current, schemaKeywords.optional)) {\n if (siblings.some((schema) => isKeyword(schema, schemaKeywords.default))) return ''\n\n return value()\n }\n\n if (current.keyword in zodKeywordMapper) {\n return value()\n }\n\n return undefined\n}\n","import transformers from '@kubb/core/transformers'\nimport type { SchemaObject } from '@kubb/oas'\nimport { isKeyword, type Schema, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { Const, File, Type } from '@kubb/react'\nimport * as parserZod from '../parser.ts'\nimport type { PluginZod } from '../types.ts'\n\ntype Props = {\n name: string\n typeName?: string\n inferTypeName?: string\n tree: Array<Schema>\n rawSchema: SchemaObject\n description?: string\n coercion: PluginZod['resolvedOptions']['coercion']\n mapper: PluginZod['resolvedOptions']['mapper']\n keysToOmit?: string[]\n wrapOutput?: PluginZod['resolvedOptions']['wrapOutput']\n version: '3' | '4'\n emptySchemaType: PluginZod['resolvedOptions']['emptySchemaType']\n}\n\nexport function Zod({\n name,\n typeName,\n tree,\n rawSchema,\n inferTypeName,\n mapper,\n coercion,\n keysToOmit,\n description,\n wrapOutput,\n version,\n emptySchemaType,\n}: Props) {\n const hasTuple = !!SchemaGenerator.deepSearch(tree, schemaKeywords.tuple)\n\n const schemas = parserZod.sort(tree).filter((item) => {\n if (hasTuple && (isKeyword(item, schemaKeywords.min) || isKeyword(item, schemaKeywords.max))) {\n return false\n }\n\n return true\n })\n\n const output = schemas\n .map((schema, _index, siblings) =>\n parserZod.parse(\n { parent: undefined, current: schema, siblings },\n { name, keysToOmit, typeName, description, mapper, coercion, wrapOutput, rawSchema, version },\n ),\n )\n .filter(Boolean)\n .join('')\n\n let suffix = ''\n const firstSchema = schemas.at(0)\n const lastSchema = schemas.at(-1)\n\n if (lastSchema && isKeyword(lastSchema, schemaKeywords.nullable)) {\n if (firstSchema && isKeyword(firstSchema, schemaKeywords.ref)) {\n if (version === '3') {\n suffix = '.unwrap().schema.unwrap()'\n } else {\n suffix = '.unwrap().unwrap()'\n }\n } else {\n suffix = '.unwrap()'\n }\n } else {\n if (firstSchema && isKeyword(firstSchema, schemaKeywords.ref) && version === '3') {\n suffix = '.schema'\n }\n }\n\n const emptyValue = parserZod.parse(\n {\n parent: undefined,\n current: {\n keyword: schemaKeywords[emptySchemaType],\n },\n siblings: [],\n },\n { name, keysToOmit, typeName, description, mapper, coercion, wrapOutput, rawSchema, version },\n )\n\n const baseSchemaOutput =\n [output, keysToOmit?.length ? `${suffix}.omit({ ${keysToOmit.map((key) => `${key}: true`).join(',')} })` : undefined].filter(Boolean).join('') ||\n emptyValue ||\n ''\n const wrappedSchemaOutput = wrapOutput ? wrapOutput({ output: baseSchemaOutput, schema: rawSchema }) || baseSchemaOutput : baseSchemaOutput\n const finalOutput = typeName ? `${wrappedSchemaOutput} as unknown as ToZod<${typeName}>` : wrappedSchemaOutput\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Const\n export\n name={name}\n JSDoc={{\n comments: [description ? `@description ${transformers.jsStringEscape(description)}` : undefined].filter(Boolean),\n }}\n >\n {finalOutput}\n </Const>\n </File.Source>\n {inferTypeName && (\n <File.Source name={inferTypeName} isExportable isIndexable isTypeOnly>\n {typeName && (\n <Type export name={inferTypeName}>\n {typeName}\n </Type>\n )}\n {!typeName && (\n <Type export name={inferTypeName}>\n {`z.infer<typeof ${name}>`}\n </Type>\n )}\n </File.Source>\n )}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,SAAgB,WAAW,EAAE,MAAM,YAAmB,EAAE;CACtD,MAAM,iBAAiB,WAAW,OAChC,CAAC,MAAM,QAAQ;EACb,KAAK,CAAC,CAAC,EAAE,IAAI,UAAU,gBAAgB,CAAC,CAAC,CAAC,IAAI,IAAI;AAElD,SAAO;CACR,GACD,CAAE,EACH;CAED,MAAM,YAAY,WAAW,OAC3B,CAA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C,OAAO,QAAQ,CAAC,KAAK,GAAG,IAC9I,cACA;CACF,MAAM,sBAAsB,aAAa,WAAW;EAAE,QAAQ;EAAkB,QAAQ;CAAW,EAAC,IAAI,mBAAmB;CAC3H,MAAM,cAAc,WAAW,GAAG,oBAAoB,qBAAqB,EAAE,SAAS,CAAC,CAAC,GAAG;AAE3F,6JAEKC,kBAAK;EAAa;EAAM;EAAa;8DACnCC;GACC;GACM;GACN,OAAO,EACL,UAAU,CAAC,cAAc,CAAC,aAAa,EAAEC,iCAAa,eAAe,YAAY,EAAE,GAAG,MAAU,EAAC,OAAO,QAAQ,CACjH;aAEA;IACK;GACI,EACb,oEACEF,kBAAK;EAAO,MAAM;EAAe;EAAa;EAAY;aACxD,8DACEG;GAAK;GAAO,MAAM;aAChB;IACI,EAER,CAAC,8DACCA;GAAK;GAAO,MAAM;aAChB,CAAC,eAAe,EAAE,KAAK,CAAC,CAAC;IACrB;GAEG,IAEf;AAEN"}
|
package/dist/components.cjs
CHANGED
|
@@ -1,16 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const require_components = require('./components-GvkeO2ig.cjs');
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
Object.defineProperty(exports, "Operations", {
|
|
8
|
-
enumerable: true,
|
|
9
|
-
get: function () { return chunkFYI4GRXP_cjs.Operations; }
|
|
10
|
-
});
|
|
11
|
-
Object.defineProperty(exports, "Zod", {
|
|
12
|
-
enumerable: true,
|
|
13
|
-
get: function () { return chunkFYI4GRXP_cjs.Zod; }
|
|
14
|
-
});
|
|
15
|
-
//# sourceMappingURL=components.cjs.map
|
|
16
|
-
//# sourceMappingURL=components.cjs.map
|
|
3
|
+
exports.Operations = require_components.Operations;
|
|
4
|
+
exports.Zod = require_components.Zod;
|
package/dist/components.d.cts
CHANGED
|
@@ -1,32 +1,62 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Operation, SchemaObject } from '@kubb/oas';
|
|
3
|
-
import { Schema } from '@kubb/plugin-oas';
|
|
4
|
-
import { P as PluginZod } from './types-BOF1ntMm.cjs';
|
|
5
|
-
import '@kubb/core';
|
|
1
|
+
import { Operation, PluginZod, Schema, SchemaObject } from "./types-B0UqdcbG.cjs";
|
|
6
2
|
|
|
3
|
+
//#region ../plugin-oas/src/hooks/useOperationManager.d.ts
|
|
4
|
+
|
|
5
|
+
type SchemaNames = {
|
|
6
|
+
request: string | undefined;
|
|
7
|
+
parameters: {
|
|
8
|
+
path: string | undefined;
|
|
9
|
+
query: string | undefined;
|
|
10
|
+
header: string | undefined;
|
|
11
|
+
};
|
|
12
|
+
responses: {
|
|
13
|
+
default?: string;
|
|
14
|
+
} & Record<number | string, string>;
|
|
15
|
+
errors: Record<number | string, string>;
|
|
16
|
+
};
|
|
17
|
+
//#endregion
|
|
18
|
+
//#region src/components/Operations.d.ts
|
|
7
19
|
type Props$1 = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
20
|
+
name: string;
|
|
21
|
+
operations: Array<{
|
|
22
|
+
operation: Operation;
|
|
23
|
+
data: SchemaNames;
|
|
24
|
+
}>;
|
|
13
25
|
};
|
|
14
|
-
declare function Operations({
|
|
15
|
-
|
|
26
|
+
declare function Operations({
|
|
27
|
+
name,
|
|
28
|
+
operations
|
|
29
|
+
}: Props$1): any;
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/components/Zod.d.ts
|
|
16
32
|
type Props = {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
33
|
+
name: string;
|
|
34
|
+
typeName?: string;
|
|
35
|
+
inferTypeName?: string;
|
|
36
|
+
tree: Array<Schema>;
|
|
37
|
+
rawSchema: SchemaObject;
|
|
38
|
+
description?: string;
|
|
39
|
+
coercion: PluginZod['resolvedOptions']['coercion'];
|
|
40
|
+
mapper: PluginZod['resolvedOptions']['mapper'];
|
|
41
|
+
keysToOmit?: string[];
|
|
42
|
+
wrapOutput?: PluginZod['resolvedOptions']['wrapOutput'];
|
|
43
|
+
version: '3' | '4';
|
|
44
|
+
emptySchemaType: PluginZod['resolvedOptions']['emptySchemaType'];
|
|
29
45
|
};
|
|
30
|
-
declare function Zod({
|
|
31
|
-
|
|
46
|
+
declare function Zod({
|
|
47
|
+
name,
|
|
48
|
+
typeName,
|
|
49
|
+
tree,
|
|
50
|
+
rawSchema,
|
|
51
|
+
inferTypeName,
|
|
52
|
+
mapper,
|
|
53
|
+
coercion,
|
|
54
|
+
keysToOmit,
|
|
55
|
+
description,
|
|
56
|
+
wrapOutput,
|
|
57
|
+
version,
|
|
58
|
+
emptySchemaType
|
|
59
|
+
}: Props): any;
|
|
60
|
+
//#endregion
|
|
32
61
|
export { Operations, Zod };
|
|
62
|
+
//# sourceMappingURL=components.d.cts.map
|