@orpc/zod 1.14.11 → 1.14.12
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 +112 -52
- package/dist/index.d.mts +86 -251
- package/dist/index.d.ts +86 -251
- package/dist/index.mjs +850 -78
- package/dist/zod4/index.d.mts +314 -0
- package/dist/zod4/index.d.ts +314 -0
- package/dist/zod4/index.mjs +699 -0
- package/package.json +17 -8
package/README.md
CHANGED
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
<
|
|
1
|
+
<div align="center">
|
|
2
|
+
<image align="center" src="https://orpc.dev/logo.webp" width=280 alt="oRPC logo" />
|
|
3
|
+
</div>
|
|
4
|
+
|
|
5
|
+
<h1></h1>
|
|
2
6
|
|
|
3
7
|
<div align="center">
|
|
4
8
|
<a href="https://codecov.io/gh/middleapi/orpc">
|
|
5
|
-
<img alt="codecov" src="https://codecov.io/gh/middleapi/orpc/branch/
|
|
9
|
+
<img alt="codecov" src="https://codecov.io/gh/middleapi/orpc/branch/1.x/graph/badge.svg">
|
|
6
10
|
</a>
|
|
7
11
|
<a href="https://www.npmjs.com/package/@orpc/zod">
|
|
8
12
|
<img alt="weekly downloads" src="https://img.shields.io/npm/dw/%40orpc%2Fzod?logo=npm" />
|
|
9
13
|
</a>
|
|
10
|
-
<a href="https://
|
|
11
|
-
<img alt="CodSpeed" src="https://img.shields.io/endpoint?url=https://codspeed.io/badge.json" />
|
|
12
|
-
</a>
|
|
13
|
-
<a href="https://github.com/middleapi/orpc/blob/main/LICENSE">
|
|
14
|
+
<a href="https://github.com/middleapi/orpc/blob/1.x/LICENSE">
|
|
14
15
|
<img alt="MIT License" src="https://img.shields.io/github/license/middleapi/orpc?logo=open-source-initiative" />
|
|
15
16
|
</a>
|
|
16
17
|
<a href="https://discord.gg/TXEbwRBvQn">
|
|
@@ -21,53 +22,119 @@
|
|
|
21
22
|
</a>
|
|
22
23
|
</div>
|
|
23
24
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
You can read the documentation [here](https://orpc.dev).
|
|
27
|
-
|
|
28
|
-
## Packages
|
|
29
|
-
|
|
30
|
-
**Core**
|
|
25
|
+
<h3 align="center">Typesafe APIs Made Simple 🪄</h3>
|
|
31
26
|
|
|
32
|
-
|
|
33
|
-
- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build APIs or implement contracts.
|
|
34
|
-
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume APIs with end-to-end type safety.
|
|
35
|
-
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Add OpenAPI compatibility to APIs.
|
|
27
|
+
**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
|
|
36
28
|
|
|
37
|
-
|
|
29
|
+
---
|
|
38
30
|
|
|
39
|
-
|
|
40
|
-
- [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): Integrate with [Valibot](https://valibot.dev/).
|
|
41
|
-
- [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): Integrate with [ArkType](https://arktype.io/).
|
|
31
|
+
## Highlights
|
|
42
32
|
|
|
43
|
-
|
|
33
|
+
- **🔗 End-to-End Type Safety**: Ensure type-safe inputs, outputs, and errors from client to server.
|
|
34
|
+
- **📘 First-Class OpenAPI**: Built-in support that fully adheres to the OpenAPI standard.
|
|
35
|
+
- **📝 Contract-First Development**: Optionally define your API contract before implementation.
|
|
36
|
+
- **🔍 First-Class OpenTelemetry**: Seamlessly integrate with OpenTelemetry for observability.
|
|
37
|
+
- **⚙️ Framework Integrations**: Seamlessly integrate with TanStack Query (React, Vue, Solid, Svelte, Angular), SWR, Pinia Colada, and more.
|
|
38
|
+
- **🚀 Server Actions**: Fully compatible with React Server Actions on Next.js, TanStack Start, and other platforms.
|
|
39
|
+
- **🔠 Standard Schema Support**: Works out of the box with Zod, Valibot, ArkType, and other schema validators.
|
|
40
|
+
- **🗃️ Native Types**: Supports native types like Date, File, Blob, BigInt, URL, and more.
|
|
41
|
+
- **⏱️ Lazy Router**: Enhance cold start times with our lazy routing feature.
|
|
42
|
+
- **📡 SSE & Streaming**: Enjoy full type-safe support for SSE and streaming.
|
|
43
|
+
- **🌍 Multi-Runtime Support**: Fast and lightweight on Cloudflare, Deno, Bun, Node.js, and beyond.
|
|
44
|
+
- **🔌 Extendability**: Easily extend functionality with plugins, middleware, and interceptors.
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
- [@orpc/ratelimit](https://www.npmjs.com/package/@orpc/ratelimit): Rate limiting with memory, Redis, and Upstash adapters.
|
|
47
|
-
- [@orpc/json-schema](https://www.npmjs.com/package/@orpc/json-schema): Smart coercion for OpenAPI requests.
|
|
48
|
-
|
|
49
|
-
**Framework & ecosystem integrations**
|
|
46
|
+
## Documentation
|
|
50
47
|
|
|
51
|
-
|
|
52
|
-
- [@orpc/ai-sdk](https://www.npmjs.com/package/@orpc/ai-sdk): Turn contracts and procedures into [AI SDK](https://ai-sdk.dev/) tools.
|
|
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/).
|
|
55
|
-
- [@orpc/swr](https://www.npmjs.com/package/@orpc/swr): Integrate with [SWR](https://swr.vercel.app/).
|
|
56
|
-
- [@orpc/experimental-effect](https://www.npmjs.com/package/@orpc/experimental-effect): Integrate with [Effect](https://effect.website/).
|
|
57
|
-
- [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Implement your contract with [NestJS](https://nestjs.com/).
|
|
58
|
-
- [@orpc/bun](https://www.npmjs.com/package/@orpc/bun): Adapters for [Bun's Redis](https://bun.sh/).
|
|
59
|
-
- [@orpc/cloudflare](https://www.npmjs.com/package/@orpc/cloudflare): Adapters for [Cloudflare's RateLimit and Durable Objects](https://developers.cloudflare.com/workers/).
|
|
60
|
-
- [@orpc/trpc](https://www.npmjs.com/package/@orpc/trpc): Reuse existing [tRPC](https://trpc.io/) routers within oRPC.
|
|
48
|
+
You can find the full documentation [here](https://orpc.dev).
|
|
61
49
|
|
|
62
|
-
|
|
50
|
+
## Packages
|
|
63
51
|
|
|
64
|
-
- [@orpc/
|
|
65
|
-
- [@orpc/
|
|
66
|
-
- [@orpc/
|
|
52
|
+
- [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
|
|
53
|
+
- [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
|
|
54
|
+
- [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
|
|
55
|
+
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
|
56
|
+
- [@orpc/otel](https://www.npmjs.com/package/@orpc/otel): [OpenTelemetry](https://opentelemetry.io/) integration for observability.
|
|
57
|
+
- [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Deeply integrate oRPC with [NestJS](https://nestjs.com/).
|
|
58
|
+
- [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
|
|
59
|
+
- [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query): [TanStack Query](https://tanstack.com/query/latest) integration.
|
|
60
|
+
- [@orpc/experimental-react-swr](https://www.npmjs.com/package/@orpc/experimental-react-swr): [SWR](https://swr.vercel.app/) integration.
|
|
61
|
+
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
|
62
|
+
- [@orpc/hey-api](https://www.npmjs.com/package/@orpc/hey-api): [Hey API](https://heyapi.dev/) integration.
|
|
63
|
+
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
|
64
|
+
- [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
|
|
65
|
+
- [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
|
|
66
|
+
|
|
67
|
+
## `@orpc/zod`
|
|
68
|
+
|
|
69
|
+
More schemas that [Zod](https://zod.dev/) doesn't support yet, and provides `ZodToJsonSchemaConverter` for generating OpenAPI specs.
|
|
70
|
+
|
|
71
|
+
### More Schemas
|
|
72
|
+
|
|
73
|
+
- `oz.url`: Zod schema for [URL](https://developer.mozilla.org/en-US/docs/Web/API/URL) instance.
|
|
74
|
+
- `oz.blob`: Zod schema for [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob) instance.
|
|
75
|
+
- `oz.file`: Zod schema for [File](https://developer.mozilla.org/en-US/docs/Web/API/File) instance.
|
|
76
|
+
- `oz.regexp`: Zod schema for [RegExp](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp) instance.
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
import { oz } from '@orpc/zod'
|
|
80
|
+
import { z } from 'zod/v3'
|
|
81
|
+
|
|
82
|
+
const Example = z.object({
|
|
83
|
+
url: oz.url(),
|
|
84
|
+
blob: oz.blob(),
|
|
85
|
+
file: oz.file().type('image/png'),
|
|
86
|
+
regexp: oz.regexp(),
|
|
87
|
+
})
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
### Generate OpenAPI Spec
|
|
91
|
+
|
|
92
|
+
```ts
|
|
93
|
+
import { OpenAPIGenerator } from '@orpc/openapi'
|
|
94
|
+
import { ZodToJsonSchemaConverter } from '@orpc/zod/zod4'
|
|
95
|
+
|
|
96
|
+
const openAPIGenerator = new OpenAPIGenerator({
|
|
97
|
+
schemaConverters: [new ZodToJsonSchemaConverter()],
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
const specFromContract = await openAPIGenerator.generate(contract, {
|
|
101
|
+
info: {
|
|
102
|
+
title: 'My App',
|
|
103
|
+
version: '0.0.0',
|
|
104
|
+
},
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
const specFromRouter = await openAPIGenerator.generate(router, {
|
|
108
|
+
info: {
|
|
109
|
+
title: 'My App',
|
|
110
|
+
version: '0.0.0',
|
|
111
|
+
},
|
|
112
|
+
})
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Extending the Specification
|
|
116
|
+
|
|
117
|
+
```ts
|
|
118
|
+
import { oz } from '@orpc/zod'
|
|
119
|
+
import * as z from 'zod'
|
|
120
|
+
|
|
121
|
+
const InputSchema = oz.openapi(
|
|
122
|
+
z.object({
|
|
123
|
+
name: z.string(),
|
|
124
|
+
}),
|
|
125
|
+
{
|
|
126
|
+
examples: [
|
|
127
|
+
{ name: 'Earth' },
|
|
128
|
+
{ name: 'Mars' },
|
|
129
|
+
],
|
|
130
|
+
// additional options...
|
|
131
|
+
}
|
|
132
|
+
)
|
|
133
|
+
```
|
|
67
134
|
|
|
68
135
|
## Sponsors
|
|
69
136
|
|
|
70
|
-
|
|
137
|
+
If you find oRPC valuable and would like to support its development, you can do so here: [GitHub Sponsors](https://github.com/sponsors/dinwwwh).
|
|
71
138
|
|
|
72
139
|
### 🏆 Platinum Sponsor
|
|
73
140
|
|
|
@@ -109,10 +176,11 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
109
176
|
<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>
|
|
110
177
|
<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>
|
|
111
178
|
<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>
|
|
179
|
+
<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
180
|
<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
|
-
<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
181
|
</tr>
|
|
115
182
|
<tr>
|
|
183
|
+
<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>
|
|
116
184
|
<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>
|
|
117
185
|
</tr>
|
|
118
186
|
</table>
|
|
@@ -172,7 +240,6 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
172
240
|
<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>
|
|
173
241
|
<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
242
|
<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>
|
|
175
|
-
<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="32" height="32" alt="Ryan Vogel" /></a>
|
|
176
243
|
<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>
|
|
177
244
|
<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>
|
|
178
245
|
<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>
|
|
@@ -187,13 +254,6 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
187
254
|
<a href="https://github.com/plancraft?ref=orpc" target="_blank" rel="noopener" title="plancraft"><img src="https://avatars.githubusercontent.com/u/46482287?v=4" width="32" height="32" alt="plancraft" /></a>
|
|
188
255
|
</p>
|
|
189
256
|
|
|
190
|
-
## References
|
|
191
|
-
|
|
192
|
-
oRPC is inspired by existing solutions that prioritize type safety and developer experience. Special acknowledgments to:
|
|
193
|
-
|
|
194
|
-
- [tRPC](https://trpc.io): For pioneering the concept of end-to-end type-safe RPC and influencing the development of type-safe APIs.
|
|
195
|
-
- [ts-rest](https://ts-rest.com): For its emphasis on contract-first development and OpenAPI integration, which have greatly inspired oRPC's feature set.
|
|
196
|
-
|
|
197
257
|
## License
|
|
198
258
|
|
|
199
|
-
Distributed under the MIT License. See [LICENSE](https://github.com/middleapi/orpc/blob/
|
|
259
|
+
Distributed under the MIT License. See [LICENSE](https://github.com/middleapi/orpc/blob/1.x/LICENSE) for more information.
|
package/dist/index.d.mts
CHANGED
|
@@ -1,256 +1,91 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
1
|
+
import { JSONSchema, ConditionalSchemaConverter, SchemaConvertOptions } from '@orpc/openapi';
|
|
2
|
+
import { ZodTypeAny, input, output, ZodTypeDef, CustomErrorParams, ZodType, ZodEffects } from 'zod/v3';
|
|
3
|
+
import { Context } from '@orpc/server';
|
|
4
|
+
import { StandardHandlerPlugin, StandardHandlerOptions } from '@orpc/server/standard';
|
|
5
|
+
import { AnySchema } from '@orpc/contract';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
declare function getCustomJsonSchema(def: ZodTypeDef, options: {
|
|
8
|
+
strategy: 'input' | 'output' | 'both';
|
|
9
|
+
}): Exclude<JSONSchema, boolean> | undefined;
|
|
10
|
+
declare function customJsonSchema<T extends ZodTypeAny, TStrategy extends 'input' | 'output' | 'both' = 'both'>(schema: T, custom: Exclude<JSONSchema<TStrategy extends 'input' ? input<T> : TStrategy extends 'output' ? output<T> : input<T> & output<T>>, boolean>, options?: {
|
|
11
|
+
strategy?: TStrategy;
|
|
12
|
+
}): T;
|
|
13
|
+
|
|
14
|
+
type CustomParams = CustomErrorParams & {
|
|
15
|
+
fatal?: boolean;
|
|
16
|
+
};
|
|
17
|
+
type CustomZodDef = {
|
|
18
|
+
type: 'blob' | 'regexp' | 'url';
|
|
19
|
+
} | {
|
|
20
|
+
type: 'file';
|
|
21
|
+
mimeType?: string;
|
|
22
|
+
};
|
|
23
|
+
declare function setCustomZodDef<T extends ZodTypeDef>(def: T, custom: CustomZodDef): void;
|
|
24
|
+
declare function getCustomZodDef(def: ZodTypeDef): CustomZodDef | undefined;
|
|
25
|
+
declare function composeParams<T = unknown>(defaultMessage: (input: T) => string, params: undefined | string | CustomParams | ((input: T) => CustomParams)): (input: T) => CustomParams;
|
|
26
|
+
|
|
27
|
+
declare function blob(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<Blob, ZodTypeDef, Blob>;
|
|
28
|
+
|
|
29
|
+
declare function file(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<File, ZodTypeDef, File> & {
|
|
30
|
+
type(mimeType: string, params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodEffects<ZodType<File, ZodTypeDef, File>, File, File>;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
declare function regexp(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<RegExp, ZodTypeDef, RegExp>;
|
|
34
|
+
|
|
35
|
+
declare function url(params?: string | CustomParams | ((input: unknown) => CustomParams)): ZodType<URL, ZodTypeDef, URL>;
|
|
36
|
+
|
|
37
|
+
declare class ZodSmartCoercionPlugin<TContext extends Context> implements StandardHandlerPlugin<TContext> {
|
|
38
|
+
init(options: StandardHandlerOptions<TContext>): void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
interface ZodToJsonSchemaOptions {
|
|
42
|
+
/**
|
|
43
|
+
* Max depth of lazy type
|
|
44
|
+
*
|
|
45
|
+
* Used `{}` when exceed max depth
|
|
46
|
+
*
|
|
47
|
+
* @default 3
|
|
48
|
+
*/
|
|
49
|
+
maxLazyDepth?: number;
|
|
50
|
+
/**
|
|
51
|
+
* Max depth of nested types
|
|
52
|
+
*
|
|
53
|
+
* Used anyJsonSchema (`{}`) when exceed max depth
|
|
54
|
+
*
|
|
55
|
+
* @default 10
|
|
56
|
+
*/
|
|
57
|
+
maxStructureDepth?: number;
|
|
58
|
+
/**
|
|
59
|
+
* The schema to be used to represent the any | unknown type.
|
|
60
|
+
*
|
|
61
|
+
* @default { }
|
|
62
|
+
*/
|
|
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>;
|
|
7
70
|
}
|
|
8
|
-
declare class ZodToJsonSchemaConverter implements
|
|
9
|
-
private
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
private
|
|
14
|
-
|
|
71
|
+
declare class ZodToJsonSchemaConverter implements ConditionalSchemaConverter {
|
|
72
|
+
#private;
|
|
73
|
+
private readonly maxLazyDepth;
|
|
74
|
+
private readonly maxStructureDepth;
|
|
75
|
+
private readonly unsupportedJsonSchema;
|
|
76
|
+
private readonly anyJsonSchema;
|
|
77
|
+
constructor(options?: ZodToJsonSchemaOptions);
|
|
78
|
+
condition(schema: AnySchema | undefined): boolean;
|
|
79
|
+
convert(schema: AnySchema | undefined, options: SchemaConvertOptions, lazyDepth?: number, isHandledCustomJSONSchema?: boolean, isHandledZodDescription?: boolean, structureDepth?: number): [required: boolean, jsonSchema: Exclude<JSONSchema, boolean>];
|
|
15
80
|
}
|
|
16
81
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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>>>;
|
|
82
|
+
declare const oz: {
|
|
83
|
+
file: typeof file;
|
|
84
|
+
blob: typeof blob;
|
|
85
|
+
url: typeof url;
|
|
86
|
+
regexp: typeof regexp;
|
|
87
|
+
openapi: typeof customJsonSchema;
|
|
88
|
+
};
|
|
254
89
|
|
|
255
|
-
export {
|
|
256
|
-
export type {
|
|
90
|
+
export { ZodSmartCoercionPlugin, ZodToJsonSchemaConverter, blob, composeParams, customJsonSchema, file, getCustomJsonSchema, getCustomZodDef, oz, regexp, setCustomZodDef, url };
|
|
91
|
+
export type { CustomParams, CustomZodDef, ZodToJsonSchemaOptions };
|