@orpc/client 0.0.0-next.32a6de9 → 0.0.0-next.32bf331

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.
Files changed (32) hide show
  1. package/README.md +30 -30
  2. package/dist/adapters/fetch/index.d.mts +31 -11
  3. package/dist/adapters/fetch/index.d.ts +31 -11
  4. package/dist/adapters/fetch/index.mjs +27 -13
  5. package/dist/adapters/message-port/index.d.mts +80 -0
  6. package/dist/adapters/message-port/index.d.ts +80 -0
  7. package/dist/adapters/message-port/index.mjs +87 -0
  8. package/dist/adapters/standard/index.d.mts +6 -5
  9. package/dist/adapters/standard/index.d.ts +6 -5
  10. package/dist/adapters/standard/index.mjs +4 -2
  11. package/dist/adapters/websocket/index.d.mts +29 -0
  12. package/dist/adapters/websocket/index.d.ts +29 -0
  13. package/dist/adapters/websocket/index.mjs +47 -0
  14. package/dist/index.d.mts +98 -23
  15. package/dist/index.d.ts +98 -23
  16. package/dist/index.mjs +55 -8
  17. package/dist/plugins/index.d.mts +151 -14
  18. package/dist/plugins/index.d.ts +151 -14
  19. package/dist/plugins/index.mjs +267 -38
  20. package/dist/shared/{client.C7z5zk4v.d.mts → client.2jUAqzYU.d.ts} +16 -11
  21. package/dist/shared/client.54Qh2j9q.mjs +171 -0
  22. package/dist/shared/{client.cs2A0fEV.d.ts → client.B3pNRBih.d.ts} +13 -9
  23. package/dist/shared/{client.Cev5VIeo.d.mts → client.BFAVy68H.d.mts} +13 -9
  24. package/dist/shared/client.BLtwTQUg.mjs +40 -0
  25. package/dist/shared/{client.p3ON_yzu.d.ts → client.CpCa3si8.d.mts} +16 -11
  26. package/dist/shared/{client.BQuFq0Vi.mjs → client._PIYQrwY.mjs} +98 -32
  27. package/dist/shared/client.i2uoJbEp.d.mts +83 -0
  28. package/dist/shared/client.i2uoJbEp.d.ts +83 -0
  29. package/package.json +18 -8
  30. package/dist/shared/client.CipPQkhk.d.mts +0 -29
  31. package/dist/shared/client.CipPQkhk.d.ts +0 -29
  32. package/dist/shared/client.jKEwIsRd.mjs +0 -175
