@orpc/client 2.0.0-beta.22 → 2.0.0-beta.24
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 +4 -1
- package/dist/adapters/fetch/index.d.mts +8 -3
- package/dist/adapters/fetch/index.d.ts +8 -3
- package/dist/adapters/fetch/index.mjs +4 -4
- package/dist/adapters/message-port/index.d.mts +11 -6
- package/dist/adapters/message-port/index.d.ts +11 -6
- package/dist/adapters/message-port/index.mjs +3 -3
- package/dist/adapters/standard/index.d.mts +4 -4
- package/dist/adapters/standard/index.d.ts +4 -4
- package/dist/adapters/standard/index.mjs +3 -3
- package/dist/adapters/websocket/index.d.mts +8 -3
- package/dist/adapters/websocket/index.d.ts +8 -3
- package/dist/adapters/websocket/index.mjs +3 -3
- package/dist/index.d.mts +23 -7
- package/dist/index.d.ts +23 -7
- package/dist/index.mjs +30 -16
- package/dist/plugins/index.d.mts +46 -8
- package/dist/plugins/index.d.ts +46 -8
- package/dist/plugins/index.mjs +2 -2
- package/dist/shared/{client.Bl4junIW.mjs → client.B6ItE3bt.mjs} +2 -2
- package/dist/shared/{client.Dlxz9Qw5.d.mts → client.B8tCfDzm.d.mts} +6 -0
- package/dist/shared/{client.Dlxz9Qw5.d.ts → client.B8tCfDzm.d.ts} +6 -0
- package/dist/shared/{client.BMKYqpdy.d.ts → client.BGShxYPR.d.ts} +1 -1
- package/dist/shared/{client.DQpq_Sdn.mjs → client.BZMJyvQd.mjs} +1 -1
- package/dist/shared/{client.8f4DNmdE.d.mts → client.BpRn9TAI.d.mts} +1 -1
- package/dist/shared/{client.Dnfj8jnT.mjs → client.CPcOxSex.mjs} +8 -7
- package/dist/shared/{client.BBZBQID8.d.mts → client.EMUKnkap.d.mts} +34 -4
- package/dist/shared/{client.BBZBQID8.d.ts → client.EMUKnkap.d.ts} +34 -4
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -44,6 +44,7 @@ You can read the documentation [here](https://orpc.dev).
|
|
|
44
44
|
|
|
45
45
|
- [@orpc/publisher](https://www.npmjs.com/package/@orpc/publisher): Pub/Sub with memory, Redis, and Upstash adapters.
|
|
46
46
|
- [@orpc/ratelimit](https://www.npmjs.com/package/@orpc/ratelimit): Rate limiting with memory, Redis, and Upstash adapters.
|
|
47
|
+
- [@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).
|
|
47
48
|
- [@orpc/json-schema](https://www.npmjs.com/package/@orpc/json-schema): Smart coercion for OpenAPI requests.
|
|
48
49
|
|
|
49
50
|
**Framework & ecosystem integrations**
|
|
@@ -114,6 +115,7 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
114
115
|
</tr>
|
|
115
116
|
<tr>
|
|
116
117
|
<td align="center"><a href="https://github.com/itigoore01?ref=orpc" target="_blank" rel="noopener" title="shota"><img src="https://avatars.githubusercontent.com/u/11831107?u=c976a6dc7e055eb026304c46c99100ed22b0c8e0&v=4" width="139" alt="shota"/><br />shota</a></td>
|
|
118
|
+
<td align="center"><a href="https://github.com/ellis-driscoll?ref=orpc" target="_blank" rel="noopener" title="Ellis Driscoll"><img src="https://avatars.githubusercontent.com/u/70685966?u=c5f95bc33b5991d9744abe00052542e4a2ed3cb9&v=4" width="139" alt="Ellis Driscoll"/><br />Ellis Driscoll</a></td>
|
|
117
119
|
</tr>
|
|
118
120
|
</table>
|
|
119
121
|
|
|
@@ -139,8 +141,9 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
139
141
|
<td align="center"><a href="https://github.com/mr-kelly?ref=orpc" target="_blank" rel="noopener" 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
142
|
</tr>
|
|
141
143
|
<tr>
|
|
144
|
+
<td align="center"><a href="https://github.com/guyariely?ref=orpc" target="_blank" rel="noopener" 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>
|
|
142
145
|
<td align="center"><a href="https://github.com/piscis?ref=orpc" target="_blank" rel="noopener" title="Alex"><img src="https://avatars.githubusercontent.com/u/326163?u=b245f368bd940cf51d08c0b6bf55f8257f359437&v=4" width="119" alt="Alex"/><br />Alex</a></td>
|
|
143
|
-
<td align="center"><a href="https://github.com/finom?ref=orpc" target="_blank" rel="noopener" title="Andrey Gubanov"><img src="https://avatars.githubusercontent.com/u/1082083?u=
|
|
146
|
+
<td align="center"><a href="https://github.com/finom?ref=orpc" target="_blank" rel="noopener" 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>
|
|
144
147
|
</tr>
|
|
145
148
|
</table>
|
|
146
149
|
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { C as ClientContext, a as ClientOptions } from '../../shared/client.
|
|
1
|
+
import { C as ClientContext, a as ClientOptions } from '../../shared/client.EMUKnkap.mjs';
|
|
2
2
|
import { Value, Promisable, Interceptor } from '@orpc/shared';
|
|
3
3
|
import { StandardRequest, StandardLazyResponse } from '@standardserver/core';
|
|
4
4
|
import { ToFetchBodyOptions } from '@standardserver/fetch';
|
|
5
|
-
import { S as StandardLinkTransport, c as StandardLinkPlugin, a as StandardLink, b as StandardLinkOptions } from '../../shared/client.
|
|
5
|
+
import { S as StandardLinkTransport, c as StandardLinkPlugin, a as StandardLink, b as StandardLinkOptions } from '../../shared/client.BpRn9TAI.mjs';
|
|
6
6
|
import { RPCLinkCodecOptions } from '../standard/index.mjs';
|
|
7
|
-
import '../../shared/client.
|
|
7
|
+
import '../../shared/client.B8tCfDzm.mjs';
|
|
8
8
|
|
|
9
9
|
interface FetchLinkTransportFetchInterceptorOptions<T extends ClientContext> extends ClientOptions<T> {
|
|
10
10
|
path: string[];
|
|
@@ -57,6 +57,11 @@ declare class CompositeFetchLinkTransportPlugin<T extends ClientContext> impleme
|
|
|
57
57
|
|
|
58
58
|
interface RPCLinkOptions<T extends ClientContext> extends Omit<StandardLinkOptions<T>, 'plugins'>, FetchLinkTransportOptions<T>, RPCLinkCodecOptions<T> {
|
|
59
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Client link that communicates with an RPC Handler over the Fetch API (HTTP).
|
|
62
|
+
*
|
|
63
|
+
* @see {@link https://orpc.dev/docs/adapters/fetch-api | Fetch API Adapter}
|
|
64
|
+
*/
|
|
60
65
|
declare class RPCLink<T extends ClientContext> extends StandardLink<T> {
|
|
61
66
|
constructor(options: RPCLinkOptions<T>);
|
|
62
67
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { C as ClientContext, a as ClientOptions } from '../../shared/client.
|
|
1
|
+
import { C as ClientContext, a as ClientOptions } from '../../shared/client.EMUKnkap.js';
|
|
2
2
|
import { Value, Promisable, Interceptor } from '@orpc/shared';
|
|
3
3
|
import { StandardRequest, StandardLazyResponse } from '@standardserver/core';
|
|
4
4
|
import { ToFetchBodyOptions } from '@standardserver/fetch';
|
|
5
|
-
import { S as StandardLinkTransport, c as StandardLinkPlugin, a as StandardLink, b as StandardLinkOptions } from '../../shared/client.
|
|
5
|
+
import { S as StandardLinkTransport, c as StandardLinkPlugin, a as StandardLink, b as StandardLinkOptions } from '../../shared/client.BGShxYPR.js';
|
|
6
6
|
import { RPCLinkCodecOptions } from '../standard/index.js';
|
|
7
|
-
import '../../shared/client.
|
|
7
|
+
import '../../shared/client.B8tCfDzm.js';
|
|
8
8
|
|
|
9
9
|
interface FetchLinkTransportFetchInterceptorOptions<T extends ClientContext> extends ClientOptions<T> {
|
|
10
10
|
path: string[];
|
|
@@ -57,6 +57,11 @@ declare class CompositeFetchLinkTransportPlugin<T extends ClientContext> impleme
|
|
|
57
57
|
|
|
58
58
|
interface RPCLinkOptions<T extends ClientContext> extends Omit<StandardLinkOptions<T>, 'plugins'>, FetchLinkTransportOptions<T>, RPCLinkCodecOptions<T> {
|
|
59
59
|
}
|
|
60
|
+
/**
|
|
61
|
+
* Client link that communicates with an RPC Handler over the Fetch API (HTTP).
|
|
62
|
+
*
|
|
63
|
+
* @see {@link https://orpc.dev/docs/adapters/fetch-api | Fetch API Adapter}
|
|
64
|
+
*/
|
|
60
65
|
declare class RPCLink<T extends ClientContext> extends StandardLink<T> {
|
|
61
66
|
constructor(options: RPCLinkOptions<T>);
|
|
62
67
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { sortPlugins, value, intercept, once } from '@orpc/shared';
|
|
2
2
|
import { toFetchBody, toFetchHeaders, toStandardLazyResponse } from '@standardserver/fetch';
|
|
3
|
-
import { S as StandardLink, R as RPCLinkCodec } from '../../shared/client.
|
|
3
|
+
import { S as StandardLink, R as RPCLinkCodec } from '../../shared/client.B6ItE3bt.mjs';
|
|
4
4
|
import '@standardserver/core';
|
|
5
|
-
import '../../shared/client.
|
|
6
|
-
import '../../shared/client.
|
|
5
|
+
import '../../shared/client.CPcOxSex.mjs';
|
|
6
|
+
import '../../shared/client.BZMJyvQd.mjs';
|
|
7
7
|
|
|
8
8
|
class CompositeFetchLinkTransportPlugin {
|
|
9
9
|
constructor(plugins = []) {
|
|
10
10
|
this.plugins = plugins;
|
|
11
11
|
this.plugins = sortPlugins(plugins);
|
|
12
12
|
}
|
|
13
|
-
name = "~composite/fetch
|
|
13
|
+
name = "~composite/fetch";
|
|
14
14
|
initFetchLinkTransportOptions(options) {
|
|
15
15
|
for (const plugin of this.plugins) {
|
|
16
16
|
if (plugin.initFetchLinkTransportOptions) {
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { C as ClientContext, a as ClientOptions } from '../../shared/client.
|
|
1
|
+
import { C as ClientContext, a as ClientOptions } from '../../shared/client.EMUKnkap.mjs';
|
|
2
2
|
import { Value, Promisable } from '@orpc/shared';
|
|
3
3
|
import { StandardRequest, StandardLazyResponse } from '@standardserver/core';
|
|
4
4
|
import { ClientPeer, EncodePeerMessageOptions, DecodePeerMessageOptions } from '@standardserver/peer';
|
|
5
|
-
import { S as StandardLinkTransport, a as StandardLink, b as StandardLinkOptions } from '../../shared/client.
|
|
5
|
+
import { S as StandardLinkTransport, a as StandardLink, b as StandardLinkOptions } from '../../shared/client.BpRn9TAI.mjs';
|
|
6
6
|
import { RPCLinkCodecOptions } from '../standard/index.mjs';
|
|
7
|
-
import '../../shared/client.
|
|
7
|
+
import '../../shared/client.B8tCfDzm.mjs';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* The message port used by electron in main process
|
|
@@ -45,9 +45,8 @@ interface MessagePortLinkTransportOptions<_T extends ClientContext> {
|
|
|
45
45
|
* such as transferring ownership of objects to the other side or support unserializable objects like `OffscreenCanvas`.
|
|
46
46
|
*
|
|
47
47
|
* @remarks
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* @warning Make sure your message port supports `transfer` before using this feature.
|
|
48
|
+
* **Note**: Returning `null` or `undefined` disables this feature.
|
|
49
|
+
* **Warning**: Make sure your message port supports `transfer` before using this feature.
|
|
51
50
|
*/
|
|
52
51
|
experimental_transfer?: Value<Promisable<object[] | null | undefined>, [message: DecodedRequestMessage, port: SupportedMessagePort]>;
|
|
53
52
|
/**
|
|
@@ -67,6 +66,12 @@ declare class MessagePortLinkTransport<T extends ClientContext> implements Stand
|
|
|
67
66
|
|
|
68
67
|
interface RPCLinkOptions<T extends ClientContext> extends StandardLinkOptions<T>, MessagePortLinkTransportOptions<T>, RPCLinkCodecOptions<T> {
|
|
69
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Client link that communicates with an RPC Handler over a Message Port
|
|
71
|
+
* (e.g. workers, iframes, browser extensions, Electron).
|
|
72
|
+
*
|
|
73
|
+
* @see {@link https://orpc.dev/docs/adapters/message-port | Message Port Adapter}
|
|
74
|
+
*/
|
|
70
75
|
declare class RPCLink<T extends ClientContext> extends StandardLink<T> {
|
|
71
76
|
constructor(options: RPCLinkOptions<T>);
|
|
72
77
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { C as ClientContext, a as ClientOptions } from '../../shared/client.
|
|
1
|
+
import { C as ClientContext, a as ClientOptions } from '../../shared/client.EMUKnkap.js';
|
|
2
2
|
import { Value, Promisable } from '@orpc/shared';
|
|
3
3
|
import { StandardRequest, StandardLazyResponse } from '@standardserver/core';
|
|
4
4
|
import { ClientPeer, EncodePeerMessageOptions, DecodePeerMessageOptions } from '@standardserver/peer';
|
|
5
|
-
import { S as StandardLinkTransport, a as StandardLink, b as StandardLinkOptions } from '../../shared/client.
|
|
5
|
+
import { S as StandardLinkTransport, a as StandardLink, b as StandardLinkOptions } from '../../shared/client.BGShxYPR.js';
|
|
6
6
|
import { RPCLinkCodecOptions } from '../standard/index.js';
|
|
7
|
-
import '../../shared/client.
|
|
7
|
+
import '../../shared/client.B8tCfDzm.js';
|
|
8
8
|
|
|
9
9
|
/**
|
|
10
10
|
* The message port used by electron in main process
|
|
@@ -45,9 +45,8 @@ interface MessagePortLinkTransportOptions<_T extends ClientContext> {
|
|
|
45
45
|
* such as transferring ownership of objects to the other side or support unserializable objects like `OffscreenCanvas`.
|
|
46
46
|
*
|
|
47
47
|
* @remarks
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* @warning Make sure your message port supports `transfer` before using this feature.
|
|
48
|
+
* **Note**: Returning `null` or `undefined` disables this feature.
|
|
49
|
+
* **Warning**: Make sure your message port supports `transfer` before using this feature.
|
|
51
50
|
*/
|
|
52
51
|
experimental_transfer?: Value<Promisable<object[] | null | undefined>, [message: DecodedRequestMessage, port: SupportedMessagePort]>;
|
|
53
52
|
/**
|
|
@@ -67,6 +66,12 @@ declare class MessagePortLinkTransport<T extends ClientContext> implements Stand
|
|
|
67
66
|
|
|
68
67
|
interface RPCLinkOptions<T extends ClientContext> extends StandardLinkOptions<T>, MessagePortLinkTransportOptions<T>, RPCLinkCodecOptions<T> {
|
|
69
68
|
}
|
|
69
|
+
/**
|
|
70
|
+
* Client link that communicates with an RPC Handler over a Message Port
|
|
71
|
+
* (e.g. workers, iframes, browser extensions, Electron).
|
|
72
|
+
*
|
|
73
|
+
* @see {@link https://orpc.dev/docs/adapters/message-port | Message Port Adapter}
|
|
74
|
+
*/
|
|
70
75
|
declare class RPCLink<T extends ClientContext> extends StandardLink<T> {
|
|
71
76
|
constructor(options: RPCLinkOptions<T>);
|
|
72
77
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { value } from '@orpc/shared';
|
|
2
2
|
import { ClientPeer, encodePeerMessage, decodePeerMessage, isServerPeerSendMessage, isPeerMessage } from '@standardserver/peer';
|
|
3
|
-
import { S as StandardLink, R as RPCLinkCodec } from '../../shared/client.
|
|
3
|
+
import { S as StandardLink, R as RPCLinkCodec } from '../../shared/client.B6ItE3bt.mjs';
|
|
4
4
|
import '@standardserver/core';
|
|
5
5
|
import '@standardserver/fetch';
|
|
6
|
-
import '../../shared/client.
|
|
7
|
-
import '../../shared/client.
|
|
6
|
+
import '../../shared/client.CPcOxSex.mjs';
|
|
7
|
+
import '../../shared/client.BZMJyvQd.mjs';
|
|
8
8
|
|
|
9
9
|
function postMessagePortMessage(port, data, transfer) {
|
|
10
10
|
if (transfer) {
|
|
@@ -1,10 +1,10 @@
|
|
|
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.BpRn9TAI.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.BpRn9TAI.mjs';
|
|
3
3
|
import { Value, Promisable } from '@orpc/shared';
|
|
4
4
|
import { StandardUrl, StandardHeaders, StandardRequest, StandardLazyResponse } from '@standardserver/core';
|
|
5
5
|
export { StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl } from '@standardserver/core';
|
|
6
|
-
import { C as ClientContext, a as ClientOptions } from '../../shared/client.
|
|
7
|
-
import { e as RPCSerializer } from '../../shared/client.
|
|
6
|
+
import { C as ClientContext, a as ClientOptions } from '../../shared/client.EMUKnkap.mjs';
|
|
7
|
+
import { e as RPCSerializer } from '../../shared/client.B8tCfDzm.mjs';
|
|
8
8
|
|
|
9
9
|
interface RPCLinkCodecOptions<T extends ClientContext> {
|
|
10
10
|
/**
|
|
@@ -1,10 +1,10 @@
|
|
|
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.BGShxYPR.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.BGShxYPR.js';
|
|
3
3
|
import { Value, Promisable } from '@orpc/shared';
|
|
4
4
|
import { StandardUrl, StandardHeaders, StandardRequest, StandardLazyResponse } from '@standardserver/core';
|
|
5
5
|
export { StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl } from '@standardserver/core';
|
|
6
|
-
import { C as ClientContext, a as ClientOptions } from '../../shared/client.
|
|
7
|
-
import { e as RPCSerializer } from '../../shared/client.
|
|
6
|
+
import { C as ClientContext, a as ClientOptions } from '../../shared/client.EMUKnkap.js';
|
|
7
|
+
import { e as RPCSerializer } from '../../shared/client.B8tCfDzm.js';
|
|
8
8
|
|
|
9
9
|
interface RPCLinkCodecOptions<T extends ClientContext> {
|
|
10
10
|
/**
|
|
@@ -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.B6ItE3bt.mjs';
|
|
2
2
|
import '@orpc/shared';
|
|
3
3
|
import '@standardserver/core';
|
|
4
4
|
import '@standardserver/fetch';
|
|
5
|
-
import '../../shared/client.
|
|
6
|
-
import '../../shared/client.
|
|
5
|
+
import '../../shared/client.CPcOxSex.mjs';
|
|
6
|
+
import '../../shared/client.BZMJyvQd.mjs';
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { C as ClientContext, a as ClientOptions } from '../../shared/client.
|
|
1
|
+
import { C as ClientContext, a as ClientOptions } from '../../shared/client.EMUKnkap.mjs';
|
|
2
2
|
import { Promisable } from '@orpc/shared';
|
|
3
3
|
import { StandardRequest, StandardLazyResponse } from '@standardserver/core';
|
|
4
4
|
import { EncodePeerMessageOptions, DecodePeerMessageOptions } from '@standardserver/peer';
|
|
5
|
-
import { S as StandardLinkTransport, a as StandardLink, b as StandardLinkOptions } from '../../shared/client.
|
|
5
|
+
import { S as StandardLinkTransport, a as StandardLink, b as StandardLinkOptions } from '../../shared/client.BpRn9TAI.mjs';
|
|
6
6
|
import { RPCLinkCodecOptions } from '../standard/index.mjs';
|
|
7
|
-
import '../../shared/client.
|
|
7
|
+
import '../../shared/client.B8tCfDzm.mjs';
|
|
8
8
|
|
|
9
9
|
type WebSocketLike = Pick<WebSocket, 'addEventListener' | 'removeEventListener' | 'send' | 'readyState'>;
|
|
10
10
|
interface WebSocketLinkTransportAttemptInfo {
|
|
@@ -113,6 +113,11 @@ declare class WebSocketLinkTransport<T extends ClientContext> implements Standar
|
|
|
113
113
|
|
|
114
114
|
interface RPCLinkOptions<T extends ClientContext> extends StandardLinkOptions<T>, WebSocketLinkTransportOptions<T>, RPCLinkCodecOptions<T> {
|
|
115
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Client link that communicates with an RPC Handler over a WebSocket connection.
|
|
118
|
+
*
|
|
119
|
+
* @see {@link https://orpc.dev/docs/adapters/websocket | WebSocket Adapters}
|
|
120
|
+
*/
|
|
116
121
|
declare class RPCLink<T extends ClientContext> extends StandardLink<T> {
|
|
117
122
|
constructor(options: RPCLinkOptions<T>);
|
|
118
123
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { C as ClientContext, a as ClientOptions } from '../../shared/client.
|
|
1
|
+
import { C as ClientContext, a as ClientOptions } from '../../shared/client.EMUKnkap.js';
|
|
2
2
|
import { Promisable } from '@orpc/shared';
|
|
3
3
|
import { StandardRequest, StandardLazyResponse } from '@standardserver/core';
|
|
4
4
|
import { EncodePeerMessageOptions, DecodePeerMessageOptions } from '@standardserver/peer';
|
|
5
|
-
import { S as StandardLinkTransport, a as StandardLink, b as StandardLinkOptions } from '../../shared/client.
|
|
5
|
+
import { S as StandardLinkTransport, a as StandardLink, b as StandardLinkOptions } from '../../shared/client.BGShxYPR.js';
|
|
6
6
|
import { RPCLinkCodecOptions } from '../standard/index.js';
|
|
7
|
-
import '../../shared/client.
|
|
7
|
+
import '../../shared/client.B8tCfDzm.js';
|
|
8
8
|
|
|
9
9
|
type WebSocketLike = Pick<WebSocket, 'addEventListener' | 'removeEventListener' | 'send' | 'readyState'>;
|
|
10
10
|
interface WebSocketLinkTransportAttemptInfo {
|
|
@@ -113,6 +113,11 @@ declare class WebSocketLinkTransport<T extends ClientContext> implements Standar
|
|
|
113
113
|
|
|
114
114
|
interface RPCLinkOptions<T extends ClientContext> extends StandardLinkOptions<T>, WebSocketLinkTransportOptions<T>, RPCLinkCodecOptions<T> {
|
|
115
115
|
}
|
|
116
|
+
/**
|
|
117
|
+
* Client link that communicates with an RPC Handler over a WebSocket connection.
|
|
118
|
+
*
|
|
119
|
+
* @see {@link https://orpc.dev/docs/adapters/websocket | WebSocket Adapters}
|
|
120
|
+
*/
|
|
116
121
|
declare class RPCLink<T extends ClientContext> extends StandardLink<T> {
|
|
117
122
|
constructor(options: RPCLinkOptions<T>);
|
|
118
123
|
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { runWithSignal, AbortError, sleep, promiseWithResolvers, sequential, loadBytes, toStringOrBytes } from '@orpc/shared';
|
|
2
2
|
import { ClientPeer, encodePeerMessage, decodePeerMessage, isServerPeerSendMessage } from '@standardserver/peer';
|
|
3
|
-
import { S as StandardLink, R as RPCLinkCodec } from '../../shared/client.
|
|
3
|
+
import { S as StandardLink, R as RPCLinkCodec } from '../../shared/client.B6ItE3bt.mjs';
|
|
4
4
|
import '@standardserver/core';
|
|
5
5
|
import '@standardserver/fetch';
|
|
6
|
-
import '../../shared/client.
|
|
7
|
-
import '../../shared/client.
|
|
6
|
+
import '../../shared/client.CPcOxSex.mjs';
|
|
7
|
+
import '../../shared/client.BZMJyvQd.mjs';
|
|
8
8
|
|
|
9
9
|
const WEBSOCKET_CONNECTING = 0;
|
|
10
10
|
const WEBSOCKET_OPEN = 1;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { WrapAsyncIteratorOptions, AsyncIteratorClass, Interceptor, PromiseWithError, ThrowableError, Promisable } from '@orpc/shared';
|
|
2
|
-
export { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, 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 ORPCError, h as ORPCErrorJSON } 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, N as NestedClient, p as ORPCErrorOptions } from './shared/client.
|
|
5
|
-
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.
|
|
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 ORPCError, h as ORPCErrorJSON } from './shared/client.EMUKnkap.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, N as NestedClient, p as ORPCErrorOptions } from './shared/client.EMUKnkap.mjs';
|
|
5
|
+
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.B8tCfDzm.mjs';
|
|
6
6
|
export { ErrorEvent, EventMeta, getEventMeta, unwrapEvent, withEventMeta } from '@standardserver/core';
|
|
7
7
|
|
|
8
8
|
declare function wrapAsyncIteratorPreservingEventMeta<TYield, TReturn, TMappedYield = TYield, TMappedReturn = TReturn>(iterator: AsyncIterator<TYield, TReturn>, { mapResult, mapError, ...rest }: WrapAsyncIteratorOptions<TYield, TReturn, TMappedYield, TMappedReturn>): AsyncIteratorClass<TMappedYield, TMappedReturn>;
|
|
@@ -37,6 +37,13 @@ interface ORPCClientOptions<T extends AnyNestedClient> {
|
|
|
37
37
|
*/
|
|
38
38
|
scoped?: ORPCClientScoped<T>;
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Creates a fully typed oRPC client from a link.
|
|
42
|
+
* The returned client mirrors the shape of your router or contract,
|
|
43
|
+
* so calling a procedure is as simple as calling a function.
|
|
44
|
+
*
|
|
45
|
+
* @see {@link https://orpc.dev/docs/client/client-side | Client-Side Clients}
|
|
46
|
+
*/
|
|
40
47
|
declare function createORPCClient<T extends AnyNestedClient>(link: ClientLink<InferClientContext<T>>, { path, ...options }?: NoInfer<ORPCClientOptions<T>>): T;
|
|
41
48
|
|
|
42
49
|
declare function resolveFriendlyClientOptions<T extends ClientContext>(options: FriendlyClientOptions<T>): ClientOptions<T>;
|
|
@@ -68,6 +75,9 @@ type SafeResult<TOutput, TError> = [error: null, data: TOutput, inferableError:
|
|
|
68
75
|
* if (inferableError) {
|
|
69
76
|
* console.log(inferableError) // or error, both are well typed
|
|
70
77
|
* }
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @see {@link https://orpc.dev/docs/client/error-handling#using-safe-and-isinferableerror | Client Error Handling - Using safe and isInferableError}
|
|
71
81
|
*/
|
|
72
82
|
declare function safe<TOutput, TError = ThrowableError>(promise: PromiseWithError<TOutput, TError>): Promise<SafeResult<TOutput, TError>>;
|
|
73
83
|
|
|
@@ -84,7 +94,7 @@ type SafeClient<T extends AnyNestedClient> = T extends Client<infer UContext, in
|
|
|
84
94
|
* // or const [error, data, inferrableError, isSuccess] = await safeClient.doSomething({ id: '123' })
|
|
85
95
|
* ```
|
|
86
96
|
*
|
|
87
|
-
* @see {@link https://orpc.dev/docs/client/error-handling#
|
|
97
|
+
* @see {@link https://orpc.dev/docs/client/error-handling#safe-client | Client Error Handling - Safe Client}
|
|
88
98
|
*/
|
|
89
99
|
declare function createSafeClient<T extends AnyNestedClient>(client: T): SafeClient<T>;
|
|
90
100
|
|
|
@@ -103,7 +113,7 @@ declare const RECURSIVE_CLIENT_UNWRAP_KEYS: Set<string>;
|
|
|
103
113
|
* DynamicLink provides a way to dynamically resolve and delegate calls to other ClientLinks
|
|
104
114
|
* based on the request path, input, and context.
|
|
105
115
|
*
|
|
106
|
-
* @see {@link https://orpc.dev/docs/client/dynamic-link
|
|
116
|
+
* @see {@link https://orpc.dev/docs/client/dynamic-link | DynamicLink}
|
|
107
117
|
*/
|
|
108
118
|
declare class DynamicLink<TClientContext extends ClientContext> implements ClientLink<TClientContext> {
|
|
109
119
|
private readonly linkResolver;
|
|
@@ -111,11 +121,17 @@ declare class DynamicLink<TClientContext extends ClientContext> implements Clien
|
|
|
111
121
|
call(path: string[], input: unknown, options: ClientOptions<TClientContext>): Promise<unknown>;
|
|
112
122
|
}
|
|
113
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Checks if an error is an `ORPCError` whose type is inferable at the TypeScript level,
|
|
126
|
+
* narrowing it so `code` and `data` are fully typed.
|
|
127
|
+
*
|
|
128
|
+
* @see {@link https://orpc.dev/docs/client/error-handling#using-safe-and-isinferableerror | Client Error Handling - Using safe and isInferableError}
|
|
129
|
+
*/
|
|
114
130
|
declare function isInferableError<T>(error: T): error is Extract<T, AnyORPCError>;
|
|
115
131
|
declare function toORPCError<T>(error: T): Extract<T, AnyORPCError> | ORPCError<'INTERNAL_SERVER_ERROR', undefined>;
|
|
116
132
|
declare function isORPCErrorJson(json: unknown): json is ORPCErrorJSON<ORPCErrorCode, unknown>;
|
|
117
133
|
declare function createORPCErrorFromJson<TCode extends ORPCErrorCode, TData>(json: ORPCErrorJSON<TCode, TData>, options?: ErrorOptions): ORPCError<TCode, TData>;
|
|
118
134
|
declare function cloneORPCError<T extends ORPCErrorCode, TData>(error: ORPCError<T, TData>): ORPCError<T, TData>;
|
|
119
135
|
|
|
120
|
-
export { AnyNestedClient, AnyORPCError, Client, ClientContext, ClientLink, ClientOptions, ClientRest, DynamicLink, FriendlyClientOptions, InferClientContext, InferClientError, ORPCError, ORPCErrorCode, ORPCErrorJSON, RECURSIVE_CLIENT_UNWRAP_KEYS, cloneORPCError, createORPCClient, createORPCErrorFromJson, createSafeClient, isInferableError as isDefinedError, isInferableError, isORPCErrorJson, resolveClientRest, resolveFriendlyClientOptions, safe, toORPCError, wrapAsyncIteratorPreservingEventMeta };
|
|
136
|
+
export { AnyNestedClient, AnyORPCError, Client, ClientContext, ClientLink, ClientOptions, ClientRest, DynamicLink, FriendlyClientOptions, InferClientContext, InferClientError, InferClientError as InferClientErrorUnion, ORPCError, ORPCErrorCode, ORPCErrorJSON, RECURSIVE_CLIENT_UNWRAP_KEYS, cloneORPCError, createORPCClient, createORPCErrorFromJson, createSafeClient, isInferableError as isDefinedError, isInferableError, isORPCErrorJson, resolveClientRest, resolveFriendlyClientOptions, safe, toORPCError, wrapAsyncIteratorPreservingEventMeta };
|
|
121
137
|
export type { ORPCClientInterceptor, ORPCClientInterceptorOptions, ORPCClientOptions, ORPCClientScoped, ORPCClientScopedOptions, SafeClient, SafeResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { WrapAsyncIteratorOptions, AsyncIteratorClass, Interceptor, PromiseWithError, ThrowableError, Promisable } from '@orpc/shared';
|
|
2
|
-
export { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, 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 ORPCError, h as ORPCErrorJSON } 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, N as NestedClient, p as ORPCErrorOptions } from './shared/client.
|
|
5
|
-
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.
|
|
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 ORPCError, h as ORPCErrorJSON } from './shared/client.EMUKnkap.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, N as NestedClient, p as ORPCErrorOptions } from './shared/client.EMUKnkap.js';
|
|
5
|
+
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.B8tCfDzm.js';
|
|
6
6
|
export { ErrorEvent, EventMeta, getEventMeta, unwrapEvent, withEventMeta } from '@standardserver/core';
|
|
7
7
|
|
|
8
8
|
declare function wrapAsyncIteratorPreservingEventMeta<TYield, TReturn, TMappedYield = TYield, TMappedReturn = TReturn>(iterator: AsyncIterator<TYield, TReturn>, { mapResult, mapError, ...rest }: WrapAsyncIteratorOptions<TYield, TReturn, TMappedYield, TMappedReturn>): AsyncIteratorClass<TMappedYield, TMappedReturn>;
|
|
@@ -37,6 +37,13 @@ interface ORPCClientOptions<T extends AnyNestedClient> {
|
|
|
37
37
|
*/
|
|
38
38
|
scoped?: ORPCClientScoped<T>;
|
|
39
39
|
}
|
|
40
|
+
/**
|
|
41
|
+
* Creates a fully typed oRPC client from a link.
|
|
42
|
+
* The returned client mirrors the shape of your router or contract,
|
|
43
|
+
* so calling a procedure is as simple as calling a function.
|
|
44
|
+
*
|
|
45
|
+
* @see {@link https://orpc.dev/docs/client/client-side | Client-Side Clients}
|
|
46
|
+
*/
|
|
40
47
|
declare function createORPCClient<T extends AnyNestedClient>(link: ClientLink<InferClientContext<T>>, { path, ...options }?: NoInfer<ORPCClientOptions<T>>): T;
|
|
41
48
|
|
|
42
49
|
declare function resolveFriendlyClientOptions<T extends ClientContext>(options: FriendlyClientOptions<T>): ClientOptions<T>;
|
|
@@ -68,6 +75,9 @@ type SafeResult<TOutput, TError> = [error: null, data: TOutput, inferableError:
|
|
|
68
75
|
* if (inferableError) {
|
|
69
76
|
* console.log(inferableError) // or error, both are well typed
|
|
70
77
|
* }
|
|
78
|
+
* ```
|
|
79
|
+
*
|
|
80
|
+
* @see {@link https://orpc.dev/docs/client/error-handling#using-safe-and-isinferableerror | Client Error Handling - Using safe and isInferableError}
|
|
71
81
|
*/
|
|
72
82
|
declare function safe<TOutput, TError = ThrowableError>(promise: PromiseWithError<TOutput, TError>): Promise<SafeResult<TOutput, TError>>;
|
|
73
83
|
|
|
@@ -84,7 +94,7 @@ type SafeClient<T extends AnyNestedClient> = T extends Client<infer UContext, in
|
|
|
84
94
|
* // or const [error, data, inferrableError, isSuccess] = await safeClient.doSomething({ id: '123' })
|
|
85
95
|
* ```
|
|
86
96
|
*
|
|
87
|
-
* @see {@link https://orpc.dev/docs/client/error-handling#
|
|
97
|
+
* @see {@link https://orpc.dev/docs/client/error-handling#safe-client | Client Error Handling - Safe Client}
|
|
88
98
|
*/
|
|
89
99
|
declare function createSafeClient<T extends AnyNestedClient>(client: T): SafeClient<T>;
|
|
90
100
|
|
|
@@ -103,7 +113,7 @@ declare const RECURSIVE_CLIENT_UNWRAP_KEYS: Set<string>;
|
|
|
103
113
|
* DynamicLink provides a way to dynamically resolve and delegate calls to other ClientLinks
|
|
104
114
|
* based on the request path, input, and context.
|
|
105
115
|
*
|
|
106
|
-
* @see {@link https://orpc.dev/docs/client/dynamic-link
|
|
116
|
+
* @see {@link https://orpc.dev/docs/client/dynamic-link | DynamicLink}
|
|
107
117
|
*/
|
|
108
118
|
declare class DynamicLink<TClientContext extends ClientContext> implements ClientLink<TClientContext> {
|
|
109
119
|
private readonly linkResolver;
|
|
@@ -111,11 +121,17 @@ declare class DynamicLink<TClientContext extends ClientContext> implements Clien
|
|
|
111
121
|
call(path: string[], input: unknown, options: ClientOptions<TClientContext>): Promise<unknown>;
|
|
112
122
|
}
|
|
113
123
|
|
|
124
|
+
/**
|
|
125
|
+
* Checks if an error is an `ORPCError` whose type is inferable at the TypeScript level,
|
|
126
|
+
* narrowing it so `code` and `data` are fully typed.
|
|
127
|
+
*
|
|
128
|
+
* @see {@link https://orpc.dev/docs/client/error-handling#using-safe-and-isinferableerror | Client Error Handling - Using safe and isInferableError}
|
|
129
|
+
*/
|
|
114
130
|
declare function isInferableError<T>(error: T): error is Extract<T, AnyORPCError>;
|
|
115
131
|
declare function toORPCError<T>(error: T): Extract<T, AnyORPCError> | ORPCError<'INTERNAL_SERVER_ERROR', undefined>;
|
|
116
132
|
declare function isORPCErrorJson(json: unknown): json is ORPCErrorJSON<ORPCErrorCode, unknown>;
|
|
117
133
|
declare function createORPCErrorFromJson<TCode extends ORPCErrorCode, TData>(json: ORPCErrorJSON<TCode, TData>, options?: ErrorOptions): ORPCError<TCode, TData>;
|
|
118
134
|
declare function cloneORPCError<T extends ORPCErrorCode, TData>(error: ORPCError<T, TData>): ORPCError<T, TData>;
|
|
119
135
|
|
|
120
|
-
export { AnyNestedClient, AnyORPCError, Client, ClientContext, ClientLink, ClientOptions, ClientRest, DynamicLink, FriendlyClientOptions, InferClientContext, InferClientError, ORPCError, ORPCErrorCode, ORPCErrorJSON, RECURSIVE_CLIENT_UNWRAP_KEYS, cloneORPCError, createORPCClient, createORPCErrorFromJson, createSafeClient, isInferableError as isDefinedError, isInferableError, isORPCErrorJson, resolveClientRest, resolveFriendlyClientOptions, safe, toORPCError, wrapAsyncIteratorPreservingEventMeta };
|
|
136
|
+
export { AnyNestedClient, AnyORPCError, Client, ClientContext, ClientLink, ClientOptions, ClientRest, DynamicLink, FriendlyClientOptions, InferClientContext, InferClientError, InferClientError as InferClientErrorUnion, ORPCError, ORPCErrorCode, ORPCErrorJSON, RECURSIVE_CLIENT_UNWRAP_KEYS, cloneORPCError, createORPCClient, createORPCErrorFromJson, createSafeClient, isInferableError as isDefinedError, isInferableError, isORPCErrorJson, resolveClientRest, resolveFriendlyClientOptions, safe, toORPCError, wrapAsyncIteratorPreservingEventMeta };
|
|
121
137
|
export type { ORPCClientInterceptor, ORPCClientInterceptorOptions, ORPCClientOptions, ORPCClientScoped, ORPCClientScopedOptions, SafeClient, SafeResult };
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as isInferableError } from './shared/client.
|
|
2
|
-
export { b as RPCJsonSerializer, R as RPCSerializer, d as cloneORPCError, c as createORPCErrorFromJson, i as isORPCErrorJson, t as toORPCError, w as wrapAsyncIteratorPreservingEventMeta } from './shared/client.
|
|
3
|
-
import {
|
|
1
|
+
import { a as isInferableError } from './shared/client.BZMJyvQd.mjs';
|
|
2
|
+
export { b as RPCJsonSerializer, R as RPCSerializer, d as cloneORPCError, c as createORPCErrorFromJson, i as isORPCErrorJson, t as toORPCError, w as wrapAsyncIteratorPreservingEventMeta } from './shared/client.BZMJyvQd.mjs';
|
|
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, O as ORPCError } from './shared/client.
|
|
5
|
+
export { C as COMMON_ERROR_STATUS_MAP, O as ORPCError } from './shared/client.CPcOxSex.mjs';
|
|
6
6
|
export { ErrorEvent, getEventMeta, unwrapEvent, withEventMeta } from '@standardserver/core';
|
|
7
7
|
|
|
8
8
|
const RECURSIVE_CLIENT_UNWRAP_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -80,30 +80,44 @@ function createORPCClient(link, { path = [], ...options } = {}) {
|
|
|
80
80
|
({ path: path2, input: input2, ...callOptions2 }) => link.call(path2, input2, callOptions2)
|
|
81
81
|
);
|
|
82
82
|
};
|
|
83
|
+
const cache = /* @__PURE__ */ new Map();
|
|
83
84
|
const recursive = new Proxy(procedureClient, {
|
|
84
85
|
get(target, key) {
|
|
85
86
|
if (typeof key !== "string" || RECURSIVE_CLIENT_UNWRAP_KEYS.has(key)) {
|
|
86
|
-
return
|
|
87
|
+
return Reflect.get(target, key);
|
|
87
88
|
}
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
let client = cache.get(key);
|
|
90
|
+
if (client === void 0) {
|
|
91
|
+
client = createORPCClient(link, {
|
|
92
|
+
...options,
|
|
93
|
+
path: [...path, key],
|
|
94
|
+
scoped: options.scoped?.[key]
|
|
95
|
+
});
|
|
96
|
+
cache.set(key, client);
|
|
97
|
+
}
|
|
98
|
+
return client;
|
|
94
99
|
}
|
|
95
100
|
});
|
|
96
101
|
return recursive;
|
|
97
102
|
}
|
|
98
103
|
|
|
99
104
|
function createSafeClient(client) {
|
|
105
|
+
const cache = /* @__PURE__ */ new Map();
|
|
100
106
|
const proxy = new Proxy((...args) => safe(client(...args)), {
|
|
101
|
-
get(
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
107
|
+
get(target, prop) {
|
|
108
|
+
if (typeof prop !== "string" || RECURSIVE_CLIENT_UNWRAP_KEYS.has(prop)) {
|
|
109
|
+
return Reflect.get(target, prop);
|
|
110
|
+
}
|
|
111
|
+
let safeClient = cache.get(prop);
|
|
112
|
+
if (safeClient === void 0) {
|
|
113
|
+
const value = client[prop];
|
|
114
|
+
if (!isTypescriptObject(value)) {
|
|
115
|
+
return value;
|
|
116
|
+
}
|
|
117
|
+
safeClient = createSafeClient(value);
|
|
118
|
+
cache.set(prop, safeClient);
|
|
105
119
|
}
|
|
106
|
-
return
|
|
120
|
+
return safeClient;
|
|
107
121
|
}
|
|
108
122
|
});
|
|
109
123
|
return proxy;
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Value, Promisable } from '@orpc/shared';
|
|
2
2
|
import { StandardUrl, StandardHeaders, StandardRequest, StandardLazyResponse } from '@standardserver/core';
|
|
3
|
-
import { C as ClientContext } from '../shared/client.
|
|
4
|
-
import { c as StandardLinkPlugin, d as StandardLinkTransportInterceptorOptions, b as StandardLinkOptions, e as StandardLinkInterceptorOptions } from '../shared/client.
|
|
3
|
+
import { C as ClientContext } from '../shared/client.EMUKnkap.mjs';
|
|
4
|
+
import { c as StandardLinkPlugin, d as StandardLinkTransportInterceptorOptions, b as StandardLinkOptions, e as StandardLinkInterceptorOptions } from '../shared/client.BpRn9TAI.mjs';
|
|
5
5
|
|
|
6
6
|
type BatchLinkPluginMode = 'streaming' | 'buffered';
|
|
7
7
|
interface BatchLinkPluginGroup<T extends ClientContext> {
|
|
@@ -79,6 +79,15 @@ interface BatchLinkPluginOptions<T extends ClientContext> {
|
|
|
79
79
|
*/
|
|
80
80
|
mapSubresponse?: (subResponse: StandardLazyResponse, batchResponse: StandardLazyResponse, subOptions: StandardLinkTransportInterceptorOptions<T>) => StandardLazyResponse;
|
|
81
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Combines multiple client requests into a single batch request
|
|
84
|
+
* and splits the batch response back into individual responses.
|
|
85
|
+
*
|
|
86
|
+
* @remarks
|
|
87
|
+
* **Note**: HTTP/2 and later already multiplex requests over a single connection, so this plugin is often less useful than it once was.
|
|
88
|
+
*
|
|
89
|
+
* @see {@link https://orpc.dev/docs/plugins/batch | Batch Plugin}
|
|
90
|
+
*/
|
|
82
91
|
declare class BatchLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
83
92
|
name: string;
|
|
84
93
|
private readonly groups;
|
|
@@ -123,6 +132,12 @@ interface DedupeLinkPluginOptions<T extends ClientContext> {
|
|
|
123
132
|
*/
|
|
124
133
|
filter?: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]>;
|
|
125
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Prevents redundant requests by deduplicating similar in-flight requests,
|
|
137
|
+
* reducing the number of requests sent to the server.
|
|
138
|
+
*
|
|
139
|
+
* @see {@link https://orpc.dev/docs/plugins/dedupe | Dedupe Plugin}
|
|
140
|
+
*/
|
|
126
141
|
declare class DedupeLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
127
142
|
name: string;
|
|
128
143
|
before: string[];
|
|
@@ -152,6 +167,12 @@ interface RequestCompressionLinkPluginOptions<_T extends ClientContext> {
|
|
|
152
167
|
*/
|
|
153
168
|
threshold?: number;
|
|
154
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Compresses request bodies before sending them to the server,
|
|
172
|
+
* reducing bandwidth usage for large payloads.
|
|
173
|
+
*
|
|
174
|
+
* @see {@link https://orpc.dev/docs/plugins/request-compression | Request Compression Plugin}
|
|
175
|
+
*/
|
|
155
176
|
declare class RequestCompressionLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
156
177
|
name: string;
|
|
157
178
|
/**
|
|
@@ -178,7 +199,7 @@ interface ResponseCompressionLinkPluginOptions<_T extends ClientContext> {
|
|
|
178
199
|
* based on the Content-Encoding header. Works at the standard link level,
|
|
179
200
|
* so it supports all adapters.
|
|
180
201
|
*
|
|
181
|
-
* @see {@link https://orpc.dev/docs/plugins/response-compression Response Compression Plugin
|
|
202
|
+
* @see {@link https://orpc.dev/docs/plugins/response-compression | Response Compression Plugin}
|
|
182
203
|
*/
|
|
183
204
|
declare class ResponseCompressionLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
184
205
|
name: string;
|
|
@@ -205,6 +226,12 @@ interface RetryLinkPluginAttemptOptions<T extends RetryLinkPluginContext> extend
|
|
|
205
226
|
*/
|
|
206
227
|
error: unknown;
|
|
207
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* Client context options that control retry behavior per call
|
|
231
|
+
* when the `RetryLinkPlugin` is enabled.
|
|
232
|
+
*
|
|
233
|
+
* @see {@link https://orpc.dev/docs/plugins/retry | Retry Plugin}
|
|
234
|
+
*/
|
|
208
235
|
interface RetryLinkPluginContext {
|
|
209
236
|
/**
|
|
210
237
|
* Maximum retry attempts before throwing.
|
|
@@ -216,7 +243,9 @@ interface RetryLinkPluginContext {
|
|
|
216
243
|
/**
|
|
217
244
|
* Delay (in ms) before retrying.
|
|
218
245
|
*
|
|
219
|
-
* @
|
|
246
|
+
* @remarks
|
|
247
|
+
* **Note**: Why 2000ms? The EventSource spec suggests a default retry delay of 2 seconds if it doesn't specify
|
|
248
|
+
*
|
|
220
249
|
* @default (o) => o.lastEventRetry ?? 2000
|
|
221
250
|
*/
|
|
222
251
|
retryDelay?: Value<Promisable<number>, [RetryLinkPluginAttemptOptions<RetryLinkPluginContext>]>;
|
|
@@ -237,6 +266,15 @@ interface RetryLinkPluginOptions<_T extends RetryLinkPluginContext> {
|
|
|
237
266
|
*/
|
|
238
267
|
default?: RetryLinkPluginContext | undefined;
|
|
239
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* Automatically retries failed requests based on customizable retry strategies,
|
|
271
|
+
* improving the resilience of your application.
|
|
272
|
+
*
|
|
273
|
+
* @remarks
|
|
274
|
+
* **Note**: Retry behavior is configured through the client context on each call.
|
|
275
|
+
*
|
|
276
|
+
* @see {@link https://orpc.dev/docs/plugins/retry | Retry Plugin}
|
|
277
|
+
*/
|
|
240
278
|
declare class RetryLinkPlugin<T extends RetryLinkPluginContext & ClientContext> implements StandardLinkPlugin<T> {
|
|
241
279
|
private readonly defaultRetry;
|
|
242
280
|
private readonly defaultRetryDelay;
|
|
@@ -280,7 +318,7 @@ interface RetryAfterLinkPluginOptions<T extends ClientContext> {
|
|
|
280
318
|
* The Retry After Link Plugin automatically retries requests based on server `retry-after` header.
|
|
281
319
|
* This is particularly useful for handling rate limiting and temporary server unavailability.
|
|
282
320
|
*
|
|
283
|
-
* @see {@link https://orpc.dev/docs/plugins/retry-after Retry After Plugin
|
|
321
|
+
* @see {@link https://orpc.dev/docs/plugins/retry-after | Retry After Plugin}
|
|
284
322
|
*/
|
|
285
323
|
declare class RetryAfterLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
286
324
|
private readonly condition;
|
|
@@ -301,7 +339,7 @@ interface TimeoutLinkPluginOptions<T extends ClientContext> {
|
|
|
301
339
|
/**
|
|
302
340
|
* The Timeout Link Plugin aborts requests that exceed a configured timeout with an `AbortError`.
|
|
303
341
|
*
|
|
304
|
-
* @see {@link https://orpc.dev/docs/plugins/timeout Timeout Plugin
|
|
342
|
+
* @see {@link https://orpc.dev/docs/plugins/timeout | Timeout Plugin}
|
|
305
343
|
*/
|
|
306
344
|
declare class TimeoutLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
307
345
|
private readonly timeout;
|
|
@@ -314,5 +352,5 @@ declare class TimeoutLinkPlugin<T extends ClientContext> implements StandardLink
|
|
|
314
352
|
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
315
353
|
}
|
|
316
354
|
|
|
317
|
-
export { BatchLinkPlugin, BatchLinkPluginError, DedupeLinkPlugin, RequestCompressionLinkPlugin, ResponseCompressionLinkPlugin, RetryAfterLinkPlugin, RetryLinkPlugin, TimeoutLinkPlugin };
|
|
318
|
-
export type { BatchLinkPluginGroup, BatchLinkPluginMode, BatchLinkPluginOptions, DedupeLinkPluginGroup, DedupeLinkPluginOptions, RequestCompressionLinkPluginOptions, ResponseCompressionLinkPluginOptions, RetryAfterLinkPluginOptions, RetryLinkPluginAttemptOptions, RetryLinkPluginContext, RetryLinkPluginOptions, TimeoutLinkPluginOptions };
|
|
355
|
+
export { BatchLinkPlugin, BatchLinkPluginError, RetryLinkPlugin as ClientRetryPlugin, DedupeLinkPlugin, DedupeLinkPlugin as DedupeRequestsPlugin, RequestCompressionLinkPlugin, ResponseCompressionLinkPlugin, RetryAfterLinkPlugin, RetryAfterLinkPlugin as RetryAfterPlugin, RetryLinkPlugin, TimeoutLinkPlugin };
|
|
356
|
+
export type { BatchLinkPluginGroup, BatchLinkPluginMode, BatchLinkPluginOptions, RetryLinkPluginContext as ClientRetryPluginContext, DedupeLinkPluginGroup, DedupeLinkPluginOptions, RequestCompressionLinkPluginOptions, ResponseCompressionLinkPluginOptions, RetryAfterLinkPluginOptions, RetryLinkPluginAttemptOptions, RetryLinkPluginContext, RetryLinkPluginOptions, TimeoutLinkPluginOptions };
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Value, Promisable } from '@orpc/shared';
|
|
2
2
|
import { StandardUrl, StandardHeaders, StandardRequest, StandardLazyResponse } from '@standardserver/core';
|
|
3
|
-
import { C as ClientContext } from '../shared/client.
|
|
4
|
-
import { c as StandardLinkPlugin, d as StandardLinkTransportInterceptorOptions, b as StandardLinkOptions, e as StandardLinkInterceptorOptions } from '../shared/client.
|
|
3
|
+
import { C as ClientContext } from '../shared/client.EMUKnkap.js';
|
|
4
|
+
import { c as StandardLinkPlugin, d as StandardLinkTransportInterceptorOptions, b as StandardLinkOptions, e as StandardLinkInterceptorOptions } from '../shared/client.BGShxYPR.js';
|
|
5
5
|
|
|
6
6
|
type BatchLinkPluginMode = 'streaming' | 'buffered';
|
|
7
7
|
interface BatchLinkPluginGroup<T extends ClientContext> {
|
|
@@ -79,6 +79,15 @@ interface BatchLinkPluginOptions<T extends ClientContext> {
|
|
|
79
79
|
*/
|
|
80
80
|
mapSubresponse?: (subResponse: StandardLazyResponse, batchResponse: StandardLazyResponse, subOptions: StandardLinkTransportInterceptorOptions<T>) => StandardLazyResponse;
|
|
81
81
|
}
|
|
82
|
+
/**
|
|
83
|
+
* Combines multiple client requests into a single batch request
|
|
84
|
+
* and splits the batch response back into individual responses.
|
|
85
|
+
*
|
|
86
|
+
* @remarks
|
|
87
|
+
* **Note**: HTTP/2 and later already multiplex requests over a single connection, so this plugin is often less useful than it once was.
|
|
88
|
+
*
|
|
89
|
+
* @see {@link https://orpc.dev/docs/plugins/batch | Batch Plugin}
|
|
90
|
+
*/
|
|
82
91
|
declare class BatchLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
83
92
|
name: string;
|
|
84
93
|
private readonly groups;
|
|
@@ -123,6 +132,12 @@ interface DedupeLinkPluginOptions<T extends ClientContext> {
|
|
|
123
132
|
*/
|
|
124
133
|
filter?: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]>;
|
|
125
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Prevents redundant requests by deduplicating similar in-flight requests,
|
|
137
|
+
* reducing the number of requests sent to the server.
|
|
138
|
+
*
|
|
139
|
+
* @see {@link https://orpc.dev/docs/plugins/dedupe | Dedupe Plugin}
|
|
140
|
+
*/
|
|
126
141
|
declare class DedupeLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
127
142
|
name: string;
|
|
128
143
|
before: string[];
|
|
@@ -152,6 +167,12 @@ interface RequestCompressionLinkPluginOptions<_T extends ClientContext> {
|
|
|
152
167
|
*/
|
|
153
168
|
threshold?: number;
|
|
154
169
|
}
|
|
170
|
+
/**
|
|
171
|
+
* Compresses request bodies before sending them to the server,
|
|
172
|
+
* reducing bandwidth usage for large payloads.
|
|
173
|
+
*
|
|
174
|
+
* @see {@link https://orpc.dev/docs/plugins/request-compression | Request Compression Plugin}
|
|
175
|
+
*/
|
|
155
176
|
declare class RequestCompressionLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
156
177
|
name: string;
|
|
157
178
|
/**
|
|
@@ -178,7 +199,7 @@ interface ResponseCompressionLinkPluginOptions<_T extends ClientContext> {
|
|
|
178
199
|
* based on the Content-Encoding header. Works at the standard link level,
|
|
179
200
|
* so it supports all adapters.
|
|
180
201
|
*
|
|
181
|
-
* @see {@link https://orpc.dev/docs/plugins/response-compression Response Compression Plugin
|
|
202
|
+
* @see {@link https://orpc.dev/docs/plugins/response-compression | Response Compression Plugin}
|
|
182
203
|
*/
|
|
183
204
|
declare class ResponseCompressionLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
184
205
|
name: string;
|
|
@@ -205,6 +226,12 @@ interface RetryLinkPluginAttemptOptions<T extends RetryLinkPluginContext> extend
|
|
|
205
226
|
*/
|
|
206
227
|
error: unknown;
|
|
207
228
|
}
|
|
229
|
+
/**
|
|
230
|
+
* Client context options that control retry behavior per call
|
|
231
|
+
* when the `RetryLinkPlugin` is enabled.
|
|
232
|
+
*
|
|
233
|
+
* @see {@link https://orpc.dev/docs/plugins/retry | Retry Plugin}
|
|
234
|
+
*/
|
|
208
235
|
interface RetryLinkPluginContext {
|
|
209
236
|
/**
|
|
210
237
|
* Maximum retry attempts before throwing.
|
|
@@ -216,7 +243,9 @@ interface RetryLinkPluginContext {
|
|
|
216
243
|
/**
|
|
217
244
|
* Delay (in ms) before retrying.
|
|
218
245
|
*
|
|
219
|
-
* @
|
|
246
|
+
* @remarks
|
|
247
|
+
* **Note**: Why 2000ms? The EventSource spec suggests a default retry delay of 2 seconds if it doesn't specify
|
|
248
|
+
*
|
|
220
249
|
* @default (o) => o.lastEventRetry ?? 2000
|
|
221
250
|
*/
|
|
222
251
|
retryDelay?: Value<Promisable<number>, [RetryLinkPluginAttemptOptions<RetryLinkPluginContext>]>;
|
|
@@ -237,6 +266,15 @@ interface RetryLinkPluginOptions<_T extends RetryLinkPluginContext> {
|
|
|
237
266
|
*/
|
|
238
267
|
default?: RetryLinkPluginContext | undefined;
|
|
239
268
|
}
|
|
269
|
+
/**
|
|
270
|
+
* Automatically retries failed requests based on customizable retry strategies,
|
|
271
|
+
* improving the resilience of your application.
|
|
272
|
+
*
|
|
273
|
+
* @remarks
|
|
274
|
+
* **Note**: Retry behavior is configured through the client context on each call.
|
|
275
|
+
*
|
|
276
|
+
* @see {@link https://orpc.dev/docs/plugins/retry | Retry Plugin}
|
|
277
|
+
*/
|
|
240
278
|
declare class RetryLinkPlugin<T extends RetryLinkPluginContext & ClientContext> implements StandardLinkPlugin<T> {
|
|
241
279
|
private readonly defaultRetry;
|
|
242
280
|
private readonly defaultRetryDelay;
|
|
@@ -280,7 +318,7 @@ interface RetryAfterLinkPluginOptions<T extends ClientContext> {
|
|
|
280
318
|
* The Retry After Link Plugin automatically retries requests based on server `retry-after` header.
|
|
281
319
|
* This is particularly useful for handling rate limiting and temporary server unavailability.
|
|
282
320
|
*
|
|
283
|
-
* @see {@link https://orpc.dev/docs/plugins/retry-after Retry After Plugin
|
|
321
|
+
* @see {@link https://orpc.dev/docs/plugins/retry-after | Retry After Plugin}
|
|
284
322
|
*/
|
|
285
323
|
declare class RetryAfterLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
286
324
|
private readonly condition;
|
|
@@ -301,7 +339,7 @@ interface TimeoutLinkPluginOptions<T extends ClientContext> {
|
|
|
301
339
|
/**
|
|
302
340
|
* The Timeout Link Plugin aborts requests that exceed a configured timeout with an `AbortError`.
|
|
303
341
|
*
|
|
304
|
-
* @see {@link https://orpc.dev/docs/plugins/timeout Timeout Plugin
|
|
342
|
+
* @see {@link https://orpc.dev/docs/plugins/timeout | Timeout Plugin}
|
|
305
343
|
*/
|
|
306
344
|
declare class TimeoutLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
307
345
|
private readonly timeout;
|
|
@@ -314,5 +352,5 @@ declare class TimeoutLinkPlugin<T extends ClientContext> implements StandardLink
|
|
|
314
352
|
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
315
353
|
}
|
|
316
354
|
|
|
317
|
-
export { BatchLinkPlugin, BatchLinkPluginError, DedupeLinkPlugin, RequestCompressionLinkPlugin, ResponseCompressionLinkPlugin, RetryAfterLinkPlugin, RetryLinkPlugin, TimeoutLinkPlugin };
|
|
318
|
-
export type { BatchLinkPluginGroup, BatchLinkPluginMode, BatchLinkPluginOptions, DedupeLinkPluginGroup, DedupeLinkPluginOptions, RequestCompressionLinkPluginOptions, ResponseCompressionLinkPluginOptions, RetryAfterLinkPluginOptions, RetryLinkPluginAttemptOptions, RetryLinkPluginContext, RetryLinkPluginOptions, TimeoutLinkPluginOptions };
|
|
355
|
+
export { BatchLinkPlugin, BatchLinkPluginError, RetryLinkPlugin as ClientRetryPlugin, DedupeLinkPlugin, DedupeLinkPlugin as DedupeRequestsPlugin, RequestCompressionLinkPlugin, ResponseCompressionLinkPlugin, RetryAfterLinkPlugin, RetryAfterLinkPlugin as RetryAfterPlugin, RetryLinkPlugin, TimeoutLinkPlugin };
|
|
356
|
+
export type { BatchLinkPluginGroup, BatchLinkPluginMode, BatchLinkPluginOptions, RetryLinkPluginContext as ClientRetryPluginContext, DedupeLinkPluginGroup, DedupeLinkPluginOptions, RequestCompressionLinkPluginOptions, ResponseCompressionLinkPluginOptions, RetryAfterLinkPluginOptions, RetryLinkPluginAttemptOptions, RetryLinkPluginContext, RetryLinkPluginOptions, TimeoutLinkPluginOptions };
|
package/dist/plugins/index.mjs
CHANGED
|
@@ -2,7 +2,7 @@ import { toArray, value, splitInHalf, stringifyJSON, isAsyncIteratorObject, defe
|
|
|
2
2
|
import { parseStandardUrl, flattenStandardHeader, generateContentDisposition, getEventMeta } from '@standardserver/core';
|
|
3
3
|
import { ClientPeer, isServerPeerSendMessage, decodePeerMessage } from '@standardserver/peer';
|
|
4
4
|
import { toFetchHeaders, toStandardBody } from '@standardserver/fetch';
|
|
5
|
-
import { C as COMMON_ERROR_STATUS_MAP } from '../shared/client.
|
|
5
|
+
import { C as COMMON_ERROR_STATUS_MAP } from '../shared/client.CPcOxSex.mjs';
|
|
6
6
|
|
|
7
7
|
class BatchLinkPluginError extends TypeError {
|
|
8
8
|
}
|
|
@@ -828,4 +828,4 @@ class TimeoutLinkPlugin {
|
|
|
828
828
|
}
|
|
829
829
|
}
|
|
830
830
|
|
|
831
|
-
export { BatchLinkPlugin, BatchLinkPluginError, DedupeLinkPlugin, RequestCompressionLinkPlugin, ResponseCompressionLinkPlugin, RetryAfterLinkPlugin, RetryLinkPlugin, TimeoutLinkPlugin };
|
|
831
|
+
export { BatchLinkPlugin, BatchLinkPluginError, RetryLinkPlugin as ClientRetryPlugin, DedupeLinkPlugin, DedupeLinkPlugin as DedupeRequestsPlugin, RequestCompressionLinkPlugin, ResponseCompressionLinkPlugin, RetryAfterLinkPlugin, RetryAfterLinkPlugin as RetryAfterPlugin, RetryLinkPlugin, TimeoutLinkPlugin };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { sortPlugins, runWithSpan, ORPC_NAME, isAsyncIteratorObject, override, traceAsyncIterator, intercept, getOpenTelemetryConfig, value, pathToHttpPath, stringifyJSON } from '@orpc/shared';
|
|
2
2
|
import { mergeStandardHeaders, parseStandardUrl } from '@standardserver/core';
|
|
3
3
|
import { toStandardHeaders } from '@standardserver/fetch';
|
|
4
|
-
import { O as ORPCError } from './client.
|
|
5
|
-
import { R as RPCSerializer, i as isORPCErrorJson, c as createORPCErrorFromJson } from './client.
|
|
4
|
+
import { O as ORPCError } from './client.CPcOxSex.mjs';
|
|
5
|
+
import { R as RPCSerializer, i as isORPCErrorJson, c as createORPCErrorFromJson } from './client.BZMJyvQd.mjs';
|
|
6
6
|
|
|
7
7
|
class CompositeStandardLinkPlugin {
|
|
8
8
|
name = "~composite";
|
|
@@ -103,6 +103,12 @@ interface RPCSerializerOptions extends RPCJsonSerializerOptions {
|
|
|
103
103
|
*/
|
|
104
104
|
serialize?: RPCSerializerSerializeOptions | undefined;
|
|
105
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Serializes and deserializes data for the RPC protocol,
|
|
108
|
+
* preserving native types like Date, BigInt, Set, and Map that plain JSON cannot represent.
|
|
109
|
+
*
|
|
110
|
+
* @see {@link https://orpc.dev/docs/rpc/serializer | RPC Serializer}
|
|
111
|
+
*/
|
|
106
112
|
declare class RPCSerializer {
|
|
107
113
|
private readonly jsonSerializer;
|
|
108
114
|
private readonly defaultSerializeOptions;
|
|
@@ -103,6 +103,12 @@ interface RPCSerializerOptions extends RPCJsonSerializerOptions {
|
|
|
103
103
|
*/
|
|
104
104
|
serialize?: RPCSerializerSerializeOptions | undefined;
|
|
105
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* Serializes and deserializes data for the RPC protocol,
|
|
108
|
+
* preserving native types like Date, BigInt, Set, and Map that plain JSON cannot represent.
|
|
109
|
+
*
|
|
110
|
+
* @see {@link https://orpc.dev/docs/rpc/serializer | RPC Serializer}
|
|
111
|
+
*/
|
|
106
112
|
declare class RPCSerializer {
|
|
107
113
|
private readonly jsonSerializer;
|
|
108
114
|
private readonly defaultSerializeOptions;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Promisable, OrderablePlugin, Interceptor } from '@orpc/shared';
|
|
2
2
|
import { StandardRequest, StandardLazyResponse } from '@standardserver/core';
|
|
3
|
-
import { C as ClientContext, a as ClientOptions, A as AnyORPCError, b as ClientLink } from './client.
|
|
3
|
+
import { C as ClientContext, a as ClientOptions, A as AnyORPCError, b as ClientLink } from './client.EMUKnkap.js';
|
|
4
4
|
|
|
5
5
|
type StandardLinkCodecDecodedResponse = {
|
|
6
6
|
kind: 'output';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { isPlainObject, wrapAsyncIterator, isTypescriptObject, NullProtoObj, isAsyncIteratorObject, stringifyJSON } from '@orpc/shared';
|
|
2
2
|
import { getEventMeta, withEventMeta, ErrorEvent } from '@standardserver/core';
|
|
3
|
-
import { O as ORPCError } from './client.
|
|
3
|
+
import { O as ORPCError } from './client.CPcOxSex.mjs';
|
|
4
4
|
|
|
5
5
|
function isInferableError(error) {
|
|
6
6
|
return error instanceof ORPCError && error.inferable;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Promisable, OrderablePlugin, Interceptor } from '@orpc/shared';
|
|
2
2
|
import { StandardRequest, StandardLazyResponse } from '@standardserver/core';
|
|
3
|
-
import { C as ClientContext, a as ClientOptions, A as AnyORPCError, b as ClientLink } from './client.
|
|
3
|
+
import { C as ClientContext, a as ClientOptions, A as AnyORPCError, b as ClientLink } from './client.EMUKnkap.mjs';
|
|
4
4
|
|
|
5
5
|
type StandardLinkCodecDecodedResponse = {
|
|
6
6
|
kind: 'output';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { resolveMaybeOptionalOptions,
|
|
1
|
+
import { resolveMaybeOptionalOptions, getConstructors } from '@orpc/shared';
|
|
2
2
|
|
|
3
3
|
const COMMON_ERROR_STATUS_MAP = {
|
|
4
4
|
BAD_REQUEST: 400,
|
|
@@ -33,8 +33,8 @@ class ORPCError extends Error {
|
|
|
33
33
|
ORPCErrorConstructors.add(ORPCError);
|
|
34
34
|
}
|
|
35
35
|
/**
|
|
36
|
-
* @
|
|
37
|
-
* The `__branch` property is used for type branding, helping TypeScript distinguish
|
|
36
|
+
* @remarks
|
|
37
|
+
* **Note**: The `__branch` property is used for type branding, helping TypeScript distinguish
|
|
38
38
|
* an `ORPCError` instance from plain objects with a similar structure.
|
|
39
39
|
*/
|
|
40
40
|
name = "ORPCError";
|
|
@@ -81,11 +81,12 @@ class ORPCError extends Error {
|
|
|
81
81
|
if (!ORPCErrorConstructors.has(this)) {
|
|
82
82
|
return super[Symbol.hasInstance](instance);
|
|
83
83
|
}
|
|
84
|
-
const constructor
|
|
85
|
-
|
|
86
|
-
|
|
84
|
+
for (const constructor of getConstructors(instance)) {
|
|
85
|
+
if (ORPCErrorConstructors.has(constructor)) {
|
|
86
|
+
return true;
|
|
87
|
+
}
|
|
87
88
|
}
|
|
88
|
-
return
|
|
89
|
+
return false;
|
|
89
90
|
}
|
|
90
91
|
}
|
|
91
92
|
|
|
@@ -21,6 +21,11 @@ type NestedClient<TClientContext extends ClientContext> = Client<TClientContext,
|
|
|
21
21
|
[k: string]: NestedClient<TClientContext>;
|
|
22
22
|
};
|
|
23
23
|
type AnyNestedClient = NestedClient<any>;
|
|
24
|
+
/**
|
|
25
|
+
* Infers the **client context type** required by a client.
|
|
26
|
+
*
|
|
27
|
+
* @see {@link https://orpc.dev/docs/client/client-side#infer-client-context | Client-Side Clients - Infer Client Context}
|
|
28
|
+
*/
|
|
24
29
|
type InferClientContext<T extends AnyNestedClient> = T extends NestedClient<infer U> ? U : never;
|
|
25
30
|
interface ClientLink<TClientContext extends ClientContext> {
|
|
26
31
|
call: (path: string[], input: unknown, options: ClientOptions<TClientContext>) => Promise<unknown>;
|
|
@@ -29,6 +34,8 @@ interface ClientLink<TClientContext extends ClientContext> {
|
|
|
29
34
|
* Recursively infers the **input types** from a client.
|
|
30
35
|
*
|
|
31
36
|
* Produces a nested map where each endpoint's input type is preserved.
|
|
37
|
+
*
|
|
38
|
+
* @see {@link https://orpc.dev/docs/client/client-side#infer-client-inputs | Client-Side Clients - Infer Client Inputs}
|
|
32
39
|
*/
|
|
33
40
|
type InferClientInputs<T extends AnyNestedClient> = T extends Client<any, infer U, any, any> ? U : {
|
|
34
41
|
[K in keyof T]: T[K] extends AnyNestedClient ? InferClientInputs<T[K]> : never;
|
|
@@ -38,6 +45,8 @@ type InferClientInputs<T extends AnyNestedClient> = T extends Client<any, infer
|
|
|
38
45
|
*
|
|
39
46
|
* If an endpoint's input includes `{ body: ... }`, only the `body` portion is extracted.
|
|
40
47
|
* Produces a nested map of body input types.
|
|
48
|
+
*
|
|
49
|
+
* @see {@link https://orpc.dev/docs/client/client-side#infer-client-body-inputs | Client-Side Clients - Infer Client Body Inputs}
|
|
41
50
|
*/
|
|
42
51
|
type InferClientBodyInputs<T extends AnyNestedClient> = T extends Client<any, infer U, any, any> ? U extends {
|
|
43
52
|
body: infer UBody;
|
|
@@ -48,6 +57,8 @@ type InferClientBodyInputs<T extends AnyNestedClient> = T extends Client<any, in
|
|
|
48
57
|
* Recursively infers the **output types** from a client.
|
|
49
58
|
*
|
|
50
59
|
* Produces a nested map where each endpoint's output type is preserved.
|
|
60
|
+
*
|
|
61
|
+
* @see {@link https://orpc.dev/docs/client/client-side#infer-client-outputs | Client-Side Clients - Infer Client Outputs}
|
|
51
62
|
*/
|
|
52
63
|
type InferClientOutputs<T extends AnyNestedClient> = T extends Client<any, any, infer U, any> ? U : {
|
|
53
64
|
[K in keyof T]: T[K] extends AnyNestedClient ? InferClientOutputs<T[K]> : never;
|
|
@@ -57,6 +68,8 @@ type InferClientOutputs<T extends AnyNestedClient> = T extends Client<any, any,
|
|
|
57
68
|
*
|
|
58
69
|
* If an endpoint's output includes `{ body: ... }`, only the `body` portion is extracted.
|
|
59
70
|
* Produces a nested map of body output types.
|
|
71
|
+
*
|
|
72
|
+
* @see {@link https://orpc.dev/docs/client/client-side#infer-client-body-outputs | Client-Side Clients - Infer Client Body Outputs}
|
|
60
73
|
*/
|
|
61
74
|
type InferClientBodyOutputs<T extends AnyNestedClient> = T extends Client<any, any, infer U, any> ? U extends {
|
|
62
75
|
body: infer UBody;
|
|
@@ -64,22 +77,33 @@ type InferClientBodyOutputs<T extends AnyNestedClient> = T extends Client<any, a
|
|
|
64
77
|
[K in keyof T]: T[K] extends AnyNestedClient ? InferClientBodyOutputs<T[K]> : never;
|
|
65
78
|
};
|
|
66
79
|
/**
|
|
67
|
-
* Recursively infers the **error types** from a client when you use [type-safe errors](https://orpc.dev/docs/error-handling#
|
|
80
|
+
* Recursively infers the **error types** from a client when you use [type-safe errors](https://orpc.dev/docs/error-handling#typesafe-errors).
|
|
68
81
|
*
|
|
69
82
|
* Produces a nested map where each endpoint's error type is preserved.
|
|
83
|
+
*
|
|
84
|
+
* @see {@link https://orpc.dev/docs/client/client-side#infer-client-errors | Client-Side Clients - Infer Client Errors}
|
|
70
85
|
*/
|
|
71
86
|
type InferClientErrors<T extends AnyNestedClient> = T extends Client<any, any, any, infer U> ? U : {
|
|
72
87
|
[K in keyof T]: T[K] extends AnyNestedClient ? InferClientErrors<T[K]> : never;
|
|
73
88
|
};
|
|
74
89
|
/**
|
|
75
|
-
* Recursively infers a **union of all error types** from a client when you use [type-safe errors](https://orpc.dev/docs/error-handling#
|
|
90
|
+
* Recursively infers a **union of all error types** from a client when you use [type-safe errors](https://orpc.dev/docs/error-handling#typesafe-errors).
|
|
76
91
|
*
|
|
77
92
|
* Useful when you want to handle all possible errors from any endpoint at once.
|
|
93
|
+
*
|
|
94
|
+
* @see {@link https://orpc.dev/docs/client/client-side#infer-client-error | Client-Side Clients - Infer Client Error}
|
|
78
95
|
*/
|
|
79
96
|
type InferClientError<T extends AnyNestedClient> = T extends Client<any, any, any, infer U> ? U : {
|
|
80
97
|
[K in keyof T]: T[K] extends AnyNestedClient ? InferClientError<T[K]> : never;
|
|
81
98
|
}[keyof T];
|
|
82
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Default mapping between common oRPC error codes and HTTP status codes.
|
|
102
|
+
* Handlers use it to determine response status codes; spread it to build a custom `errorStatusMap`.
|
|
103
|
+
*
|
|
104
|
+
* @see {@link https://orpc.dev/docs/rpc/handler#custom-error-response | RPC Handler - Custom Error Response}
|
|
105
|
+
* @see {@link https://orpc.dev/docs/openapi/handler#custom-error-response | OpenAPI Handler - Custom Error Response}
|
|
106
|
+
*/
|
|
83
107
|
declare const COMMON_ERROR_STATUS_MAP: {
|
|
84
108
|
BAD_REQUEST: number;
|
|
85
109
|
UNAUTHORIZED: number;
|
|
@@ -114,10 +138,16 @@ type ORPCErrorOptions<TData> = ErrorOptions & {
|
|
|
114
138
|
} : {
|
|
115
139
|
data: TData;
|
|
116
140
|
});
|
|
141
|
+
/**
|
|
142
|
+
* Typed error carrying a `code`, a `message`, and optional `data`.
|
|
143
|
+
* Throw it from handlers or middleware to produce typed error responses on the client.
|
|
144
|
+
*
|
|
145
|
+
* @see {@link https://orpc.dev/docs/error-handling#orpcerror-class | Error Handling - ORPCError Class}
|
|
146
|
+
*/
|
|
117
147
|
declare class ORPCError<TCode extends ORPCErrorCode, TData> extends Error {
|
|
118
148
|
/**
|
|
119
|
-
* @
|
|
120
|
-
* The `__branch` property is used for type branding, helping TypeScript distinguish
|
|
149
|
+
* @remarks
|
|
150
|
+
* **Note**: The `__branch` property is used for type branding, helping TypeScript distinguish
|
|
121
151
|
* an `ORPCError` instance from plain objects with a similar structure.
|
|
122
152
|
*/
|
|
123
153
|
readonly name: "ORPCError" & {
|
|
@@ -21,6 +21,11 @@ type NestedClient<TClientContext extends ClientContext> = Client<TClientContext,
|
|
|
21
21
|
[k: string]: NestedClient<TClientContext>;
|
|
22
22
|
};
|
|
23
23
|
type AnyNestedClient = NestedClient<any>;
|
|
24
|
+
/**
|
|
25
|
+
* Infers the **client context type** required by a client.
|
|
26
|
+
*
|
|
27
|
+
* @see {@link https://orpc.dev/docs/client/client-side#infer-client-context | Client-Side Clients - Infer Client Context}
|
|
28
|
+
*/
|
|
24
29
|
type InferClientContext<T extends AnyNestedClient> = T extends NestedClient<infer U> ? U : never;
|
|
25
30
|
interface ClientLink<TClientContext extends ClientContext> {
|
|
26
31
|
call: (path: string[], input: unknown, options: ClientOptions<TClientContext>) => Promise<unknown>;
|
|
@@ -29,6 +34,8 @@ interface ClientLink<TClientContext extends ClientContext> {
|
|
|
29
34
|
* Recursively infers the **input types** from a client.
|
|
30
35
|
*
|
|
31
36
|
* Produces a nested map where each endpoint's input type is preserved.
|
|
37
|
+
*
|
|
38
|
+
* @see {@link https://orpc.dev/docs/client/client-side#infer-client-inputs | Client-Side Clients - Infer Client Inputs}
|
|
32
39
|
*/
|
|
33
40
|
type InferClientInputs<T extends AnyNestedClient> = T extends Client<any, infer U, any, any> ? U : {
|
|
34
41
|
[K in keyof T]: T[K] extends AnyNestedClient ? InferClientInputs<T[K]> : never;
|
|
@@ -38,6 +45,8 @@ type InferClientInputs<T extends AnyNestedClient> = T extends Client<any, infer
|
|
|
38
45
|
*
|
|
39
46
|
* If an endpoint's input includes `{ body: ... }`, only the `body` portion is extracted.
|
|
40
47
|
* Produces a nested map of body input types.
|
|
48
|
+
*
|
|
49
|
+
* @see {@link https://orpc.dev/docs/client/client-side#infer-client-body-inputs | Client-Side Clients - Infer Client Body Inputs}
|
|
41
50
|
*/
|
|
42
51
|
type InferClientBodyInputs<T extends AnyNestedClient> = T extends Client<any, infer U, any, any> ? U extends {
|
|
43
52
|
body: infer UBody;
|
|
@@ -48,6 +57,8 @@ type InferClientBodyInputs<T extends AnyNestedClient> = T extends Client<any, in
|
|
|
48
57
|
* Recursively infers the **output types** from a client.
|
|
49
58
|
*
|
|
50
59
|
* Produces a nested map where each endpoint's output type is preserved.
|
|
60
|
+
*
|
|
61
|
+
* @see {@link https://orpc.dev/docs/client/client-side#infer-client-outputs | Client-Side Clients - Infer Client Outputs}
|
|
51
62
|
*/
|
|
52
63
|
type InferClientOutputs<T extends AnyNestedClient> = T extends Client<any, any, infer U, any> ? U : {
|
|
53
64
|
[K in keyof T]: T[K] extends AnyNestedClient ? InferClientOutputs<T[K]> : never;
|
|
@@ -57,6 +68,8 @@ type InferClientOutputs<T extends AnyNestedClient> = T extends Client<any, any,
|
|
|
57
68
|
*
|
|
58
69
|
* If an endpoint's output includes `{ body: ... }`, only the `body` portion is extracted.
|
|
59
70
|
* Produces a nested map of body output types.
|
|
71
|
+
*
|
|
72
|
+
* @see {@link https://orpc.dev/docs/client/client-side#infer-client-body-outputs | Client-Side Clients - Infer Client Body Outputs}
|
|
60
73
|
*/
|
|
61
74
|
type InferClientBodyOutputs<T extends AnyNestedClient> = T extends Client<any, any, infer U, any> ? U extends {
|
|
62
75
|
body: infer UBody;
|
|
@@ -64,22 +77,33 @@ type InferClientBodyOutputs<T extends AnyNestedClient> = T extends Client<any, a
|
|
|
64
77
|
[K in keyof T]: T[K] extends AnyNestedClient ? InferClientBodyOutputs<T[K]> : never;
|
|
65
78
|
};
|
|
66
79
|
/**
|
|
67
|
-
* Recursively infers the **error types** from a client when you use [type-safe errors](https://orpc.dev/docs/error-handling#
|
|
80
|
+
* Recursively infers the **error types** from a client when you use [type-safe errors](https://orpc.dev/docs/error-handling#typesafe-errors).
|
|
68
81
|
*
|
|
69
82
|
* Produces a nested map where each endpoint's error type is preserved.
|
|
83
|
+
*
|
|
84
|
+
* @see {@link https://orpc.dev/docs/client/client-side#infer-client-errors | Client-Side Clients - Infer Client Errors}
|
|
70
85
|
*/
|
|
71
86
|
type InferClientErrors<T extends AnyNestedClient> = T extends Client<any, any, any, infer U> ? U : {
|
|
72
87
|
[K in keyof T]: T[K] extends AnyNestedClient ? InferClientErrors<T[K]> : never;
|
|
73
88
|
};
|
|
74
89
|
/**
|
|
75
|
-
* Recursively infers a **union of all error types** from a client when you use [type-safe errors](https://orpc.dev/docs/error-handling#
|
|
90
|
+
* Recursively infers a **union of all error types** from a client when you use [type-safe errors](https://orpc.dev/docs/error-handling#typesafe-errors).
|
|
76
91
|
*
|
|
77
92
|
* Useful when you want to handle all possible errors from any endpoint at once.
|
|
93
|
+
*
|
|
94
|
+
* @see {@link https://orpc.dev/docs/client/client-side#infer-client-error | Client-Side Clients - Infer Client Error}
|
|
78
95
|
*/
|
|
79
96
|
type InferClientError<T extends AnyNestedClient> = T extends Client<any, any, any, infer U> ? U : {
|
|
80
97
|
[K in keyof T]: T[K] extends AnyNestedClient ? InferClientError<T[K]> : never;
|
|
81
98
|
}[keyof T];
|
|
82
99
|
|
|
100
|
+
/**
|
|
101
|
+
* Default mapping between common oRPC error codes and HTTP status codes.
|
|
102
|
+
* Handlers use it to determine response status codes; spread it to build a custom `errorStatusMap`.
|
|
103
|
+
*
|
|
104
|
+
* @see {@link https://orpc.dev/docs/rpc/handler#custom-error-response | RPC Handler - Custom Error Response}
|
|
105
|
+
* @see {@link https://orpc.dev/docs/openapi/handler#custom-error-response | OpenAPI Handler - Custom Error Response}
|
|
106
|
+
*/
|
|
83
107
|
declare const COMMON_ERROR_STATUS_MAP: {
|
|
84
108
|
BAD_REQUEST: number;
|
|
85
109
|
UNAUTHORIZED: number;
|
|
@@ -114,10 +138,16 @@ type ORPCErrorOptions<TData> = ErrorOptions & {
|
|
|
114
138
|
} : {
|
|
115
139
|
data: TData;
|
|
116
140
|
});
|
|
141
|
+
/**
|
|
142
|
+
* Typed error carrying a `code`, a `message`, and optional `data`.
|
|
143
|
+
* Throw it from handlers or middleware to produce typed error responses on the client.
|
|
144
|
+
*
|
|
145
|
+
* @see {@link https://orpc.dev/docs/error-handling#orpcerror-class | Error Handling - ORPCError Class}
|
|
146
|
+
*/
|
|
117
147
|
declare class ORPCError<TCode extends ORPCErrorCode, TData> extends Error {
|
|
118
148
|
/**
|
|
119
|
-
* @
|
|
120
|
-
* The `__branch` property is used for type branding, helping TypeScript distinguish
|
|
149
|
+
* @remarks
|
|
150
|
+
* **Note**: The `__branch` property is used for type branding, helping TypeScript distinguish
|
|
121
151
|
* an `ORPCError` instance from plain objects with a similar structure.
|
|
122
152
|
*/
|
|
123
153
|
readonly name: "ORPCError" & {
|
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.24",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.dev",
|
|
7
7
|
"repository": {
|
|
@@ -50,10 +50,10 @@
|
|
|
50
50
|
"dist"
|
|
51
51
|
],
|
|
52
52
|
"dependencies": {
|
|
53
|
-
"@standardserver/core": "^0.
|
|
54
|
-
"@standardserver/fetch": "^0.
|
|
55
|
-
"@standardserver/peer": "^0.
|
|
56
|
-
"@orpc/shared": "2.0.0-beta.
|
|
53
|
+
"@standardserver/core": "^0.7.1",
|
|
54
|
+
"@standardserver/fetch": "^0.7.1",
|
|
55
|
+
"@standardserver/peer": "^0.7.1",
|
|
56
|
+
"@orpc/shared": "2.0.0-beta.24"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"zod": "^4.4.3"
|