@orpc/client 2.0.0-beta.46 → 2.0.0-beta.48
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 +6 -4
- package/dist/adapters/fetch/index.d.mts +2 -48
- package/dist/adapters/fetch/index.mjs +2 -77
- package/dist/adapters/fetch/rpc-link.d.mts +13 -0
- package/dist/adapters/fetch/rpc-link.mjs +10 -0
- package/dist/adapters/fetch/transport.d.mts +31 -0
- package/dist/adapters/fetch/transport.mjs +65 -0
- package/dist/adapters/message-port/index.d.mts +3 -80
- package/dist/adapters/message-port/index.mjs +3 -101
- package/dist/adapters/message-port/message-port.d.mts +29 -0
- package/dist/adapters/message-port/message-port.mjs +43 -0
- package/dist/adapters/message-port/rpc-link.d.mts +14 -0
- package/dist/adapters/message-port/rpc-link.mjs +10 -0
- package/dist/adapters/message-port/transport.d.mts +35 -0
- package/dist/adapters/message-port/transport.mjs +47 -0
- package/dist/adapters/standard/codec.d.mts +14 -0
- package/dist/adapters/standard/codec.mjs +1 -0
- package/dist/adapters/standard/index.d.mts +5 -60
- package/dist/adapters/standard/index.mjs +4 -6
- package/dist/adapters/standard/link.d.mts +40 -0
- package/dist/adapters/standard/link.mjs +79 -0
- package/dist/adapters/standard/plugin.d.mts +32 -0
- package/dist/adapters/standard/plugin.mjs +16 -0
- package/dist/adapters/standard/rpc-link-codec.d.mts +55 -0
- package/dist/adapters/standard/rpc-link-codec.mjs +104 -0
- package/dist/adapters/standard/transport.d.mts +14 -0
- package/dist/adapters/standard/transport.mjs +1 -0
- package/dist/adapters/websocket/index.d.mts +2 -136
- package/dist/adapters/websocket/index.mjs +2 -131
- package/dist/adapters/websocket/rpc-link.d.mts +13 -0
- package/dist/adapters/websocket/rpc-link.mjs +10 -0
- package/dist/adapters/websocket/transport.d.mts +119 -0
- package/dist/adapters/websocket/transport.mjs +123 -0
- package/dist/async-iterator-object.d.mts +7 -0
- package/dist/async-iterator-object.mjs +30 -0
- package/dist/client-safe.d.mts +16 -0
- package/dist/client-safe.mjs +23 -0
- package/dist/client.d.mts +51 -0
- package/dist/client.mjs +32 -0
- package/dist/consts.d.mts +10 -0
- package/dist/consts.mjs +10 -0
- package/dist/dynamic-link.d.mts +13 -0
- package/dist/dynamic-link.mjs +12 -0
- package/dist/error-utils.d.mts +24 -0
- package/dist/error-utils.mjs +44 -0
- package/dist/error.d.mts +138 -0
- package/dist/error.mjs +105 -0
- package/dist/index.d.mts +42 -137
- package/dist/index.mjs +18 -142
- package/dist/plugins/batch.d.mts +150 -0
- package/dist/plugins/batch.mjs +339 -0
- package/dist/plugins/cookie-jar.d.mts +82 -0
- package/dist/plugins/cookie-jar.mjs +229 -0
- package/dist/plugins/dedupe.d.mts +58 -0
- package/dist/plugins/dedupe.mjs +199 -0
- package/dist/plugins/index.d.mts +28 -420
- package/dist/plugins/index.mjs +17 -971
- package/dist/plugins/request-compression.d.mts +44 -0
- package/dist/plugins/request-compression.mjs +150 -0
- package/dist/plugins/response-compression.d.mts +28 -0
- package/dist/plugins/response-compression.mjs +78 -0
- package/dist/plugins/retry-after.d.mts +41 -0
- package/dist/plugins/retry-after.mjs +71 -0
- package/dist/plugins/retry.d.mts +82 -0
- package/dist/plugins/retry.mjs +127 -0
- package/dist/plugins/timeout.d.mts +25 -0
- package/dist/plugins/timeout.mjs +36 -0
- package/dist/rpc-json-serializer.d.mts +99 -0
- package/dist/rpc-json-serializer.mjs +365 -0
- package/dist/rpc-serializer.d.mts +32 -0
- package/dist/rpc-serializer.mjs +100 -0
- package/dist/types.d.mts +93 -0
- package/dist/types.mjs +1 -0
- package/dist/utils.d.mts +46 -0
- package/dist/utils.mjs +53 -0
- package/package.json +5 -5
- package/dist/adapters/fetch/index.d.ts +0 -48
- package/dist/adapters/message-port/index.d.ts +0 -80
- package/dist/adapters/standard/index.d.ts +0 -60
- package/dist/adapters/websocket/index.d.ts +0 -136
- package/dist/index.d.ts +0 -144
- package/dist/plugins/index.d.ts +0 -420
- package/dist/shared/client.BoHJeq15.d.mts +0 -233
- package/dist/shared/client.BoHJeq15.d.ts +0 -233
- package/dist/shared/client.CKQeJJ2U.mjs +0 -172
- package/dist/shared/client.DqIWeNhQ.d.mts +0 -131
- package/dist/shared/client.DqIWeNhQ.d.ts +0 -131
- package/dist/shared/client.JBJwBhR8.d.ts +0 -90
- package/dist/shared/client.LF04eOvL.mjs +0 -115
- package/dist/shared/client._wG5INmC.mjs +0 -505
- package/dist/shared/client.euYjjcFz.d.mts +0 -90
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1,420 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
*/
|
|
30
|
-
context: Value<T, [items: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]>;
|
|
31
|
-
/**
|
|
32
|
-
* The path segments applied to requests in this batch group for the remainder of the link chain.
|
|
33
|
-
*
|
|
34
|
-
* @default []
|
|
35
|
-
*/
|
|
36
|
-
path?: Value<string[], [items: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]> | undefined;
|
|
37
|
-
}
|
|
38
|
-
interface BatchLinkPluginOptions<T extends ClientContext> {
|
|
39
|
-
groups: [BatchLinkPluginGroup<T>, ...BatchLinkPluginGroup<T>[]];
|
|
40
|
-
/**
|
|
41
|
-
* Filters requests to batch.
|
|
42
|
-
*
|
|
43
|
-
* @default () => true
|
|
44
|
-
*/
|
|
45
|
-
filter?: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]> | undefined;
|
|
46
|
-
/**
|
|
47
|
-
* Only requests with the same scope are batched together.
|
|
48
|
-
* On the server, return a value unique to the incoming request so different users never share a batch.
|
|
49
|
-
*
|
|
50
|
-
* @default () => undefined
|
|
51
|
-
*/
|
|
52
|
-
scope?: ((options: StandardLinkTransportInterceptorOptions<T>) => unknown) | undefined;
|
|
53
|
-
/**
|
|
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`.
|
|
56
|
-
*
|
|
57
|
-
* @default DEFAULT_BATCH_MAX_SIZE (10)
|
|
58
|
-
* @see {@link https://orpc.dev/docs/plugins/batch#max-size | Batch Plugin - Max Size}
|
|
59
|
-
*/
|
|
60
|
-
maxSize?: Value<Promisable<number>, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]> | undefined;
|
|
61
|
-
/**
|
|
62
|
-
* How long (in ms) to wait for more requests before sending the batch,
|
|
63
|
-
* counted from the first queued request.
|
|
64
|
-
* With `0`, only requests made in the same event loop tick are batched.
|
|
65
|
-
*
|
|
66
|
-
* @default 0
|
|
67
|
-
*/
|
|
68
|
-
wait?: number | undefined;
|
|
69
|
-
/**
|
|
70
|
-
* URL for the batch request.
|
|
71
|
-
*
|
|
72
|
-
* @default URL of the first subrequest in the batch + '/__batch__'
|
|
73
|
-
*/
|
|
74
|
-
url?: Value<Promisable<StandardUrl>, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]> | undefined;
|
|
75
|
-
/**
|
|
76
|
-
* The maximum length of the URL that runtime supports,
|
|
77
|
-
* if exceeded, the batch will be split into smaller batches and sent sequentially.
|
|
78
|
-
*
|
|
79
|
-
* This only applies to GET batch requests where the batch data is sent via URL query parameter.
|
|
80
|
-
*
|
|
81
|
-
* @default 2083
|
|
82
|
-
*/
|
|
83
|
-
maxUrlLength?: Value<Promisable<number>, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]> | undefined;
|
|
84
|
-
/**
|
|
85
|
-
* Headers used for the batch request.
|
|
86
|
-
*
|
|
87
|
-
* @default Common headers among all subrequests in the batch.
|
|
88
|
-
*/
|
|
89
|
-
headers?: Value<Promisable<StandardHeaders>, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]> | undefined;
|
|
90
|
-
/**
|
|
91
|
-
* Map each subrequest in the batch before it is sent.
|
|
92
|
-
*
|
|
93
|
-
* @default Removes headers that are duplicated with the batch headers
|
|
94
|
-
*/
|
|
95
|
-
mapSubrequest?: ((subOptions: StandardLinkTransportInterceptorOptions<T>, partialBatchRequest: Pick<StandardRequest, 'url' | 'headers'>) => StandardRequest) | undefined;
|
|
96
|
-
/**
|
|
97
|
-
* Maps each subresponse before returning the final response.
|
|
98
|
-
*
|
|
99
|
-
* @default Low-priority merges headers from the batch response into each subresponse.
|
|
100
|
-
*/
|
|
101
|
-
mapSubresponse?: ((subResponse: StandardLazyResponse, batchResponse: StandardLazyResponse, subOptions: StandardLinkTransportInterceptorOptions<T>) => StandardLazyResponse) | undefined;
|
|
102
|
-
}
|
|
103
|
-
/**
|
|
104
|
-
* Combines multiple client requests into a single batch request
|
|
105
|
-
* and splits the batch response back into individual responses.
|
|
106
|
-
*
|
|
107
|
-
* @remarks
|
|
108
|
-
* **Note**: HTTP/2 and later already multiplex requests over a single connection, so this plugin is often less useful than it once was.
|
|
109
|
-
*
|
|
110
|
-
* @see {@link https://orpc.dev/docs/plugins/batch | Batch Plugin}
|
|
111
|
-
*/
|
|
112
|
-
declare class BatchLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
113
|
-
name: string;
|
|
114
|
-
private readonly groups;
|
|
115
|
-
private readonly filter;
|
|
116
|
-
private readonly scope;
|
|
117
|
-
private readonly maxSize;
|
|
118
|
-
private readonly wait;
|
|
119
|
-
private readonly batchUrl;
|
|
120
|
-
private readonly maxUrlLength;
|
|
121
|
-
private readonly batchHeaders;
|
|
122
|
-
private readonly mapSubrequest;
|
|
123
|
-
private readonly mapSubresponse;
|
|
124
|
-
private readonly queue;
|
|
125
|
-
constructor(options: NoInfer<BatchLinkPluginOptions<T>>);
|
|
126
|
-
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
127
|
-
private processPendingBatches;
|
|
128
|
-
/**
|
|
129
|
-
* Runs the batch in the async context of its first request instead of the timer's,
|
|
130
|
-
* so the transport and batch options see that caller's request state.
|
|
131
|
-
* `executeBatch` always runs in the context of its first request.
|
|
132
|
-
*/
|
|
133
|
-
private executeBatchInOwnContext;
|
|
134
|
-
private executeBatch;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
interface DedupeLinkPluginGroup<T extends ClientContext> {
|
|
138
|
-
condition: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]>;
|
|
139
|
-
/**
|
|
140
|
-
* The context used for the rest of the request lifecycle.
|
|
141
|
-
*/
|
|
142
|
-
context: Value<T, [
|
|
143
|
-
items: [
|
|
144
|
-
StandardLinkTransportInterceptorOptions<T>,
|
|
145
|
-
StandardLinkTransportInterceptorOptions<T>,
|
|
146
|
-
...StandardLinkTransportInterceptorOptions<T>[]
|
|
147
|
-
]
|
|
148
|
-
]>;
|
|
149
|
-
}
|
|
150
|
-
interface DedupeLinkPluginOptions<T extends ClientContext> {
|
|
151
|
-
/**
|
|
152
|
-
* To enable deduplication, a request must match at least one defined group.
|
|
153
|
-
* Requests that fall into the same group are considered for deduplication together.
|
|
154
|
-
*/
|
|
155
|
-
groups: [DedupeLinkPluginGroup<T>, ...DedupeLinkPluginGroup<T>[]];
|
|
156
|
-
/**
|
|
157
|
-
* Filters requests to dedupe.
|
|
158
|
-
*
|
|
159
|
-
* @default ({ request }) => request.method === 'GET' || request.method === 'QUERY'
|
|
160
|
-
*/
|
|
161
|
-
filter?: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]> | undefined;
|
|
162
|
-
/**
|
|
163
|
-
* Only requests with the same scope are deduplicated together.
|
|
164
|
-
* On the server, return a value unique to the incoming request so different users never share a response.
|
|
165
|
-
*
|
|
166
|
-
* @default () => undefined
|
|
167
|
-
*/
|
|
168
|
-
scope?: ((options: StandardLinkTransportInterceptorOptions<T>) => unknown) | undefined;
|
|
169
|
-
/**
|
|
170
|
-
* How long (in ms) to wait for more identical requests before sending,
|
|
171
|
-
* counted from the first queued request.
|
|
172
|
-
* With `0`, only requests made in the same event loop tick are deduplicated.
|
|
173
|
-
*
|
|
174
|
-
* @default 0
|
|
175
|
-
*/
|
|
176
|
-
wait?: number | undefined;
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Prevents redundant requests by deduplicating similar in-flight requests,
|
|
180
|
-
* reducing the number of requests sent to the server.
|
|
181
|
-
*
|
|
182
|
-
* @see {@link https://orpc.dev/docs/plugins/dedupe | Dedupe Plugin}
|
|
183
|
-
*/
|
|
184
|
-
declare class DedupeLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
185
|
-
name: string;
|
|
186
|
-
before: string[];
|
|
187
|
-
private readonly groups;
|
|
188
|
-
private readonly filter;
|
|
189
|
-
private readonly scope;
|
|
190
|
-
private readonly wait;
|
|
191
|
-
private readonly queue;
|
|
192
|
-
constructor(options: NoInfer<DedupeLinkPluginOptions<T>>);
|
|
193
|
-
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
194
|
-
private enqueue;
|
|
195
|
-
private processPendingRequests;
|
|
196
|
-
private execute;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
interface RequestCompressionLinkPluginOptions<T extends ClientContext> {
|
|
200
|
-
/**
|
|
201
|
-
* The compression scheme to use for request compression.
|
|
202
|
-
*
|
|
203
|
-
* @default 'gzip'
|
|
204
|
-
*/
|
|
205
|
-
encoding?: 'gzip' | 'deflate' | 'deflate-raw' | undefined;
|
|
206
|
-
/**
|
|
207
|
-
* The minimum request size in bytes required to trigger compression.
|
|
208
|
-
* Requests smaller than this threshold will not be compressed to avoid overhead.
|
|
209
|
-
* If the request size cannot be determined, compression will still be applied.
|
|
210
|
-
*
|
|
211
|
-
* @default 1024 (1KB)
|
|
212
|
-
*/
|
|
213
|
-
threshold?: number | undefined;
|
|
214
|
-
/**
|
|
215
|
-
* Determines whether a request with the given Content-Type should be compressed.
|
|
216
|
-
* Only consulted for binary transfers (streams, files, and file form-data parts).
|
|
217
|
-
* Also receives the transport interceptor options for per-request decisions.
|
|
218
|
-
*
|
|
219
|
-
* @default isCompressibleContentType (covers common text-based formats)
|
|
220
|
-
*/
|
|
221
|
-
isCompressibleContentType?: ((contentType: string | null | undefined, options: StandardLinkTransportInterceptorOptions<T>) => boolean) | undefined;
|
|
222
|
-
}
|
|
223
|
-
/**
|
|
224
|
-
* Compresses request bodies before sending them to the server,
|
|
225
|
-
* reducing bandwidth usage for large payloads.
|
|
226
|
-
*
|
|
227
|
-
* @see {@link https://orpc.dev/docs/plugins/request-compression | Request Compression Plugin}
|
|
228
|
-
*/
|
|
229
|
-
declare class RequestCompressionLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
230
|
-
name: string;
|
|
231
|
-
/**
|
|
232
|
-
* Compression should be done after batching, to compress the final request
|
|
233
|
-
*/
|
|
234
|
-
after: string[];
|
|
235
|
-
private readonly encoding;
|
|
236
|
-
private readonly threshold;
|
|
237
|
-
private readonly isCompressibleContentType;
|
|
238
|
-
constructor(options?: RequestCompressionLinkPluginOptions<T>);
|
|
239
|
-
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
interface ResponseCompressionLinkPluginOptions<_T extends ClientContext> {
|
|
243
|
-
/**
|
|
244
|
-
* Compression schemes to advertise via Accept-Encoding, in preference order.
|
|
245
|
-
* Only schemes that can be decompressed by this plugin should be listed.
|
|
246
|
-
*
|
|
247
|
-
* @default ['gzip', 'deflate']
|
|
248
|
-
*/
|
|
249
|
-
encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[] | undefined;
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* Advertises Accept-Encoding on requests and decompresses response bodies
|
|
253
|
-
* based on the Content-Encoding header. Works at the standard link level,
|
|
254
|
-
* so it supports all adapters.
|
|
255
|
-
*
|
|
256
|
-
* @see {@link https://orpc.dev/docs/plugins/response-compression | Response Compression Plugin}
|
|
257
|
-
*/
|
|
258
|
-
declare class ResponseCompressionLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
259
|
-
name: string;
|
|
260
|
-
/**
|
|
261
|
-
* Decompression should wrap the final batch response instead of sub-responses.
|
|
262
|
-
*/
|
|
263
|
-
after: string[];
|
|
264
|
-
private readonly encodings;
|
|
265
|
-
constructor(options?: ResponseCompressionLinkPluginOptions<T>);
|
|
266
|
-
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
interface RetryLinkPluginAttemptOptions<T extends RetryLinkPluginContext> extends StandardLinkInterceptorOptions<T> {
|
|
270
|
-
/**
|
|
271
|
-
* Latest retry delay advertised by the server via event metadata.
|
|
272
|
-
*/
|
|
273
|
-
lastEventRetry: number | undefined;
|
|
274
|
-
/**
|
|
275
|
-
* Current retry attempt number, starting at 1.
|
|
276
|
-
*/
|
|
277
|
-
attempt: number;
|
|
278
|
-
/**
|
|
279
|
-
* Error that triggered this retry attempt.
|
|
280
|
-
*/
|
|
281
|
-
error: unknown;
|
|
282
|
-
}
|
|
283
|
-
/**
|
|
284
|
-
* Client context options that control retry behavior per call
|
|
285
|
-
* when the `RetryLinkPlugin` is enabled.
|
|
286
|
-
*
|
|
287
|
-
* @see {@link https://orpc.dev/docs/plugins/retry | Retry Plugin}
|
|
288
|
-
*/
|
|
289
|
-
interface RetryLinkPluginContext {
|
|
290
|
-
/**
|
|
291
|
-
* Maximum retry attempts before throwing.
|
|
292
|
-
* Use `Number.POSITIVE_INFINITY` for infinite retries (e.g. for AsyncIteratorObject).
|
|
293
|
-
*
|
|
294
|
-
* @default 0
|
|
295
|
-
*/
|
|
296
|
-
retry?: Value<Promisable<number>, [Omit<StandardLinkInterceptorOptions<RetryLinkPluginContext>, 'next'>]> | undefined;
|
|
297
|
-
/**
|
|
298
|
-
* Delay (in ms) before retrying.
|
|
299
|
-
*
|
|
300
|
-
* @remarks
|
|
301
|
-
* **Note**: Why 2000ms? The EventSource spec suggests a default retry delay of 2 seconds if it doesn't specify
|
|
302
|
-
*
|
|
303
|
-
* @default (o) => o.lastEventRetry ?? 2000
|
|
304
|
-
*/
|
|
305
|
-
retryDelay?: Value<Promisable<number>, [RetryLinkPluginAttemptOptions<RetryLinkPluginContext>]> | undefined;
|
|
306
|
-
/**
|
|
307
|
-
* Determine whether to retry.
|
|
308
|
-
*
|
|
309
|
-
* @default (o) => isRetryableError(o.error)
|
|
310
|
-
*/
|
|
311
|
-
shouldRetry?: Value<Promisable<boolean>, [RetryLinkPluginAttemptOptions<RetryLinkPluginContext>]> | undefined;
|
|
312
|
-
/**
|
|
313
|
-
* Hook called before each retry. Can return a cleanup callback.
|
|
314
|
-
*/
|
|
315
|
-
onRetry?: ((options: RetryLinkPluginAttemptOptions<RetryLinkPluginContext>) => void | ((isSuccess: boolean) => void)) | undefined;
|
|
316
|
-
}
|
|
317
|
-
interface RetryLinkPluginOptions<_T extends RetryLinkPluginContext> {
|
|
318
|
-
/**
|
|
319
|
-
* Default retry options. Can be overridden by individual calls via the context.
|
|
320
|
-
*/
|
|
321
|
-
default?: RetryLinkPluginContext | undefined;
|
|
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;
|
|
330
|
-
/**
|
|
331
|
-
* Automatically retries failed requests based on customizable retry strategies,
|
|
332
|
-
* improving the resilience of your application.
|
|
333
|
-
*
|
|
334
|
-
* @remarks
|
|
335
|
-
* **Note**: Retry behavior is configured through the client context on each call.
|
|
336
|
-
*
|
|
337
|
-
* @see {@link https://orpc.dev/docs/plugins/retry | Retry Plugin}
|
|
338
|
-
*/
|
|
339
|
-
declare class RetryLinkPlugin<T extends RetryLinkPluginContext & ClientContext> implements StandardLinkPlugin<T> {
|
|
340
|
-
private readonly defaultRetry;
|
|
341
|
-
private readonly defaultRetryDelay;
|
|
342
|
-
private readonly defaultShouldRetry;
|
|
343
|
-
private readonly defaultOnRetry;
|
|
344
|
-
name: string;
|
|
345
|
-
constructor(options?: RetryLinkPluginOptions<T>);
|
|
346
|
-
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
interface RetryAfterLinkPluginOptions<T extends ClientContext> {
|
|
350
|
-
/**
|
|
351
|
-
* Override condition to determine whether to retry or not.
|
|
352
|
-
*
|
|
353
|
-
* @default ((response) => response.status === 429 || response.status === 503)
|
|
354
|
-
*/
|
|
355
|
-
condition?: Value<boolean, [
|
|
356
|
-
response: StandardLazyResponse,
|
|
357
|
-
options: StandardLinkTransportInterceptorOptions<T>
|
|
358
|
-
]> | undefined;
|
|
359
|
-
/**
|
|
360
|
-
* Maximum attempts before giving up retries.
|
|
361
|
-
*
|
|
362
|
-
* @default 3
|
|
363
|
-
*/
|
|
364
|
-
maxAttempts?: Value<number, [
|
|
365
|
-
response: StandardLazyResponse,
|
|
366
|
-
options: StandardLinkTransportInterceptorOptions<T>
|
|
367
|
-
]> | undefined;
|
|
368
|
-
/**
|
|
369
|
-
* Maximum timeout in milliseconds to wait before giving up retries.
|
|
370
|
-
*
|
|
371
|
-
* @default 5 * 60 * 1000 (5 minutes)
|
|
372
|
-
*/
|
|
373
|
-
timeout?: Value<number, [
|
|
374
|
-
response: StandardLazyResponse,
|
|
375
|
-
options: StandardLinkTransportInterceptorOptions<T>
|
|
376
|
-
]> | undefined;
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* The Retry After Link Plugin automatically retries requests based on server `retry-after` header.
|
|
380
|
-
* This is particularly useful for handling rate limiting and temporary server unavailability.
|
|
381
|
-
*
|
|
382
|
-
* @remarks
|
|
383
|
-
* **Note**: Requests with a stream or async iterator body are never retried, since the body cannot be resent.
|
|
384
|
-
*
|
|
385
|
-
* @see {@link https://orpc.dev/docs/plugins/retry-after | Retry After Plugin}
|
|
386
|
-
*/
|
|
387
|
-
declare class RetryAfterLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
388
|
-
private readonly condition;
|
|
389
|
-
private readonly maxAttempts;
|
|
390
|
-
private readonly timeout;
|
|
391
|
-
name: string;
|
|
392
|
-
constructor(options?: RetryAfterLinkPluginOptions<T>);
|
|
393
|
-
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
interface TimeoutLinkPluginOptions<T extends ClientContext> {
|
|
397
|
-
/**
|
|
398
|
-
* Timeout in milliseconds before the request is aborted.
|
|
399
|
-
* Use `null` or `undefined` to disable the timeout.
|
|
400
|
-
*/
|
|
401
|
-
timeout: Value<number | null | undefined, [options: StandardLinkInterceptorOptions<T>]>;
|
|
402
|
-
}
|
|
403
|
-
/**
|
|
404
|
-
* The Timeout Link Plugin aborts requests that exceed a configured timeout with an `AbortError`.
|
|
405
|
-
*
|
|
406
|
-
* @see {@link https://orpc.dev/docs/plugins/timeout | Timeout Plugin}
|
|
407
|
-
*/
|
|
408
|
-
declare class TimeoutLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
409
|
-
private readonly timeout;
|
|
410
|
-
name: string;
|
|
411
|
-
/**
|
|
412
|
-
* Should abort if the total retry time exceeds the configured timeout
|
|
413
|
-
*/
|
|
414
|
-
after: string[];
|
|
415
|
-
constructor(options: NoInfer<TimeoutLinkPluginOptions<T>>);
|
|
416
|
-
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
417
|
-
}
|
|
418
|
-
|
|
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 };
|
|
1
|
+
export * from "./batch.mjs";
|
|
2
|
+
export * from "./cookie-jar.mjs";
|
|
3
|
+
export * from "./dedupe.mjs";
|
|
4
|
+
export {
|
|
5
|
+
/**
|
|
6
|
+
* @deprecated Use `DedupeLinkPlugin` instead.
|
|
7
|
+
*/
|
|
8
|
+
DedupeLinkPlugin as DedupeRequestsPlugin } from "./dedupe.mjs";
|
|
9
|
+
export * from "./request-compression.mjs";
|
|
10
|
+
export * from "./response-compression.mjs";
|
|
11
|
+
export * from "./retry.mjs";
|
|
12
|
+
export {
|
|
13
|
+
/**
|
|
14
|
+
* @deprecated Use `RetryLinkPlugin` instead.
|
|
15
|
+
*/
|
|
16
|
+
RetryLinkPlugin as ClientRetryPlugin } from "./retry.mjs";
|
|
17
|
+
export type {
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated Use `RetryLinkPluginContext` instead.
|
|
20
|
+
*/
|
|
21
|
+
RetryLinkPluginContext as ClientRetryPluginContext } from "./retry.mjs";
|
|
22
|
+
export * from "./retry-after.mjs";
|
|
23
|
+
export {
|
|
24
|
+
/**
|
|
25
|
+
* @deprecated Use `RetryAfterLinkPlugin` instead.
|
|
26
|
+
*/
|
|
27
|
+
RetryAfterLinkPlugin as RetryAfterPlugin } from "./retry-after.mjs";
|
|
28
|
+
export * from "./timeout.mjs";
|