@@ -1,7 +1,8 @@
1
- import { Value } from '@orpc/shared';
2
- import { StandardHeaders, StandardRequest } from '@orpc/standard-server';
3
- import { S as StandardLinkClientInterceptorOptions, a as StandardLinkPlugin, b as StandardLinkOptions, c as StandardLinkInterceptorOptions } from '../shared/client.C7z5zk4v.mjs';
4
- import { a as ClientContext } from '../shared/client.CipPQkhk.mjs';
1
+ import { Value, Promisable } from '@orpc/shared';
2
+ import { StandardHeaders, StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
3
+ import { BatchResponseMode } from '@orpc/standard-server/batch';
4
+ import { S as StandardLinkClientInterceptorOptions, a as StandardLinkPlugin, b as StandardLinkOptions, c as StandardLinkInterceptorOptions } from '../shared/client.CpCa3si8.mjs';
5
+ import { b as ClientContext } from '../shared/client.i2uoJbEp.mjs';
5
6
 
6
7
  interface BatchLinkPluginGroup<T extends ClientContext> {
7
8
  condition(options: StandardLinkClientInterceptorOptions<T>): boolean;
@@ -16,25 +17,31 @@ interface BatchLinkPluginOptions<T extends ClientContext> {
16
17
  *
17
18
  * @default 10
18
19
  */
19
- maxSize?: Value<number, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
20
+ maxSize?: Value<Promisable<number>, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
21
+ /**
22
+ * The batch response mode.
23
+ *
24
+ * @default 'streaming'
25
+ */
26
+ mode?: Value<BatchResponseMode, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
20
27
  /**
21
28
  * Defines the URL to use for the batch request.
22
29
  *
23
30
  * @default the URL of the first request in the batch + '/__batch__'
24
31
  */
25
- url?: Value<string | URL, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
32
+ url?: Value<Promisable<string | URL>, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
26
33
  /**
27
34
  * The maximum length of the URL.
28
35
  *
29
36
  * @default 2083
30
37
  */
31
- maxUrlLength?: Value<number, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
38
+ maxUrlLength?: Value<Promisable<number>, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
32
39
  /**
33
40
  * Defines the HTTP headers to use for the batch request.
34
41
  *
35
42
  * @default The same headers of all requests in the batch
36
43
  */
37
- headers?: Value<StandardHeaders, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
44
+ headers?: Value<Promisable<StandardHeaders>, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
38
45
  /**
39
46
  * Map the batch request items before sending them.
40
47
  *
@@ -51,6 +58,12 @@ interface BatchLinkPluginOptions<T extends ClientContext> {
51
58
  */
52
59
  exclude?: (options: StandardLinkClientInterceptorOptions<T>) => boolean;
53
60
  }
61
+ /**
62
+ * The Batch Requests Plugin allows you to combine multiple requests and responses into a single batch,
63
+ * reducing the overhead of sending each one separately.
64
+ *
65
+ * @see {@link https://orpc.dev/docs/plugins/batch-requests Batch Requests Plugin Docs}
66
+ */
54
67
  declare class BatchLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
55
68
  #private;
56
69
  private readonly groups;
@@ -60,8 +73,42 @@ declare class BatchLinkPlugin<T extends ClientContext> implements StandardLinkPl
60
73
  private readonly batchHeaders;
61
74
  private readonly mapRequestItem;
62
75
  private readonly exclude;
76
+ private readonly mode;
63
77
  private pending;
64
- constructor(options: BatchLinkPluginOptions<T>);
78
+ order: number;
79
+ constructor(options: NoInfer<BatchLinkPluginOptions<T>>);
80
+ init(options: StandardLinkOptions<T>): void;
81
+ }
82
+
83
+ interface DedupeRequestsPluginGroup<T extends ClientContext> {
84
+ condition(options: StandardLinkClientInterceptorOptions<T>): boolean;
85
+ /**
86
+ * The context used for the rest of the request lifecycle.
87
+ */
88
+ context: T;
89
+ }
90
+ interface DedupeRequestsPluginOptions<T extends ClientContext> {
91
+ /**
92
+ * To enable deduplication, a request must match at least one defined group.
93
+ * Requests that fall into the same group are considered for deduplication together.
94
+ */
95
+ groups: readonly [DedupeRequestsPluginGroup<T>, ...DedupeRequestsPluginGroup<T>[]];
96
+ /**
97
+ * Filters requests to dedupe
98
+ *
99
+ * @default (({ request }) => request.method === 'GET')
100
+ */
101
+ filter?: (options: StandardLinkClientInterceptorOptions<T>) => boolean;
102
+ }
103
+ /**
104
+ * Prevents duplicate requests by deduplicating similar ones to reduce server load.
105
+ *
106
+ * @see {@link https://orpc.dev/docs/plugins/dedupe-requests Dedupe Requests Plugin}
107
+ */
108
+ declare class DedupeRequestsPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
109
+ #private;
110
+ order: number;
111
+ constructor(options: NoInfer<DedupeRequestsPluginOptions<T>>);
65
112
  init(options: StandardLinkOptions<T>): void;
66
113
  }
67
114
 
@@ -77,36 +124,126 @@ interface ClientRetryPluginContext {
77
124
  *
78
125
  * @default 0
79
126
  */
80
- retry?: Value<number, [StandardLinkInterceptorOptions<ClientRetryPluginContext>]>;
127
+ retry?: Value<Promisable<number>, [StandardLinkInterceptorOptions<ClientRetryPluginContext>]>;
81
128
  /**
82
129
  * Delay (in ms) before retrying.
83
130
  *
84
131
  * @default (o) => o.lastEventRetry ?? 2000
85
132
  */
86
- retryDelay?: Value<number, [ClientRetryPluginAttemptOptions<ClientRetryPluginContext>]>;
133
+ retryDelay?: Value<Promisable<number>, [ClientRetryPluginAttemptOptions<ClientRetryPluginContext>]>;
87
134
  /**
88
135
  * Determine should retry or not.
89
136
  *
90
137
  * @default true
91
138
  */
92
- shouldRetry?: Value<boolean, [ClientRetryPluginAttemptOptions<ClientRetryPluginContext>]>;
139
+ shouldRetry?: Value<Promisable<boolean>, [ClientRetryPluginAttemptOptions<ClientRetryPluginContext>]>;
93
140
  /**
94
141
  * The hook called when retrying, and return the unsubscribe function.
95
142
  */
96
- onRetry?: (options: ClientRetryPluginAttemptOptions<ClientRetryPluginContext>) => void | (() => void);
143
+ onRetry?: (options: ClientRetryPluginAttemptOptions<ClientRetryPluginContext>) => void | ((isSuccess: boolean) => void);
97
144
  }
