@kubb/plugin-zod 4.0.0 → 4.1.0
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-DtKP6doO.js → components-B1-pLa6g.js} +73 -35
- package/dist/components-B1-pLa6g.js.map +1 -0
- package/dist/{components-Bv7MaVo7.cjs → components-C6PNc1ua.cjs} +73 -35
- package/dist/components-C6PNc1ua.cjs.map +1 -0
- package/dist/components.cjs +1 -1
- package/dist/components.js +1 -1
- package/dist/{generators-CrSYV5kr.cjs → generators-8iZ6rvz2.cjs} +4 -4
- package/dist/generators-8iZ6rvz2.cjs.map +1 -0
- package/dist/{generators-BY96mD4w.js → generators-B66sl9uI.js} +4 -4
- package/dist/generators-B66sl9uI.js.map +1 -0
- package/dist/generators.cjs +2 -2
- package/dist/generators.js +2 -2
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/package.json +8 -13
- package/src/components/Zod.tsx +8 -6
- package/src/generators/__snapshots__/coercion.ts +5 -8
- package/src/generators/__snapshots__/coercionDates.ts +5 -8
- package/src/generators/__snapshots__/coercionNumbers.ts +5 -8
- package/src/generators/__snapshots__/coercionStrings.ts +5 -8
- package/src/generators/__snapshots__/deletePet.ts +1 -1
- package/src/generators/__snapshots__/deletePet_wrapOutput.ts +1 -1
- package/src/generators/__snapshots__/example.ts +1 -1
- package/src/generators/__snapshots__/getPets.ts +2 -2
- package/src/generators/__snapshots__/getPets_wrapOutput.ts +2 -2
- package/src/generators/__snapshots__/nullable.ts +1 -1
- package/src/generators/__snapshots__/oneof.ts +2 -2
- package/src/generators/__snapshots__/optionalPetInfer.ts +3 -3
- package/src/generators/__snapshots__/optionalPetTyped.ts +3 -3
- package/src/generators/__snapshots__/order.ts +6 -6
- package/src/generators/__snapshots__/orderDateTypeFalse.ts +6 -6
- package/src/generators/__snapshots__/orderDateTypeString.ts +6 -6
- package/src/generators/__snapshots__/pet.ts +5 -8
- package/src/generators/__snapshots__/petCoercion.ts +5 -8
- package/src/generators/__snapshots__/petTupleObject.ts +1 -1
- package/src/generators/__snapshots__/petV4.ts +5 -8
- package/src/generators/__snapshots__/petWithMapper.ts +5 -8
- package/src/generators/__snapshots__/pets.ts +1 -1
- package/src/generators/__snapshots__/queryAllDefaulted.ts +2 -2
- package/src/generators/__snapshots__/queryAllDefaulted_wrapOutput.ts +2 -2
- package/src/generators/__snapshots__/toy.ts +2 -2
- package/src/generators/zodGenerator.tsx +1 -1
- package/src/parser.ts +78 -21
- package/dist/components-Bv7MaVo7.cjs.map +0 -1
- package/dist/components-DtKP6doO.js.map +0 -1
- package/dist/generators-BY96mD4w.js.map +0 -1
- package/dist/generators-CrSYV5kr.cjs.map +0 -1
- package/dist/utils/v4.cjs +0 -0
- package/dist/utils/v4.d.cts +0 -38
- package/dist/utils/v4.d.ts +0 -38
- package/dist/utils/v4.js +0 -1
- package/src/utils/v4/ToZod.ts +0 -61
- package/src/utils/v4/index.ts +0 -1
|
@@ -87,9 +87,15 @@ const zodKeywordMapper = {
|
|
|
87
87
|
},
|
|
88
88
|
boolean: () => "z.boolean()",
|
|
89
89
|
undefined: () => "z.undefined()",
|
|
90
|
-
nullable: () =>
|
|
90
|
+
nullable: (value) => {
|
|
91
|
+
if (value) return `z.nullable(${value})`;
|
|
92
|
+
return ".nullable()";
|
|
93
|
+
},
|
|
91
94
|
null: () => "z.null()",
|
|
92
|
-
nullish: () =>
|
|
95
|
+
nullish: (value) => {
|
|
96
|
+
if (value) return `z.nullish(${value})`;
|
|
97
|
+
return ".nullish()";
|
|
98
|
+
},
|
|
93
99
|
array: (items = [], min, max, unique) => {
|
|
94
100
|
return [
|
|
95
101
|
`z.array(${items?.join("")})`,
|
|
@@ -125,9 +131,12 @@ const zodKeywordMapper = {
|
|
|
125
131
|
},
|
|
126
132
|
and: (items = []) => items?.map((item) => `.and(${item})`).join(""),
|
|
127
133
|
describe: (value = "") => `.describe(${value})`,
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
optional: () =>
|
|
134
|
+
max: void 0,
|
|
135
|
+
min: void 0,
|
|
136
|
+
optional: (value) => {
|
|
137
|
+
if (value) return `z.optional(${value})`;
|
|
138
|
+
return ".optional()";
|
|
139
|
+
},
|
|
131
140
|
matches: (value = "", coercion) => coercion ? `z.coerce.string().regex(${value})` : `z.string().regex(${value})`,
|
|
132
141
|
email: (coercion, version = "3") => version === "4" ? coercion ? "z.coerce.string().email()" : "z.email()" : coercion ? "z.coerce.string().email()" : "z.string().email()",
|
|
133
142
|
firstName: void 0,
|
|
@@ -260,9 +269,15 @@ function parse({ parent, current, name, siblings }, options) {
|
|
|
260
269
|
const schema = item[1];
|
|
261
270
|
return schema && typeof schema.map === "function";
|
|
262
271
|
}).map(([name$1, schemas]) => {
|
|
263
|
-
const
|
|
272
|
+
const nameSchema = schemas.find((it) => it.keyword === schemaKeywords.name);
|
|
273
|
+
const isNullable = schemas.some((it) => isKeyword(it, schemaKeywords.nullable));
|
|
274
|
+
const isNullish = schemas.some((it) => isKeyword(it, schemaKeywords.nullish));
|
|
275
|
+
const isOptional = schemas.some((it) => isKeyword(it, schemaKeywords.optional));
|
|
276
|
+
const mappedName = nameSchema?.args || name$1;
|
|
264
277
|
if (options.mapper?.[mappedName]) return `"${name$1}": ${options.mapper?.[mappedName]}`;
|
|
265
|
-
const baseSchemaOutput = sort(schemas).
|
|
278
|
+
const baseSchemaOutput = sort(schemas).filter((schema) => {
|
|
279
|
+
return !isKeyword(schema, schemaKeywords.optional) && !isKeyword(schema, schemaKeywords.nullable) && !isKeyword(schema, schemaKeywords.nullish);
|
|
280
|
+
}).map((schema) => parse({
|
|
266
281
|
parent: current,
|
|
267
282
|
name: name$1,
|
|
268
283
|
current: schema,
|
|
@@ -272,9 +287,23 @@ function parse({ parent, current, name, siblings }, options) {
|
|
|
272
287
|
output: baseSchemaOutput,
|
|
273
288
|
schema: options.rawSchema?.properties?.[name$1]
|
|
274
289
|
}) || baseSchemaOutput : baseSchemaOutput;
|
|
275
|
-
if (options.version === "4" && SchemaGenerator.find(schemas, schemaKeywords.ref))
|
|
290
|
+
if (options.version === "4" && SchemaGenerator.find(schemas, schemaKeywords.ref)) {
|
|
291
|
+
if (isNullish) return `get ${name$1}(){
|
|
292
|
+
return ${zodKeywordMapper.nullish(objectValue)}
|
|
293
|
+
}`;
|
|
294
|
+
if (isOptional) return `get ${name$1}(){
|
|
295
|
+
return ${zodKeywordMapper.optional(objectValue)}
|
|
296
|
+
}`;
|
|
297
|
+
if (isNullable) return `get ${name$1}(){
|
|
298
|
+
return ${zodKeywordMapper.nullable(objectValue)}
|
|
299
|
+
}`;
|
|
300
|
+
return `get ${name$1}(){
|
|
276
301
|
return ${objectValue}
|
|
277
302
|
}`;
|
|
303
|
+
}
|
|
304
|
+
if (isNullish) return `"${name$1}": ${objectValue}${zodKeywordMapper.nullish()}`;
|
|
305
|
+
if (isOptional) return `"${name$1}": ${zodKeywordMapper.optional(objectValue)}`;
|
|
306
|
+
if (isNullable) return `"${name$1}": ${zodKeywordMapper.nullable(objectValue)}`;
|
|
278
307
|
return `"${name$1}": ${objectValue}`;
|
|
279
308
|
}).join(",\n");
|
|
280
309
|
const additionalProperties = current.args?.additionalProperties?.length ? current.args.additionalProperties.map((schema, _index, siblings$1) => parse({
|
|
@@ -305,14 +334,24 @@ function parse({ parent, current, name, siblings }, options) {
|
|
|
305
334
|
if (isKeyword(current, schemaKeywords.describe)) {
|
|
306
335
|
if (current.args) return zodKeywordMapper.describe(transformers.stringify(current.args.toString()));
|
|
307
336
|
}
|
|
308
|
-
if (isKeyword(current, schemaKeywords.string))
|
|
337
|
+
if (isKeyword(current, schemaKeywords.string)) {
|
|
338
|
+
const minSchema = SchemaGenerator.find(siblings, schemaKeywords.min);
|
|
339
|
+
const maxSchema = SchemaGenerator.find(siblings, schemaKeywords.max);
|
|
340
|
+
return zodKeywordMapper.string(shouldCoerce(options.coercion, "strings"), minSchema?.args, maxSchema?.args);
|
|
341
|
+
}
|
|
309
342
|
if (isKeyword(current, schemaKeywords.uuid)) return zodKeywordMapper.uuid(shouldCoerce(options.coercion, "strings"), options.version);
|
|
310
343
|
if (isKeyword(current, schemaKeywords.email)) return zodKeywordMapper.email(shouldCoerce(options.coercion, "strings"), options.version);
|
|
311
344
|
if (isKeyword(current, schemaKeywords.url)) return zodKeywordMapper.url(shouldCoerce(options.coercion, "strings"), options.version);
|
|
312
|
-
if (isKeyword(current, schemaKeywords.number))
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
345
|
+
if (isKeyword(current, schemaKeywords.number)) {
|
|
346
|
+
const minSchema = SchemaGenerator.find(siblings, schemaKeywords.min);
|
|
347
|
+
const maxSchema = SchemaGenerator.find(siblings, schemaKeywords.max);
|
|
348
|
+
return zodKeywordMapper.number(shouldCoerce(options.coercion, "numbers"), minSchema?.args, maxSchema?.args);
|
|
349
|
+
}
|
|
350
|
+
if (isKeyword(current, schemaKeywords.integer)) {
|
|
351
|
+
const minSchema = SchemaGenerator.find(siblings, schemaKeywords.min);
|
|
352
|
+
const maxSchema = SchemaGenerator.find(siblings, schemaKeywords.max);
|
|
353
|
+
return zodKeywordMapper.integer(shouldCoerce(options.coercion, "numbers"), minSchema?.args, maxSchema?.args, options.version);
|
|
354
|
+
}
|
|
316
355
|
if (isKeyword(current, schemaKeywords.datetime)) return zodKeywordMapper.datetime(current.args.offset, current.args.local, options.version);
|
|
317
356
|
if (isKeyword(current, schemaKeywords.date)) return zodKeywordMapper.date(current.args.type, shouldCoerce(options.coercion, "dates"), options.version);
|
|
318
357
|
if (isKeyword(current, schemaKeywords.time)) return zodKeywordMapper.time(current.args.type, shouldCoerce(options.coercion, "dates"), options.version);
|
|
@@ -320,10 +359,6 @@ function parse({ parent, current, name, siblings }, options) {
|
|
|
320
359
|
const value$1 = zodKeywordMapper[current.keyword];
|
|
321
360
|
return value$1(current.args);
|
|
322
361
|
}
|
|
323
|
-
if (isKeyword(current, schemaKeywords.optional)) {
|
|
324
|
-
if (siblings.some((schema) => isKeyword(schema, schemaKeywords.default))) return "";
|
|
325
|
-
return value();
|
|
326
|
-
}
|
|
327
362
|
if (current.keyword in zodKeywordMapper) return value();
|
|
328
363
|
}
|
|
329
364
|
|
|
@@ -335,21 +370,24 @@ function Zod({ name, typeName, tree, rawSchema, inferTypeName, mapper, coercion,
|
|
|
335
370
|
if (hasTuple && (isKeyword(item, schemaKeywords.min) || isKeyword(item, schemaKeywords.max))) return false;
|
|
336
371
|
return true;
|
|
337
372
|
});
|
|
338
|
-
const output = schemas.map((schema,
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
373
|
+
const output = schemas.map((schema, index) => {
|
|
374
|
+
const siblings = schemas.filter((_, i) => i !== index);
|
|
375
|
+
return parse({
|
|
376
|
+
parent: void 0,
|
|
377
|
+
current: schema,
|
|
378
|
+
siblings
|
|
379
|
+
}, {
|
|
380
|
+
name,
|
|
381
|
+
keysToOmit,
|
|
382
|
+
typeName,
|
|
383
|
+
description,
|
|
384
|
+
mapper,
|
|
385
|
+
coercion,
|
|
386
|
+
wrapOutput,
|
|
387
|
+
rawSchema,
|
|
388
|
+
version
|
|
389
|
+
});
|
|
390
|
+
}).filter(Boolean).join("");
|
|
353
391
|
let suffix = "";
|
|
354
392
|
const firstSchema = schemas.at(0);
|
|
355
393
|
const lastSchema = schemas.at(-1);
|
|
@@ -372,12 +410,12 @@ function Zod({ name, typeName, tree, rawSchema, inferTypeName, mapper, coercion,
|
|
|
372
410
|
rawSchema,
|
|
373
411
|
version
|
|
374
412
|
});
|
|
375
|
-
const baseSchemaOutput = [output, keysToOmit?.length ? `${suffix}.omit({ ${keysToOmit.map((key) =>
|
|
413
|
+
const baseSchemaOutput = [output, keysToOmit?.length ? `${suffix}.omit({ ${keysToOmit.map((key) => `'${key}': true`).join(",")} })` : void 0].filter(Boolean).join("") || emptyValue || "";
|
|
376
414
|
const wrappedSchemaOutput = wrapOutput ? wrapOutput({
|
|
377
415
|
output: baseSchemaOutput,
|
|
378
416
|
schema: rawSchema
|
|
379
417
|
}) || baseSchemaOutput : baseSchemaOutput;
|
|
380
|
-
const finalOutput = typeName ? `${wrappedSchemaOutput} as unknown as ToZod<${typeName}>` : wrappedSchemaOutput;
|
|
418
|
+
const finalOutput = typeName ? `${wrappedSchemaOutput} as unknown as ${version === "4" ? "z.ZodType" : "ToZod"}<${typeName}>` : wrappedSchemaOutput;
|
|
381
419
|
return /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(File.Source, {
|
|
382
420
|
name,
|
|
383
421
|
isExportable: true,
|
|
@@ -407,4 +445,4 @@ function Zod({ name, typeName, tree, rawSchema, inferTypeName, mapper, coercion,
|
|
|
407
445
|
|
|
408
446
|
//#endregion
|
|
409
447
|
export { Operations, Zod };
|
|
410
|
-
//# sourceMappingURL=components-
|
|
448
|
+
//# sourceMappingURL=components-B1-pLa6g.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-B1-pLa6g.js","names":["order: string[]","name","value","parserZod.sort","parserZod.parse"],"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\n//TODO add zodKeywordMapper as function that returns 3 versions: v3, v4 and v4 mini, this can also be used to have the custom mapping(see object type)\n// also include shouldCoerce\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: (value?: string) => {\n if (value) {\n return `z.nullable(${value})`\n }\n return '.nullable()'\n },\n null: () => 'z.null()',\n nullish: (value?: string) => {\n if (value) {\n return `z.nullish(${value})`\n }\n return '.nullish()'\n },\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 max: undefined,\n min: undefined,\n optional: (value?: string) => {\n if (value) {\n return `z.optional(${value})`\n }\n return '.optional()'\n },\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((it) => it.keyword === schemaKeywords.name) as SchemaKeywordMapper['name']\n const isNullable = schemas.some((it) => isKeyword(it, schemaKeywords.nullable))\n const isNullish = schemas.some((it) => isKeyword(it, schemaKeywords.nullish))\n const isOptional = schemas.some((it) => isKeyword(it, schemaKeywords.optional))\n\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 .filter((schema) => {\n return !isKeyword(schema, schemaKeywords.optional) && !isKeyword(schema, schemaKeywords.nullable) && !isKeyword(schema, schemaKeywords.nullish)\n })\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 // both optional and nullable\n if (isNullish) {\n return `get ${name}(){\n return ${zodKeywordMapper.nullish(objectValue)}\n }`\n }\n\n // undefined\n if (isOptional) {\n return `get ${name}(){\n return ${zodKeywordMapper.optional(objectValue)}\n }`\n }\n\n // null\n if (isNullable) {\n return `get ${name}(){\n return ${zodKeywordMapper.nullable(objectValue)}\n }`\n }\n\n return `get ${name}(){\n return ${objectValue}\n }`\n }\n\n // both optional and nullable\n if (isNullish) {\n return `\"${name}\": ${objectValue}${zodKeywordMapper.nullish()}`\n }\n\n // undefined\n if (isOptional) {\n return `\"${name}\": ${zodKeywordMapper.optional(objectValue)}`\n }\n\n // null\n if (isNullable) {\n return `\"${name}\": ${zodKeywordMapper.nullable(objectValue)}`\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 const minSchema = SchemaGenerator.find(siblings, schemaKeywords.min)\n const maxSchema = SchemaGenerator.find(siblings, schemaKeywords.max)\n\n return zodKeywordMapper.string(shouldCoerce(options.coercion, 'strings'), minSchema?.args, maxSchema?.args)\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 const minSchema = SchemaGenerator.find(siblings, schemaKeywords.min)\n const maxSchema = SchemaGenerator.find(siblings, schemaKeywords.max)\n\n return zodKeywordMapper.number(shouldCoerce(options.coercion, 'numbers'), minSchema?.args, maxSchema?.args)\n }\n\n if (isKeyword(current, schemaKeywords.integer)) {\n const minSchema = SchemaGenerator.find(siblings, schemaKeywords.min)\n const maxSchema = SchemaGenerator.find(siblings, schemaKeywords.max)\n\n return zodKeywordMapper.integer(shouldCoerce(options.coercion, 'numbers'), minSchema?.args, maxSchema?.args, options.version)\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 (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) => {\n const siblings = schemas.filter((_, i) => i !== index)\n\n return 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 ${version === '4' ? 'z.ZodType' : '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,cAAqB;CACtD,MAAM,iBAAiB,WAAW,QAC/B,MAAM,QAAQ;AACb,OAAK,IAAI,IAAI,UAAU,gBAAgB,CAAC,MAAM,IAAI;AAElD,SAAO;IAET,EAAE,CACH;CAED,MAAM,YAAY,WAAW,QAC1B,MAAM,QAAQ;AACb,OAAK,IAAI,IAAI,UAAU,KAAK,MAAM;GAChC,GAAI,KAAK,IAAI,IAAI,UAAU,KAAK,OAAQ,EAAE;IACzC,IAAI,UAAU,SAAS,eAAe,IAAI,UAAU,gBAAgB,CAAC;GACvE;AAED,SAAO;IAET,EAAE,CACH;AAED,QACE,4CACE,oBAAC,KAAK;EAAa;EAAM;EAAa;YACpC,oBAAC;GAAM;GAAa;GAAM;aACvB,IAAI,aAAa,gBAAgB,eAAe,CAAC;IAC5C;GACI,EACd,oBAAC,KAAK;EAAO,MAAM;EAAS;EAAa;YACvC,oBAAC;GAAM;GAAO,MAAM;GAAS;aAC1B,IAAI,aAAa,gBAAgB,UAAU,CAAC;IACvC;GACI,IACb;;;;;ACpCP,MAAM,mBAAmB;CACvB,WAAW;CACX,eAAe;CACf,YAAY;CACZ,SAAS,UAAoB,KAAc,QAAiB;AAC1D,SAAO;GAAC,WAAW,sBAAsB;GAAc,QAAQ,SAAY,QAAQ,IAAI,KAAK;GAAW,QAAQ,SAAY,QAAQ,IAAI,KAAK;GAAU,CACnJ,OAAO,QAAQ,CACf,KAAK,GAAG;;CAEb,UAAU,U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AAK,IAAI,CAAC,OAAO,OAAU,CAAC,OAAO,QAAQ,CAAC,KAAK,GAAG,IAChJ,cACA;CACF,MAAM,sBAAsB,aAAa,WAAW;EAAE,QAAQ;EAAkB,QAAQ;EAAW,CAAC,IAAI,mBAAmB;CAC3H,MAAM,cAAc,WAAW,GAAG,oBAAoB,iBAAiB,YAAY,MAAM,cAAc,QAAQ,GAAG,SAAS,KAAK;AAEhI,QACE,4CACE,oBAAC,KAAK;EAAa;EAAM;EAAa;YACpC,oBAAC;GACC;GACM;GACN,OAAO,EACL,UAAU,CAAC,cAAc,gBAAgB,aAAa,eAAe,YAAY,KAAK,OAAU,CAAC,OAAO,QAAQ,EACjH;aAEA;IACK;GACI,EACb,iBACC,qBAAC,KAAK;EAAO,MAAM;EAAe;EAAa;EAAY;aACxD,YACC,oBAAC;GAAK;GAAO,MAAM;aAChB;IACI,EAER,CAAC,YACA,oBAAC;GAAK;GAAO,MAAM;aAChB,kBAAkB,KAAK;IACnB;GAEG,IAEf"}
|
|
@@ -114,9 +114,15 @@ const zodKeywordMapper = {
|
|
|
114
114
|
},
|
|
115
115
|
boolean: () => "z.boolean()",
|
|
116
116
|
undefined: () => "z.undefined()",
|
|
117
|
-
nullable: () =>
|
|
117
|
+
nullable: (value) => {
|
|
118
|
+
if (value) return `z.nullable(${value})`;
|
|
119
|
+
return ".nullable()";
|
|
120
|
+
},
|
|
118
121
|
null: () => "z.null()",
|
|
119
|
-
nullish: () =>
|
|
122
|
+
nullish: (value) => {
|
|
123
|
+
if (value) return `z.nullish(${value})`;
|
|
124
|
+
return ".nullish()";
|
|
125
|
+
},
|
|
120
126
|
array: (items = [], min, max, unique) => {
|
|
121
127
|
return [
|
|
122
128
|
`z.array(${items?.join("")})`,
|
|
@@ -152,9 +158,12 @@ const zodKeywordMapper = {
|
|
|
152
158
|
},
|
|
153
159
|
and: (items = []) => items?.map((item) => `.and(${item})`).join(""),
|
|
154
160
|
describe: (value = "") => `.describe(${value})`,
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
optional: () =>
|
|
161
|
+
max: void 0,
|
|
162
|
+
min: void 0,
|
|
163
|
+
optional: (value) => {
|
|
164
|
+
if (value) return `z.optional(${value})`;
|
|
165
|
+
return ".optional()";
|
|
166
|
+
},
|
|
158
167
|
matches: (value = "", coercion) => coercion ? `z.coerce.string().regex(${value})` : `z.string().regex(${value})`,
|
|
159
168
|
email: (coercion, version = "3") => version === "4" ? coercion ? "z.coerce.string().email()" : "z.email()" : coercion ? "z.coerce.string().email()" : "z.string().email()",
|
|
160
169
|
firstName: void 0,
|
|
@@ -287,9 +296,15 @@ function parse({ parent, current, name, siblings }, options) {
|
|
|
287
296
|
const schema = item[1];
|
|
288
297
|
return schema && typeof schema.map === "function";
|
|
289
298
|
}).map(([name$1, schemas]) => {
|
|
290
|
-
const
|
|
299
|
+
const nameSchema = schemas.find((it) => it.keyword === __kubb_plugin_oas.schemaKeywords.name);
|
|
300
|
+
const isNullable = schemas.some((it) => (0, __kubb_plugin_oas.isKeyword)(it, __kubb_plugin_oas.schemaKeywords.nullable));
|
|
301
|
+
const isNullish = schemas.some((it) => (0, __kubb_plugin_oas.isKeyword)(it, __kubb_plugin_oas.schemaKeywords.nullish));
|
|
302
|
+
const isOptional = schemas.some((it) => (0, __kubb_plugin_oas.isKeyword)(it, __kubb_plugin_oas.schemaKeywords.optional));
|
|
303
|
+
const mappedName = nameSchema?.args || name$1;
|
|
291
304
|
if (options.mapper?.[mappedName]) return `"${name$1}": ${options.mapper?.[mappedName]}`;
|
|
292
|
-
const baseSchemaOutput = sort(schemas).
|
|
305
|
+
const baseSchemaOutput = sort(schemas).filter((schema) => {
|
|
306
|
+
return !(0, __kubb_plugin_oas.isKeyword)(schema, __kubb_plugin_oas.schemaKeywords.optional) && !(0, __kubb_plugin_oas.isKeyword)(schema, __kubb_plugin_oas.schemaKeywords.nullable) && !(0, __kubb_plugin_oas.isKeyword)(schema, __kubb_plugin_oas.schemaKeywords.nullish);
|
|
307
|
+
}).map((schema) => parse({
|
|
293
308
|
parent: current,
|
|
294
309
|
name: name$1,
|
|
295
310
|
current: schema,
|
|
@@ -299,9 +314,23 @@ function parse({ parent, current, name, siblings }, options) {
|
|
|
299
314
|
output: baseSchemaOutput,
|
|
300
315
|
schema: options.rawSchema?.properties?.[name$1]
|
|
301
316
|
}) || baseSchemaOutput : baseSchemaOutput;
|
|
302
|
-
if (options.version === "4" && __kubb_plugin_oas.SchemaGenerator.find(schemas, __kubb_plugin_oas.schemaKeywords.ref))
|
|
317
|
+
if (options.version === "4" && __kubb_plugin_oas.SchemaGenerator.find(schemas, __kubb_plugin_oas.schemaKeywords.ref)) {
|
|
318
|
+
if (isNullish) return `get ${name$1}(){
|
|
319
|
+
return ${zodKeywordMapper.nullish(objectValue)}
|
|
320
|
+
}`;
|
|
321
|
+
if (isOptional) return `get ${name$1}(){
|
|
322
|
+
return ${zodKeywordMapper.optional(objectValue)}
|
|
323
|
+
}`;
|
|
324
|
+
if (isNullable) return `get ${name$1}(){
|
|
325
|
+
return ${zodKeywordMapper.nullable(objectValue)}
|
|
326
|
+
}`;
|
|
327
|
+
return `get ${name$1}(){
|
|
303
328
|
return ${objectValue}
|
|
304
329
|
}`;
|
|
330
|
+
}
|
|
331
|
+
if (isNullish) return `"${name$1}": ${objectValue}${zodKeywordMapper.nullish()}`;
|
|
332
|
+
if (isOptional) return `"${name$1}": ${zodKeywordMapper.optional(objectValue)}`;
|
|
333
|
+
if (isNullable) return `"${name$1}": ${zodKeywordMapper.nullable(objectValue)}`;
|
|
305
334
|
return `"${name$1}": ${objectValue}`;
|
|
306
335
|
}).join(",\n");
|
|
307
336
|
const additionalProperties = current.args?.additionalProperties?.length ? current.args.additionalProperties.map((schema, _index, siblings$1) => parse({
|
|
@@ -332,14 +361,24 @@ function parse({ parent, current, name, siblings }, options) {
|
|
|
332
361
|
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.describe)) {
|
|
333
362
|
if (current.args) return zodKeywordMapper.describe(__kubb_core_transformers.default.stringify(current.args.toString()));
|
|
334
363
|
}
|
|
335
|
-
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.string))
|
|
364
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.string)) {
|
|
365
|
+
const minSchema = __kubb_plugin_oas.SchemaGenerator.find(siblings, __kubb_plugin_oas.schemaKeywords.min);
|
|
366
|
+
const maxSchema = __kubb_plugin_oas.SchemaGenerator.find(siblings, __kubb_plugin_oas.schemaKeywords.max);
|
|
367
|
+
return zodKeywordMapper.string(shouldCoerce(options.coercion, "strings"), minSchema?.args, maxSchema?.args);
|
|
368
|
+
}
|
|
336
369
|
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.uuid)) return zodKeywordMapper.uuid(shouldCoerce(options.coercion, "strings"), options.version);
|
|
337
370
|
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.email)) return zodKeywordMapper.email(shouldCoerce(options.coercion, "strings"), options.version);
|
|
338
371
|
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.url)) return zodKeywordMapper.url(shouldCoerce(options.coercion, "strings"), options.version);
|
|
339
|
-
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.number))
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
372
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.number)) {
|
|
373
|
+
const minSchema = __kubb_plugin_oas.SchemaGenerator.find(siblings, __kubb_plugin_oas.schemaKeywords.min);
|
|
374
|
+
const maxSchema = __kubb_plugin_oas.SchemaGenerator.find(siblings, __kubb_plugin_oas.schemaKeywords.max);
|
|
375
|
+
return zodKeywordMapper.number(shouldCoerce(options.coercion, "numbers"), minSchema?.args, maxSchema?.args);
|
|
376
|
+
}
|
|
377
|
+
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.integer)) {
|
|
378
|
+
const minSchema = __kubb_plugin_oas.SchemaGenerator.find(siblings, __kubb_plugin_oas.schemaKeywords.min);
|
|
379
|
+
const maxSchema = __kubb_plugin_oas.SchemaGenerator.find(siblings, __kubb_plugin_oas.schemaKeywords.max);
|
|
380
|
+
return zodKeywordMapper.integer(shouldCoerce(options.coercion, "numbers"), minSchema?.args, maxSchema?.args, options.version);
|
|
381
|
+
}
|
|
343
382
|
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.datetime)) return zodKeywordMapper.datetime(current.args.offset, current.args.local, options.version);
|
|
344
383
|
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.date)) return zodKeywordMapper.date(current.args.type, shouldCoerce(options.coercion, "dates"), options.version);
|
|
345
384
|
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.time)) return zodKeywordMapper.time(current.args.type, shouldCoerce(options.coercion, "dates"), options.version);
|
|
@@ -347,10 +386,6 @@ function parse({ parent, current, name, siblings }, options) {
|
|
|
347
386
|
const value$1 = zodKeywordMapper[current.keyword];
|
|
348
387
|
return value$1(current.args);
|
|
349
388
|
}
|
|
350
|
-
if ((0, __kubb_plugin_oas.isKeyword)(current, __kubb_plugin_oas.schemaKeywords.optional)) {
|
|
351
|
-
if (siblings.some((schema) => (0, __kubb_plugin_oas.isKeyword)(schema, __kubb_plugin_oas.schemaKeywords.default))) return "";
|
|
352
|
-
return value();
|
|
353
|
-
}
|
|
354
389
|
if (current.keyword in zodKeywordMapper) return value();
|
|
355
390
|
}
|
|
356
391
|
|
|
@@ -362,21 +397,24 @@ function Zod({ name, typeName, tree, rawSchema, inferTypeName, mapper, coercion,
|
|
|
362
397
|
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
398
|
return true;
|
|
364
399
|
});
|
|
365
|
-
const output = schemas.map((schema,
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
400
|
+
const output = schemas.map((schema, index) => {
|
|
401
|
+
const siblings = schemas.filter((_, i) => i !== index);
|
|
402
|
+
return parse({
|
|
403
|
+
parent: void 0,
|
|
404
|
+
current: schema,
|
|
405
|
+
siblings
|
|
406
|
+
}, {
|
|
407
|
+
name,
|
|
408
|
+
keysToOmit,
|
|
409
|
+
typeName,
|
|
410
|
+
description,
|
|
411
|
+
mapper,
|
|
412
|
+
coercion,
|
|
413
|
+
wrapOutput,
|
|
414
|
+
rawSchema,
|
|
415
|
+
version
|
|
416
|
+
});
|
|
417
|
+
}).filter(Boolean).join("");
|
|
380
418
|
let suffix = "";
|
|
381
419
|
const firstSchema = schemas.at(0);
|
|
382
420
|
const lastSchema = schemas.at(-1);
|
|
@@ -399,12 +437,12 @@ function Zod({ name, typeName, tree, rawSchema, inferTypeName, mapper, coercion,
|
|
|
399
437
|
rawSchema,
|
|
400
438
|
version
|
|
401
439
|
});
|
|
402
|
-
const baseSchemaOutput = [output, keysToOmit?.length ? `${suffix}.omit({ ${keysToOmit.map((key) =>
|
|
440
|
+
const baseSchemaOutput = [output, keysToOmit?.length ? `${suffix}.omit({ ${keysToOmit.map((key) => `'${key}': true`).join(",")} })` : void 0].filter(Boolean).join("") || emptyValue || "";
|
|
403
441
|
const wrappedSchemaOutput = wrapOutput ? wrapOutput({
|
|
404
442
|
output: baseSchemaOutput,
|
|
405
443
|
schema: rawSchema
|
|
406
444
|
}) || baseSchemaOutput : baseSchemaOutput;
|
|
407
|
-
const finalOutput = typeName ? `${wrappedSchemaOutput} as unknown as ToZod<${typeName}>` : wrappedSchemaOutput;
|
|
445
|
+
const finalOutput = typeName ? `${wrappedSchemaOutput} as unknown as ${version === "4" ? "z.ZodType" : "ToZod"}<${typeName}>` : wrappedSchemaOutput;
|
|
408
446
|
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
447
|
name,
|
|
410
448
|
isExportable: true,
|
|
@@ -451,4 +489,4 @@ Object.defineProperty(exports, '__toESM', {
|
|
|
451
489
|
return __toESM;
|
|
452
490
|
}
|
|
453
491
|
});
|
|
454
|
-
//# sourceMappingURL=components-
|
|
492
|
+
//# sourceMappingURL=components-C6PNc1ua.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"components-C6PNc1ua.cjs","names":["File","Const","transformers","order: string[]","schemaKeywords","transformers","name","SchemaGenerator","value","SchemaGenerator","schemaKeywords","parserZod.sort","parserZod.parse","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\n//TODO add zodKeywordMapper as function that returns 3 versions: v3, v4 and v4 mini, this can also be used to have the custom mapping(see object type)\n// also include shouldCoerce\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: (value?: string) => {\n if (value) {\n return `z.nullable(${value})`\n }\n return '.nullable()'\n },\n null: () => 'z.null()',\n nullish: (value?: string) => {\n if (value) {\n return `z.nullish(${value})`\n }\n return '.nullish()'\n },\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 max: undefined,\n min: undefined,\n optional: (value?: string) => {\n if (value) {\n return `z.optional(${value})`\n }\n return '.optional()'\n },\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((it) => it.keyword === schemaKeywords.name) as SchemaKeywordMapper['name']\n const isNullable = schemas.some((it) => isKeyword(it, schemaKeywords.nullable))\n const isNullish = schemas.some((it) => isKeyword(it, schemaKeywords.nullish))\n const isOptional = schemas.some((it) => isKeyword(it, schemaKeywords.optional))\n\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 .filter((schema) => {\n return !isKeyword(schema, schemaKeywords.optional) && !isKeyword(schema, schemaKeywords.nullable) && !isKeyword(schema, schemaKeywords.nullish)\n })\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 // both optional and nullable\n if (isNullish) {\n return `get ${name}(){\n return ${zodKeywordMapper.nullish(objectValue)}\n }`\n }\n\n // undefined\n if (isOptional) {\n return `get ${name}(){\n return ${zodKeywordMapper.optional(objectValue)}\n }`\n }\n\n // null\n if (isNullable) {\n return `get ${name}(){\n return ${zodKeywordMapper.nullable(objectValue)}\n }`\n }\n\n return `get ${name}(){\n return ${objectValue}\n }`\n }\n\n // both optional and nullable\n if (isNullish) {\n return `\"${name}\": ${objectValue}${zodKeywordMapper.nullish()}`\n }\n\n // undefined\n if (isOptional) {\n return `\"${name}\": ${zodKeywordMapper.optional(objectValue)}`\n }\n\n // null\n if (isNullable) {\n return `\"${name}\": ${zodKeywordMapper.nullable(objectValue)}`\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 const minSchema = SchemaGenerator.find(siblings, schemaKeywords.min)\n const maxSchema = SchemaGenerator.find(siblings, schemaKeywords.max)\n\n return zodKeywordMapper.string(shouldCoerce(options.coercion, 'strings'), minSchema?.args, maxSchema?.args)\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 const minSchema = SchemaGenerator.find(siblings, schemaKeywords.min)\n const maxSchema = SchemaGenerator.find(siblings, schemaKeywords.max)\n\n return zodKeywordMapper.number(shouldCoerce(options.coercion, 'numbers'), minSchema?.args, maxSchema?.args)\n }\n\n if (isKeyword(current, schemaKeywords.integer)) {\n const minSchema = SchemaGenerator.find(siblings, schemaKeywords.min)\n const maxSchema = SchemaGenerator.find(siblings, schemaKeywords.max)\n\n return zodKeywordMapper.integer(shouldCoerce(options.coercion, 'numbers'), minSchema?.args, maxSchema?.args, options.version)\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 (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) => {\n const siblings = schemas.filter((_, i) => i !== index)\n\n return 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 ${version === '4' ? 'z.ZodType' : '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,cAAqB;CACtD,MAAM,iBAAiB,WAAW,QAC/B,MAAM,QAAQ;AACb,OAAK,IAAI,IAAI,UAAU,gBAAgB,CAAC,MAAM,IAAI;AAElD,SAAO;IAET,EAAE,CACH;CAED,MAAM,YAAY,WAAW,QAC1B,MAAM,QAAQ;AACb,OAAK,IAAI,IAAI,UAAU,KAAK,MAAM;GAChC,GAAI,KAAK,IAAI,IAAI,UAAU,KAAK,OAAQ,EAAE;IACzC,IAAI,UAAU,SAAS,eAAe,IAAI,UAAU,gBAAgB,CAAC;GACvE;AAED,SAAO;IAET,EAAE,CACH;AAED,QACE,mGACE,kDAACA,kBAAK;EAAa;EAAM;EAAa;YACpC,kDAACC;GAAM;GAAa;GAAM;aACvB,IAAIC,iCAAa,gBAAgB,eAAe,CAAC;IAC5C;GACI,EACd,kDAACF,kBAAK;EAAO,MAAM;EAAS;EAAa;YACvC,kDAACC;GAAM;GAAO,MAAM;GAAS;aAC1B,IAAIC,iCAAa,gBAAgB,UAAU,CAAC;IACvC;GACI,IACb;;;;;ACpCP,MAAM,mBAAmB;CACvB,WAAW;CACX,eAAe;CACf,YAAY;CACZ,SAAS,UAAoB,KAAc,QAAiB;AAC1D,SAAO;GAAC,WAAW,sBAAsB;GAAc,QAAQ,SAAY,QAAQ,IAAI,KAAK;GAAW,QAAQ,SAAY,QAAQ,IAAI,KAAK;GAAU,CACnJ,OAAO,QAAQ,CACf,KAAK,GAAG;;CAEb,UAAU,UAAoB,KAAc,KAAc,UAAqB,QAAQ;AACrF,SAAO;GACL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AAQ,CAAC,KAAK,GAAG,IAChJ,cACA;CACF,MAAM,sBAAsB,aAAa,WAAW;EAAE,QAAQ;EAAkB,QAAQ;EAAW,CAAC,IAAI,mBAAmB;CAC3H,MAAM,cAAc,WAAW,GAAG,oBAAoB,iBAAiB,YAAY,MAAM,cAAc,QAAQ,GAAG,SAAS,KAAK;AAEhI,QACE,mGACE,kDAACG,kBAAK;EAAa;EAAM;EAAa;YACpC,kDAACC;GACC;GACM;GACN,OAAO,EACL,UAAU,CAAC,cAAc,gBAAgBC,iCAAa,eAAe,YAAY,KAAK,OAAU,CAAC,OAAO,QAAQ,EACjH;aAEA;IACK;GACI,EACb,iBACC,mDAACF,kBAAK;EAAO,MAAM;EAAe;EAAa;EAAY;aACxD,YACC,kDAACG;GAAK;GAAO,MAAM;aAChB;IACI,EAER,CAAC,YACA,kDAACA;GAAK;GAAO,MAAM;aAChB,kBAAkB,KAAK;IACnB;GAEG,IAEf"}
|
package/dist/components.cjs
CHANGED
package/dist/components.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const require_components = require('./components-
|
|
1
|
+
const require_components = require('./components-C6PNc1ua.cjs');
|
|
2
2
|
let __kubb_plugin_oas = require("@kubb/plugin-oas");
|
|
3
3
|
__kubb_plugin_oas = require_components.__toESM(__kubb_plugin_oas);
|
|
4
4
|
let __kubb_plugin_ts = require("@kubb/plugin-ts");
|
|
@@ -81,9 +81,9 @@ const zodGenerator = (0, __kubb_plugin_oas.createReactGenerator)({
|
|
|
81
81
|
path: type.file.path,
|
|
82
82
|
name: [type.name]
|
|
83
83
|
}),
|
|
84
|
-
typed && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
|
|
84
|
+
typed && plugin.options.version === "3" && /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
|
|
85
85
|
isTypeOnly: true,
|
|
86
|
-
path:
|
|
86
|
+
path: "@kubb/plugin-zod/utils",
|
|
87
87
|
name: ["ToZod"]
|
|
88
88
|
}),
|
|
89
89
|
imports.map((imp) => /* @__PURE__ */ (0, __kubb_react_jsx_runtime.jsx)(__kubb_react.File.Import, {
|
|
@@ -269,4 +269,4 @@ Object.defineProperty(exports, 'zodGenerator', {
|
|
|
269
269
|
return zodGenerator;
|
|
270
270
|
}
|
|
271
271
|
});
|
|
272
|
-
//# sourceMappingURL=generators-
|
|
272
|
+
//# sourceMappingURL=generators-8iZ6rvz2.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"generators-8iZ6rvz2.cjs","names":["SchemaGenerator","options","schemaKeywords","pluginTsName","Oas","File","Zod","File","Operations"],"sources":["../src/generators/zodGenerator.tsx","../src/generators/operationsGenerator.tsx"],"sourcesContent":["import { createReactGenerator, type OperationSchema as OperationSchemaType, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { Oas } from '@kubb/plugin-oas/components'\nimport { useOas, useOperationManager, useSchemaManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { pluginTsName } from '@kubb/plugin-ts'\nimport { File, useApp } from '@kubb/react'\nimport { Zod } from '../components'\nimport type { PluginZod } from '../types'\n\nexport const zodGenerator = createReactGenerator<PluginZod>({\n name: 'zod',\n Operation({ operation, options }) {\n const { coercion: globalCoercion, inferred, typed, mapper, wrapOutput } = options\n\n const { plugin, pluginManager, mode } = useApp<PluginZod>()\n const oas = useOas()\n const { getSchemas, getFile, getGroup } = useOperationManager()\n const schemaManager = useSchemaManager()\n\n const file = getFile(operation)\n const schemas = getSchemas(operation)\n const schemaGenerator = new SchemaGenerator(options, {\n oas,\n plugin,\n pluginManager,\n mode,\n override: options.override,\n })\n\n const operationSchemas = [schemas.pathParams, schemas.queryParams, schemas.headerParams, schemas.statusCodes, schemas.request, schemas.response]\n .flat()\n .filter(Boolean)\n\n const mapOperationSchema = ({ name, schema: schemaObject, description, keysToOmit, ...options }: OperationSchemaType, i: number) => {\n // hack so Params can be optional when needed\n const required = Array.isArray(schemaObject?.required) ? !!schemaObject.required.length : !!schemaObject?.required\n const someDefaults = Object.values(schemaObject.properties || {}).some((property) => Object.hasOwn(property, 'default') && property.default !== undefined)\n const optional = !required && !someDefaults && name.includes('Params')\n\n const tree = [...schemaGenerator.parse({ schemaObject, name }), optional ? { keyword: schemaKeywords.optional } : undefined].filter(Boolean)\n const imports = schemaManager.getImports(tree)\n const group = options.operation ? getGroup(options.operation) : undefined\n\n const coercion = name.includes('Params') ? { numbers: true, strings: false, dates: true } : globalCoercion\n\n const zod = {\n name: schemaManager.getName(name, { type: 'function' }),\n inferTypeName: schemaManager.getName(name, { type: 'type' }),\n file: schemaManager.getFile(name),\n }\n\n const type = {\n name: schemaManager.getName(name, {\n type: 'type',\n pluginKey: [pluginTsName],\n }),\n file: schemaManager.getFile(options.operationName || name, {\n pluginKey: [pluginTsName],\n group,\n }),\n }\n\n return (\n <Oas.Schema key={i} name={name} schemaObject={schemaObject} tree={tree}>\n {typed && <File.Import isTypeOnly root={file.path} path={type.file.path} name={[type.name]} />}\n {typed && plugin.options.version === '3' && <File.Import isTypeOnly path={'@kubb/plugin-zod/utils'} name={['ToZod']} />}\n {imports.map((imp) => (\n <File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} root={file.path} path={imp.path} name={imp.name} />\n ))}\n <Zod\n name={zod.name}\n typeName={typed ? type.name : undefined}\n inferTypeName={inferred ? zod.inferTypeName : undefined}\n description={description}\n tree={tree}\n rawSchema={schemaObject}\n mapper={mapper}\n coercion={coercion}\n keysToOmit={keysToOmit}\n wrapOutput={wrapOutput}\n version={plugin.options.version}\n emptySchemaType={plugin.options.emptySchemaType}\n />\n </Oas.Schema>\n )\n }\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output: plugin.options.output, config: pluginManager.config })}\n footer={getFooter({ oas, output: plugin.options.output })}\n >\n <File.Import name={['z']} path={plugin.options.importPath} />\n {operationSchemas.map(mapOperationSchema)}\n </File>\n )\n },\n Schema({ schema, options }) {\n const { coercion, inferred, typed, mapper, importPath, wrapOutput, version } = options\n\n const { getName, getFile, getImports } = useSchemaManager()\n const {\n pluginManager,\n plugin: {\n options: { output, emptySchemaType },\n },\n } = useApp<PluginZod>()\n const oas = useOas()\n\n const imports = getImports(schema.tree)\n\n const zod = {\n name: getName(schema.name, { type: 'function' }),\n inferTypeName: getName(schema.name, { type: 'type' }),\n file: getFile(schema.name),\n }\n\n const type = {\n name: getName(schema.name, { type: 'type', pluginKey: [pluginTsName] }),\n file: getFile(schema.name, { pluginKey: [pluginTsName] }),\n }\n\n return (\n <File\n baseName={zod.file.baseName}\n path={zod.file.path}\n meta={zod.file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n <File.Import name={['z']} path={importPath} />\n {typed && <File.Import isTypeOnly root={zod.file.path} path={type.file.path} name={[type.name]} />}\n {typed && <File.Import isTypeOnly path={options.version === '4' ? '@kubb/plugin-zod/utils/v4' : '@kubb/plugin-zod/utils'} name={['ToZod']} />}\n {imports.map((imp) => (\n <File.Import key={[imp.path, imp.name, imp.isTypeOnly].join('-')} root={zod.file.path} path={imp.path} name={imp.name} />\n ))}\n\n <Zod\n name={zod.name}\n typeName={typed ? type.name : undefined}\n inferTypeName={inferred ? zod.inferTypeName : undefined}\n description={schema.value.description}\n tree={schema.tree}\n rawSchema={schema.value}\n mapper={mapper}\n coercion={coercion}\n wrapOutput={wrapOutput}\n version={version}\n emptySchemaType={emptySchemaType}\n />\n </File>\n )\n },\n})\n","import { createReactGenerator } from '@kubb/plugin-oas'\nimport { useOas, useOperationManager } from '@kubb/plugin-oas/hooks'\nimport { getBanner, getFooter } from '@kubb/plugin-oas/utils'\nimport { File, useApp } from '@kubb/react'\nimport { Operations } from '../components/Operations'\nimport type { PluginZod } from '../types'\n\nexport const operationsGenerator = createReactGenerator<PluginZod>({\n name: 'operations',\n Operations({ operations }) {\n const {\n pluginManager,\n plugin: {\n key: pluginKey,\n options: { output },\n },\n } = useApp<PluginZod>()\n const oas = useOas()\n const { getFile, groupSchemasByName } = useOperationManager()\n\n const name = 'operations'\n const file = pluginManager.getFile({ name, extname: '.ts', pluginKey })\n\n const transformedOperations = operations.map((operation) => ({ operation, data: groupSchemasByName(operation, { type: 'function' }) }))\n\n const imports = Object.entries(transformedOperations)\n .map(([key, { data, operation }]) => {\n const names = [data.request, ...Object.values(data.responses), ...Object.values(data.parameters)].filter(Boolean)\n\n return <File.Import key={key} name={names} root={file.path} path={getFile(operation).path} />\n })\n .filter(Boolean)\n\n return (\n <File\n baseName={file.baseName}\n path={file.path}\n meta={file.meta}\n banner={getBanner({ oas, output, config: pluginManager.config })}\n footer={getFooter({ oas, output })}\n >\n {imports}\n <Operations name={name} operations={transformedOperations} />\n </File>\n )\n },\n})\n"],"mappings":";;;;;;;;;;;;;;;;;AASA,MAAa,2DAA+C;CAC1D,MAAM;CACN,UAAU,EAAE,WAAW,WAAW;EAChC,MAAM,EAAE,UAAU,gBAAgB,UAAU,OAAO,QAAQ,eAAe;EAE1E,MAAM,EAAE,QAAQ,eAAe,mCAA4B;EAC3D,MAAM,2CAAc;EACpB,MAAM,EAAE,YAAY,SAAS,+DAAkC;EAC/D,MAAM,+DAAkC;EAExC,MAAM,OAAO,QAAQ,UAAU;EAC/B,MAAM,UAAU,WAAW,UAAU;EACrC,MAAM,kBAAkB,IAAIA,kCAAgB,SAAS;GACnD;GACA;GACA;GACA;GACA,UAAU,QAAQ;GACnB,CAAC;EAEF,MAAM,mBAAmB;GAAC,QAAQ;GAAY,QAAQ;GAAa,QAAQ;GAAc,QAAQ;GAAa,QAAQ;GAAS,QAAQ;GAAS,CAC7I,MAAM,CACN,OAAO,QAAQ;EAElB,MAAM,sBAAsB,EAAE,MAAM,QAAQ,cAAc,aAAa,WAAY,GAAGC,aAAgC,MAAc;GAElI,MAAM,WAAW,MAAM,QAAQ,cAAc,SAAS,GAA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AAY,CAAC;GAAE,EAAE;EAEvI,MAAM,UAAU,OAAO,QAAQ,sBAAsB,CAClD,KAAK,CAAC,KAAK,EAAE,MAAM,iBAAiB;GACnC,MAAM,QAAQ;IAAC,KAAK;IAAS,GAAG,OAAO,OAAO,KAAK,UAAU;IAAE,GAAG,OAAO,OAAO,KAAK,WAAW;IAAC,CAAC,OAAO,QAAQ;AAEjH,UAAO,kDAACC,kBAAK;IAAiB,MAAM;IAAO,MAAM,KAAK;IAAM,MAAM,QAAQ,UAAU,CAAC;MAA5D,IAAoE;IAC7F,CACD,OAAO,QAAQ;AAElB,SACE,mDAACA;GACC,UAAU,KAAK;GACf,MAAM,KAAK;GACX,MAAM,KAAK;GACX,+CAAkB;IAAE;IAAK;IAAQ,QAAQ,cAAc;IAAQ,CAAC;GAChE,+CAAkB;IAAE;IAAK;IAAQ,CAAC;cAEjC,SACD,kDAACC;IAAiB;IAAM,YAAY;KAAyB;IACxD;;CAGZ,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Operations, Zod } from "./components-
|
|
1
|
+
import { Operations, Zod } from "./components-B1-pLa6g.js";
|
|
2
2
|
import { SchemaGenerator, createReactGenerator, schemaKeywords } from "@kubb/plugin-oas";
|
|
3
3
|
import { pluginTsName } from "@kubb/plugin-ts";
|
|
4
4
|
import { Oas } from "@kubb/plugin-oas/components";
|
|
@@ -74,9 +74,9 @@ const zodGenerator = createReactGenerator({
|
|
|
74
74
|
path: type.file.path,
|
|
75
75
|
name: [type.name]
|
|
76
76
|
}),
|
|
77
|
-
typed && /* @__PURE__ */ jsx(File.Import, {
|
|
77
|
+
typed && plugin.options.version === "3" && /* @__PURE__ */ jsx(File.Import, {
|
|
78
78
|
isTypeOnly: true,
|
|
79
|
-
path:
|
|
79
|
+
path: "@kubb/plugin-zod/utils",
|
|
80
80
|
name: ["ToZod"]
|
|
81
81
|
}),
|
|
82
82
|
imports.map((imp) => /* @__PURE__ */ jsx(File.Import, {
|
|
@@ -251,4 +251,4 @@ const operationsGenerator = createReactGenerator({
|
|
|
251
251
|
|
|
252
252
|
//#endregion
|
|
253
253
|
export { operationsGenerator, zodGenerator };
|
|
254
|
-
//# sourceMappingURL=generators-
|
|
254
|
+
//# sourceMappingURL=generators-B66sl9uI.js.map
|