@kubb/plugin-zod 3.18.3 → 4.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/dist/{components-GvkeO2ig.cjs → components-DQw9romi.cjs} +85 -47
  2. package/dist/components-DQw9romi.cjs.map +1 -0
  3. package/dist/{components-CJ6RN1R2.js → components-GBbHstRa.js} +77 -43
  4. package/dist/components-GBbHstRa.js.map +1 -0
  5. package/dist/components.cjs +1 -1
  6. package/dist/components.js +1 -1
  7. package/dist/{generators-C3ALr3ph.js → generators-C6LY9NRE.js} +2 -2
  8. package/dist/{generators-C3ALr3ph.js.map → generators-C6LY9NRE.js.map} +1 -1
  9. package/dist/{generators-D3uH7-vO.cjs → generators-CfwuO_nS.cjs} +16 -9
  10. package/dist/{generators-D3uH7-vO.cjs.map → generators-CfwuO_nS.cjs.map} +1 -1
  11. package/dist/generators.cjs +2 -2
  12. package/dist/generators.js +2 -2
  13. package/dist/index.cjs +17 -15
  14. package/dist/index.cjs.map +1 -1
  15. package/dist/index.js +7 -10
  16. package/dist/index.js.map +1 -1
  17. package/package.json +9 -10
  18. package/src/components/Zod.tsx +7 -5
  19. package/src/generators/__snapshots__/coercion.ts +5 -8
  20. package/src/generators/__snapshots__/coercionDates.ts +5 -8
  21. package/src/generators/__snapshots__/coercionNumbers.ts +5 -8
  22. package/src/generators/__snapshots__/coercionStrings.ts +5 -8
  23. package/src/generators/__snapshots__/deletePet.ts +1 -1
  24. package/src/generators/__snapshots__/deletePet_wrapOutput.ts +1 -1
  25. package/src/generators/__snapshots__/example.ts +1 -1
  26. package/src/generators/__snapshots__/getPets.ts +2 -2
  27. package/src/generators/__snapshots__/getPets_wrapOutput.ts +2 -2
  28. package/src/generators/__snapshots__/nullable.ts +1 -1
  29. package/src/generators/__snapshots__/oneof.ts +2 -2
  30. package/src/generators/__snapshots__/optionalPetInfer.ts +3 -3
  31. package/src/generators/__snapshots__/optionalPetTyped.ts +3 -3
  32. package/src/generators/__snapshots__/order.ts +6 -6
  33. package/src/generators/__snapshots__/orderDateTypeFalse.ts +6 -6
  34. package/src/generators/__snapshots__/orderDateTypeString.ts +6 -6
  35. package/src/generators/__snapshots__/pet.ts +5 -8
  36. package/src/generators/__snapshots__/petCoercion.ts +5 -8
  37. package/src/generators/__snapshots__/petTupleObject.ts +1 -1
  38. package/src/generators/__snapshots__/petV4.ts +5 -8
  39. package/src/generators/__snapshots__/petWithMapper.ts +5 -8
  40. package/src/generators/__snapshots__/pets.ts +1 -1
  41. package/src/generators/__snapshots__/queryAllDefaulted.ts +2 -2
  42. package/src/generators/__snapshots__/queryAllDefaulted_wrapOutput.ts +2 -2
  43. package/src/generators/__snapshots__/toy.ts +2 -2
  44. package/src/parser.ts +78 -21
  45. package/dist/components-CJ6RN1R2.js.map +0 -1
  46. package/dist/components-GvkeO2ig.cjs.map +0 -1
@@ -5,9 +5,9 @@
5
5
  import { z } from 'zod'
6
6
 
7
7
  export const optionalPet = z.object({
8
- id: z.number().int().optional(),
9
- name: z.string().optional(),
10
- tag: z.string().optional(),
8
+ id: z.optional(z.number().int()),
9
+ name: z.optional(z.string()),
10
+ tag: z.optional(z.string()),
11
11
  })
12
12
 
13
13
  export type OptionalPet = z.infer<typeof optionalPet>
@@ -6,7 +6,7 @@ import type { ToZod } from '@kubb/plugin-zod/utils'
6
6
  import { z } from 'zod'
7
7
 
8
8
  export const optionalPet = z.object({
9
- id: z.number().int().optional(),
10
- name: z.string().optional(),
11
- tag: z.string().optional(),
9
+ id: z.optional(z.number().int()),
10
+ name: z.optional(z.string()),
11
+ tag: z.optional(z.string()),
12
12
  }) as unknown as ToZod<OptionalPet>
@@ -5,10 +5,10 @@
5
5
  import { z } from 'zod'
6
6
 
7
7
  export const order = z.object({
8
- id: z.number().int().optional(),
9
- petId: z.number().int().optional(),
10
- quantity: z.number().int().optional(),
11
- shipDate: z.date().optional(),
12
- status: z.enum(['placed', 'approved', 'delivered']).describe('Order Status').optional(),
13
- complete: z.boolean().optional(),
8
+ id: z.optional(z.number().int()),
9
+ petId: z.optional(z.number().int()),
10
+ quantity: z.optional(z.number().int()),
11
+ shipDate: z.optional(z.date()),
12
+ status: z.optional(z.enum(['placed', 'approved', 'delivered']).describe('Order Status')),
13
+ complete: z.optional(z.boolean()),
14
14
  })
@@ -5,10 +5,10 @@
5
5
  import { z } from 'zod'
6
6
 
7
7
  export const order = z.object({
8
- id: z.number().int().optional(),
9
- petId: z.number().int().optional(),
10
- quantity: z.number().int().optional(),
11
- shipDate: z.string().optional(),
12
- status: z.enum(['placed', 'approved', 'delivered']).describe('Order Status').optional(),
13
- complete: z.boolean().optional(),
8
+ id: z.optional(z.number().int()),
9
+ petId: z.optional(z.number().int()),
10
+ quantity: z.optional(z.number().int()),
11
+ shipDate: z.optional(z.string()),
12
+ status: z.optional(z.enum(['placed', 'approved', 'delivered']).describe('Order Status')),
13
+ complete: z.optional(z.boolean()),
14
14
  })
@@ -5,10 +5,10 @@
5
5
  import { z } from 'zod'
6
6
 
7
7
  export const order = z.object({
8
- id: z.number().int().optional(),
9
- petId: z.number().int().optional(),
10
- quantity: z.number().int().optional(),
11
- shipDate: z.string().datetime().optional(),
12
- status: z.enum(['placed', 'approved', 'delivered']).describe('Order Status').optional(),
13
- complete: z.boolean().optional(),
8
+ id: z.optional(z.number().int()),
9
+ petId: z.optional(z.number().int()),
10
+ quantity: z.optional(z.number().int()),
11
+ shipDate: z.optional(z.string().datetime()),
12
+ status: z.optional(z.enum(['placed', 'approved', 'delivered']).describe('Order Status')),
13
+ complete: z.optional(z.boolean()),
14
14
  })
@@ -7,12 +7,9 @@ import { z } from 'zod'
7
7
  export const pet = z.object({
8
8
  id: z.number().int(),
9
9
  name: z.string(),
10
- date: z.date().optional(),
11
- uuid: z.string().uuid().optional(),
12
- email: z.string().email().optional(),
13
- pattern: z
14
- .string()
15
- .regex(/^[a-zA-Z0-9]{3}$/)
16
- .optional(),
17
- tag: z.string().min(5).max(100).optional(),
10
+ date: z.optional(z.date()),
11
+ uuid: z.optional(z.string().uuid()),
12
+ email: z.optional(z.string().email()),
13
+ pattern: z.optional(z.string().regex(/^[a-zA-Z0-9]{3}$/)),
14
+ tag: z.optional(z.string().min(5).max(100)),
18
15
  })
@@ -7,12 +7,9 @@ import { z } from 'zod'
7
7
  export const pet = z.object({
8
8
  id: z.coerce.number().int(),
9
9
  name: z.coerce.string(),
10
- date: z.coerce.date().optional(),
11
- uuid: z.coerce.string().uuid().optional(),
12
- email: z.coerce.string().email().optional(),
13
- pattern: z.coerce
14
- .string()
15
- .regex(/^[a-zA-Z0-9]{3}$/)
16
- .optional(),
17
- tag: z.coerce.string().min(5).max(100).optional(),
10
+ date: z.optional(z.coerce.date()),
11
+ uuid: z.optional(z.coerce.string().uuid()),
12
+ email: z.optional(z.coerce.string().email()),
13
+ pattern: z.optional(z.coerce.string().regex(/^[a-zA-Z0-9]{3}$/)),
14
+ tag: z.optional(z.coerce.string().min(5).max(100)),
18
15
  })
