@orpc/zod 0.0.0-next.dcc6c29 → 0.0.0-next.dda04c5
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/README.md +17 -22
- package/dist/index.d.mts +17 -7
- package/dist/index.d.ts +17 -7
- package/dist/index.mjs +44 -27
- package/dist/zod4/index.d.mts +311 -0
- package/dist/zod4/index.d.ts +311 -0
- package/dist/zod4/index.mjs +668 -0
- package/package.json +13 -7
package/README.md
CHANGED
@@ -21,28 +21,24 @@
|
|
21
21
|
|
22
22
|
<h3 align="center">Typesafe APIs Made Simple 🪄</h3>
|
23
23
|
|
24
|
-
**oRPC is a powerful combination of RPC and OpenAPI**, makes it easy to build APIs that are end-to-end type-safe and adhere to OpenAPI standards
|
24
|
+
**oRPC is a powerful combination of RPC and OpenAPI**, makes it easy to build APIs that are end-to-end type-safe and adhere to OpenAPI standards
|
25
25
|
|
26
26
|
---
|
27
27
|
|
28
28
|
## Highlights
|
29
29
|
|
30
|
-
-
|
31
|
-
-
|
32
|
-
-
|
33
|
-
-
|
34
|
-
-
|
35
|
-
-
|
36
|
-
-
|
37
|
-
-
|
38
|
-
-
|
39
|
-
-
|
40
|
-
-
|
41
|
-
-
|
42
|
-
- **Reusability 🔄**: Write once and reuse your code across multiple purposes effortlessly.
|
43
|
-
- **Extendability 🔌**: Easily enhance oRPC with plugins, middleware, and interceptors.
|
44
|
-
- **Reliability 🛡️**: Well-tested, fully TypeScript, production-ready, and MIT licensed for peace of mind.
|
45
|
-
- **Simplicity 💡**: Enjoy straightforward, clean code with no hidden magic.
|
30
|
+
- **🔗 End-to-End Type Safety**: Ensure type-safe inputs, outputs, and errors from client to server.
|
31
|
+
- **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.
|
32
|
+
- **📝 Contract-First Development**: Optionally define your API contract before implementation.
|
33
|
+
- **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), Pinia Colada, and more.
|
34
|
+
- **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
|
35
|
+
- **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
|
36
|
+
- **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
|
37
|
+
- **⏱️ Lazy Router**: Enhance cold start times with our lazy routing feature.
|
38
|
+
- **📡 SSE & Streaming**: Enjoy full type-safe support for SSE and streaming.
|
39
|
+
- **🌍 Multi-Runtime Support**: Fast and lightweight on Cloudflare, Deno, Bun, Node.js, and beyond.
|
40
|
+
- **🔌 Extendability**: Easily extend functionality with plugins, middleware, and interceptors.
|
41
|
+
- **🛡️ Reliability**: Well-tested, TypeScript-based, production-ready, and MIT licensed.
|
46
42
|
|
47
43
|
## Documentation
|
48
44
|
|
@@ -53,13 +49,12 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
53
49
|
- [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
|
54
50
|
- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
|
55
51
|
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
52
|
+
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
53
|
+
- [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with [NestJS](https://nestjs.com/).
|
56
54
|
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
57
|
-
- [@orpc/
|
58
|
-
- [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
|
59
|
-
- [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
|
60
|
-
- [@orpc/svelte-query](https://www.npmjs.com/package/@orpc/svelte-query): Integration with [Svelte Query](https://tanstack.com/query/latest/docs/framework/svelte/overview).
|
55
|
+
- [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query): [TanStack Query](https://tanstack.com/query/latest) integration.
|
61
56
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
62
|
-
- [@orpc/
|
57
|
+
- [@orpc/hey-api](https://www.npmjs.com/package/@orpc/hey-api): [Hey API](https://heyapi.dev/) integration.
|
63
58
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
64
59
|
- [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
|
65
60
|
- [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
|
package/dist/index.d.mts
CHANGED
@@ -40,34 +40,43 @@ declare class ZodSmartCoercionPlugin<TContext extends Context> implements Standa
|
|
40
40
|
|
41
41
|
interface ZodToJsonSchemaOptions {
|
42
42
|
/**
|
43
|
-
* Max depth of lazy type
|
43
|
+
* Max depth of lazy type
|
44
44
|
*
|
45
|
-
* Used `{}` when
|
45
|
+
* Used `{}` when exceed max depth
|
46
46
|
*
|
47
47
|
* @default 3
|
48
48
|
*/
|
49
49
|
maxLazyDepth?: number;
|
50
50
|
/**
|
51
|
-
*
|
51
|
+
* Max depth of nested types
|
52
52
|
*
|
53
|
-
*
|
53
|
+
* Used anyJsonSchema (`{}`) when exceed max depth
|
54
|
+
*
|
55
|
+
* @default 10
|
54
56
|
*/
|
55
|
-
|
57
|
+
maxStructureDepth?: number;
|
56
58
|
/**
|
57
59
|
* The schema to be used to represent the any | unknown type.
|
58
60
|
*
|
59
61
|
* @default { }
|
60
62
|
*/
|
61
63
|
anyJsonSchema?: Exclude<JSONSchema, boolean>;
|
64
|
+
/**
|
65
|
+
* The schema to be used when the Zod schema is unsupported.
|
66
|
+
*
|
67
|
+
* @default { not: {} }
|
68
|
+
*/
|
69
|
+
unsupportedJsonSchema?: Exclude<JSONSchema, boolean>;
|
62
70
|
}
|
63
71
|
declare class ZodToJsonSchemaConverter implements ConditionalSchemaConverter {
|
64
72
|
#private;
|
65
73
|
private readonly maxLazyDepth;
|
74
|
+
private readonly maxStructureDepth;
|
66
75
|
private readonly unsupportedJsonSchema;
|
67
76
|
private readonly anyJsonSchema;
|
68
77
|
constructor(options?: ZodToJsonSchemaOptions);
|
69
78
|
condition(schema: AnySchema | undefined): boolean;
|
70
|
-
convert(schema: AnySchema | undefined, options: SchemaConvertOptions, lazyDepth?: number, isHandledCustomJSONSchema?: boolean, isHandledZodDescription?: boolean): [required: boolean, jsonSchema: Exclude<JSONSchema, boolean>];
|
79
|
+
convert(schema: AnySchema | undefined, options: SchemaConvertOptions, lazyDepth?: number, isHandledCustomJSONSchema?: boolean, isHandledZodDescription?: boolean, structureDepth?: number): [required: boolean, jsonSchema: Exclude<JSONSchema, boolean>];
|
71
80
|
}
|
72
81
|
|
73
82
|
declare const oz: {
|
@@ -78,4 +87,5 @@ declare const oz: {
|
|
78
87
|
openapi: typeof customJsonSchema;
|
79
88
|
};
|
80
89
|
|
81
|
-
export {
|
90
|
+
export { ZodSmartCoercionPlugin, ZodToJsonSchemaConverter, blob, composeParams, customJsonSchema, file, getCustomJsonSchema, getCustomZodDef, oz, regexp, setCustomZodDef, url };
|
91
|
+
export type { CustomParams, CustomZodDef, ZodToJsonSchemaOptions };
|
package/dist/index.d.ts
CHANGED
@@ -40,34 +40,43 @@ declare class ZodSmartCoercionPlugin<TContext extends Context> implements Standa
|
|
40
40
|
|
41
41
|
interface ZodToJsonSchemaOptions {
|
42
42
|
/**
|
43
|
-
* Max depth of lazy type
|
43
|
+
* Max depth of lazy type
|
44
44
|
*
|
45
|
-
* Used `{}` when
|
45
|
+
* Used `{}` when exceed max depth
|
46
46
|
*
|
47
47
|
* @default 3
|
48
48
|
*/
|
49
49
|
maxLazyDepth?: number;
|
50
50
|
/**
|
51
|
-
*
|
51
|
+
* Max depth of nested types
|
52
52
|
*
|
53
|
-
*
|
53
|
+
* Used anyJsonSchema (`{}`) when exceed max depth
|
54
|
+
*
|
55
|
+
* @default 10
|
54
56
|
*/
|
55
|
-
|
57
|
+
maxStructureDepth?: number;
|
56
58
|
/**
|
57
59
|
* The schema to be used to represent the any | unknown type.
|
58
60
|
*
|
59
61
|
* @default { }
|
60
62
|
*/
|
61
63
|
anyJsonSchema?: Exclude<JSONSchema, boolean>;
|
64
|
+
/**
|
65
|
+
* The schema to be used when the Zod schema is unsupported.
|
66
|
+
*
|
67
|
+
* @default { not: {} }
|
68
|
+
*/
|
69
|
+
unsupportedJsonSchema?: Exclude<JSONSchema, boolean>;
|
62
70
|
}
|
63
71
|
declare class ZodToJsonSchemaConverter implements ConditionalSchemaConverter {
|
64
72
|
#private;
|
65
73
|
private readonly maxLazyDepth;
|
74
|
+
private readonly maxStructureDepth;
|
66
75
|
private readonly unsupportedJsonSchema;
|
67
76
|
private readonly anyJsonSchema;
|
68
77
|
constructor(options?: ZodToJsonSchemaOptions);
|
69
78
|
condition(schema: AnySchema | undefined): boolean;
|
70
|
-
convert(schema: AnySchema | undefined, options: SchemaConvertOptions, lazyDepth?: number, isHandledCustomJSONSchema?: boolean, isHandledZodDescription?: boolean): [required: boolean, jsonSchema: Exclude<JSONSchema, boolean>];
|
79
|
+
convert(schema: AnySchema | undefined, options: SchemaConvertOptions, lazyDepth?: number, isHandledCustomJSONSchema?: boolean, isHandledZodDescription?: boolean, structureDepth?: number): [required: boolean, jsonSchema: Exclude<JSONSchema, boolean>];
|
71
80
|
}
|
72
81
|
|
73
82
|
declare const oz: {
|
@@ -78,4 +87,5 @@ declare const oz: {
|
|
78
87
|
openapi: typeof customJsonSchema;
|
79
88
|
};
|
80
89
|
|
81
|
-
export {
|
90
|
+
export { ZodSmartCoercionPlugin, ZodToJsonSchemaConverter, blob, composeParams, customJsonSchema, file, getCustomJsonSchema, getCustomZodDef, oz, regexp, setCustomZodDef, url };
|
91
|
+
export type { CustomParams, CustomZodDef, ZodToJsonSchemaOptions };
|
package/dist/index.mjs
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import { custom, ZodFirstPartyTypeKind } from 'zod';
|
2
2
|
import wcmatch from 'wildcard-match';
|
3
|
-
import { isObject, guard } from '@orpc/shared';
|
3
|
+
import { isObject, guard, toArray } from '@orpc/shared';
|
4
4
|
import { JSONSchemaFormat } from '@orpc/openapi';
|
5
5
|
import escapeStringRegexp from 'escape-string-regexp';
|
6
6
|
|
@@ -390,25 +390,39 @@ function safeToDate(value) {
|
|
390
390
|
|
391
391
|
class ZodToJsonSchemaConverter {
|
392
392
|
maxLazyDepth;
|
393
|
+
maxStructureDepth;
|
393
394
|
unsupportedJsonSchema;
|
394
395
|
anyJsonSchema;
|
395
396
|
constructor(options = {}) {
|
396
397
|
this.maxLazyDepth = options.maxLazyDepth ?? 3;
|
398
|
+
this.maxStructureDepth = options.maxStructureDepth ?? 10;
|
397
399
|
this.unsupportedJsonSchema = options.unsupportedJsonSchema ?? { not: {} };
|
398
400
|
this.anyJsonSchema = options.anyJsonSchema ?? {};
|
399
401
|
}
|
400
402
|
condition(schema) {
|
401
403
|
return schema !== void 0 && schema["~standard"].vendor === "zod";
|
402
404
|
}
|
403
|
-
convert(schema, options, lazyDepth = 0, isHandledCustomJSONSchema = false, isHandledZodDescription = false) {
|
405
|
+
convert(schema, options, lazyDepth = 0, isHandledCustomJSONSchema = false, isHandledZodDescription = false, structureDepth = 0) {
|
404
406
|
const def = schema._def;
|
407
|
+
if (structureDepth > this.maxStructureDepth) {
|
408
|
+
return [false, this.anyJsonSchema];
|
409
|
+
}
|
410
|
+
if (!options.minStructureDepthForRef || options.minStructureDepthForRef <= structureDepth) {
|
411
|
+
const components = toArray(options.components);
|
412
|
+
for (const component of components) {
|
413
|
+
if (component.schema === schema && component.allowedStrategies.includes(options.strategy)) {
|
414
|
+
return [component.required, { $ref: component.ref }];
|
415
|
+
}
|
416
|
+
}
|
417
|
+
}
|
405
418
|
if (!isHandledZodDescription && "description" in def && typeof def.description === "string") {
|
406
419
|
const [required, json] = this.convert(
|
407
420
|
schema,
|
408
421
|
options,
|
409
422
|
lazyDepth,
|
410
423
|
isHandledCustomJSONSchema,
|
411
|
-
true
|
424
|
+
true,
|
425
|
+
structureDepth
|
412
426
|
);
|
413
427
|
return [required, { ...json, description: def.description }];
|
414
428
|
}
|
@@ -420,7 +434,8 @@ class ZodToJsonSchemaConverter {
|
|
420
434
|
options,
|
421
435
|
lazyDepth,
|
422
436
|
true,
|
423
|
-
isHandledZodDescription
|
437
|
+
isHandledZodDescription,
|
438
|
+
structureDepth
|
424
439
|
);
|
425
440
|
return [required, { ...json, ...customJSONSchema }];
|
426
441
|
}
|
@@ -591,7 +606,7 @@ class ZodToJsonSchemaConverter {
|
|
591
606
|
const schema_ = schema;
|
592
607
|
const def2 = schema_._def;
|
593
608
|
const json = { type: "array" };
|
594
|
-
const [itemRequired, itemJson] = this.convert(def2.type, options, lazyDepth, false, false);
|
609
|
+
const [itemRequired, itemJson] = this.convert(def2.type, options, lazyDepth, false, false, structureDepth + 1);
|
595
610
|
json.items = this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy);
|
596
611
|
if (def2.exactLength) {
|
597
612
|
json.maxItems = def2.exactLength.value;
|
@@ -610,7 +625,7 @@ class ZodToJsonSchemaConverter {
|
|
610
625
|
const prefixItems = [];
|
611
626
|
const json = { type: "array" };
|
612
627
|
for (const item of schema_._def.items) {
|
613
|
-
const [itemRequired, itemJson] = this.convert(item, options, lazyDepth, false, false);
|
628
|
+
const [itemRequired, itemJson] = this.convert(item, options, lazyDepth, false, false, structureDepth + 1);
|
614
629
|
prefixItems.push(
|
615
630
|
this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy)
|
616
631
|
);
|
@@ -619,7 +634,7 @@ class ZodToJsonSchemaConverter {
|
|
619
634
|
json.prefixItems = prefixItems;
|
620
635
|
}
|
621
636
|
if (schema_._def.rest) {
|
622
|
-
const [itemRequired, itemJson] = this.convert(schema_._def.rest, options, lazyDepth, false, false);
|
637
|
+
const [itemRequired, itemJson] = this.convert(schema_._def.rest, options, lazyDepth, false, false, structureDepth + 1);
|
623
638
|
json.items = this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy);
|
624
639
|
}
|
625
640
|
return [true, json];
|
@@ -630,7 +645,7 @@ class ZodToJsonSchemaConverter {
|
|
630
645
|
const properties = {};
|
631
646
|
const required = [];
|
632
647
|
for (const [key, value] of Object.entries(schema_.shape)) {
|
633
|
-
const [itemRequired, itemJson] = this.convert(value, options, lazyDepth, false, false);
|
648
|
+
const [itemRequired, itemJson] = this.convert(value, options, lazyDepth, false, false, structureDepth + 1);
|
634
649
|
properties[key] = itemJson;
|
635
650
|
if (itemRequired) {
|
636
651
|
required.push(key);
|
@@ -648,7 +663,7 @@ class ZodToJsonSchemaConverter {
|
|
648
663
|
json.additionalProperties = false;
|
649
664
|
}
|
650
665
|
} else {
|
651
|
-
const [_, addJson] = this.convert(schema_._def.catchall, options, lazyDepth, false, false);
|
666
|
+
const [_, addJson] = this.convert(schema_._def.catchall, options, lazyDepth, false, false, structureDepth + 1);
|
652
667
|
json.additionalProperties = addJson;
|
653
668
|
}
|
654
669
|
return [true, json];
|
@@ -656,25 +671,25 @@ class ZodToJsonSchemaConverter {
|
|
656
671
|
case ZodFirstPartyTypeKind.ZodRecord: {
|
657
672
|
const schema_ = schema;
|
658
673
|
const json = { type: "object" };
|
659
|
-
const [__, keyJson] = this.convert(schema_._def.keyType, options, lazyDepth, false, false);
|
674
|
+
const [__, keyJson] = this.convert(schema_._def.keyType, options, lazyDepth, false, false, structureDepth + 1);
|
660
675
|
if (Object.entries(keyJson).some(([k, v]) => k !== "type" || v !== "string")) {
|
661
676
|
json.propertyNames = keyJson;
|
662
677
|
}
|
663
|
-
const [_, itemJson] = this.convert(schema_._def.valueType, options, lazyDepth, false, false);
|
678
|
+
const [_, itemJson] = this.convert(schema_._def.valueType, options, lazyDepth, false, false, structureDepth + 1);
|
664
679
|
json.additionalProperties = itemJson;
|
665
680
|
return [true, json];
|
666
681
|
}
|
667
682
|
case ZodFirstPartyTypeKind.ZodSet: {
|
668
683
|
const schema_ = schema;
|
669
684
|
const json = { type: "array", uniqueItems: true };
|
670
|
-
const [itemRequired, itemJson] = this.convert(schema_._def.valueType, options, lazyDepth, false, false);
|
685
|
+
const [itemRequired, itemJson] = this.convert(schema_._def.valueType, options, lazyDepth, false, false, structureDepth + 1);
|
671
686
|
json.items = this.#toArrayItemJsonSchema(itemRequired, itemJson, options.strategy);
|
672
687
|
return [true, json];
|
673
688
|
}
|
674
689
|
case ZodFirstPartyTypeKind.ZodMap: {
|
675
690
|
const schema_ = schema;
|
676
|
-
const [keyRequired, keyJson] = this.convert(schema_._def.keyType, options, lazyDepth, false, false);
|
677
|
-
const [valueRequired, valueJson] = this.convert(schema_._def.valueType, options, lazyDepth, false, false);
|
691
|
+
const [keyRequired, keyJson] = this.convert(schema_._def.keyType, options, lazyDepth, false, false, structureDepth + 1);
|
692
|
+
const [valueRequired, valueJson] = this.convert(schema_._def.valueType, options, lazyDepth, false, false, structureDepth + 1);
|
678
693
|
return [true, {
|
679
694
|
type: "array",
|
680
695
|
items: {
|
@@ -694,7 +709,7 @@ class ZodToJsonSchemaConverter {
|
|
694
709
|
const anyOf = [];
|
695
710
|
let required = true;
|
696
711
|
for (const item of schema_._def.options) {
|
697
|
-
const [itemRequired, itemJson] = this.convert(item, options, lazyDepth, false, false);
|
712
|
+
const [itemRequired, itemJson] = this.convert(item, options, lazyDepth, false, false, structureDepth);
|
698
713
|
if (!itemRequired) {
|
699
714
|
required = false;
|
700
715
|
if (itemJson !== this.unsupportedJsonSchema) {
|
@@ -714,7 +729,7 @@ class ZodToJsonSchemaConverter {
|
|
714
729
|
const allOf = [];
|
715
730
|
let required = false;
|
716
731
|
for (const item of [schema_._def.left, schema_._def.right]) {
|
717
|
-
const [itemRequired, itemJson] = this.convert(item, options, lazyDepth, false, false);
|
732
|
+
const [itemRequired, itemJson] = this.convert(item, options, lazyDepth, false, false, structureDepth);
|
718
733
|
allOf.push(itemJson);
|
719
734
|
if (itemRequired) {
|
720
735
|
required = true;
|
@@ -723,25 +738,26 @@ class ZodToJsonSchemaConverter {
|
|
723
738
|
return [required, { allOf }];
|
724
739
|
}
|
725
740
|
case ZodFirstPartyTypeKind.ZodLazy: {
|
726
|
-
|
741
|
+
const currentLazyDepth = lazyDepth + 1;
|
742
|
+
if (currentLazyDepth > this.maxLazyDepth) {
|
727
743
|
return [false, this.anyJsonSchema];
|
728
744
|
}
|
729
745
|
const schema_ = schema;
|
730
|
-
return this.convert(schema_._def.getter(), options,
|
746
|
+
return this.convert(schema_._def.getter(), options, currentLazyDepth, false, false, structureDepth);
|
731
747
|
}
|
732
748
|
case ZodFirstPartyTypeKind.ZodOptional: {
|
733
749
|
const schema_ = schema;
|
734
|
-
const [_, inner] = this.convert(schema_._def.innerType, options, lazyDepth, false, false);
|
750
|
+
const [_, inner] = this.convert(schema_._def.innerType, options, lazyDepth, false, false, structureDepth);
|
735
751
|
return [false, inner];
|
736
752
|
}
|
737
753
|
case ZodFirstPartyTypeKind.ZodReadonly: {
|
738
754
|
const schema_ = schema;
|
739
|
-
const [required, json] = this.convert(schema_._def.innerType, options, lazyDepth, false, false);
|
755
|
+
const [required, json] = this.convert(schema_._def.innerType, options, lazyDepth, false, false, structureDepth);
|
740
756
|
return [required, { ...json, readOnly: true }];
|
741
757
|
}
|
742
758
|
case ZodFirstPartyTypeKind.ZodDefault: {
|
743
759
|
const schema_ = schema;
|
744
|
-
const [_, json] = this.convert(schema_._def.innerType, options, lazyDepth, false, false);
|
760
|
+
const [_, json] = this.convert(schema_._def.innerType, options, lazyDepth, false, false, structureDepth);
|
745
761
|
return [false, { default: schema_._def.defaultValue(), ...json }];
|
746
762
|
}
|
747
763
|
case ZodFirstPartyTypeKind.ZodEffects: {
|
@@ -749,15 +765,15 @@ class ZodToJsonSchemaConverter {
|
|
749
765
|
if (schema_._def.effect.type === "transform" && options.strategy === "output") {
|
750
766
|
return [false, this.anyJsonSchema];
|
751
767
|
}
|
752
|
-
return this.convert(schema_._def.schema, options, lazyDepth, false, false);
|
768
|
+
return this.convert(schema_._def.schema, options, lazyDepth, false, false, structureDepth);
|
753
769
|
}
|
754
770
|
case ZodFirstPartyTypeKind.ZodCatch: {
|
755
771
|
const schema_ = schema;
|
756
|
-
return this.convert(schema_._def.innerType, options, lazyDepth, false, false);
|
772
|
+
return this.convert(schema_._def.innerType, options, lazyDepth, false, false, structureDepth);
|
757
773
|
}
|
758
774
|
case ZodFirstPartyTypeKind.ZodBranded: {
|
759
775
|
const schema_ = schema;
|
760
|
-
return this.convert(schema_._def.type, options, lazyDepth, false, false);
|
776
|
+
return this.convert(schema_._def.type, options, lazyDepth, false, false, structureDepth);
|
761
777
|
}
|
762
778
|
case ZodFirstPartyTypeKind.ZodPipeline: {
|
763
779
|
const schema_ = schema;
|
@@ -766,13 +782,14 @@ class ZodToJsonSchemaConverter {
|
|
766
782
|
options,
|
767
783
|
lazyDepth,
|
768
784
|
false,
|
769
|
-
false
|
785
|
+
false,
|
786
|
+
structureDepth
|
770
787
|
);
|
771
788
|
}
|
772
789
|
case ZodFirstPartyTypeKind.ZodNullable: {
|
773
790
|
const schema_ = schema;
|
774
|
-
const [required, json] = this.convert(schema_._def.innerType, options, lazyDepth, false, false);
|
775
|
-
return [required, { anyOf: [{ type: "null" }
|
791
|
+
const [required, json] = this.convert(schema_._def.innerType, options, lazyDepth, false, false, structureDepth);
|
792
|
+
return [required, { anyOf: [json, { type: "null" }] }];
|
776
793
|
}
|
777
794
|
}
|
778
795
|
return [true, this.unsupportedJsonSchema];
|