@orpc/client 0.0.0-next.aac73c2 → 0.0.0-next.ab2f831

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 +22 -22
  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 +7 -5
  9. package/dist/adapters/standard/index.d.ts +7 -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 +105 -27
  15. package/dist/index.d.ts +105 -27
  16. package/dist/index.mjs +61 -14
  17. package/dist/plugins/index.d.mts +209 -21
  18. package/dist/plugins/index.d.ts +209 -21
  19. package/dist/plugins/index.mjs +412 -53
  20. package/dist/shared/client.BH1AYT_p.d.mts +83 -0
  21. package/dist/shared/client.BH1AYT_p.d.ts +83 -0
  22. package/dist/shared/{client.D77bw0hs.mjs → client.BJ7mFf_E.mjs} +95 -30
  23. package/dist/shared/client.BLtwTQUg.mjs +40 -0
  24. package/dist/shared/{client.DczFzIj1.d.ts → client.BxV-mzeR.d.ts} +13 -25
  25. package/dist/shared/{client.D_TnaeH1.d.mts → client.CPgZaUox.d.mts} +20 -14
  26. package/dist/shared/client.Czkbx_PI.mjs +171 -0
  27. package/dist/shared/{client.DnHi1dp8.d.mts → client.D8lMmWVC.d.mts} +13 -25
  28. package/dist/shared/{client.BZZMKcrk.d.ts → client.De8SW4Kw.d.ts} +20 -14
  29. package/package.json +16 -5
  30. package/dist/shared/client.Bnaxb-CE.d.mts +0 -30
  31. package/dist/shared/client.Bnaxb-CE.d.ts +0 -30
  32. package/dist/shared/client.jKEwIsRd.mjs +0 -175
@@ -1,11 +1,119 @@
1
- import { Value } from '@orpc/shared';
2
- import { S as StandardLinkPlugin, a as StandardLinkOptions } from '../shared/client.D_TnaeH1.mjs';
3
- import { b as ClientOptions } from '../shared/client.Bnaxb-CE.mjs';
4
- import '@orpc/standard-server';
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.CPgZaUox.mjs';
5
+ import { b as ClientContext } from '../shared/client.BH1AYT_p.mjs';
5
6
 
6
- interface ClientRetryPluginAttemptOptions {
7
+ interface BatchLinkPluginGroup<T extends ClientContext> {
8
+ condition(options: StandardLinkClientInterceptorOptions<T>): boolean;
9
+ context: T;
10
+ path?: readonly string[];
11
+ input?: unknown;
12
+ }
13
+ interface BatchLinkPluginOptions<T extends ClientContext> {
14
+ groups: readonly [BatchLinkPluginGroup<T>, ...BatchLinkPluginGroup<T>[]];
15
+ /**
16
+ * The maximum number of requests in the batch.
17
+ *
18
+ * @default 10
19
+ */
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>[]]]>;
27
+ /**
28
+ * Defines the URL to use for the batch request.
29
+ *
30
+ * @default the URL of the first request in the batch + '/__batch__'
31
+ */
32
+ url?: Value<Promisable<string | URL>, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
33
+ /**
34
+ * The maximum length of the URL.
35
+ *
36
+ * @default 2083
37
+ */
38
+ maxUrlLength?: Value<Promisable<number>, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
39
+ /**
40
+ * Defines the HTTP headers to use for the batch request.
41
+ *
42
+ * @default The same headers of all requests in the batch
43
+ */
44
+ headers?: Value<Promisable<StandardHeaders>, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
45
+ /**
46
+ * Map the batch request items before sending them.
47
+ *
48
+ * @default Removes headers that are duplicated in the batch headers.
49
+ */
50
+ mapRequestItem?: (options: StandardLinkClientInterceptorOptions<T> & {
51
+ batchUrl: URL;
52
+ batchHeaders: StandardHeaders;
53
+ }) => StandardRequest;
54
+ /**
55
+ * Exclude a request from the batch.
56
+ *
57
+ * @default () => false
58
+ */
59
+ exclude?: (options: StandardLinkClientInterceptorOptions<T>) => boolean;
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.unnoq.com/docs/plugins/batch-requests Batch Requests Plugin Docs}
66
+ */
67
+ declare class BatchLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
68
+ #private;
69
+ private readonly groups;
70
+ private readonly maxSize;
71
+ private readonly batchUrl;
72
+ private readonly maxUrlLength;
73
+ private readonly batchHeaders;
74
+ private readonly mapRequestItem;
75
+ private readonly exclude;
76
+ private readonly mode;
77
+ private pending;
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.unnoq.com/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>>);
112
+ init(options: StandardLinkOptions<T>): void;
113
+ }
114
+
115
+ interface ClientRetryPluginAttemptOptions<T extends ClientContext> extends StandardLinkInterceptorOptions<T> {
7
116
  lastEventRetry: number | undefined;
8
- lastEventId: string | undefined;
9
117
  attemptIndex: number;
10
118
  error: unknown;
11
119
  }