@@ -9,6 +9,6 @@ import { z } from 'zod'
9
9
  */
10
10
  export const petTupleObject = z
11
11
  .object({
12
- tupleProperty: z.tuple([z.string(), z.string()]).optional(),
12
+ tupleProperty: z.optional(z.tuple([z.string(), z.string()])),
13
13
  })
14
14
  .describe('Tuple of exact length 2 nested in an object')
@@ -7,12 +7,9 @@ import { z } from 'zod'
7
7
  export const pet = z.object({
8
8
  id: z.int(),
9
9
  name: z.string(),
10
- date: z.date().optional(),
11
- uuid: z.uuid().optional(),
12
- email: z.email().optional(),
13
- pattern: z
14
- .string()
15
- .regex(/^[a-zA-Z0-9]{3}$/)
16
- .optional(),
17
- tag: z.string().min(5).max(100).optional(),
10
+ date: z.optional(z.date()),
11
+ uuid: z.optional(z.uuid()),
12
+ email: z.optional(z.email()),
13
+ pattern: z.optional(z.string().regex(/^[a-zA-Z0-9]{3}$/)),
14
+ tag: z.optional(z.string().min(5).max(100)),
18
15
  })
@@ -7,12 +7,9 @@ import { z } from 'zod'
7
7
  export const pet = z.object({
8
8
  id: z.number().int(),
9
9
  name: z.string().email(),
10
- date: z.date().optional(),
11
- uuid: z.string().uuid().optional(),
12
- email: z.string().email().optional(),
13
- pattern: z
14
- .string()
15
- .regex(/^[a-zA-Z0-9]{3}$/)
16
- .optional(),
17
- tag: z.string().min(5).max(100).optional(),
10
+ date: z.optional(z.date()),
11
+ uuid: z.optional(z.string().uuid()),
12
+ email: z.optional(z.string().email()),
13
+ pattern: z.optional(z.string().regex(/^[a-zA-Z0-9]{3}$/)),
14
+ tag: z.optional(z.string().min(5).max(100)),
18
15
  })
@@ -9,6 +9,6 @@ export const pets = z.array(
9
9
  z.object({
10
10
  id: z.number().int(),
11
11
  name: z.string(),
12
- tag: z.string().optional(),
12
+ tag: z.optional(z.string()),
13
13
  }),
14
14
  ) as unknown as ToZod<Pets>
@@ -5,8 +5,8 @@
5
5
  import { z } from 'zod'
6
6
 
7
7
  export const getThingsQueryParams = z.object({
8
- limit: z.coerce.number().int().min(1).max(100).default(100).describe('Maximum number of things to return'),
9
- skip: z.coerce.number().int().min(0).default(0).describe('Number of things to skip'),
8
+ limit: z.optional(z.coerce.number().int().min(1).max(100).default(100).describe('Maximum number of things to return')),
9
+ skip: z.optional(z.coerce.number().int().min(0).default(0).describe('Number of things to skip')),
10
10
  })
11
11
 
