@orpc/client 2.0.0-beta.2 → 2.0.0-beta.21

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.
@@ -1,14 +1,14 @@
1
- import { runWithSignal, AbortError, sleep, promiseWithResolvers, toStringOrBytes } from '@orpc/shared';
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.DXhchJ84.mjs';
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.DMXKFDyV.mjs';
7
+ import '../../shared/client.DqYwRDUO.mjs';
8
8
 
9
9
  const WEBSOCKET_CONNECTING = 0;
10
10
  const WEBSOCKET_OPEN = 1;
11
- class WebsocketLinkTransport {
11
+ class WebSocketLinkTransport {
12
12
  connect;
13
13
  reconnectEnabled;
14
14
  reconnectDelay;
@@ -71,13 +71,13 @@ class WebsocketLinkTransport {
71
71
  connectingResolvers?.resolve();
72
72
  });
73
73
  }
74
- websocket.addEventListener("message", async (event) => {
75
- const message = await toStringOrBytes(event.data);
74
+ websocket.addEventListener("message", sequential(async (event) => {
75
+ const message = event.data instanceof Blob ? await loadBytes(event.data) : toStringOrBytes(event.data);
76
76
  const result = decodePeerMessage(message, this.decodePeerMessageOptions);
77
77
  if (result.matched && isServerPeerSendMessage(result.message)) {
78
- await peer.message(result.message);
78
+ peer.message(result.message);
79
79
  }
80
- });
80
+ }));
81
81
  websocket.addEventListener("close", async (event) => {
82
82
  connectingResolvers?.resolve();
83
83
  if (this.reconnectOnCloseEnabled) {
@@ -102,9 +102,9 @@ class WebsocketLinkTransport {
102
102
  class RPCLink extends StandardLink {
103
103
  constructor(options) {
104
104
  const codec = new RPCLinkCodec(options);
105
- const transport = new WebsocketLinkTransport(options);
105
+ const transport = new WebSocketLinkTransport(options);
106
106
  super(codec, transport, options);
107
107
  }
108
108
  }
109
109
 
110
- export { RPCLink, WebsocketLinkTransport };
110
+ export { RPCLink, WebSocketLinkTransport };
package/dist/index.d.mts CHANGED
@@ -1,15 +1,11 @@
1
- import { O as ORPCErrorCode, c as ORPCError, d as ORPCErrorJSON, A as AnyORPCError, C as ClientContext, a as ClientOptions, e as AnyNestedClient, I as InferClientContext, f as InferClientError, g as Client, b as ClientLink, h as ClientRest, F as FriendlyClientOptions } from './shared/client.8ug8I-zu.mjs';
2
- 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.8ug8I-zu.mjs';
3
- import { Interceptor, PromiseWithError, ThrowableError, Promisable, WrapAsyncIteratorOptions, AsyncIteratorClass } from '@orpc/shared';
4
- export { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, Registry, ThrowableError, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
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
- export { ErrorEvent, getEventMeta, unwrapEvent, withEventMeta } from '@standardserver/core';
6
+ export { ErrorEvent, EventMeta, getEventMeta, unwrapEvent, withEventMeta } from '@standardserver/core';
7
7
 
8
- declare function isInferableError<T>(error: T): error is Extract<T, AnyORPCError>;
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 wrapEventIteratorPreservingMeta<TYield, TReturn, TMappedYield = TYield, TMappedReturn = TReturn>(iterator: AsyncIterator<TYield, TReturn>, { mapResult, mapError, ...rest }: WrapAsyncIteratorOptions<TYield, TReturn, TMappedYield, TMappedReturn>): AsyncIteratorClass<TMappedYield, TMappedReturn>;
148
-
149
- /**
150
- * @deprecated Use `isInferableError` instead.
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, consumeEventIterator, createORPCClient, createORPCErrorFromJson, createSafeClient, isDefinedError, isInferableError, isORPCErrorJson, resolveClientRest, resolveFriendlyClientOptions, safe, toORPCError, wrapEventIteratorPreservingMeta };
155
- export type { ConsumeEventIteratorOptions, ORPCClientInterceptor, ORPCClientInterceptorOptions, ORPCClientOptions, ORPCClientScoped, ORPCClientScopedOptions, SafeClient, SafeResult };
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 { O as ORPCErrorCode, c as ORPCError, d as ORPCErrorJSON, A as AnyORPCError, C as ClientContext, a as ClientOptions, e as AnyNestedClient, I as InferClientContext, f as InferClientError, g as Client, b as ClientLink, h as ClientRest, F as FriendlyClientOptions } from './shared/client.8ug8I-zu.js';
2
- 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.8ug8I-zu.js';
3
- import { Interceptor, PromiseWithError, ThrowableError, Promisable, WrapAsyncIteratorOptions, AsyncIteratorClass } from '@orpc/shared';
4
- export { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, Registry, ThrowableError, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
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
- export { ErrorEvent, getEventMeta, unwrapEvent, withEventMeta } from '@standardserver/core';
6
+ export { ErrorEvent, EventMeta, getEventMeta, unwrapEvent, withEventMeta } from '@standardserver/core';
7
7
 
8
- declare function isInferableError<T>(error: T): error is Extract<T, AnyORPCError>;
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 wrapEventIteratorPreservingMeta<TYield, TReturn, TMappedYield = TYield, TMappedReturn = TReturn>(iterator: AsyncIterator<TYield, TReturn>, { mapResult, mapError, ...rest }: WrapAsyncIteratorOptions<TYield, TReturn, TMappedYield, TMappedReturn>): AsyncIteratorClass<TMappedYield, TMappedReturn>;
148
-
149
- /**
150
- * @deprecated Use `isInferableError` instead.
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, consumeEventIterator, createORPCClient, createORPCErrorFromJson, createSafeClient, isDefinedError, isInferableError, isORPCErrorJson, resolveClientRest, resolveFriendlyClientOptions, safe, toORPCError, wrapEventIteratorPreservingMeta };
155
- export type { ConsumeEventIteratorOptions, ORPCClientInterceptor, ORPCClientInterceptorOptions, ORPCClientOptions, ORPCClientScoped, ORPCClientScopedOptions, SafeClient, SafeResult };
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.DMXKFDyV.mjs';
2
- export { b as RPCJsonSerializer, R as RPCSerializer, d as cloneORPCError, c as createORPCErrorFromJson, i as isORPCErrorJson, t as toORPCError, w as wrapEventIteratorPreservingMeta } from './shared/client.DMXKFDyV.mjs';
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, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
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
- const isDefinedError = isInferableError;
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 };
@@ -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.8ug8I-zu.mjs';
4
- import { c as StandardLinkPlugin, d as StandardLinkTransportInterceptorOptions, b as StandardLinkOptions, e as StandardLinkInterceptorOptions } from '../shared/client.Cby_-GGh.mjs';
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 event iterators).
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,28 @@ 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, RetryLinkPluginInvalidEventIteratorRetryResponse };
242
- export type { BatchLinkPluginGroup, BatchLinkPluginMode, BatchLinkPluginOptions, DedupeLinkPluginGroup, DedupeLinkPluginOptions, RetryAfterLinkPluginOptions, RetryLinkPluginAttemptOptions, RetryLinkPluginContext, RetryLinkPluginOptions };
294
+ interface TimeoutLinkPluginOptions<T extends ClientContext> {
295
+ /**
296
+ * Timeout in milliseconds before the request is aborted.
297
+ * Use `null` or `undefined` to disable the timeout.
298
+ */
299
+ timeout: Value<number | null | undefined, [options: StandardLinkInterceptorOptions<T>]>;
300
+ }
301
+ /**
302
+ * The Timeout Link Plugin aborts requests that exceed a configured timeout with an `AbortError`.
303
+ *
304
+ * @see {@link https://orpc.dev/docs/plugins/timeout Timeout Plugin Docs}
305
+ */
306
+ declare class TimeoutLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
307
+ private readonly timeout;
308
+ name: string;
309
+ /**
310
+ * Should abort if the total retry time exceeds the configured timeout
311
+ */
312
+ after: string[];
313
+ constructor(options: NoInfer<TimeoutLinkPluginOptions<T>>);
314
+ init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
315
+ }
316
+
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 };
@@ -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.8ug8I-zu.js';
4
- import { c as StandardLinkPlugin, d as StandardLinkTransportInterceptorOptions, b as StandardLinkOptions, e as StandardLinkInterceptorOptions } from '../shared/client.CPF3hX6O.js';
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 event iterators).
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,28 @@ 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, RetryLinkPluginInvalidEventIteratorRetryResponse };
242
- export type { BatchLinkPluginGroup, BatchLinkPluginMode, BatchLinkPluginOptions, DedupeLinkPluginGroup, DedupeLinkPluginOptions, RetryAfterLinkPluginOptions, RetryLinkPluginAttemptOptions, RetryLinkPluginContext, RetryLinkPluginOptions };
294
+ interface TimeoutLinkPluginOptions<T extends ClientContext> {
295
+ /**
296
+ * Timeout in milliseconds before the request is aborted.
297
+ * Use `null` or `undefined` to disable the timeout.
298
+ */
299
+ timeout: Value<number | null | undefined, [options: StandardLinkInterceptorOptions<T>]>;
300
+ }
301
+ /**
302
+ * The Timeout Link Plugin aborts requests that exceed a configured timeout with an `AbortError`.
303
+ *
304
+ * @see {@link https://orpc.dev/docs/plugins/timeout Timeout Plugin Docs}
305
+ */
306
+ declare class TimeoutLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
307
+ private readonly timeout;
308
+ name: string;
309
+ /**
310
+ * Should abort if the total retry time exceeds the configured timeout
311
+ */
312
+ after: string[];
313
+ constructor(options: NoInfer<TimeoutLinkPluginOptions<T>>);
314
+ init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
315
+ }
316
+
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 };