@@ -16,46 +124,126 @@ interface ClientRetryPluginContext {
16
124
  *
17
125
  * @default 0
18
126
  */
19
- retry?: number;
127
+ retry?: Value<Promisable<number>, [StandardLinkInterceptorOptions<ClientRetryPluginContext>]>;
20
128
  /**
21
129
  * Delay (in ms) before retrying.
22
130
  *
23
131
  * @default (o) => o.lastEventRetry ?? 2000
24
132
  */
25
- retryDelay?: Value<number, [
26
- attemptOptions: ClientRetryPluginAttemptOptions,
27
- clientOptions: ClientOptions<ClientRetryPluginContext>,
28
- path: readonly string[],
29
- input: unknown
30
- ]>;
133
+ retryDelay?: Value<Promisable<number>, [ClientRetryPluginAttemptOptions<ClientRetryPluginContext>]>;
31
134
  /**
32
135
  * Determine should retry or not.
33
136
  *
34
137
  * @default true
35
138
  */
36
- shouldRetry?: Value<boolean, [
37
- attemptOptions: ClientRetryPluginAttemptOptions,
38
- clientOptions: ClientOptions<ClientRetryPluginContext>,
39
- path: readonly string[],
40
- input: unknown
41
- ]>;
139
+ shouldRetry?: Value<Promisable<boolean>, [ClientRetryPluginAttemptOptions<ClientRetryPluginContext>]>;
42
140
  /**
43
141
  * The hook called when retrying, and return the unsubscribe function.
44
142
  */
45
- onRetry?: (options: ClientRetryPluginAttemptOptions, clientOptions: ClientOptions<ClientRetryPluginContext>, path: readonly string[], input: unknown) => void | (() => void);
143
+ onRetry?: (options: ClientRetryPluginAttemptOptions<ClientRetryPluginContext>) => void | ((isSuccess: boolean) => void);
46
144
  }
47
145
  declare class ClientRetryPluginInvalidEventIteratorRetryResponse extends Error {
48
146
  }
49
147
  interface ClientRetryPluginOptions {
50
148
  default?: ClientRetryPluginContext;
51
149
  }
150
+ /**
151
+ * The Client Retry Plugin enables retrying client calls when errors occur.
152
+ *
153
+ * @see {@link https://orpc.unnoq.com/docs/plugins/client-retry Client Retry Plugin Docs}
154
+ */
52
155
  declare class ClientRetryPlugin<T extends ClientRetryPluginContext> implements StandardLinkPlugin<T> {
53
156
  private readonly defaultRetry;
54
157
  private readonly defaultRetryDelay;
55
158
  private readonly defaultShouldRetry;
56
159
  private readonly defaultOnRetry;
160
+ order: number;
57
161
  constructor(options?: ClientRetryPluginOptions);
58
162
  init(options: StandardLinkOptions<T>): void;
59
163
  }
60
164
 
