@orpc/zod 2.0.0-beta.18 → 2.0.0-beta.19
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 +5 -2
- package/dist/index.d.mts +243 -2
- package/dist/index.d.ts +243 -2
- package/dist/index.mjs +18 -2
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -49,11 +49,14 @@ You can read the documentation [here](https://orpc.dev).
|
|
|
49
49
|
**Framework & ecosystem integrations**
|
|
50
50
|
|
|
51
51
|
- [@orpc/next](https://www.npmjs.com/package/@orpc/next): Integrate with [Next.js Server Functions](https://nextjs.org/docs/app/getting-started/mutating-data).
|
|
52
|
+
- [@orpc/ai-sdk](https://www.npmjs.com/package/@orpc/ai-sdk): Turn contracts and procedures into [AI SDK](https://ai-sdk.dev/) tools.
|
|
52
53
|
- [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query): Integrate with [TanStack Query](https://tanstack.com/query/latest).
|
|
54
|
+
- [@orpc/pinia-colada](https://www.npmjs.com/package/@orpc/pinia-colada): Integrate with [Pinia Colada](https://pinia-colada.esm.dev/).
|
|
53
55
|
- [@orpc/experimental-effect](https://www.npmjs.com/package/@orpc/experimental-effect): Integrate with [Effect](https://effect.website/).
|
|
54
56
|
- [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Implement your contract with [NestJS](https://nestjs.com/).
|
|
55
57
|
- [@orpc/bun](https://www.npmjs.com/package/@orpc/bun): Adapters for [Bun's Redis](https://bun.sh/).
|
|
56
58
|
- [@orpc/cloudflare](https://www.npmjs.com/package/@orpc/cloudflare): Adapters for [Cloudflare's RateLimit and Durable Objects](https://developers.cloudflare.com/workers/).
|
|
59
|
+
- [@orpc/trpc](https://www.npmjs.com/package/@orpc/trpc): Reuse existing [tRPC](https://trpc.io/) routers within oRPC.
|
|
57
60
|
|
|
58
61
|
**Observability**
|
|
59
62
|
|
|
@@ -105,11 +108,10 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
105
108
|
<td align="center"><a href="https://github.com/valerii15298?ref=orpc" target="_blank" rel="noopener" title="Valerii Petryniak"><img src="https://avatars.githubusercontent.com/u/44531564?u=88ac74d9bacd20401518441907acad21063cd397&v=4" width="139" alt="Valerii Petryniak"/><br />Valerii Petryniak</a></td>
|
|
106
109
|
<td align="center"><a href="https://github.com/letstri?ref=orpc" target="_blank" rel="noopener" title="Valerii Strilets"><img src="https://avatars.githubusercontent.com/u/13253748?u=c7b10399ccc8f8081e24db94ec32cd9858e86ac3&v=4" width="139" alt="Valerii Strilets"/><br />Valerii Strilets</a></td>
|
|
107
110
|
<td align="center"><a href="https://github.com/K-Mistele?ref=orpc" target="_blank" rel="noopener" title="Kyle Mistele"><img src="https://avatars.githubusercontent.com/u/18430555?u=3afebeb81de666e35aaac3ed46f14159d7603ffb&v=4" width="139" alt="Kyle Mistele"/><br />Kyle Mistele</a></td>
|
|
108
|
-
<td align="center"><a href="https://github.com/andrewpeters9?ref=orpc" target="_blank" rel="noopener" title="Andrew Peters"><img src="https://avatars.githubusercontent.com/u/36251325?v=4" width="139" alt="Andrew Peters"/><br />Andrew Peters</a></td>
|
|
109
111
|
<td align="center"><a href="https://github.com/R44VC0RP?ref=orpc" target="_blank" rel="noopener" title="Ryan Vogel"><img src="https://avatars.githubusercontent.com/u/89211796?u=1857347b9787d8d8a7ea5bfc333f96be92d5a683&v=4" width="139" alt="Ryan Vogel"/><br />Ryan Vogel</a></td>
|
|
112
|
+
<td align="center"><a href="https://github.com/christ12938?ref=orpc" target="_blank" rel="noopener" title="christ12938"><img src="https://avatars.githubusercontent.com/u/25758598?v=4" width="139" alt="christ12938"/><br />christ12938</a></td>
|
|
110
113
|
</tr>
|
|
111
114
|
<tr>
|
|
112
|
-
<td align="center"><a href="https://github.com/christ12938?ref=orpc" target="_blank" rel="noopener" title="christ12938"><img src="https://avatars.githubusercontent.com/u/25758598?v=4" width="139" alt="christ12938"/><br />christ12938</a></td>
|
|
113
115
|
<td align="center"><a href="https://github.com/Ryanjso?ref=orpc" target="_blank" rel="noopener" title="Ryan Soderberg"><img src="https://avatars.githubusercontent.com/u/39172778?u=5ed913c31d57e7221b75784abcad48c7ebddde27&v=4" width="139" alt="Ryan Soderberg"/><br />Ryan Soderberg</a></td>
|
|
114
116
|
<td align="center"><a href="https://github.com/itigoore01?ref=orpc" target="_blank" rel="noopener" title="shota"><img src="https://avatars.githubusercontent.com/u/11831107?u=c976a6dc7e055eb026304c46c99100ed22b0c8e0&v=4" width="139" alt="shota"/><br />shota</a></td>
|
|
115
117
|
</tr>
|
|
@@ -169,6 +171,7 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
169
171
|
<a href="https://github.com/nelsonlaidev?ref=orpc" target="_blank" rel="noopener" title="Nelson Lai"><img src="https://avatars.githubusercontent.com/u/75498339?u=2fc0e0b95dd184c5ffb744df977cb15a18b60672&v=4" width="32" height="32" alt="Nelson Lai" /></a>
|
|
170
172
|
<a href="https://github.com/nguyenlc1993?ref=orpc" target="_blank" rel="noopener" title="Lê Cao Nguyên"><img src="https://avatars.githubusercontent.com/u/13871971?u=83c8b69d9e35b589c4e1f066cc113b1d9461386f&v=4" width="32" height="32" alt="Lê Cao Nguyên" /></a>
|
|
171
173
|
<a href="https://github.com/wobsoriano?ref=orpc" target="_blank" rel="noopener" title="Robert Soriano"><img src="https://avatars.githubusercontent.com/u/13049130?u=6d72104182e7c9ed25934815313fb69107332111&v=4" width="32" height="32" alt="Robert Soriano" /></a>
|
|
174
|
+
<a href="https://github.com/andrewpeters9?ref=orpc" target="_blank" rel="noopener" title="Andrew Peters"><img src="https://avatars.githubusercontent.com/u/36251325?v=4" width="32" height="32" alt="Andrew Peters" /></a>
|
|
172
175
|
<a href="https://github.com/SKostyukovich?ref=orpc" target="_blank" rel="noopener" title="SKostyukovich"><img src="https://avatars.githubusercontent.com/u/10700067?v=4" width="32" height="32" alt="SKostyukovich" /></a>
|
|
173
176
|
<a href="https://github.com/peter-adam-dy?ref=orpc" target="_blank" rel="noopener" title="Peter Adam"><img src="https://avatars.githubusercontent.com/u/132129459?u=4f3dbbb3b443990b56acb7d6a5d11ed2c555f6db&v=4" width="32" height="32" alt="Peter Adam" /></a>
|
|
174
177
|
<a href="https://github.com/FabworksHQ?ref=orpc" target="_blank" rel="noopener" title="Fabworks"><img src="https://avatars.githubusercontent.com/u/160179500?v=4" width="32" height="32" alt="Fabworks" /></a>
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { JsonSchemaConverter, AnySchema, JsonSchemaConverterDirection, JsonSchema } from '@orpc/json-schema';
|
|
2
|
-
import
|
|
2
|
+
import * as zod_v4_core from 'zod/v4/core';
|
|
3
|
+
import { ToJSONSchemaParams, $input, $output } from 'zod/v4/core';
|
|
4
|
+
import * as json_schema_typed from 'json-schema-typed';
|
|
3
5
|
|
|
4
6
|
interface ZodToJsonSchemaConverterOptions extends Omit<ToJSONSchemaParams, 'target' | 'io'> {
|
|
5
7
|
}
|
|
@@ -9,7 +11,246 @@ declare class ZodToJsonSchemaConverter implements JsonSchemaConverter {
|
|
|
9
11
|
condition(schema: AnySchema | undefined, _direction: JsonSchemaConverterDirection): boolean;
|
|
10
12
|
convert(schema: AnySchema | undefined, direction: JsonSchemaConverterDirection): [jsonSchema: JsonSchema, optional: boolean];
|
|
11
13
|
private convertZod;
|
|
14
|
+
private getCustomJsonSchema;
|
|
12
15
|
}
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Zod registry for customizing generated JSON schema, can use both for .input and .output
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { JSON_SCHEMA_REGISTRY } from '@orpc/zod'
|
|
23
|
+
*
|
|
24
|
+
* const user = z.object({
|
|
25
|
+
* name: z.string(),
|
|
26
|
+
* age: z.number(),
|
|
27
|
+
* })
|
|
28
|
+
*
|
|
29
|
+
* JSON_SCHEMA_REGISTRY.add(user, {
|
|
30
|
+
* examples: [{ name: 'John', age: 20 }],
|
|
31
|
+
* })
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
declare const JSON_SCHEMA_REGISTRY: zod_v4_core.$ZodRegistry<{
|
|
35
|
+
$anchor?: string;
|
|
36
|
+
$comment?: string;
|
|
37
|
+
$defs?: Record<string, json_schema_typed.JSONSchema>;
|
|
38
|
+
$dynamicAnchor?: string;
|
|
39
|
+
$dynamicRef?: string;
|
|
40
|
+
$id?: string;
|
|
41
|
+
$ref?: string;
|
|
42
|
+
$schema?: string;
|
|
43
|
+
$vocabulary?: Record<string, string>;
|
|
44
|
+
additionalItems?: json_schema_typed.JSONSchema;
|
|
45
|
+
additionalProperties?: json_schema_typed.JSONSchema;
|
|
46
|
+
allOf?: (json_schema_typed.JSONSchema<typeof $input | typeof $output, json_schema_typed.JSONSchema.TypeValue>[] | readonly json_schema_typed.JSONSchema<typeof $input | typeof $output, json_schema_typed.JSONSchema.TypeValue>[]) | undefined;
|
|
47
|
+
anyOf?: (json_schema_typed.JSONSchema<typeof $input | typeof $output, json_schema_typed.JSONSchema.TypeValue>[] | readonly json_schema_typed.JSONSchema<typeof $input | typeof $output, json_schema_typed.JSONSchema.TypeValue>[]) | undefined;
|
|
48
|
+
const?: typeof $input | typeof $output | undefined;
|
|
49
|
+
contains?: json_schema_typed.JSONSchema<typeof $input | typeof $output, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
50
|
+
contentEncoding?: "7bit" | "8bit" | "base64" | "binary" | "ietf-token" | "quoted-printable" | "x-token";
|
|
51
|
+
contentMediaType?: string;
|
|
52
|
+
contentSchema?: json_schema_typed.JSONSchema<typeof $input | typeof $output, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
53
|
+
default?: typeof $input | typeof $output | undefined;
|
|
54
|
+
definitions?: Record<string, json_schema_typed.JSONSchema>;
|
|
55
|
+
dependencies?: Record<string, (string[] | readonly string[]) | json_schema_typed.JSONSchema>;
|
|
56
|
+
dependentRequired?: Record<string, string[] | readonly string[]>;
|
|
57
|
+
dependentSchemas?: Record<string, json_schema_typed.JSONSchema>;
|
|
58
|
+
deprecated?: boolean;
|
|
59
|
+
description?: string;
|
|
60
|
+
else?: json_schema_typed.JSONSchema<typeof $input | typeof $output, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
61
|
+
enum?: ((typeof $input | typeof $output)[] | readonly (typeof $input | typeof $output)[]) | undefined;
|
|
62
|
+
examples?: ((typeof $input | typeof $output)[] | readonly (typeof $input | typeof $output)[]) | undefined;
|
|
63
|
+
exclusiveMaximum?: number;
|
|
64
|
+
exclusiveMinimum?: number;
|
|
65
|
+
format?: string;
|
|
66
|
+
if?: json_schema_typed.JSONSchema<typeof $input | typeof $output, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
67
|
+
items?: json_schema_typed.JSONSchema;
|
|
68
|
+
maxContains?: number;
|
|
69
|
+
maximum?: number;
|
|
70
|
+
maxItems?: number;
|
|
71
|
+
maxLength?: number;
|
|
72
|
+
maxProperties?: number;
|
|
73
|
+
minContains?: number;
|
|
74
|
+
minimum?: number;
|
|
75
|
+
minItems?: number;
|
|
76
|
+
minLength?: number;
|
|
77
|
+
minProperties?: number;
|
|
78
|
+
multipleOf?: number;
|
|
79
|
+
not?: json_schema_typed.JSONSchema<typeof $input | typeof $output, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
80
|
+
oneOf?: (json_schema_typed.JSONSchema<typeof $input | typeof $output, json_schema_typed.JSONSchema.TypeValue>[] | readonly json_schema_typed.JSONSchema<typeof $input | typeof $output, json_schema_typed.JSONSchema.TypeValue>[]) | undefined;
|
|
81
|
+
pattern?: string;
|
|
82
|
+
patternProperties?: Record<string, json_schema_typed.JSONSchema>;
|
|
83
|
+
prefixItems?: (json_schema_typed.JSONSchema<any, json_schema_typed.JSONSchema.TypeValue>[] | readonly json_schema_typed.JSONSchema<any, json_schema_typed.JSONSchema.TypeValue>[]) | json_schema_typed.JSONSchema;
|
|
84
|
+
properties?: Record<string, json_schema_typed.JSONSchema>;
|
|
85
|
+
propertyNames?: json_schema_typed.JSONSchema;
|
|
86
|
+
readOnly?: boolean;
|
|
87
|
+
required?: string[] | readonly string[];
|
|
88
|
+
then?: json_schema_typed.JSONSchema<typeof $input | typeof $output, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
89
|
+
title?: string;
|
|
90
|
+
type?: json_schema_typed.JSONSchema.TypeValue | undefined;
|
|
91
|
+
unevaluatedItems?: json_schema_typed.JSONSchema;
|
|
92
|
+
unevaluatedProperties?: json_schema_typed.JSONSchema;
|
|
93
|
+
uniqueItems?: boolean;
|
|
94
|
+
writeOnly?: boolean;
|
|
95
|
+
}, zod_v4_core.$ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>>>;
|
|
96
|
+
/**
|
|
97
|
+
* Zod registry for customizing generated JSON schema, only useful for .input
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* import { JSON_SCHEMA_INPUT_REGISTRY } from '@orpc/zod'
|
|
102
|
+
*
|
|
103
|
+
* const user = z.object({
|
|
104
|
+
* name: z.string(),
|
|
105
|
+
* age: z.string().transform(v => Number(v)),
|
|
106
|
+
* })
|
|
107
|
+
*
|
|
108
|
+
* JSON_SCHEMA_INPUT_REGISTRY.add(user, {
|
|
109
|
+
* examples: [{ name: 'John', age: "20" }],
|
|
110
|
+
* })
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
declare const JSON_SCHEMA_INPUT_REGISTRY: zod_v4_core.$ZodRegistry<{
|
|
114
|
+
$anchor?: string;
|
|
115
|
+
$comment?: string;
|
|
116
|
+
$defs?: Record<string, json_schema_typed.JSONSchema>;
|
|
117
|
+
$dynamicAnchor?: string;
|
|
118
|
+
$dynamicRef?: string;
|
|
119
|
+
$id?: string;
|
|
120
|
+
$ref?: string;
|
|
121
|
+
$schema?: string;
|
|
122
|
+
$vocabulary?: Record<string, string>;
|
|
123
|
+
additionalItems?: json_schema_typed.JSONSchema;
|
|
124
|
+
additionalProperties?: json_schema_typed.JSONSchema;
|
|
125
|
+
allOf?: (json_schema_typed.JSONSchema<typeof $input, json_schema_typed.JSONSchema.TypeValue>[] | readonly json_schema_typed.JSONSchema<typeof $input, json_schema_typed.JSONSchema.TypeValue>[]) | undefined;
|
|
126
|
+
anyOf?: (json_schema_typed.JSONSchema<typeof $input, json_schema_typed.JSONSchema.TypeValue>[] | readonly json_schema_typed.JSONSchema<typeof $input, json_schema_typed.JSONSchema.TypeValue>[]) | undefined;
|
|
127
|
+
const?: typeof $input | undefined;
|
|
128
|
+
contains?: json_schema_typed.JSONSchema<typeof $input, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
129
|
+
contentEncoding?: "7bit" | "8bit" | "base64" | "binary" | "ietf-token" | "quoted-printable" | "x-token";
|
|
130
|
+
contentMediaType?: string;
|
|
131
|
+
contentSchema?: json_schema_typed.JSONSchema<typeof $input, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
132
|
+
default?: typeof $input | undefined;
|
|
133
|
+
definitions?: Record<string, json_schema_typed.JSONSchema>;
|
|
134
|
+
dependencies?: Record<string, (string[] | readonly string[]) | json_schema_typed.JSONSchema>;
|
|
135
|
+
dependentRequired?: Record<string, string[] | readonly string[]>;
|
|
136
|
+
dependentSchemas?: Record<string, json_schema_typed.JSONSchema>;
|
|
137
|
+
deprecated?: boolean;
|
|
138
|
+
description?: string;
|
|
139
|
+
else?: json_schema_typed.JSONSchema<typeof $input, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
140
|
+
enum?: ((typeof $input)[] | readonly (typeof $input)[]) | undefined;
|
|
141
|
+
examples?: ((typeof $input)[] | readonly (typeof $input)[]) | undefined;
|
|
142
|
+
exclusiveMaximum?: number;
|
|
143
|
+
exclusiveMinimum?: number;
|
|
144
|
+
format?: string;
|
|
145
|
+
if?: json_schema_typed.JSONSchema<typeof $input, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
146
|
+
items?: json_schema_typed.JSONSchema;
|
|
147
|
+
maxContains?: number;
|
|
148
|
+
maximum?: number;
|
|
149
|
+
maxItems?: number;
|
|
150
|
+
maxLength?: number;
|
|
151
|
+
maxProperties?: number;
|
|
152
|
+
minContains?: number;
|
|
153
|
+
minimum?: number;
|
|
154
|
+
minItems?: number;
|
|
155
|
+
minLength?: number;
|
|
156
|
+
minProperties?: number;
|
|
157
|
+
multipleOf?: number;
|
|
158
|
+
not?: json_schema_typed.JSONSchema<typeof $input, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
159
|
+
oneOf?: (json_schema_typed.JSONSchema<typeof $input, json_schema_typed.JSONSchema.TypeValue>[] | readonly json_schema_typed.JSONSchema<typeof $input, json_schema_typed.JSONSchema.TypeValue>[]) | undefined;
|
|
160
|
+
pattern?: string;
|
|
161
|
+
patternProperties?: Record<string, json_schema_typed.JSONSchema>;
|
|
162
|
+
prefixItems?: (json_schema_typed.JSONSchema<any, json_schema_typed.JSONSchema.TypeValue>[] | readonly json_schema_typed.JSONSchema<any, json_schema_typed.JSONSchema.TypeValue>[]) | json_schema_typed.JSONSchema;
|
|
163
|
+
properties?: Record<string, json_schema_typed.JSONSchema>;
|
|
164
|
+
propertyNames?: json_schema_typed.JSONSchema;
|
|
165
|
+
readOnly?: boolean;
|
|
166
|
+
required?: string[] | readonly string[];
|
|
167
|
+
then?: json_schema_typed.JSONSchema<typeof $input, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
168
|
+
title?: string;
|
|
169
|
+
type?: json_schema_typed.JSONSchema.TypeValue | undefined;
|
|
170
|
+
unevaluatedItems?: json_schema_typed.JSONSchema;
|
|
171
|
+
unevaluatedProperties?: json_schema_typed.JSONSchema;
|
|
172
|
+
uniqueItems?: boolean;
|
|
173
|
+
writeOnly?: boolean;
|
|
174
|
+
}, zod_v4_core.$ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>>>;
|
|
175
|
+
/**
|
|
176
|
+
* Zod registry for customizing generated JSON schema, only useful for .output
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts
|
|
180
|
+
* import { JSON_SCHEMA_OUTPUT_REGISTRY } from '@orpc/zod'
|
|
181
|
+
*
|
|
182
|
+
* const user = z.object({
|
|
183
|
+
* name: z.string(),
|
|
184
|
+
* age: z.string().transform(v => Number(v)),
|
|
185
|
+
* })
|
|
186
|
+
*
|
|
187
|
+
* JSON_SCHEMA_OUTPUT_REGISTRY.add(user, {
|
|
188
|
+
* examples: [{ name: 'John', age: 20 }],
|
|
189
|
+
* })
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
declare const JSON_SCHEMA_OUTPUT_REGISTRY: zod_v4_core.$ZodRegistry<{
|
|
193
|
+
$anchor?: string;
|
|
194
|
+
$comment?: string;
|
|
195
|
+
$defs?: Record<string, json_schema_typed.JSONSchema>;
|
|
196
|
+
$dynamicAnchor?: string;
|
|
197
|
+
$dynamicRef?: string;
|
|
198
|
+
$id?: string;
|
|
199
|
+
$ref?: string;
|
|
200
|
+
$schema?: string;
|
|
201
|
+
$vocabulary?: Record<string, string>;
|
|
202
|
+
additionalItems?: json_schema_typed.JSONSchema;
|
|
203
|
+
additionalProperties?: json_schema_typed.JSONSchema;
|
|
204
|
+
allOf?: (json_schema_typed.JSONSchema<typeof $output, json_schema_typed.JSONSchema.TypeValue>[] | readonly json_schema_typed.JSONSchema<typeof $output, json_schema_typed.JSONSchema.TypeValue>[]) | undefined;
|
|
205
|
+
anyOf?: (json_schema_typed.JSONSchema<typeof $output, json_schema_typed.JSONSchema.TypeValue>[] | readonly json_schema_typed.JSONSchema<typeof $output, json_schema_typed.JSONSchema.TypeValue>[]) | undefined;
|
|
206
|
+
const?: typeof $output | undefined;
|
|
207
|
+
contains?: json_schema_typed.JSONSchema<typeof $output, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
208
|
+
contentEncoding?: "7bit" | "8bit" | "base64" | "binary" | "ietf-token" | "quoted-printable" | "x-token";
|
|
209
|
+
contentMediaType?: string;
|
|
210
|
+
contentSchema?: json_schema_typed.JSONSchema<typeof $output, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
211
|
+
default?: typeof $output | undefined;
|
|
212
|
+
definitions?: Record<string, json_schema_typed.JSONSchema>;
|
|
213
|
+
dependencies?: Record<string, (string[] | readonly string[]) | json_schema_typed.JSONSchema>;
|
|
214
|
+
dependentRequired?: Record<string, string[] | readonly string[]>;
|
|
215
|
+
dependentSchemas?: Record<string, json_schema_typed.JSONSchema>;
|
|
216
|
+
deprecated?: boolean;
|
|
217
|
+
description?: string;
|
|
218
|
+
else?: json_schema_typed.JSONSchema<typeof $output, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
219
|
+
enum?: ((typeof $output)[] | readonly (typeof $output)[]) | undefined;
|
|
220
|
+
examples?: ((typeof $output)[] | readonly (typeof $output)[]) | undefined;
|
|
221
|
+
exclusiveMaximum?: number;
|
|
222
|
+
exclusiveMinimum?: number;
|
|
223
|
+
format?: string;
|
|
224
|
+
if?: json_schema_typed.JSONSchema<typeof $output, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
225
|
+
items?: json_schema_typed.JSONSchema;
|
|
226
|
+
maxContains?: number;
|
|
227
|
+
maximum?: number;
|
|
228
|
+
maxItems?: number;
|
|
229
|
+
maxLength?: number;
|
|
230
|
+
maxProperties?: number;
|
|
231
|
+
minContains?: number;
|
|
232
|
+
minimum?: number;
|
|
233
|
+
minItems?: number;
|
|
234
|
+
minLength?: number;
|
|
235
|
+
minProperties?: number;
|
|
236
|
+
multipleOf?: number;
|
|
237
|
+
not?: json_schema_typed.JSONSchema<typeof $output, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
238
|
+
oneOf?: (json_schema_typed.JSONSchema<typeof $output, json_schema_typed.JSONSchema.TypeValue>[] | readonly json_schema_typed.JSONSchema<typeof $output, json_schema_typed.JSONSchema.TypeValue>[]) | undefined;
|
|
239
|
+
pattern?: string;
|
|
240
|
+
patternProperties?: Record<string, json_schema_typed.JSONSchema>;
|
|
241
|
+
prefixItems?: (json_schema_typed.JSONSchema<any, json_schema_typed.JSONSchema.TypeValue>[] | readonly json_schema_typed.JSONSchema<any, json_schema_typed.JSONSchema.TypeValue>[]) | json_schema_typed.JSONSchema;
|
|
242
|
+
properties?: Record<string, json_schema_typed.JSONSchema>;
|
|
243
|
+
propertyNames?: json_schema_typed.JSONSchema;
|
|
244
|
+
readOnly?: boolean;
|
|
245
|
+
required?: string[] | readonly string[];
|
|
246
|
+
then?: json_schema_typed.JSONSchema<typeof $output, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
247
|
+
title?: string;
|
|
248
|
+
type?: json_schema_typed.JSONSchema.TypeValue | undefined;
|
|
249
|
+
unevaluatedItems?: json_schema_typed.JSONSchema;
|
|
250
|
+
unevaluatedProperties?: json_schema_typed.JSONSchema;
|
|
251
|
+
uniqueItems?: boolean;
|
|
252
|
+
writeOnly?: boolean;
|
|
253
|
+
}, zod_v4_core.$ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>>>;
|
|
254
|
+
|
|
255
|
+
export { JSON_SCHEMA_INPUT_REGISTRY, JSON_SCHEMA_OUTPUT_REGISTRY, JSON_SCHEMA_REGISTRY, ZodToJsonSchemaConverter };
|
|
15
256
|
export type { ZodToJsonSchemaConverterOptions };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { JsonSchemaConverter, AnySchema, JsonSchemaConverterDirection, JsonSchema } from '@orpc/json-schema';
|
|
2
|
-
import
|
|
2
|
+
import * as zod_v4_core from 'zod/v4/core';
|
|
3
|
+
import { ToJSONSchemaParams, $input, $output } from 'zod/v4/core';
|
|
4
|
+
import * as json_schema_typed from 'json-schema-typed';
|
|
3
5
|
|
|
4
6
|
interface ZodToJsonSchemaConverterOptions extends Omit<ToJSONSchemaParams, 'target' | 'io'> {
|
|
5
7
|
}
|
|
@@ -9,7 +11,246 @@ declare class ZodToJsonSchemaConverter implements JsonSchemaConverter {
|
|
|
9
11
|
condition(schema: AnySchema | undefined, _direction: JsonSchemaConverterDirection): boolean;
|
|
10
12
|
convert(schema: AnySchema | undefined, direction: JsonSchemaConverterDirection): [jsonSchema: JsonSchema, optional: boolean];
|
|
11
13
|
private convertZod;
|
|
14
|
+
private getCustomJsonSchema;
|
|
12
15
|
}
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Zod registry for customizing generated JSON schema, can use both for .input and .output
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* import { JSON_SCHEMA_REGISTRY } from '@orpc/zod'
|
|
23
|
+
*
|
|
24
|
+
* const user = z.object({
|
|
25
|
+
* name: z.string(),
|
|
26
|
+
* age: z.number(),
|
|
27
|
+
* })
|
|
28
|
+
*
|
|
29
|
+
* JSON_SCHEMA_REGISTRY.add(user, {
|
|
30
|
+
* examples: [{ name: 'John', age: 20 }],
|
|
31
|
+
* })
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
declare const JSON_SCHEMA_REGISTRY: zod_v4_core.$ZodRegistry<{
|
|
35
|
+
$anchor?: string;
|
|
36
|
+
$comment?: string;
|
|
37
|
+
$defs?: Record<string, json_schema_typed.JSONSchema>;
|
|
38
|
+
$dynamicAnchor?: string;
|
|
39
|
+
$dynamicRef?: string;
|
|
40
|
+
$id?: string;
|
|
41
|
+
$ref?: string;
|
|
42
|
+
$schema?: string;
|
|
43
|
+
$vocabulary?: Record<string, string>;
|
|
44
|
+
additionalItems?: json_schema_typed.JSONSchema;
|
|
45
|
+
additionalProperties?: json_schema_typed.JSONSchema;
|
|
46
|
+
allOf?: (json_schema_typed.JSONSchema<typeof $input | typeof $output, json_schema_typed.JSONSchema.TypeValue>[] | readonly json_schema_typed.JSONSchema<typeof $input | typeof $output, json_schema_typed.JSONSchema.TypeValue>[]) | undefined;
|
|
47
|
+
anyOf?: (json_schema_typed.JSONSchema<typeof $input | typeof $output, json_schema_typed.JSONSchema.TypeValue>[] | readonly json_schema_typed.JSONSchema<typeof $input | typeof $output, json_schema_typed.JSONSchema.TypeValue>[]) | undefined;
|
|
48
|
+
const?: typeof $input | typeof $output | undefined;
|
|
49
|
+
contains?: json_schema_typed.JSONSchema<typeof $input | typeof $output, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
50
|
+
contentEncoding?: "7bit" | "8bit" | "base64" | "binary" | "ietf-token" | "quoted-printable" | "x-token";
|
|
51
|
+
contentMediaType?: string;
|
|
52
|
+
contentSchema?: json_schema_typed.JSONSchema<typeof $input | typeof $output, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
53
|
+
default?: typeof $input | typeof $output | undefined;
|
|
54
|
+
definitions?: Record<string, json_schema_typed.JSONSchema>;
|
|
55
|
+
dependencies?: Record<string, (string[] | readonly string[]) | json_schema_typed.JSONSchema>;
|
|
56
|
+
dependentRequired?: Record<string, string[] | readonly string[]>;
|
|
57
|
+
dependentSchemas?: Record<string, json_schema_typed.JSONSchema>;
|
|
58
|
+
deprecated?: boolean;
|
|
59
|
+
description?: string;
|
|
60
|
+
else?: json_schema_typed.JSONSchema<typeof $input | typeof $output, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
61
|
+
enum?: ((typeof $input | typeof $output)[] | readonly (typeof $input | typeof $output)[]) | undefined;
|
|
62
|
+
examples?: ((typeof $input | typeof $output)[] | readonly (typeof $input | typeof $output)[]) | undefined;
|
|
63
|
+
exclusiveMaximum?: number;
|
|
64
|
+
exclusiveMinimum?: number;
|
|
65
|
+
format?: string;
|
|
66
|
+
if?: json_schema_typed.JSONSchema<typeof $input | typeof $output, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
67
|
+
items?: json_schema_typed.JSONSchema;
|
|
68
|
+
maxContains?: number;
|
|
69
|
+
maximum?: number;
|
|
70
|
+
maxItems?: number;
|
|
71
|
+
maxLength?: number;
|
|
72
|
+
maxProperties?: number;
|
|
73
|
+
minContains?: number;
|
|
74
|
+
minimum?: number;
|
|
75
|
+
minItems?: number;
|
|
76
|
+
minLength?: number;
|
|
77
|
+
minProperties?: number;
|
|
78
|
+
multipleOf?: number;
|
|
79
|
+
not?: json_schema_typed.JSONSchema<typeof $input | typeof $output, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
80
|
+
oneOf?: (json_schema_typed.JSONSchema<typeof $input | typeof $output, json_schema_typed.JSONSchema.TypeValue>[] | readonly json_schema_typed.JSONSchema<typeof $input | typeof $output, json_schema_typed.JSONSchema.TypeValue>[]) | undefined;
|
|
81
|
+
pattern?: string;
|
|
82
|
+
patternProperties?: Record<string, json_schema_typed.JSONSchema>;
|
|
83
|
+
prefixItems?: (json_schema_typed.JSONSchema<any, json_schema_typed.JSONSchema.TypeValue>[] | readonly json_schema_typed.JSONSchema<any, json_schema_typed.JSONSchema.TypeValue>[]) | json_schema_typed.JSONSchema;
|
|
84
|
+
properties?: Record<string, json_schema_typed.JSONSchema>;
|
|
85
|
+
propertyNames?: json_schema_typed.JSONSchema;
|
|
86
|
+
readOnly?: boolean;
|
|
87
|
+
required?: string[] | readonly string[];
|
|
88
|
+
then?: json_schema_typed.JSONSchema<typeof $input | typeof $output, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
89
|
+
title?: string;
|
|
90
|
+
type?: json_schema_typed.JSONSchema.TypeValue | undefined;
|
|
91
|
+
unevaluatedItems?: json_schema_typed.JSONSchema;
|
|
92
|
+
unevaluatedProperties?: json_schema_typed.JSONSchema;
|
|
93
|
+
uniqueItems?: boolean;
|
|
94
|
+
writeOnly?: boolean;
|
|
95
|
+
}, zod_v4_core.$ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>>>;
|
|
96
|
+
/**
|
|
97
|
+
* Zod registry for customizing generated JSON schema, only useful for .input
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* ```ts
|
|
101
|
+
* import { JSON_SCHEMA_INPUT_REGISTRY } from '@orpc/zod'
|
|
102
|
+
*
|
|
103
|
+
* const user = z.object({
|
|
104
|
+
* name: z.string(),
|
|
105
|
+
* age: z.string().transform(v => Number(v)),
|
|
106
|
+
* })
|
|
107
|
+
*
|
|
108
|
+
* JSON_SCHEMA_INPUT_REGISTRY.add(user, {
|
|
109
|
+
* examples: [{ name: 'John', age: "20" }],
|
|
110
|
+
* })
|
|
111
|
+
* ```
|
|
112
|
+
*/
|
|
113
|
+
declare const JSON_SCHEMA_INPUT_REGISTRY: zod_v4_core.$ZodRegistry<{
|
|
114
|
+
$anchor?: string;
|
|
115
|
+
$comment?: string;
|
|
116
|
+
$defs?: Record<string, json_schema_typed.JSONSchema>;
|
|
117
|
+
$dynamicAnchor?: string;
|
|
118
|
+
$dynamicRef?: string;
|
|
119
|
+
$id?: string;
|
|
120
|
+
$ref?: string;
|
|
121
|
+
$schema?: string;
|
|
122
|
+
$vocabulary?: Record<string, string>;
|
|
123
|
+
additionalItems?: json_schema_typed.JSONSchema;
|
|
124
|
+
additionalProperties?: json_schema_typed.JSONSchema;
|
|
125
|
+
allOf?: (json_schema_typed.JSONSchema<typeof $input, json_schema_typed.JSONSchema.TypeValue>[] | readonly json_schema_typed.JSONSchema<typeof $input, json_schema_typed.JSONSchema.TypeValue>[]) | undefined;
|
|
126
|
+
anyOf?: (json_schema_typed.JSONSchema<typeof $input, json_schema_typed.JSONSchema.TypeValue>[] | readonly json_schema_typed.JSONSchema<typeof $input, json_schema_typed.JSONSchema.TypeValue>[]) | undefined;
|
|
127
|
+
const?: typeof $input | undefined;
|
|
128
|
+
contains?: json_schema_typed.JSONSchema<typeof $input, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
129
|
+
contentEncoding?: "7bit" | "8bit" | "base64" | "binary" | "ietf-token" | "quoted-printable" | "x-token";
|
|
130
|
+
contentMediaType?: string;
|
|
131
|
+
contentSchema?: json_schema_typed.JSONSchema<typeof $input, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
132
|
+
default?: typeof $input | undefined;
|
|
133
|
+
definitions?: Record<string, json_schema_typed.JSONSchema>;
|
|
134
|
+
dependencies?: Record<string, (string[] | readonly string[]) | json_schema_typed.JSONSchema>;
|
|
135
|
+
dependentRequired?: Record<string, string[] | readonly string[]>;
|
|
136
|
+
dependentSchemas?: Record<string, json_schema_typed.JSONSchema>;
|
|
137
|
+
deprecated?: boolean;
|
|
138
|
+
description?: string;
|
|
139
|
+
else?: json_schema_typed.JSONSchema<typeof $input, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
140
|
+
enum?: ((typeof $input)[] | readonly (typeof $input)[]) | undefined;
|
|
141
|
+
examples?: ((typeof $input)[] | readonly (typeof $input)[]) | undefined;
|
|
142
|
+
exclusiveMaximum?: number;
|
|
143
|
+
exclusiveMinimum?: number;
|
|
144
|
+
format?: string;
|
|
145
|
+
if?: json_schema_typed.JSONSchema<typeof $input, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
146
|
+
items?: json_schema_typed.JSONSchema;
|
|
147
|
+
maxContains?: number;
|
|
148
|
+
maximum?: number;
|
|
149
|
+
maxItems?: number;
|
|
150
|
+
maxLength?: number;
|
|
151
|
+
maxProperties?: number;
|
|
152
|
+
minContains?: number;
|
|
153
|
+
minimum?: number;
|
|
154
|
+
minItems?: number;
|
|
155
|
+
minLength?: number;
|
|
156
|
+
minProperties?: number;
|
|
157
|
+
multipleOf?: number;
|
|
158
|
+
not?: json_schema_typed.JSONSchema<typeof $input, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
159
|
+
oneOf?: (json_schema_typed.JSONSchema<typeof $input, json_schema_typed.JSONSchema.TypeValue>[] | readonly json_schema_typed.JSONSchema<typeof $input, json_schema_typed.JSONSchema.TypeValue>[]) | undefined;
|
|
160
|
+
pattern?: string;
|
|
161
|
+
patternProperties?: Record<string, json_schema_typed.JSONSchema>;
|
|
162
|
+
prefixItems?: (json_schema_typed.JSONSchema<any, json_schema_typed.JSONSchema.TypeValue>[] | readonly json_schema_typed.JSONSchema<any, json_schema_typed.JSONSchema.TypeValue>[]) | json_schema_typed.JSONSchema;
|
|
163
|
+
properties?: Record<string, json_schema_typed.JSONSchema>;
|
|
164
|
+
propertyNames?: json_schema_typed.JSONSchema;
|
|
165
|
+
readOnly?: boolean;
|
|
166
|
+
required?: string[] | readonly string[];
|
|
167
|
+
then?: json_schema_typed.JSONSchema<typeof $input, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
168
|
+
title?: string;
|
|
169
|
+
type?: json_schema_typed.JSONSchema.TypeValue | undefined;
|
|
170
|
+
unevaluatedItems?: json_schema_typed.JSONSchema;
|
|
171
|
+
unevaluatedProperties?: json_schema_typed.JSONSchema;
|
|
172
|
+
uniqueItems?: boolean;
|
|
173
|
+
writeOnly?: boolean;
|
|
174
|
+
}, zod_v4_core.$ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>>>;
|
|
175
|
+
/**
|
|
176
|
+
* Zod registry for customizing generated JSON schema, only useful for .output
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* ```ts
|
|
180
|
+
* import { JSON_SCHEMA_OUTPUT_REGISTRY } from '@orpc/zod'
|
|
181
|
+
*
|
|
182
|
+
* const user = z.object({
|
|
183
|
+
* name: z.string(),
|
|
184
|
+
* age: z.string().transform(v => Number(v)),
|
|
185
|
+
* })
|
|
186
|
+
*
|
|
187
|
+
* JSON_SCHEMA_OUTPUT_REGISTRY.add(user, {
|
|
188
|
+
* examples: [{ name: 'John', age: 20 }],
|
|
189
|
+
* })
|
|
190
|
+
* ```
|
|
191
|
+
*/
|
|
192
|
+
declare const JSON_SCHEMA_OUTPUT_REGISTRY: zod_v4_core.$ZodRegistry<{
|
|
193
|
+
$anchor?: string;
|
|
194
|
+
$comment?: string;
|
|
195
|
+
$defs?: Record<string, json_schema_typed.JSONSchema>;
|
|
196
|
+
$dynamicAnchor?: string;
|
|
197
|
+
$dynamicRef?: string;
|
|
198
|
+
$id?: string;
|
|
199
|
+
$ref?: string;
|
|
200
|
+
$schema?: string;
|
|
201
|
+
$vocabulary?: Record<string, string>;
|
|
202
|
+
additionalItems?: json_schema_typed.JSONSchema;
|
|
203
|
+
additionalProperties?: json_schema_typed.JSONSchema;
|
|
204
|
+
allOf?: (json_schema_typed.JSONSchema<typeof $output, json_schema_typed.JSONSchema.TypeValue>[] | readonly json_schema_typed.JSONSchema<typeof $output, json_schema_typed.JSONSchema.TypeValue>[]) | undefined;
|
|
205
|
+
anyOf?: (json_schema_typed.JSONSchema<typeof $output, json_schema_typed.JSONSchema.TypeValue>[] | readonly json_schema_typed.JSONSchema<typeof $output, json_schema_typed.JSONSchema.TypeValue>[]) | undefined;
|
|
206
|
+
const?: typeof $output | undefined;
|
|
207
|
+
contains?: json_schema_typed.JSONSchema<typeof $output, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
208
|
+
contentEncoding?: "7bit" | "8bit" | "base64" | "binary" | "ietf-token" | "quoted-printable" | "x-token";
|
|
209
|
+
contentMediaType?: string;
|
|
210
|
+
contentSchema?: json_schema_typed.JSONSchema<typeof $output, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
211
|
+
default?: typeof $output | undefined;
|
|
212
|
+
definitions?: Record<string, json_schema_typed.JSONSchema>;
|
|
213
|
+
dependencies?: Record<string, (string[] | readonly string[]) | json_schema_typed.JSONSchema>;
|
|
214
|
+
dependentRequired?: Record<string, string[] | readonly string[]>;
|
|
215
|
+
dependentSchemas?: Record<string, json_schema_typed.JSONSchema>;
|
|
216
|
+
deprecated?: boolean;
|
|
217
|
+
description?: string;
|
|
218
|
+
else?: json_schema_typed.JSONSchema<typeof $output, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
219
|
+
enum?: ((typeof $output)[] | readonly (typeof $output)[]) | undefined;
|
|
220
|
+
examples?: ((typeof $output)[] | readonly (typeof $output)[]) | undefined;
|
|
221
|
+
exclusiveMaximum?: number;
|
|
222
|
+
exclusiveMinimum?: number;
|
|
223
|
+
format?: string;
|
|
224
|
+
if?: json_schema_typed.JSONSchema<typeof $output, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
225
|
+
items?: json_schema_typed.JSONSchema;
|
|
226
|
+
maxContains?: number;
|
|
227
|
+
maximum?: number;
|
|
228
|
+
maxItems?: number;
|
|
229
|
+
maxLength?: number;
|
|
230
|
+
maxProperties?: number;
|
|
231
|
+
minContains?: number;
|
|
232
|
+
minimum?: number;
|
|
233
|
+
minItems?: number;
|
|
234
|
+
minLength?: number;
|
|
235
|
+
minProperties?: number;
|
|
236
|
+
multipleOf?: number;
|
|
237
|
+
not?: json_schema_typed.JSONSchema<typeof $output, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
238
|
+
oneOf?: (json_schema_typed.JSONSchema<typeof $output, json_schema_typed.JSONSchema.TypeValue>[] | readonly json_schema_typed.JSONSchema<typeof $output, json_schema_typed.JSONSchema.TypeValue>[]) | undefined;
|
|
239
|
+
pattern?: string;
|
|
240
|
+
patternProperties?: Record<string, json_schema_typed.JSONSchema>;
|
|
241
|
+
prefixItems?: (json_schema_typed.JSONSchema<any, json_schema_typed.JSONSchema.TypeValue>[] | readonly json_schema_typed.JSONSchema<any, json_schema_typed.JSONSchema.TypeValue>[]) | json_schema_typed.JSONSchema;
|
|
242
|
+
properties?: Record<string, json_schema_typed.JSONSchema>;
|
|
243
|
+
propertyNames?: json_schema_typed.JSONSchema;
|
|
244
|
+
readOnly?: boolean;
|
|
245
|
+
required?: string[] | readonly string[];
|
|
246
|
+
then?: json_schema_typed.JSONSchema<typeof $output, json_schema_typed.JSONSchema.TypeValue> | undefined;
|
|
247
|
+
title?: string;
|
|
248
|
+
type?: json_schema_typed.JSONSchema.TypeValue | undefined;
|
|
249
|
+
unevaluatedItems?: json_schema_typed.JSONSchema;
|
|
250
|
+
unevaluatedProperties?: json_schema_typed.JSONSchema;
|
|
251
|
+
uniqueItems?: boolean;
|
|
252
|
+
writeOnly?: boolean;
|
|
253
|
+
}, zod_v4_core.$ZodType<unknown, unknown, zod_v4_core.$ZodTypeInternals<unknown, unknown>>>;
|
|
254
|
+
|
|
255
|
+
export { JSON_SCHEMA_INPUT_REGISTRY, JSON_SCHEMA_OUTPUT_REGISTRY, JSON_SCHEMA_REGISTRY, ZodToJsonSchemaConverter };
|
|
15
256
|
export type { ZodToJsonSchemaConverterOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { JsonSchemaXNativeType, JsonSchemaFormat, encodeJsonPointerSegment } from '@orpc/json-schema';
|
|
2
|
-
import { toJSONSchema, globalRegistry } from 'zod/v4/core';
|
|
2
|
+
import { registry, toJSONSchema, globalRegistry } from 'zod/v4/core';
|
|
3
|
+
|
|
4
|
+
const JSON_SCHEMA_REGISTRY = registry();
|
|
5
|
+
const JSON_SCHEMA_INPUT_REGISTRY = registry();
|
|
6
|
+
const JSON_SCHEMA_OUTPUT_REGISTRY = registry();
|
|
3
7
|
|
|
4
8
|
class ZodToJsonSchemaConverter {
|
|
5
9
|
constructor(options = {}) {
|
|
@@ -55,6 +59,10 @@ class ZodToJsonSchemaConverter {
|
|
|
55
59
|
};
|
|
56
60
|
ctx.jsonSchema["x-native-type"] = JsonSchemaXNativeType.Map;
|
|
57
61
|
}
|
|
62
|
+
const customJsonSchema = this.getCustomJsonSchema(ctx.zodSchema, direction);
|
|
63
|
+
if (customJsonSchema) {
|
|
64
|
+
Object.assign(ctx.jsonSchema, customJsonSchema);
|
|
65
|
+
}
|
|
58
66
|
this.options.override?.(ctx);
|
|
59
67
|
}
|
|
60
68
|
});
|
|
@@ -78,6 +86,14 @@ class ZodToJsonSchemaConverter {
|
|
|
78
86
|
}
|
|
79
87
|
return rest;
|
|
80
88
|
}
|
|
89
|
+
getCustomJsonSchema(schema, direction) {
|
|
90
|
+
const general = JSON_SCHEMA_REGISTRY.get(schema);
|
|
91
|
+
const directional = direction === "input" ? JSON_SCHEMA_INPUT_REGISTRY.get(schema) : JSON_SCHEMA_OUTPUT_REGISTRY.get(schema);
|
|
92
|
+
if (general === void 0 && directional === void 0) {
|
|
93
|
+
return void 0;
|
|
94
|
+
}
|
|
95
|
+
return { ...general, ...directional };
|
|
96
|
+
}
|
|
81
97
|
}
|
|
82
98
|
|
|
83
|
-
export { ZodToJsonSchemaConverter };
|
|
99
|
+
export { JSON_SCHEMA_INPUT_REGISTRY, JSON_SCHEMA_OUTPUT_REGISTRY, JSON_SCHEMA_REGISTRY, ZodToJsonSchemaConverter };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/zod",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.19",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.dev",
|
|
7
7
|
"repository": {
|
|
@@ -29,7 +29,8 @@
|
|
|
29
29
|
"zod": ">=4.3.5"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"
|
|
32
|
+
"json-schema-typed": "^8.0.2",
|
|
33
|
+
"@orpc/json-schema": "2.0.0-beta.19"
|
|
33
34
|
},
|
|
34
35
|
"devDependencies": {
|
|
35
36
|
"zod": "^4.4.3"
|