12
12
  /**
@@ -5,8 +5,8 @@
5
5
  import { z } from '@hono/zod-openapi'
6
6
 
7
7
  export const getThingsQueryParams = z.object({
8
- limit: z.coerce.number().int().min(1).max(100).default(100).describe('Maximum number of things to return'),
9
- skip: z.coerce.number().int().min(0).default(0).describe('Number of things to skip'),
8
+ limit: z.optional(z.coerce.number().int().min(1).max(100).default(100).describe('Maximum number of things to return')),
9
+ skip: z.optional(z.coerce.number().int().min(0).default(0).describe('Number of things to skip')),
10
10
  })
11
11
 
12
12
  /**
@@ -7,7 +7,7 @@ import { z } from 'zod'
7
7
  export const toy = z
8
8
  .object({
9
9
  id: z.string().uuid(),
10
- name: z.string().optional(),
11
- description: z.string().nullable().nullish(),
10
+ name: z.optional(z.string()),
11
+ description: z.string().nullish(),
12
12
  })
13
13
  .nullable()
package/src/parser.ts CHANGED
@@ -4,6 +4,9 @@ import type { SchemaObject } from '@kubb/oas'
4
4
  import type { Schema, SchemaKeywordBase, SchemaMapper } from '@kubb/plugin-oas'
5
5
  import { isKeyword, SchemaGenerator, type SchemaKeywordMapper, type SchemaTree, schemaKeywords } from '@kubb/plugin-oas'
6
6
 
7
+ //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)
8
+ // also include shouldCoerce
9
+
7
10
  const zodKeywordMapper = {
8
11
  any: () => 'z.any()',
9
12
  unknown: () => 'z.unknown()',
@@ -57,9 +60,19 @@ const zodKeywordMapper = {
57
60
  //support for discriminatedUnion
58
61
  boolean: () => 'z.boolean()',
59
62
  undefined: () => 'z.undefined()',
60
- nullable: () => '.nullable()',
63
+ nullable: (value?: string) => {
64
+ if (value) {
65
+ return `z.nullable(${value})`
66
+ }
67
+ return '.nullable()'
68
+ },
61
69
  null: () => 'z.null()',
62
- nullish: () => '.nullish()',
70
+ nullish: (value?: string) => {
71
+ if (value) {
72
+ return `z.nullish(${value})`
73
+ }
74
+ return '.nullish()'
75
+ },
63
76
  array: (items: string[] = [], min?: number, max?: number, unique?: boolean) => {
64
77
  return [
65
78
  `z.array(${items?.join('')})`,
@@ -132,9 +145,14 @@ const zodKeywordMapper = {
132
145
  },
133
146
  and: (items: string[] = []) => items?.map((item) => `.and(${item})`).join(''),
134
147
  describe: (value = '') => `.describe(${value})`,
135
- min: (value?: number) => `.min(${value ?? ''})`,
136
- max: (value?: number) => `.max(${value ?? ''})`,
137
- optional: () => '.optional()',
148
+ max: undefined,
149
+ min: undefined,
150
+ optional: (value?: string) => {
151
+ if (value) {
152
+ return `z.optional(${value})`
153
+ }
154
+ return '.optional()'
155
+ },
138
156
  matches: (value = '', coercion?: boolean) => (coercion ? `z.coerce.string().regex(${value})` : `z.string().regex(${value})`),
139
157
  email: (coercion?: boolean, version: '3' | '4' = '3') =>
140
158
  version === '4' ? (coercion ? 'z.coerce.string().email()' : 'z.email()') : coercion ? 'z.coerce.string().email()' : 'z.string().email()',
@@ -322,7 +340,11 @@ export function parse({ parent, current, name, siblings }: SchemaTree, options:
322
340
 
323
341
  const properties = propertyEntries
324
342
  .map(([name, schemas]) => {
325
- const nameSchema = schemas.find((schema) => schema.keyword === schemaKeywords.name) as SchemaKeywordMapper['name']
343
+ const nameSchema = schemas.find((it) => it.keyword === schemaKeywords.name) as SchemaKeywordMapper['name']
344
+ const isNullable = schemas.some((it) => isKeyword(it, schemaKeywords.nullable))
345
+ const isNullish = schemas.some((it) => isKeyword(it, schemaKeywords.nullish))
346
+ const isOptional = schemas.some((it) => isKeyword(it, schemaKeywords.optional))
347
+
326
348
  const mappedName = nameSchema?.args || name
327
349
 
328
350
  // custom mapper(pluginOptions)
@@ -331,6 +353,9 @@ export function parse({ parent, current, name, siblings }: SchemaTree, options:
331
353
  }
332
354
 
333
355
  const baseSchemaOutput = sort(schemas)
356
+ .filter((schema) => {
357
+ return !isKeyword(schema, schemaKeywords.optional) && !isKeyword(schema, schemaKeywords.nullable) && !isKeyword(schema, schemaKeywords.nullish)
358
+ })
334
359
  .map((schema) => parse({ parent: current, name, current: schema, siblings: schemas }, options))
335
360
  .filter(Boolean)
336
361
  .join('')
@@ -340,11 +365,47 @@ export function parse({ parent, current, name, siblings }: SchemaTree, options:
340
365
  : baseSchemaOutput
341
366
 
342
367
  if (options.version === '4' && SchemaGenerator.find(schemas, schemaKeywords.ref)) {
368
+ // both optional and nullable
369
+ if (isNullish) {
370
+ return `get ${name}(){
371
+ return ${zodKeywordMapper.nullish(objectValue)}
372
+ }`
373
+ }
374
+
375
+ // undefined
376
+ if (isOptional) {
377
+ return `get ${name}(){
378
+ return ${zodKeywordMapper.optional(objectValue)}
379
+ }`
380
+ }
381
+
382
+ // null
383
+ if (isNullable) {
384
+ return `get ${name}(){
385
+ return ${zodKeywordMapper.nullable(objectValue)}
386
+ }`
387
+ }
388
+
343
389
  return `get ${name}(){
344
390
  return ${objectValue}
345
391
  }`
346
392
  }
347
393
 
394
+ // both optional and nullable
395
+ if (isNullish) {
396
+ return `"${name}": ${objectValue}${zodKeywordMapper.nullish()}`
397
+ }
398
+
399
+ // undefined
400
+ if (isOptional) {
401
+ return `"${name}": ${zodKeywordMapper.optional(objectValue)}`
402
+ }
403
+
404
+ // null
405
+ if (isNullable) {
406
+ return `"${name}": ${zodKeywordMapper.nullable(objectValue)}`
407
+ }
408
+
348
409
  return `"${name}": ${objectValue}`
349
410
  })
350
411
  .join(',\n')
@@ -400,7 +461,10 @@ export function parse({ parent, current, name, siblings }: SchemaTree, options:
400
461
  }
401
462
 
402
463
  if (isKeyword(current, schemaKeywords.string)) {
403
- return zodKeywordMapper.string(shouldCoerce(options.coercion, 'strings'))
464
+ const minSchema = SchemaGenerator.find(siblings, schemaKeywords.min)
465
+ const maxSchema = SchemaGenerator.find(siblings, schemaKeywords.max)
466
+
467
+ return zodKeywordMapper.string(shouldCoerce(options.coercion, 'strings'), minSchema?.args, maxSchema?.args)
404
468
  }
405
469
 
406
470
  if (isKeyword(current, schemaKeywords.uuid)) {
@@ -416,18 +480,17 @@ export function parse({ parent, current, name, siblings }: SchemaTree, options:
416
480
  }
417
481
 
418
482
  if (isKeyword(current, schemaKeywords.number)) {
419
- return zodKeywordMapper.number(shouldCoerce(options.coercion, 'numbers'))
483
+ const minSchema = SchemaGenerator.find(siblings, schemaKeywords.min)
484
+ const maxSchema = SchemaGenerator.find(siblings, schemaKeywords.max)
485
+
486
+ return zodKeywordMapper.number(shouldCoerce(options.coercion, 'numbers'), minSchema?.args, maxSchema?.args)
420
487
  }
421
488
 
422
489
  if (isKeyword(current, schemaKeywords.integer)) {
423
- return zodKeywordMapper.integer(shouldCoerce(options.coercion, 'numbers'), undefined, undefined, options.version)
424
- }
490
+ const minSchema = SchemaGenerator.find(siblings, schemaKeywords.min)
491
+ const maxSchema = SchemaGenerator.find(siblings, schemaKeywords.max)
425
492
 
426
- if (isKeyword(current, schemaKeywords.min)) {
427
- return zodKeywordMapper.min(current.args)
428
- }
429
- if (isKeyword(current, schemaKeywords.max)) {
430
- return zodKeywordMapper.max(current.args)
493
+ return zodKeywordMapper.integer(shouldCoerce(options.coercion, 'numbers'), minSchema?.args, maxSchema?.args, options.version)
431
494
  }
432
495
 
433
496
  if (isKeyword(current, schemaKeywords.datetime)) {
@@ -448,12 +511,6 @@ export function parse({ parent, current, name, siblings }: SchemaTree, options:
448
511
  return value((current as SchemaKeywordBase<unknown>).args as any)
449
512
  }
450
513
 
451
- if (isKeyword(current, schemaKeywords.optional)) {
452
- if (siblings.some((schema) => isKeyword(schema, schemaKeywords.default))) return ''
453
-
454
- return value()
455
- }
456
-
457
514
  if (current.keyword in zodKeywordMapper) {
458
515
  return value()
459
516
  }
@@ -1 +0,0 @@
1
- {"version":3,"file":"components-CJ6RN1R2.js","names":["order: string[]","name","value"],"sources":["../src/components/Operations.tsx","../src/parser.ts","../src/components/Zod.tsx"],"sourcesContent":["import type { SchemaNames } from '@kubb/plugin-oas/hooks'\nimport { Const, File } from '@kubb/react'\n\nimport transformers from '@kubb/core/transformers'\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype Props = {\n name: string\n operations: Array<{ operation: Operation; data: SchemaNames }>\n}\n\nexport function Operations({ name, operations }: Props) {\n const operationsJSON = operations.reduce(\n (prev, acc) => {\n prev[`\"${acc.operation.getOperationId()}\"`] = acc.data\n\n return prev\n },\n {} as Record<string, unknown>,\n )\n\n const pathsJSON = operations.reduce(\n (prev, acc) => {\n prev[`\"${acc.operation.path}\"`] = {\n ...(prev[`\"${acc.operation.path}\"`] || ({} as Record<HttpMethod, string>)),\n [acc.operation.method]: `operations[\"${acc.operation.getOperationId()}\"]`,\n }\n\n return prev\n },\n {} as Record<string, Record<HttpMethod, string>>,\n )\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Const export name={name} asConst>\n {`{${transformers.stringifyObject(operationsJSON)}}`}\n </Const>\n </File.Source>\n <File.Source name={'paths'} isExportable isIndexable>\n <Const export name={'paths'} asConst>\n {`{${transformers.stringifyObject(pathsJSON)}}`}\n </Const>\n </File.Source>\n </>\n )\n}\n","import transformers from '@kubb/core/transformers'\nimport type { SchemaObject } from '@kubb/oas'\n\nimport type { Schema, SchemaKeywordBase, SchemaMapper } from '@kubb/plugin-oas'\nimport { isKeyword, SchemaGenerator, type SchemaKeywordMapper, type SchemaTree, schemaKeywords } from '@kubb/plugin-oas'\n\nconst zodKeywordMapper = {\n any: () => 'z.any()',\n unknown: () => 'z.unknown()',\n void: () => 'z.void()',\n number: (coercion?: boolean, min?: number, max?: number) => {\n return [coercion ? 'z.coerce.number()' : 'z.number()', min !== undefined ? `.min(${min})` : undefined, max !== undefined ? `.max(${max})` : undefined]\n .filter(Boolean)\n .join('')\n },\n integer: (coercion?: boolean, min?: number, max?: number, version: '3' | '4' = '3') => {\n return [\n coercion ? 'z.coerce.number().int()' : version === '4' ? 'z.int()' : 'z.number().int()',\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n interface: (value?: string, strict?: boolean) => {\n if (strict) {\n return `z.strictInterface({\n ${value}\n })`\n }\n return `z.interface({\n ${value}\n })`\n },\n object: (value?: string, strict?: boolean, version: '3' | '4' = '3') => {\n if (version === '4' && strict) {\n return `z.strictObject({\n ${value}\n })`\n }\n\n if (strict) {\n return `z.object({\n ${value}\n }).strict()`\n }\n\n return `z.object({\n ${value}\n })`\n },\n string: (coercion?: boolean, min?: number, max?: number) => {\n return [coercion ? 'z.coerce.string()' : 'z.string()', min !== undefined ? `.min(${min})` : undefined, max !== undefined ? `.max(${max})` : undefined]\n .filter(Boolean)\n .join('')\n },\n //support for discriminatedUnion\n boolean: () => 'z.boolean()',\n undefined: () => 'z.undefined()',\n nullable: () => '.nullable()',\n null: () => 'z.null()',\n nullish: () => '.nullish()',\n array: (items: string[] = [], min?: number, max?: number, unique?: boolean) => {\n return [\n `z.array(${items?.join('')})`,\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n unique ? `.refine(items => new Set(items).size === items.length, { message: \"Array entries must be unique\" })` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n tuple: (items: string[] = []) => `z.tuple([${items?.join(', ')}])`,\n enum: (items: string[] = []) => `z.enum([${items?.join(', ')}])`,\n union: (items: string[] = []) => `z.union([${items?.join(', ')}])`,\n const: (value?: string | number | boolean) => `z.literal(${value ?? ''})`,\n /**\n * ISO 8601\n */\n datetime: (offset = false, local = false, version: '3' | '4' = '3') => {\n if (offset) {\n return version === '4' ? `z.iso.datetime({ offset: ${offset} })` : `z.string().datetime({ offset: ${offset} })`\n }\n\n if (local) {\n return version === '4' ? `z.iso.datetime({ local: ${local} })` : `z.string().datetime({ local: ${local} })`\n }\n\n return 'z.string().datetime()'\n },\n /**\n * Type `'date'` Date\n * Type `'string'` ISO date format (YYYY-MM-DD)\n * @default ISO date format (YYYY-MM-DD)\n */\n date: (type: 'date' | 'string' = 'string', coercion?: boolean, version: '3' | '4' = '3') => {\n if (type === 'string') {\n return version === '4' ? 'z.iso.date()' : 'z.string().date()'\n }\n\n if (coercion) {\n return 'z.coerce.date()'\n }\n\n return 'z.date()'\n },\n /**\n * Type `'date'` Date\n * Type `'string'` ISO time format (HH:mm:ss[.SSSSSS])\n * @default ISO time format (HH:mm:ss[.SSSSSS])\n */\n time: (type: 'date' | 'string' = 'string', coercion?: boolean, version: '3' | '4' = '3') => {\n if (type === 'string') {\n return version === '4' ? 'z.iso.time()' : 'z.string().time()'\n }\n\n if (coercion) {\n return 'z.coerce.date()'\n }\n\n return 'z.date()'\n },\n uuid: (coercion?: boolean, version: '3' | '4' = '3') =>\n version === '4' ? (coercion ? 'z.coerce.string().uuid()' : 'z.uuid()') : coercion ? 'z.coerce.string().uuid()' : 'z.string().uuid()',\n url: (coercion?: boolean, version: '3' | '4' = '3') =>\n version === '4' ? (coercion ? 'z.coerce.string().url()' : 'z.url()') : coercion ? 'z.coerce.string().url()' : 'z.string().url()',\n default: (value?: string | number | true | object) => {\n if (typeof value === 'object') {\n return '.default({})'\n }\n return `.default(${value ?? ''})`\n },\n and: (items: string[] = []) => items?.map((item) => `.and(${item})`).join(''),\n describe: (value = '') => `.describe(${value})`,\n min: (value?: number) => `.min(${value ?? ''})`,\n max: (value?: number) => `.max(${value ?? ''})`,\n optional: () => '.optional()',\n matches: (value = '', coercion?: boolean) => (coercion ? `z.coerce.string().regex(${value})` : `z.string().regex(${value})`),\n email: (coercion?: boolean, version: '3' | '4' = '3') =>\n version === '4' ? (coercion ? 'z.coerce.string().email()' : 'z.email()') : coercion ? 'z.coerce.string().email()' : 'z.string().email()',\n firstName: undefined,\n lastName: undefined,\n password: undefined,\n phone: undefined,\n readOnly: undefined,\n writeOnly: undefined,\n ref: (value?: string, version: '3' | '4' = '3') => {\n if (!value) {\n return undefined\n }\n\n return version === '4' ? value : `z.lazy(() => ${value})`\n },\n blob: () => 'z.instanceof(File)',\n deprecated: undefined,\n example: undefined,\n schema: undefined,\n catchall: (value?: string) => (value ? `.catchall(${value})` : undefined),\n name: undefined,\n} satisfies SchemaMapper<string | null | undefined>\n\n/**\n * @link based on https://github.com/cellular/oazapfts/blob/7ba226ebb15374e8483cc53e7532f1663179a22c/src/codegen/generate.ts#L398\n */\n\nexport function sort(items?: Schema[]): Schema[] {\n const order: string[] = [\n schemaKeywords.string,\n schemaKeywords.datetime,\n schemaKeywords.date,\n schemaKeywords.time,\n schemaKeywords.tuple,\n schemaKeywords.number,\n schemaKeywords.object,\n schemaKeywords.enum,\n schemaKeywords.url,\n schemaKeywords.email,\n schemaKeywords.firstName,\n schemaKeywords.lastName,\n schemaKeywords.password,\n schemaKeywords.matches,\n schemaKeywords.uuid,\n schemaKeywords.null,\n schemaKeywords.min,\n schemaKeywords.max,\n schemaKeywords.default,\n schemaKeywords.describe,\n schemaKeywords.optional,\n schemaKeywords.nullable,\n schemaKeywords.nullish,\n ]\n\n if (!items) {\n return []\n }\n\n return transformers.orderBy(items, [(v) => order.indexOf(v.keyword)], ['asc'])\n}\n\nconst shouldCoerce = (coercion: ParserOptions['coercion'] | undefined, type: 'dates' | 'strings' | 'numbers'): boolean => {\n if (coercion === undefined) {\n return false\n }\n if (typeof coercion === 'boolean') {\n return coercion\n }\n\n return !!coercion[type]\n}\n\ntype ParserOptions = {\n name: string\n typeName?: string\n description?: string\n keysToOmit?: string[]\n mapper?: Record<string, string>\n coercion?: boolean | { dates?: boolean; strings?: boolean; numbers?: boolean }\n wrapOutput?: (opts: { output: string; schema: any }) => string | undefined\n rawSchema: SchemaObject\n version: '3' | '4'\n}\n\nexport function parse({ parent, current, name, siblings }: SchemaTree, options: ParserOptions): string | undefined {\n const value = zodKeywordMapper[current.keyword as keyof typeof zodKeywordMapper]\n\n // Early exit: if siblings contain both matches and ref → skip matches entirely\n const hasMatches = siblings.some((it) => isKeyword(it, schemaKeywords.matches))\n const hasRef = siblings.some((it) => isKeyword(it, schemaKeywords.ref))\n\n if (hasMatches && hasRef && isKeyword(current, schemaKeywords.matches)) {\n return undefined // strip matches\n }\n\n if (!value) {\n return undefined\n }\n\n if (isKeyword(current, schemaKeywords.union)) {\n // zod union type needs at least 2 items\n if (Array.isArray(current.args) && current.args.length === 1) {\n return parse({ parent, name: name, current: current.args[0] as Schema, siblings }, options)\n }\n if (Array.isArray(current.args) && !current.args.length) {\n return ''\n }\n\n return zodKeywordMapper.union(\n sort(current.args)\n .map((schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options))\n .filter(Boolean),\n )\n }\n\n if (isKeyword(current, schemaKeywords.and)) {\n const items = sort(current.args)\n .filter((schema: Schema) => {\n return ![schemaKeywords.optional, schemaKeywords.describe].includes(schema.keyword as typeof schemaKeywords.describe)\n })\n .map((schema: Schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options))\n .filter(Boolean)\n\n return `${items.slice(0, 1)}${zodKeywordMapper.and(items.slice(1))}`\n }\n\n if (isKeyword(current, schemaKeywords.array)) {\n return zodKeywordMapper.array(\n sort(current.args.items)\n .map((schemas, _index, siblings) => parse({ parent: current, name: name, current: schemas, siblings }, options))\n .filter(Boolean),\n current.args.min,\n current.args.max,\n current.args.unique,\n )\n }\n\n if (isKeyword(current, schemaKeywords.enum)) {\n if (current.args.asConst) {\n if (current.args.items.length === 1) {\n const child = {\n keyword: schemaKeywords.const,\n args: current.args.items[0],\n }\n return parse({ parent: current, name: name, current: child, siblings: [child] }, options)\n }\n\n return zodKeywordMapper.union(\n current.args.items\n .map((schema) => ({\n keyword: schemaKeywords.const,\n args: schema,\n }))\n .map((schema, _index, siblings) => {\n return parse({ parent: current, name: name, current: schema, siblings }, options)\n })\n .filter(Boolean),\n )\n }\n\n return zodKeywordMapper.enum(\n current.args.items.map((schema) => {\n if (schema.format === 'boolean') {\n return transformers.stringify(schema.value)\n }\n\n if (schema.format === 'number') {\n return transformers.stringify(schema.value)\n }\n return transformers.stringify(schema.value)\n }),\n )\n }\n\n if (isKeyword(current, schemaKeywords.ref)) {\n return zodKeywordMapper.ref(current.args?.name, options.version)\n }\n\n if (isKeyword(current, schemaKeywords.object)) {\n const propertyEntries = Object.entries(current.args?.properties || {}).filter((item) => {\n const schema = item[1]\n return schema && typeof schema.map === 'function'\n })\n\n const properties = propertyEntries\n .map(([name, schemas]) => {\n const nameSchema = schemas.find((schema) => schema.keyword === schemaKeywords.name) as SchemaKeywordMapper['name']\n const mappedName = nameSchema?.args || name\n\n // custom mapper(pluginOptions)\n if (options.mapper?.[mappedName]) {\n return `\"${name}\": ${options.mapper?.[mappedName]}`\n }\n\n const baseSchemaOutput = sort(schemas)\n .map((schema) => parse({ parent: current, name, current: schema, siblings: schemas }, options))\n .filter(Boolean)\n .join('')\n\n const objectValue = options.wrapOutput\n ? options.wrapOutput({ output: baseSchemaOutput, schema: options.rawSchema?.properties?.[name] }) || baseSchemaOutput\n : baseSchemaOutput\n\n if (options.version === '4' && SchemaGenerator.find(schemas, schemaKeywords.ref)) {\n return `get ${name}(){\n return ${objectValue}\n }`\n }\n\n return `\"${name}\": ${objectValue}`\n })\n .join(',\\n')\n\n const additionalProperties = current.args?.additionalProperties?.length\n ? current.args.additionalProperties\n .map((schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options))\n .filter(Boolean)\n .join('')\n : undefined\n\n const text = [\n zodKeywordMapper.object(properties, current.args?.strict, options.version),\n additionalProperties ? zodKeywordMapper.catchall(additionalProperties) : undefined,\n ].filter(Boolean)\n\n return text.join('')\n }\n\n if (isKeyword(current, schemaKeywords.tuple)) {\n return zodKeywordMapper.tuple(\n current.args.items.map((schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options)).filter(Boolean),\n )\n }\n\n if (isKeyword(current, schemaKeywords.const)) {\n if (current.args.format === 'number' && current.args.value !== undefined) {\n return zodKeywordMapper.const(Number(current.args.value))\n }\n\n if (current.args.format === 'boolean' && current.args.value !== undefined) {\n return zodKeywordMapper.const(current.args.value)\n }\n return zodKeywordMapper.const(transformers.stringify(current.args.value))\n }\n\n if (isKeyword(current, schemaKeywords.matches)) {\n if (current.args) {\n return zodKeywordMapper.matches(transformers.toRegExpString(current.args, null), shouldCoerce(options.coercion, 'strings'))\n }\n }\n\n if (isKeyword(current, schemaKeywords.default)) {\n if (current.args) {\n return zodKeywordMapper.default(current.args)\n }\n }\n\n if (isKeyword(current, schemaKeywords.describe)) {\n if (current.args) {\n return zodKeywordMapper.describe(transformers.stringify(current.args.toString()))\n }\n }\n\n if (isKeyword(current, schemaKeywords.string)) {\n return zodKeywordMapper.string(shouldCoerce(options.coercion, 'strings'))\n }\n\n if (isKeyword(current, schemaKeywords.uuid)) {\n return zodKeywordMapper.uuid(shouldCoerce(options.coercion, 'strings'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.email)) {\n return zodKeywordMapper.email(shouldCoerce(options.coercion, 'strings'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.url)) {\n return zodKeywordMapper.url(shouldCoerce(options.coercion, 'strings'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.number)) {\n return zodKeywordMapper.number(shouldCoerce(options.coercion, 'numbers'))\n }\n\n if (isKeyword(current, schemaKeywords.integer)) {\n return zodKeywordMapper.integer(shouldCoerce(options.coercion, 'numbers'), undefined, undefined, options.version)\n }\n\n if (isKeyword(current, schemaKeywords.min)) {\n return zodKeywordMapper.min(current.args)\n }\n if (isKeyword(current, schemaKeywords.max)) {\n return zodKeywordMapper.max(current.args)\n }\n\n if (isKeyword(current, schemaKeywords.datetime)) {\n return zodKeywordMapper.datetime(current.args.offset, current.args.local, options.version)\n }\n\n if (isKeyword(current, schemaKeywords.date)) {\n return zodKeywordMapper.date(current.args.type, shouldCoerce(options.coercion, 'dates'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.time)) {\n return zodKeywordMapper.time(current.args.type, shouldCoerce(options.coercion, 'dates'), options.version)\n }\n\n if (current.keyword in zodKeywordMapper && 'args' in current) {\n const value = zodKeywordMapper[current.keyword as keyof typeof zodKeywordMapper] as (typeof zodKeywordMapper)['const']\n\n return value((current as SchemaKeywordBase<unknown>).args as any)\n }\n\n if (isKeyword(current, schemaKeywords.optional)) {\n if (siblings.some((schema) => isKeyword(schema, schemaKeywords.default))) return ''\n\n return value()\n }\n\n if (current.keyword in zodKeywordMapper) {\n return value()\n }\n\n return undefined\n}\n","import transformers from '@kubb/core/transformers'\nimport type { SchemaObject } from '@kubb/oas'\nimport { isKeyword, type Schema, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { Const, File, Type } from '@kubb/react'\nimport * as parserZod from '../parser.ts'\nimport type { PluginZod } from '../types.ts'\n\ntype Props = {\n name: string\n typeName?: string\n inferTypeName?: string\n tree: Array<Schema>\n rawSchema: SchemaObject\n description?: string\n coercion: PluginZod['resolvedOptions']['coercion']\n mapper: PluginZod['resolvedOptions']['mapper']\n keysToOmit?: string[]\n wrapOutput?: PluginZod['resolvedOptions']['wrapOutput']\n version: '3' | '4'\n emptySchemaType: PluginZod['resolvedOptions']['emptySchemaType']\n}\n\nexport function Zod({\n name,\n typeName,\n tree,\n rawSchema,\n inferTypeName,\n mapper,\n coercion,\n keysToOmit,\n description,\n wrapOutput,\n version,\n emptySchemaType,\n}: Props) {\n const hasTuple = !!SchemaGenerator.deepSearch(tree, schemaKeywords.tuple)\n\n const schemas = parserZod.sort(tree).filter((item) => {\n if (hasTuple && (isKeyword(item, schemaKeywords.min) || isKeyword(item, schemaKeywords.max))) {\n return false\n }\n\n return true\n })\n\n const output = schemas\n .map((schema, _index, siblings) =>\n parserZod.parse(\n { parent: undefined, current: schema, siblings },\n { name, keysToOmit, typeName, description, mapper, coercion, wrapOutput, rawSchema, version },\n ),\n )\n .filter(Boolean)\n .join('')\n\n let suffix = ''\n const firstSchema = schemas.at(0)\n const lastSchema = schemas.at(-1)\n\n if (lastSchema && isKeyword(lastSchema, schemaKeywords.nullable)) {\n if (firstSchema && isKeyword(firstSchema, schemaKeywords.ref)) {\n if (version === '3') {\n suffix = '.unwrap().schema.unwrap()'\n } else {\n suffix = '.unwrap().unwrap()'\n }\n } else {\n suffix = '.unwrap()'\n }\n } else {\n if (firstSchema && isKeyword(firstSchema, schemaKeywords.ref) && version === '3') {\n suffix = '.schema'\n }\n }\n\n const emptyValue = parserZod.parse(\n {\n parent: undefined,\n current: {\n keyword: schemaKeywords[emptySchemaType],\n },\n siblings: [],\n },\n { name, keysToOmit, typeName, description, mapper, coercion, wrapOutput, rawSchema, version },\n )\n\n const baseSchemaOutput =\n [output, keysToOmit?.length ? `${suffix}.omit({ ${keysToOmit.map((key) => `${key}: true`).join(',')} })` : undefined].filter(Boolean).join('') ||\n emptyValue ||\n ''\n const wrappedSchemaOutput = wrapOutput ? wrapOutput({ output: baseSchemaOutput, schema: rawSchema }) || baseSchemaOutput : baseSchemaOutput\n const finalOutput = typeName ? `${wrappedSchemaOutput} as unknown as ToZod<${typeName}>` : wrappedSchemaOutput\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Const\n export\n name={name}\n JSDoc={{\n comments: [description ? `@description ${transformers.jsStringEscape(description)}` : undefined].filter(Boolean),\n }}\n >\n {finalOutput}\n </Const>\n </File.Source>\n {inferTypeName && (\n <File.Source name={inferTypeName} isExportable isIndexable isTypeOnly>\n {typeName && (\n <Type export name={inferTypeName}>\n {typeName}\n </Type>\n )}\n {!typeName && (\n <Type export name={inferTypeName}>\n {`z.infer<typeof ${name}>`}\n </Type>\n )}\n </File.Source>\n )}\n </>\n )\n}\n"],"mappings":";;;;;;AAWA,SAAgB,WAAW,EAAE,MAAM,cAAqB;CACtD,MAAM,iBAAiB,WAAW,QAC/B,MAAM,QAAQ;AACb,OAAK,IAAI,IAAI,UAAU,iBAAiB,MAAM,IAAI;AAElD,SAAO;IAET;CAGF,MAAM,YAAY,WAAW,QAC1B,MAAM,QAAQ;AACb,OAAK,IAAI,IAAI,UAAU,KAAK,MAAM;GAChC,GAAI,KAAK,IAAI,IAAI,UAAU,KAAK,OAAQ;IACvC,IAAI,UAAU,SAAS,eAAe,IAAI,UAAU,iBAAiB;;AAGxE,SAAO;IAET;AAGF,QACE,4CACE,oBAAC,KAAK;EAAa;EAAM;EAAa;YACpC,oBAAC;GAAM;GAAa;GAAM;aACvB,IAAI,aAAa,gBAAgB,gBAAgB;;KAGtD,oBAAC,KAAK;EAAO,MAAM;EAAS;EAAa;YACvC,oBAAC;GAAM;GAAO,MAAM;GAAS;aAC1B,IAAI,aAAa,gBAAgB,WAAW;;;;;;;ACpCvD,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;IACzI,OAAO,SACP,KAAK;;CA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AAI,YAAY,IACd,UAAS;KAET,UAAS;KAGX,UAAS;UAGP,eAAe,UAAU,aAAa,eAAe,QAAQ,YAAY,IAC3E,UAAS;CAIb,MAAM,mBACJ;EACE,QAAQ;EACR,SAAS,EACP,SAAS,eAAe;EAE1B,UAAU;IAEZ;EAAE;EAAM;EAAY;EAAU;EAAa;EAAQ;EAAU;EAAY;EAAW;;CAGtF,MAAM,mBACJ,CAAC,QAAQ,YAAY,SAAS,GAAG,OAAO,UAAU,WAAW,KAAK,QAAQ,GAAG,IAAI,SAAS,KAAK,KAAK,OAAO,QAAW,OAAO,SAAS,KAAK,OAC3I,cACA;CACF,MAAM,sBAAsB,aAAa,WAAW;EAAE,QAAQ;EAAkB,QAAQ;OAAgB,mBAAmB;CAC3H,MAAM,cAAc,WAAW,GAAG,oBAAoB,uBAAuB,SAAS,KAAK;AAE3F,QACE,4CACE,oBAAC,KAAK;EAAa;EAAM;EAAa;YACpC,oBAAC;GACC;GACM;GACN,OAAO,EACL,UAAU,CAAC,cAAc,gBAAgB,aAAa,eAAe,iBAAiB,QAAW,OAAO;aAGzG;;KAGJ,iBACC,qBAAC,KAAK;EAAO,MAAM;EAAe;EAAa;EAAY;aACxD,YACC,oBAAC;GAAK;GAAO,MAAM;aAChB;MAGJ,CAAC,YACA,oBAAC;GAAK;GAAO,MAAM;aAChB,kBAAkB,KAAK"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"components-GvkeO2ig.cjs","names":["File","Const","transformers","order: string[]","schemaKeywords","transformers","name","SchemaGenerator","value","SchemaGenerator","schemaKeywords","File","Const","transformers","Type"],"sources":["../src/components/Operations.tsx","../src/parser.ts","../src/components/Zod.tsx"],"sourcesContent":["import type { SchemaNames } from '@kubb/plugin-oas/hooks'\nimport { Const, File } from '@kubb/react'\n\nimport transformers from '@kubb/core/transformers'\nimport type { HttpMethod, Operation } from '@kubb/oas'\n\ntype Props = {\n name: string\n operations: Array<{ operation: Operation; data: SchemaNames }>\n}\n\nexport function Operations({ name, operations }: Props) {\n const operationsJSON = operations.reduce(\n (prev, acc) => {\n prev[`\"${acc.operation.getOperationId()}\"`] = acc.data\n\n return prev\n },\n {} as Record<string, unknown>,\n )\n\n const pathsJSON = operations.reduce(\n (prev, acc) => {\n prev[`\"${acc.operation.path}\"`] = {\n ...(prev[`\"${acc.operation.path}\"`] || ({} as Record<HttpMethod, string>)),\n [acc.operation.method]: `operations[\"${acc.operation.getOperationId()}\"]`,\n }\n\n return prev\n },\n {} as Record<string, Record<HttpMethod, string>>,\n )\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Const export name={name} asConst>\n {`{${transformers.stringifyObject(operationsJSON)}}`}\n </Const>\n </File.Source>\n <File.Source name={'paths'} isExportable isIndexable>\n <Const export name={'paths'} asConst>\n {`{${transformers.stringifyObject(pathsJSON)}}`}\n </Const>\n </File.Source>\n </>\n )\n}\n","import transformers from '@kubb/core/transformers'\nimport type { SchemaObject } from '@kubb/oas'\n\nimport type { Schema, SchemaKeywordBase, SchemaMapper } from '@kubb/plugin-oas'\nimport { isKeyword, SchemaGenerator, type SchemaKeywordMapper, type SchemaTree, schemaKeywords } from '@kubb/plugin-oas'\n\nconst zodKeywordMapper = {\n any: () => 'z.any()',\n unknown: () => 'z.unknown()',\n void: () => 'z.void()',\n number: (coercion?: boolean, min?: number, max?: number) => {\n return [coercion ? 'z.coerce.number()' : 'z.number()', min !== undefined ? `.min(${min})` : undefined, max !== undefined ? `.max(${max})` : undefined]\n .filter(Boolean)\n .join('')\n },\n integer: (coercion?: boolean, min?: number, max?: number, version: '3' | '4' = '3') => {\n return [\n coercion ? 'z.coerce.number().int()' : version === '4' ? 'z.int()' : 'z.number().int()',\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n interface: (value?: string, strict?: boolean) => {\n if (strict) {\n return `z.strictInterface({\n ${value}\n })`\n }\n return `z.interface({\n ${value}\n })`\n },\n object: (value?: string, strict?: boolean, version: '3' | '4' = '3') => {\n if (version === '4' && strict) {\n return `z.strictObject({\n ${value}\n })`\n }\n\n if (strict) {\n return `z.object({\n ${value}\n }).strict()`\n }\n\n return `z.object({\n ${value}\n })`\n },\n string: (coercion?: boolean, min?: number, max?: number) => {\n return [coercion ? 'z.coerce.string()' : 'z.string()', min !== undefined ? `.min(${min})` : undefined, max !== undefined ? `.max(${max})` : undefined]\n .filter(Boolean)\n .join('')\n },\n //support for discriminatedUnion\n boolean: () => 'z.boolean()',\n undefined: () => 'z.undefined()',\n nullable: () => '.nullable()',\n null: () => 'z.null()',\n nullish: () => '.nullish()',\n array: (items: string[] = [], min?: number, max?: number, unique?: boolean) => {\n return [\n `z.array(${items?.join('')})`,\n min !== undefined ? `.min(${min})` : undefined,\n max !== undefined ? `.max(${max})` : undefined,\n unique ? `.refine(items => new Set(items).size === items.length, { message: \"Array entries must be unique\" })` : undefined,\n ]\n .filter(Boolean)\n .join('')\n },\n tuple: (items: string[] = []) => `z.tuple([${items?.join(', ')}])`,\n enum: (items: string[] = []) => `z.enum([${items?.join(', ')}])`,\n union: (items: string[] = []) => `z.union([${items?.join(', ')}])`,\n const: (value?: string | number | boolean) => `z.literal(${value ?? ''})`,\n /**\n * ISO 8601\n */\n datetime: (offset = false, local = false, version: '3' | '4' = '3') => {\n if (offset) {\n return version === '4' ? `z.iso.datetime({ offset: ${offset} })` : `z.string().datetime({ offset: ${offset} })`\n }\n\n if (local) {\n return version === '4' ? `z.iso.datetime({ local: ${local} })` : `z.string().datetime({ local: ${local} })`\n }\n\n return 'z.string().datetime()'\n },\n /**\n * Type `'date'` Date\n * Type `'string'` ISO date format (YYYY-MM-DD)\n * @default ISO date format (YYYY-MM-DD)\n */\n date: (type: 'date' | 'string' = 'string', coercion?: boolean, version: '3' | '4' = '3') => {\n if (type === 'string') {\n return version === '4' ? 'z.iso.date()' : 'z.string().date()'\n }\n\n if (coercion) {\n return 'z.coerce.date()'\n }\n\n return 'z.date()'\n },\n /**\n * Type `'date'` Date\n * Type `'string'` ISO time format (HH:mm:ss[.SSSSSS])\n * @default ISO time format (HH:mm:ss[.SSSSSS])\n */\n time: (type: 'date' | 'string' = 'string', coercion?: boolean, version: '3' | '4' = '3') => {\n if (type === 'string') {\n return version === '4' ? 'z.iso.time()' : 'z.string().time()'\n }\n\n if (coercion) {\n return 'z.coerce.date()'\n }\n\n return 'z.date()'\n },\n uuid: (coercion?: boolean, version: '3' | '4' = '3') =>\n version === '4' ? (coercion ? 'z.coerce.string().uuid()' : 'z.uuid()') : coercion ? 'z.coerce.string().uuid()' : 'z.string().uuid()',\n url: (coercion?: boolean, version: '3' | '4' = '3') =>\n version === '4' ? (coercion ? 'z.coerce.string().url()' : 'z.url()') : coercion ? 'z.coerce.string().url()' : 'z.string().url()',\n default: (value?: string | number | true | object) => {\n if (typeof value === 'object') {\n return '.default({})'\n }\n return `.default(${value ?? ''})`\n },\n and: (items: string[] = []) => items?.map((item) => `.and(${item})`).join(''),\n describe: (value = '') => `.describe(${value})`,\n min: (value?: number) => `.min(${value ?? ''})`,\n max: (value?: number) => `.max(${value ?? ''})`,\n optional: () => '.optional()',\n matches: (value = '', coercion?: boolean) => (coercion ? `z.coerce.string().regex(${value})` : `z.string().regex(${value})`),\n email: (coercion?: boolean, version: '3' | '4' = '3') =>\n version === '4' ? (coercion ? 'z.coerce.string().email()' : 'z.email()') : coercion ? 'z.coerce.string().email()' : 'z.string().email()',\n firstName: undefined,\n lastName: undefined,\n password: undefined,\n phone: undefined,\n readOnly: undefined,\n writeOnly: undefined,\n ref: (value?: string, version: '3' | '4' = '3') => {\n if (!value) {\n return undefined\n }\n\n return version === '4' ? value : `z.lazy(() => ${value})`\n },\n blob: () => 'z.instanceof(File)',\n deprecated: undefined,\n example: undefined,\n schema: undefined,\n catchall: (value?: string) => (value ? `.catchall(${value})` : undefined),\n name: undefined,\n} satisfies SchemaMapper<string | null | undefined>\n\n/**\n * @link based on https://github.com/cellular/oazapfts/blob/7ba226ebb15374e8483cc53e7532f1663179a22c/src/codegen/generate.ts#L398\n */\n\nexport function sort(items?: Schema[]): Schema[] {\n const order: string[] = [\n schemaKeywords.string,\n schemaKeywords.datetime,\n schemaKeywords.date,\n schemaKeywords.time,\n schemaKeywords.tuple,\n schemaKeywords.number,\n schemaKeywords.object,\n schemaKeywords.enum,\n schemaKeywords.url,\n schemaKeywords.email,\n schemaKeywords.firstName,\n schemaKeywords.lastName,\n schemaKeywords.password,\n schemaKeywords.matches,\n schemaKeywords.uuid,\n schemaKeywords.null,\n schemaKeywords.min,\n schemaKeywords.max,\n schemaKeywords.default,\n schemaKeywords.describe,\n schemaKeywords.optional,\n schemaKeywords.nullable,\n schemaKeywords.nullish,\n ]\n\n if (!items) {\n return []\n }\n\n return transformers.orderBy(items, [(v) => order.indexOf(v.keyword)], ['asc'])\n}\n\nconst shouldCoerce = (coercion: ParserOptions['coercion'] | undefined, type: 'dates' | 'strings' | 'numbers'): boolean => {\n if (coercion === undefined) {\n return false\n }\n if (typeof coercion === 'boolean') {\n return coercion\n }\n\n return !!coercion[type]\n}\n\ntype ParserOptions = {\n name: string\n typeName?: string\n description?: string\n keysToOmit?: string[]\n mapper?: Record<string, string>\n coercion?: boolean | { dates?: boolean; strings?: boolean; numbers?: boolean }\n wrapOutput?: (opts: { output: string; schema: any }) => string | undefined\n rawSchema: SchemaObject\n version: '3' | '4'\n}\n\nexport function parse({ parent, current, name, siblings }: SchemaTree, options: ParserOptions): string | undefined {\n const value = zodKeywordMapper[current.keyword as keyof typeof zodKeywordMapper]\n\n // Early exit: if siblings contain both matches and ref → skip matches entirely\n const hasMatches = siblings.some((it) => isKeyword(it, schemaKeywords.matches))\n const hasRef = siblings.some((it) => isKeyword(it, schemaKeywords.ref))\n\n if (hasMatches && hasRef && isKeyword(current, schemaKeywords.matches)) {\n return undefined // strip matches\n }\n\n if (!value) {\n return undefined\n }\n\n if (isKeyword(current, schemaKeywords.union)) {\n // zod union type needs at least 2 items\n if (Array.isArray(current.args) && current.args.length === 1) {\n return parse({ parent, name: name, current: current.args[0] as Schema, siblings }, options)\n }\n if (Array.isArray(current.args) && !current.args.length) {\n return ''\n }\n\n return zodKeywordMapper.union(\n sort(current.args)\n .map((schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options))\n .filter(Boolean),\n )\n }\n\n if (isKeyword(current, schemaKeywords.and)) {\n const items = sort(current.args)\n .filter((schema: Schema) => {\n return ![schemaKeywords.optional, schemaKeywords.describe].includes(schema.keyword as typeof schemaKeywords.describe)\n })\n .map((schema: Schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options))\n .filter(Boolean)\n\n return `${items.slice(0, 1)}${zodKeywordMapper.and(items.slice(1))}`\n }\n\n if (isKeyword(current, schemaKeywords.array)) {\n return zodKeywordMapper.array(\n sort(current.args.items)\n .map((schemas, _index, siblings) => parse({ parent: current, name: name, current: schemas, siblings }, options))\n .filter(Boolean),\n current.args.min,\n current.args.max,\n current.args.unique,\n )\n }\n\n if (isKeyword(current, schemaKeywords.enum)) {\n if (current.args.asConst) {\n if (current.args.items.length === 1) {\n const child = {\n keyword: schemaKeywords.const,\n args: current.args.items[0],\n }\n return parse({ parent: current, name: name, current: child, siblings: [child] }, options)\n }\n\n return zodKeywordMapper.union(\n current.args.items\n .map((schema) => ({\n keyword: schemaKeywords.const,\n args: schema,\n }))\n .map((schema, _index, siblings) => {\n return parse({ parent: current, name: name, current: schema, siblings }, options)\n })\n .filter(Boolean),\n )\n }\n\n return zodKeywordMapper.enum(\n current.args.items.map((schema) => {\n if (schema.format === 'boolean') {\n return transformers.stringify(schema.value)\n }\n\n if (schema.format === 'number') {\n return transformers.stringify(schema.value)\n }\n return transformers.stringify(schema.value)\n }),\n )\n }\n\n if (isKeyword(current, schemaKeywords.ref)) {\n return zodKeywordMapper.ref(current.args?.name, options.version)\n }\n\n if (isKeyword(current, schemaKeywords.object)) {\n const propertyEntries = Object.entries(current.args?.properties || {}).filter((item) => {\n const schema = item[1]\n return schema && typeof schema.map === 'function'\n })\n\n const properties = propertyEntries\n .map(([name, schemas]) => {\n const nameSchema = schemas.find((schema) => schema.keyword === schemaKeywords.name) as SchemaKeywordMapper['name']\n const mappedName = nameSchema?.args || name\n\n // custom mapper(pluginOptions)\n if (options.mapper?.[mappedName]) {\n return `\"${name}\": ${options.mapper?.[mappedName]}`\n }\n\n const baseSchemaOutput = sort(schemas)\n .map((schema) => parse({ parent: current, name, current: schema, siblings: schemas }, options))\n .filter(Boolean)\n .join('')\n\n const objectValue = options.wrapOutput\n ? options.wrapOutput({ output: baseSchemaOutput, schema: options.rawSchema?.properties?.[name] }) || baseSchemaOutput\n : baseSchemaOutput\n\n if (options.version === '4' && SchemaGenerator.find(schemas, schemaKeywords.ref)) {\n return `get ${name}(){\n return ${objectValue}\n }`\n }\n\n return `\"${name}\": ${objectValue}`\n })\n .join(',\\n')\n\n const additionalProperties = current.args?.additionalProperties?.length\n ? current.args.additionalProperties\n .map((schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options))\n .filter(Boolean)\n .join('')\n : undefined\n\n const text = [\n zodKeywordMapper.object(properties, current.args?.strict, options.version),\n additionalProperties ? zodKeywordMapper.catchall(additionalProperties) : undefined,\n ].filter(Boolean)\n\n return text.join('')\n }\n\n if (isKeyword(current, schemaKeywords.tuple)) {\n return zodKeywordMapper.tuple(\n current.args.items.map((schema, _index, siblings) => parse({ parent: current, name: name, current: schema, siblings }, options)).filter(Boolean),\n )\n }\n\n if (isKeyword(current, schemaKeywords.const)) {\n if (current.args.format === 'number' && current.args.value !== undefined) {\n return zodKeywordMapper.const(Number(current.args.value))\n }\n\n if (current.args.format === 'boolean' && current.args.value !== undefined) {\n return zodKeywordMapper.const(current.args.value)\n }\n return zodKeywordMapper.const(transformers.stringify(current.args.value))\n }\n\n if (isKeyword(current, schemaKeywords.matches)) {\n if (current.args) {\n return zodKeywordMapper.matches(transformers.toRegExpString(current.args, null), shouldCoerce(options.coercion, 'strings'))\n }\n }\n\n if (isKeyword(current, schemaKeywords.default)) {\n if (current.args) {\n return zodKeywordMapper.default(current.args)\n }\n }\n\n if (isKeyword(current, schemaKeywords.describe)) {\n if (current.args) {\n return zodKeywordMapper.describe(transformers.stringify(current.args.toString()))\n }\n }\n\n if (isKeyword(current, schemaKeywords.string)) {\n return zodKeywordMapper.string(shouldCoerce(options.coercion, 'strings'))\n }\n\n if (isKeyword(current, schemaKeywords.uuid)) {\n return zodKeywordMapper.uuid(shouldCoerce(options.coercion, 'strings'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.email)) {\n return zodKeywordMapper.email(shouldCoerce(options.coercion, 'strings'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.url)) {\n return zodKeywordMapper.url(shouldCoerce(options.coercion, 'strings'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.number)) {\n return zodKeywordMapper.number(shouldCoerce(options.coercion, 'numbers'))\n }\n\n if (isKeyword(current, schemaKeywords.integer)) {\n return zodKeywordMapper.integer(shouldCoerce(options.coercion, 'numbers'), undefined, undefined, options.version)\n }\n\n if (isKeyword(current, schemaKeywords.min)) {\n return zodKeywordMapper.min(current.args)\n }\n if (isKeyword(current, schemaKeywords.max)) {\n return zodKeywordMapper.max(current.args)\n }\n\n if (isKeyword(current, schemaKeywords.datetime)) {\n return zodKeywordMapper.datetime(current.args.offset, current.args.local, options.version)\n }\n\n if (isKeyword(current, schemaKeywords.date)) {\n return zodKeywordMapper.date(current.args.type, shouldCoerce(options.coercion, 'dates'), options.version)\n }\n\n if (isKeyword(current, schemaKeywords.time)) {\n return zodKeywordMapper.time(current.args.type, shouldCoerce(options.coercion, 'dates'), options.version)\n }\n\n if (current.keyword in zodKeywordMapper && 'args' in current) {\n const value = zodKeywordMapper[current.keyword as keyof typeof zodKeywordMapper] as (typeof zodKeywordMapper)['const']\n\n return value((current as SchemaKeywordBase<unknown>).args as any)\n }\n\n if (isKeyword(current, schemaKeywords.optional)) {\n if (siblings.some((schema) => isKeyword(schema, schemaKeywords.default))) return ''\n\n return value()\n }\n\n if (current.keyword in zodKeywordMapper) {\n return value()\n }\n\n return undefined\n}\n","import transformers from '@kubb/core/transformers'\nimport type { SchemaObject } from '@kubb/oas'\nimport { isKeyword, type Schema, SchemaGenerator, schemaKeywords } from '@kubb/plugin-oas'\nimport { Const, File, Type } from '@kubb/react'\nimport * as parserZod from '../parser.ts'\nimport type { PluginZod } from '../types.ts'\n\ntype Props = {\n name: string\n typeName?: string\n inferTypeName?: string\n tree: Array<Schema>\n rawSchema: SchemaObject\n description?: string\n coercion: PluginZod['resolvedOptions']['coercion']\n mapper: PluginZod['resolvedOptions']['mapper']\n keysToOmit?: string[]\n wrapOutput?: PluginZod['resolvedOptions']['wrapOutput']\n version: '3' | '4'\n emptySchemaType: PluginZod['resolvedOptions']['emptySchemaType']\n}\n\nexport function Zod({\n name,\n typeName,\n tree,\n rawSchema,\n inferTypeName,\n mapper,\n coercion,\n keysToOmit,\n description,\n wrapOutput,\n version,\n emptySchemaType,\n}: Props) {\n const hasTuple = !!SchemaGenerator.deepSearch(tree, schemaKeywords.tuple)\n\n const schemas = parserZod.sort(tree).filter((item) => {\n if (hasTuple && (isKeyword(item, schemaKeywords.min) || isKeyword(item, schemaKeywords.max))) {\n return false\n }\n\n return true\n })\n\n const output = schemas\n .map((schema, _index, siblings) =>\n parserZod.parse(\n { parent: undefined, current: schema, siblings },\n { name, keysToOmit, typeName, description, mapper, coercion, wrapOutput, rawSchema, version },\n ),\n )\n .filter(Boolean)\n .join('')\n\n let suffix = ''\n const firstSchema = schemas.at(0)\n const lastSchema = schemas.at(-1)\n\n if (lastSchema && isKeyword(lastSchema, schemaKeywords.nullable)) {\n if (firstSchema && isKeyword(firstSchema, schemaKeywords.ref)) {\n if (version === '3') {\n suffix = '.unwrap().schema.unwrap()'\n } else {\n suffix = '.unwrap().unwrap()'\n }\n } else {\n suffix = '.unwrap()'\n }\n } else {\n if (firstSchema && isKeyword(firstSchema, schemaKeywords.ref) && version === '3') {\n suffix = '.schema'\n }\n }\n\n const emptyValue = parserZod.parse(\n {\n parent: undefined,\n current: {\n keyword: schemaKeywords[emptySchemaType],\n },\n siblings: [],\n },\n { name, keysToOmit, typeName, description, mapper, coercion, wrapOutput, rawSchema, version },\n )\n\n const baseSchemaOutput =\n [output, keysToOmit?.length ? `${suffix}.omit({ ${keysToOmit.map((key) => `${key}: true`).join(',')} })` : undefined].filter(Boolean).join('') ||\n emptyValue ||\n ''\n const wrappedSchemaOutput = wrapOutput ? wrapOutput({ output: baseSchemaOutput, schema: rawSchema }) || baseSchemaOutput : baseSchemaOutput\n const finalOutput = typeName ? `${wrappedSchemaOutput} as unknown as ToZod<${typeName}>` : wrappedSchemaOutput\n\n return (\n <>\n <File.Source name={name} isExportable isIndexable>\n <Const\n export\n name={name}\n JSDoc={{\n comments: [description ? `@description ${transformers.jsStringEscape(description)}` : undefined].filter(Boolean),\n }}\n >\n {finalOutput}\n </Const>\n </File.Source>\n {inferTypeName && (\n <File.Source name={inferTypeName} isExportable isIndexable isTypeOnly>\n {typeName && (\n <Type export name={inferTypeName}>\n {typeName}\n </Type>\n )}\n {!typeName && (\n <Type export name={inferTypeName}>\n {`z.infer<typeof ${name}>`}\n </Type>\n )}\n </File.Source>\n )}\n </>\n )\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAWA,SAAgB,WAAW,EAAE,MAAM,cAAqB;CACtD,MAAM,iBAAiB,WAAW,QAC/B,MAAM,QAAQ;AACb,OAAK,IAAI,IAAI,UAAU,iBAAiB,MAAM,IAAI;AAElD,SAAO;IAET;CAGF,MAAM,YAAY,WAAW,QAC1B,MAAM,QAAQ;AACb,OAAK,IAAI,IAAI,UAAU,KAAK,MAAM;GAChC,GAAI,KAAK,IAAI,IAAI,UAAU,KAAK,OAAQ;IACvC,IAAI,UAAU,SAAS,eAAe,IAAI,UAAU,iBAAiB;;AAGxE,SAAO;IAET;AAGF,QACE,mGACE,kDAACA,kBAAK;EAAa;EAAM;EAAa;YACpC,kDAACC;G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