98
145
  declare class ClientRetryPluginInvalidEventIteratorRetryResponse extends Error {
99
146
  }
100
147
  interface ClientRetryPluginOptions {
101
148
  default?: ClientRetryPluginContext;
102
149
  }
150
+ /**
151
+ * The Client Retry Plugin enables retrying client calls when errors occur.
152
+ *
153
+ * @see {@link https://orpc.dev/docs/plugins/client-retry Client Retry Plugin Docs}
154
+ */
103
155
  declare class ClientRetryPlugin<T extends ClientRetryPluginContext> implements StandardLinkPlugin<T> {
104
156
  private readonly defaultRetry;
105
157
  private readonly defaultRetryDelay;
106
158
  private readonly defaultShouldRetry;
107
159
  private readonly defaultOnRetry;
160
+ order: number;
108
161
  constructor(options?: ClientRetryPluginOptions);
109
162
  init(options: StandardLinkOptions<T>): void;
110
163
  }
111
164
 
112
- export { BatchLinkPlugin, type BatchLinkPluginGroup, type BatchLinkPluginOptions, ClientRetryPlugin, type ClientRetryPluginAttemptOptions, type ClientRetryPluginContext, ClientRetryPluginInvalidEventIteratorRetryResponse, type ClientRetryPluginOptions };
165
+ interface RetryAfterPluginOptions<T extends ClientContext> {
166
+ /**
167
+ * Override condition to determine whether to retry or not.
168
+ *
169
+ * @default ((response) => response.status === 429 || response.status === 503)
170
+ */
171
+ condition?: Value<boolean, [
172
+ response: StandardLazyResponse,
173
+ options: StandardLinkClientInterceptorOptions<T>
174
+ ]>;
175
+ /**
176
+ * Maximum attempts before giving up retries.
177
+ *
178
+ * @default 3
179
+ */
180
+ maxAttempts?: Value<number, [
181
+ response: StandardLazyResponse,
182
+ options: StandardLinkClientInterceptorOptions<T>
183
+ ]>;
184
+ /**
185
+ * Maximum timeout in milliseconds to wait before giving up retries.
186
+ *
187
+ * @default 5 * 60 * 1000 (5 minutes)
188
+ */
189
+ timeout?: Value<number, [
190
+ response: StandardLazyResponse,
191
+ options: StandardLinkClientInterceptorOptions<T>
192
+ ]>;
193
+ }
194
+ /**
195
+ * The Retry After Plugin automatically retries requests based on server `Retry-After` headers.
196
+ * This is particularly useful for handling rate limiting and temporary server unavailability.
197
+ *
198
+ * @see {@link https://orpc.dev/docs/plugins/retry-after Retry After Plugin Docs}
199
+ */
200
+ declare class RetryAfterPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
201
+ private readonly condition;
202
+ private readonly maxAttempts;
203
+ private readonly timeout;
204
+ order: number;
205
+ constructor(options?: RetryAfterPluginOptions<T>);
206
+ init(options: StandardLinkOptions<T>): void;
207
+ private parseRetryAfterHeader;
208
+ private delayExecution;
209
+ }
210
+
211
+ interface SimpleCsrfProtectionLinkPluginOptions<T extends ClientContext> {
212
+ /**
213
+ * The name of the header to check.
214
+ *
215
+ * @default 'x-csrf-token'
216
+ */
217
+ headerName?: Value<Promisable<string>, [options: StandardLinkClientInterceptorOptions<T>]>;
218
+ /**
219
+ * The value of the header to check.
220
+ *
221
+ * @default 'orpc'
222
+ *
223
+ */
224
+ headerValue?: Value<Promisable<string>, [options: StandardLinkClientInterceptorOptions<T>]>;
225
+ /**
226
+ * Exclude a procedure from the plugin.
227
+ *
228
+ * @default false
229
+ */
230
+ exclude?: Value<Promisable<boolean>, [options: StandardLinkClientInterceptorOptions<T>]>;
231
+ }
232
+ /**
233
+ * This plugin adds basic Cross-Site Request Forgery (CSRF) protection to your oRPC application.
234
+ * It helps ensure that requests to your procedures originate from JavaScript code,
235
+ * not from other sources like standard HTML forms or direct browser navigation.
236
+ *
237
+ * @see {@link https://orpc.dev/docs/plugins/simple-csrf-protection Simple CSRF Protection Plugin Docs}
238
+ */
239
+ declare class SimpleCsrfProtectionLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
240
+ private readonly headerName;
241
+ private readonly headerValue;
242
+ private readonly exclude;
243
+ constructor(options?: SimpleCsrfProtectionLinkPluginOptions<T>);
244
+ order: number;
245
+ init(options: StandardLinkOptions<T>): void;
246
+ }
247
+
248
+ export { BatchLinkPlugin, ClientRetryPlugin, ClientRetryPluginInvalidEventIteratorRetryResponse, DedupeRequestsPlugin, RetryAfterPlugin, SimpleCsrfProtectionLinkPlugin };
249
+ export type { BatchLinkPluginGroup, BatchLinkPluginOptions, ClientRetryPluginAttemptOptions, ClientRetryPluginContext, ClientRetryPluginOptions, DedupeRequestsPluginGroup, DedupeRequestsPluginOptions, RetryAfterPluginOptions, SimpleCsrfProtectionLinkPluginOptions };
@@ -1,7 +1,8 @@
1
- import { Value } from '@orpc/shared';
2
- import { StandardHeaders, StandardRequest } from '@orpc/standard-server';
3
- import { S as StandardLinkClientInterceptorOptions, a as StandardLinkPlugin, b as StandardLinkOptions, c as StandardLinkInterceptorOptions } from '../shared/client.p3ON_yzu.js';
4
- import { a as ClientContext } from '../shared/client.CipPQkhk.js';
1
+ import { Value, Promisable } from '@orpc/shared';
2
+ import { StandardHeaders, StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
3
+ import { BatchResponseMode } from '@orpc/standard-server/batch';
4
+ import { S as StandardLinkClientInterceptorOptions, a as StandardLinkPlugin, b as StandardLinkOptions, c as StandardLinkInterceptorOptions } from '../shared/client.2jUAqzYU.js';
5
+ import { b as ClientContext } from '../shared/client.i2uoJbEp.js';
5
6
 
6
7
  interface BatchLinkPluginGroup<T extends ClientContext> {
7
8
  condition(options: StandardLinkClientInterceptorOptions<T>): boolean;
@@ -16,25 +17,31 @@ interface BatchLinkPluginOptions<T extends ClientContext> {
16
17
  *
17
18
  * @default 10
18
19
  */
19
- maxSize?: Value<number, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
20
+ maxSize?: Value<Promisable<number>, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
21
+ /**
22
+ * The batch response mode.
23
+ *
24
+ * @default 'streaming'
25
+ */
26
+ mode?: Value<BatchResponseMode, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
20
27
  /**
21
28
  * Defines the URL to use for the batch request.
22
29
  *
23
30
  * @default the URL of the first request in the batch + '/__batch__'
24
31
  */
25
- url?: Value<string | URL, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
32
+ url?: Value<Promisable<string | URL>, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
26
33
  /**
27
34
  * The maximum length of the URL.
28
35
  *
29
36
  * @default 2083
30
37
  */
31
- maxUrlLength?: Value<number, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
38
+ maxUrlLength?: Value<Promisable<number>, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
32
39
  /**
33
40
  * Defines the HTTP headers to use for the batch request.
34
41
  *
35
42
  * @default The same headers of all requests in the batch
36
43
  */
37
- headers?: Value<StandardHeaders, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
44
+ headers?: Value<Promisable<StandardHeaders>, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
38
45
  /**
39
46
  * Map the batch request items before sending them.
40
47
  *
@@ -51,6 +58,12 @@ interface BatchLinkPluginOptions<T extends ClientContext> {
51
58
  */
52
59
  exclude?: (options: StandardLinkClientInterceptorOptions<T>) => boolean;
53
60
  }
61
+ /**
62
+ * The Batch Requests Plugin allows you to combine multiple requests and responses into a single batch,
63
+ * reducing the overhead of sending each one separately.
64
+ *
65
+ * @see {@link https://orpc.dev/docs/plugins/batch-requests Batch Requests Plugin Docs}
66
+ */
54
67
  declare class BatchLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
55
68
  #private;
56
69
  private readonly groups;
@@ -60,8 +73,42 @@ declare class BatchLinkPlugin<T extends ClientContext> implements StandardLinkPl
60
73
  private readonly batchHeaders;
61
74
  private readonly mapRequestItem;
62
75
  private readonly exclude;
76
+ private readonly mode;
63
77
  private pending;
64
- constructor(options: BatchLinkPluginOptions<T>);
78
+ order: number;
79
+ constructor(options: NoInfer<BatchLinkPluginOptions<T>>);
80
+ init(options: StandardLinkOptions<T>): void;
81
+ }
82
+
83
+ interface DedupeRequestsPluginGroup<T extends ClientContext> {
84
+ condition(options: StandardLinkClientInterceptorOptions<T>): boolean;
85
+ /**
86
+ * The context used for the rest of the request lifecycle.
87
+ */
88
+ context: T;
89
+ }
90
+ interface DedupeRequestsPluginOptions<T extends ClientContext> {
91
+ /**
92
+ * To enable deduplication, a request must match at least one defined group.
93
+ * Requests that fall into the same group are considered for deduplication together.
94
+ */
95
+ groups: readonly [DedupeRequestsPluginGroup<T>, ...DedupeRequestsPluginGroup<T>[]];
96
+ /**
97
+ * Filters requests to dedupe
98
+ *
99
+ * @default (({ request }) => request.method === 'GET')
100
+ */
101
+ filter?: (options: StandardLinkClientInterceptorOptions<T>) => boolean;
102
+ }
103
+ /**
104
+ * Prevents duplicate requests by deduplicating similar ones to reduce server load.
105
+ *
106
+ * @see {@link https://orpc.dev/docs/plugins/dedupe-requests Dedupe Requests Plugin}
107
+ */
108
+ declare class DedupeRequestsPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
109
+ #private;
110
+ order: number;
111
+ constructor(options: NoInfer<DedupeRequestsPluginOptions<T>>);
65
112
  init(options: StandardLinkOptions<T>): void;
66
113
  }
