@orpc/client 2.0.0-beta.14 → 2.0.0-beta.16
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 +2 -2
- package/dist/adapters/fetch/index.d.mts +3 -3
- package/dist/adapters/fetch/index.d.ts +3 -3
- package/dist/adapters/fetch/index.mjs +28 -3
- package/dist/adapters/message-port/index.d.mts +2 -2
- package/dist/adapters/message-port/index.d.ts +2 -2
- package/dist/adapters/message-port/index.mjs +2 -2
- package/dist/adapters/standard/index.d.mts +3 -3
- package/dist/adapters/standard/index.d.ts +3 -3
- package/dist/adapters/standard/index.mjs +2 -2
- package/dist/adapters/websocket/index.d.mts +2 -2
- package/dist/adapters/websocket/index.d.ts +2 -2
- package/dist/adapters/websocket/index.mjs +2 -2
- package/dist/index.d.mts +12 -46
- package/dist/index.d.ts +12 -46
- package/dist/index.mjs +4 -35
- package/dist/plugins/index.d.mts +60 -7
- package/dist/plugins/index.d.ts +60 -7
- package/dist/plugins/index.mjs +231 -9
- package/dist/shared/{client.Cby_-GGh.d.mts → client.8f4DNmdE.d.mts} +1 -1
- package/dist/shared/{client.8ug8I-zu.d.mts → client.BBZBQID8.d.mts} +2 -2
- package/dist/shared/{client.8ug8I-zu.d.ts → client.BBZBQID8.d.ts} +2 -2
- package/dist/shared/{client.CPF3hX6O.d.ts → client.BMKYqpdy.d.ts} +1 -1
- package/dist/shared/{client.BN52ep3E.mjs → client.BRJnOJ0R.mjs} +4 -4
- package/dist/shared/{client.D3TIIok6.mjs → client.DqYwRDUO.mjs} +4 -4
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -107,7 +107,6 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
107
107
|
</tr>
|
|
108
108
|
<tr>
|
|
109
109
|
<td align="center"><a href="https://github.com/christ12938?ref=orpc" target="_blank" rel="noopener" title="christ12938"><img src="https://avatars.githubusercontent.com/u/25758598?v=4" width="139" alt="christ12938"/><br />christ12938</a></td>
|
|
110
|
-
<td align="center"><a href="https://github.com/peter-adam-dy?ref=orpc" target="_blank" rel="noopener" title="Peter Adam"><img src="https://avatars.githubusercontent.com/u/132129459?u=4f3dbbb3b443990b56acb7d6a5d11ed2c555f6db&v=4" width="139" alt="Peter Adam"/><br />Peter Adam</a></td>
|
|
111
110
|
<td align="center"><a href="https://github.com/Ryanjso?ref=orpc" target="_blank" rel="noopener" title="Ryan Soderberg"><img src="https://avatars.githubusercontent.com/u/39172778?u=5ed913c31d57e7221b75784abcad48c7ebddde27&v=4" width="139" alt="Ryan Soderberg"/><br />Ryan Soderberg</a></td>
|
|
112
111
|
<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>
|
|
113
112
|
</tr>
|
|
@@ -168,6 +167,7 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
168
167
|
<a href="https://github.com/nguyenlc1993?ref=orpc" target="_blank" rel="noopener" title="Lê Cao Nguyên"><img src="https://avatars.githubusercontent.com/u/13871971?u=83c8b69d9e35b589c4e1f066cc113b1d9461386f&v=4" width="32" height="32" alt="Lê Cao Nguyên" /></a>
|
|
169
168
|
<a href="https://github.com/wobsoriano?ref=orpc" target="_blank" rel="noopener" title="Robert Soriano"><img src="https://avatars.githubusercontent.com/u/13049130?u=6d72104182e7c9ed25934815313fb69107332111&v=4" width="32" height="32" alt="Robert Soriano" /></a>
|
|
170
169
|
<a href="https://github.com/SKostyukovich?ref=orpc" target="_blank" rel="noopener" title="SKostyukovich"><img src="https://avatars.githubusercontent.com/u/10700067?v=4" width="32" height="32" alt="SKostyukovich" /></a>
|
|
170
|
+
<a href="https://github.com/peter-adam-dy?ref=orpc" target="_blank" rel="noopener" title="Peter Adam"><img src="https://avatars.githubusercontent.com/u/132129459?u=4f3dbbb3b443990b56acb7d6a5d11ed2c555f6db&v=4" width="32" height="32" alt="Peter Adam" /></a>
|
|
171
171
|
<a href="https://github.com/FabworksHQ?ref=orpc" target="_blank" rel="noopener" title="Fabworks"><img src="https://avatars.githubusercontent.com/u/160179500?v=4" width="32" height="32" alt="Fabworks" /></a>
|
|
172
172
|
<a href="https://github.com/NovakAnton?ref=orpc" target="_blank" rel="noopener" title="Novak Antonijevic"><img src="https://avatars.githubusercontent.com/u/157126729?u=ae49fa22292d55c0434ff0ca008206155b18663b&v=4" width="32" height="32" alt="Novak Antonijevic" /></a>
|
|
173
173
|
<a href="https://github.com/laduniestu?ref=orpc" target="_blank" rel="noopener" title="Laduni Estu Syalwa"><img src="https://avatars.githubusercontent.com/u/44757637?u=a2fc1ea8f7d827a96721176f79d30592d1c48059&v=4" width="32" height="32" alt="Laduni Estu Syalwa" /></a>
|
|
@@ -175,7 +175,7 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
|
|
|
175
175
|
<a href="https://github.com/illarionvk?ref=orpc" target="_blank" rel="noopener" title="Illarion Koperski"><img src="https://avatars.githubusercontent.com/u/5012724?u=7cfa13652f7ac5fb3c56d880e3eb3fbe40c3ea34&v=4" width="32" height="32" alt="Illarion Koperski" /></a>
|
|
176
176
|
<a href="https://github.com/steelbrain?ref=orpc" target="_blank" rel="noopener" title="Anees Iqbal"><img src="https://avatars.githubusercontent.com/u/4278113?u=22b80b5399eed68ac76cd58b02961b0481f1db11&v=4" width="32" height="32" alt="Anees Iqbal" /></a>
|
|
177
177
|
<a href="https://github.com/Scrumplex?ref=orpc" target="_blank" rel="noopener" title="Sefa Eyeoglu"><img src="https://avatars.githubusercontent.com/u/11587657?u=ab503582165c0bbff0cca47ce31c9450bb1553c9&v=4" width="32" height="32" alt="Sefa Eyeoglu" /></a>
|
|
178
|
-
<a href="https://github.com/nattstack?ref=orpc" target="_blank" rel="noopener" title="
|
|
178
|
+
<a href="https://github.com/nattstack?ref=orpc" target="_blank" rel="noopener" title="NΛTT"><img src="https://avatars.githubusercontent.com/u/31426677?u=fa9dbb8b3e66eb0ea3c88db5dc07f31c8c5418fe&v=4" width="32" height="32" alt="NΛTT" /></a>
|
|
179
179
|
<a href="https://github.com/ChromeGG?ref=orpc" target="_blank" rel="noopener" title="Adam Tkaczyk"><img src="https://avatars.githubusercontent.com/u/39050595?u=a58ca6042a6950e94e6e92442db76ef584279bc0&v=4" width="32" height="32" alt="Adam Tkaczyk" /></a>
|
|
180
180
|
<a href="https://github.com/plancraft?ref=orpc" target="_blank" rel="noopener" title="plancraft"><img src="https://avatars.githubusercontent.com/u/46482287?v=4" width="32" height="32" alt="plancraft" /></a>
|
|
181
181
|
</p>
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as ClientContext, a as ClientOptions } from '../../shared/client.
|
|
1
|
+
import { C as ClientContext, a as ClientOptions } from '../../shared/client.BBZBQID8.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.8f4DNmdE.mjs';
|
|
6
6
|
import { RPCLinkCodecOptions } from '../standard/index.mjs';
|
|
7
7
|
import '../../shared/client.BdItY5DT.mjs';
|
|
8
8
|
|
|
@@ -21,7 +21,7 @@ interface FetchLinkTransportOptions<T extends ClientContext> {
|
|
|
21
21
|
*/
|
|
22
22
|
origin?: Value<Promisable<`https://${string}` | `http://${string}` | ({} & string) | undefined>, [options: ClientOptions<T>, path: string[]]>;
|
|
23
23
|
/**
|
|
24
|
-
* Options for how to convert the Standard Request to a Fetch Request, like event
|
|
24
|
+
* Options for how to convert the Standard Request to a Fetch Request, like event stream options, etc.
|
|
25
25
|
*/
|
|
26
26
|
toFetchRequest?: undefined | ToFetchBodyOptions;
|
|
27
27
|
/**
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as ClientContext, a as ClientOptions } from '../../shared/client.
|
|
1
|
+
import { C as ClientContext, a as ClientOptions } from '../../shared/client.BBZBQID8.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.BMKYqpdy.js';
|
|
6
6
|
import { RPCLinkCodecOptions } from '../standard/index.js';
|
|
7
7
|
import '../../shared/client.BdItY5DT.js';
|
|
8
8
|
|
|
@@ -21,7 +21,7 @@ interface FetchLinkTransportOptions<T extends ClientContext> {
|
|
|
21
21
|
*/
|
|
22
22
|
origin?: Value<Promisable<`https://${string}` | `http://${string}` | ({} & string) | undefined>, [options: ClientOptions<T>, path: string[]]>;
|
|
23
23
|
/**
|
|
24
|
-
* Options for how to convert the Standard Request to a Fetch Request, like event
|
|
24
|
+
* Options for how to convert the Standard Request to a Fetch Request, like event stream options, etc.
|
|
25
25
|
*/
|
|
26
26
|
toFetchRequest?: undefined | ToFetchBodyOptions;
|
|
27
27
|
/**
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { sortPlugins, value, intercept } from '@orpc/shared';
|
|
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.BRJnOJ0R.mjs';
|
|
4
4
|
import '@standardserver/core';
|
|
5
5
|
import '../../shared/client.Dnfj8jnT.mjs';
|
|
6
|
-
import '../../shared/client.
|
|
6
|
+
import '../../shared/client.DqYwRDUO.mjs';
|
|
7
7
|
|
|
8
8
|
class CompositeFetchLinkTransportPlugin {
|
|
9
9
|
constructor(plugins = []) {
|
|
@@ -21,6 +21,25 @@ class CompositeFetchLinkTransportPlugin {
|
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
const GET_SUPPORTED_DUPLEX_MODE = once(() => {
|
|
25
|
+
try {
|
|
26
|
+
let duplex;
|
|
27
|
+
void new Request(
|
|
28
|
+
"https://example.com",
|
|
29
|
+
{
|
|
30
|
+
method: "POST",
|
|
31
|
+
body: new ReadableStream(),
|
|
32
|
+
get duplex() {
|
|
33
|
+
duplex = "half";
|
|
34
|
+
return "half";
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
return duplex;
|
|
39
|
+
} catch {
|
|
40
|
+
return void 0;
|
|
41
|
+
}
|
|
42
|
+
});
|
|
24
43
|
class FetchLinkTransport {
|
|
25
44
|
origin;
|
|
26
45
|
fetch;
|
|
@@ -47,6 +66,12 @@ class FetchLinkTransport {
|
|
|
47
66
|
signal: options.signal,
|
|
48
67
|
redirect: "manual"
|
|
49
68
|
};
|
|
69
|
+
if (body instanceof ReadableStream) {
|
|
70
|
+
const duplex = GET_SUPPORTED_DUPLEX_MODE();
|
|
71
|
+
if (duplex !== void 0) {
|
|
72
|
+
init.duplex = duplex;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
50
75
|
const response = await intercept(
|
|
51
76
|
this.fetchInterceptors,
|
|
52
77
|
{ ...options, url, path, init },
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as ClientContext, a as ClientOptions } from '../../shared/client.
|
|
1
|
+
import { C as ClientContext, a as ClientOptions } from '../../shared/client.BBZBQID8.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.8f4DNmdE.mjs';
|
|
6
6
|
import { RPCLinkCodecOptions } from '../standard/index.mjs';
|
|
7
7
|
import '../../shared/client.BdItY5DT.mjs';
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as ClientContext, a as ClientOptions } from '../../shared/client.
|
|
1
|
+
import { C as ClientContext, a as ClientOptions } from '../../shared/client.BBZBQID8.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.BMKYqpdy.js';
|
|
6
6
|
import { RPCLinkCodecOptions } from '../standard/index.js';
|
|
7
7
|
import '../../shared/client.BdItY5DT.js';
|
|
8
8
|
|
|
@@ -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.BRJnOJ0R.mjs';
|
|
4
4
|
import '@standardserver/core';
|
|
5
5
|
import '@standardserver/fetch';
|
|
6
6
|
import '../../shared/client.Dnfj8jnT.mjs';
|
|
7
|
-
import '../../shared/client.
|
|
7
|
+
import '../../shared/client.DqYwRDUO.mjs';
|
|
8
8
|
|
|
9
9
|
function postMessagePortMessage(port, data, transfer) {
|
|
10
10
|
if (transfer) {
|
|
@@ -1,9 +1,9 @@
|
|
|
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.8f4DNmdE.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.8f4DNmdE.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.
|
|
6
|
+
import { C as ClientContext, a as ClientOptions } from '../../shared/client.BBZBQID8.mjs';
|
|
7
7
|
import { e as RPCSerializer } from '../../shared/client.BdItY5DT.mjs';
|
|
8
8
|
|
|
9
9
|
interface RPCLinkCodecOptions<T extends ClientContext> {
|
|
@@ -1,9 +1,9 @@
|
|
|
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.BMKYqpdy.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.BMKYqpdy.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.
|
|
6
|
+
import { C as ClientContext, a as ClientOptions } from '../../shared/client.BBZBQID8.js';
|
|
7
7
|
import { e as RPCSerializer } from '../../shared/client.BdItY5DT.js';
|
|
8
8
|
|
|
9
9
|
interface RPCLinkCodecOptions<T extends ClientContext> {
|
|
@@ -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.BRJnOJ0R.mjs';
|
|
2
2
|
import '@orpc/shared';
|
|
3
3
|
import '@standardserver/core';
|
|
4
4
|
import '@standardserver/fetch';
|
|
5
5
|
import '../../shared/client.Dnfj8jnT.mjs';
|
|
6
|
-
import '../../shared/client.
|
|
6
|
+
import '../../shared/client.DqYwRDUO.mjs';
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as ClientContext, a as ClientOptions } from '../../shared/client.
|
|
1
|
+
import { C as ClientContext, a as ClientOptions } from '../../shared/client.BBZBQID8.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.8f4DNmdE.mjs';
|
|
6
6
|
import { RPCLinkCodecOptions } from '../standard/index.mjs';
|
|
7
7
|
import '../../shared/client.BdItY5DT.mjs';
|
|
8
8
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { C as ClientContext, a as ClientOptions } from '../../shared/client.
|
|
1
|
+
import { C as ClientContext, a as ClientOptions } from '../../shared/client.BBZBQID8.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.BMKYqpdy.js';
|
|
6
6
|
import { RPCLinkCodecOptions } from '../standard/index.js';
|
|
7
7
|
import '../../shared/client.BdItY5DT.js';
|
|
8
8
|
|
|
@@ -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.BRJnOJ0R.mjs';
|
|
4
4
|
import '@standardserver/core';
|
|
5
5
|
import '@standardserver/fetch';
|
|
6
6
|
import '../../shared/client.Dnfj8jnT.mjs';
|
|
7
|
-
import '../../shared/client.
|
|
7
|
+
import '../../shared/client.DqYwRDUO.mjs';
|
|
8
8
|
|
|
9
9
|
const WEBSOCKET_CONNECTING = 0;
|
|
10
10
|
const WEBSOCKET_OPEN = 1;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
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.BBZBQID8.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.BBZBQID8.mjs';
|
|
5
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.BdItY5DT.mjs';
|
|
6
6
|
export { ErrorEvent, EventMeta, getEventMeta, unwrapEvent, withEventMeta } from '@standardserver/core';
|
|
7
7
|
|
|
8
|
-
declare function
|
|
9
|
-
declare function toORPCError<T>(error: T): Extract<T, AnyORPCError> | ORPCError<'INTERNAL_SERVER_ERROR', undefined>;
|
|
10
|
-
declare function isORPCErrorJson(json: unknown): json is ORPCErrorJSON<ORPCErrorCode, unknown>;
|
|
11
|
-
declare function createORPCErrorFromJson<TCode extends ORPCErrorCode, TData>(json: ORPCErrorJSON<TCode, TData>, options?: ErrorOptions): ORPCError<TCode, TData>;
|
|
12
|
-
declare function cloneORPCError<T extends ORPCErrorCode, TData>(error: ORPCError<T, TData>): ORPCError<T, TData>;
|
|
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>;
|
|
13
9
|
|
|
14
10
|
interface ORPCClientInterceptorOptions<TClientContext extends ClientContext, TInput> extends ClientOptions<TClientContext> {
|
|
15
11
|
path: string[];
|
|
@@ -74,35 +70,6 @@ type SafeResult<TOutput, TError> = [error: null, data: TOutput, inferableError:
|
|
|
74
70
|
* }
|
|
75
71
|
*/
|
|
76
72
|
declare function safe<TOutput, TError = ThrowableError>(promise: PromiseWithError<TOutput, TError>): Promise<SafeResult<TOutput, TError>>;
|
|
77
|
-
interface ConsumeEventIteratorOptions<T, TReturn, TError> {
|
|
78
|
-
/**
|
|
79
|
-
* Called on each event
|
|
80
|
-
*/
|
|
81
|
-
onEvent: (event: T) => void;
|
|
82
|
-
/**
|
|
83
|
-
* Called once error happens
|
|
84
|
-
*/
|
|
85
|
-
onError?: (error: TError) => void;
|
|
86
|
-
/**
|
|
87
|
-
* Called once event iterator is done
|
|
88
|
-
*
|
|
89
|
-
* @info If iterator is canceled, `undefined` can be passed on success
|
|
90
|
-
*/
|
|
91
|
-
onSuccess?: (value: TReturn | undefined) => void;
|
|
92
|
-
/**
|
|
93
|
-
* Called once after onError or onSuccess
|
|
94
|
-
*
|
|
95
|
-
* @info If iterator is canceled, `undefined` can be passed on success
|
|
96
|
-
*/
|
|
97
|
-
onFinish?: (state: [error: TError, data: undefined, isSuccess: false] | [error: null, data: TReturn | undefined, isSuccess: true]) => void;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Consumes an event iterator with lifecycle callbacks
|
|
101
|
-
*
|
|
102
|
-
* @warning If no `onError` or `onFinish` is provided, error will be thrown into unhandled rejection channel.
|
|
103
|
-
* @return unsubscribe callback
|
|
104
|
-
*/
|
|
105
|
-
declare function consumeEventIterator<T, TReturn, TError = ThrowableError>(iterator: AsyncIterator<T, TReturn> | PromiseWithError<AsyncIterator<T, TReturn>, TError>, options: ConsumeEventIteratorOptions<T, TReturn, TError>): () => Promise<void>;
|
|
106
73
|
|
|
107
74
|
type SafeClient<T extends AnyNestedClient> = T extends Client<infer UContext, infer UInput, infer UOutput, infer UError> ? (...rest: ClientRest<UContext, UInput>) => Promise<SafeResult<UOutput, UError>> : {
|
|
108
75
|
[K in keyof T]: T[K] extends AnyNestedClient ? SafeClient<T[K]> : never;
|
|
@@ -144,12 +111,11 @@ declare class DynamicLink<TClientContext extends ClientContext> implements Clien
|
|
|
144
111
|
call(path: string[], input: unknown, options: ClientOptions<TClientContext>): Promise<unknown>;
|
|
145
112
|
}
|
|
146
113
|
|
|
147
|
-
declare function
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
declare const isDefinedError: typeof isInferableError;
|
|
114
|
+
declare function isInferableError<T>(error: T): error is Extract<T, AnyORPCError>;
|
|
115
|
+
declare function toORPCError<T>(error: T): Extract<T, AnyORPCError> | ORPCError<'INTERNAL_SERVER_ERROR', undefined>;
|
|
116
|
+
declare function isORPCErrorJson(json: unknown): json is ORPCErrorJSON<ORPCErrorCode, unknown>;
|
|
117
|
+
declare function createORPCErrorFromJson<TCode extends ORPCErrorCode, TData>(json: ORPCErrorJSON<TCode, TData>, options?: ErrorOptions): ORPCError<TCode, TData>;
|
|
118
|
+
declare function cloneORPCError<T extends ORPCErrorCode, TData>(error: ORPCError<T, TData>): ORPCError<T, TData>;
|
|
153
119
|
|
|
154
|
-
export { AnyNestedClient, AnyORPCError, Client, ClientContext, ClientLink, ClientOptions, ClientRest, DynamicLink, FriendlyClientOptions, InferClientContext, InferClientError, ORPCError, ORPCErrorCode, ORPCErrorJSON, RECURSIVE_CLIENT_UNWRAP_KEYS, cloneORPCError,
|
|
155
|
-
export type {
|
|
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 };
|
|
121
|
+
export type { ORPCClientInterceptor, ORPCClientInterceptorOptions, ORPCClientOptions, ORPCClientScoped, ORPCClientScopedOptions, SafeClient, SafeResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
export {
|
|
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.BBZBQID8.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.BBZBQID8.js';
|
|
5
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.BdItY5DT.js';
|
|
6
6
|
export { ErrorEvent, EventMeta, getEventMeta, unwrapEvent, withEventMeta } from '@standardserver/core';
|
|
7
7
|
|
|
8
|
-
declare function
|
|
9
|
-
declare function toORPCError<T>(error: T): Extract<T, AnyORPCError> | ORPCError<'INTERNAL_SERVER_ERROR', undefined>;
|
|
10
|
-
declare function isORPCErrorJson(json: unknown): json is ORPCErrorJSON<ORPCErrorCode, unknown>;
|
|
11
|
-
declare function createORPCErrorFromJson<TCode extends ORPCErrorCode, TData>(json: ORPCErrorJSON<TCode, TData>, options?: ErrorOptions): ORPCError<TCode, TData>;
|
|
12
|
-
declare function cloneORPCError<T extends ORPCErrorCode, TData>(error: ORPCError<T, TData>): ORPCError<T, TData>;
|
|
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>;
|
|
13
9
|
|
|
14
10
|
interface ORPCClientInterceptorOptions<TClientContext extends ClientContext, TInput> extends ClientOptions<TClientContext> {
|
|
15
11
|
path: string[];
|
|
@@ -74,35 +70,6 @@ type SafeResult<TOutput, TError> = [error: null, data: TOutput, inferableError:
|
|
|
74
70
|
* }
|
|
75
71
|
*/
|
|
76
72
|
declare function safe<TOutput, TError = ThrowableError>(promise: PromiseWithError<TOutput, TError>): Promise<SafeResult<TOutput, TError>>;
|
|
77
|
-
interface ConsumeEventIteratorOptions<T, TReturn, TError> {
|
|
78
|
-
/**
|
|
79
|
-
* Called on each event
|
|
80
|
-
*/
|
|
81
|
-
onEvent: (event: T) => void;
|
|
82
|
-
/**
|
|
83
|
-
* Called once error happens
|
|
84
|
-
*/
|
|
85
|
-
onError?: (error: TError) => void;
|
|
86
|
-
/**
|
|
87
|
-
* Called once event iterator is done
|
|
88
|
-
*
|
|
89
|
-
* @info If iterator is canceled, `undefined` can be passed on success
|
|
90
|
-
*/
|
|
91
|
-
onSuccess?: (value: TReturn | undefined) => void;
|
|
92
|
-
/**
|
|
93
|
-
* Called once after onError or onSuccess
|
|
94
|
-
*
|
|
95
|
-
* @info If iterator is canceled, `undefined` can be passed on success
|
|
96
|
-
*/
|
|
97
|
-
onFinish?: (state: [error: TError, data: undefined, isSuccess: false] | [error: null, data: TReturn | undefined, isSuccess: true]) => void;
|
|
98
|
-
}
|
|
99
|
-
/**
|
|
100
|
-
* Consumes an event iterator with lifecycle callbacks
|
|
101
|
-
*
|
|
102
|
-
* @warning If no `onError` or `onFinish` is provided, error will be thrown into unhandled rejection channel.
|
|
103
|
-
* @return unsubscribe callback
|
|
104
|
-
*/
|
|
105
|
-
declare function consumeEventIterator<T, TReturn, TError = ThrowableError>(iterator: AsyncIterator<T, TReturn> | PromiseWithError<AsyncIterator<T, TReturn>, TError>, options: ConsumeEventIteratorOptions<T, TReturn, TError>): () => Promise<void>;
|
|
106
73
|
|
|
107
74
|
type SafeClient<T extends AnyNestedClient> = T extends Client<infer UContext, infer UInput, infer UOutput, infer UError> ? (...rest: ClientRest<UContext, UInput>) => Promise<SafeResult<UOutput, UError>> : {
|
|
108
75
|
[K in keyof T]: T[K] extends AnyNestedClient ? SafeClient<T[K]> : never;
|
|
@@ -144,12 +111,11 @@ declare class DynamicLink<TClientContext extends ClientContext> implements Clien
|
|
|
144
111
|
call(path: string[], input: unknown, options: ClientOptions<TClientContext>): Promise<unknown>;
|
|
145
112
|
}
|
|
146
113
|
|
|
147
|
-
declare function
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
declare const isDefinedError: typeof isInferableError;
|
|
114
|
+
declare function isInferableError<T>(error: T): error is Extract<T, AnyORPCError>;
|
|
115
|
+
declare function toORPCError<T>(error: T): Extract<T, AnyORPCError> | ORPCError<'INTERNAL_SERVER_ERROR', undefined>;
|
|
116
|
+
declare function isORPCErrorJson(json: unknown): json is ORPCErrorJSON<ORPCErrorCode, unknown>;
|
|
117
|
+
declare function createORPCErrorFromJson<TCode extends ORPCErrorCode, TData>(json: ORPCErrorJSON<TCode, TData>, options?: ErrorOptions): ORPCError<TCode, TData>;
|
|
118
|
+
declare function cloneORPCError<T extends ORPCErrorCode, TData>(error: ORPCError<T, TData>): ORPCError<T, TData>;
|
|
153
119
|
|
|
154
|
-
export { AnyNestedClient, AnyORPCError, Client, ClientContext, ClientLink, ClientOptions, ClientRest, DynamicLink, FriendlyClientOptions, InferClientContext, InferClientError, ORPCError, ORPCErrorCode, ORPCErrorJSON, RECURSIVE_CLIENT_UNWRAP_KEYS, cloneORPCError,
|
|
155
|
-
export type {
|
|
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 };
|
|
121
|
+
export type { ORPCClientInterceptor, ORPCClientInterceptorOptions, ORPCClientOptions, ORPCClientScoped, ORPCClientScopedOptions, SafeClient, SafeResult };
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
|
|
1
|
+
import { a as isInferableError } from './shared/client.DqYwRDUO.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.DqYwRDUO.mjs';
|
|
3
3
|
import { getOrBind, toArray, intercept, isTypescriptObject } from '@orpc/shared';
|
|
4
|
-
export { AsyncIteratorClass, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onError, onFinish, onStart, onSuccess,
|
|
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
5
|
export { C as COMMON_ERROR_STATUS_MAP, O as ORPCError } from './shared/client.Dnfj8jnT.mjs';
|
|
6
6
|
export { ErrorEvent, getEventMeta, unwrapEvent, withEventMeta } from '@standardserver/core';
|
|
7
7
|
|
|
@@ -66,35 +66,6 @@ async function safe(promise) {
|
|
|
66
66
|
);
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
|
-
function consumeEventIterator(iterator, options) {
|
|
70
|
-
void (async () => {
|
|
71
|
-
let onFinishState;
|
|
72
|
-
try {
|
|
73
|
-
const resolvedIterator = await iterator;
|
|
74
|
-
while (true) {
|
|
75
|
-
const { done, value } = await resolvedIterator.next();
|
|
76
|
-
if (done) {
|
|
77
|
-
const realValue = value;
|
|
78
|
-
onFinishState = [null, realValue, true];
|
|
79
|
-
options.onSuccess?.(realValue);
|
|
80
|
-
break;
|
|
81
|
-
}
|
|
82
|
-
options.onEvent(value);
|
|
83
|
-
}
|
|
84
|
-
} catch (error) {
|
|
85
|
-
onFinishState = [error, void 0, false];
|
|
86
|
-
if (!options.onError && !options.onFinish) {
|
|
87
|
-
throw error;
|
|
88
|
-
}
|
|
89
|
-
options.onError?.(error);
|
|
90
|
-
} finally {
|
|
91
|
-
options.onFinish?.(onFinishState);
|
|
92
|
-
}
|
|
93
|
-
})();
|
|
94
|
-
return async () => {
|
|
95
|
-
await (await iterator)?.return?.();
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
69
|
|
|
99
70
|
function createORPCClient(link, { path = [], ...options } = {}) {
|
|
100
71
|
const procedureClient = (...rest) => {
|
|
@@ -149,6 +120,4 @@ class DynamicLink {
|
|
|
149
120
|
}
|
|
150
121
|
}
|
|
151
122
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
export { DynamicLink, RECURSIVE_CLIENT_UNWRAP_KEYS, consumeEventIterator, createORPCClient, createSafeClient, isDefinedError, isInferableError, resolveClientRest, resolveFriendlyClientOptions, safe };
|
|
123
|
+
export { DynamicLink, RECURSIVE_CLIENT_UNWRAP_KEYS, createORPCClient, createSafeClient, isInferableError as isDefinedError, isInferableError, resolveClientRest, resolveFriendlyClientOptions, safe };
|
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.BBZBQID8.mjs';
|
|
4
|
+
import { c as StandardLinkPlugin, d as StandardLinkTransportInterceptorOptions, b as StandardLinkOptions, e as StandardLinkInterceptorOptions } from '../shared/client.8f4DNmdE.mjs';
|
|
5
5
|
|
|
6
6
|
type BatchLinkPluginMode = 'streaming' | 'buffered';
|
|
7
7
|
interface BatchLinkPluginGroup<T extends ClientContext> {
|
|
@@ -136,6 +136,61 @@ declare class DedupeLinkPlugin<T extends ClientContext> implements StandardLinkP
|
|
|
136
136
|
private execute;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
interface RequestCompressionLinkPluginOptions<_T extends ClientContext> {
|
|
140
|
+
/**
|
|
141
|
+
* The compression scheme to use for request compression.
|
|
142
|
+
*
|
|
143
|
+
* @default 'gzip'
|
|
144
|
+
*/
|
|
145
|
+
encoding?: 'gzip' | 'deflate' | 'deflate-raw';
|
|
146
|
+
/**
|
|
147
|
+
* The minimum request size in bytes required to trigger compression.
|
|
148
|
+
* Requests smaller than this threshold will not be compressed to avoid overhead.
|
|
149
|
+
* If the request size cannot be determined, compression will still be applied.
|
|
150
|
+
*
|
|
151
|
+
* @default 1024 (1KB)
|
|
152
|
+
*/
|
|
153
|
+
threshold?: number;
|
|
154
|
+
}
|
|
155
|
+
declare class RequestCompressionLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
156
|
+
name: string;
|
|
157
|
+
/**
|
|
158
|
+
* Compression should be done after batching, to compress the final request
|
|
159
|
+
*/
|
|
160
|
+
after: string[];
|
|
161
|
+
private readonly encoding;
|
|
162
|
+
private readonly threshold;
|
|
163
|
+
constructor(options?: RequestCompressionLinkPluginOptions<T>);
|
|
164
|
+
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
interface ResponseCompressionLinkPluginOptions<_T extends ClientContext> {
|
|
168
|
+
/**
|
|
169
|
+
* Compression schemes to advertise via Accept-Encoding, in preference order.
|
|
170
|
+
* Only schemes that can be decompressed by this plugin should be listed.
|
|
171
|
+
*
|
|
172
|
+
* @default ['gzip', 'deflate']
|
|
173
|
+
*/
|
|
174
|
+
encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[];
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Advertises Accept-Encoding on requests and decompresses response bodies
|
|
178
|
+
* based on the Content-Encoding header. Works at the standard link level,
|
|
179
|
+
* so it supports all adapters.
|
|
180
|
+
*
|
|
181
|
+
* @see {@link https://orpc.dev/docs/plugins/response-compression Response Compression Plugin Docs}
|
|
182
|
+
*/
|
|
183
|
+
declare class ResponseCompressionLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
184
|
+
name: string;
|
|
185
|
+
/**
|
|
186
|
+
* Decompression should wrap the final batch response instead of sub-responses.
|
|
187
|
+
*/
|
|
188
|
+
after: string[];
|
|
189
|
+
private readonly encodings;
|
|
190
|
+
constructor(options?: ResponseCompressionLinkPluginOptions<T>);
|
|
191
|
+
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
192
|
+
}
|
|
193
|
+
|
|
139
194
|
interface RetryLinkPluginAttemptOptions<T extends RetryLinkPluginContext> extends StandardLinkInterceptorOptions<T> {
|
|
140
195
|
/**
|
|
141
196
|
* Latest retry delay advertised by the server via event metadata.
|
|
@@ -153,7 +208,7 @@ interface RetryLinkPluginAttemptOptions<T extends RetryLinkPluginContext> extend
|
|
|
153
208
|
interface RetryLinkPluginContext {
|
|
154
209
|
/**
|
|
155
210
|
* Maximum retry attempts before throwing.
|
|
156
|
-
* Use `Number.POSITIVE_INFINITY` for infinite retries (e.g. for
|
|
211
|
+
* Use `Number.POSITIVE_INFINITY` for infinite retries (e.g. for AsyncIteratorObject).
|
|
157
212
|
*
|
|
158
213
|
* @default 0
|
|
159
214
|
*/
|
|
@@ -182,8 +237,6 @@ interface RetryLinkPluginOptions<_T extends RetryLinkPluginContext> {
|
|
|
182
237
|
*/
|
|
183
238
|
default?: RetryLinkPluginContext | undefined;
|
|
184
239
|
}
|
|
185
|
-
declare class RetryLinkPluginInvalidEventIteratorRetryResponse extends Error {
|
|
186
|
-
}
|
|
187
240
|
declare class RetryLinkPlugin<T extends RetryLinkPluginContext & ClientContext> implements StandardLinkPlugin<T> {
|
|
188
241
|
private readonly defaultRetry;
|
|
189
242
|
private readonly defaultRetryDelay;
|
|
@@ -238,5 +291,5 @@ declare class RetryAfterLinkPlugin<T extends ClientContext> implements StandardL
|
|
|
238
291
|
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
239
292
|
}
|
|
240
293
|
|
|
241
|
-
export { BatchLinkPlugin, BatchLinkPluginError, DedupeLinkPlugin, RetryAfterLinkPlugin, RetryLinkPlugin
|
|
242
|
-
export type { BatchLinkPluginGroup, BatchLinkPluginMode, BatchLinkPluginOptions, DedupeLinkPluginGroup, DedupeLinkPluginOptions, RetryAfterLinkPluginOptions, RetryLinkPluginAttemptOptions, RetryLinkPluginContext, RetryLinkPluginOptions };
|
|
294
|
+
export { BatchLinkPlugin, BatchLinkPluginError, DedupeLinkPlugin, RequestCompressionLinkPlugin, ResponseCompressionLinkPlugin, RetryAfterLinkPlugin, RetryLinkPlugin };
|
|
295
|
+
export type { BatchLinkPluginGroup, BatchLinkPluginMode, BatchLinkPluginOptions, DedupeLinkPluginGroup, DedupeLinkPluginOptions, RequestCompressionLinkPluginOptions, ResponseCompressionLinkPluginOptions, RetryAfterLinkPluginOptions, RetryLinkPluginAttemptOptions, RetryLinkPluginContext, RetryLinkPluginOptions };
|
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.BBZBQID8.js';
|
|
4
|
+
import { c as StandardLinkPlugin, d as StandardLinkTransportInterceptorOptions, b as StandardLinkOptions, e as StandardLinkInterceptorOptions } from '../shared/client.BMKYqpdy.js';
|
|
5
5
|
|
|
6
6
|
type BatchLinkPluginMode = 'streaming' | 'buffered';
|
|
7
7
|
interface BatchLinkPluginGroup<T extends ClientContext> {
|
|
@@ -136,6 +136,61 @@ declare class DedupeLinkPlugin<T extends ClientContext> implements StandardLinkP
|
|
|
136
136
|
private execute;
|
|
137
137
|
}
|
|
138
138
|
|
|
139
|
+
interface RequestCompressionLinkPluginOptions<_T extends ClientContext> {
|
|
140
|
+
/**
|
|
141
|
+
* The compression scheme to use for request compression.
|
|
142
|
+
*
|
|
143
|
+
* @default 'gzip'
|
|
144
|
+
*/
|
|
145
|
+
encoding?: 'gzip' | 'deflate' | 'deflate-raw';
|
|
146
|
+
/**
|
|
147
|
+
* The minimum request size in bytes required to trigger compression.
|
|
148
|
+
* Requests smaller than this threshold will not be compressed to avoid overhead.
|
|
149
|
+
* If the request size cannot be determined, compression will still be applied.
|
|
150
|
+
*
|
|
151
|
+
* @default 1024 (1KB)
|
|
152
|
+
*/
|
|
153
|
+
threshold?: number;
|
|
154
|
+
}
|
|
155
|
+
declare class RequestCompressionLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
156
|
+
name: string;
|
|
157
|
+
/**
|
|
158
|
+
* Compression should be done after batching, to compress the final request
|
|
159
|
+
*/
|
|
160
|
+
after: string[];
|
|
161
|
+
private readonly encoding;
|
|
162
|
+
private readonly threshold;
|
|
163
|
+
constructor(options?: RequestCompressionLinkPluginOptions<T>);
|
|
164
|
+
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
interface ResponseCompressionLinkPluginOptions<_T extends ClientContext> {
|
|
168
|
+
/**
|
|
169
|
+
* Compression schemes to advertise via Accept-Encoding, in preference order.
|
|
170
|
+
* Only schemes that can be decompressed by this plugin should be listed.
|
|
171
|
+
*
|
|
172
|
+
* @default ['gzip', 'deflate']
|
|
173
|
+
*/
|
|
174
|
+
encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[];
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Advertises Accept-Encoding on requests and decompresses response bodies
|
|
178
|
+
* based on the Content-Encoding header. Works at the standard link level,
|
|
179
|
+
* so it supports all adapters.
|
|
180
|
+
*
|
|
181
|
+
* @see {@link https://orpc.dev/docs/plugins/response-compression Response Compression Plugin Docs}
|
|
182
|
+
*/
|
|
183
|
+
declare class ResponseCompressionLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
184
|
+
name: string;
|
|
185
|
+
/**
|
|
186
|
+
* Decompression should wrap the final batch response instead of sub-responses.
|
|
187
|
+
*/
|
|
188
|
+
after: string[];
|
|
189
|
+
private readonly encodings;
|
|
190
|
+
constructor(options?: ResponseCompressionLinkPluginOptions<T>);
|
|
191
|
+
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
192
|
+
}
|
|
193
|
+
|
|
139
194
|
interface RetryLinkPluginAttemptOptions<T extends RetryLinkPluginContext> extends StandardLinkInterceptorOptions<T> {
|
|
140
195
|
/**
|
|
141
196
|
* Latest retry delay advertised by the server via event metadata.
|
|
@@ -153,7 +208,7 @@ interface RetryLinkPluginAttemptOptions<T extends RetryLinkPluginContext> extend
|
|
|
153
208
|
interface RetryLinkPluginContext {
|
|
154
209
|
/**
|
|
155
210
|
* Maximum retry attempts before throwing.
|
|
156
|
-
* Use `Number.POSITIVE_INFINITY` for infinite retries (e.g. for
|
|
211
|
+
* Use `Number.POSITIVE_INFINITY` for infinite retries (e.g. for AsyncIteratorObject).
|
|
157
212
|
*
|
|
158
213
|
* @default 0
|
|
159
214
|
*/
|
|
@@ -182,8 +237,6 @@ interface RetryLinkPluginOptions<_T extends RetryLinkPluginContext> {
|
|
|
182
237
|
*/
|
|
183
238
|
default?: RetryLinkPluginContext | undefined;
|
|
184
239
|
}
|
|
185
|
-
declare class RetryLinkPluginInvalidEventIteratorRetryResponse extends Error {
|
|
186
|
-
}
|
|
187
240
|
declare class RetryLinkPlugin<T extends RetryLinkPluginContext & ClientContext> implements StandardLinkPlugin<T> {
|
|
188
241
|
private readonly defaultRetry;
|
|
189
242
|
private readonly defaultRetryDelay;
|
|
@@ -238,5 +291,5 @@ declare class RetryAfterLinkPlugin<T extends ClientContext> implements StandardL
|
|
|
238
291
|
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
239
292
|
}
|
|
240
293
|
|
|
241
|
-
export { BatchLinkPlugin, BatchLinkPluginError, DedupeLinkPlugin, RetryAfterLinkPlugin, RetryLinkPlugin
|
|
242
|
-
export type { BatchLinkPluginGroup, BatchLinkPluginMode, BatchLinkPluginOptions, DedupeLinkPluginGroup, DedupeLinkPluginOptions, RetryAfterLinkPluginOptions, RetryLinkPluginAttemptOptions, RetryLinkPluginContext, RetryLinkPluginOptions };
|
|
294
|
+
export { BatchLinkPlugin, BatchLinkPluginError, DedupeLinkPlugin, RequestCompressionLinkPlugin, ResponseCompressionLinkPlugin, RetryAfterLinkPlugin, RetryLinkPlugin };
|
|
295
|
+
export type { BatchLinkPluginGroup, BatchLinkPluginMode, BatchLinkPluginOptions, DedupeLinkPluginGroup, DedupeLinkPluginOptions, RequestCompressionLinkPluginOptions, ResponseCompressionLinkPluginOptions, RetryAfterLinkPluginOptions, RetryLinkPluginAttemptOptions, RetryLinkPluginContext, RetryLinkPluginOptions };
|
package/dist/plugins/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { toArray, value, splitInHalf, stringifyJSON, isAsyncIteratorObject, defer, loadBytes, allAbortSignal, replicateAsyncIterator, replicateReadableStream, override, AsyncIteratorClass, sleep } from '@orpc/shared';
|
|
2
|
-
import { parseStandardUrl,
|
|
1
|
+
import { toArray, value, splitInHalf, stringifyJSON, isAsyncIteratorObject, defer, loadBytes, allAbortSignal, replicateAsyncIterator, replicateReadableStream, isCompressibleContentType, override, AsyncIteratorClass, sleep } from '@orpc/shared';
|
|
2
|
+
import { parseStandardUrl, flattenStandardHeader, generateContentDisposition, getEventMeta } from '@standardserver/core';
|
|
3
3
|
import { ClientPeer, isServerPeerSendMessage, decodePeerMessage } from '@standardserver/peer';
|
|
4
|
+
import { toFetchHeaders, toStandardBody } from '@standardserver/fetch';
|
|
4
5
|
import { C as COMMON_ERROR_STATUS_MAP } from '../shared/client.Dnfj8jnT.mjs';
|
|
5
6
|
|
|
6
7
|
class BatchLinkPluginError extends TypeError {
|
|
@@ -387,8 +388,229 @@ function shouldDedupe(items) {
|
|
|
387
388
|
return items.length >= 2;
|
|
388
389
|
}
|
|
389
390
|
|
|
390
|
-
|
|
391
|
+
const AVG_BYTES_PER_CHAR = 1.2;
|
|
392
|
+
class RequestCompressionLinkPlugin {
|
|
393
|
+
name = "~request-compression";
|
|
394
|
+
/**
|
|
395
|
+
* Compression should be done after batching, to compress the final request
|
|
396
|
+
*/
|
|
397
|
+
after = ["~batch"];
|
|
398
|
+
encoding;
|
|
399
|
+
threshold;
|
|
400
|
+
constructor(options = {}) {
|
|
401
|
+
this.encoding = options.encoding ?? "gzip";
|
|
402
|
+
this.threshold = options.threshold ?? 1024;
|
|
403
|
+
}
|
|
404
|
+
init(options) {
|
|
405
|
+
const transportInterceptor = async ({ next, ...interceptorOptions }) => {
|
|
406
|
+
const request = interceptorOptions.request;
|
|
407
|
+
const contentEncoding = flattenStandardHeader(request.headers["content-encoding"])?.trim()?.toLowerCase();
|
|
408
|
+
if (contentEncoding !== void 0) {
|
|
409
|
+
return next();
|
|
410
|
+
}
|
|
411
|
+
if (request.body instanceof ReadableStream) {
|
|
412
|
+
const contentLength = Number(flattenStandardHeader(request.headers["content-length"]));
|
|
413
|
+
if ((!Number.isFinite(contentLength) || contentLength >= this.threshold) && isCompressibleContentType(flattenStandardHeader(request.headers["content-type"]))) {
|
|
414
|
+
const compressedStream = request.body.pipeThrough(new CompressionStream(this.encoding));
|
|
415
|
+
return next({
|
|
416
|
+
...interceptorOptions,
|
|
417
|
+
request: {
|
|
418
|
+
...interceptorOptions.request,
|
|
419
|
+
body: compressedStream,
|
|
420
|
+
headers: {
|
|
421
|
+
...request.headers,
|
|
422
|
+
"standard-server": "octet-stream",
|
|
423
|
+
"content-length": [],
|
|
424
|
+
"content-encoding": this.encoding
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
} else if (request.body instanceof Blob) {
|
|
430
|
+
if ((!Number.isFinite(request.body.size) || request.body.size >= this.threshold) && isCompressibleContentType(request.body.type)) {
|
|
431
|
+
const compressedStream = request.body.stream().pipeThrough(new CompressionStream(this.encoding));
|
|
432
|
+
const contentDisposition = request.headers["content-disposition"] ?? generateContentDisposition(
|
|
433
|
+
request.body instanceof File ? request.body.name : "blob"
|
|
434
|
+
);
|
|
435
|
+
return next({
|
|
436
|
+
...interceptorOptions,
|
|
437
|
+
request: {
|
|
438
|
+
...interceptorOptions.request,
|
|
439
|
+
body: compressedStream,
|
|
440
|
+
headers: {
|
|
441
|
+
...request.headers,
|
|
442
|
+
"standard-server": "file",
|
|
443
|
+
"content-type": request.body.type,
|
|
444
|
+
"content-length": [],
|
|
445
|
+
"content-disposition": contentDisposition,
|
|
446
|
+
"content-encoding": this.encoding
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
});
|
|
450
|
+
}
|
|
451
|
+
} else if (request.body instanceof FormData) {
|
|
452
|
+
const PART_OVERHEAD = 64;
|
|
453
|
+
let contentLength = 0;
|
|
454
|
+
for (const [key, value] of request.body) {
|
|
455
|
+
contentLength += PART_OVERHEAD + key.length;
|
|
456
|
+
if (value instanceof Blob) {
|
|
457
|
+
if (!Number.isFinite(value.size)) {
|
|
458
|
+
if (!isCompressibleContentType(value.type)) {
|
|
459
|
+
contentLength = -Infinity;
|
|
460
|
+
break;
|
|
461
|
+
}
|
|
462
|
+
contentLength = Infinity;
|
|
463
|
+
} else {
|
|
464
|
+
contentLength += isCompressibleContentType(value.type) ? value.size : -value.size;
|
|
465
|
+
}
|
|
466
|
+
} else {
|
|
467
|
+
contentLength += value.length * AVG_BYTES_PER_CHAR;
|
|
468
|
+
}
|
|
469
|
+
}
|
|
470
|
+
if (contentLength >= this.threshold) {
|
|
471
|
+
const res = new Response(request.body);
|
|
472
|
+
const compressedStream = res.body.pipeThrough(new CompressionStream(this.encoding));
|
|
473
|
+
return next({
|
|
474
|
+
...interceptorOptions,
|
|
475
|
+
request: {
|
|
476
|
+
...interceptorOptions.request,
|
|
477
|
+
body: compressedStream,
|
|
478
|
+
headers: {
|
|
479
|
+
...request.headers,
|
|
480
|
+
"standard-server": [],
|
|
481
|
+
"content-type": res.headers.get("content-type"),
|
|
482
|
+
"content-length": [],
|
|
483
|
+
"content-encoding": this.encoding
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
});
|
|
487
|
+
}
|
|
488
|
+
} else if (request.body instanceof URLSearchParams) {
|
|
489
|
+
const string = request.body.toString();
|
|
490
|
+
if (string.length * AVG_BYTES_PER_CHAR >= this.threshold) {
|
|
491
|
+
const compressedStream = new Blob([string]).stream().pipeThrough(new CompressionStream(this.encoding));
|
|
492
|
+
return next({
|
|
493
|
+
...interceptorOptions,
|
|
494
|
+
request: {
|
|
495
|
+
...interceptorOptions.request,
|
|
496
|
+
body: compressedStream,
|
|
497
|
+
headers: {
|
|
498
|
+
...request.headers,
|
|
499
|
+
"standard-server": [],
|
|
500
|
+
"content-type": "application/x-www-form-urlencoded",
|
|
501
|
+
"content-length": [],
|
|
502
|
+
"content-encoding": this.encoding
|
|
503
|
+
}
|
|
504
|
+
}
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
} else if (request.body !== void 0 && !isAsyncIteratorObject(request.body)) {
|
|
508
|
+
const string = stringifyJSON(request.body);
|
|
509
|
+
if (string.length * AVG_BYTES_PER_CHAR >= this.threshold) {
|
|
510
|
+
const compressedStream = new Blob([string]).stream().pipeThrough(new CompressionStream(this.encoding));
|
|
511
|
+
return next({
|
|
512
|
+
...interceptorOptions,
|
|
513
|
+
request: {
|
|
514
|
+
...interceptorOptions.request,
|
|
515
|
+
body: compressedStream,
|
|
516
|
+
headers: {
|
|
517
|
+
...request.headers,
|
|
518
|
+
"standard-server": [],
|
|
519
|
+
"content-type": "application/json",
|
|
520
|
+
"content-length": [],
|
|
521
|
+
"content-encoding": this.encoding
|
|
522
|
+
}
|
|
523
|
+
}
|
|
524
|
+
});
|
|
525
|
+
}
|
|
526
|
+
}
|
|
527
|
+
return next();
|
|
528
|
+
};
|
|
529
|
+
return {
|
|
530
|
+
...options,
|
|
531
|
+
transportInterceptors: [
|
|
532
|
+
...toArray(options.transportInterceptors),
|
|
533
|
+
transportInterceptor
|
|
534
|
+
]
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
}
|
|
538
|
+
|
|
539
|
+
class ResponseCompressionLinkPlugin {
|
|
540
|
+
name = "~response-compression";
|
|
541
|
+
/**
|
|
542
|
+
* Decompression should wrap the final batch response instead of sub-responses.
|
|
543
|
+
*/
|
|
544
|
+
after = ["~batch"];
|
|
545
|
+
encodings;
|
|
546
|
+
constructor(options = {}) {
|
|
547
|
+
this.encodings = options.encodings ?? ["gzip", "deflate"];
|
|
548
|
+
}
|
|
549
|
+
init(options) {
|
|
550
|
+
const acceptEncodingHeader = this.encodings.join(", ");
|
|
551
|
+
const transportInterceptor = async ({ next, ...interceptorOptions }) => {
|
|
552
|
+
const response = await next({
|
|
553
|
+
...interceptorOptions,
|
|
554
|
+
request: {
|
|
555
|
+
...interceptorOptions.request,
|
|
556
|
+
headers: {
|
|
557
|
+
...interceptorOptions.request.headers,
|
|
558
|
+
"accept-encoding": acceptEncodingHeader
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
});
|
|
562
|
+
const encodings = parseContentEncodings(
|
|
563
|
+
flattenStandardHeader(response.headers["content-encoding"])
|
|
564
|
+
);
|
|
565
|
+
if (encodings.length === 0 || !encodings.every(isSupportedEncoding)) {
|
|
566
|
+
return response;
|
|
567
|
+
}
|
|
568
|
+
const decompressedHeaders = {
|
|
569
|
+
...response.headers,
|
|
570
|
+
"content-length": void 0,
|
|
571
|
+
"content-encoding": void 0
|
|
572
|
+
};
|
|
573
|
+
return {
|
|
574
|
+
...response,
|
|
575
|
+
headers: decompressedHeaders,
|
|
576
|
+
async resolveBody(hint) {
|
|
577
|
+
const stream = await response.resolveBody("octet-stream");
|
|
578
|
+
if (!(stream instanceof ReadableStream)) {
|
|
579
|
+
return stream;
|
|
580
|
+
}
|
|
581
|
+
let decompressedStream = stream;
|
|
582
|
+
for (let i = encodings.length - 1; i >= 0; i--) {
|
|
583
|
+
decompressedStream = decompressedStream.pipeThrough(
|
|
584
|
+
new DecompressionStream(encodings[i])
|
|
585
|
+
);
|
|
586
|
+
}
|
|
587
|
+
const fetchResponse = new Response(decompressedStream, {
|
|
588
|
+
headers: toFetchHeaders(decompressedHeaders)
|
|
589
|
+
});
|
|
590
|
+
return toStandardBody(fetchResponse, { hint });
|
|
591
|
+
}
|
|
592
|
+
};
|
|
593
|
+
};
|
|
594
|
+
return {
|
|
595
|
+
...options,
|
|
596
|
+
transportInterceptors: [
|
|
597
|
+
...toArray(options.transportInterceptors),
|
|
598
|
+
transportInterceptor
|
|
599
|
+
]
|
|
600
|
+
};
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
const SUPPORTED_ENCODINGS = ["gzip", "deflate", "deflate-raw"];
|
|
604
|
+
function isSupportedEncoding(encoding) {
|
|
605
|
+
return SUPPORTED_ENCODINGS.includes(encoding);
|
|
391
606
|
}
|
|
607
|
+
function parseContentEncodings(header) {
|
|
608
|
+
if (header === void 0) {
|
|
609
|
+
return [];
|
|
610
|
+
}
|
|
611
|
+
return header.split(",").map((part) => part.trim().toLowerCase());
|
|
612
|
+
}
|
|
613
|
+
|
|
392
614
|
class RetryLinkPlugin {
|
|
393
615
|
defaultRetry;
|
|
394
616
|
defaultRetryDelay;
|
|
@@ -484,13 +706,13 @@ class RetryLinkPlugin {
|
|
|
484
706
|
const meta = getEventMeta(error);
|
|
485
707
|
lastEventId = meta?.id ?? lastEventId;
|
|
486
708
|
lastEventRetry = meta?.retry ?? lastEventRetry;
|
|
487
|
-
const
|
|
488
|
-
if (!isAsyncIteratorObject(
|
|
489
|
-
throw new
|
|
490
|
-
"RetryLinkPlugin: Expected an
|
|
709
|
+
const asyncIteratorObject = await callNext({ error });
|
|
710
|
+
if (!isAsyncIteratorObject(asyncIteratorObject)) {
|
|
711
|
+
throw new TypeError(
|
|
712
|
+
"RetryLinkPlugin: Expected an AsyncIteratorObject, got a different type."
|
|
491
713
|
);
|
|
492
714
|
}
|
|
493
|
-
current =
|
|
715
|
+
current = asyncIteratorObject;
|
|
494
716
|
if (isIteratorAborted) {
|
|
495
717
|
await current.return?.();
|
|
496
718
|
throw error;
|
|
@@ -571,4 +793,4 @@ function parseRetryAfterHeader(value2) {
|
|
|
571
793
|
return void 0;
|
|
572
794
|
}
|
|
573
795
|
|
|
574
|
-
export { BatchLinkPlugin, BatchLinkPluginError, DedupeLinkPlugin, RetryAfterLinkPlugin, RetryLinkPlugin
|
|
796
|
+
export { BatchLinkPlugin, BatchLinkPluginError, DedupeLinkPlugin, RequestCompressionLinkPlugin, ResponseCompressionLinkPlugin, RetryAfterLinkPlugin, RetryLinkPlugin };
|
|
@@ -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.BBZBQID8.mjs';
|
|
4
4
|
|
|
5
5
|
type StandardLinkCodecDecodedResponse = {
|
|
6
6
|
kind: 'output';
|
|
@@ -163,5 +163,5 @@ interface ORPCErrorJSON<TCode extends string, TData> extends Pick<ORPCError<TCod
|
|
|
163
163
|
type AnyORPCError = ORPCError<any, any>;
|
|
164
164
|
type AnyORPCErrorJSON = ORPCErrorJSON<any, any>;
|
|
165
165
|
|
|
166
|
-
export { ORPCError as
|
|
167
|
-
export type { AnyORPCError as A, ClientContext as C, FriendlyClientOptions as F, InferClientContext as I, NestedClient as N, ORPCErrorCode as O, ClientOptions as a, ClientLink as b,
|
|
166
|
+
export { ORPCError as g, COMMON_ERROR_STATUS_MAP as j };
|
|
167
|
+
export type { AnyORPCError as A, ClientContext as C, FriendlyClientOptions as F, InferClientContext as I, NestedClient as N, ORPCErrorCode as O, ClientOptions as a, ClientLink as b, AnyNestedClient as c, InferClientError as d, Client as e, ClientRest as f, ORPCErrorJSON as h, AnyORPCErrorJSON as i, InferClientBodyInputs as k, InferClientBodyOutputs as l, InferClientErrors as m, InferClientInputs as n, InferClientOutputs as o, ORPCErrorOptions as p };
|
|
@@ -163,5 +163,5 @@ interface ORPCErrorJSON<TCode extends string, TData> extends Pick<ORPCError<TCod
|
|
|
163
163
|
type AnyORPCError = ORPCError<any, any>;
|
|
164
164
|
type AnyORPCErrorJSON = ORPCErrorJSON<any, any>;
|
|
165
165
|
|
|
166
|
-
export { ORPCError as
|
|
167
|
-
export type { AnyORPCError as A, ClientContext as C, FriendlyClientOptions as F, InferClientContext as I, NestedClient as N, ORPCErrorCode as O, ClientOptions as a, ClientLink as b,
|
|
166
|
+
export { ORPCError as g, COMMON_ERROR_STATUS_MAP as j };
|
|
167
|
+
export type { AnyORPCError as A, ClientContext as C, FriendlyClientOptions as F, InferClientContext as I, NestedClient as N, ORPCErrorCode as O, ClientOptions as a, ClientLink as b, AnyNestedClient as c, InferClientError as d, Client as e, ClientRest as f, ORPCErrorJSON as h, AnyORPCErrorJSON as i, InferClientBodyInputs as k, InferClientBodyOutputs as l, InferClientErrors as m, InferClientInputs as n, InferClientOutputs as o, ORPCErrorOptions as p };
|
|
@@ -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.BBZBQID8.js';
|
|
4
4
|
|
|
5
5
|
type StandardLinkCodecDecodedResponse = {
|
|
6
6
|
kind: 'output';
|
|
@@ -2,7 +2,7 @@ import { sortPlugins, runWithSpan, ORPC_NAME, isAsyncIteratorObject, override, t
|
|
|
2
2
|
import { mergeStandardHeaders, parseStandardUrl } from '@standardserver/core';
|
|
3
3
|
import { toStandardHeaders } from '@standardserver/fetch';
|
|
4
4
|
import { O as ORPCError } from './client.Dnfj8jnT.mjs';
|
|
5
|
-
import { R as RPCSerializer, i as isORPCErrorJson, c as createORPCErrorFromJson } from './client.
|
|
5
|
+
import { R as RPCSerializer, i as isORPCErrorJson, c as createORPCErrorFromJson } from './client.DqYwRDUO.mjs';
|
|
6
6
|
|
|
7
7
|
class CompositeStandardLinkPlugin {
|
|
8
8
|
name = "~composite";
|
|
@@ -38,7 +38,7 @@ class StandardLink {
|
|
|
38
38
|
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
39
39
|
span?.setAttribute("rpc.method", path.join("."));
|
|
40
40
|
if (isAsyncIteratorObject(input)) {
|
|
41
|
-
input = override(input, traceAsyncIterator("
|
|
41
|
+
input = override(input, traceAsyncIterator("consume_async_iterator_object_input", input));
|
|
42
42
|
}
|
|
43
43
|
return intercept(this.interceptors, { ...options, path, input }, async ({ path: path2, input: input2, ...options2 }) => {
|
|
44
44
|
const otel = getOpenTelemetryConfig();
|
|
@@ -80,7 +80,7 @@ class StandardLink {
|
|
|
80
80
|
}
|
|
81
81
|
const output = decodedResult.output;
|
|
82
82
|
if (isAsyncIteratorObject(output)) {
|
|
83
|
-
return override(output, traceAsyncIterator("
|
|
83
|
+
return override(output, traceAsyncIterator("consume_async_iterator_object_output", output));
|
|
84
84
|
}
|
|
85
85
|
return output;
|
|
86
86
|
});
|
|
@@ -139,7 +139,7 @@ class RPCLinkCodec {
|
|
|
139
139
|
};
|
|
140
140
|
}
|
|
141
141
|
async decodeResponse(response) {
|
|
142
|
-
const isOk = response.status
|
|
142
|
+
const isOk = response.status < 400;
|
|
143
143
|
const body = await response.resolveBody();
|
|
144
144
|
const deserialized = await (async () => {
|
|
145
145
|
try {
|
|
@@ -40,7 +40,7 @@ function cloneORPCError(error) {
|
|
|
40
40
|
return cloned;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
function
|
|
43
|
+
function wrapAsyncIteratorPreservingEventMeta(iterator, { mapResult, mapError, ...rest }) {
|
|
44
44
|
return wrapAsyncIterator(iterator, {
|
|
45
45
|
...rest,
|
|
46
46
|
mapResult: mapResult && (async (result) => {
|
|
@@ -271,7 +271,7 @@ class RPCSerializer {
|
|
|
271
271
|
return data;
|
|
272
272
|
}
|
|
273
273
|
if (isAsyncIteratorObject(data)) {
|
|
274
|
-
return
|
|
274
|
+
return wrapAsyncIteratorPreservingEventMeta(data, {
|
|
275
275
|
mapResult: (result) => {
|
|
276
276
|
if (result.value === void 0) {
|
|
277
277
|
return result;
|
|
@@ -304,7 +304,7 @@ class RPCSerializer {
|
|
|
304
304
|
return data;
|
|
305
305
|
}
|
|
306
306
|
if (isAsyncIteratorObject(data)) {
|
|
307
|
-
return
|
|
307
|
+
return wrapAsyncIteratorPreservingEventMeta(data, {
|
|
308
308
|
mapResult: (result) => {
|
|
309
309
|
if (result.value === void 0) {
|
|
310
310
|
return result;
|
|
@@ -340,4 +340,4 @@ class RPCSerializer {
|
|
|
340
340
|
}
|
|
341
341
|
}
|
|
342
342
|
|
|
343
|
-
export { RPCSerializer as R, isInferableError as a, RPCJsonSerializer as b, createORPCErrorFromJson as c, cloneORPCError as d, isORPCErrorJson as i, toORPCError as t,
|
|
343
|
+
export { RPCSerializer as R, isInferableError as a, RPCJsonSerializer as b, createORPCErrorFromJson as c, cloneORPCError as d, isORPCErrorJson as i, toORPCError as t, wrapAsyncIteratorPreservingEventMeta as w };
|
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.16",
|
|
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.0
|
|
54
|
-
"@standardserver/fetch": "^0.0
|
|
55
|
-
"@standardserver/peer": "^0.0
|
|
56
|
-
"@orpc/shared": "2.0.0-beta.
|
|
53
|
+
"@standardserver/core": "^0.2.0",
|
|
54
|
+
"@standardserver/fetch": "^0.2.0",
|
|
55
|
+
"@standardserver/peer": "^0.2.0",
|
|
56
|
+
"@orpc/shared": "2.0.0-beta.16"
|
|
57
57
|
},
|
|
58
58
|
"devDependencies": {
|
|
59
59
|
"zod": "^4.4.3"
|