@orpc/client 1.14.6 → 2.0.0-beta.10

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 (38) hide show
  1. package/README.md +78 -107
  2. package/dist/adapters/fetch/index.d.mts +54 -35
  3. package/dist/adapters/fetch/index.d.ts +54 -35
  4. package/dist/adapters/fetch/index.mjs +49 -27
  5. package/dist/adapters/message-port/index.d.mts +25 -30
  6. package/dist/adapters/message-port/index.d.ts +25 -30
  7. package/dist/adapters/message-port/index.mjs +33 -29
  8. package/dist/adapters/standard/index.d.mts +59 -9
  9. package/dist/adapters/standard/index.d.ts +59 -9
  10. package/dist/adapters/standard/index.mjs +5 -5
  11. package/dist/adapters/websocket/index.d.mts +113 -21
  12. package/dist/adapters/websocket/index.d.ts +113 -21
  13. package/dist/adapters/websocket/index.mjs +95 -37
  14. package/dist/index.d.mts +84 -159
  15. package/dist/index.d.ts +84 -159
  16. package/dist/index.mjs +76 -34
  17. package/dist/plugins/index.d.mts +125 -132
  18. package/dist/plugins/index.d.ts +125 -132
  19. package/dist/plugins/index.mjs +373 -284
  20. package/dist/shared/client.8ug8I-zu.d.mts +167 -0
  21. package/dist/shared/client.8ug8I-zu.d.ts +167 -0
  22. package/dist/shared/client.BN52ep3E.mjs +174 -0
  23. package/dist/shared/client.BdItY5DT.d.mts +111 -0
  24. package/dist/shared/client.BdItY5DT.d.ts +111 -0
  25. package/dist/shared/client.CPF3hX6O.d.ts +96 -0
  26. package/dist/shared/client.Cby_-GGh.d.mts +96 -0
  27. package/dist/shared/client.D3TIIok6.mjs +343 -0
  28. package/dist/shared/client.Dnfj8jnT.mjs +92 -0
  29. package/package.json +7 -7
  30. package/dist/shared/client.2jUAqzYU.d.ts +0 -45
  31. package/dist/shared/client.B3pNRBih.d.ts +0 -91
  32. package/dist/shared/client.BFAVy68H.d.mts +0 -91
  33. package/dist/shared/client.BLtwTQUg.mjs +0 -40
  34. package/dist/shared/client.CpCa3si8.d.mts +0 -45
  35. package/dist/shared/client.D9eWXdBV.mjs +0 -174
  36. package/dist/shared/client.DLhbktiD.mjs +0 -404
  37. package/dist/shared/client.i2uoJbEp.d.mts +0 -83
  38. package/dist/shared/client.i2uoJbEp.d.ts +0 -83