61
- export { 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.unnoq.com/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.unnoq.com/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,11 +1,119 @@
1
- import { Value } from '@orpc/shared';
2
- import { S as StandardLinkPlugin, a as StandardLinkOptions } from '../shared/client.BZZMKcrk.js';
3
- import { b as ClientOptions } from '../shared/client.Bnaxb-CE.js';
4
- import '@orpc/standard-server';
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.De8SW4Kw.js';
5
+ import { b as ClientContext } from '../shared/client.BH1AYT_p.js';
5
6
 
6
- interface ClientRetryPluginAttemptOptions {
7
+ interface BatchLinkPluginGroup<T extends ClientContext> {
8
+ condition(options: StandardLinkClientInterceptorOptions<T>): boolean;
9
+ context: T;
10
+ path?: readonly string[];
11
+ input?: unknown;
12
+ }
13
+ interface BatchLinkPluginOptions<T extends ClientContext> {
14
+ groups: readonly [BatchLinkPluginGroup<T>, ...BatchLinkPluginGroup<T>[]];
15
+ /**
16
+ * The maximum number of requests in the batch.
17
+ *
18
+ * @default 10
19
+ */
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>[]]]>;
27
+ /**
28
+ * Defines the URL to use for the batch request.
29
+ *
30
+ * @default the URL of the first request in the batch + '/__batch__'
31
+ */
32
+ url?: Value<Promisable<string | URL>, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
33
+ /**
34
+ * The maximum length of the URL.
35
+ *
36
+ * @default 2083
37
+ */
38
+ maxUrlLength?: Value<Promisable<number>, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
39
+ /**
40
+ * Defines the HTTP headers to use for the batch request.
41
+ *
42
+ * @default The same headers of all requests in the batch
43
+ */
44
+ headers?: Value<Promisable<StandardHeaders>, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
45
+ /**
46
+ * Map the batch request items before sending them.
47
+ *
48
+ * @default Removes headers that are duplicated in the batch headers.
49
+ */
50
+ mapRequestItem?: (options: StandardLinkClientInterceptorOptions<T> & {
51
+ batchUrl: URL;
52
+ batchHeaders: StandardHeaders;
53
+ }) => StandardRequest;
54
+ /**
55
+ * Exclude a request from the batch.
56
+ *
57
+ * @default () => false
58
+ */
59
+ exclude?: (options: StandardLinkClientInterceptorOptions<T>) => boolean;
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.unnoq.com/docs/plugins/batch-requests Batch Requests Plugin Docs}
66
+ */
67
+ declare class BatchLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
68
+ #private;
69
+ private readonly groups;
70
+ private readonly maxSize;
71
+ private readonly batchUrl;
72
+ private readonly maxUrlLength;
73
+ private readonly batchHeaders;
74
+ private readonly mapRequestItem;
75
+ private readonly exclude;
76
+ private readonly mode;
77
+ private pending;
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.unnoq.com/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>>);
112
+ init(options: StandardLinkOptions<T>): void;
113
+ }
114
+
115
+ interface ClientRetryPluginAttemptOptions<T extends ClientContext> extends StandardLinkInterceptorOptions<T> {
7
116
  lastEventRetry: number | undefined;
8
- lastEventId: string | undefined;
9
117
  attemptIndex: number;
10
118
  error: unknown;
11
119
  }
@@ -16,46 +124,126 @@ interface ClientRetryPluginContext {
16
124
  *
17
125
  * @default 0
18
126
  */
19
- retry?: number;
127
+ retry?: Value<Promisable<number>, [StandardLinkInterceptorOptions<ClientRetryPluginContext>]>;
20
128
  /**
21
129
  * Delay (in ms) before retrying.
22
130
  *
23
131
  * @default (o) => o.lastEventRetry ?? 2000
24
132
  */
25
- retryDelay?: Value<number, [
26
- attemptOptions: ClientRetryPluginAttemptOptions,
27
- clientOptions: ClientOptions<ClientRetryPluginContext>,
28
- path: readonly string[],
29
- input: unknown
30
- ]>;
133
+ retryDelay?: Value<Promisable<number>, [ClientRetryPluginAttemptOptions<ClientRetryPluginContext>]>;
31
134
  /**
32
135
  * Determine should retry or not.
33
136
  *
34
137
  * @default true
35
138
  */
36
- shouldRetry?: Value<boolean, [
37
- attemptOptions: ClientRetryPluginAttemptOptions,
38
- clientOptions: ClientOptions<ClientRetryPluginContext>,
39
- path: readonly string[],
40
- input: unknown
41
- ]>;
139
+ shouldRetry?: Value<Promisable<boolean>, [ClientRetryPluginAttemptOptions<ClientRetryPluginContext>]>;
42
140
  /**
43
141
  * The hook called when retrying, and return the unsubscribe function.
44
142
  */
45
- onRetry?: (options: ClientRetryPluginAttemptOptions, clientOptions: ClientOptions<ClientRetryPluginContext>, path: readonly string[], input: unknown) => void | (() => void);
143
+ onRetry?: (options: ClientRetryPluginAttemptOptions<ClientRetryPluginContext>) => void | ((isSuccess: boolean) => void);
46
144
  }
47
145
  declare class ClientRetryPluginInvalidEventIteratorRetryResponse extends Error {
48
146
  }
49
147
  interface ClientRetryPluginOptions {
50
148
  default?: ClientRetryPluginContext;
51
149
  }
150
+ /**
151
+ * The Client Retry Plugin enables retrying client calls when errors occur.
152
+ *
153
+ * @see {@link https://orpc.unnoq.com/docs/plugins/client-retry Client Retry Plugin Docs}
154
+ */
52
155
  declare class ClientRetryPlugin<T extends ClientRetryPluginContext> implements StandardLinkPlugin<T> {
53
156
  private readonly defaultRetry;
54
157
  private readonly defaultRetryDelay;
55
158
  private readonly defaultShouldRetry;
56
159
  private readonly defaultOnRetry;
160
+ order: number;
57
161
  constructor(options?: ClientRetryPluginOptions);
58
162
  init(options: StandardLinkOptions<T>): void;
59
163
  }
60
164
 
61
- export { 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.unnoq.com/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.unnoq.com/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 };