@kubb/plugin-zod 3.16.2 → 3.16.3
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-B13NknOz.cjs +265 -0
- package/dist/generators-B13NknOz.cjs.map +1 -0
- package/dist/generators-DcUZYcq0.js +254 -0
- package/dist/generators-DcUZYcq0.js.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.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 +24 -30
- 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
package/dist/chunk-FYI4GRXP.cjs
DELETED
|
@@ -1,460 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var react = require('@kubb/react');
|
|
4
|
-
var transformers2 = require('@kubb/core/transformers');
|
|
5
|
-
var jsxRuntime = require('@kubb/react/jsx-runtime');
|
|
6
|
-
var pluginOas = require('@kubb/plugin-oas');
|
|
7
|
-
|
|
8
|
-
function _interopDefault (e) { return e && e.__esModule ? e : { default: e }; }
|
|
9
|
-
|
|
10
|
-
var transformers2__default = /*#__PURE__*/_interopDefault(transformers2);
|
|
11
|
-
|
|
12
|
-
// src/components/Operations.tsx
|
|
13
|
-
function Operations({ name, operations }) {
|
|
14
|
-
const operationsJSON = operations.reduce(
|
|
15
|
-
(prev, acc) => {
|
|
16
|
-
prev[`"${acc.operation.getOperationId()}"`] = acc.data;
|
|
17
|
-
return prev;
|
|
18
|
-
},
|
|
19
|
-
{}
|
|
20
|
-
);
|
|
21
|
-
const pathsJSON = operations.reduce(
|
|
22
|
-
(prev, acc) => {
|
|
23
|
-
prev[`"${acc.operation.path}"`] = {
|
|
24
|
-
...prev[`"${acc.operation.path}"`] || {},
|
|
25
|
-
[acc.operation.method]: `operations["${acc.operation.getOperationId()}"]`
|
|
26
|
-
};
|
|
27
|
-
return prev;
|
|
28
|
-
},
|
|
29
|
-
{}
|
|
30
|
-
);
|
|
31
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
32
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Const, { export: true, name, asConst: true, children: `{${transformers2__default.default.stringifyObject(operationsJSON)}}` }) }),
|
|
33
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name: "paths", isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(react.Const, { export: true, name: "paths", asConst: true, children: `{${transformers2__default.default.stringifyObject(pathsJSON)}}` }) })
|
|
34
|
-
] });
|
|
35
|
-
}
|
|
36
|
-
var zodKeywordMapper = {
|
|
37
|
-
any: () => "z.any()",
|
|
38
|
-
unknown: () => "z.unknown()",
|
|
39
|
-
void: () => "z.void()",
|
|
40
|
-
number: (coercion, min, max) => {
|
|
41
|
-
return [coercion ? "z.coerce.number()" : "z.number()", min !== void 0 ? `.min(${min})` : void 0, max !== void 0 ? `.max(${max})` : void 0].filter(Boolean).join("");
|
|
42
|
-
},
|
|
43
|
-
integer: (coercion, min, max, version = "3") => {
|
|
44
|
-
return [
|
|
45
|
-
coercion ? "z.coerce.number().int()" : version === "4" ? "z.int()" : "z.number().int()",
|
|
46
|
-
min !== void 0 ? `.min(${min})` : void 0,
|
|
47
|
-
max !== void 0 ? `.max(${max})` : void 0
|
|
48
|
-
].filter(Boolean).join("");
|
|
49
|
-
},
|
|
50
|
-
interface: (value, strict) => {
|
|
51
|
-
if (strict) {
|
|
52
|
-
return `z.strictInterface({
|
|
53
|
-
${value}
|
|
54
|
-
})`;
|
|
55
|
-
}
|
|
56
|
-
return `z.interface({
|
|
57
|
-
${value}
|
|
58
|
-
})`;
|
|
59
|
-
},
|
|
60
|
-
object: (value, strict, version = "3") => {
|
|
61
|
-
if (version === "4" && strict) {
|
|
62
|
-
return `z.strictObject({
|
|
63
|
-
${value}
|
|
64
|
-
})`;
|
|
65
|
-
}
|
|
66
|
-
if (strict) {
|
|
67
|
-
return `z.object({
|
|
68
|
-
${value}
|
|
69
|
-
}).strict()`;
|
|
70
|
-
}
|
|
71
|
-
return `z.object({
|
|
72
|
-
${value}
|
|
73
|
-
})`;
|
|
74
|
-
},
|
|
75
|
-
string: (coercion, min, max) => {
|
|
76
|
-
return [coercion ? "z.coerce.string()" : "z.string()", min !== void 0 ? `.min(${min})` : void 0, max !== void 0 ? `.max(${max})` : void 0].filter(Boolean).join("");
|
|
77
|
-
},
|
|
78
|
-
//support for discriminatedUnion
|
|
79
|
-
boolean: () => "z.boolean()",
|
|
80
|
-
undefined: () => "z.undefined()",
|
|
81
|
-
nullable: () => ".nullable()",
|
|
82
|
-
null: () => "z.null()",
|
|
83
|
-
nullish: () => ".nullish()",
|
|
84
|
-
array: (items = [], min, max, unique) => {
|
|
85
|
-
return [
|
|
86
|
-
`z.array(${items?.join("")})`,
|
|
87
|
-
min !== void 0 ? `.min(${min})` : void 0,
|
|
88
|
-
max !== void 0 ? `.max(${max})` : void 0,
|
|
89
|
-
unique ? `.refine(items => new Set(items).size === items.length, { message: "Array entries must be unique" })` : void 0
|
|
90
|
-
].filter(Boolean).join("");
|
|
91
|
-
},
|
|
92
|
-
tuple: (items = []) => `z.tuple([${items?.join(", ")}])`,
|
|
93
|
-
enum: (items = []) => `z.enum([${items?.join(", ")}])`,
|
|
94
|
-
union: (items = []) => `z.union([${items?.join(", ")}])`,
|
|
95
|
-
const: (value) => `z.literal(${value ?? ""})`,
|
|
96
|
-
/**
|
|
97
|
-
* ISO 8601
|
|
98
|
-
*/
|
|
99
|
-
datetime: (offset = false, local = false, version = "3") => {
|
|
100
|
-
if (offset) {
|
|
101
|
-
return version === "4" ? `z.iso.datetime({ offset: ${offset} })` : `z.string().datetime({ offset: ${offset} })`;
|
|
102
|
-
}
|
|
103
|
-
if (local) {
|
|
104
|
-
return version === "4" ? `z.iso.datetime({ local: ${local} })` : `z.string().datetime({ local: ${local} })`;
|
|
105
|
-
}
|
|
106
|
-
return "z.string().datetime()";
|
|
107
|
-
},
|
|
108
|
-
/**
|
|
109
|
-
* Type `'date'` Date
|
|
110
|
-
* Type `'string'` ISO date format (YYYY-MM-DD)
|
|
111
|
-
* @default ISO date format (YYYY-MM-DD)
|
|
112
|
-
*/
|
|
113
|
-
date: (type = "string", coercion, version = "3") => {
|
|
114
|
-
if (type === "string") {
|
|
115
|
-
return version === "4" ? "z.iso.date()" : "z.string().date()";
|
|
116
|
-
}
|
|
117
|
-
if (coercion) {
|
|
118
|
-
return "z.coerce.date()";
|
|
119
|
-
}
|
|
120
|
-
return "z.date()";
|
|
121
|
-
},
|
|
122
|
-
/**
|
|
123
|
-
* Type `'date'` Date
|
|
124
|
-
* Type `'string'` ISO time format (HH:mm:ss[.SSSSSS])
|
|
125
|
-
* @default ISO time format (HH:mm:ss[.SSSSSS])
|
|
126
|
-
*/
|
|
127
|
-
time: (type = "string", coercion, version = "3") => {
|
|
128
|
-
if (type === "string") {
|
|
129
|
-
return version === "4" ? "z.iso.time()" : "z.string().time()";
|
|
130
|
-
}
|
|
131
|
-
if (coercion) {
|
|
132
|
-
return "z.coerce.date()";
|
|
133
|
-
}
|
|
134
|
-
return "z.date()";
|
|
135
|
-
},
|
|
136
|
-
uuid: (coercion, version = "3") => version === "4" ? coercion ? "z.coerce.string().uuid()" : "z.uuid()" : coercion ? "z.coerce.string().uuid()" : "z.string().uuid()",
|
|
137
|
-
url: (coercion, version = "3") => version === "4" ? coercion ? "z.coerce.string().url()" : "z.url()" : coercion ? "z.coerce.string().url()" : "z.string().url()",
|
|
138
|
-
default: (value) => {
|
|
139
|
-
if (typeof value === "object") {
|
|
140
|
-
return ".default({})";
|
|
141
|
-
}
|
|
142
|
-
return `.default(${value ?? ""})`;
|
|
143
|
-
},
|
|
144
|
-
and: (items = []) => items?.map((item) => `.and(${item})`).join(""),
|
|
145
|
-
describe: (value = "") => `.describe(${value})`,
|
|
146
|
-
min: (value) => `.min(${value ?? ""})`,
|
|
147
|
-
max: (value) => `.max(${value ?? ""})`,
|
|
148
|
-
optional: () => ".optional()",
|
|
149
|
-
matches: (value = "", coercion) => coercion ? `z.coerce.string().regex(${value})` : `z.string().regex(${value})`,
|
|
150
|
-
email: (coercion, version = "3") => version === "4" ? coercion ? "z.coerce.string().email()" : "z.email()" : coercion ? "z.coerce.string().email()" : "z.string().email()",
|
|
151
|
-
firstName: void 0,
|
|
152
|
-
lastName: void 0,
|
|
153
|
-
password: void 0,
|
|
154
|
-
phone: void 0,
|
|
155
|
-
readOnly: void 0,
|
|
156
|
-
writeOnly: void 0,
|
|
157
|
-
ref: (value, version = "3") => {
|
|
158
|
-
if (!value) {
|
|
159
|
-
return void 0;
|
|
160
|
-
}
|
|
161
|
-
return version === "4" ? value : `z.lazy(() => ${value})`;
|
|
162
|
-
},
|
|
163
|
-
blob: () => "z.instanceof(File)",
|
|
164
|
-
deprecated: void 0,
|
|
165
|
-
example: void 0,
|
|
166
|
-
schema: void 0,
|
|
167
|
-
catchall: (value) => value ? `.catchall(${value})` : void 0,
|
|
168
|
-
name: void 0
|
|
169
|
-
};
|
|
170
|
-
function sort(items) {
|
|
171
|
-
const order = [
|
|
172
|
-
pluginOas.schemaKeywords.string,
|
|
173
|
-
pluginOas.schemaKeywords.datetime,
|
|
174
|
-
pluginOas.schemaKeywords.date,
|
|
175
|
-
pluginOas.schemaKeywords.time,
|
|
176
|
-
pluginOas.schemaKeywords.tuple,
|
|
177
|
-
pluginOas.schemaKeywords.number,
|
|
178
|
-
pluginOas.schemaKeywords.object,
|
|
179
|
-
pluginOas.schemaKeywords.enum,
|
|
180
|
-
pluginOas.schemaKeywords.url,
|
|
181
|
-
pluginOas.schemaKeywords.email,
|
|
182
|
-
pluginOas.schemaKeywords.firstName,
|
|
183
|
-
pluginOas.schemaKeywords.lastName,
|
|
184
|
-
pluginOas.schemaKeywords.password,
|
|
185
|
-
pluginOas.schemaKeywords.matches,
|
|
186
|
-
pluginOas.schemaKeywords.uuid,
|
|
187
|
-
pluginOas.schemaKeywords.null,
|
|
188
|
-
pluginOas.schemaKeywords.min,
|
|
189
|
-
pluginOas.schemaKeywords.max,
|
|
190
|
-
pluginOas.schemaKeywords.default,
|
|
191
|
-
pluginOas.schemaKeywords.describe,
|
|
192
|
-
pluginOas.schemaKeywords.optional,
|
|
193
|
-
pluginOas.schemaKeywords.nullable,
|
|
194
|
-
pluginOas.schemaKeywords.nullish
|
|
195
|
-
];
|
|
196
|
-
if (!items) {
|
|
197
|
-
return [];
|
|
198
|
-
}
|
|
199
|
-
return transformers2__default.default.orderBy(items, [(v) => order.indexOf(v.keyword)], ["asc"]);
|
|
200
|
-
}
|
|
201
|
-
var shouldCoerce = (coercion, type) => {
|
|
202
|
-
if (coercion === void 0) {
|
|
203
|
-
return false;
|
|
204
|
-
}
|
|
205
|
-
if (typeof coercion === "boolean") {
|
|
206
|
-
return coercion;
|
|
207
|
-
}
|
|
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) => pluginOas.isKeyword(it, pluginOas.schemaKeywords.matches));
|
|
213
|
-
const hasRef = siblings.some((it) => pluginOas.isKeyword(it, pluginOas.schemaKeywords.ref));
|
|
214
|
-
if (hasMatches && hasRef && pluginOas.isKeyword(current, pluginOas.schemaKeywords.matches)) {
|
|
215
|
-
return void 0;
|
|
216
|
-
}
|
|
217
|
-
if (!value) {
|
|
218
|
-
return void 0;
|
|
219
|
-
}
|
|
220
|
-
if (pluginOas.isKeyword(current, pluginOas.schemaKeywords.union)) {
|
|
221
|
-
if (Array.isArray(current.args) && current.args.length === 1) {
|
|
222
|
-
return parse({ parent, name, current: current.args[0], siblings }, options);
|
|
223
|
-
}
|
|
224
|
-
if (Array.isArray(current.args) && !current.args.length) {
|
|
225
|
-
return "";
|
|
226
|
-
}
|
|
227
|
-
return zodKeywordMapper.union(
|
|
228
|
-
sort(current.args).map((schema, _index, siblings2) => parse({ parent: current, name, current: schema, siblings: siblings2 }, options)).filter(Boolean)
|
|
229
|
-
);
|
|
230
|
-
}
|
|
231
|
-
if (pluginOas.isKeyword(current, pluginOas.schemaKeywords.and)) {
|
|
232
|
-
const items = sort(current.args).filter((schema) => {
|
|
233
|
-
return ![pluginOas.schemaKeywords.optional, pluginOas.schemaKeywords.describe].includes(schema.keyword);
|
|
234
|
-
}).map((schema, _index, siblings2) => parse({ parent: current, name, current: schema, siblings: siblings2 }, options)).filter(Boolean);
|
|
235
|
-
return `${items.slice(0, 1)}${zodKeywordMapper.and(items.slice(1))}`;
|
|
236
|
-
}
|
|
237
|
-
if (pluginOas.isKeyword(current, pluginOas.schemaKeywords.array)) {
|
|
238
|
-
return zodKeywordMapper.array(
|
|
239
|
-
sort(current.args.items).map((schemas, _index, siblings2) => parse({ parent: current, name, current: schemas, siblings: siblings2 }, options)).filter(Boolean),
|
|
240
|
-
current.args.min,
|
|
241
|
-
current.args.max,
|
|
242
|
-
current.args.unique
|
|
243
|
-
);
|
|
244
|
-
}
|
|
245
|
-
if (pluginOas.isKeyword(current, pluginOas.schemaKeywords.enum)) {
|
|
246
|
-
if (current.args.asConst) {
|
|
247
|
-
if (current.args.items.length === 1) {
|
|
248
|
-
const child = {
|
|
249
|
-
keyword: pluginOas.schemaKeywords.const,
|
|
250
|
-
args: current.args.items[0]
|
|
251
|
-
};
|
|
252
|
-
return parse({ parent: current, name, current: child, siblings: [child] }, options);
|
|
253
|
-
}
|
|
254
|
-
return zodKeywordMapper.union(
|
|
255
|
-
current.args.items.map((schema) => ({
|
|
256
|
-
keyword: pluginOas.schemaKeywords.const,
|
|
257
|
-
args: schema
|
|
258
|
-
})).map((schema, _index, siblings2) => {
|
|
259
|
-
return parse({ parent: current, name, current: schema, siblings: siblings2 }, options);
|
|
260
|
-
}).filter(Boolean)
|
|
261
|
-
);
|
|
262
|
-
}
|
|
263
|
-
return zodKeywordMapper.enum(
|
|
264
|
-
current.args.items.map((schema) => {
|
|
265
|
-
if (schema.format === "boolean") {
|
|
266
|
-
return transformers2__default.default.stringify(schema.value);
|
|
267
|
-
}
|
|
268
|
-
if (schema.format === "number") {
|
|
269
|
-
return transformers2__default.default.stringify(schema.value);
|
|
270
|
-
}
|
|
271
|
-
return transformers2__default.default.stringify(schema.value);
|
|
272
|
-
})
|
|
273
|
-
);
|
|
274
|
-
}
|
|
275
|
-
if (pluginOas.isKeyword(current, pluginOas.schemaKeywords.ref)) {
|
|
276
|
-
return zodKeywordMapper.ref(current.args?.name, options.version);
|
|
277
|
-
}
|
|
278
|
-
if (pluginOas.isKeyword(current, pluginOas.schemaKeywords.object)) {
|
|
279
|
-
const propertyEntries = Object.entries(current.args?.properties || {}).filter((item) => {
|
|
280
|
-
const schema = item[1];
|
|
281
|
-
return schema && typeof schema.map === "function";
|
|
282
|
-
});
|
|
283
|
-
const properties = propertyEntries.map(([name2, schemas]) => {
|
|
284
|
-
const nameSchema = schemas.find((schema) => schema.keyword === pluginOas.schemaKeywords.name);
|
|
285
|
-
const mappedName = nameSchema?.args || name2;
|
|
286
|
-
if (options.mapper?.[mappedName]) {
|
|
287
|
-
return `"${name2}": ${options.mapper?.[mappedName]}`;
|
|
288
|
-
}
|
|
289
|
-
const baseSchemaOutput = sort(schemas).map((schema) => parse({ parent: current, name: name2, current: schema, siblings: schemas }, options)).filter(Boolean).join("");
|
|
290
|
-
const objectValue = options.wrapOutput ? options.wrapOutput({ output: baseSchemaOutput, schema: options.rawSchema?.properties?.[name2] }) || baseSchemaOutput : baseSchemaOutput;
|
|
291
|
-
if (options.version === "4" && pluginOas.SchemaGenerator.find(schemas, pluginOas.schemaKeywords.ref)) {
|
|
292
|
-
return `get ${name2}(){
|
|
293
|
-
return ${objectValue}
|
|
294
|
-
}`;
|
|
295
|
-
}
|
|
296
|
-
return `"${name2}": ${objectValue}`;
|
|
297
|
-
}).join(",\n");
|
|
298
|
-
const additionalProperties = current.args?.additionalProperties?.length ? current.args.additionalProperties.map((schema, _index, siblings2) => parse({ parent: current, name, current: schema, siblings: siblings2 }, options)).filter(Boolean).join("") : void 0;
|
|
299
|
-
const text = [
|
|
300
|
-
zodKeywordMapper.object(properties, current.args?.strict, options.version),
|
|
301
|
-
additionalProperties ? zodKeywordMapper.catchall(additionalProperties) : void 0
|
|
302
|
-
].filter(Boolean);
|
|
303
|
-
return text.join("");
|
|
304
|
-
}
|
|
305
|
-
if (pluginOas.isKeyword(current, pluginOas.schemaKeywords.tuple)) {
|
|
306
|
-
return zodKeywordMapper.tuple(
|
|
307
|
-
current.args.items.map((schema, _index, siblings2) => parse({ parent: current, name, current: schema, siblings: siblings2 }, options)).filter(Boolean)
|
|
308
|
-
);
|
|
309
|
-
}
|
|
310
|
-
if (pluginOas.isKeyword(current, pluginOas.schemaKeywords.const)) {
|
|
311
|
-
if (current.args.format === "number" && current.args.value !== void 0) {
|
|
312
|
-
return zodKeywordMapper.const(Number(current.args.value));
|
|
313
|
-
}
|
|
314
|
-
if (current.args.format === "boolean" && current.args.value !== void 0) {
|
|
315
|
-
return zodKeywordMapper.const(current.args.value);
|
|
316
|
-
}
|
|
317
|
-
return zodKeywordMapper.const(transformers2__default.default.stringify(current.args.value));
|
|
318
|
-
}
|
|
319
|
-
if (pluginOas.isKeyword(current, pluginOas.schemaKeywords.matches)) {
|
|
320
|
-
if (current.args) {
|
|
321
|
-
return zodKeywordMapper.matches(transformers2__default.default.toRegExpString(current.args, null), shouldCoerce(options.coercion, "strings"));
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
if (pluginOas.isKeyword(current, pluginOas.schemaKeywords.default)) {
|
|
325
|
-
if (current.args) {
|
|
326
|
-
return zodKeywordMapper.default(current.args);
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
if (pluginOas.isKeyword(current, pluginOas.schemaKeywords.describe)) {
|
|
330
|
-
if (current.args) {
|
|
331
|
-
return zodKeywordMapper.describe(transformers2__default.default.stringify(current.args.toString()));
|
|
332
|
-
}
|
|
333
|
-
}
|
|
334
|
-
if (pluginOas.isKeyword(current, pluginOas.schemaKeywords.string)) {
|
|
335
|
-
return zodKeywordMapper.string(shouldCoerce(options.coercion, "strings"));
|
|
336
|
-
}
|
|
337
|
-
if (pluginOas.isKeyword(current, pluginOas.schemaKeywords.uuid)) {
|
|
338
|
-
return zodKeywordMapper.uuid(shouldCoerce(options.coercion, "strings"), options.version);
|
|
339
|
-
}
|
|
340
|
-
if (pluginOas.isKeyword(current, pluginOas.schemaKeywords.email)) {
|
|
341
|
-
return zodKeywordMapper.email(shouldCoerce(options.coercion, "strings"), options.version);
|
|
342
|
-
}
|
|
343
|
-
if (pluginOas.isKeyword(current, pluginOas.schemaKeywords.url)) {
|
|
344
|
-
return zodKeywordMapper.url(shouldCoerce(options.coercion, "strings"), options.version);
|
|
345
|
-
}
|
|
346
|
-
if (pluginOas.isKeyword(current, pluginOas.schemaKeywords.number)) {
|
|
347
|
-
return zodKeywordMapper.number(shouldCoerce(options.coercion, "numbers"));
|
|
348
|
-
}
|
|
349
|
-
if (pluginOas.isKeyword(current, pluginOas.schemaKeywords.integer)) {
|
|
350
|
-
return zodKeywordMapper.integer(shouldCoerce(options.coercion, "numbers"), void 0, void 0, options.version);
|
|
351
|
-
}
|
|
352
|
-
if (pluginOas.isKeyword(current, pluginOas.schemaKeywords.min)) {
|
|
353
|
-
return zodKeywordMapper.min(current.args);
|
|
354
|
-
}
|
|
355
|
-
if (pluginOas.isKeyword(current, pluginOas.schemaKeywords.max)) {
|
|
356
|
-
return zodKeywordMapper.max(current.args);
|
|
357
|
-
}
|
|
358
|
-
if (pluginOas.isKeyword(current, pluginOas.schemaKeywords.datetime)) {
|
|
359
|
-
return zodKeywordMapper.datetime(current.args.offset, current.args.local, options.version);
|
|
360
|
-
}
|
|
361
|
-
if (pluginOas.isKeyword(current, pluginOas.schemaKeywords.date)) {
|
|
362
|
-
return zodKeywordMapper.date(current.args.type, shouldCoerce(options.coercion, "dates"), options.version);
|
|
363
|
-
}
|
|
364
|
-
if (pluginOas.isKeyword(current, pluginOas.schemaKeywords.time)) {
|
|
365
|
-
return zodKeywordMapper.time(current.args.type, shouldCoerce(options.coercion, "dates"), options.version);
|
|
366
|
-
}
|
|
367
|
-
if (current.keyword in zodKeywordMapper && "args" in current) {
|
|
368
|
-
const value2 = zodKeywordMapper[current.keyword];
|
|
369
|
-
return value2(current.args);
|
|
370
|
-
}
|
|
371
|
-
if (pluginOas.isKeyword(current, pluginOas.schemaKeywords.optional)) {
|
|
372
|
-
if (siblings.some((schema) => pluginOas.isKeyword(schema, pluginOas.schemaKeywords.default))) return "";
|
|
373
|
-
return value();
|
|
374
|
-
}
|
|
375
|
-
if (current.keyword in zodKeywordMapper) {
|
|
376
|
-
return value();
|
|
377
|
-
}
|
|
378
|
-
return void 0;
|
|
379
|
-
}
|
|
380
|
-
function Zod({
|
|
381
|
-
name,
|
|
382
|
-
typeName,
|
|
383
|
-
tree,
|
|
384
|
-
rawSchema,
|
|
385
|
-
inferTypeName,
|
|
386
|
-
mapper,
|
|
387
|
-
coercion,
|
|
388
|
-
keysToOmit,
|
|
389
|
-
description,
|
|
390
|
-
wrapOutput,
|
|
391
|
-
version,
|
|
392
|
-
emptySchemaType
|
|
393
|
-
}) {
|
|
394
|
-
const hasTuple = !!pluginOas.SchemaGenerator.deepSearch(tree, pluginOas.schemaKeywords.tuple);
|
|
395
|
-
const schemas = sort(tree).filter((item) => {
|
|
396
|
-
if (hasTuple && (pluginOas.isKeyword(item, pluginOas.schemaKeywords.min) || pluginOas.isKeyword(item, pluginOas.schemaKeywords.max))) {
|
|
397
|
-
return false;
|
|
398
|
-
}
|
|
399
|
-
return true;
|
|
400
|
-
});
|
|
401
|
-
const output = schemas.map(
|
|
402
|
-
(schema, _index, siblings) => parse(
|
|
403
|
-
{ parent: void 0, current: schema, siblings },
|
|
404
|
-
{ name, keysToOmit, typeName, description, mapper, coercion, wrapOutput, rawSchema, version }
|
|
405
|
-
)
|
|
406
|
-
).filter(Boolean).join("");
|
|
407
|
-
let suffix = "";
|
|
408
|
-
const firstSchema = schemas.at(0);
|
|
409
|
-
const lastSchema = schemas.at(-1);
|
|
410
|
-
if (lastSchema && pluginOas.isKeyword(lastSchema, pluginOas.schemaKeywords.nullable)) {
|
|
411
|
-
if (firstSchema && pluginOas.isKeyword(firstSchema, pluginOas.schemaKeywords.ref)) {
|
|
412
|
-
if (version === "3") {
|
|
413
|
-
suffix = ".unwrap().schema.unwrap()";
|
|
414
|
-
} else {
|
|
415
|
-
suffix = ".unwrap().unwrap()";
|
|
416
|
-
}
|
|
417
|
-
} else {
|
|
418
|
-
suffix = ".unwrap()";
|
|
419
|
-
}
|
|
420
|
-
} else {
|
|
421
|
-
if (firstSchema && pluginOas.isKeyword(firstSchema, pluginOas.schemaKeywords.ref) && version === "3") {
|
|
422
|
-
suffix = ".schema";
|
|
423
|
-
}
|
|
424
|
-
}
|
|
425
|
-
const emptyValue = parse(
|
|
426
|
-
{
|
|
427
|
-
parent: void 0,
|
|
428
|
-
current: {
|
|
429
|
-
keyword: pluginOas.schemaKeywords[emptySchemaType]
|
|
430
|
-
},
|
|
431
|
-
siblings: []
|
|
432
|
-
},
|
|
433
|
-
{ name, keysToOmit, typeName, description, mapper, coercion, wrapOutput, rawSchema, version }
|
|
434
|
-
);
|
|
435
|
-
const baseSchemaOutput = [output, keysToOmit?.length ? `${suffix}.omit({ ${keysToOmit.map((key) => `${key}: true`).join(",")} })` : void 0].filter(Boolean).join("") || emptyValue || "";
|
|
436
|
-
const wrappedSchemaOutput = wrapOutput ? wrapOutput({ output: baseSchemaOutput, schema: rawSchema }) || baseSchemaOutput : baseSchemaOutput;
|
|
437
|
-
const finalOutput = typeName ? `${wrappedSchemaOutput} as unknown as ToZod<${typeName}>` : wrappedSchemaOutput;
|
|
438
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
439
|
-
/* @__PURE__ */ jsxRuntime.jsx(react.File.Source, { name, isExportable: true, isIndexable: true, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
440
|
-
react.Const,
|
|
441
|
-
{
|
|
442
|
-
export: true,
|
|
443
|
-
name,
|
|
444
|
-
JSDoc: {
|
|
445
|
-
comments: [description ? `@description ${transformers2__default.default.jsStringEscape(description)}` : void 0].filter(Boolean)
|
|
446
|
-
},
|
|
447
|
-
children: finalOutput
|
|
448
|
-
}
|
|
449
|
-
) }),
|
|
450
|
-
inferTypeName && /* @__PURE__ */ jsxRuntime.jsxs(react.File.Source, { name: inferTypeName, isExportable: true, isIndexable: true, isTypeOnly: true, children: [
|
|
451
|
-
typeName && /* @__PURE__ */ jsxRuntime.jsx(react.Type, { export: true, name: inferTypeName, children: typeName }),
|
|
452
|
-
!typeName && /* @__PURE__ */ jsxRuntime.jsx(react.Type, { export: true, name: inferTypeName, children: `z.infer<typeof ${name}>` })
|
|
453
|
-
] })
|
|
454
|
-
] });
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
exports.Operations = Operations;
|
|
458
|
-
exports.Zod = Zod;
|
|
459
|
-
//# sourceMappingURL=chunk-FYI4GRXP.cjs.map
|
|
460
|
-
//# sourceMappingURL=chunk-FYI4GRXP.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/components/Operations.tsx","../src/parser.ts","../src/components/Zod.tsx"],"names":["jsxs","Fragment","jsx","File","Const","transformers","schemaKeywords","isKeyword","siblings","name","SchemaGenerator","value","Type"],"mappings":";;;;;;;;;;;;AAWO,SAAS,UAAW,CAAA,EAAE,IAAM,EAAA,UAAA,EAAqB,EAAA;AACtD,EAAA,MAAM,iBAAiB,UAAW,CAAA,MAAA;AAAA,IAChC,CAAC,MAAM,GAAQ,KAAA;AACb,MAAA,IAAA,CAAK,IAAI,GAAI,CAAA,SAAA,CAAU,gBAAgB,CAAA,CAAA,CAAG,IAAI,GAAI,CAAA,IAAA;AAElD,MAAO,OAAA,IAAA;AAAA,KACT;AAAA,IACA;AAAC,GACH;AAEA,EAAA,MAAM,YAAY,UAAW,CAAA,MAAA;AAAA,IAC3B,CAAC,MAAM,GAAQ,KAAA;AACb,MAAA,IAAA,CAAK,CAAI,CAAA,EAAA,GAAA,CAAI,SAAU,CAAA,IAAI,GAAG,CAAI,GAAA;AAAA,QAChC,GAAI,KAAK,CAAI,CAAA,EAAA,GAAA,CAAI,UAAU,IAAI,CAAA,CAAA,CAAG,KAAM,EAAC;AAAA,QACzC,CAAC,IAAI,SAAU,C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EAAA,CAAA;AAAA,IACC,aACC,oBAAAL,eAACG,CAAAA,UAAAA,CAAK,MAAL,EAAA,EAAY,IAAM,EAAA,aAAA,EAAe,YAAY,EAAA,IAAA,EAAC,WAAW,EAAA,IAAA,EAAC,YAAU,IAClE,EAAA,QAAA,EAAA;AAAA,MAAA,QAAA,oBACCD,cAAC,CAAAU,UAAA,EAAA,EAAK,QAAM,IAAC,EAAA,IAAA,EAAM,eAChB,QACH,EAAA,QAAA,EAAA,CAAA;AAAA,MAED,CAAC,QACA,oBAAAV,cAAC,CAAAU,UAAA,EAAA,EAAK,MAAM,EAAA,IAAA,EAAC,IAAM,EAAA,aAAA,EAChB,QAAkB,EAAA,CAAA,eAAA,EAAA,IAAI,CACzB,CAAA,CAAA,EAAA;AAAA,KAEJ,EAAA;AAAA,GAEJ,EAAA,CAAA;AAEJ","file":"chunk-FYI4GRXP.cjs","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"]}
|