@orpc/client 2.0.0-beta.32 → 2.0.0-beta.34
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 +44 -29
- package/dist/adapters/fetch/index.d.mts +3 -3
- package/dist/adapters/fetch/index.d.ts +3 -3
- package/dist/adapters/fetch/index.mjs +5 -5
- package/dist/adapters/message-port/index.d.mts +3 -3
- package/dist/adapters/message-port/index.d.ts +3 -3
- package/dist/adapters/message-port/index.mjs +6 -6
- package/dist/adapters/standard/index.d.mts +3 -3
- package/dist/adapters/standard/index.d.ts +3 -3
- package/dist/adapters/standard/index.mjs +5 -5
- package/dist/adapters/websocket/index.d.mts +3 -3
- package/dist/adapters/websocket/index.d.ts +3 -3
- package/dist/adapters/websocket/index.mjs +6 -6
- package/dist/index.d.mts +23 -23
- package/dist/index.d.ts +23 -23
- package/dist/index.mjs +19 -9
- package/dist/plugins/index.d.mts +1 -1
- package/dist/plugins/index.d.ts +1 -1
- package/dist/plugins/index.mjs +4 -4
- package/dist/shared/{client.BhTyskpV.d.ts → client.BWkR2vPU.d.mts} +2 -2
- package/dist/shared/{client.B0-4UDVl.d.mts → client.BnpRXnLi.d.ts} +2 -2
- package/dist/shared/{client.CFVTHyN6.d.ts → client.BoXZCzuS.d.mts} +3 -11
- package/dist/shared/{client.CFVTHyN6.d.mts → client.BoXZCzuS.d.ts} +3 -11
- package/dist/shared/{client.Qwo2aQOm.d.ts → client.CJLNNSvk.d.mts} +1 -1
- package/dist/shared/{client.Qwo2aQOm.d.mts → client.CJLNNSvk.d.ts} +1 -1
- package/dist/shared/{client.BnATe4Ob.mjs → client.Cik8dxOF.mjs} +7 -8
- package/dist/shared/{client.DcoDDrD4.mjs → client.Dtv1JPkU.mjs} +2 -7
- package/dist/shared/{client.vEM0O_Eg.mjs → client.P-JKJSdc.mjs} +3 -3
- package/package.json +6 -7
package/README.md
CHANGED
|
@@ -29,44 +29,54 @@ You can read the documentation [here](https://orpc.dev).
|
|
|
29
29
|
|
|
30
30
|
**Core**
|
|
31
31
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
| Package | Purpose | Docs |
|
|
33
|
+
| -------------------------------------------------------------- | -------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
34
|
+
| [@orpc/contract](https://www.npmjs.com/package/@orpc/contract) | Define API contract as the single source of truth. | [Procedure Contract](https://orpc.dev/docs/contract/procedure), [Contract Router](https://orpc.dev/docs/contract/router), [Implementation](https://orpc.dev/docs/contract/implementation), [Generate from OpenAPI](https://orpc.dev/docs/contract/generate-from-openapi) |
|
|
35
|
+
| [@orpc/server](https://www.npmjs.com/package/@orpc/server) | Build APIs or implement contracts. | [Procedure](https://orpc.dev/docs/procedure), [Router](https://orpc.dev/docs/router), [Middleware](https://orpc.dev/docs/middleware), [Context](https://orpc.dev/docs/context), [RPC Handler](https://orpc.dev/docs/rpc/handler) |
|
|
36
|
+
| [@orpc/client](https://www.npmjs.com/package/@orpc/client) | Consume APIs with end-to-end type safety. | [Client-Side Clients](https://orpc.dev/docs/client/client-side), [Server-Side Clients](https://orpc.dev/docs/client/server-side), [RPC Link](https://orpc.dev/docs/rpc/link), [Error Handling](https://orpc.dev/docs/client/error-handling) |
|
|
37
|
+
| [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi) | Add OpenAPI compatibility to APIs. | [OpenAPI Handler](https://orpc.dev/docs/openapi/handler), [OpenAPI Link](https://orpc.dev/docs/openapi/link), [Specification](https://orpc.dev/docs/openapi/specification), [Scalar](https://orpc.dev/docs/openapi/scalar) |
|
|
36
38
|
|
|
37
39
|
**Schema validation**
|
|
38
40
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
41
|
+
| Package | Purpose | Docs |
|
|
42
|
+
| ------------------------------------------------------------ | ----------------------------------------------- | ----------------------------------------------------- |
|
|
43
|
+
| [@orpc/zod](https://www.npmjs.com/package/@orpc/zod) | Integrate with [Zod](https://zod.dev/). | [Zod](https://orpc.dev/docs/integrations/zod) |
|
|
44
|
+
| [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot) | Integrate with [Valibot](https://valibot.dev/). | [Valibot](https://orpc.dev/docs/integrations/valibot) |
|
|
45
|
+
| [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype) | Integrate with [ArkType](https://arktype.io/). | [ArkType](https://orpc.dev/docs/integrations/arktype) |
|
|
42
46
|
|
|
43
47
|
**Built-in features**
|
|
44
48
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
+
| Package | Purpose | Docs |
|
|
50
|
+
| -------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------- |
|
|
51
|
+
| [@orpc/publisher](https://www.npmjs.com/package/@orpc/publisher) | Pub/Sub with memory, Redis, and Upstash adapters. | [Publisher](https://orpc.dev/docs/helpers/publisher) |
|
|
52
|
+
| [@orpc/ratelimit](https://www.npmjs.com/package/@orpc/ratelimit) | Rate limiting with memory, Redis, and Upstash adapters. | [Rate Limit](https://orpc.dev/docs/helpers/ratelimit) |
|
|
53
|
+
| [@orpc/hibernation](https://www.npmjs.com/package/@orpc/hibernation) | Leverage Hibernation APIs like [Cloudflare's Hibernation WebSocket](https://developers.cloudflare.com/durable-objects/best-practices/websockets/#durable-objects-hibernation-websocket-api). | [Hibernation](https://orpc.dev/docs/integrations/hibernation) |
|
|
54
|
+
| [@orpc/json-schema](https://www.npmjs.com/package/@orpc/json-schema) | Smart coercion for OpenAPI requests. | [Smart Coercion](https://orpc.dev/docs/plugins/smart-coercion) |
|
|
49
55
|
|
|
50
56
|
**Framework & ecosystem integrations**
|
|
51
57
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
58
|
+
| Package | Purpose | Docs |
|
|
59
|
+
| ------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
60
|
+
| [@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) |
|
|
61
|
+
| [@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) |
|
|
62
|
+
| [@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) |
|
|
63
|
+
| [@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) |
|
|
64
|
+
| [@orpc/swr](https://www.npmjs.com/package/@orpc/swr) | Integrate with [SWR](https://swr.vercel.app/). | [SWR](https://orpc.dev/docs/integrations/swr) |
|
|
65
|
+
| [@orpc/experimental-msw](https://www.npmjs.com/package/@orpc/experimental-msw) | Mock procedures with [Mock Service Worker](https://mswjs.io/). | [MSW](https://orpc.dev/docs/integrations/msw) |
|
|
66
|
+
| [@orpc/experimental-effect](https://www.npmjs.com/package/@orpc/experimental-effect) | Integrate with [Effect](https://effect.website/). | [Effect](https://orpc.dev/docs/integrations/effect) |
|
|
67
|
+
| [@orpc/nest](https://www.npmjs.com/package/@orpc/nest) | Implement your contract with [NestJS](https://nestjs.com/). | [NestJS](https://orpc.dev/docs/integrations/nest) |
|
|
68
|
+
| [@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) |
|
|
69
|
+
| [@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) |
|
|
70
|
+
| [@orpc/cloudflare](https://www.npmjs.com/package/@orpc/cloudflare) | Adapters for [Cloudflare's RateLimit and Durable Objects](https://developers.cloudflare.com/workers/). | [Publisher](https://orpc.dev/docs/helpers/publisher), [Rate Limit](https://orpc.dev/docs/helpers/ratelimit) |
|
|
71
|
+
| [@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) |
|
|
64
72
|
|
|
65
73
|
**Observability**
|
|
66
74
|
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
75
|
+
| Package | Purpose | Docs |
|
|
76
|
+
| ------------------------------------------------------------------------ | ---------------------------------------------------------------------------------- | ----------------------------------------------------------------- |
|
|
77
|
+
| [@orpc/opentelemetry](https://www.npmjs.com/package/@orpc/opentelemetry) | Integrate with [OpenTelemetry](https://opentelemetry.io/) for distributed tracing. | [OpenTelemetry](https://orpc.dev/docs/integrations/opentelemetry) |
|
|
78
|
+
| [@orpc/pino](https://www.npmjs.com/package/@orpc/pino) | Integrate with [Pino](https://getpino.io/) for logging. | [Pino](https://orpc.dev/docs/integrations/pino) |
|
|
79
|
+
| [@orpc/evlog](https://www.npmjs.com/package/@orpc/evlog) | Integrate with [Evlog](https://evlog.dev/) for logging. | [Evlog](https://orpc.dev/docs/integrations/evlog) |
|
|
70
80
|
|
|
71
81
|
## Sponsors
|
|
72
82
|
|
|
@@ -76,6 +86,9 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
76
86
|
<tr>
|
|
77
87
|
<td width="2000"><a href="https://screenshotone.com/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener" title="The screenshot API for developers"><img src="https://avatars.githubusercontent.com/u/97035603?v=4" width="64" align="left" hspace="12" alt="ScreenshotOne.com"/><b>ScreenshotOne.com</b></a><br /><sub>The screenshot API for developers</sub></td>
|
|
78
88
|
</tr>
|
|
89
|
+
<tr>
|
|
90
|
+
<td width="2000"><a href="https://yuzu.health/careers?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="We're hiring NYC based engineers"><img src="https://avatars.githubusercontent.com/u/102488956?v=4" width="64" align="left" hspace="12" alt="Yuzu"/><b>Yuzu</b></a><br /><sub>We're hiring NYC based engineers</sub></td>
|
|
91
|
+
</tr>
|
|
79
92
|
<tr>
|
|
80
93
|
<td width="2000"><a href="https://misskey.io/?ref=middleapi&utm_source=middleapi&utm_medium=sponsor" target="_blank" rel="noopener sponsored" title="Decentralized microblogging SNS born on Earth"><img src="https://github.com/MisskeyIO.png" width="64" align="left" hspace="12" alt="MisskeyHQ"/><b>MisskeyHQ</b></a><br /><sub>Decentralized microblogging SNS born on Earth</sub></td>
|
|
81
94
|
</tr>
|
|
@@ -122,30 +135,32 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
122
135
|
<table>
|
|
123
136
|
<tr>
|
|
124
137
|
<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="119" alt="David Walsh"/><br />David Walsh</a></td>
|
|
138
|
+
<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="119" alt="IPv4Addr"/><br />IPv4Addr</a></td>
|
|
125
139
|
<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="119" alt="Robbe Vaes"/><br />Robbe Vaes</a></td>
|
|
126
140
|
<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="119" alt="Aidan Sunbury"/><br />Aidan Sunbury</a></td>
|
|
127
141
|
<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="119" alt="soonoo"/><br />soonoo</a></td>
|
|
128
142
|
<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="119" alt="Kevin Porten"/><br />Kevin Porten</a></td>
|
|
129
143
|
<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>
|
|
130
|
-
<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="119" alt="Christopher Kapic"/><br />Christopher Kapic</a></td>
|
|
131
144
|
</tr>
|
|
132
145
|
<tr>
|
|
146
|
+
<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="119" alt="Christopher Kapic"/><br />Christopher Kapic</a></td>
|
|
133
147
|
<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="119" alt="Tom Ballinger"/><br />Tom Ballinger</a></td>
|
|
134
148
|
<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="119" alt="Sam"/><br />Sam</a></td>
|
|
135
149
|
<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="119" alt="Titoine"/><br />Titoine</a></td>
|
|
136
150
|
<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="119" alt="Igor Makowski"/><br />Igor Makowski</a></td>
|
|
137
151
|
<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="119" alt="hanayashiki"/><br />hanayashiki</a></td>
|
|
138
152
|
<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>
|
|
139
|
-
<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="119" alt="Kelly Peilin Chan"/><br />Kelly Peilin Chan</a></td>
|
|
140
153
|
</tr>
|
|
141
154
|
<tr>
|
|
155
|
+
<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="119" alt="Kelly Peilin Chan"/><br />Kelly Peilin Chan</a></td>
|
|
142
156
|
<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="119" alt="Guy Ariely"/><br />Guy Ariely</a></td>
|
|
157
|
+
<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="119" alt="PaulSenon"/><br />PaulSenon</a></td>
|
|
143
158
|
<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="119" alt="Alex"/><br />Alex</a></td>
|
|
144
159
|
<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="119" alt="Andrey Gubanov"/><br />Andrey Gubanov</a></td>
|
|
145
160
|
</tr>
|
|
146
161
|
</table>
|
|
147
162
|
|
|
148
|
-
With thanks to [
|
|
163
|
+
With thanks to [36 past sponsors](https://htmlpreview.github.io/?https://github.com/middleapi/static/blob/main/sponsors.svg) who helped get oRPC here.
|
|
149
164
|
|
|
150
165
|
## References
|
|
151
166
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ClientContext, ClientOptions } from '../../index.mjs';
|
|
2
2
|
import { Value, Promisable, Interceptor } from '@orpc/shared';
|
|
3
|
-
import { StandardRequest, StandardLazyResponse } from '@
|
|
4
|
-
import { ToFetchBodyOptions } from '@
|
|
3
|
+
import { StandardRequest, StandardLazyResponse } from '@standard-server/core';
|
|
4
|
+
import { ToFetchBodyOptions } from '@standard-server/fetch';
|
|
5
5
|
import { StandardLinkTransport, StandardLinkPlugin, StandardLink, StandardLinkOptions } from '../standard/index.mjs';
|
|
6
6
|
import { RPCLinkCodecOptions } from '../standard/index.mjs';
|
|
7
|
-
import '../../shared/client.
|
|
7
|
+
import '../../shared/client.CJLNNSvk.mjs';
|
|
8
8
|
|
|
9
9
|
interface FetchLinkTransportFetchInterceptorOptions<T extends ClientContext> extends ClientOptions<T> {
|
|
10
10
|
path: string[];
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ClientContext, ClientOptions } from '../../index.js';
|
|
2
2
|
import { Value, Promisable, Interceptor } from '@orpc/shared';
|
|
3
|
-
import { StandardRequest, StandardLazyResponse } from '@
|
|
4
|
-
import { ToFetchBodyOptions } from '@
|
|
3
|
+
import { StandardRequest, StandardLazyResponse } from '@standard-server/core';
|
|
4
|
+
import { ToFetchBodyOptions } from '@standard-server/fetch';
|
|
5
5
|
import { StandardLinkTransport, StandardLinkPlugin, StandardLink, StandardLinkOptions } from '../standard/index.js';
|
|
6
6
|
import { RPCLinkCodecOptions } from '../standard/index.js';
|
|
7
|
-
import '../../shared/client.
|
|
7
|
+
import '../../shared/client.CJLNNSvk.js';
|
|
8
8
|
|
|
9
9
|
interface FetchLinkTransportFetchInterceptorOptions<T extends ClientContext> extends ClientOptions<T> {
|
|
10
10
|
path: string[];
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { sortPlugins, value, intercept, once } from '@orpc/shared';
|
|
2
|
-
import { toFetchBody, toFetchHeaders, toStandardLazyResponse } from '@
|
|
3
|
-
import { S as StandardLink, R as RPCLinkCodec } from '../../shared/client.
|
|
4
|
-
import '@
|
|
5
|
-
import '../../shared/client.
|
|
6
|
-
import '../../shared/client.
|
|
2
|
+
import { toFetchBody, toFetchHeaders, toStandardLazyResponse } from '@standard-server/fetch';
|
|
3
|
+
import { S as StandardLink, R as RPCLinkCodec } from '../../shared/client.P-JKJSdc.mjs';
|
|
4
|
+
import '@standard-server/core';
|
|
5
|
+
import '../../shared/client.Cik8dxOF.mjs';
|
|
6
|
+
import '../../shared/client.Dtv1JPkU.mjs';
|
|
7
7
|
|
|
8
8
|
class CompositeFetchLinkTransportPlugin {
|
|
9
9
|
constructor(plugins = []) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ClientContext, ClientOptions } from '../../index.mjs';
|
|
2
2
|
import { Value, Promisable } from '@orpc/shared';
|
|
3
|
-
import { StandardRequest, StandardLazyResponse } from '@
|
|
4
|
-
import { ClientPeer, EncodePeerMessageOptions, DecodePeerMessageOptions } from '@
|
|
3
|
+
import { StandardRequest, StandardLazyResponse } from '@standard-server/core';
|
|
4
|
+
import { ClientPeer, EncodePeerMessageOptions, DecodePeerMessageOptions } from '@standard-server/peer';
|
|
5
5
|
import { StandardLinkTransport, StandardLink, StandardLinkOptions } from '../standard/index.mjs';
|
|
6
6
|
import { RPCLinkCodecOptions } from '../standard/index.mjs';
|
|
7
|
-
import '../../shared/client.
|
|
7
|
+
import '../../shared/client.CJLNNSvk.mjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* The message port used by electron in main process
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ClientContext, ClientOptions } from '../../index.js';
|
|
2
2
|
import { Value, Promisable } from '@orpc/shared';
|
|
3
|
-
import { StandardRequest, StandardLazyResponse } from '@
|
|
4
|
-
import { ClientPeer, EncodePeerMessageOptions, DecodePeerMessageOptions } from '@
|
|
3
|
+
import { StandardRequest, StandardLazyResponse } from '@standard-server/core';
|
|
4
|
+
import { ClientPeer, EncodePeerMessageOptions, DecodePeerMessageOptions } from '@standard-server/peer';
|
|
5
5
|
import { StandardLinkTransport, StandardLink, StandardLinkOptions } from '../standard/index.js';
|
|
6
6
|
import { RPCLinkCodecOptions } from '../standard/index.js';
|
|
7
|
-
import '../../shared/client.
|
|
7
|
+
import '../../shared/client.CJLNNSvk.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* The message port used by electron in main process
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { value } from '@orpc/shared';
|
|
2
|
-
import { ClientPeer, encodePeerMessage, decodePeerMessage, isServerPeerSendMessage, isPeerMessage } from '@
|
|
3
|
-
import { S as StandardLink, R as RPCLinkCodec } from '../../shared/client.
|
|
4
|
-
import '@
|
|
5
|
-
import '@
|
|
6
|
-
import '../../shared/client.
|
|
7
|
-
import '../../shared/client.
|
|
2
|
+
import { ClientPeer, encodePeerMessage, decodePeerMessage, isServerPeerSendMessage, isPeerMessage } from '@standard-server/peer';
|
|
3
|
+
import { S as StandardLink, R as RPCLinkCodec } from '../../shared/client.P-JKJSdc.mjs';
|
|
4
|
+
import '@standard-server/core';
|
|
5
|
+
import '@standard-server/fetch';
|
|
6
|
+
import '../../shared/client.Cik8dxOF.mjs';
|
|
7
|
+
import '../../shared/client.Dtv1JPkU.mjs';
|
|
8
8
|
|
|
9
9
|
function postMessagePortMessage(port, data, transfer) {
|
|
10
10
|
if (transfer) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { f as StandardLinkCodec, g as StandardLinkCodecDecodedResponse } from '../../shared/client.
|
|
2
|
-
export { C as CompositeStandardLinkPlugin, a as StandardLink, h as StandardLinkInterceptor, e as StandardLinkInterceptorOptions, b as StandardLinkOptions, c as StandardLinkPlugin, S as StandardLinkTransport, i as StandardLinkTransportInterceptor, d as StandardLinkTransportInterceptorOptions } from '../../shared/client.
|
|
1
|
+
import { f as StandardLinkCodec, g as StandardLinkCodecDecodedResponse } from '../../shared/client.BWkR2vPU.mjs';
|
|
2
|
+
export { C as CompositeStandardLinkPlugin, a as StandardLink, h as StandardLinkInterceptor, e as StandardLinkInterceptorOptions, b as StandardLinkOptions, c as StandardLinkPlugin, S as StandardLinkTransport, i as StandardLinkTransportInterceptor, d as StandardLinkTransportInterceptorOptions } from '../../shared/client.BWkR2vPU.mjs';
|
|
3
3
|
import { Value, Promisable } from '@orpc/shared';
|
|
4
|
-
import { StandardUrl, StandardHeaders, StandardRequest, StandardLazyResponse } from '@
|
|
4
|
+
import { StandardUrl, StandardHeaders, StandardRequest, StandardLazyResponse } from '@standard-server/core';
|
|
5
5
|
import { ClientContext, ClientOptions } from '../../index.mjs';
|
|
6
6
|
import { RPCSerializer } from '../../index.mjs';
|
|
7
7
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { f as StandardLinkCodec, g as StandardLinkCodecDecodedResponse } from '../../shared/client.
|
|
2
|
-
export { C as CompositeStandardLinkPlugin, a as StandardLink, h as StandardLinkInterceptor, e as StandardLinkInterceptorOptions, b as StandardLinkOptions, c as StandardLinkPlugin, S as StandardLinkTransport, i as StandardLinkTransportInterceptor, d as StandardLinkTransportInterceptorOptions } from '../../shared/client.
|
|
1
|
+
import { f as StandardLinkCodec, g as StandardLinkCodecDecodedResponse } from '../../shared/client.BnpRXnLi.js';
|
|
2
|
+
export { C as CompositeStandardLinkPlugin, a as StandardLink, h as StandardLinkInterceptor, e as StandardLinkInterceptorOptions, b as StandardLinkOptions, c as StandardLinkPlugin, S as StandardLinkTransport, i as StandardLinkTransportInterceptor, d as StandardLinkTransportInterceptorOptions } from '../../shared/client.BnpRXnLi.js';
|
|
3
3
|
import { Value, Promisable } from '@orpc/shared';
|
|
4
|
-
import { StandardUrl, StandardHeaders, StandardRequest, StandardLazyResponse } from '@
|
|
4
|
+
import { StandardUrl, StandardHeaders, StandardRequest, StandardLazyResponse } from '@standard-server/core';
|
|
5
5
|
import { ClientContext, ClientOptions } from '../../index.js';
|
|
6
6
|
import { RPCSerializer } from '../../index.js';
|
|
7
7
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { C as CompositeStandardLinkPlugin, R as RPCLinkCodec, S as StandardLink } from '../../shared/client.
|
|
1
|
+
export { C as CompositeStandardLinkPlugin, R as RPCLinkCodec, S as StandardLink } from '../../shared/client.P-JKJSdc.mjs';
|
|
2
2
|
import '@orpc/shared';
|
|
3
|
-
import '@
|
|
4
|
-
import '@
|
|
5
|
-
import '../../shared/client.
|
|
6
|
-
import '../../shared/client.
|
|
3
|
+
import '@standard-server/core';
|
|
4
|
+
import '@standard-server/fetch';
|
|
5
|
+
import '../../shared/client.Cik8dxOF.mjs';
|
|
6
|
+
import '../../shared/client.Dtv1JPkU.mjs';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ClientContext, ClientOptions } from '../../index.mjs';
|
|
2
2
|
import { Promisable } from '@orpc/shared';
|
|
3
|
-
import { StandardRequest, StandardLazyResponse } from '@
|
|
4
|
-
import { EncodePeerMessageOptions, DecodePeerMessageOptions } from '@
|
|
3
|
+
import { StandardRequest, StandardLazyResponse } from '@standard-server/core';
|
|
4
|
+
import { EncodePeerMessageOptions, DecodePeerMessageOptions } from '@standard-server/peer';
|
|
5
5
|
import { StandardLinkTransport, StandardLink, StandardLinkOptions } from '../standard/index.mjs';
|
|
6
6
|
import { RPCLinkCodecOptions } from '../standard/index.mjs';
|
|
7
|
-
import '../../shared/client.
|
|
7
|
+
import '../../shared/client.CJLNNSvk.mjs';
|
|
8
8
|
|
|
9
9
|
type WebSocketLike = Pick<WebSocket, 'addEventListener' | 'removeEventListener' | 'send' | 'readyState'>;
|
|
10
10
|
interface WebSocketLinkTransportAttemptInfo {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { ClientContext, ClientOptions } from '../../index.js';
|
|
2
2
|
import { Promisable } from '@orpc/shared';
|
|
3
|
-
import { StandardRequest, StandardLazyResponse } from '@
|
|
4
|
-
import { EncodePeerMessageOptions, DecodePeerMessageOptions } from '@
|
|
3
|
+
import { StandardRequest, StandardLazyResponse } from '@standard-server/core';
|
|
4
|
+
import { EncodePeerMessageOptions, DecodePeerMessageOptions } from '@standard-server/peer';
|
|
5
5
|
import { StandardLinkTransport, StandardLink, StandardLinkOptions } from '../standard/index.js';
|
|
6
6
|
import { RPCLinkCodecOptions } from '../standard/index.js';
|
|
7
|
-
import '../../shared/client.
|
|
7
|
+
import '../../shared/client.CJLNNSvk.js';
|
|
8
8
|
|
|
9
9
|
type WebSocketLike = Pick<WebSocket, 'addEventListener' | 'removeEventListener' | 'send' | 'readyState'>;
|
|
10
10
|
interface WebSocketLinkTransportAttemptInfo {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { runWithSignal, AbortError, sleep, promiseWithResolvers, sequential, loadBytes, toStringOrBytes } from '@orpc/shared';
|
|
2
|
-
import { ClientPeer, encodePeerMessage, decodePeerMessage, isServerPeerSendMessage } from '@
|
|
3
|
-
import { S as StandardLink, R as RPCLinkCodec } from '../../shared/client.
|
|
4
|
-
import '@
|
|
5
|
-
import '@
|
|
6
|
-
import '../../shared/client.
|
|
7
|
-
import '../../shared/client.
|
|
2
|
+
import { ClientPeer, encodePeerMessage, decodePeerMessage, isServerPeerSendMessage } from '@standard-server/peer';
|
|
3
|
+
import { S as StandardLink, R as RPCLinkCodec } from '../../shared/client.P-JKJSdc.mjs';
|
|
4
|
+
import '@standard-server/core';
|
|
5
|
+
import '@standard-server/fetch';
|
|
6
|
+
import '../../shared/client.Cik8dxOF.mjs';
|
|
7
|
+
import '../../shared/client.Dtv1JPkU.mjs';
|
|
8
8
|
|
|
9
9
|
const WEBSOCKET_CONNECTING = 0;
|
|
10
10
|
const WEBSOCKET_OPEN = 1;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { WrapAsyncIteratorOptions, AsyncIteratorClass, Interceptor, PromiseWithError, ThrowableError, Promisable } from '@orpc/shared';
|
|
2
2
|
export { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, PromiseWithError as ClientPromiseResult, MaybeOptionalOptions, PromiseWithError, Registry, ThrowableError, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, consumeAsyncIterator, consumeAsyncIterator as consumeEventIterator, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject, streamToAsyncIteratorObject as streamToEventIterator } from '@orpc/shared';
|
|
3
|
-
import { C as ClientContext, a as ClientOptions, c as AnyNestedClient, I as InferClientContext, d as InferClientError, e as Client, b as ClientLink, A as AnyORPCError, f as ClientRest, F as FriendlyClientOptions, O as ORPCErrorCode, g as ORPCErrorJSON, h as ORPCError, M as MalformedResponseErrorOptions } from './shared/client.
|
|
4
|
-
export { i as AnyORPCErrorJSON, j as COMMON_ERROR_STATUS_MAP, k as InferClientBodyInputs, l as InferClientBodyOutputs, m as InferClientErrors, n as InferClientInputs, o as InferClientOutputs, p as MalformedResponseError, N as NestedClient, q as ORPCErrorOptions } from './shared/client.
|
|
5
|
-
import { StandardResponse } from '@
|
|
6
|
-
export { ErrorEvent, EventMeta, StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl, getEventMeta, unwrapEvent, withEventMeta } from '@
|
|
7
|
-
export { R as RPCJsonSerialization, a as RPCJsonSerializationMeta, b as RPCJsonSerializer, c as RPCJsonSerializerHandler, d as RPCJsonSerializerOptions, e as RPCSerializer, f as RPCSerializerOptions, g as RPCSerializerSerializeOptions } from './shared/client.
|
|
3
|
+
import { C as ClientContext, a as ClientOptions, c as AnyNestedClient, I as InferClientContext, d as InferClientError, e as Client, b as ClientLink, A as AnyORPCError, f as ClientRest, F as FriendlyClientOptions, O as ORPCErrorCode, g as ORPCErrorJSON, h as ORPCError, M as MalformedResponseErrorOptions } from './shared/client.BoXZCzuS.mjs';
|
|
4
|
+
export { i as AnyORPCErrorJSON, j as COMMON_ERROR_STATUS_MAP, k as InferClientBodyInputs, l as InferClientBodyOutputs, m as InferClientErrors, n as InferClientInputs, o as InferClientOutputs, p as MalformedResponseError, N as NestedClient, q as ORPCErrorOptions } from './shared/client.BoXZCzuS.mjs';
|
|
5
|
+
import { StandardResponse } from '@standard-server/core';
|
|
6
|
+
export { ErrorEvent, EventMeta, StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl, getEventMeta, unwrapEvent, withEventMeta } from '@standard-server/core';
|
|
7
|
+
export { R as RPCJsonSerialization, a as RPCJsonSerializationMeta, b as RPCJsonSerializer, c as RPCJsonSerializerHandler, d as RPCJsonSerializerOptions, e as RPCSerializer, f as RPCSerializerOptions, g as RPCSerializerSerializeOptions } from './shared/client.CJLNNSvk.mjs';
|
|
8
8
|
|
|
9
9
|
declare function wrapAsyncIteratorPreservingEventMeta<TYield, TReturn, TMappedYield = TYield, TMappedReturn = TReturn>(iterator: AsyncIterator<TYield, TReturn>, { mapResult, mapError, ...rest }: WrapAsyncIteratorOptions<TYield, TReturn, TMappedYield, TMappedReturn>): AsyncIteratorClass<TMappedYield, TMappedReturn>;
|
|
10
10
|
|
|
@@ -49,36 +49,36 @@ declare function createORPCClient<T extends AnyNestedClient>(link: ClientLink<In
|
|
|
49
49
|
|
|
50
50
|
declare function resolveFriendlyClientOptions<T extends ClientContext>(options: FriendlyClientOptions<T>): ClientOptions<T>;
|
|
51
51
|
declare function resolveClientRest<TClientContext extends ClientContext, TInput>(rest: ClientRest<TClientContext, TInput>): [input: TInput, options: ClientOptions<TClientContext>];
|
|
52
|
-
type SafeResult<TOutput, TError> = [error: null, data: TOutput,
|
|
52
|
+
type SafeResult<TOutput, TError> = [error: null, data: TOutput, definedError: null, isSuccess: true] & {
|
|
53
53
|
error: null;
|
|
54
54
|
data: TOutput;
|
|
55
|
-
|
|
55
|
+
definedError: null;
|
|
56
56
|
isSuccess: true;
|
|
57
|
-
} | [error: Exclude<TError, AnyORPCError>, data: undefined,
|
|
57
|
+
} | [error: Exclude<TError, AnyORPCError>, data: undefined, definedError: null, isSuccess: false] & {
|
|
58
58
|
error: Exclude<TError, AnyORPCError>;
|
|
59
59
|
data: undefined;
|
|
60
|
-
|
|
60
|
+
definedError: null;
|
|
61
61
|
isSuccess: false;
|
|
62
|
-
} | [error: Extract<TError, AnyORPCError>, data: undefined,
|
|
62
|
+
} | [error: Extract<TError, AnyORPCError>, data: undefined, definedError: Extract<TError, AnyORPCError>, isSuccess: false] & {
|
|
63
63
|
error: Extract<TError, AnyORPCError>;
|
|
64
64
|
data: undefined;
|
|
65
|
-
|
|
65
|
+
definedError: Extract<TError, AnyORPCError>;
|
|
66
66
|
isSuccess: false;
|
|
67
67
|
};
|
|
68
68
|
/**
|
|
69
|
-
* Works like try/catch, but help you infer the error type if it is
|
|
69
|
+
* Works like try/catch, but help you infer the error type if it is a defined ORPCError.
|
|
70
70
|
*
|
|
71
71
|
* @example
|
|
72
72
|
* ```ts
|
|
73
|
-
* const [error, data,
|
|
74
|
-
* // or const { error, data,
|
|
73
|
+
* const [error, data, definedError, isSuccess] = await safe(client(...))
|
|
74
|
+
* // or const { error, data, definedError, isSuccess } = await safe(client(...))
|
|
75
75
|
*
|
|
76
|
-
* if (
|
|
77
|
-
* console.log(
|
|
76
|
+
* if (definedError) {
|
|
77
|
+
* console.log(definedError) // or error, both are well typed
|
|
78
78
|
* }
|
|
79
79
|
* ```
|
|
80
80
|
*
|
|
81
|
-
* @see {@link https://orpc.dev/docs/client/error-handling#using-safe-and-
|
|
81
|
+
* @see {@link https://orpc.dev/docs/client/error-handling#using-safe-and-isdefinederror | Client Error Handling - Using safe and isDefinedError}
|
|
82
82
|
*/
|
|
83
83
|
declare function safe<TOutput, TError = ThrowableError>(promise: PromiseWithError<TOutput, TError>): Promise<SafeResult<TOutput, TError>>;
|
|
84
84
|
|
|
@@ -91,8 +91,8 @@ type SafeClient<T extends AnyNestedClient> = T extends Client<infer UContext, in
|
|
|
91
91
|
* @example
|
|
92
92
|
* ```ts
|
|
93
93
|
* const safeClient = createSafeClient(client)
|
|
94
|
-
* const { error, data,
|
|
95
|
-
* // or const [error, data,
|
|
94
|
+
* const { error, data, definedError, isSuccess } = await safeClient.doSomething({ id: '123' })
|
|
95
|
+
* // or const [error, data, definedError, isSuccess] = await safeClient.doSomething({ id: '123' })
|
|
96
96
|
* ```
|
|
97
97
|
*
|
|
98
98
|
* @see {@link https://orpc.dev/docs/client/error-handling#safe-client | Client Error Handling - Safe Client}
|
|
@@ -123,12 +123,12 @@ declare class DynamicLink<TClientContext extends ClientContext> implements Clien
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
/**
|
|
126
|
-
* Checks if an error is an `ORPCError`
|
|
126
|
+
* Checks if an error is an `ORPCError` that matches a definition in the procedure's `.errors` map,
|
|
127
127
|
* narrowing it so `code` and `data` are fully typed.
|
|
128
128
|
*
|
|
129
|
-
* @see {@link https://orpc.dev/docs/client/error-handling#using-safe-and-
|
|
129
|
+
* @see {@link https://orpc.dev/docs/client/error-handling#using-safe-and-isdefinederror | Client Error Handling - Using safe and isDefinedError}
|
|
130
130
|
*/
|
|
131
|
-
declare function
|
|
131
|
+
declare function isDefinedError<T>(error: T): error is Extract<T, AnyORPCError>;
|
|
132
132
|
declare function toORPCError<T>(error: T): Extract<T, AnyORPCError> | ORPCError<'INTERNAL_SERVER_ERROR', undefined>;
|
|
133
133
|
declare function isORPCErrorJson(json: unknown): json is ORPCErrorJSON<ORPCErrorCode, unknown>;
|
|
134
134
|
declare function createORPCErrorFromJson<TCode extends ORPCErrorCode, TData>(json: ORPCErrorJSON<TCode, TData>, options?: ErrorOptions): ORPCError<TCode, TData>;
|
|
@@ -152,5 +152,5 @@ declare function createORPCErrorFromMalformedResponse(options: MalformedResponse
|
|
|
152
152
|
*/
|
|
153
153
|
declare function cloneORPCError<T extends AnyORPCError>(error: T): T;
|
|
154
154
|
|
|
155
|
-
export { AnyNestedClient, AnyORPCError, Client, ClientContext, ClientLink, ClientOptions, ClientRest, DynamicLink, FriendlyClientOptions, InferClientContext, InferClientError, InferClientError as InferClientErrorUnion, MalformedResponseErrorOptions, ORPCError, ORPCErrorCode, ORPCErrorJSON, RECURSIVE_CLIENT_UNWRAP_KEYS, cloneORPCError, createORPCClient, createORPCErrorFromJson, createORPCErrorFromMalformedResponse, createSafeClient,
|
|
155
|
+
export { AnyNestedClient, AnyORPCError, Client, ClientContext, ClientLink, ClientOptions, ClientRest, DynamicLink, FriendlyClientOptions, InferClientContext, InferClientError, InferClientError as InferClientErrorUnion, MalformedResponseErrorOptions, ORPCError, ORPCErrorCode, ORPCErrorJSON, RECURSIVE_CLIENT_UNWRAP_KEYS, cloneORPCError, createORPCClient, createORPCErrorFromJson, createORPCErrorFromMalformedResponse, createSafeClient, isDefinedError, isORPCErrorJson, resolveClientRest, resolveFriendlyClientOptions, safe, toORPCError, wrapAsyncIteratorPreservingEventMeta };
|
|
156
156
|
export type { ORPCClientInterceptor, ORPCClientInterceptorOptions, ORPCClientOptions, ORPCClientScoped, ORPCClientScopedOptions, SafeClient, SafeResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { WrapAsyncIteratorOptions, AsyncIteratorClass, Interceptor, PromiseWithError, ThrowableError, Promisable } from '@orpc/shared';
|
|
2
2
|
export { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, PromiseWithError as ClientPromiseResult, MaybeOptionalOptions, PromiseWithError, Registry, ThrowableError, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, consumeAsyncIterator, consumeAsyncIterator as consumeEventIterator, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject, streamToAsyncIteratorObject as streamToEventIterator } from '@orpc/shared';
|
|
3
|
-
import { C as ClientContext, a as ClientOptions, c as AnyNestedClient, I as InferClientContext, d as InferClientError, e as Client, b as ClientLink, A as AnyORPCError, f as ClientRest, F as FriendlyClientOptions, O as ORPCErrorCode, g as ORPCErrorJSON, h as ORPCError, M as MalformedResponseErrorOptions } from './shared/client.
|
|
4
|
-
export { i as AnyORPCErrorJSON, j as COMMON_ERROR_STATUS_MAP, k as InferClientBodyInputs, l as InferClientBodyOutputs, m as InferClientErrors, n as InferClientInputs, o as InferClientOutputs, p as MalformedResponseError, N as NestedClient, q as ORPCErrorOptions } from './shared/client.
|
|
5
|
-
import { StandardResponse } from '@
|
|
6
|
-
export { ErrorEvent, EventMeta, StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl, getEventMeta, unwrapEvent, withEventMeta } from '@
|
|
7
|
-
export { R as RPCJsonSerialization, a as RPCJsonSerializationMeta, b as RPCJsonSerializer, c as RPCJsonSerializerHandler, d as RPCJsonSerializerOptions, e as RPCSerializer, f as RPCSerializerOptions, g as RPCSerializerSerializeOptions } from './shared/client.
|
|
3
|
+
import { C as ClientContext, a as ClientOptions, c as AnyNestedClient, I as InferClientContext, d as InferClientError, e as Client, b as ClientLink, A as AnyORPCError, f as ClientRest, F as FriendlyClientOptions, O as ORPCErrorCode, g as ORPCErrorJSON, h as ORPCError, M as MalformedResponseErrorOptions } from './shared/client.BoXZCzuS.js';
|
|
4
|
+
export { i as AnyORPCErrorJSON, j as COMMON_ERROR_STATUS_MAP, k as InferClientBodyInputs, l as InferClientBodyOutputs, m as InferClientErrors, n as InferClientInputs, o as InferClientOutputs, p as MalformedResponseError, N as NestedClient, q as ORPCErrorOptions } from './shared/client.BoXZCzuS.js';
|
|
5
|
+
import { StandardResponse } from '@standard-server/core';
|
|
6
|
+
export { ErrorEvent, EventMeta, StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl, getEventMeta, unwrapEvent, withEventMeta } from '@standard-server/core';
|
|
7
|
+
export { R as RPCJsonSerialization, a as RPCJsonSerializationMeta, b as RPCJsonSerializer, c as RPCJsonSerializerHandler, d as RPCJsonSerializerOptions, e as RPCSerializer, f as RPCSerializerOptions, g as RPCSerializerSerializeOptions } from './shared/client.CJLNNSvk.js';
|
|
8
8
|
|
|
9
9
|
declare function wrapAsyncIteratorPreservingEventMeta<TYield, TReturn, TMappedYield = TYield, TMappedReturn = TReturn>(iterator: AsyncIterator<TYield, TReturn>, { mapResult, mapError, ...rest }: WrapAsyncIteratorOptions<TYield, TReturn, TMappedYield, TMappedReturn>): AsyncIteratorClass<TMappedYield, TMappedReturn>;
|
|
10
10
|
|
|
@@ -49,36 +49,36 @@ declare function createORPCClient<T extends AnyNestedClient>(link: ClientLink<In
|
|
|
49
49
|
|
|
50
50
|
declare function resolveFriendlyClientOptions<T extends ClientContext>(options: FriendlyClientOptions<T>): ClientOptions<T>;
|
|
51
51
|
declare function resolveClientRest<TClientContext extends ClientContext, TInput>(rest: ClientRest<TClientContext, TInput>): [input: TInput, options: ClientOptions<TClientContext>];
|
|
52
|
-
type SafeResult<TOutput, TError> = [error: null, data: TOutput,
|
|
52
|
+
type SafeResult<TOutput, TError> = [error: null, data: TOutput, definedError: null, isSuccess: true] & {
|
|
53
53
|
error: null;
|
|
54
54
|
data: TOutput;
|
|
55
|
-
|
|
55
|
+
definedError: null;
|
|
56
56
|
isSuccess: true;
|
|
57
|
-
} | [error: Exclude<TError, AnyORPCError>, data: undefined,
|
|
57
|
+
} | [error: Exclude<TError, AnyORPCError>, data: undefined, definedError: null, isSuccess: false] & {
|
|
58
58
|
error: Exclude<TError, AnyORPCError>;
|
|
59
59
|
data: undefined;
|
|
60
|
-
|
|
60
|
+
definedError: null;
|
|
61
61
|
isSuccess: false;
|
|
62
|
-
} | [error: Extract<TError, AnyORPCError>, data: undefined,
|
|
62
|
+
} | [error: Extract<TError, AnyORPCError>, data: undefined, definedError: Extract<TError, AnyORPCError>, isSuccess: false] & {
|
|
63
63
|
error: Extract<TError, AnyORPCError>;
|
|
64
64
|
data: undefined;
|
|
65
|
-
|
|
65
|
+
definedError: Extract<TError, AnyORPCError>;
|
|
66
66
|
isSuccess: false;
|
|
67
67
|
};
|
|
68
68
|
/**
|
|
69
|
-
* Works like try/catch, but help you infer the error type if it is
|
|
69
|
+
* Works like try/catch, but help you infer the error type if it is a defined ORPCError.
|
|
70
70
|
*
|
|
71
71
|
* @example
|
|
72
72
|
* ```ts
|
|
73
|
-
* const [error, data,
|
|
74
|
-
* // or const { error, data,
|
|
73
|
+
* const [error, data, definedError, isSuccess] = await safe(client(...))
|
|
74
|
+
* // or const { error, data, definedError, isSuccess } = await safe(client(...))
|
|
75
75
|
*
|
|
76
|
-
* if (
|
|
77
|
-
* console.log(
|
|
76
|
+
* if (definedError) {
|
|
77
|
+
* console.log(definedError) // or error, both are well typed
|
|
78
78
|
* }
|
|
79
79
|
* ```
|
|
80
80
|
*
|
|
81
|
-
* @see {@link https://orpc.dev/docs/client/error-handling#using-safe-and-
|
|
81
|
+
* @see {@link https://orpc.dev/docs/client/error-handling#using-safe-and-isdefinederror | Client Error Handling - Using safe and isDefinedError}
|
|
82
82
|
*/
|
|
83
83
|
declare function safe<TOutput, TError = ThrowableError>(promise: PromiseWithError<TOutput, TError>): Promise<SafeResult<TOutput, TError>>;
|
|
84
84
|
|
|
@@ -91,8 +91,8 @@ type SafeClient<T extends AnyNestedClient> = T extends Client<infer UContext, in
|
|
|
91
91
|
* @example
|
|
92
92
|
* ```ts
|
|
93
93
|
* const safeClient = createSafeClient(client)
|
|
94
|
-
* const { error, data,
|
|
95
|
-
* // or const [error, data,
|
|
94
|
+
* const { error, data, definedError, isSuccess } = await safeClient.doSomething({ id: '123' })
|
|
95
|
+
* // or const [error, data, definedError, isSuccess] = await safeClient.doSomething({ id: '123' })
|
|
96
96
|
* ```
|
|
97
97
|
*
|
|
98
98
|
* @see {@link https://orpc.dev/docs/client/error-handling#safe-client | Client Error Handling - Safe Client}
|
|
@@ -123,12 +123,12 @@ declare class DynamicLink<TClientContext extends ClientContext> implements Clien
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
/**
|
|
126
|
-
* Checks if an error is an `ORPCError`
|
|
126
|
+
* Checks if an error is an `ORPCError` that matches a definition in the procedure's `.errors` map,
|
|
127
127
|
* narrowing it so `code` and `data` are fully typed.
|
|
128
128
|
*
|
|
129
|
-
* @see {@link https://orpc.dev/docs/client/error-handling#using-safe-and-
|
|
129
|
+
* @see {@link https://orpc.dev/docs/client/error-handling#using-safe-and-isdefinederror | Client Error Handling - Using safe and isDefinedError}
|
|
130
130
|
*/
|
|
131
|
-
declare function
|
|
131
|
+
declare function isDefinedError<T>(error: T): error is Extract<T, AnyORPCError>;
|
|
132
132
|
declare function toORPCError<T>(error: T): Extract<T, AnyORPCError> | ORPCError<'INTERNAL_SERVER_ERROR', undefined>;
|
|
133
133
|
declare function isORPCErrorJson(json: unknown): json is ORPCErrorJSON<ORPCErrorCode, unknown>;
|
|
134
134
|
declare function createORPCErrorFromJson<TCode extends ORPCErrorCode, TData>(json: ORPCErrorJSON<TCode, TData>, options?: ErrorOptions): ORPCError<TCode, TData>;
|
|
@@ -152,5 +152,5 @@ declare function createORPCErrorFromMalformedResponse(options: MalformedResponse
|
|
|
152
152
|
*/
|
|
153
153
|
declare function cloneORPCError<T extends AnyORPCError>(error: T): T;
|
|
154
154
|
|
|
155
|
-
export { AnyNestedClient, AnyORPCError, Client, ClientContext, ClientLink, ClientOptions, ClientRest, DynamicLink, FriendlyClientOptions, InferClientContext, InferClientError, InferClientError as InferClientErrorUnion, MalformedResponseErrorOptions, ORPCError, ORPCErrorCode, ORPCErrorJSON, RECURSIVE_CLIENT_UNWRAP_KEYS, cloneORPCError, createORPCClient, createORPCErrorFromJson, createORPCErrorFromMalformedResponse, createSafeClient,
|
|
155
|
+
export { AnyNestedClient, AnyORPCError, Client, ClientContext, ClientLink, ClientOptions, ClientRest, DynamicLink, FriendlyClientOptions, InferClientContext, InferClientError, InferClientError as InferClientErrorUnion, MalformedResponseErrorOptions, ORPCError, ORPCErrorCode, ORPCErrorJSON, RECURSIVE_CLIENT_UNWRAP_KEYS, cloneORPCError, createORPCClient, createORPCErrorFromJson, createORPCErrorFromMalformedResponse, createSafeClient, isDefinedError, isORPCErrorJson, resolveClientRest, resolveFriendlyClientOptions, safe, toORPCError, wrapAsyncIteratorPreservingEventMeta };
|
|
156
156
|
export type { ORPCClientInterceptor, ORPCClientInterceptorOptions, ORPCClientOptions, ORPCClientScoped, ORPCClientScopedOptions, SafeClient, SafeResult };
|
package/dist/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { b as
|
|
2
|
-
export { d as RPCJsonSerializer, R as RPCSerializer, e as cloneORPCError, a as createORPCErrorFromJson, c as createORPCErrorFromMalformedResponse, i as isORPCErrorJson, t as toORPCError, w as wrapAsyncIteratorPreservingEventMeta } from './shared/client.
|
|
1
|
+
import { b as isDefinedError } from './shared/client.Cik8dxOF.mjs';
|
|
2
|
+
export { d as RPCJsonSerializer, R as RPCSerializer, e as cloneORPCError, a as createORPCErrorFromJson, c as createORPCErrorFromMalformedResponse, i as isORPCErrorJson, t as toORPCError, w as wrapAsyncIteratorPreservingEventMeta } from './shared/client.Cik8dxOF.mjs';
|
|
3
3
|
import { toArray, intercept, isTypescriptObject } from '@orpc/shared';
|
|
4
4
|
export { AsyncIteratorClass, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, consumeAsyncIterator, consumeAsyncIterator as consumeEventIterator, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject, streamToAsyncIteratorObject as streamToEventIterator } from '@orpc/shared';
|
|
5
|
-
export { C as COMMON_ERROR_STATUS_MAP, M as MalformedResponseError, O as ORPCError } from './shared/client.
|
|
6
|
-
export { ErrorEvent, getEventMeta, unwrapEvent, withEventMeta } from '@
|
|
5
|
+
export { C as COMMON_ERROR_STATUS_MAP, M as MalformedResponseError, O as ORPCError } from './shared/client.Dtv1JPkU.mjs';
|
|
6
|
+
export { ErrorEvent, getEventMeta, unwrapEvent, withEventMeta } from '@standard-server/core';
|
|
7
7
|
|
|
8
8
|
const RECURSIVE_CLIENT_UNWRAP_KEYS = /* @__PURE__ */ new Set([
|
|
9
9
|
/**
|
|
@@ -16,6 +16,16 @@ const RECURSIVE_CLIENT_UNWRAP_KEYS = /* @__PURE__ */ new Set([
|
|
|
16
16
|
* context.
|
|
17
17
|
*/
|
|
18
18
|
"bind",
|
|
19
|
+
/**
|
|
20
|
+
* Commonly used by libraries to invoke functions with a specific `this`
|
|
21
|
+
* context.
|
|
22
|
+
*/
|
|
23
|
+
"call",
|
|
24
|
+
/**
|
|
25
|
+
* Commonly used by libraries to invoke functions with a specific `this`
|
|
26
|
+
* context and an arguments array.
|
|
27
|
+
*/
|
|
28
|
+
"apply",
|
|
19
29
|
/**
|
|
20
30
|
* Commonly accessed during primitive conversion, inspection, and logging.
|
|
21
31
|
*/
|
|
@@ -50,19 +60,19 @@ async function safe(promise) {
|
|
|
50
60
|
const output = await promise;
|
|
51
61
|
return Object.assign(
|
|
52
62
|
[null, output, null, true],
|
|
53
|
-
{ error: null, data: output,
|
|
63
|
+
{ error: null, data: output, definedError: null, isSuccess: true }
|
|
54
64
|
);
|
|
55
65
|
} catch (e) {
|
|
56
66
|
const error = e;
|
|
57
|
-
if (
|
|
67
|
+
if (isDefinedError(error)) {
|
|
58
68
|
return Object.assign(
|
|
59
69
|
[error, void 0, error, false],
|
|
60
|
-
{ error, data: void 0,
|
|
70
|
+
{ error, data: void 0, definedError: error, isSuccess: false }
|
|
61
71
|
);
|
|
62
72
|
}
|
|
63
73
|
return Object.assign(
|
|
64
74
|
[error, void 0, null, false],
|
|
65
|
-
{ error, data: void 0,
|
|
75
|
+
{ error, data: void 0, definedError: null, isSuccess: false }
|
|
66
76
|
);
|
|
67
77
|
}
|
|
68
78
|
}
|
|
@@ -134,4 +144,4 @@ class DynamicLink {
|
|
|
134
144
|
}
|
|
135
145
|
}
|
|
136
146
|
|
|
137
|
-
export { DynamicLink, RECURSIVE_CLIENT_UNWRAP_KEYS, createORPCClient, createSafeClient,
|
|
147
|
+
export { DynamicLink, RECURSIVE_CLIENT_UNWRAP_KEYS, createORPCClient, createSafeClient, isDefinedError, resolveClientRest, resolveFriendlyClientOptions, safe };
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Value, Promisable } from '@orpc/shared';
|
|
2
|
-
import { StandardUrl, StandardHeaders, StandardRequest, StandardLazyResponse } from '@
|
|
2
|
+
import { StandardUrl, StandardHeaders, StandardRequest, StandardLazyResponse } from '@standard-server/core';
|
|
3
3
|
import { ClientContext } from '../index.mjs';
|
|
4
4
|
import { StandardLinkPlugin, StandardLinkTransportInterceptorOptions, StandardLinkOptions, StandardLinkInterceptorOptions } from '../adapters/standard/index.mjs';
|
|
5
5
|
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Value, Promisable } from '@orpc/shared';
|
|
2
|
-
import { StandardUrl, StandardHeaders, StandardRequest, StandardLazyResponse } from '@
|
|
2
|
+
import { StandardUrl, StandardHeaders, StandardRequest, StandardLazyResponse } from '@standard-server/core';
|
|
3
3
|
import { ClientContext } from '../index.js';
|
|
4
4
|
import { StandardLinkPlugin, StandardLinkTransportInterceptorOptions, StandardLinkOptions, StandardLinkInterceptorOptions } from '../adapters/standard/index.js';
|
|
5
5
|
|
package/dist/plugins/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { toArray, value, splitInHalf, stringifyJSON, once, isAsyncIteratorObject, defer, loadBytes, allAbortSignal, replicateAsyncIterator, replicateReadableStream, isCompressibleContentType, override, AsyncIteratorClass, sleep, AbortError, anyAbortSignal } from '@orpc/shared';
|
|
2
|
-
import { parseStandardUrl, flattenStandardHeader, generateContentDisposition, getEventMeta } from '@
|
|
3
|
-
import { ClientPeer, isServerPeerSendMessage, decodePeerMessage } from '@
|
|
4
|
-
import { toFetchHeaders, toStandardBody } from '@
|
|
5
|
-
import { C as COMMON_ERROR_STATUS_MAP } from '../shared/client.
|
|
2
|
+
import { parseStandardUrl, flattenStandardHeader, generateContentDisposition, getEventMeta } from '@standard-server/core';
|
|
3
|
+
import { ClientPeer, isServerPeerSendMessage, decodePeerMessage } from '@standard-server/peer';
|
|
4
|
+
import { toFetchHeaders, toStandardBody } from '@standard-server/fetch';
|
|
5
|
+
import { C as COMMON_ERROR_STATUS_MAP } from '../shared/client.Dtv1JPkU.mjs';
|
|
6
6
|
|
|
7
7
|
class BatchLinkPlugin {
|
|
8
8
|
name = "~batch";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Promisable, OrderablePlugin, Interceptor } from '@orpc/shared';
|
|
2
|
-
import { StandardRequest, StandardLazyResponse } from '@
|
|
3
|
-
import { C as ClientContext, a as ClientOptions, A as AnyORPCError, b as ClientLink } from './client.
|
|
2
|
+
import { StandardRequest, StandardLazyResponse } from '@standard-server/core';
|
|
3
|
+
import { C as ClientContext, a as ClientOptions, A as AnyORPCError, b as ClientLink } from './client.BoXZCzuS.mjs';
|
|
4
4
|
|
|
5
5
|
type StandardLinkCodecDecodedResponse = {
|
|
6
6
|
kind: 'output';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Promisable, OrderablePlugin, Interceptor } from '@orpc/shared';
|
|
2
|
-
import { StandardRequest, StandardLazyResponse } from '@
|
|
3
|
-
import { C as ClientContext, a as ClientOptions, A as AnyORPCError, b as ClientLink } from './client.
|
|
2
|
+
import { StandardRequest, StandardLazyResponse } from '@standard-server/core';
|
|
3
|
+
import { C as ClientContext, a as ClientOptions, A as AnyORPCError, b as ClientLink } from './client.BoXZCzuS.js';
|
|
4
4
|
|
|
5
5
|
type StandardLinkCodecDecodedResponse = {
|
|
6
6
|
kind: 'output';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PromiseWithError, Registry, MaybeOptionalOptions } from '@orpc/shared';
|
|
2
|
-
import { StandardResponse } from '@
|
|
2
|
+
import { StandardResponse } from '@standard-server/core';
|
|
3
3
|
|
|
4
4
|
interface ClientContext {
|
|
5
5
|
[key: PropertyKey]: any;
|
|
@@ -155,14 +155,10 @@ declare class ORPCError<TCode extends ORPCErrorCode, TData> extends Error {
|
|
|
155
155
|
__branch: "ORPCError";
|
|
156
156
|
};
|
|
157
157
|
/**
|
|
158
|
-
* Indicates whether the error matches a definition in the procedure's `.errors` map
|
|
158
|
+
* Indicates whether the error matches a definition in the procedure's `.errors` map,
|
|
159
|
+
* which makes its type inferable on the client.
|
|
159
160
|
*/
|
|
160
161
|
readonly defined: boolean;
|
|
161
|
-
/**
|
|
162
|
-
* Indicates whether the error's type is inferable at the TypeScript level.
|
|
163
|
-
* This is typically true when the error is explicitly defined or returned within a handler.
|
|
164
|
-
*/
|
|
165
|
-
readonly inferable: boolean;
|
|
166
162
|
code: TCode;
|
|
167
163
|
data: TData;
|
|
168
164
|
constructor(code: TCode, ...rest: MaybeOptionalOptions<ORPCErrorOptions<TData>>);
|
|
@@ -186,10 +182,6 @@ interface ORPCErrorJSON<TCode extends string, TData> extends Pick<ORPCError<TCod
|
|
|
186
182
|
* remove readonly
|
|
187
183
|
*/
|
|
188
184
|
defined: boolean;
|
|
189
|
-
/**
|
|
190
|
-
* remove readonly
|
|
191
|
-
*/
|
|
192
|
-
inferable: boolean;
|
|
193
185
|
}
|
|
194
186
|
type AnyORPCError = ORPCError<any, any>;
|
|
195
187
|
type AnyORPCErrorJSON = ORPCErrorJSON<any, any>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PromiseWithError, Registry, MaybeOptionalOptions } from '@orpc/shared';
|
|
2
|
-
import { StandardResponse } from '@
|
|
2
|
+
import { StandardResponse } from '@standard-server/core';
|
|
3
3
|
|
|
4
4
|
interface ClientContext {
|
|
5
5
|
[key: PropertyKey]: any;
|
|
@@ -155,14 +155,10 @@ declare class ORPCError<TCode extends ORPCErrorCode, TData> extends Error {
|
|
|
155
155
|
__branch: "ORPCError";
|
|
156
156
|
};
|
|
157
157
|
/**
|
|
158
|
-
* Indicates whether the error matches a definition in the procedure's `.errors` map
|
|
158
|
+
* Indicates whether the error matches a definition in the procedure's `.errors` map,
|
|
159
|
+
* which makes its type inferable on the client.
|
|
159
160
|
*/
|
|
160
161
|
readonly defined: boolean;
|
|
161
|
-
/**
|
|
162
|
-
* Indicates whether the error's type is inferable at the TypeScript level.
|
|
163
|
-
* This is typically true when the error is explicitly defined or returned within a handler.
|
|
164
|
-
*/
|
|
165
|
-
readonly inferable: boolean;
|
|
166
162
|
code: TCode;
|
|
167
163
|
data: TData;
|
|
168
164
|
constructor(code: TCode, ...rest: MaybeOptionalOptions<ORPCErrorOptions<TData>>);
|
|
@@ -186,10 +182,6 @@ interface ORPCErrorJSON<TCode extends string, TData> extends Pick<ORPCError<TCod
|
|
|
186
182
|
* remove readonly
|
|
187
183
|
*/
|
|
188
184
|
defined: boolean;
|
|
189
|
-
/**
|
|
190
|
-
* remove readonly
|
|
191
|
-
*/
|
|
192
|
-
inferable: boolean;
|
|
193
185
|
}
|
|
194
186
|
type AnyORPCError = ORPCError<any, any>;
|
|
195
187
|
type AnyORPCErrorJSON = ORPCErrorJSON<any, any>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { isPlainObject, wrapAsyncIterator, isTypescriptObject, NullProtoObj, isAsyncIteratorObject, stringifyJSON } from '@orpc/shared';
|
|
2
|
-
import { getEventMeta, withEventMeta, ErrorEvent } from '@
|
|
3
|
-
import { O as ORPCError, M as MalformedResponseError, C as COMMON_ERROR_STATUS_MAP } from './client.
|
|
2
|
+
import { getEventMeta, withEventMeta, ErrorEvent } from '@standard-server/core';
|
|
3
|
+
import { O as ORPCError, M as MalformedResponseError, C as COMMON_ERROR_STATUS_MAP } from './client.Dtv1JPkU.mjs';
|
|
4
4
|
|
|
5
|
-
function
|
|
6
|
-
return error instanceof ORPCError && error.
|
|
5
|
+
function isDefinedError(error) {
|
|
6
|
+
return error instanceof ORPCError && error.defined;
|
|
7
7
|
}
|
|
8
8
|
function toORPCError(error) {
|
|
9
9
|
return error instanceof ORPCError ? error : new ORPCError("INTERNAL_SERVER_ERROR", { cause: error });
|
|
@@ -12,11 +12,11 @@ function isORPCErrorJson(json) {
|
|
|
12
12
|
if (!isPlainObject(json)) {
|
|
13
13
|
return false;
|
|
14
14
|
}
|
|
15
|
-
const validKeys = ["defined", "
|
|
15
|
+
const validKeys = ["defined", "code", "message", "data"];
|
|
16
16
|
if (Object.keys(json).some((k) => !validKeys.includes(k))) {
|
|
17
17
|
return false;
|
|
18
18
|
}
|
|
19
|
-
return "defined" in json && typeof json.defined === "boolean" && "
|
|
19
|
+
return "defined" in json && typeof json.defined === "boolean" && "code" in json && typeof json.code === "string" && "message" in json && typeof json.message === "string";
|
|
20
20
|
}
|
|
21
21
|
function createORPCErrorFromJson(json, options = {}) {
|
|
22
22
|
const error = new ORPCError(json.code, {
|
|
@@ -24,7 +24,6 @@ function createORPCErrorFromJson(json, options = {}) {
|
|
|
24
24
|
...options
|
|
25
25
|
});
|
|
26
26
|
error.defined = json.defined;
|
|
27
|
-
error.inferable = json.inferable;
|
|
28
27
|
return error;
|
|
29
28
|
}
|
|
30
29
|
function createORPCErrorFromMalformedResponse(options) {
|
|
@@ -458,4 +457,4 @@ class RPCSerializer {
|
|
|
458
457
|
}
|
|
459
458
|
}
|
|
460
459
|
|
|
461
|
-
export { RPCSerializer as R, createORPCErrorFromJson as a,
|
|
460
|
+
export { RPCSerializer as R, createORPCErrorFromJson as a, isDefinedError as b, createORPCErrorFromMalformedResponse as c, RPCJsonSerializer as d, cloneORPCError as e, isORPCErrorJson as i, toORPCError as t, wrapAsyncIteratorPreservingEventMeta as w };
|
|
@@ -39,14 +39,10 @@ class ORPCError extends Error {
|
|
|
39
39
|
*/
|
|
40
40
|
name = "ORPCError";
|
|
41
41
|
/**
|
|
42
|
-
* Indicates whether the error matches a definition in the procedure's `.errors` map
|
|
42
|
+
* Indicates whether the error matches a definition in the procedure's `.errors` map,
|
|
43
|
+
* which makes its type inferable on the client.
|
|
43
44
|
*/
|
|
44
45
|
defined = false;
|
|
45
|
-
/**
|
|
46
|
-
* Indicates whether the error's type is inferable at the TypeScript level.
|
|
47
|
-
* This is typically true when the error is explicitly defined or returned within a handler.
|
|
48
|
-
*/
|
|
49
|
-
inferable = false;
|
|
50
46
|
code;
|
|
51
47
|
data;
|
|
52
48
|
constructor(code, ...rest) {
|
|
@@ -59,7 +55,6 @@ class ORPCError extends Error {
|
|
|
59
55
|
toJSON() {
|
|
60
56
|
return {
|
|
61
57
|
defined: this.defined,
|
|
62
|
-
inferable: this.inferable,
|
|
63
58
|
code: this.code,
|
|
64
59
|
message: this.message,
|
|
65
60
|
data: this.data
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { sortPlugins, runWithSpan, ORPC_NAME, isAsyncIteratorObject, override, traceAsyncIterator, intercept, getOpenTelemetryConfig, value, pathToHttpPath, stringifyJSON } from '@orpc/shared';
|
|
2
|
-
import { mergeStandardHeaders, parseStandardUrl } from '@
|
|
3
|
-
import { toStandardHeaders } from '@
|
|
4
|
-
import { R as RPCSerializer, c as createORPCErrorFromMalformedResponse, i as isORPCErrorJson, a as createORPCErrorFromJson } from './client.
|
|
2
|
+
import { mergeStandardHeaders, parseStandardUrl } from '@standard-server/core';
|
|
3
|
+
import { toStandardHeaders } from '@standard-server/fetch';
|
|
4
|
+
import { R as RPCSerializer, c as createORPCErrorFromMalformedResponse, i as isORPCErrorJson, a as createORPCErrorFromJson } from './client.Cik8dxOF.mjs';
|
|
5
5
|
|
|
6
6
|
class CompositeStandardLinkPlugin {
|
|
7
7
|
name = "~composite";
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@orpc/client",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.0.0-beta.
|
|
4
|
+
"version": "2.0.0-beta.34",
|
|
5
5
|
"description": "Consume oRPC and OpenAPI APIs with end-to-end type safety over HTTP, WebSocket, or message ports",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": [
|
|
@@ -63,16 +63,15 @@
|
|
|
63
63
|
"dist"
|
|
64
64
|
],
|
|
65
65
|
"dependencies": {
|
|
66
|
-
"@orpc/shared": "2.0.0-beta.
|
|
67
|
-
"@
|
|
68
|
-
"@
|
|
69
|
-
"@
|
|
66
|
+
"@orpc/shared": "2.0.0-beta.34",
|
|
67
|
+
"@standard-server/core": "~0.9.0",
|
|
68
|
+
"@standard-server/fetch": "~0.9.0",
|
|
69
|
+
"@standard-server/peer": "~0.9.0"
|
|
70
70
|
},
|
|
71
71
|
"devDependencies": {
|
|
72
|
-
"zod": "^4.4
|
|
72
|
+
"zod": "^4.5.4"
|
|
73
73
|
},
|
|
74
74
|
"scripts": {
|
|
75
|
-
"build": "unbuild",
|
|
76
75
|
"type:check": "tsc -b"
|
|
77
76
|
}
|
|
78
77
|
}
|