67
114
 
@@ -77,36 +124,126 @@ interface ClientRetryPluginContext {
77
124
  *
78
125
  * @default 0
79
126
  */
80
- retry?: Value<number, [StandardLinkInterceptorOptions<ClientRetryPluginContext>]>;
127
+ retry?: Value<Promisable<number>, [StandardLinkInterceptorOptions<ClientRetryPluginContext>]>;
81
128
  /**
82
129
  * Delay (in ms) before retrying.
83
130
  *
84
131
  * @default (o) => o.lastEventRetry ?? 2000
85
132
  */
86
- retryDelay?: Value<number, [ClientRetryPluginAttemptOptions<ClientRetryPluginContext>]>;
133
+ retryDelay?: Value<Promisable<number>, [ClientRetryPluginAttemptOptions<ClientRetryPluginContext>]>;
87
134
  /**
88
135
  * Determine should retry or not.
89
136
  *
90
137
  * @default true
91
138
  */
92
- shouldRetry?: Value<boolean, [ClientRetryPluginAttemptOptions<ClientRetryPluginContext>]>;
139
+ shouldRetry?: Value<Promisable<boolean>, [ClientRetryPluginAttemptOptions<ClientRetryPluginContext>]>;
93
140
  /**
94
141
  * The hook called when retrying, and return the unsubscribe function.
95
142
  */
96
- onRetry?: (options: ClientRetryPluginAttemptOptions<ClientRetryPluginContext>) => void | (() => void);
143
+ onRetry?: (options: ClientRetryPluginAttemptOptions<ClientRetryPluginContext>) => void | ((isSuccess: boolean) => void);
97
144
  }
