@orpc/client 2.0.0-beta.4 → 2.0.0-beta.40
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 +97 -94
- package/dist/adapters/fetch/index.d.mts +16 -33
- package/dist/adapters/fetch/index.d.ts +16 -33
- package/dist/adapters/fetch/index.mjs +32 -30
- package/dist/adapters/message-port/index.d.mts +13 -8
- package/dist/adapters/message-port/index.d.ts +13 -8
- package/dist/adapters/message-port/index.mjs +22 -17
- package/dist/adapters/standard/index.d.mts +9 -10
- package/dist/adapters/standard/index.d.ts +9 -10
- package/dist/adapters/standard/index.mjs +5 -5
- package/dist/adapters/websocket/index.d.mts +21 -16
- package/dist/adapters/websocket/index.d.ts +21 -16
- package/dist/adapters/websocket/index.mjs +14 -14
- package/dist/index.d.mts +62 -61
- package/dist/index.d.ts +62 -61
- package/dist/index.mjs +47 -54
- package/dist/plugins/index.d.mts +134 -13
- package/dist/plugins/index.d.ts +134 -13
- package/dist/plugins/index.mjs +298 -27
- package/dist/shared/{client.Cby_-GGh.d.mts → client.BWkR2vPU.d.mts} +2 -2
- package/dist/shared/client.BYHnU_Z3.mjs +469 -0
- package/dist/shared/{client.CPF3hX6O.d.ts → client.BnpRXnLi.d.ts} +2 -2
- package/dist/shared/{client.8ug8I-zu.d.mts → client.BoXZCzuS.d.mts} +56 -16
- package/dist/shared/{client.8ug8I-zu.d.ts → client.BoXZCzuS.d.ts} +56 -16
- package/dist/shared/{client.Dnfj8jnT.mjs → client.Dtv1JPkU.mjs} +19 -15
- package/dist/shared/{client.DXhchJ84.mjs → client.VXsLhJtT.mjs} +25 -30
- package/dist/shared/{client.BdItY5DT.d.mts → client.n8K9dFhY.d.mts} +25 -4
- package/dist/shared/{client.BdItY5DT.d.ts → client.n8K9dFhY.d.ts} +25 -4
- package/package.json +20 -8
- package/dist/shared/client.DMXKFDyV.mjs +0 -343
package/dist/plugins/index.d.mts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Value, Promisable } from '@orpc/shared';
|
|
2
|
-
import { StandardUrl, StandardHeaders, StandardRequest, StandardLazyResponse } from '@
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { StandardUrl, StandardHeaders, StandardRequest, StandardLazyResponse } from '@standard-server/core';
|
|
3
|
+
import { ClientContext } from '../index.mjs';
|
|
4
|
+
import { StandardLinkPlugin, StandardLinkTransportInterceptorOptions, StandardLinkOptions, StandardLinkInterceptorOptions } from '../adapters/standard/index.mjs';
|
|
5
5
|
|
|
6
6
|
type BatchLinkPluginMode = 'streaming' | 'buffered';
|
|
7
7
|
interface BatchLinkPluginGroup<T extends ClientContext> {
|
|
@@ -23,8 +23,6 @@ interface BatchLinkPluginGroup<T extends ClientContext> {
|
|
|
23
23
|
*/
|
|
24
24
|
path?: Value<string[], [items: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]>;
|
|
25
25
|
}
|
|
26
|
-
declare class BatchLinkPluginError extends TypeError {
|
|
27
|
-
}
|
|
28
26
|
interface BatchLinkPluginOptions<T extends ClientContext> {
|
|
29
27
|
groups: [BatchLinkPluginGroup<T>, ...BatchLinkPluginGroup<T>[]];
|
|
30
28
|
/**
|
|
@@ -79,6 +77,15 @@ interface BatchLinkPluginOptions<T extends ClientContext> {
|
|
|
79
77
|
*/
|
|
80
78
|
mapSubresponse?: (subResponse: StandardLazyResponse, batchResponse: StandardLazyResponse, subOptions: StandardLinkTransportInterceptorOptions<T>) => StandardLazyResponse;
|
|
81
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Combines multiple client requests into a single batch request
|
|
82
|
+
* and splits the batch response back into individual responses.
|
|
83
|
+
*
|
|
84
|
+
* @remarks
|
|
85
|
+
* **Note**: HTTP/2 and later already multiplex requests over a single connection, so this plugin is often less useful than it once was.
|
|
86
|
+
*
|
|
87
|
+
* @see {@link https://orpc.dev/docs/plugins/batch | Batch Plugin}
|
|
88
|
+
*/
|
|
82
89
|
declare class BatchLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
83
90
|
name: string;
|
|
84
91
|
private readonly groups;
|
|
@@ -119,10 +126,16 @@ interface DedupeLinkPluginOptions<T extends ClientContext> {
|
|
|
119
126
|
/**
|
|
120
127
|
* Filters requests to dedupe.
|
|
121
128
|
*
|
|
122
|
-
* @default ({ request }) => request.method === 'GET'
|
|
129
|
+
* @default ({ request }) => request.method === 'GET' || request.method === 'QUERY'
|
|
123
130
|
*/
|
|
124
131
|
filter?: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]>;
|
|
125
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Prevents redundant requests by deduplicating similar in-flight requests,
|
|
135
|
+
* reducing the number of requests sent to the server.
|
|
136
|
+
*
|
|
137
|
+
* @see {@link https://orpc.dev/docs/plugins/dedupe | Dedupe Plugin}
|
|
138
|
+
*/
|
|
126
139
|
declare class DedupeLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
127
140
|
name: string;
|
|
128
141
|
before: string[];
|
|
@@ -136,6 +149,76 @@ declare class DedupeLinkPlugin<T extends ClientContext> implements StandardLinkP
|
|
|
136
149
|
private execute;
|
|
137
150
|
}
|
|
138
151
|
|
|
152
|
+
interface RequestCompressionLinkPluginOptions<T extends ClientContext> {
|
|
153
|
+
/**
|
|
154
|
+
* The compression scheme to use for request compression.
|
|
155
|
+
*
|
|
156
|
+
* @default 'gzip'
|
|
157
|
+
*/
|
|
158
|
+
encoding?: 'gzip' | 'deflate' | 'deflate-raw';
|
|
159
|
+
/**
|
|
160
|
+
* The minimum request size in bytes required to trigger compression.
|
|
161
|
+
* Requests smaller than this threshold will not be compressed to avoid overhead.
|
|
162
|
+
* If the request size cannot be determined, compression will still be applied.
|
|
163
|
+
*
|
|
164
|
+
* @default 1024 (1KB)
|
|
165
|
+
*/
|
|
166
|
+
threshold?: number;
|
|
167
|
+
/**
|
|
168
|
+
* Determines whether a request with the given Content-Type should be compressed.
|
|
169
|
+
* Only consulted for binary transfers (streams, files, and file form-data parts).
|
|
170
|
+
* Also receives the transport interceptor options for per-request decisions.
|
|
171
|
+
*
|
|
172
|
+
* @default isCompressibleContentType (covers common text-based formats)
|
|
173
|
+
*/
|
|
174
|
+
isCompressibleContentType?: (contentType: string | null | undefined, options: StandardLinkTransportInterceptorOptions<T>) => boolean;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Compresses request bodies before sending them to the server,
|
|
178
|
+
* reducing bandwidth usage for large payloads.
|
|
179
|
+
*
|
|
180
|
+
* @see {@link https://orpc.dev/docs/plugins/request-compression | Request Compression Plugin}
|
|
181
|
+
*/
|
|
182
|
+
declare class RequestCompressionLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
183
|
+
name: string;
|
|
184
|
+
/**
|
|
185
|
+
* Compression should be done after batching, to compress the final request
|
|
186
|
+
*/
|
|
187
|
+
after: string[];
|
|
188
|
+
private readonly encoding;
|
|
189
|
+
private readonly threshold;
|
|
190
|
+
private readonly isCompressibleContentType;
|
|
191
|
+
constructor(options?: RequestCompressionLinkPluginOptions<T>);
|
|
192
|
+
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
interface ResponseCompressionLinkPluginOptions<_T extends ClientContext> {
|
|
196
|
+
/**
|
|
197
|
+
* Compression schemes to advertise via Accept-Encoding, in preference order.
|
|
198
|
+
* Only schemes that can be decompressed by this plugin should be listed.
|
|
199
|
+
*
|
|
200
|
+
* @default ['gzip', 'deflate']
|
|
201
|
+
*/
|
|
202
|
+
encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[];
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Advertises Accept-Encoding on requests and decompresses response bodies
|
|
206
|
+
* based on the Content-Encoding header. Works at the standard link level,
|
|
207
|
+
* so it supports all adapters.
|
|
208
|
+
*
|
|
209
|
+
* @see {@link https://orpc.dev/docs/plugins/response-compression | Response Compression Plugin}
|
|
210
|
+
*/
|
|
211
|
+
declare class ResponseCompressionLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
212
|
+
name: string;
|
|
213
|
+
/**
|
|
214
|
+
* Decompression should wrap the final batch response instead of sub-responses.
|
|
215
|
+
*/
|
|
216
|
+
after: string[];
|
|
217
|
+
private readonly encodings;
|
|
218
|
+
constructor(options?: ResponseCompressionLinkPluginOptions<T>);
|
|
219
|
+
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
220
|
+
}
|
|
221
|
+
|
|
139
222
|
interface RetryLinkPluginAttemptOptions<T extends RetryLinkPluginContext> extends StandardLinkInterceptorOptions<T> {
|
|
140
223
|
/**
|
|
141
224
|
* Latest retry delay advertised by the server via event metadata.
|
|
@@ -150,10 +233,16 @@ interface RetryLinkPluginAttemptOptions<T extends RetryLinkPluginContext> extend
|
|
|
150
233
|
*/
|
|
151
234
|
error: unknown;
|
|
152
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* Client context options that control retry behavior per call
|
|
238
|
+
* when the `RetryLinkPlugin` is enabled.
|
|
239
|
+
*
|
|
240
|
+
* @see {@link https://orpc.dev/docs/plugins/retry | Retry Plugin}
|
|
241
|
+
*/
|
|
153
242
|
interface RetryLinkPluginContext {
|
|
154
243
|
/**
|
|
155
244
|
* Maximum retry attempts before throwing.
|
|
156
|
-
* Use `Number.POSITIVE_INFINITY` for infinite retries (e.g. for
|
|
245
|
+
* Use `Number.POSITIVE_INFINITY` for infinite retries (e.g. for AsyncIteratorObject).
|
|
157
246
|
*
|
|
158
247
|
* @default 0
|
|
159
248
|
*/
|
|
@@ -161,7 +250,9 @@ interface RetryLinkPluginContext {
|
|
|
161
250
|
/**
|
|
162
251
|
* Delay (in ms) before retrying.
|
|
163
252
|
*
|
|
164
|
-
* @
|
|
253
|
+
* @remarks
|
|
254
|
+
* **Note**: Why 2000ms? The EventSource spec suggests a default retry delay of 2 seconds if it doesn't specify
|
|
255
|
+
*
|
|
165
256
|
* @default (o) => o.lastEventRetry ?? 2000
|
|
166
257
|
*/
|
|
167
258
|
retryDelay?: Value<Promisable<number>, [RetryLinkPluginAttemptOptions<RetryLinkPluginContext>]>;
|
|
@@ -182,8 +273,15 @@ interface RetryLinkPluginOptions<_T extends RetryLinkPluginContext> {
|
|
|
182
273
|
*/
|
|
183
274
|
default?: RetryLinkPluginContext | undefined;
|
|
184
275
|
}
|
|
185
|
-
|
|
186
|
-
|
|
276
|
+
/**
|
|
277
|
+
* Automatically retries failed requests based on customizable retry strategies,
|
|
278
|
+
* improving the resilience of your application.
|
|
279
|
+
*
|
|
280
|
+
* @remarks
|
|
281
|
+
* **Note**: Retry behavior is configured through the client context on each call.
|
|
282
|
+
*
|
|
283
|
+
* @see {@link https://orpc.dev/docs/plugins/retry | Retry Plugin}
|
|
284
|
+
*/
|
|
187
285
|
declare class RetryLinkPlugin<T extends RetryLinkPluginContext & ClientContext> implements StandardLinkPlugin<T> {
|
|
188
286
|
private readonly defaultRetry;
|
|
189
287
|
private readonly defaultRetryDelay;
|
|
@@ -227,7 +325,7 @@ interface RetryAfterLinkPluginOptions<T extends ClientContext> {
|
|
|
227
325
|
* The Retry After Link Plugin automatically retries requests based on server `retry-after` header.
|
|
228
326
|
* This is particularly useful for handling rate limiting and temporary server unavailability.
|
|
229
327
|
*
|
|
230
|
-
* @see {@link https://orpc.dev/docs/plugins/retry-after Retry After Plugin
|
|
328
|
+
* @see {@link https://orpc.dev/docs/plugins/retry-after | Retry After Plugin}
|
|
231
329
|
*/
|
|
232
330
|
declare class RetryAfterLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
233
331
|
private readonly condition;
|
|
@@ -238,5 +336,28 @@ declare class RetryAfterLinkPlugin<T extends ClientContext> implements StandardL
|
|
|
238
336
|
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
239
337
|
}
|
|
240
338
|
|
|
241
|
-
|
|
242
|
-
|
|
339
|
+
interface TimeoutLinkPluginOptions<T extends ClientContext> {
|
|
340
|
+
/**
|
|
341
|
+
* Timeout in milliseconds before the request is aborted.
|
|
342
|
+
* Use `null` or `undefined` to disable the timeout.
|
|
343
|
+
*/
|
|
344
|
+
timeout: Value<number | null | undefined, [options: StandardLinkInterceptorOptions<T>]>;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* The Timeout Link Plugin aborts requests that exceed a configured timeout with an `AbortError`.
|
|
348
|
+
*
|
|
349
|
+
* @see {@link https://orpc.dev/docs/plugins/timeout | Timeout Plugin}
|
|
350
|
+
*/
|
|
351
|
+
declare class TimeoutLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
352
|
+
private readonly timeout;
|
|
353
|
+
name: string;
|
|
354
|
+
/**
|
|
355
|
+
* Should abort if the total retry time exceeds the configured timeout
|
|
356
|
+
*/
|
|
357
|
+
after: string[];
|
|
358
|
+
constructor(options: NoInfer<TimeoutLinkPluginOptions<T>>);
|
|
359
|
+
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export { BatchLinkPlugin, RetryLinkPlugin as ClientRetryPlugin, DedupeLinkPlugin, DedupeLinkPlugin as DedupeRequestsPlugin, RequestCompressionLinkPlugin, ResponseCompressionLinkPlugin, RetryAfterLinkPlugin, RetryAfterLinkPlugin as RetryAfterPlugin, RetryLinkPlugin, TimeoutLinkPlugin };
|
|
363
|
+
export type { BatchLinkPluginGroup, BatchLinkPluginMode, BatchLinkPluginOptions, RetryLinkPluginContext as ClientRetryPluginContext, DedupeLinkPluginGroup, DedupeLinkPluginOptions, RequestCompressionLinkPluginOptions, ResponseCompressionLinkPluginOptions, RetryAfterLinkPluginOptions, RetryLinkPluginAttemptOptions, RetryLinkPluginContext, RetryLinkPluginOptions, TimeoutLinkPluginOptions };
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Value, Promisable } from '@orpc/shared';
|
|
2
|
-
import { StandardUrl, StandardHeaders, StandardRequest, StandardLazyResponse } from '@
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { StandardUrl, StandardHeaders, StandardRequest, StandardLazyResponse } from '@standard-server/core';
|
|
3
|
+
import { ClientContext } from '../index.js';
|
|
4
|
+
import { StandardLinkPlugin, StandardLinkTransportInterceptorOptions, StandardLinkOptions, StandardLinkInterceptorOptions } from '../adapters/standard/index.js';
|
|
5
5
|
|
|
6
6
|
type BatchLinkPluginMode = 'streaming' | 'buffered';
|
|
7
7
|
interface BatchLinkPluginGroup<T extends ClientContext> {
|
|
@@ -23,8 +23,6 @@ interface BatchLinkPluginGroup<T extends ClientContext> {
|
|
|
23
23
|
*/
|
|
24
24
|
path?: Value<string[], [items: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]>;
|
|
25
25
|
}
|
|
26
|
-
declare class BatchLinkPluginError extends TypeError {
|
|
27
|
-
}
|
|
28
26
|
interface BatchLinkPluginOptions<T extends ClientContext> {
|
|
29
27
|
groups: [BatchLinkPluginGroup<T>, ...BatchLinkPluginGroup<T>[]];
|
|
30
28
|
/**
|
|
@@ -79,6 +77,15 @@ interface BatchLinkPluginOptions<T extends ClientContext> {
|
|
|
79
77
|
*/
|
|
80
78
|
mapSubresponse?: (subResponse: StandardLazyResponse, batchResponse: StandardLazyResponse, subOptions: StandardLinkTransportInterceptorOptions<T>) => StandardLazyResponse;
|
|
81
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Combines multiple client requests into a single batch request
|
|
82
|
+
* and splits the batch response back into individual responses.
|
|
83
|
+
*
|
|
84
|
+
* @remarks
|
|
85
|
+
* **Note**: HTTP/2 and later already multiplex requests over a single connection, so this plugin is often less useful than it once was.
|
|
86
|
+
*
|
|
87
|
+
* @see {@link https://orpc.dev/docs/plugins/batch | Batch Plugin}
|
|
88
|
+
*/
|
|
82
89
|
declare class BatchLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
83
90
|
name: string;
|
|
84
91
|
private readonly groups;
|
|
@@ -119,10 +126,16 @@ interface DedupeLinkPluginOptions<T extends ClientContext> {
|
|
|
119
126
|
/**
|
|
120
127
|
* Filters requests to dedupe.
|
|
121
128
|
*
|
|
122
|
-
* @default ({ request }) => request.method === 'GET'
|
|
129
|
+
* @default ({ request }) => request.method === 'GET' || request.method === 'QUERY'
|
|
123
130
|
*/
|
|
124
131
|
filter?: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]>;
|
|
125
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
* Prevents redundant requests by deduplicating similar in-flight requests,
|
|
135
|
+
* reducing the number of requests sent to the server.
|
|
136
|
+
*
|
|
137
|
+
* @see {@link https://orpc.dev/docs/plugins/dedupe | Dedupe Plugin}
|
|
138
|
+
*/
|
|
126
139
|
declare class DedupeLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
127
140
|
name: string;
|
|
128
141
|
before: string[];
|
|
@@ -136,6 +149,76 @@ declare class DedupeLinkPlugin<T extends ClientContext> implements StandardLinkP
|
|
|
136
149
|
private execute;
|
|
137
150
|
}
|
|
138
151
|
|
|
152
|
+
interface RequestCompressionLinkPluginOptions<T extends ClientContext> {
|
|
153
|
+
/**
|
|
154
|
+
* The compression scheme to use for request compression.
|
|
155
|
+
*
|
|
156
|
+
* @default 'gzip'
|
|
157
|
+
*/
|
|
158
|
+
encoding?: 'gzip' | 'deflate' | 'deflate-raw';
|
|
159
|
+
/**
|
|
160
|
+
* The minimum request size in bytes required to trigger compression.
|
|
161
|
+
* Requests smaller than this threshold will not be compressed to avoid overhead.
|
|
162
|
+
* If the request size cannot be determined, compression will still be applied.
|
|
163
|
+
*
|
|
164
|
+
* @default 1024 (1KB)
|
|
165
|
+
*/
|
|
166
|
+
threshold?: number;
|
|
167
|
+
/**
|
|
168
|
+
* Determines whether a request with the given Content-Type should be compressed.
|
|
169
|
+
* Only consulted for binary transfers (streams, files, and file form-data parts).
|
|
170
|
+
* Also receives the transport interceptor options for per-request decisions.
|
|
171
|
+
*
|
|
172
|
+
* @default isCompressibleContentType (covers common text-based formats)
|
|
173
|
+
*/
|
|
174
|
+
isCompressibleContentType?: (contentType: string | null | undefined, options: StandardLinkTransportInterceptorOptions<T>) => boolean;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Compresses request bodies before sending them to the server,
|
|
178
|
+
* reducing bandwidth usage for large payloads.
|
|
179
|
+
*
|
|
180
|
+
* @see {@link https://orpc.dev/docs/plugins/request-compression | Request Compression Plugin}
|
|
181
|
+
*/
|
|
182
|
+
declare class RequestCompressionLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
183
|
+
name: string;
|
|
184
|
+
/**
|
|
185
|
+
* Compression should be done after batching, to compress the final request
|
|
186
|
+
*/
|
|
187
|
+
after: string[];
|
|
188
|
+
private readonly encoding;
|
|
189
|
+
private readonly threshold;
|
|
190
|
+
private readonly isCompressibleContentType;
|
|
191
|
+
constructor(options?: RequestCompressionLinkPluginOptions<T>);
|
|
192
|
+
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
interface ResponseCompressionLinkPluginOptions<_T extends ClientContext> {
|
|
196
|
+
/**
|
|
197
|
+
* Compression schemes to advertise via Accept-Encoding, in preference order.
|
|
198
|
+
* Only schemes that can be decompressed by this plugin should be listed.
|
|
199
|
+
*
|
|
200
|
+
* @default ['gzip', 'deflate']
|
|
201
|
+
*/
|
|
202
|
+
encodings?: readonly ('gzip' | 'deflate' | 'deflate-raw')[];
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Advertises Accept-Encoding on requests and decompresses response bodies
|
|
206
|
+
* based on the Content-Encoding header. Works at the standard link level,
|
|
207
|
+
* so it supports all adapters.
|
|
208
|
+
*
|
|
209
|
+
* @see {@link https://orpc.dev/docs/plugins/response-compression | Response Compression Plugin}
|
|
210
|
+
*/
|
|
211
|
+
declare class ResponseCompressionLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
212
|
+
name: string;
|
|
213
|
+
/**
|
|
214
|
+
* Decompression should wrap the final batch response instead of sub-responses.
|
|
215
|
+
*/
|
|
216
|
+
after: string[];
|
|
217
|
+
private readonly encodings;
|
|
218
|
+
constructor(options?: ResponseCompressionLinkPluginOptions<T>);
|
|
219
|
+
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
220
|
+
}
|
|
221
|
+
|
|
139
222
|
interface RetryLinkPluginAttemptOptions<T extends RetryLinkPluginContext> extends StandardLinkInterceptorOptions<T> {
|
|
140
223
|
/**
|
|
141
224
|
* Latest retry delay advertised by the server via event metadata.
|
|
@@ -150,10 +233,16 @@ interface RetryLinkPluginAttemptOptions<T extends RetryLinkPluginContext> extend
|
|
|
150
233
|
*/
|
|
151
234
|
error: unknown;
|
|
152
235
|
}
|
|
236
|
+
/**
|
|
237
|
+
* Client context options that control retry behavior per call
|
|
238
|
+
* when the `RetryLinkPlugin` is enabled.
|
|
239
|
+
*
|
|
240
|
+
* @see {@link https://orpc.dev/docs/plugins/retry | Retry Plugin}
|
|
241
|
+
*/
|
|
153
242
|
interface RetryLinkPluginContext {
|
|
154
243
|
/**
|
|
155
244
|
* Maximum retry attempts before throwing.
|
|
156
|
-
* Use `Number.POSITIVE_INFINITY` for infinite retries (e.g. for
|
|
245
|
+
* Use `Number.POSITIVE_INFINITY` for infinite retries (e.g. for AsyncIteratorObject).
|
|
157
246
|
*
|
|
158
247
|
* @default 0
|
|
159
248
|
*/
|
|
@@ -161,7 +250,9 @@ interface RetryLinkPluginContext {
|
|
|
161
250
|
/**
|
|
162
251
|
* Delay (in ms) before retrying.
|
|
163
252
|
*
|
|
164
|
-
* @
|
|
253
|
+
* @remarks
|
|
254
|
+
* **Note**: Why 2000ms? The EventSource spec suggests a default retry delay of 2 seconds if it doesn't specify
|
|
255
|
+
*
|
|
165
256
|
* @default (o) => o.lastEventRetry ?? 2000
|
|
166
257
|
*/
|
|
167
258
|
retryDelay?: Value<Promisable<number>, [RetryLinkPluginAttemptOptions<RetryLinkPluginContext>]>;
|
|
@@ -182,8 +273,15 @@ interface RetryLinkPluginOptions<_T extends RetryLinkPluginContext> {
|
|
|
182
273
|
*/
|
|
183
274
|
default?: RetryLinkPluginContext | undefined;
|
|
184
275
|
}
|
|
185
|
-
|
|
186
|
-
|
|
276
|
+
/**
|
|
277
|
+
* Automatically retries failed requests based on customizable retry strategies,
|
|
278
|
+
* improving the resilience of your application.
|
|
279
|
+
*
|
|
280
|
+
* @remarks
|
|
281
|
+
* **Note**: Retry behavior is configured through the client context on each call.
|
|
282
|
+
*
|
|
283
|
+
* @see {@link https://orpc.dev/docs/plugins/retry | Retry Plugin}
|
|
284
|
+
*/
|
|
187
285
|
declare class RetryLinkPlugin<T extends RetryLinkPluginContext & ClientContext> implements StandardLinkPlugin<T> {
|
|
188
286
|
private readonly defaultRetry;
|
|
189
287
|
private readonly defaultRetryDelay;
|
|
@@ -227,7 +325,7 @@ interface RetryAfterLinkPluginOptions<T extends ClientContext> {
|
|
|
227
325
|
* The Retry After Link Plugin automatically retries requests based on server `retry-after` header.
|
|
228
326
|
* This is particularly useful for handling rate limiting and temporary server unavailability.
|
|
229
327
|
*
|
|
230
|
-
* @see {@link https://orpc.dev/docs/plugins/retry-after Retry After Plugin
|
|
328
|
+
* @see {@link https://orpc.dev/docs/plugins/retry-after | Retry After Plugin}
|
|
231
329
|
*/
|
|
232
330
|
declare class RetryAfterLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
233
331
|
private readonly condition;
|
|
@@ -238,5 +336,28 @@ declare class RetryAfterLinkPlugin<T extends ClientContext> implements StandardL
|
|
|
238
336
|
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
239
337
|
}
|
|
240
338
|
|
|
241
|
-
|
|
242
|
-
|
|
339
|
+
interface TimeoutLinkPluginOptions<T extends ClientContext> {
|
|
340
|
+
/**
|
|
341
|
+
* Timeout in milliseconds before the request is aborted.
|
|
342
|
+
* Use `null` or `undefined` to disable the timeout.
|
|
343
|
+
*/
|
|
344
|
+
timeout: Value<number | null | undefined, [options: StandardLinkInterceptorOptions<T>]>;
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* The Timeout Link Plugin aborts requests that exceed a configured timeout with an `AbortError`.
|
|
348
|
+
*
|
|
349
|
+
* @see {@link https://orpc.dev/docs/plugins/timeout | Timeout Plugin}
|
|
350
|
+
*/
|
|
351
|
+
declare class TimeoutLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
|
|
352
|
+
private readonly timeout;
|
|
353
|
+
name: string;
|
|
354
|
+
/**
|
|
355
|
+
* Should abort if the total retry time exceeds the configured timeout
|
|
356
|
+
*/
|
|
357
|
+
after: string[];
|
|
358
|
+
constructor(options: NoInfer<TimeoutLinkPluginOptions<T>>);
|
|
359
|
+
init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
export { BatchLinkPlugin, RetryLinkPlugin as ClientRetryPlugin, DedupeLinkPlugin, DedupeLinkPlugin as DedupeRequestsPlugin, RequestCompressionLinkPlugin, ResponseCompressionLinkPlugin, RetryAfterLinkPlugin, RetryAfterLinkPlugin as RetryAfterPlugin, RetryLinkPlugin, TimeoutLinkPlugin };
|
|
363
|
+
export type { BatchLinkPluginGroup, BatchLinkPluginMode, BatchLinkPluginOptions, RetryLinkPluginContext as ClientRetryPluginContext, DedupeLinkPluginGroup, DedupeLinkPluginOptions, RequestCompressionLinkPluginOptions, ResponseCompressionLinkPluginOptions, RetryAfterLinkPluginOptions, RetryLinkPluginAttemptOptions, RetryLinkPluginContext, RetryLinkPluginOptions, TimeoutLinkPluginOptions };
|