package/dist/index.mjs CHANGED
@@ -1,38 +1,71 @@
1
- import { preventNativeAwait, isTypescriptObject } from '@orpc/shared';
2
- export { AsyncIteratorClass, EventPublisher, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
3
- import { i as isDefinedError } from './shared/client.D9eWXdBV.mjs';
4
- export { C as COMMON_ORPC_ERROR_DEFS, c as ORPCError, O as ORPC_CLIENT_PACKAGE_NAME, a as ORPC_CLIENT_PACKAGE_VERSION, g as createORPCErrorFromJson, b as fallbackORPCErrorMessage, f as fallbackORPCErrorStatus, e as isORPCErrorJson, d as isORPCErrorStatus, t as toORPCError } from './shared/client.D9eWXdBV.mjs';
5
- export { m as mapEventIterator } from './shared/client.BLtwTQUg.mjs';
6
- export { ErrorEvent, getEventMeta, withEventMeta } from '@orpc/standard-server';
1
+ import { a as isInferableError } from './shared/client.D3TIIok6.mjs';
2
+ export { b as RPCJsonSerializer, R as RPCSerializer, d as cloneORPCError, c as createORPCErrorFromJson, i as isORPCErrorJson, t as toORPCError, w as wrapEventIteratorPreservingMeta } from './shared/client.D3TIIok6.mjs';
3
+ import { getOrBind, toArray, intercept, isTypescriptObject } from '@orpc/shared';
4
+ export { AsyncIteratorClass, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
5
+ export { C as COMMON_ERROR_STATUS_MAP, O as ORPCError } from './shared/client.Dnfj8jnT.mjs';
6
+ export { ErrorEvent, getEventMeta, unwrapEvent, withEventMeta } from '@standardserver/core';
7
7
 
8
+ const RECURSIVE_CLIENT_UNWRAP_KEYS = /* @__PURE__ */ new Set([
9
+ /**
10
+ * Prevents the client from being treated as a thenable when users
11
+ * accidentally write `await client`.
12
+ */
13
+ "then",
14
+ /**
15
+ * Commonly used by libraries to bind functions to a specific `this`
16
+ * context.
17
+ */
18
+ "bind",
19
+ /**
20
+ * Commonly accessed during primitive conversion, inspection, and logging.
21
+ */
22
+ "valueOf",
23
+ /**
24
+ * Commonly accessed during string conversion, inspection, and logging.
25
+ */
26
+ "toString",
27
+ /**
28
+ * Commonly accessed by serializers such as `JSON.stringify`.
29
+ */
30
+ "toJSON"
31
+ ]);
32
+
33
+ function resolveFriendlyClientOptions(options) {
34
+ return {
35
+ ...options,
36
+ context: options.context ?? {}
37
+ // Context only optional if all fields are optional
38
+ };
39
+ }
40
+ function resolveClientRest(rest) {
41
+ return [
42
+ rest[0],
43
+ // rest[0] can be undefined if TInput is optional,
44
+ resolveFriendlyClientOptions(rest[1] ?? {})
45
+ // rest[1] can be undefined if all fields of FriendlyClientOptions are optional
46
+ ];
47
+ }
8
48
  async function safe(promise) {
9
49
  try {
10
50
  const output = await promise;
11
51
  return Object.assign(
12
- [null, output, false, true],
13
- { error: null, data: output, isDefined: false, isSuccess: true }
52
+ [null, output, null, true],
53
+ { error: null, data: output, inferableError: null, isSuccess: true }
14
54
  );
15
55
  } catch (e) {
16
56
  const error = e;
17
- if (isDefinedError(error)) {
57
+ if (isInferableError(error)) {
18
58
  return Object.assign(
19
- [error, void 0, true, false],
20
- { error, data: void 0, isDefined: true, isSuccess: false }
59
+ [error, void 0, error, false],
60
+ { error, data: void 0, inferableError: error, isSuccess: false }
21
61
  );
22
62
  }
23
63
  return Object.assign(
24
- [error, void 0, false, false],
25
- { error, data: void 0, isDefined: false, isSuccess: false }
64
+ [error, void 0, null, false],
65
+ { error, data: void 0, inferableError: null, isSuccess: false }
26
66
  );
27
67
  }
28
68
  }
29
- function resolveFriendlyClientOptions(options) {
30
- return {
31
- ...options,
32
- context: options.context ?? {}
33
- // Context only optional if all fields are optional
34
- };
35
- }
36
69
  function consumeEventIterator(iterator, options) {
37
70
  void (async () => {
38
71
  let onFinishState;
@@ -63,32 +96,39 @@ function consumeEventIterator(iterator, options) {
63
96
  };
64
97
  }
65
98
 
66
- function createORPCClient(link, options = {}) {
67
- const path = options.path ?? [];
68
- const procedureClient = async (...[input, options2 = {}]) => {
69
- return await link.call(path, input, resolveFriendlyClientOptions(options2));
99
+ function createORPCClient(link, { path = [], ...options } = {}) {
100
+ const procedureClient = (...rest) => {
101
+ const [input, callOptions] = resolveClientRest(rest);
102
+ const interceptors = [
103
+ ...toArray(options.interceptors),
104
+ ...toArray(options.scoped?.interceptors)
105
+ ];
106
+ return intercept(
107
+ interceptors,
108
+ { ...callOptions, input, path },
109
+ ({ path: path2, input: input2, ...callOptions2 }) => link.call(path2, input2, callOptions2)
110
+ );
70
111
  };
71
112
  const recursive = new Proxy(procedureClient, {
72
113
  get(target, key) {
73
- if (typeof key !== "string") {
74
- return Reflect.get(target, key);
114
+ if (typeof key !== "string" || RECURSIVE_CLIENT_UNWRAP_KEYS.has(key)) {
115
+ return getOrBind(target, key);
75
116
  }
117
+ const scoped = options.scoped === void 0 ? void 0 : options.scoped[key];
76
118
  return createORPCClient(link, {
77
119
  ...options,
78
- path: [...path, key]
120
+ path: [...path, key],
121
+ scoped
79
122
  });
80
123
  }
81
124
  });
82
- return preventNativeAwait(recursive);
125
+ return recursive;
83
126
  }
84
127
 
85
128
  function createSafeClient(client) {
86
129
  const proxy = new Proxy((...args) => safe(client(...args)), {
87
- get(_, prop, receiver) {
88
- const value = Reflect.get(client, prop, receiver);
89
- if (typeof prop !== "string") {
90
- return value;
91
- }
130
+ get(_, prop) {
131
+ const value = getOrBind(client, prop);
92
132
  if (!isTypescriptObject(value)) {
93
133
  return value;
94
134
  }
@@ -109,4 +149,6 @@ class DynamicLink {
109
149
  }
110
150
  }
111
151
 
112
- export { DynamicLink, consumeEventIterator, createORPCClient, createSafeClient, isDefinedError, resolveFriendlyClientOptions, safe };
152
+ const isDefinedError = isInferableError;
153
+
154
+ export { DynamicLink, RECURSIVE_CLIENT_UNWRAP_KEYS, consumeEventIterator, createORPCClient, createSafeClient, isDefinedError, isInferableError, resolveClientRest, resolveFriendlyClientOptions, safe };
@@ -1,168 +1,200 @@
1
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 { b as ClientContext } from '../shared/client.i2uoJbEp.mjs';
5
- import { S as StandardLinkClientInterceptorOptions, a as StandardLinkPlugin, b as StandardLinkOptions, c as StandardLinkInterceptorOptions } from '../shared/client.CpCa3si8.mjs';
2
+ import { StandardUrl, StandardHeaders, StandardRequest, StandardLazyResponse } from '@standardserver/core';
3
+ import { C as ClientContext } from '../shared/client.8ug8I-zu.mjs';
4
+ import { c as StandardLinkPlugin, d as StandardLinkTransportInterceptorOptions, b as StandardLinkOptions, e as StandardLinkInterceptorOptions } from '../shared/client.Cby_-GGh.mjs';
6
5
 
6
+ type BatchLinkPluginMode = 'streaming' | 'buffered';
7
7
  interface BatchLinkPluginGroup<T extends ClientContext> {
8
- condition(options: StandardLinkClientInterceptorOptions<T>): boolean;
9
- context: T;
10
- path?: readonly string[];
11
- input?: unknown;
8
+ /**
9
+ * Determines whether a request should be included in this batch group.
10
+ * Requests will be evaluated against each group's condition in order,
11
+ * and included in the first group whose condition returns true.
12
+ * If no group's condition returns true, the request will not be batched.
13
+ */
14
+ condition: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]>;
15
+ /**
16
+ * The client context applied to requests in this batch group for the remainder of the link chain.
17
+ */
18
+ context: Value<T, [items: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]>;
19
+ /**
20
+ * The path segments applied to requests in this batch group for the remainder of the link chain.
21
+ *
22
+ * @default []
23
+ */
24
+ path?: Value<string[], [items: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]>;
25
+ }
26
+ declare class BatchLinkPluginError extends TypeError {
12
27
  }
13
28
  interface BatchLinkPluginOptions<T extends ClientContext> {
14
- groups: readonly [BatchLinkPluginGroup<T>, ...BatchLinkPluginGroup<T>[]];
29
+ groups: [BatchLinkPluginGroup<T>, ...BatchLinkPluginGroup<T>[]];
30
+ /**
31
+ * Filters requests to batch.
32
+ *
33
+ * @default () => true
34
+ */
35
+ filter?: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]>;
15
36
  /**
16
37
  * The maximum number of requests in the batch.
17
38
  *
18
39
  * @default 10
19
40
  */
20
- maxSize?: Value<Promisable<number>, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
41
+ maxSize?: Value<Promisable<number>, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]>;
21
42
  /**
22
43
  * The batch response mode.
23
44
  *
24
45
  * @default 'streaming'
25
46
  */
26
- mode?: Value<BatchResponseMode, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
47
+ mode?: Value<BatchLinkPluginMode, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]>;
27
48
  /**
28
- * Defines the URL to use for the batch request.
49
+ * URL for the batch request.
29
50
  *
30
- * @default the URL of the first request in the batch + '/__batch__'
51
+ * @default URL of the first subrequest in the batch + '/__batch__'
31
52
  */
32
- url?: Value<Promisable<string | URL>, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
53
+ url?: Value<Promisable<StandardUrl>, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]>;
33
54
  /**
34
- * The maximum length of the URL.
55
+ * The maximum length of the URL that runtime supports,
56
+ * if exceeded, the batch will be split into smaller batches and sent sequentially.
57
+ *
58
+ * This only applies to GET batch requests where the batch data is sent via URL query parameter.
35
59
  *
36
60
  * @default 2083
37
61
  */
38
- maxUrlLength?: Value<Promisable<number>, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
62
+ maxUrlLength?: Value<Promisable<number>, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]>;
39
63
  /**
40
- * Defines the HTTP headers to use for the batch request.
64
+ * Headers used for the batch request.
41
65
  *
42
- * @default The same headers of all requests in the batch
66
+ * @default Common headers among all subrequests in the batch.
43
67
  */
44
- headers?: Value<Promisable<StandardHeaders>, [readonly [StandardLinkClientInterceptorOptions<T>, ...StandardLinkClientInterceptorOptions<T>[]]]>;
68
+ headers?: Value<Promisable<StandardHeaders>, [subOptionsList: [StandardLinkTransportInterceptorOptions<T>, ...StandardLinkTransportInterceptorOptions<T>[]]]>;
45
69
  /**
46
- * Map the batch request items before sending them.
70
+ * Map each subrequest in the batch before it is sent.
47
71
  *
48
- * @default Removes headers that are duplicated in the batch headers.
72
+ * @default Removes headers that are duplicated with the batch headers
49
73
  */
50
- mapRequestItem?: (options: StandardLinkClientInterceptorOptions<T> & {
51
- batchUrl: URL;
52
- batchHeaders: StandardHeaders;
53
- }) => StandardRequest;
74
+ mapSubrequest?: (subOptions: StandardLinkTransportInterceptorOptions<T>, partialBatchRequest: Pick<StandardRequest, 'url' | 'headers'>) => StandardRequest;
54
75
  /**
55
- * Exclude a request from the batch.
76
+ * Maps each subresponse before returning the final response.
56
77
  *
57
- * @default () => false
78
+ * @default Low-priority merges headers from the batch response into each subresponse.
58
79
  */
59
- exclude?: (options: StandardLinkClientInterceptorOptions<T>) => boolean;
80
+ mapSubresponse?: (subResponse: StandardLazyResponse, batchResponse: StandardLazyResponse, subOptions: StandardLinkTransportInterceptorOptions<T>) => StandardLazyResponse;
60
81
  }
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
- */
67
82
  declare class BatchLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
68
- #private;
83
+ name: string;
69
84
  private readonly groups;
85
+ private readonly filter;
70
86
  private readonly maxSize;
87
+ private readonly mode;
71
88
  private readonly batchUrl;
72
89
  private readonly maxUrlLength;
73
90
  private readonly batchHeaders;
74
- private readonly mapRequestItem;
75
- private readonly exclude;
76
- private readonly mode;
77
- private pending;
78
- order: number;
91
+ private readonly mapSubrequest;
92
+ private readonly mapSubresponse;
93
+ private readonly queue;
79
94
  constructor(options: NoInfer<BatchLinkPluginOptions<T>>);
80
- init(options: StandardLinkOptions<T>): void;
95
+ init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
96
+ private processPendingBatches;
97
+ private executeBatch;
81
98
  }
82
99
 
83
- interface DedupeRequestsPluginGroup<T extends ClientContext> {
84
- condition(options: StandardLinkClientInterceptorOptions<T>): boolean;
100
+ interface DedupeLinkPluginGroup<T extends ClientContext> {
101
+ condition: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]>;
85
102
  /**
86
103
  * The context used for the rest of the request lifecycle.
87
104
  */
88
- context: T;
105
+ context: Value<T, [
106
+ items: [
107
+ StandardLinkTransportInterceptorOptions<T>,
108
+ StandardLinkTransportInterceptorOptions<T>,
109
+ ...StandardLinkTransportInterceptorOptions<T>[]
110
+ ]
111
+ ]>;
89
112
  }
90
- interface DedupeRequestsPluginOptions<T extends ClientContext> {
113
+ interface DedupeLinkPluginOptions<T extends ClientContext> {
91
114
  /**
92
115
  * To enable deduplication, a request must match at least one defined group.
93
116
  * Requests that fall into the same group are considered for deduplication together.
94
117
  */
95
- groups: readonly [DedupeRequestsPluginGroup<T>, ...DedupeRequestsPluginGroup<T>[]];
118
+ groups: [DedupeLinkPluginGroup<T>, ...DedupeLinkPluginGroup<T>[]];
96
119
  /**
97
- * Filters requests to dedupe
120
+ * Filters requests to dedupe.
98
121
  *
99
- * @default (({ request }) => request.method === 'GET')
122
+ * @default ({ request }) => request.method === 'GET'
100
123
  */
101
- filter?: (options: StandardLinkClientInterceptorOptions<T>) => boolean;
124
+ filter?: Value<boolean, [options: StandardLinkTransportInterceptorOptions<T>]>;
102
125
  }
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>>);
112
- init(options: StandardLinkOptions<T>): void;
126
+ declare class DedupeLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
127
+ name: string;
128
+ before: string[];
129
+ private readonly groups;
130
+ private readonly filter;
131
+ private readonly queue;
132
+ constructor(options: NoInfer<DedupeLinkPluginOptions<T>>);
133
+ init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
134
+ private enqueue;
135
+ private processPendingRequests;
136
+ private execute;
113
137
  }
114
138
 
115
- interface ClientRetryPluginAttemptOptions<T extends ClientContext> extends StandardLinkInterceptorOptions<T> {
139
+ interface RetryLinkPluginAttemptOptions<T extends RetryLinkPluginContext> extends StandardLinkInterceptorOptions<T> {
140
+ /**
141
+ * Latest retry delay advertised by the server via event metadata.
142
+ */
116
143
  lastEventRetry: number | undefined;
117
- attemptIndex: number;
144
+ /**
145
+ * Current retry attempt number, starting at 1.
146
+ */
147
+ attempt: number;
148
+ /**
149
+ * Error that triggered this retry attempt.
150
+ */
118
151
  error: unknown;
119
152
  }
120
- interface ClientRetryPluginContext {
153
+ interface RetryLinkPluginContext {
121
154
  /**
122
- * Maximum retry attempts before throwing
123
- * Use `Number.POSITIVE_INFINITY` for infinite retries (e.g., when handling Server-Sent Events).
155
+ * Maximum retry attempts before throwing.
156
+ * Use `Number.POSITIVE_INFINITY` for infinite retries (e.g. for event iterators).
124
157
  *
125
158
  * @default 0
126
159
  */
127
- retry?: Value<Promisable<number>, [StandardLinkInterceptorOptions<ClientRetryPluginContext>]>;
160
+ retry?: Value<Promisable<number>, [Omit<StandardLinkInterceptorOptions<RetryLinkPluginContext>, 'next'>]>;
128
161
  /**
129
162
  * Delay (in ms) before retrying.
130
163
  *
164
+ * @info Why 2000ms? The EventSource spec suggests a default retry delay of 2 seconds if it doesn't specify
131
165
  * @default (o) => o.lastEventRetry ?? 2000
132
166
  */
133
- retryDelay?: Value<Promisable<number>, [ClientRetryPluginAttemptOptions<ClientRetryPluginContext>]>;
167
+ retryDelay?: Value<Promisable<number>, [RetryLinkPluginAttemptOptions<RetryLinkPluginContext>]>;
134
168
  /**
135
- * Determine should retry or not.
169
+ * Determine whether to retry.
136
170
  *
137
171
  * @default true
138
172
  */
139
- shouldRetry?: Value<Promisable<boolean>, [ClientRetryPluginAttemptOptions<ClientRetryPluginContext>]>;
173
+ shouldRetry?: Value<Promisable<boolean>, [RetryLinkPluginAttemptOptions<RetryLinkPluginContext>]>;
140
174
  /**
141
- * The hook called when retrying, and return the unsubscribe function.
175
+ * Hook called before each retry. Can return a cleanup callback.
142
176
  */
143
- onRetry?: (options: ClientRetryPluginAttemptOptions<ClientRetryPluginContext>) => void | ((isSuccess: boolean) => void);
177
+ onRetry?: (options: RetryLinkPluginAttemptOptions<RetryLinkPluginContext>) => void | ((isSuccess: boolean) => void);
144
178
  }
145
- declare class ClientRetryPluginInvalidEventIteratorRetryResponse extends Error {
179
+ interface RetryLinkPluginOptions<_T extends RetryLinkPluginContext> {
180
+ /**
181
+ * Default retry options. Can be overridden by individual calls via the context.
182
+ */
183
+ default?: RetryLinkPluginContext | undefined;
146
184
  }
147
- interface ClientRetryPluginOptions {
148
- default?: ClientRetryPluginContext;
185
+ declare class RetryLinkPluginInvalidEventIteratorRetryResponse extends Error {
149
186
  }
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
- */
155
- declare class ClientRetryPlugin<T extends ClientRetryPluginContext> implements StandardLinkPlugin<T> {
187
+ declare class RetryLinkPlugin<T extends RetryLinkPluginContext & ClientContext> implements StandardLinkPlugin<T> {
156
188
  private readonly defaultRetry;
157
189
  private readonly defaultRetryDelay;
158
190
  private readonly defaultShouldRetry;
159
191
  private readonly defaultOnRetry;
160
- order: number;
161
- constructor(options?: ClientRetryPluginOptions);
162
- init(options: StandardLinkOptions<T>): void;
192
+ name: string;
193
+ constructor(options?: RetryLinkPluginOptions<T>);
194
+ init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
163
195
  }
164
196
 
165
- interface RetryAfterPluginOptions<T extends ClientContext> {
197
+ interface RetryAfterLinkPluginOptions<T extends ClientContext> {
166
198
  /**
167
199
  * Override condition to determine whether to retry or not.
168
200
  *
@@ -170,7 +202,7 @@ interface RetryAfterPluginOptions<T extends ClientContext> {
170
202
  */
171
203
  condition?: Value<boolean, [
172
204
  response: StandardLazyResponse,
173
- options: StandardLinkClientInterceptorOptions<T>
205
+ options: StandardLinkTransportInterceptorOptions<T>
174
206
  ]>;
175
207
  /**
176
208
  * Maximum attempts before giving up retries.
@@ -179,7 +211,7 @@ interface RetryAfterPluginOptions<T extends ClientContext> {
179
211
  */
180
212
  maxAttempts?: Value<number, [
181
213
  response: StandardLazyResponse,
182
- options: StandardLinkClientInterceptorOptions<T>
214
+ options: StandardLinkTransportInterceptorOptions<T>
183
215
  ]>;
184
216
  /**
185
217
  * Maximum timeout in milliseconds to wait before giving up retries.
@@ -188,62 +220,23 @@ interface RetryAfterPluginOptions<T extends ClientContext> {
188
220
  */
189
221
  timeout?: Value<number, [
190
222
  response: StandardLazyResponse,
191
- options: StandardLinkClientInterceptorOptions<T>
223
+ options: StandardLinkTransportInterceptorOptions<T>
192
224
  ]>;
193
225
  }
194
226
  /**
195
- * The Retry After Plugin automatically retries requests based on server `Retry-After` headers.
227
+ * The Retry After Link Plugin automatically retries requests based on server `retry-after` header.
196
228
  * This is particularly useful for handling rate limiting and temporary server unavailability.
197
229
  *
198
230
  * @see {@link https://orpc.dev/docs/plugins/retry-after Retry After Plugin Docs}
199
231
  */
200
- declare class RetryAfterPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
232
+ declare class RetryAfterLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
201
233
  private readonly condition;
202
234
  private readonly maxAttempts;
203
235
  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;
236
+ name: string;
237
+ constructor(options?: RetryAfterLinkPluginOptions<T>);
238
+ init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
246
239
  }
247
240
 
248
- export { BatchLinkPlugin, ClientRetryPlugin, ClientRetryPluginInvalidEventIteratorRetryResponse, DedupeRequestsPlugin, RetryAfterPlugin, SimpleCsrfProtectionLinkPlugin };
249
- export type { BatchLinkPluginGroup, BatchLinkPluginOptions, ClientRetryPluginAttemptOptions, ClientRetryPluginContext, ClientRetryPluginOptions, DedupeRequestsPluginGroup, DedupeRequestsPluginOptions, RetryAfterPluginOptions, SimpleCsrfProtectionLinkPluginOptions };
241
+ export { BatchLinkPlugin, BatchLinkPluginError, DedupeLinkPlugin, RetryAfterLinkPlugin, RetryLinkPlugin, RetryLinkPluginInvalidEventIteratorRetryResponse };
242
+ export type { BatchLinkPluginGroup, BatchLinkPluginMode, BatchLinkPluginOptions, DedupeLinkPluginGroup, DedupeLinkPluginOptions, RetryAfterLinkPluginOptions, RetryLinkPluginAttemptOptions, RetryLinkPluginContext, RetryLinkPluginOptions };