98
145
  declare class ClientRetryPluginInvalidEventIteratorRetryResponse extends Error {
99
146
  }
100
147
  interface ClientRetryPluginOptions {
101
148
  default?: ClientRetryPluginContext;
102
149
  }
150
+ /**
151
+ * The Client Retry Plugin enables retrying client calls when errors occur.
152
+ *
153
+ * @see {@link https://orpc.dev/docs/plugins/client-retry Client Retry Plugin Docs}
154
+ */
103
155
  declare class ClientRetryPlugin<T extends ClientRetryPluginContext> implements StandardLinkPlugin<T> {
104
156
  private readonly defaultRetry;
105
157
  private readonly defaultRetryDelay;
106
158
  private readonly defaultShouldRetry;
107
159
  private readonly defaultOnRetry;
160
+ order: number;
108
161
  constructor(options?: ClientRetryPluginOptions);
109
162
  init(options: StandardLinkOptions<T>): void;
110
163
  }
111
164
 
112
- export { BatchLinkPlugin, type BatchLinkPluginGroup, type BatchLinkPluginOptions, ClientRetryPlugin, type ClientRetryPluginAttemptOptions, type ClientRetryPluginContext, ClientRetryPluginInvalidEventIteratorRetryResponse, type ClientRetryPluginOptions };
165
+ interface RetryAfterPluginOptions<T extends ClientContext> {
166
+ /**
167
+ * Override condition to determine whether to retry or not.
168
+ *
169
+ * @default ((response) => response.status === 429 || response.status === 503)
170
+ */
171
+ condition?: Value<boolean, [
172
+ response: StandardLazyResponse,
173
+ options: StandardLinkClientInterceptorOptions<T>
174
+ ]>;
175
+ /**
176
+ * Maximum attempts before giving up retries.
177
+ *
178
+ * @default 3
179
+ */
180
+ maxAttempts?: Value<number, [
181
+ response: StandardLazyResponse,
182
+ options: StandardLinkClientInterceptorOptions<T>
183
+ ]>;
184
+ /**
185
+ * Maximum timeout in milliseconds to wait before giving up retries.
186
+ *
187
+ * @default 5 * 60 * 1000 (5 minutes)
188
+ */
189
+ timeout?: Value<number, [
190
+ response: StandardLazyResponse,
191
+ options: StandardLinkClientInterceptorOptions<T>
192
+ ]>;
193
+ }
194
+ /**
195
+ * The Retry After Plugin automatically retries requests based on server `Retry-After` headers.
196
+ * This is particularly useful for handling rate limiting and temporary server unavailability.
197
+ *
198
+ * @see {@link https://orpc.dev/docs/plugins/retry-after Retry After Plugin Docs}
199
+ */
200
+ declare class RetryAfterPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
201
+ private readonly condition;
202
+ private readonly maxAttempts;
203
+ private readonly timeout;
204
+ order: number;
205
+ constructor(options?: RetryAfterPluginOptions<T>);
206
+ init(options: StandardLinkOptions<T>): void;
207
+ private parseRetryAfterHeader;
208
+ private delayExecution;
209
+ }
210
+
211
+ interface SimpleCsrfProtectionLinkPluginOptions<T extends ClientContext> {
212
+ /**
213
+ * The name of the header to check.
214
+ *
215
+ * @default 'x-csrf-token'
216
+ */
217
+ headerName?: Value<Promisable<string>, [options: StandardLinkClientInterceptorOptions<T>]>;
218
+ /**
219
+ * The value of the header to check.
220
+ *
221
+ * @default 'orpc'
222
+ *
223
+ */
224
+ headerValue?: Value<Promisable<string>, [options: StandardLinkClientInterceptorOptions<T>]>;
225
+ /**
226
+ * Exclude a procedure from the plugin.
227
+ *
228
+ * @default false
229
+ */
230
+ exclude?: Value<Promisable<boolean>, [options: StandardLinkClientInterceptorOptions<T>]>;
231
+ }
232
+ /**
233
+ * This plugin adds basic Cross-Site Request Forgery (CSRF) protection to your oRPC application.
234
+ * It helps ensure that requests to your procedures originate from JavaScript code,
235
+ * not from other sources like standard HTML forms or direct browser navigation.
236
+ *
237
+ * @see {@link https://orpc.dev/docs/plugins/simple-csrf-protection Simple CSRF Protection Plugin Docs}
238
+ */
239
+ declare class SimpleCsrfProtectionLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
240
+ private readonly headerName;
241
+ private readonly headerValue;
242
+ private readonly exclude;
243
+ constructor(options?: SimpleCsrfProtectionLinkPluginOptions<T>);
244
+ order: number;
245
+ init(options: StandardLinkOptions<T>): void;
246
+ }
247
+
248
+ export { BatchLinkPlugin, ClientRetryPlugin, ClientRetryPluginInvalidEventIteratorRetryResponse, DedupeRequestsPlugin, RetryAfterPlugin, SimpleCsrfProtectionLinkPlugin };
249
+ export type { BatchLinkPluginGroup, BatchLinkPluginOptions, ClientRetryPluginAttemptOptions, ClientRetryPluginContext, ClientRetryPluginOptions, DedupeRequestsPluginGroup, DedupeRequestsPluginOptions, RetryAfterPluginOptions, SimpleCsrfProtectionLinkPluginOptions };