@orpc/client 2.0.0-beta.44 → 2.0.0-beta.45
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 +55 -48
- package/dist/adapters/fetch/index.d.mts +3 -3
- package/dist/adapters/fetch/index.d.ts +3 -3
- package/dist/adapters/fetch/index.mjs +3 -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 +3 -3
- package/dist/adapters/standard/index.d.mts +8 -8
- package/dist/adapters/standard/index.d.ts +8 -8
- package/dist/adapters/standard/index.mjs +3 -3
- package/dist/adapters/websocket/index.d.mts +9 -9
- package/dist/adapters/websocket/index.d.ts +9 -9
- package/dist/adapters/websocket/index.mjs +3 -3
- package/dist/index.d.mts +8 -8
- package/dist/index.d.ts +8 -8
- package/dist/index.mjs +3 -3
- package/dist/plugins/index.d.mts +51 -38
- package/dist/plugins/index.d.ts +51 -38
- package/dist/plugins/index.mjs +15 -8
- package/dist/shared/{client.DZHZRyR6.d.mts → client.BoHJeq15.d.mts} +30 -12
- package/dist/shared/{client.DZHZRyR6.d.ts → client.BoHJeq15.d.ts} +30 -12
- package/dist/shared/{client.B7P_ugvl.mjs → client.Bpyj1NM2.mjs} +8 -3
- package/dist/shared/{client.BzAY7ZC2.d.mts → client.CkwtFnrc.d.mts} +4 -4
- package/dist/shared/{client.CHH2CNMj.d.ts → client.DBDKICdk.d.ts} +4 -4
- package/dist/shared/{client.BPa_Mmuh.d.mts → client.DqIWeNhQ.d.mts} +7 -8
- package/dist/shared/{client.BPa_Mmuh.d.ts → client.DqIWeNhQ.d.ts} +7 -8
- package/dist/shared/{client.CrHurHrq.mjs → client.LF04eOvL.mjs} +10 -4
- package/dist/shared/{client.BLfXUpyF.mjs → client._wG5INmC.mjs} +16 -17
- package/package.json +6 -6
package/dist/index.d.mts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { WrapAsyncIteratorOptions, AsyncIteratorClass, Interceptor, PromiseWithError, ThrowableError, Promisable } from '@orpc/shared';
|
|
2
2
|
export { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, PromiseWithError as ClientPromiseResult, MaybeOptionalOptions, PromiseWithError, Registry, ThrowableError, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, consumeAsyncIterator, consumeAsyncIterator as consumeEventIterator, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject, streamToAsyncIteratorObject as streamToEventIterator } from '@orpc/shared';
|
|
3
|
-
import { C as ClientContext, a as ClientOptions, c as AnyNestedClient, I as InferClientContext, d as InferClientError, e as Client, b as ClientLink, A as AnyORPCError, f as ClientRest, F as FriendlyClientOptions, O as ORPCErrorCode, g as ORPCErrorJSON, h as ORPCError } from './shared/client.
|
|
4
|
-
export { i as AnyORPCErrorJSON, j as COMMON_ERROR_STATUS_MAP, k as InferClientBodyInputs, l as InferClientBodyOutputs, m as InferClientErrors, n as InferClientInputs, o as InferClientOutputs, M as MalformedResponseError, p as MalformedResponseErrorOptions, N as NestedClient, q as ORPCErrorOptions } from './shared/client.
|
|
5
|
-
export { R as RPCJsonSerialization, a as RPCJsonSerializationMeta, b as RPCJsonSerializer, c as RPCJsonSerializerHandler, d as RPCJsonSerializerOptions, e as RPCSerializer, f as RPCSerializerOptions, g as RPCSerializerSerializeOptions } from './shared/client.
|
|
3
|
+
import { C as ClientContext, a as ClientOptions, c as AnyNestedClient, I as InferClientContext, d as InferClientError, e as Client, b as ClientLink, A as AnyORPCError, f as ClientRest, F as FriendlyClientOptions, O as ORPCErrorCode, g as ORPCErrorJSON, h as ORPCError } from './shared/client.BoHJeq15.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, M as MalformedResponseError, p as MalformedResponseErrorOptions, N as NestedClient, q as ORPCErrorOptions, R as ResponseError, r as ResponseErrorOptions } from './shared/client.BoHJeq15.mjs';
|
|
5
|
+
export { R as RPCJsonSerialization, a as RPCJsonSerializationMeta, b as RPCJsonSerializer, c as RPCJsonSerializerHandler, d as RPCJsonSerializerOptions, e as RPCSerializer, f as RPCSerializerOptions, g as RPCSerializerSerializeOptions } from './shared/client.DqIWeNhQ.mjs';
|
|
6
6
|
export { ErrorEvent, EventMeta, StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl, getEventMeta, unwrapEvent, withEventMeta } from '@standard-server/core';
|
|
7
7
|
|
|
8
8
|
declare function wrapAsyncIteratorPreservingEventMeta<TYield, TReturn, TMappedYield = TYield, TMappedReturn = TReturn>(iterator: AsyncIterator<TYield, TReturn>, { mapResult, mapError, ...rest }: WrapAsyncIteratorOptions<TYield, TReturn, TMappedYield, TMappedReturn>): AsyncIteratorClass<TMappedYield, TMappedReturn>;
|
|
@@ -16,26 +16,26 @@ interface ORPCClientScopedOptions<TClientContext extends ClientContext, TInput,
|
|
|
16
16
|
/**
|
|
17
17
|
* Interceptors that wrap the entire client call lifecycle.
|
|
18
18
|
*/
|
|
19
|
-
interceptors?: ORPCClientInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
19
|
+
interceptors?: ORPCClientInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
20
20
|
}
|
|
21
21
|
type ORPCClientScoped<T extends AnyNestedClient> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ORPCClientScopedOptions<UClientContext, UInput, UOutput, UError> : {
|
|
22
|
-
[K in keyof T]?: T[K] extends AnyNestedClient ? ORPCClientScoped<T[K]> : never;
|
|
22
|
+
[K in keyof T]?: (T[K] extends AnyNestedClient ? ORPCClientScoped<T[K]> : never) | undefined;
|
|
23
23
|
};
|
|
24
24
|
interface ORPCClientOptions<T extends AnyNestedClient> {
|
|
25
25
|
/**
|
|
26
26
|
* Use as base path for all procedure, useful when you only want to call a subset of the procedure.
|
|
27
27
|
*/
|
|
28
|
-
path?: string[];
|
|
28
|
+
path?: string[] | undefined;
|
|
29
29
|
/**
|
|
30
30
|
* Interceptors that wrap the entire client call lifecycle, applied to every procedure call.
|
|
31
31
|
*/
|
|
32
|
-
interceptors?: ORPCClientInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
32
|
+
interceptors?: ORPCClientInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
|
|
33
33
|
/**
|
|
34
34
|
* Per-procedure options following the shape of the router.
|
|
35
35
|
* Allows fine-grained configuration (e.g. additional interceptors) for individual procedures
|
|
36
36
|
* without affecting the rest of the router.
|
|
37
37
|
*/
|
|
38
|
-
scoped?: ORPCClientScoped<T
|
|
38
|
+
scoped?: ORPCClientScoped<T> | undefined;
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Creates a fully typed oRPC client from a link.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { WrapAsyncIteratorOptions, AsyncIteratorClass, Interceptor, PromiseWithError, ThrowableError, Promisable } from '@orpc/shared';
|
|
2
2
|
export { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, PromiseWithError as ClientPromiseResult, MaybeOptionalOptions, PromiseWithError, Registry, ThrowableError, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, consumeAsyncIterator, consumeAsyncIterator as consumeEventIterator, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject, streamToAsyncIteratorObject as streamToEventIterator } from '@orpc/shared';
|
|
3
|
-
import { C as ClientContext, a as ClientOptions, c as AnyNestedClient, I as InferClientContext, d as InferClientError, e as Client, b as ClientLink, A as AnyORPCError, f as ClientRest, F as FriendlyClientOptions, O as ORPCErrorCode, g as ORPCErrorJSON, h as ORPCError } from './shared/client.
|
|
4
|
-
export { i as AnyORPCErrorJSON, j as COMMON_ERROR_STATUS_MAP, k as InferClientBodyInputs, l as InferClientBodyOutputs, m as InferClientErrors, n as InferClientInputs, o as InferClientOutputs, M as MalformedResponseError, p as MalformedResponseErrorOptions, N as NestedClient, q as ORPCErrorOptions } from './shared/client.
|
|
5
|
-
export { R as RPCJsonSerialization, a as RPCJsonSerializationMeta, b as RPCJsonSerializer, c as RPCJsonSerializerHandler, d as RPCJsonSerializerOptions, e as RPCSerializer, f as RPCSerializerOptions, g as RPCSerializerSerializeOptions } from './shared/client.
|
|
3
|
+
import { C as ClientContext, a as ClientOptions, c as AnyNestedClient, I as InferClientContext, d as InferClientError, e as Client, b as ClientLink, A as AnyORPCError, f as ClientRest, F as FriendlyClientOptions, O as ORPCErrorCode, g as ORPCErrorJSON, h as ORPCError } from './shared/client.BoHJeq15.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, M as MalformedResponseError, p as MalformedResponseErrorOptions, N as NestedClient, q as ORPCErrorOptions, R as ResponseError, r as ResponseErrorOptions } from './shared/client.BoHJeq15.js';
|
|
5
|
+
export { R as RPCJsonSerialization, a as RPCJsonSerializationMeta, b as RPCJsonSerializer, c as RPCJsonSerializerHandler, d as RPCJsonSerializerOptions, e as RPCSerializer, f as RPCSerializerOptions, g as RPCSerializerSerializeOptions } from './shared/client.DqIWeNhQ.js';
|
|
6
6
|
export { ErrorEvent, EventMeta, StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl, getEventMeta, unwrapEvent, withEventMeta } from '@standard-server/core';
|
|
7
7
|
|
|
8
8
|
declare function wrapAsyncIteratorPreservingEventMeta<TYield, TReturn, TMappedYield = TYield, TMappedReturn = TReturn>(iterator: AsyncIterator<TYield, TReturn>, { mapResult, mapError, ...rest }: WrapAsyncIteratorOptions<TYield, TReturn, TMappedYield, TMappedReturn>): AsyncIteratorClass<TMappedYield, TMappedReturn>;
|
|
@@ -16,26 +16,26 @@ interface ORPCClientScopedOptions<TClientContext extends ClientContext, TInput,
|
|
|
16
16
|
/**
|
|
17
17
|
* Interceptors that wrap the entire client call lifecycle.
|
|
18
18
|
*/
|
|
19
|
-
interceptors?: ORPCClientInterceptor<TClientContext, TInput, TOutput, TError>[];
|
|
19
|
+
interceptors?: ORPCClientInterceptor<TClientContext, TInput, TOutput, TError>[] | undefined;
|
|
20
20
|
}
|
|
21
21
|
type ORPCClientScoped<T extends AnyNestedClient> = T extends Client<infer UClientContext, infer UInput, infer UOutput, infer UError> ? ORPCClientScopedOptions<UClientContext, UInput, UOutput, UError> : {
|
|
22
|
-
[K in keyof T]?: T[K] extends AnyNestedClient ? ORPCClientScoped<T[K]> : never;
|
|
22
|
+
[K in keyof T]?: (T[K] extends AnyNestedClient ? ORPCClientScoped<T[K]> : never) | undefined;
|
|
23
23
|
};
|
|
24
24
|
interface ORPCClientOptions<T extends AnyNestedClient> {
|
|
25
25
|
/**
|
|
26
26
|
* Use as base path for all procedure, useful when you only want to call a subset of the procedure.
|
|
27
27
|
*/
|
|
28
|
-
path?: string[];
|
|
28
|
+
path?: string[] | undefined;
|
|
29
29
|
/**
|
|
30
30
|
* Interceptors that wrap the entire client call lifecycle, applied to every procedure call.
|
|
31
31
|
*/
|
|
32
|
-
interceptors?: ORPCClientInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[];
|
|
32
|
+
interceptors?: ORPCClientInterceptor<InferClientContext<T>, unknown, unknown, InferClientError<T>>[] | undefined;
|
|
33
33
|
/**
|
|
34
34
|
* Per-procedure options following the shape of the router.
|
|
35
35
|
* Allows fine-grained configuration (e.g. additional interceptors) for individual procedures
|
|
36
36
|
* without affecting the rest of the router.
|
|
37
37
|
*/
|
|
38
|
-
scoped?: ORPCClientScoped<T
|
|
38
|
+
scoped?: ORPCClientScoped<T> | undefined;
|
|
39
39
|
}
|
|
40
40
|
/**
|
|
41
41
|
* Creates a fully typed oRPC client from a link.
|
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as isDefinedError } from './shared/client.
|
|
2
|
-
export { b as RPCJsonSerializer, R as RPCSerializer, d as cloneORPCError, c as createORPCErrorFromJson, i as isORPCErrorJson, t as toORPCError, w as wrapAsyncIteratorPreservingEventMeta } from './shared/client.
|
|
1
|
+
import { a as isDefinedError } from './shared/client._wG5INmC.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._wG5INmC.mjs';
|
|
3
3
|
import { toArray, intercept, isTypescriptObject } from '@orpc/shared';
|
|
4
4
|
export { AsyncIteratorClass, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, consumeAsyncIterator, consumeAsyncIterator as consumeEventIterator, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject, streamToAsyncIteratorObject as streamToEventIterator } from '@orpc/shared';
|
|
5
|
-
export { C as COMMON_ERROR_STATUS_MAP, M as MalformedResponseError, O as ORPCError } from './shared/client.
|
|
5
|
+
export { C as COMMON_ERROR_STATUS_MAP, M as MalformedResponseError, O as ORPCError, R as ResponseError } from './shared/client.LF04eOvL.mjs';
|
|
6
6
|
export { ErrorEvent, getEventMeta, unwrapEvent, withEventMeta } from '@standard-server/core';
|
|
7
7
|
|
|
8
8
|
const RECURSIVE_CLIENT_UNWRAP_KEYS = /* @__PURE__ */ new Set([
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -3,7 +3,19 @@ import { StandardUrl, StandardHeaders, StandardRequest, StandardLazyResponse } f
|
|
|
3
3
|
import { ClientContext } from '../index.mjs';
|
|
4
4
|
import { StandardLinkPlugin, StandardLinkTransportInterceptorOptions, StandardLinkOptions, StandardLinkInterceptorOptions } from '../adapters/standard/index.mjs';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Header that marks a request as a batch, set by the Batch Link Plugin and detected by the Batch Handler Plugin.
|
|
8
|
+
* Nothing between the client and server, such as a CORS policy or proxy, should block or strip it.
|
|
9
|
+
*
|
|
10
|
+
* @see {@link https://orpc.dev/docs/plugins/batch#setup | Batch Plugin - Setup}
|
|
11
|
+
*/
|
|
12
|
+
declare const BATCH_HEADER = "orpc-batch";
|
|
13
|
+
/**
|
|
14
|
+
* Default `maxSize` of both the Batch Link Plugin and the Batch Handler Plugin.
|
|
15
|
+
*
|
|
16
|
+
* @see {@link https://orpc.dev/docs/plugins/batch#max-size | Batch Plugin - Max Size}
|
|
17
|
+
*/
|
|
18
|
+
declare const DEFAULT_BATCH_MAX_SIZE = 10;
|
|
7
19
|
interface BatchLinkPluginGroup<T extends ClientContext> {
|
|
8
20
|
/**
|
|
9
21
|
* Determines whether a request should be included in this batch group.
|
|
@@ -21,7 +33,7 @@ interface BatchLinkPluginGroup<T extends ClientContext> {
|
|
|
21
33
|
*
|
|
22
34
|
* @default []
|
|
23
35
|
*/
|
|
24
|
-
path?: Value<string[], [items: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]
|
|
36
|
+
path?: Value<string[], [items: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]> | undefined;
|
|
25
37
|
}
|
|
26
38
|
interface BatchLinkPluginOptions<T extends ClientContext> {
|
|
27
39
|
groups: [BatchLinkPluginGroup<T>, ...BatchLinkPluginGroup<T>[]];
|
|
@@ -30,20 +42,22 @@ interface BatchLinkPluginOptions<T extends ClientContext> {
|
|
|
30
42
|
*
|
|
31
43
|
* @default () => true
|
|
32
44
|
*/
|
|
33
|
-
filter?: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]
|
|
45
|
+
filter?: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]> | undefined;
|
|
34
46
|
/**
|
|
35
47
|
* Only requests with the same scope are batched together.
|
|
36
48
|
* On the server, return a value unique to the incoming request so different users never share a batch.
|
|
37
49
|
*
|
|
38
50
|
* @default () => undefined
|
|
39
51
|
*/
|
|
40
|
-
scope?: (options: StandardLinkTransportInterceptorOptions<T>) => unknown;
|
|
52
|
+
scope?: ((options: StandardLinkTransportInterceptorOptions<T>) => unknown) | undefined;
|
|
41
53
|
/**
|
|
42
|
-
* The maximum number of requests in the batch.
|
|
54
|
+
* The maximum number of requests in the batch. Larger batches are split.
|
|
55
|
+
* Keep it at or below the server Batch Handler Plugin's `maxSize`, which rejects larger batches with a `413`.
|
|
43
56
|
*
|
|
44
|
-
* @default 10
|
|
57
|
+
* @default DEFAULT_BATCH_MAX_SIZE (10)
|
|
58
|
+
* @see {@link https://orpc.dev/docs/plugins/batch#max-size | Batch Plugin - Max Size}
|
|
45
59
|
*/
|
|
46
|
-
maxSize?: Value<Promisable<number>, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]
|
|
60
|
+
maxSize?: Value<Promisable<number>, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]> | undefined;
|
|
47
61
|
/**
|
|
48
62
|
* How long (in ms) to wait for more requests before sending the batch,
|
|
49
63
|
* counted from the first queued request.
|
|
@@ -51,20 +65,13 @@ interface BatchLinkPluginOptions<T extends ClientContext> {
|
|
|
51
65
|
*
|
|
52
66
|
* @default 0
|
|
53
67
|
*/
|
|
54
|
-
wait?: number;
|
|
55
|
-
/**
|
|
56
|
-
* The batch response mode.
|
|
57
|
-
* A `buffered` batch still streams once a procedure in it returns a stream.
|
|
58
|
-
*
|
|
59
|
-
* @default 'streaming'
|
|
60
|
-
*/
|
|
61
|
-
mode?: Value<BatchLinkPluginMode, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]>;
|
|
68
|
+
wait?: number | undefined;
|
|
62
69
|
/**
|
|
63
70
|
* URL for the batch request.
|
|
64
71
|
*
|
|
65
72
|
* @default URL of the first subrequest in the batch + '/__batch__'
|
|
66
73
|
*/
|
|
67
|
-
url?: Value<Promisable<StandardUrl>, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]
|
|
74
|
+
url?: Value<Promisable<StandardUrl>, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]> | undefined;
|
|
68
75
|
/**
|
|
69
76
|
* The maximum length of the URL that runtime supports,
|
|
70
77
|
* if exceeded, the batch will be split into smaller batches and sent sequentially.
|
|
@@ -73,25 +80,25 @@ interface BatchLinkPluginOptions<T extends ClientContext> {
|
|
|
73
80
|
*
|
|
74
81
|
* @default 2083
|
|
75
82
|
*/
|
|
76
|
-
maxUrlLength?: Value<Promisable<number>, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]
|
|
83
|
+
maxUrlLength?: Value<Promisable<number>, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]> | undefined;
|
|
77
84
|
/**
|
|
78
85
|
* Headers used for the batch request.
|
|
79
86
|
*
|
|
80
87
|
* @default Common headers among all subrequests in the batch.
|
|
81
88
|
*/
|
|
82
|
-
headers?: Value<Promisable<StandardHeaders>, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]
|
|
89
|
+
headers?: Value<Promisable<StandardHeaders>, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]> | undefined;
|
|
83
90
|
/**
|
|
84
91
|
* Map each subrequest in the batch before it is sent.
|
|
85
92
|
*
|
|
86
93
|
* @default Removes headers that are duplicated with the batch headers
|
|
87
94
|
*/
|
|
88
|
-
mapSubrequest?: (subOptions: StandardLinkTransportInterceptorOptions<T>, partialBatchRequest: Pick<StandardRequest, 'url' | 'headers'>) => StandardRequest;
|
|
95
|
+
mapSubrequest?: ((subOptions: StandardLinkTransportInterceptorOptions<T>, partialBatchRequest: Pick<StandardRequest, 'url' | 'headers'>) => StandardRequest) | undefined;
|
|
89
96
|
/**
|
|
90
97
|
* Maps each subresponse before returning the final response.
|
|
91
98
|
*
|
|
92
99
|
* @default Low-priority merges headers from the batch response into each subresponse.
|
|
93
100
|
*/
|
|
94
|
-
mapSubresponse?: (subResponse: StandardLazyResponse, batchResponse: StandardLazyResponse, subOptions: StandardLinkTransportInterceptorOptions<T>) => StandardLazyResponse;
|
|
101
|
+
mapSubresponse?: ((subResponse: StandardLazyResponse, batchResponse: StandardLazyResponse, subOptions: StandardLinkTransportInterceptorOptions<T>) => StandardLazyResponse) | undefined;
|
|
95
102
|
}
|
|
96
103
|
/**
|
|
97
104
|
* Combines multiple client requests into a single batch request
|
|
@@ -109,7 +116,6 @@ declare class BatchLinkPlugin<T extends ClientContext> implements StandardLinkPl
|
|
|
109
116
|
private readonly scope;
|
|
110
117
|
private readonly maxSize;
|
|
111
118
|
private readonly wait;
|
|
112
|
-
private readonly mode;
|
|
113
119
|
private readonly batchUrl;
|
|
114
120
|
private readonly maxUrlLength;
|
|
115
121
|
private readonly batchHeaders;
|
|
@@ -152,14 +158,14 @@ interface DedupeLinkPluginOptions<T extends ClientContext> {
|
|
|
152
158
|
*
|
|
153
159
|
* @default ({ request }) => request.method === 'GET' || request.method === 'QUERY'
|
|
154
160
|
*/
|
|
155
|
-
filter?: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]
|
|
161
|
+
filter?: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]> | undefined;
|
|
156
162
|
/**
|
|
157
163
|
* Only requests with the same scope are deduplicated together.
|
|
158
164
|
* On the server, return a value unique to the incoming request so different users never share a response.
|
|
159
165
|
*
|
|
160
166
|
* @default () => undefined
|
|
161
167
|
*/
|
|
162
|
-
scope?: (options: StandardLinkTransportInterceptorOptions<T>) => unknown;
|
|
168
|
+
scope?: ((options: StandardLinkTransportInterceptorOptions<T>) => unknown) | undefined;
|
|
163
169
|
/**
|
|
164
170
|
* How long (in ms) to wait for more identical requests before sending,
|
|
165
171
|
* counted from the first queued request.
|
|
@@ -167,7 +173,7 @@ interface DedupeLinkPluginOptions<T extends ClientContext> {
|
|
|
167
173
|
*
|
|
168
174
|
* @default 0
|
|
169
175
|
*/
|
|
170
|
-
wait?: number;
|
|
176
|
+
wait?: number | undefined;
|
|
171
177
|
}
|
|
172
178
|
/**
|
|
173
179
|
* Prevents redundant requests by deduplicating similar in-flight requests,
|
|
@@ -196,7 +202,7 @@ interface RequestCompressionLinkPluginOptions<T extends ClientContext> {
|
|
|
196
202
|
*
|
|
197
203
|
* @default 'gzip'
|
|
198
204
|
*/
|
|
199
|
-
encoding?: 'gzip' | 'deflate' | 'deflate-raw';
|
|
205
|
+
encoding?: 'gzip' | 'deflate' | 'deflate-raw' | undefined;
|
|
200
206
|
/**
|
|
201
207
|
* The minimum request size in bytes required to trigger compression.
|
|
202
208
|
* Requests smaller than this threshold will not be compressed to avoid overhead.
|
|
@@ -204,7 +210,7 @@ interface RequestCompressionLinkPluginOptions<T extends ClientContext> {
|
|
|
204
210
|
*
|
|
205
211
|
* @default 1024 (1KB)
|
|
206
212
|
*/
|
|
207
|
-
threshold?: number;
|
|
213
|
+
threshold?: number | undefined;
|
|
208
214
|
/**
|
|
209
215
|
* Determines whether a request with the given Content-Type should be compressed.
|
|
210
216
|
* Only consulted for binary transfers (streams, files, and file form-data parts).
|
|
@@ -212,7 +218,7 @@ interface RequestCompressionLinkPluginOptions<T extends ClientContext> {
|
|
|
212
218
|
*
|
|
213
219
|
* @default isCompressibleContentType (covers common text-based formats)
|
|
214
220
|
*/
|
|
215
|
-
isCompressibleContentType?: (contentType: string | null | undefined, options: StandardLinkTransportInterceptorOptions<T>) => boolean;
|
|
221
|
+
isCompressibleContentType?: ((contentType: string | null | undefined, options: StandardLinkTransportInterceptorOptions<T>) => boolean) | undefined;
|
|
216
222
|
}
|
|
217
223
|
/**
|
|
218
224
|
* Compresses request bodies before sending them to the server,
|
|
@@ -240,7 +246,7 @@ interface ResponseCompressionLinkPluginOptions<_T extends ClientContext> {
|
|
|
240
246
|
*
|
|
241
247
|
* @default ['gzip', 'deflate']
|
|
242
248
|
*/
|
|
243
|
-
encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[];
|
|
249
|
+
encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[] | undefined;
|
|
244
250
|
}
|
|
245
251
|
/**
|
|
246
252
|
* Advertises Accept-Encoding on requests and decompresses response bodies
|
|
@@ -287,7 +293,7 @@ interface RetryLinkPluginContext {
|
|
|
287
293
|
*
|
|
288
294
|
* @default 0
|
|
289
295
|
*/
|
|
290
|
-
retry?: Value<Promisable<number>, [Omit<StandardLinkInterceptorOptions<RetryLinkPluginContext>, 'next'>]
|
|
296
|
+
retry?: Value<Promisable<number>, [Omit<StandardLinkInterceptorOptions<RetryLinkPluginContext>, 'next'>]> | undefined;
|
|
291
297
|
/**
|
|
292
298
|
* Delay (in ms) before retrying.
|
|
293
299
|
*
|
|
@@ -296,17 +302,17 @@ interface RetryLinkPluginContext {
|
|
|
296
302
|
*
|
|
297
303
|
* @default (o) => o.lastEventRetry ?? 2000
|
|
298
304
|
*/
|
|
299
|
-
retryDelay?: Value<Promisable<number>, [RetryLinkPluginAttemptOptions<RetryLinkPluginContext>]
|
|
305
|
+
retryDelay?: Value<Promisable<number>, [RetryLinkPluginAttemptOptions<RetryLinkPluginContext>]> | undefined;
|
|
300
306
|
/**
|
|
301
307
|
* Determine whether to retry.
|
|
302
308
|
*
|
|
303
|
-
* @default
|
|
309
|
+
* @default (o) => isRetryableError(o.error)
|
|
304
310
|
*/
|
|
305
|
-
shouldRetry?: Value<Promisable<boolean>, [RetryLinkPluginAttemptOptions<RetryLinkPluginContext>]
|
|
311
|
+
shouldRetry?: Value<Promisable<boolean>, [RetryLinkPluginAttemptOptions<RetryLinkPluginContext>]> | undefined;
|
|
306
312
|
/**
|
|
307
313
|
* Hook called before each retry. Can return a cleanup callback.
|
|
308
314
|
*/
|
|
309
|
-
onRetry?: (options: RetryLinkPluginAttemptOptions<RetryLinkPluginContext>) => void | ((isSuccess: boolean) => void);
|
|
315
|
+
onRetry?: ((options: RetryLinkPluginAttemptOptions<RetryLinkPluginContext>) => void | ((isSuccess: boolean) => void)) | undefined;
|
|
310
316
|
}
|
|
311
317
|
interface RetryLinkPluginOptions<_T extends RetryLinkPluginContext> {
|
|
312
318
|
/**
|
|
@@ -314,6 +320,13 @@ interface RetryLinkPluginOptions<_T extends RetryLinkPluginContext> {
|
|
|
314
320
|
*/
|
|
315
321
|
default?: RetryLinkPluginContext | undefined;
|
|
316
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* Default `shouldRetry` check of `RetryLinkPlugin`. Returns `false` only for errors
|
|
325
|
+
* from a 4xx response other than `408` and `429`.
|
|
326
|
+
*
|
|
327
|
+
* @see {@link https://orpc.dev/docs/plugins/retry#client-error-responses | Retry Plugin - Client Error Responses}
|
|
328
|
+
*/
|
|
329
|
+
declare function isRetryableError(error: unknown): boolean;
|
|
317
330
|
/**
|
|
318
331
|
* Automatically retries failed requests based on customizable retry strategies,
|
|
319
332
|
* improving the resilience of your application.
|
|
@@ -342,7 +355,7 @@ interface RetryAfterLinkPluginOptions<T extends ClientContext> {
|
|
|
342
355
|
condition?: Value<boolean, [
|
|
343
356
|
response: StandardLazyResponse,
|
|
344
357
|
options: StandardLinkTransportInterceptorOptions<T>
|
|
345
|
-
]
|
|
358
|
+
]> | undefined;
|
|
346
359
|
/**
|
|
347
360
|
* Maximum attempts before giving up retries.
|
|
348
361
|
*
|
|
@@ -351,7 +364,7 @@ interface RetryAfterLinkPluginOptions<T extends ClientContext> {
|
|
|
351
364
|
maxAttempts?: Value<number, [
|
|
352
365
|
response: StandardLazyResponse,
|
|
353
366
|
options: StandardLinkTransportInterceptorOptions<T>
|
|
354
|
-
]
|
|
367
|
+
]> | undefined;
|
|
355
368
|
/**
|
|
356
369
|
* Maximum timeout in milliseconds to wait before giving up retries.
|
|
357
370
|
*
|
|
@@ -360,7 +373,7 @@ interface RetryAfterLinkPluginOptions<T extends ClientContext> {
|
|
|
360
373
|
timeout?: Value<number, [
|
|
361
374
|
response: StandardLazyResponse,
|
|
362
375
|
options: StandardLinkTransportInterceptorOptions<T>
|
|
363
|
-
]
|
|
376
|
+
]> | undefined;
|
|
364
377
|
}
|
|
365
378
|
/**
|
|
366
379
|
* The Retry After Link Plugin automatically retries requests based on server `retry-after` header.
|
|
@@ -403,5 +416,5 @@ declare class TimeoutLinkPlugin<T extends ClientContext> implements StandardLink
|
|
|
403
416
|
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
404
417
|
}
|
|
405
418
|
|
|
406
|
-
export { BatchLinkPlugin, RetryLinkPlugin as ClientRetryPlugin, DedupeLinkPlugin, DedupeLinkPlugin as DedupeRequestsPlugin, RequestCompressionLinkPlugin, ResponseCompressionLinkPlugin, RetryAfterLinkPlugin, RetryAfterLinkPlugin as RetryAfterPlugin, RetryLinkPlugin, TimeoutLinkPlugin };
|
|
407
|
-
export type { BatchLinkPluginGroup,
|
|
419
|
+
export { BATCH_HEADER, BatchLinkPlugin, RetryLinkPlugin as ClientRetryPlugin, DEFAULT_BATCH_MAX_SIZE, DedupeLinkPlugin, DedupeLinkPlugin as DedupeRequestsPlugin, RequestCompressionLinkPlugin, ResponseCompressionLinkPlugin, RetryAfterLinkPlugin, RetryAfterLinkPlugin as RetryAfterPlugin, RetryLinkPlugin, TimeoutLinkPlugin, isRetryableError };
|
|
420
|
+
export type { BatchLinkPluginGroup, BatchLinkPluginOptions, RetryLinkPluginContext as ClientRetryPluginContext, DedupeLinkPluginGroup, DedupeLinkPluginOptions, RequestCompressionLinkPluginOptions, ResponseCompressionLinkPluginOptions, RetryAfterLinkPluginOptions, RetryLinkPluginAttemptOptions, RetryLinkPluginContext, RetryLinkPluginOptions, TimeoutLinkPluginOptions };
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -3,7 +3,19 @@ import { StandardUrl, StandardHeaders, StandardRequest, StandardLazyResponse } f
|
|
|
3
3
|
import { ClientContext } from '../index.js';
|
|
4
4
|
import { StandardLinkPlugin, StandardLinkTransportInterceptorOptions, StandardLinkOptions, StandardLinkInterceptorOptions } from '../adapters/standard/index.js';
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Header that marks a request as a batch, set by the Batch Link Plugin and detected by the Batch Handler Plugin.
|
|
8
|
+
* Nothing between the client and server, such as a CORS policy or proxy, should block or strip it.
|
|
9
|
+
*
|
|
10
|
+
* @see {@link https://orpc.dev/docs/plugins/batch#setup | Batch Plugin - Setup}
|
|
11
|
+
*/
|
|
12
|
+
declare const BATCH_HEADER = "orpc-batch";
|
|
13
|
+
/**
|
|
14
|
+
* Default `maxSize` of both the Batch Link Plugin and the Batch Handler Plugin.
|
|
15
|
+
*
|
|
16
|
+
* @see {@link https://orpc.dev/docs/plugins/batch#max-size | Batch Plugin - Max Size}
|
|
17
|
+
*/
|
|
18
|
+
declare const DEFAULT_BATCH_MAX_SIZE = 10;
|
|
7
19
|
interface BatchLinkPluginGroup<T extends ClientContext> {
|
|
8
20
|
/**
|
|
9
21
|
* Determines whether a request should be included in this batch group.
|
|
@@ -21,7 +33,7 @@ interface BatchLinkPluginGroup<T extends ClientContext> {
|
|
|
21
33
|
*
|
|
22
34
|
* @default []
|
|
23
35
|
*/
|
|
24
|
-
path?: Value<string[], [items: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]
|
|
36
|
+
path?: Value<string[], [items: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]> | undefined;
|
|
25
37
|
}
|
|
26
38
|
interface BatchLinkPluginOptions<T extends ClientContext> {
|
|
27
39
|
groups: [BatchLinkPluginGroup<T>, ...BatchLinkPluginGroup<T>[]];
|
|
@@ -30,20 +42,22 @@ interface BatchLinkPluginOptions<T extends ClientContext> {
|
|
|
30
42
|
*
|
|
31
43
|
* @default () => true
|
|
32
44
|
*/
|
|
33
|
-
filter?: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]
|
|
45
|
+
filter?: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]> | undefined;
|
|
34
46
|
/**
|
|
35
47
|
* Only requests with the same scope are batched together.
|
|
36
48
|
* On the server, return a value unique to the incoming request so different users never share a batch.
|
|
37
49
|
*
|
|
38
50
|
* @default () => undefined
|
|
39
51
|
*/
|
|
40
|
-
scope?: (options: StandardLinkTransportInterceptorOptions<T>) => unknown;
|
|
52
|
+
scope?: ((options: StandardLinkTransportInterceptorOptions<T>) => unknown) | undefined;
|
|
41
53
|
/**
|
|
42
|
-
* The maximum number of requests in the batch.
|
|
54
|
+
* The maximum number of requests in the batch. Larger batches are split.
|
|
55
|
+
* Keep it at or below the server Batch Handler Plugin's `maxSize`, which rejects larger batches with a `413`.
|
|
43
56
|
*
|
|
44
|
-
* @default 10
|
|
57
|
+
* @default DEFAULT_BATCH_MAX_SIZE (10)
|
|
58
|
+
* @see {@link https://orpc.dev/docs/plugins/batch#max-size | Batch Plugin - Max Size}
|
|
45
59
|
*/
|
|
46
|
-
maxSize?: Value<Promisable<number>, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]
|
|
60
|
+
maxSize?: Value<Promisable<number>, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]> | undefined;
|
|
47
61
|
/**
|
|
48
62
|
* How long (in ms) to wait for more requests before sending the batch,
|
|
49
63
|
* counted from the first queued request.
|
|
@@ -51,20 +65,13 @@ interface BatchLinkPluginOptions<T extends ClientContext> {
|
|
|
51
65
|
*
|
|
52
66
|
* @default 0
|
|
53
67
|
*/
|
|
54
|
-
wait?: number;
|
|
55
|
-
/**
|
|
56
|
-
* The batch response mode.
|
|
57
|
-
* A `buffered` batch still streams once a procedure in it returns a stream.
|
|
58
|
-
*
|
|
59
|
-
* @default 'streaming'
|
|
60
|
-
*/
|
|
61
|
-
mode?: Value<BatchLinkPluginMode, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]>;
|
|
68
|
+
wait?: number | undefined;
|
|
62
69
|
/**
|
|
63
70
|
* URL for the batch request.
|
|
64
71
|
*
|
|
65
72
|
* @default URL of the first subrequest in the batch + '/__batch__'
|
|
66
73
|
*/
|
|
67
|
-
url?: Value<Promisable<StandardUrl>, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]
|
|
74
|
+
url?: Value<Promisable<StandardUrl>, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]> | undefined;
|
|
68
75
|
/**
|
|
69
76
|
* The maximum length of the URL that runtime supports,
|
|
70
77
|
* if exceeded, the batch will be split into smaller batches and sent sequentially.
|
|
@@ -73,25 +80,25 @@ interface BatchLinkPluginOptions<T extends ClientContext> {
|
|
|
73
80
|
*
|
|
74
81
|
* @default 2083
|
|
75
82
|
*/
|
|
76
|
-
maxUrlLength?: Value<Promisable<number>, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]
|
|
83
|
+
maxUrlLength?: Value<Promisable<number>, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]> | undefined;
|
|
77
84
|
/**
|
|
78
85
|
* Headers used for the batch request.
|
|
79
86
|
*
|
|
80
87
|
* @default Common headers among all subrequests in the batch.
|
|
81
88
|
*/
|
|
82
|
-
headers?: Value<Promisable<StandardHeaders>, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]
|
|
89
|
+
headers?: Value<Promisable<StandardHeaders>, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]> | undefined;
|
|
83
90
|
/**
|
|
84
91
|
* Map each subrequest in the batch before it is sent.
|
|
85
92
|
*
|
|
86
93
|
* @default Removes headers that are duplicated with the batch headers
|
|
87
94
|
*/
|
|
88
|
-
mapSubrequest?: (subOptions: StandardLinkTransportInterceptorOptions<T>, partialBatchRequest: Pick<StandardRequest, 'url' | 'headers'>) => StandardRequest;
|
|
95
|
+
mapSubrequest?: ((subOptions: StandardLinkTransportInterceptorOptions<T>, partialBatchRequest: Pick<StandardRequest, 'url' | 'headers'>) => StandardRequest) | undefined;
|
|
89
96
|
/**
|
|
90
97
|
* Maps each subresponse before returning the final response.
|
|
91
98
|
*
|
|
92
99
|
* @default Low-priority merges headers from the batch response into each subresponse.
|
|
93
100
|
*/
|
|
94
|
-
mapSubresponse?: (subResponse: StandardLazyResponse, batchResponse: StandardLazyResponse, subOptions: StandardLinkTransportInterceptorOptions<T>) => StandardLazyResponse;
|
|
101
|
+
mapSubresponse?: ((subResponse: StandardLazyResponse, batchResponse: StandardLazyResponse, subOptions: StandardLinkTransportInterceptorOptions<T>) => StandardLazyResponse) | undefined;
|
|
95
102
|
}
|
|
96
103
|
/**
|
|
97
104
|
* Combines multiple client requests into a single batch request
|
|
@@ -109,7 +116,6 @@ declare class BatchLinkPlugin<T extends ClientContext> implements StandardLinkPl
|
|
|
109
116
|
private readonly scope;
|
|
110
117
|
private readonly maxSize;
|
|
111
118
|
private readonly wait;
|
|
112
|
-
private readonly mode;
|
|
113
119
|
private readonly batchUrl;
|
|
114
120
|
private readonly maxUrlLength;
|
|
115
121
|
private readonly batchHeaders;
|
|
@@ -152,14 +158,14 @@ interface DedupeLinkPluginOptions<T extends ClientContext> {
|
|
|
152
158
|
*
|
|
153
159
|
* @default ({ request }) => request.method === 'GET' || request.method === 'QUERY'
|
|
154
160
|
*/
|
|
155
|
-
filter?: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]
|
|
161
|
+
filter?: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]> | undefined;
|
|
156
162
|
/**
|
|
157
163
|
* Only requests with the same scope are deduplicated together.
|
|
158
164
|
* On the server, return a value unique to the incoming request so different users never share a response.
|
|
159
165
|
*
|
|
160
166
|
* @default () => undefined
|
|
161
167
|
*/
|
|
162
|
-
scope?: (options: StandardLinkTransportInterceptorOptions<T>) => unknown;
|
|
168
|
+
scope?: ((options: StandardLinkTransportInterceptorOptions<T>) => unknown) | undefined;
|
|
163
169
|
/**
|
|
164
170
|
* How long (in ms) to wait for more identical requests before sending,
|
|
165
171
|
* counted from the first queued request.
|
|
@@ -167,7 +173,7 @@ interface DedupeLinkPluginOptions<T extends ClientContext> {
|
|
|
167
173
|
*
|
|
168
174
|
* @default 0
|
|
169
175
|
*/
|
|
170
|
-
wait?: number;
|
|
176
|
+
wait?: number | undefined;
|
|
171
177
|
}
|
|
172
178
|
/**
|
|
173
179
|
* Prevents redundant requests by deduplicating similar in-flight requests,
|
|
@@ -196,7 +202,7 @@ interface RequestCompressionLinkPluginOptions<T extends ClientContext> {
|
|
|
196
202
|
*
|
|
197
203
|
* @default 'gzip'
|
|
198
204
|
*/
|
|
199
|
-
encoding?: 'gzip' | 'deflate' | 'deflate-raw';
|
|
205
|
+
encoding?: 'gzip' | 'deflate' | 'deflate-raw' | undefined;
|
|
200
206
|
/**
|
|
201
207
|
* The minimum request size in bytes required to trigger compression.
|
|
202
208
|
* Requests smaller than this threshold will not be compressed to avoid overhead.
|
|
@@ -204,7 +210,7 @@ interface RequestCompressionLinkPluginOptions<T extends ClientContext> {
|
|
|
204
210
|
*
|
|
205
211
|
* @default 1024 (1KB)
|
|
206
212
|
*/
|
|
207
|
-
threshold?: number;
|
|
213
|
+
threshold?: number | undefined;
|
|
208
214
|
/**
|
|
209
215
|
* Determines whether a request with the given Content-Type should be compressed.
|
|
210
216
|
* Only consulted for binary transfers (streams, files, and file form-data parts).
|
|
@@ -212,7 +218,7 @@ interface RequestCompressionLinkPluginOptions<T extends ClientContext> {
|
|
|
212
218
|
*
|
|
213
219
|
* @default isCompressibleContentType (covers common text-based formats)
|
|
214
220
|
*/
|
|
215
|
-
isCompressibleContentType?: (contentType: string | null | undefined, options: StandardLinkTransportInterceptorOptions<T>) => boolean;
|
|
221
|
+
isCompressibleContentType?: ((contentType: string | null | undefined, options: StandardLinkTransportInterceptorOptions<T>) => boolean) | undefined;
|
|
216
222
|
}
|
|
217
223
|
/**
|
|
218
224
|
* Compresses request bodies before sending them to the server,
|
|
@@ -240,7 +246,7 @@ interface ResponseCompressionLinkPluginOptions<_T extends ClientContext> {
|
|
|
240
246
|
*
|
|
241
247
|
* @default ['gzip', 'deflate']
|
|
242
248
|
*/
|
|
243
|
-
encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[];
|
|
249
|
+
encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[] | undefined;
|
|
244
250
|
}
|
|
245
251
|
/**
|
|
246
252
|
* Advertises Accept-Encoding on requests and decompresses response bodies
|
|
@@ -287,7 +293,7 @@ interface RetryLinkPluginContext {
|
|
|
287
293
|
*
|
|
288
294
|
* @default 0
|
|
289
295
|
*/
|
|
290
|
-
retry?: Value<Promisable<number>, [Omit<StandardLinkInterceptorOptions<RetryLinkPluginContext>, 'next'>]
|
|
296
|
+
retry?: Value<Promisable<number>, [Omit<StandardLinkInterceptorOptions<RetryLinkPluginContext>, 'next'>]> | undefined;
|
|
291
297
|
/**
|
|
292
298
|
* Delay (in ms) before retrying.
|
|
293
299
|
*
|
|
@@ -296,17 +302,17 @@ interface RetryLinkPluginContext {
|
|
|
296
302
|
*
|
|
297
303
|
* @default (o) => o.lastEventRetry ?? 2000
|
|
298
304
|
*/
|
|
299
|
-
retryDelay?: Value<Promisable<number>, [RetryLinkPluginAttemptOptions<RetryLinkPluginContext>]
|
|
305
|
+
retryDelay?: Value<Promisable<number>, [RetryLinkPluginAttemptOptions<RetryLinkPluginContext>]> | undefined;
|
|
300
306
|
/**
|
|
301
307
|
* Determine whether to retry.
|
|
302
308
|
*
|
|
303
|
-
* @default
|
|
309
|
+
* @default (o) => isRetryableError(o.error)
|
|
304
310
|
*/
|
|
305
|
-
shouldRetry?: Value<Promisable<boolean>, [RetryLinkPluginAttemptOptions<RetryLinkPluginContext>]
|
|
311
|
+
shouldRetry?: Value<Promisable<boolean>, [RetryLinkPluginAttemptOptions<RetryLinkPluginContext>]> | undefined;
|
|
306
312
|
/**
|
|
307
313
|
* Hook called before each retry. Can return a cleanup callback.
|
|
308
314
|
*/
|
|
309
|
-
onRetry?: (options: RetryLinkPluginAttemptOptions<RetryLinkPluginContext>) => void | ((isSuccess: boolean) => void);
|
|
315
|
+
onRetry?: ((options: RetryLinkPluginAttemptOptions<RetryLinkPluginContext>) => void | ((isSuccess: boolean) => void)) | undefined;
|
|
310
316
|
}
|
|
311
317
|
interface RetryLinkPluginOptions<_T extends RetryLinkPluginContext> {
|
|
312
318
|
/**
|
|
@@ -314,6 +320,13 @@ interface RetryLinkPluginOptions<_T extends RetryLinkPluginContext> {
|
|
|
314
320
|
*/
|
|
315
321
|
default?: RetryLinkPluginContext | undefined;
|
|
316
322
|
}
|
|
323
|
+
/**
|
|
324
|
+
* Default `shouldRetry` check of `RetryLinkPlugin`. Returns `false` only for errors
|
|
325
|
+
* from a 4xx response other than `408` and `429`.
|
|
326
|
+
*
|
|
327
|
+
* @see {@link https://orpc.dev/docs/plugins/retry#client-error-responses | Retry Plugin - Client Error Responses}
|
|
328
|
+
*/
|
|
329
|
+
declare function isRetryableError(error: unknown): boolean;
|
|
317
330
|
/**
|
|
318
331
|
* Automatically retries failed requests based on customizable retry strategies,
|
|
319
332
|
* improving the resilience of your application.
|
|
@@ -342,7 +355,7 @@ interface RetryAfterLinkPluginOptions<T extends ClientContext> {
|
|
|
342
355
|
condition?: Value<boolean, [
|
|
343
356
|
response: StandardLazyResponse,
|
|
344
357
|
options: StandardLinkTransportInterceptorOptions<T>
|
|
345
|
-
]
|
|
358
|
+
]> | undefined;
|
|
346
359
|
/**
|
|
347
360
|
* Maximum attempts before giving up retries.
|
|
348
361
|
*
|
|
@@ -351,7 +364,7 @@ interface RetryAfterLinkPluginOptions<T extends ClientContext> {
|
|
|
351
364
|
maxAttempts?: Value<number, [
|
|
352
365
|
response: StandardLazyResponse,
|
|
353
366
|
options: StandardLinkTransportInterceptorOptions<T>
|
|
354
|
-
]
|
|
367
|
+
]> | undefined;
|
|
355
368
|
/**
|
|
356
369
|
* Maximum timeout in milliseconds to wait before giving up retries.
|
|
357
370
|
*
|
|
@@ -360,7 +373,7 @@ interface RetryAfterLinkPluginOptions<T extends ClientContext> {
|
|
|
360
373
|
timeout?: Value<number, [
|
|
361
374
|
response: StandardLazyResponse,
|
|
362
375
|
options: StandardLinkTransportInterceptorOptions<T>
|
|
363
|
-
]
|
|
376
|
+
]> | undefined;
|
|
364
377
|
}
|
|
365
378
|
/**
|
|
366
379
|
* The Retry After Link Plugin automatically retries requests based on server `retry-after` header.
|
|
@@ -403,5 +416,5 @@ declare class TimeoutLinkPlugin<T extends ClientContext> implements StandardLink
|
|
|
403
416
|
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
404
417
|
}
|
|
405
418
|
|
|
406
|
-
export { BatchLinkPlugin, RetryLinkPlugin as ClientRetryPlugin, DedupeLinkPlugin, DedupeLinkPlugin as DedupeRequestsPlugin, RequestCompressionLinkPlugin, ResponseCompressionLinkPlugin, RetryAfterLinkPlugin, RetryAfterLinkPlugin as RetryAfterPlugin, RetryLinkPlugin, TimeoutLinkPlugin };
|
|
407
|
-
export type { BatchLinkPluginGroup,
|
|
419
|
+
export { BATCH_HEADER, BatchLinkPlugin, RetryLinkPlugin as ClientRetryPlugin, DEFAULT_BATCH_MAX_SIZE, DedupeLinkPlugin, DedupeLinkPlugin as DedupeRequestsPlugin, RequestCompressionLinkPlugin, ResponseCompressionLinkPlugin, RetryAfterLinkPlugin, RetryAfterLinkPlugin as RetryAfterPlugin, RetryLinkPlugin, TimeoutLinkPlugin, isRetryableError };
|
|
420
|
+
export type { BatchLinkPluginGroup, BatchLinkPluginOptions, RetryLinkPluginContext as ClientRetryPluginContext, DedupeLinkPluginGroup, DedupeLinkPluginOptions, RequestCompressionLinkPluginOptions, ResponseCompressionLinkPluginOptions, RetryAfterLinkPluginOptions, RetryLinkPluginAttemptOptions, RetryLinkPluginContext, RetryLinkPluginOptions, TimeoutLinkPluginOptions };
|