@orpc/contract 2.0.0-beta.44 → 2.0.0-beta.46
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 +100 -62
- package/dist/index.d.mts +19 -19
- package/dist/index.d.ts +19 -19
- package/dist/index.mjs +21 -3
- package/dist/shared/{contract.CQzrFGcD.d.mts → contract.CM62dTQK.d.mts} +3 -4
- package/dist/shared/{contract.CQzrFGcD.d.ts → contract.CM62dTQK.d.ts} +3 -4
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -21,9 +21,40 @@
|
|
|
21
21
|
</a>
|
|
22
22
|
</div>
|
|
23
23
|
|
|
24
|
+
**oRPC** is a TypeScript framework for building end-to-end typesafe APIs. Write your API once as plain TypeScript functions, and oRPC gives you a fully typed client, a REST API with an OpenAPI document, and MCP tools for AI agents, with no code generation. It runs on Node.js, Bun, Deno, Cloudflare Workers, and more.
|
|
25
|
+
|
|
26
|
+
Define procedures on the server and serve them with an [RPC handler](https://orpc.dev/docs/rpc/handler):
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { os } from '@orpc/server'
|
|
30
|
+
import * as z from 'zod'
|
|
31
|
+
|
|
32
|
+
export const router = {
|
|
33
|
+
planet: {
|
|
34
|
+
find: os
|
|
35
|
+
.input(z.object({ id: z.number() }))
|
|
36
|
+
.handler(({ input }) => ({ id: input.id, name: 'Earth' })),
|
|
37
|
+
},
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
Then call them from a client that knows every input and output, without generating anything:
|
|
42
|
+
|
|
43
|
+
```ts
|
|
44
|
+
import type { RouterClient } from '@orpc/server'
|
|
45
|
+
import type { router } from './router'
|
|
46
|
+
import { createORPCClient } from '@orpc/client'
|
|
47
|
+
import { RPCLink } from '@orpc/client/fetch'
|
|
48
|
+
|
|
49
|
+
const link = new RPCLink({ origin: 'http://localhost:3000', url: '/rpc' })
|
|
50
|
+
const client: RouterClient<typeof router> = createORPCClient(link)
|
|
51
|
+
|
|
52
|
+
const planet = await client.planet.find({ id: 1 }) // { id: number, name: string }
|
|
53
|
+
```
|
|
54
|
+
|
|
24
55
|
## Documentation
|
|
25
56
|
|
|
26
|
-
|
|
57
|
+
Read the full documentation at [orpc.dev](https://orpc.dev), starting with the [Getting Started guide](https://orpc.dev/docs/getting-started).
|
|
27
58
|
|
|
28
59
|
## Packages
|
|
29
60
|
|
|
@@ -56,20 +87,21 @@ You can read the documentation [here](https://orpc.dev).
|
|
|
56
87
|
|
|
57
88
|
**Framework & ecosystem integrations**
|
|
58
89
|
|
|
59
|
-
| Package
|
|
60
|
-
|
|
|
61
|
-
| [@orpc/next](https://www.npmjs.com/package/@orpc/next)
|
|
62
|
-
| [@orpc/ai-sdk](https://www.npmjs.com/package/@orpc/ai-sdk)
|
|
63
|
-
| [@orpc/
|
|
64
|
-
| [@orpc/
|
|
65
|
-
| [@orpc/
|
|
66
|
-
| [@orpc/
|
|
67
|
-
| [@orpc/
|
|
68
|
-
| [@orpc/
|
|
69
|
-
| [@orpc/
|
|
70
|
-
| [@orpc/
|
|
71
|
-
| [@orpc/
|
|
72
|
-
| [@orpc/
|
|
90
|
+
| Package | Purpose | Docs |
|
|
91
|
+
| -------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
92
|
+
| [@orpc/next](https://www.npmjs.com/package/@orpc/next) | Integrate with [Next.js Server Functions](https://nextjs.org/docs/app/getting-started/mutating-data). | [Next.js](https://orpc.dev/docs/integrations/next) |
|
|
93
|
+
| [@orpc/ai-sdk](https://www.npmjs.com/package/@orpc/ai-sdk) | Turn contracts and procedures into [AI SDK](https://ai-sdk.dev/) tools. | [AI SDK](https://orpc.dev/docs/integrations/ai-sdk) |
|
|
94
|
+
| [@orpc/mcp](https://www.npmjs.com/package/@orpc/mcp) | Expose procedures as [MCP](https://modelcontextprotocol.io/) tools. | [MCP](https://orpc.dev/docs/integrations/mcp) |
|
|
95
|
+
| [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query) | Integrate with [TanStack Query](https://tanstack.com/query/latest). | [TanStack Query](https://orpc.dev/docs/integrations/tanstack-query) |
|
|
96
|
+
| [@orpc/pinia-colada](https://www.npmjs.com/package/@orpc/pinia-colada) | Integrate with [Pinia Colada](https://pinia-colada.esm.dev/). | [Pinia Colada](https://orpc.dev/docs/integrations/pinia-colada) |
|
|
97
|
+
| [@orpc/swr](https://www.npmjs.com/package/@orpc/swr) | Integrate with [SWR](https://swr.vercel.app/). | [SWR](https://orpc.dev/docs/integrations/swr) |
|
|
98
|
+
| [@orpc/msw](https://www.npmjs.com/package/@orpc/msw) | Mock procedures with [Mock Service Worker](https://mswjs.io/). | [MSW](https://orpc.dev/docs/integrations/msw) |
|
|
99
|
+
| [@orpc/effect](https://www.npmjs.com/package/@orpc/effect) | Integrate with [Effect](https://effect.website/). | [Effect](https://orpc.dev/docs/integrations/effect) |
|
|
100
|
+
| [@orpc/nest](https://www.npmjs.com/package/@orpc/nest) | Implement your contract with [NestJS](https://nestjs.com/). | [NestJS](https://orpc.dev/docs/integrations/nest) |
|
|
101
|
+
| [@orpc/node](https://www.npmjs.com/package/@orpc/node) | [Node.js](https://nodejs.org/) plugins for static file serving and large uploads. | [Static File](https://orpc.dev/docs/plugins/static-file), [Tmp File Upload](https://orpc.dev/docs/plugins/tmp-file-upload), [Batch Response Compression](https://orpc.dev/docs/plugins/batch-response-compression) |
|
|
102
|
+
| [@orpc/bun](https://www.npmjs.com/package/@orpc/bun) | Adapters for [Bun's Redis](https://bun.sh/). | [Publisher](https://orpc.dev/docs/helpers/publisher), [Rate Limit](https://orpc.dev/docs/helpers/ratelimit), [Lock](https://orpc.dev/docs/helpers/lock) |
|
|
103
|
+
| [@orpc/cloudflare](https://www.npmjs.com/package/@orpc/cloudflare) | Adapters for [Cloudflare Workers](https://developers.cloudflare.com/workers/). | [Publisher](https://orpc.dev/docs/helpers/publisher), [Rate Limit](https://orpc.dev/docs/helpers/ratelimit), [Lock](https://orpc.dev/docs/helpers/lock), [Traces](https://orpc.dev/docs/integrations/cloudflare-traces) |
|
|
104
|
+
| [@orpc/trpc](https://www.npmjs.com/package/@orpc/trpc) | Reuse existing [tRPC](https://trpc.io/) routers within oRPC. | [tRPC](https://orpc.dev/docs/integrations/trpc) |
|
|
73
105
|
|
|
74
106
|
**Observability**
|
|
75
107
|
|
|
@@ -95,19 +127,11 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
95
127
|
</tr>
|
|
96
128
|
</table>
|
|
97
129
|
|
|
98
|
-
### Premium Sponsors
|
|
99
|
-
|
|
100
|
-
<table>
|
|
101
|
-
<tr>
|
|
102
|
-
<td align="center"><a href="https://github.com/nexa-ca?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Nexa"><img src="https://avatars.githubusercontent.com/u/199146462?v=4" width="209" alt="Nexa"/><br />Nexa</a></td>
|
|
103
|
-
</tr>
|
|
104
|
-
</table>
|
|
105
|
-
|
|
106
130
|
### Organization Sponsors
|
|
107
131
|
|
|
108
132
|
<table>
|
|
109
133
|
<tr>
|
|
110
|
-
<td align="center"><a href="https://lnmarkets.com/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="LN Markets"><img src="https://avatars.githubusercontent.com/u/70597625?v=4" width="
|
|
134
|
+
<td align="center"><a href="https://lnmarkets.com/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="LN Markets"><img src="https://avatars.githubusercontent.com/u/70597625?v=4" width="209" alt="LN Markets"/><br />LN Markets</a></td>
|
|
111
135
|
</tr>
|
|
112
136
|
</table>
|
|
113
137
|
|
|
@@ -115,27 +139,29 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
115
139
|
|
|
116
140
|
<table>
|
|
117
141
|
<tr>
|
|
118
|
-
<td align="center"><a href="https://github.com/hrmcdonald?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Reece McDonald"><img src="https://avatars.githubusercontent.com/u/39349270?v=4" width="
|
|
119
|
-
<td align="center"><a href="https://soymilk.party/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="あわわわとーにゅ"><img src="https://avatars.githubusercontent.com/u/17376330?u=de3353804be889f009f7e0a1582daf04d0ab292d&v=4" width="
|
|
120
|
-
<td align="center"><a href="https://github.com/nicognaW?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="nk"><img src="https://avatars.githubusercontent.com/u/66731869?u=4699bda3a9092d3ec34fbd959450767bcc8b8b6d&v=4" width="
|
|
121
|
-
<td align="center"><a href="https://supastarter.dev/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="supastarter"><img src="https://avatars.githubusercontent.com/u/110960143?v=4" width="
|
|
122
|
-
<td align="center"><a href="https://github.com/herrfugbaum?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="herrfugbaum"><img src="https://avatars.githubusercontent.com/u/12859776?u=644dc1666d0220bc0468eb0de3c56b919f635b16&v=4" width="
|
|
123
|
-
|
|
142
|
+
<td align="center"><a href="https://github.com/hrmcdonald?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Reece McDonald"><img src="https://avatars.githubusercontent.com/u/39349270?v=4" width="167" alt="Reece McDonald"/><br />Reece McDonald</a></td>
|
|
143
|
+
<td align="center"><a href="https://soymilk.party/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="あわわわとーにゅ"><img src="https://avatars.githubusercontent.com/u/17376330?u=de3353804be889f009f7e0a1582daf04d0ab292d&v=4" width="167" alt="あわわわとーにゅ"/><br />あわわわとーにゅ</a></td>
|
|
144
|
+
<td align="center"><a href="https://github.com/nicognaW?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="nk"><img src="https://avatars.githubusercontent.com/u/66731869?u=4699bda3a9092d3ec34fbd959450767bcc8b8b6d&v=4" width="167" alt="nk"/><br />nk</a></td>
|
|
145
|
+
<td align="center"><a href="https://supastarter.dev/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="supastarter"><img src="https://avatars.githubusercontent.com/u/110960143?v=4" width="167" alt="supastarter"/><br />supastarter</a></td>
|
|
146
|
+
<td align="center"><a href="https://github.com/herrfugbaum?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="herrfugbaum"><img src="https://avatars.githubusercontent.com/u/12859776?u=644dc1666d0220bc0468eb0de3c56b919f635b16&v=4" width="167" alt="herrfugbaum"/><br />herrfugbaum</a></td>
|
|
147
|
+
</tr>
|
|
148
|
+
<tr>
|
|
149
|
+
<td align="center"><a href="https://laststance.io/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Ryota Murakami"><img src="https://avatars.githubusercontent.com/u/5501268?u=599389e03340734325726ca3f8f423c021d47d7f&v=4" width="167" alt="Ryota Murakami"/><br />Ryota Murakami</a></td>
|
|
150
|
+
<td align="center"><a href="https://cra.mr/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="David Cramer"><img src="https://avatars.githubusercontent.com/u/23610?v=4" width="167" alt="David Cramer"/><br />David Cramer</a></td>
|
|
151
|
+
<td align="center"><a href="https://valerii15298.github.io/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Valerii Petryniak"><img src="https://avatars.githubusercontent.com/u/44531564?u=88ac74d9bacd20401518441907acad21063cd397&v=4" width="167" alt="Valerii Petryniak"/><br />Valerii Petryniak</a></td>
|
|
152
|
+
<td align="center"><a href="https://letstri.dev/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Valerii Strilets"><img src="https://avatars.githubusercontent.com/u/13253748?u=c7b10399ccc8f8081e24db94ec32cd9858e86ac3&v=4" width="167" alt="Valerii Strilets"/><br />Valerii Strilets</a></td>
|
|
153
|
+
<td align="center"><a href="https://blacklight.sh/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Kyle Mistele"><img src="https://avatars.githubusercontent.com/u/18430555?u=3afebeb81de666e35aaac3ed46f14159d7603ffb&v=4" width="167" alt="Kyle Mistele"/><br />Kyle Mistele</a></td>
|
|
124
154
|
</tr>
|
|
125
155
|
<tr>
|
|
126
|
-
<td align="center"><a href="https://
|
|
127
|
-
<td align="center"><a href="https://
|
|
128
|
-
<td align="center"><a href="https://
|
|
129
|
-
<td align="center"><a href="https://
|
|
130
|
-
<td align="center"><a href="https://github.com/
|
|
131
|
-
<td align="center"><a href="https://github.com/Ryanjso?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" 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>
|
|
156
|
+
<td align="center"><a href="https://github.com/christ12938?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="christ12938"><img src="https://avatars.githubusercontent.com/u/25758598?v=4" width="167" alt="christ12938"/><br />christ12938</a></td>
|
|
157
|
+
<td align="center"><a href="https://github.com/Ryanjso?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Ryan Soderberg"><img src="https://avatars.githubusercontent.com/u/39172778?u=5ed913c31d57e7221b75784abcad48c7ebddde27&v=4" width="167" alt="Ryan Soderberg"/><br />Ryan Soderberg</a></td>
|
|
158
|
+
<td align="center"><a href="https://github.com/itigoore01?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="shota"><img src="https://avatars.githubusercontent.com/u/11831107?u=c976a6dc7e055eb026304c46c99100ed22b0c8e0&v=4" width="167" alt="shota"/><br />shota</a></td>
|
|
159
|
+
<td align="center"><a href="https://github.com/ellis-driscoll?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Ellis Driscoll"><img src="https://avatars.githubusercontent.com/u/70685966?u=c5f95bc33b5991d9744abe00052542e4a2ed3cb9&v=4" width="167" alt="Ellis Driscoll"/><br />Ellis Driscoll</a></td>
|
|
160
|
+
<td align="center"><a href="https://github.com/hoangbn?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Hoang Nguyen"><img src="https://avatars.githubusercontent.com/u/38968280?u=c90084c6de65c56facabab7ba13a72a49ddbc3e4&v=4" width="167" alt="Hoang Nguyen"/><br />Hoang Nguyen</a></td>
|
|
132
161
|
</tr>
|
|
133
162
|
<tr>
|
|
134
|
-
<td align="center"><a href="https://
|
|
135
|
-
<td align="center"><a href="https://
|
|
136
|
-
<td align="center"><a href="https://github.com/hoangbn?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Hoang Nguyen"><img src="https://avatars.githubusercontent.com/u/38968280?u=c90084c6de65c56facabab7ba13a72a49ddbc3e4&v=4" width="139" alt="Hoang Nguyen"/><br />Hoang Nguyen</a></td>
|
|
137
|
-
<td align="center"><a href="https://opencollective.com/guest-ac41de3b?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Orestis Ioannou"><img src="https://images.opencollective.com/guest-ac41de3b/avatar/460.png" width="139" alt="Orestis Ioannou"/><br />Orestis Ioannou</a></td>
|
|
138
|
-
<td align="center"><a href="https://automatio.ai/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Stefan Smiljkovic"><img src="https://avatars.githubusercontent.com/u/1984909?u=b7bf5bc40ed49df3c22f69d2da7b8d78709c49ed&v=4" width="139" alt="Stefan Smiljkovic"/><br />Stefan Smiljkovic</a></td>
|
|
163
|
+
<td align="center"><a href="https://opencollective.com/guest-ac41de3b?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Orestis Ioannou"><img src="https://images.opencollective.com/guest-ac41de3b/avatar/460.png" width="167" alt="Orestis Ioannou"/><br />Orestis Ioannou</a></td>
|
|
164
|
+
<td align="center"><a href="https://automatio.ai/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Stefan Smiljkovic"><img src="https://avatars.githubusercontent.com/u/1984909?u=b7bf5bc40ed49df3c22f69d2da7b8d78709c49ed&v=4" width="167" alt="Stefan Smiljkovic"/><br />Stefan Smiljkovic</a></td>
|
|
139
165
|
</tr>
|
|
140
166
|
</table>
|
|
141
167
|
|
|
@@ -143,34 +169,46 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
143
169
|
|
|
144
170
|
<table>
|
|
145
171
|
<tr>
|
|
146
|
-
<td align="center"><a href="https://github.com/rhinodavid?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="David Walsh"><img src="https://avatars.githubusercontent.com/u/5778036?u=b5521f07d2f88c3db2a0dae62b5f2f8357214af0&v=4" width="
|
|
147
|
-
<td align="center"><a href="https://github.com/IPv4Addr?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="IPv4Addr"><img src="https://avatars.githubusercontent.com/u/100147665?u=59996b72f69bb53063cb7e9ff8b8f898616cd94d&v=4" width="
|
|
148
|
-
<td align="center"><a href="https://robbevaes.be/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Robbe Vaes"><img src="https://avatars.githubusercontent.com/u/44748019?u=e0232402c045ad4eac7cbd217f1f47e083103b89&v=4" width="
|
|
149
|
-
<td align="center"><a href="https://github.com/aidansunbury?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Aidan Sunbury"><img src="https://avatars.githubusercontent.com/u/64103161?v=4" width="
|
|
150
|
-
<td align="center"><a href="https://github.com/soonoo?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="soonoo"><img src="https://avatars.githubusercontent.com/u/5436405?u=5d0b4aa955c87e30e6bda7f0cccae5402da99528&v=4" width="
|
|
151
|
-
<td align="center"><a href="https://kevinporten.dev/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Kevin Porten"><img src="https://avatars.githubusercontent.com/u/1839345?u=dc2263d5cfe0d927ce1a0be04a1d55dd6b55405c&v=4" width="
|
|
152
|
-
<td align="center"><a href="https://github.com/pumpkinlink?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Denis"><img src="https://avatars.githubusercontent.com/u/11864620?u=5f47bbe6c65d0f6f5cf011021490238e4b0593d0&v=4" width="119" alt="Denis"/><br />Denis</a></td>
|
|
172
|
+
<td align="center"><a href="https://github.com/rhinodavid?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="David Walsh"><img src="https://avatars.githubusercontent.com/u/5778036?u=b5521f07d2f88c3db2a0dae62b5f2f8357214af0&v=4" width="139" alt="David Walsh"/><br />David Walsh</a></td>
|
|
173
|
+
<td align="center"><a href="https://github.com/IPv4Addr?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="IPv4Addr"><img src="https://avatars.githubusercontent.com/u/100147665?u=59996b72f69bb53063cb7e9ff8b8f898616cd94d&v=4" width="139" alt="IPv4Addr"/><br />IPv4Addr</a></td>
|
|
174
|
+
<td align="center"><a href="https://robbevaes.be/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Robbe Vaes"><img src="https://avatars.githubusercontent.com/u/44748019?u=e0232402c045ad4eac7cbd217f1f47e083103b89&v=4" width="139" alt="Robbe Vaes"/><br />Robbe Vaes</a></td>
|
|
175
|
+
<td align="center"><a href="https://github.com/aidansunbury?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Aidan Sunbury"><img src="https://avatars.githubusercontent.com/u/64103161?v=4" width="139" alt="Aidan Sunbury"/><br />Aidan Sunbury</a></td>
|
|
176
|
+
<td align="center"><a href="https://github.com/soonoo?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="soonoo"><img src="https://avatars.githubusercontent.com/u/5436405?u=5d0b4aa955c87e30e6bda7f0cccae5402da99528&v=4" width="139" alt="soonoo"/><br />soonoo</a></td>
|
|
177
|
+
<td align="center"><a href="https://kevinporten.dev/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Kevin Porten"><img src="https://avatars.githubusercontent.com/u/1839345?u=dc2263d5cfe0d927ce1a0be04a1d55dd6b55405c&v=4" width="139" alt="Kevin Porten"/><br />Kevin Porten</a></td>
|
|
153
178
|
</tr>
|
|
154
179
|
<tr>
|
|
155
|
-
<td align="center"><a href="https://github.com/
|
|
156
|
-
<td align="center"><a href="
|
|
157
|
-
<td align="center"><a href="
|
|
158
|
-
<td align="center"><a href="https://
|
|
159
|
-
<td align="center"><a href="https://
|
|
160
|
-
<td align="center"><a href="https://
|
|
161
|
-
<td align="center"><a href="https://dubinets.io/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Lev Dubinets"><img src="https://avatars.githubusercontent.com/u/3114081?u=f547f5d5012cab54851f1b1ad72d10e537f78fc2&v=4" width="119" alt="Lev Dubinets"/><br />Lev Dubinets</a></td>
|
|
180
|
+
<td align="center"><a href="https://github.com/pumpkinlink?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Denis"><img src="https://avatars.githubusercontent.com/u/11864620?u=5f47bbe6c65d0f6f5cf011021490238e4b0593d0&v=4" width="139" alt="Denis"/><br />Denis</a></td>
|
|
181
|
+
<td align="center"><a href="https://github.com/christopher-kapic?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Christopher Kapic"><img src="https://avatars.githubusercontent.com/u/59740769?u=e7ad4b72b5bf6c9eb1644c26dbf3332a8f987377&v=4" width="139" alt="Christopher Kapic"/><br />Christopher Kapic</a></td>
|
|
182
|
+
<td align="center"><a href="http://ballingt.com/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Tom Ballinger"><img src="https://avatars.githubusercontent.com/u/458879?u=4b045ac75d721b6ac2b42a74d7d37f61f0414031&v=4" width="139" alt="Tom Ballinger"/><br />Tom Ballinger</a></td>
|
|
183
|
+
<td align="center"><a href="https://lee-sam.com/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Sam"><img src="https://avatars.githubusercontent.com/u/102863520?u=3c89611f549d5070be232eb4532f690c8f2e7a65&v=4" width="139" alt="Sam"/><br />Sam</a></td>
|
|
184
|
+
<td align="center"><a href="https://github.com/Titoine?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Titoine"><img src="https://avatars.githubusercontent.com/u/3514286?u=1bb1e86b0c99c8a1121372e56d51a177eea12191&v=4" width="139" alt="Titoine"/><br />Titoine</a></td>
|
|
185
|
+
<td align="center"><a href="https://rigtch.fm/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Igor Makowski"><img src="https://avatars.githubusercontent.com/u/56691628?u=ee8c879478f7c151b9156aef6c74243fa3e247a8&v=4" width="139" alt="Igor Makowski"/><br />Igor Makowski</a></td>
|
|
162
186
|
</tr>
|
|
163
187
|
<tr>
|
|
164
|
-
<td align="center"><a href="https://
|
|
165
|
-
<td align="center"><a href="https://
|
|
166
|
-
<td align="center"><a href="https://
|
|
167
|
-
<td align="center"><a href="https://
|
|
168
|
-
<td align="center"><a href="https://
|
|
169
|
-
<td align="center"><a href="https://
|
|
188
|
+
<td align="center"><a href="https://blog.cwang.io/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="hanayashiki"><img src="https://avatars.githubusercontent.com/u/26056783?u=06c3b9205a16fd41a871e82da1cc2a09306d53f5&v=4" width="139" alt="hanayashiki"/><br />hanayashiki</a></td>
|
|
189
|
+
<td align="center"><a href="https://dubinets.io/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Lev Dubinets"><img src="https://avatars.githubusercontent.com/u/3114081?u=f547f5d5012cab54851f1b1ad72d10e537f78fc2&v=4" width="139" alt="Lev Dubinets"/><br />Lev Dubinets</a></td>
|
|
190
|
+
<td align="center"><a href="https://kellychan.im/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Kelly Peilin Chan"><img src="https://avatars.githubusercontent.com/u/520852?u=6b0f7105f694e7b5cacf410a3f04c7044b469dc8&v=4" width="139" alt="Kelly Peilin Chan"/><br />Kelly Peilin Chan</a></td>
|
|
191
|
+
<td align="center"><a href="https://guyariely.com/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Guy Ariely"><img src="https://avatars.githubusercontent.com/u/42813496?u=edb6b7f563bf28e160a290832e7da57c0506f8ca&v=4" width="139" alt="Guy Ariely"/><br />Guy Ariely</a></td>
|
|
192
|
+
<td align="center"><a href="https://paulsenon.com/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="PaulSenon"><img src="https://avatars.githubusercontent.com/u/19531087?u=6385741eb91d200b8c513ec6045482e301767ca6&v=4" width="139" alt="PaulSenon"/><br />PaulSenon</a></td>
|
|
193
|
+
<td align="center"><a href="https://nakasyou.how/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Shotaro Nakamura"><img src="https://avatars.githubusercontent.com/u/79000684?u=f644df3f29f0e8677a90967115774564f1d9d6ab&v=4" width="139" alt="Shotaro Nakamura"/><br />Shotaro Nakamura</a></td>
|
|
194
|
+
</tr>
|
|
195
|
+
<tr>
|
|
196
|
+
<td align="center"><a href="https://piscis.dev/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Alex"><img src="https://avatars.githubusercontent.com/u/326163?u=b245f368bd940cf51d08c0b6bf55f8257f359437&v=4" width="139" alt="Alex"/><br />Alex</a></td>
|
|
197
|
+
<td align="center"><a href="https://opensource.gubanov.eu/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Andrey Gubanov"><img src="https://avatars.githubusercontent.com/u/1082083?u=c5f2daf7ebece498e85c83367bb37b4e10e2649d&v=4" width="139" alt="Andrey Gubanov"/><br />Andrey Gubanov</a></td>
|
|
170
198
|
</tr>
|
|
171
199
|
</table>
|
|
172
200
|
|
|
173
|
-
With thanks to [
|
|
201
|
+
With thanks to [40 past sponsors](https://orpc.dev/sponsors#past-sponsors) who helped get oRPC here.
|
|
202
|
+
|
|
203
|
+
## Open Source Programs
|
|
204
|
+
|
|
205
|
+
[middleapi](https://github.com/middleapi) is supported by these open source programs:
|
|
206
|
+
|
|
207
|
+
<table>
|
|
208
|
+
<tr>
|
|
209
|
+
<td align="center"><a href="https://claude.com/contact-sales/claude-for-oss" target="_blank" rel="noopener" title="Claude for Open Source"><img src="https://cdn.simpleicons.org/claude" width="64" alt="Claude"/><br />Claude for Open Source</a></td>
|
|
210
|
+
</tr>
|
|
211
|
+
</table>
|
|
174
212
|
|
|
175
213
|
## References
|
|
176
214
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { E as ErrorMap, A as AnySchema, P as ProcedureContract, M as MetaPlugin, a as MergedSchema, b as Meta, c as AnyMetaPlugin, R as RouterContract, d as AnyProcedureContract, S as Schema, I as InferSchemaInput, e as InferSchemaOutput, O as ORPCErrorFromErrorMap, f as ErrorMapItem, g as SchemaIssue } from './shared/contract.
|
|
2
|
-
export {
|
|
1
|
+
import { E as ErrorMap, A as AnySchema, P as ProcedureContract, M as MetaPlugin, a as MergedSchema, b as Meta, c as AnyMetaPlugin, R as RouterContract, d as AnyProcedureContract, S as Schema, I as InferSchemaInput, e as InferSchemaOutput, O as ORPCErrorFromErrorMap, f as ErrorMapItem, g as SchemaIssue } from './shared/contract.CM62dTQK.mjs';
|
|
2
|
+
export { h as InferContractRouterErrorMap, i as InferContractRouterInputs, j as InferContractRouterOutputs, k as InferRouterContractError, h as InferRouterContractErrorMap, l as InferRouterContractErrors, i as InferRouterContractInputs, j as InferRouterContractOutputs, m as MetaPluginDefinition, n as ProcedureContractDefinition, V as ValidationError, o as ValidationErrorOptions, p as getHiddenMetaPlugins, s as setHiddenMetaPlugins } from './shared/contract.CM62dTQK.mjs';
|
|
3
3
|
import { AnyORPCError, ClientContext, Client, ORPCClientOptions, ClientLink, ORPCErrorCode, ORPCErrorOptions, ORPCError } from '@orpc/client';
|
|
4
4
|
export { Client, ClientContext, ClientOptions, ClientRest, FriendlyClientOptions } from '@orpc/client';
|
|
5
5
|
import { ThrowableError, MaybeOptionalOptions, AsyncIteratorClass, Promisable, IsEqual } from '@orpc/shared';
|
|
6
|
-
export { PromiseWithError, Registry, ThrowableError } from '@orpc/shared';
|
|
6
|
+
export { AsyncIteratorClass, PromiseWithError, Registry, ThrowableError } from '@orpc/shared';
|
|
7
7
|
import '@standard-schema/spec';
|
|
8
8
|
|
|
9
9
|
type MergedErrorMap<T1 extends ErrorMap, T2 extends ErrorMap> = keyof T1 extends never | keyof T2 ? T2 : Omit<T1, keyof T2> & T2;
|
|
@@ -116,10 +116,6 @@ interface AugmentContractRouterOptions<TErrorMap extends ErrorMap> {
|
|
|
116
116
|
metaPlugins?: AnyMetaPlugin[] | undefined;
|
|
117
117
|
errorMap: TErrorMap;
|
|
118
118
|
}
|
|
119
|
-
/**
|
|
120
|
-
* Add capabilities without changing identity of the router contract
|
|
121
|
-
*/
|
|
122
|
-
declare function augmentContractRouter<T extends RouterContract, TErrorMap extends ErrorMap>(router: T, options: AugmentContractRouterOptions<TErrorMap>): AugmentedContractRouter<T, TErrorMap>;
|
|
123
119
|
declare function getRouterContract(router: RouterContract, path: readonly string[]): RouterContract | undefined;
|
|
124
120
|
declare function getProcedureContractOrThrow(router: RouterContract, path: readonly string[]): AnyProcedureContract;
|
|
125
121
|
/**
|
|
@@ -162,7 +158,7 @@ declare class ContractBuilder<TErrorMap extends ErrorMap> extends ProcedureContr
|
|
|
162
158
|
*
|
|
163
159
|
* @see {@link https://orpc.dev/docs/contract/procedure | Procedure Contract}
|
|
164
160
|
*/
|
|
165
|
-
static create(): ContractBuilder<
|
|
161
|
+
static create(): ContractBuilder<Record<never, never>>;
|
|
166
162
|
/**
|
|
167
163
|
* Applies metadata plugins to contracts built from this builder.
|
|
168
164
|
*
|
|
@@ -202,7 +198,7 @@ declare class ContractBuilder<TErrorMap extends ErrorMap> extends ProcedureContr
|
|
|
202
198
|
*
|
|
203
199
|
* @see {@link https://orpc.dev/docs/contract/procedure | Procedure Contract}
|
|
204
200
|
*/
|
|
205
|
-
declare const oc: ContractBuilder<
|
|
201
|
+
declare const oc: ContractBuilder<Record<never, never>>;
|
|
206
202
|
|
|
207
203
|
type ProcedureContractClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ORPCErrorFromErrorMap<TErrorMap> | ThrowableError>;
|
|
208
204
|
|
|
@@ -225,7 +221,7 @@ interface ContractClientFactoryOptions<TClientContext extends ClientContext> ext
|
|
|
225
221
|
* When provided, the client factory will automatically register the passed contract
|
|
226
222
|
* into the router at the path defined by `meta.path`.
|
|
227
223
|
*/
|
|
228
|
-
contractRef?:
|
|
224
|
+
contractRef?: RouterContract | undefined;
|
|
229
225
|
}
|
|
230
226
|
/**
|
|
231
227
|
* Creates a client factory that builds a client from any procedure or router contract,
|
|
@@ -243,11 +239,11 @@ interface ORPCErrorFactoryOptions<TData> {
|
|
|
243
239
|
* Optional schema used to type and validate the error data.
|
|
244
240
|
* Must be a synchronous schema.
|
|
245
241
|
*/
|
|
246
|
-
data?: Schema<TData
|
|
242
|
+
data?: Schema<TData> | undefined;
|
|
247
243
|
/**
|
|
248
244
|
* Optional default message, can be overridden when constructing an error.
|
|
249
245
|
*/
|
|
250
|
-
message?: string;
|
|
246
|
+
message?: string | undefined;
|
|
251
247
|
}
|
|
252
248
|
interface ORPCErrorFactory<TCode extends ORPCErrorCode, TData> extends ErrorMapItem {
|
|
253
249
|
code: TCode;
|
|
@@ -397,10 +393,6 @@ declare function defineMeta<TName extends string, TData>(name: TName, merge: (in
|
|
|
397
393
|
}) => TData | undefined
|
|
398
394
|
];
|
|
399
395
|
|
|
400
|
-
interface AsyncIteratorObjectSchemaDetails {
|
|
401
|
-
yieldSchema: AnySchema;
|
|
402
|
-
returnSchema?: AnySchema;
|
|
403
|
-
}
|
|
404
396
|
/**
|
|
405
397
|
* Defines a schema for an AsyncIteratorObject, validating each yielded value
|
|
406
398
|
* (and optionally the return value) with the given schemas.
|
|
@@ -408,7 +400,15 @@ interface AsyncIteratorObjectSchemaDetails {
|
|
|
408
400
|
* @see {@link https://orpc.dev/docs/async-iterator-object | AsyncIteratorObject (SSE)}
|
|
409
401
|
*/
|
|
410
402
|
declare function asyncIteratorObject<TYieldIn, TYieldOut, TReturnIn = unknown, TReturnOut = unknown>(yieldSchema: Schema<TYieldIn, TYieldOut>, returnSchema?: Schema<TReturnIn, TReturnOut>): Schema<AsyncIteratorObject<TYieldIn, TReturnIn, void>, AsyncIteratorClass<TYieldOut, TReturnOut, void>>;
|
|
411
|
-
|
|
403
|
+
interface AsyncIteratorObjectSchemasDetails {
|
|
404
|
+
yieldSchemas: AnySchema[];
|
|
405
|
+
returnSchemas: AnySchema[];
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Collects the yield and return schemas of multiple schemas, such as the `.output` schemas of a procedure,
|
|
409
|
+
* or returns `undefined` when there are none or any of them does not describe an AsyncIteratorObject.
|
|
410
|
+
*/
|
|
411
|
+
declare function getAsyncIteratorObjectSchemasDetails(schemas: readonly AnySchema[] | undefined): undefined | AsyncIteratorObjectSchemasDetails;
|
|
412
412
|
|
|
413
413
|
type TypeRest<TInput, TOutput> = [map: (input: TInput) => Promisable<TOutput>] | (IsEqual<TInput, TOutput> extends true ? [] : never);
|
|
414
414
|
/**
|
|
@@ -429,5 +429,5 @@ declare function type<TInput, TOutput = TInput>(...[map]: TypeRest<TInput, TOutp
|
|
|
429
429
|
*/
|
|
430
430
|
declare function isSchemaIssue(issue: unknown): issue is SchemaIssue;
|
|
431
431
|
|
|
432
|
-
export { AnyProcedureContract as AnyContractProcedure, RouterContract as AnyContractRouter, AnyMetaPlugin, AnyProcedureContract, AnySchema, ContractBuilder, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, MergedSchema, Meta, MetaPlugin, ORPCErrorFromErrorMap, ProcedureContract, RouterContract, Schema, SchemaIssue, asyncIteratorObject,
|
|
433
|
-
export type {
|
|
432
|
+
export { AnyProcedureContract as AnyContractProcedure, RouterContract as AnyContractRouter, AnyMetaPlugin, AnyProcedureContract, AnySchema, ContractBuilder, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, MergedSchema, Meta, MetaPlugin, ORPCErrorFromErrorMap, ProcedureContract, RouterContract, Schema, SchemaIssue, asyncIteratorObject, createContractClientFactory, createORPCErrorConstructorMap, defineMeta, error, asyncIteratorObject as eventIterator, getAsyncIteratorObjectSchemasDetails, getRouterContract as getContractRouter, getPathMeta, getProcedureContractOrThrow, getRouterContract, isSchemaIssue, mergeErrorMap, meta, minifyRouterContract as minifyContractRouter, minifyRouterContract, oc, reconcileORPCError, resolveBasePathMeta, resolveMetaPlugins, type };
|
|
433
|
+
export type { AsyncIteratorObjectSchemasDetails, AugmentContractRouterOptions, AugmentedContractRouter, ContractClientFactory, ContractClientFactoryOptions, RouterContractClient as ContractRouterClient, InitialInputSchema, InitialOutputSchema, MergedErrorMap, ORPCErrorConstructorMap, ORPCErrorConstructorMapItem, ORPCErrorConstructorMapItemOptions, ORPCErrorFactory, ORPCErrorFactoryOptions, PathMetaPlugin, ProcedureContractBuilderWithInput, ProcedureContractBuilderWithInputOutput, ProcedureContractBuilderWithOutput, ProcedureContractClient, RouterContractClient, TypeRest };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { E as ErrorMap, A as AnySchema, P as ProcedureContract, M as MetaPlugin, a as MergedSchema, b as Meta, c as AnyMetaPlugin, R as RouterContract, d as AnyProcedureContract, S as Schema, I as InferSchemaInput, e as InferSchemaOutput, O as ORPCErrorFromErrorMap, f as ErrorMapItem, g as SchemaIssue } from './shared/contract.
|
|
2
|
-
export {
|
|
1
|
+
import { E as ErrorMap, A as AnySchema, P as ProcedureContract, M as MetaPlugin, a as MergedSchema, b as Meta, c as AnyMetaPlugin, R as RouterContract, d as AnyProcedureContract, S as Schema, I as InferSchemaInput, e as InferSchemaOutput, O as ORPCErrorFromErrorMap, f as ErrorMapItem, g as SchemaIssue } from './shared/contract.CM62dTQK.js';
|
|
2
|
+
export { h as InferContractRouterErrorMap, i as InferContractRouterInputs, j as InferContractRouterOutputs, k as InferRouterContractError, h as InferRouterContractErrorMap, l as InferRouterContractErrors, i as InferRouterContractInputs, j as InferRouterContractOutputs, m as MetaPluginDefinition, n as ProcedureContractDefinition, V as ValidationError, o as ValidationErrorOptions, p as getHiddenMetaPlugins, s as setHiddenMetaPlugins } from './shared/contract.CM62dTQK.js';
|
|
3
3
|
import { AnyORPCError, ClientContext, Client, ORPCClientOptions, ClientLink, ORPCErrorCode, ORPCErrorOptions, ORPCError } from '@orpc/client';
|
|
4
4
|
export { Client, ClientContext, ClientOptions, ClientRest, FriendlyClientOptions } from '@orpc/client';
|
|
5
5
|
import { ThrowableError, MaybeOptionalOptions, AsyncIteratorClass, Promisable, IsEqual } from '@orpc/shared';
|
|
6
|
-
export { PromiseWithError, Registry, ThrowableError } from '@orpc/shared';
|
|
6
|
+
export { AsyncIteratorClass, PromiseWithError, Registry, ThrowableError } from '@orpc/shared';
|
|
7
7
|
import '@standard-schema/spec';
|
|
8
8
|
|
|
9
9
|
type MergedErrorMap<T1 extends ErrorMap, T2 extends ErrorMap> = keyof T1 extends never | keyof T2 ? T2 : Omit<T1, keyof T2> & T2;
|
|
@@ -116,10 +116,6 @@ interface AugmentContractRouterOptions<TErrorMap extends ErrorMap> {
|
|
|
116
116
|
metaPlugins?: AnyMetaPlugin[] | undefined;
|
|
117
117
|
errorMap: TErrorMap;
|
|
118
118
|
}
|
|
119
|
-
/**
|
|
120
|
-
* Add capabilities without changing identity of the router contract
|
|
121
|
-
*/
|
|
122
|
-
declare function augmentContractRouter<T extends RouterContract, TErrorMap extends ErrorMap>(router: T, options: AugmentContractRouterOptions<TErrorMap>): AugmentedContractRouter<T, TErrorMap>;
|
|
123
119
|
declare function getRouterContract(router: RouterContract, path: readonly string[]): RouterContract | undefined;
|
|
124
120
|
declare function getProcedureContractOrThrow(router: RouterContract, path: readonly string[]): AnyProcedureContract;
|
|
125
121
|
/**
|
|
@@ -162,7 +158,7 @@ declare class ContractBuilder<TErrorMap extends ErrorMap> extends ProcedureContr
|
|
|
162
158
|
*
|
|
163
159
|
* @see {@link https://orpc.dev/docs/contract/procedure | Procedure Contract}
|
|
164
160
|
*/
|
|
165
|
-
static create(): ContractBuilder<
|
|
161
|
+
static create(): ContractBuilder<Record<never, never>>;
|
|
166
162
|
/**
|
|
167
163
|
* Applies metadata plugins to contracts built from this builder.
|
|
168
164
|
*
|
|
@@ -202,7 +198,7 @@ declare class ContractBuilder<TErrorMap extends ErrorMap> extends ProcedureContr
|
|
|
202
198
|
*
|
|
203
199
|
* @see {@link https://orpc.dev/docs/contract/procedure | Procedure Contract}
|
|
204
200
|
*/
|
|
205
|
-
declare const oc: ContractBuilder<
|
|
201
|
+
declare const oc: ContractBuilder<Record<never, never>>;
|
|
206
202
|
|
|
207
203
|
type ProcedureContractClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ORPCErrorFromErrorMap<TErrorMap> | ThrowableError>;
|
|
208
204
|
|
|
@@ -225,7 +221,7 @@ interface ContractClientFactoryOptions<TClientContext extends ClientContext> ext
|
|
|
225
221
|
* When provided, the client factory will automatically register the passed contract
|
|
226
222
|
* into the router at the path defined by `meta.path`.
|
|
227
223
|
*/
|
|
228
|
-
contractRef?:
|
|
224
|
+
contractRef?: RouterContract | undefined;
|
|
229
225
|
}
|
|
230
226
|
/**
|
|
231
227
|
* Creates a client factory that builds a client from any procedure or router contract,
|
|
@@ -243,11 +239,11 @@ interface ORPCErrorFactoryOptions<TData> {
|
|
|
243
239
|
* Optional schema used to type and validate the error data.
|
|
244
240
|
* Must be a synchronous schema.
|
|
245
241
|
*/
|
|
246
|
-
data?: Schema<TData
|
|
242
|
+
data?: Schema<TData> | undefined;
|
|
247
243
|
/**
|
|
248
244
|
* Optional default message, can be overridden when constructing an error.
|
|
249
245
|
*/
|
|
250
|
-
message?: string;
|
|
246
|
+
message?: string | undefined;
|
|
251
247
|
}
|
|
252
248
|
interface ORPCErrorFactory<TCode extends ORPCErrorCode, TData> extends ErrorMapItem {
|
|
253
249
|
code: TCode;
|
|
@@ -397,10 +393,6 @@ declare function defineMeta<TName extends string, TData>(name: TName, merge: (in
|
|
|
397
393
|
}) => TData | undefined
|
|
398
394
|
];
|
|
399
395
|
|
|
400
|
-
interface AsyncIteratorObjectSchemaDetails {
|
|
401
|
-
yieldSchema: AnySchema;
|
|
402
|
-
returnSchema?: AnySchema;
|
|
403
|
-
}
|
|
404
396
|
/**
|
|
405
397
|
* Defines a schema for an AsyncIteratorObject, validating each yielded value
|
|
406
398
|
* (and optionally the return value) with the given schemas.
|
|
@@ -408,7 +400,15 @@ interface AsyncIteratorObjectSchemaDetails {
|
|
|
408
400
|
* @see {@link https://orpc.dev/docs/async-iterator-object | AsyncIteratorObject (SSE)}
|
|
409
401
|
*/
|
|
410
402
|
declare function asyncIteratorObject<TYieldIn, TYieldOut, TReturnIn = unknown, TReturnOut = unknown>(yieldSchema: Schema<TYieldIn, TYieldOut>, returnSchema?: Schema<TReturnIn, TReturnOut>): Schema<AsyncIteratorObject<TYieldIn, TReturnIn, void>, AsyncIteratorClass<TYieldOut, TReturnOut, void>>;
|
|
411
|
-
|
|
403
|
+
interface AsyncIteratorObjectSchemasDetails {
|
|
404
|
+
yieldSchemas: AnySchema[];
|
|
405
|
+
returnSchemas: AnySchema[];
|
|
406
|
+
}
|
|
407
|
+
/**
|
|
408
|
+
* Collects the yield and return schemas of multiple schemas, such as the `.output` schemas of a procedure,
|
|
409
|
+
* or returns `undefined` when there are none or any of them does not describe an AsyncIteratorObject.
|
|
410
|
+
*/
|
|
411
|
+
declare function getAsyncIteratorObjectSchemasDetails(schemas: readonly AnySchema[] | undefined): undefined | AsyncIteratorObjectSchemasDetails;
|
|
412
412
|
|
|
413
413
|
type TypeRest<TInput, TOutput> = [map: (input: TInput) => Promisable<TOutput>] | (IsEqual<TInput, TOutput> extends true ? [] : never);
|
|
414
414
|
/**
|
|
@@ -429,5 +429,5 @@ declare function type<TInput, TOutput = TInput>(...[map]: TypeRest<TInput, TOutp
|
|
|
429
429
|
*/
|
|
430
430
|
declare function isSchemaIssue(issue: unknown): issue is SchemaIssue;
|
|
431
431
|
|
|
432
|
-
export { AnyProcedureContract as AnyContractProcedure, RouterContract as AnyContractRouter, AnyMetaPlugin, AnyProcedureContract, AnySchema, ContractBuilder, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, MergedSchema, Meta, MetaPlugin, ORPCErrorFromErrorMap, ProcedureContract, RouterContract, Schema, SchemaIssue, asyncIteratorObject,
|
|
433
|
-
export type {
|
|
432
|
+
export { AnyProcedureContract as AnyContractProcedure, RouterContract as AnyContractRouter, AnyMetaPlugin, AnyProcedureContract, AnySchema, ContractBuilder, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, MergedSchema, Meta, MetaPlugin, ORPCErrorFromErrorMap, ProcedureContract, RouterContract, Schema, SchemaIssue, asyncIteratorObject, createContractClientFactory, createORPCErrorConstructorMap, defineMeta, error, asyncIteratorObject as eventIterator, getAsyncIteratorObjectSchemasDetails, getRouterContract as getContractRouter, getPathMeta, getProcedureContractOrThrow, getRouterContract, isSchemaIssue, mergeErrorMap, meta, minifyRouterContract as minifyContractRouter, minifyRouterContract, oc, reconcileORPCError, resolveBasePathMeta, resolveMetaPlugins, type };
|
|
433
|
+
export type { AsyncIteratorObjectSchemasDetails, AugmentContractRouterOptions, AugmentedContractRouter, ContractClientFactory, ContractClientFactoryOptions, RouterContractClient as ContractRouterClient, InitialInputSchema, InitialOutputSchema, MergedErrorMap, ORPCErrorConstructorMap, ORPCErrorConstructorMapItem, ORPCErrorConstructorMapItemOptions, ORPCErrorFactory, ORPCErrorFactoryOptions, PathMetaPlugin, ProcedureContractBuilderWithInput, ProcedureContractBuilderWithInputOutput, ProcedureContractBuilderWithOutput, ProcedureContractClient, RouterContractClient, TypeRest };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { isTypescriptObject, toArray, get, set, isPropertyKey, ORPC_NAME, resolveMaybeOptionalOptions, getOwn, isAsyncIteratorObject } from '@orpc/shared';
|
|
2
2
|
import { P as ProcedureContract, r as resolveMetaPlugins, m as mergeErrorMap, a as augmentContractRouter, V as ValidationError } from './shared/contract.T7BNVKJ4.mjs';
|
|
3
3
|
export { d as defineMeta, g as getContractRouter, b as getProcedureContractOrThrow, g as getRouterContract, c as minifyContractRouter, c as minifyRouterContract, e as reconcileORPCError } from './shared/contract.T7BNVKJ4.mjs';
|
|
4
|
-
import { createORPCClient, ORPCError, wrapAsyncIteratorPreservingEventMeta } from '@orpc/client';
|
|
4
|
+
import { createORPCClient, RECURSIVE_CLIENT_UNWRAP_KEYS, ORPCError, wrapAsyncIteratorPreservingEventMeta } from '@orpc/client';
|
|
5
5
|
|
|
6
6
|
const HIDDEN_META_PLUGINS_SYMBOL = Symbol.for("ORPC_HIDDEN_META_PLUGINS");
|
|
7
7
|
function getHiddenMetaPlugins(container) {
|
|
@@ -256,7 +256,7 @@ function error(code, { data: dataSchema, message } = {}) {
|
|
|
256
256
|
function createORPCErrorConstructorMap(errorMap) {
|
|
257
257
|
const proxy = new Proxy(errorMap, {
|
|
258
258
|
get(target, code) {
|
|
259
|
-
if (typeof code !== "string" || code
|
|
259
|
+
if (typeof code !== "string" || RECURSIVE_CLIENT_UNWRAP_KEYS.has(code)) {
|
|
260
260
|
return Reflect.get(target, code);
|
|
261
261
|
}
|
|
262
262
|
const item = (...rest) => {
|
|
@@ -320,5 +320,23 @@ function getAsyncIteratorObjectSchemaDetails(schema) {
|
|
|
320
320
|
}
|
|
321
321
|
return schema["~standard"][ASYNC_ITERATOR_OBJECT_SCHEMA_DETAILS_SYMBOL];
|
|
322
322
|
}
|
|
323
|
+
function getAsyncIteratorObjectSchemasDetails(schemas) {
|
|
324
|
+
if (!schemas || schemas.length === 0) {
|
|
325
|
+
return void 0;
|
|
326
|
+
}
|
|
327
|
+
const yieldSchemas = [];
|
|
328
|
+
const returnSchemas = [];
|
|
329
|
+
for (const schema of schemas) {
|
|
330
|
+
const details = getAsyncIteratorObjectSchemaDetails(schema);
|
|
331
|
+
if (!details) {
|
|
332
|
+
return void 0;
|
|
333
|
+
}
|
|
334
|
+
yieldSchemas.push(details.yieldSchema);
|
|
335
|
+
if (details.returnSchema) {
|
|
336
|
+
returnSchemas.push(details.returnSchema);
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return { yieldSchemas, returnSchemas };
|
|
340
|
+
}
|
|
323
341
|
|
|
324
|
-
export { ContractBuilder,
|
|
342
|
+
export { ContractBuilder, ProcedureContract, ValidationError, asyncIteratorObject, createContractClientFactory, createORPCErrorConstructorMap, error, asyncIteratorObject as eventIterator, getAsyncIteratorObjectSchemasDetails, getHiddenMetaPlugins, getPathMeta, isSchemaIssue, mergeErrorMap, meta, oc, resolveBasePathMeta, resolveMetaPlugins, setHiddenMetaPlugins, type };
|
|
@@ -31,11 +31,11 @@ interface ErrorMapItem {
|
|
|
31
31
|
/**
|
|
32
32
|
* Default message, can be overridden when constructing an error.
|
|
33
33
|
*/
|
|
34
|
-
message?:
|
|
34
|
+
message?: string | undefined;
|
|
35
35
|
/**
|
|
36
36
|
* Schema used to type and validate the error data.
|
|
37
37
|
*/
|
|
38
|
-
data?:
|
|
38
|
+
data?: AnySchema | undefined;
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Map of error codes to their definitions, as passed to `.errors(...)`.
|
|
@@ -120,7 +120,6 @@ interface MetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySc
|
|
|
120
120
|
* @see {@link https://orpc.dev/docs/procedure | Procedure}
|
|
121
121
|
*/
|
|
122
122
|
type AnyMetaPlugin = MetaPlugin<any, any, any>;
|
|
123
|
-
declare const HIDDEN_META_PLUGINS_SYMBOL: unique symbol;
|
|
124
123
|
declare function getHiddenMetaPlugins(container: unknown): AnyMetaPlugin[] | undefined;
|
|
125
124
|
declare function setHiddenMetaPlugins<T extends object>(container: T, metaPlugins: AnyMetaPlugin[]): void;
|
|
126
125
|
|
|
@@ -199,5 +198,5 @@ type InferRouterContractErrors<T extends RouterContract> = T extends ProcedureCo
|
|
|
199
198
|
[K in keyof T]: T[K] extends RouterContract ? InferRouterContractErrors<T[K]> : never;
|
|
200
199
|
};
|
|
201
200
|
|
|
202
|
-
export {
|
|
201
|
+
export { ProcedureContract as P, ValidationError as V, getHiddenMetaPlugins as p, setHiddenMetaPlugins as s };
|
|
203
202
|
export type { AnySchema as A, ErrorMap as E, InferSchemaInput as I, MetaPlugin as M, ORPCErrorFromErrorMap as O, RouterContract as R, Schema as S, MergedSchema as a, Meta as b, AnyMetaPlugin as c, AnyProcedureContract as d, InferSchemaOutput as e, ErrorMapItem as f, SchemaIssue as g, InferRouterContractErrorMap as h, InferRouterContractInputs as i, InferRouterContractOutputs as j, InferRouterContractError as k, InferRouterContractErrors as l, MetaPluginDefinition as m, ProcedureContractDefinition as n, ValidationErrorOptions as o };
|
|
@@ -31,11 +31,11 @@ interface ErrorMapItem {
|
|
|
31
31
|
/**
|
|
32
32
|
* Default message, can be overridden when constructing an error.
|
|
33
33
|
*/
|
|
34
|
-
message?:
|
|
34
|
+
message?: string | undefined;
|
|
35
35
|
/**
|
|
36
36
|
* Schema used to type and validate the error data.
|
|
37
37
|
*/
|
|
38
|
-
data?:
|
|
38
|
+
data?: AnySchema | undefined;
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Map of error codes to their definitions, as passed to `.errors(...)`.
|
|
@@ -120,7 +120,6 @@ interface MetaPlugin<TInputSchema extends AnySchema, TOutputSchema extends AnySc
|
|
|
120
120
|
* @see {@link https://orpc.dev/docs/procedure | Procedure}
|
|
121
121
|
*/
|
|
122
122
|
type AnyMetaPlugin = MetaPlugin<any, any, any>;
|
|
123
|
-
declare const HIDDEN_META_PLUGINS_SYMBOL: unique symbol;
|
|
124
123
|
declare function getHiddenMetaPlugins(container: unknown): AnyMetaPlugin[] | undefined;
|
|
125
124
|
declare function setHiddenMetaPlugins<T extends object>(container: T, metaPlugins: AnyMetaPlugin[]): void;
|
|
126
125
|
|
|
@@ -199,5 +198,5 @@ type InferRouterContractErrors<T extends RouterContract> = T extends ProcedureCo
|
|
|
199
198
|
[K in keyof T]: T[K] extends RouterContract ? InferRouterContractErrors<T[K]> : never;
|
|
200
199
|
};
|
|
201
200
|
|
|
202
|
-
export {
|
|
201
|
+
export { ProcedureContract as P, ValidationError as V, getHiddenMetaPlugins as p, setHiddenMetaPlugins as s };
|
|
203
202
|
export type { AnySchema as A, ErrorMap as E, InferSchemaInput as I, MetaPlugin as M, ORPCErrorFromErrorMap as O, RouterContract as R, Schema as S, MergedSchema as a, Meta as b, AnyMetaPlugin as c, AnyProcedureContract as d, InferSchemaOutput as e, ErrorMapItem as f, SchemaIssue as g, InferRouterContractErrorMap as h, InferRouterContractInputs as i, InferRouterContractOutputs as j, InferRouterContractError as k, InferRouterContractErrors as l, MetaPluginDefinition as m, ProcedureContractDefinition as n, ValidationErrorOptions as o };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/contract",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.46",
|
|
5
5
|
"description": "Define typesafe API contracts as the single source of truth for oRPC, powered by Standard Schema",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": [
|
|
@@ -43,14 +43,14 @@
|
|
|
43
43
|
"dist"
|
|
44
44
|
],
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@orpc/client": "2.0.0-beta.
|
|
47
|
-
"@orpc/shared": "2.0.0-beta.
|
|
46
|
+
"@orpc/client": "2.0.0-beta.46",
|
|
47
|
+
"@orpc/shared": "2.0.0-beta.46",
|
|
48
48
|
"@standard-schema/spec": "^1.1.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"arktype": "^2.2.8",
|
|
52
52
|
"valibot": "^1.5.0",
|
|
53
|
-
"zod": "^4.6.
|
|
53
|
+
"zod": "^4.6.7"
|
|
54
54
|
},
|
|
55
55
|
"scripts": {
|
|
56
56
|
"type:check": "tsc -b"
|