@orpc/client 0.0.0-next.6a2fc81 → 0.0.0-next.6a3f818

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 (29) hide show
  1. package/README.md +117 -13
  2. package/dist/adapters/fetch/index.d.mts +5 -5
  3. package/dist/adapters/fetch/index.d.ts +5 -5
  4. package/dist/adapters/fetch/index.mjs +3 -2
  5. package/dist/adapters/message-port/index.d.mts +30 -9
  6. package/dist/adapters/message-port/index.d.ts +30 -9
  7. package/dist/adapters/message-port/index.mjs +25 -10
  8. package/dist/adapters/standard/index.d.mts +3 -3
  9. package/dist/adapters/standard/index.d.ts +3 -3
  10. package/dist/adapters/standard/index.mjs +3 -2
  11. package/dist/adapters/websocket/index.d.mts +5 -5
  12. package/dist/adapters/websocket/index.d.ts +5 -5
  13. package/dist/adapters/websocket/index.mjs +4 -3
  14. package/dist/index.d.mts +8 -8
  15. package/dist/index.d.ts +8 -8
  16. package/dist/index.mjs +4 -3
  17. package/dist/plugins/index.d.mts +55 -9
  18. package/dist/plugins/index.d.ts +55 -9
  19. package/dist/plugins/index.mjs +80 -2
  20. package/dist/shared/{client.De8SW4Kw.d.ts → client.2jUAqzYU.d.ts} +1 -1
  21. package/dist/shared/{client.BxV-mzeR.d.ts → client.B3pNRBih.d.ts} +2 -2
  22. package/dist/shared/{client.D8lMmWVC.d.mts → client.BFAVy68H.d.mts} +2 -2
  23. package/dist/shared/client.BLtwTQUg.mjs +40 -0
  24. package/dist/shared/{client.D8z2qgU7.mjs → client.BRQ5L8_O.mjs} +9 -2
  25. package/dist/shared/{client.CKLkYKOx.mjs → client.BvT2y6vS.mjs} +3 -40
  26. package/dist/shared/{client.CPgZaUox.d.mts → client.CpCa3si8.d.mts} +1 -1
  27. package/dist/shared/{client.BH1AYT_p.d.mts → client.i2uoJbEp.d.mts} +2 -2
  28. package/dist/shared/{client.BH1AYT_p.d.ts → client.i2uoJbEp.d.ts} +2 -2
  29. package/package.json +8 -9
package/dist/index.d.mts CHANGED
@@ -1,8 +1,8 @@
1
- import { N as NestedClient, C as ClientLink, I as InferClientContext, a as ClientPromiseResult, b as ClientContext, F as FriendlyClientOptions, c as ClientOptions, d as Client, e as ClientRest } from './shared/client.BH1AYT_p.mjs';
2
- export { f as HTTPMethod, H as HTTPPath, h as InferClientBodyInputs, j as InferClientBodyOutputs, l as InferClientErrorUnion, k as InferClientErrors, g as InferClientInputs, i as InferClientOutputs } from './shared/client.BH1AYT_p.mjs';
1
+ import { N as NestedClient, C as ClientLink, I as InferClientContext, a as ClientPromiseResult, b as ClientContext, F as FriendlyClientOptions, c as ClientOptions, d as Client, e as ClientRest } from './shared/client.i2uoJbEp.mjs';
2
+ export { f as HTTPMethod, H as HTTPPath, h as InferClientBodyInputs, j as InferClientBodyOutputs, l as InferClientErrorUnion, k as InferClientErrors, g as InferClientInputs, i as InferClientOutputs } from './shared/client.i2uoJbEp.mjs';
3
3
  import { MaybeOptionalOptions, ThrowableError, OnFinishState, Promisable, AsyncIteratorClass } from '@orpc/shared';
4
4
  export { AsyncIteratorClass, EventPublisher, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, Registry, ThrowableError, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
5
- export { ErrorEvent } from '@orpc/standard-server';
5
+ export { ErrorEvent, EventMeta, getEventMeta, withEventMeta } from '@orpc/standard-server';
6
6
 
7
7
  interface createORPCClientOptions {
8
8
  /**
@@ -13,7 +13,7 @@ interface createORPCClientOptions {
13
13
  /**
14
14
  * Create a oRPC client-side client from a link.
15
15
  *
16
- * @see {@link https://orpc.unnoq.com/docs/client/client-side Client-side Client Docs}
16
+ * @see {@link https://orpc.dev/docs/client/client-side Client-side Client Docs}
17
17
  */
18
18
  declare function createORPCClient<T extends NestedClient<any>>(link: ClientLink<InferClientContext<T>>, options?: createORPCClientOptions): T;
19
19
 
@@ -156,7 +156,7 @@ type SafeResult<TOutput, TError> = [error: null, data: TOutput, isDefined: false
156
156
  * Works like try/catch, but can infer error types.
157
157
  *
158
158
  * @info support both tuple `[error, data, isDefined, isSuccess]` and object `{ error, data, isDefined, isSuccess }` styles.
159
- * @see {@link https://orpc.unnoq.com/docs/client/error-handling Client Error Handling Docs}
159
+ * @see {@link https://orpc.dev/docs/client/error-handling Client Error Handling Docs}
160
160
  */
161
161
  declare function safe<TOutput, TError = ThrowableError>(promise: ClientPromiseResult<TOutput, TError>): Promise<SafeResult<TOutput, TError>>;
162
162
  declare function resolveFriendlyClientOptions<T extends ClientContext>(options: FriendlyClientOptions<T>): ClientOptions<T>;
@@ -202,18 +202,18 @@ type SafeClient<T extends NestedClient<any>> = T extends Client<infer UContext,
202
202
  * const { error, data, isDefined } = await safeClient.doSomething({ id: '123' })
203
203
  * ```
204
204
  *
205
- * @see {@link https://orpc.unnoq.com/docs/client/error-handling#using-createsafeclient Safe Client Docs}
205
+ * @see {@link https://orpc.dev/docs/client/error-handling#using-createsafeclient Safe Client Docs}
206
206
  */
207
207
  declare function createSafeClient<T extends NestedClient<any>>(client: T): SafeClient<T>;
208
208
 
209
209
  declare const ORPC_CLIENT_PACKAGE_NAME = "@orpc/client";
210
- declare const ORPC_CLIENT_PACKAGE_VERSION = "0.0.0-next.6a2fc81";
210
+ declare const ORPC_CLIENT_PACKAGE_VERSION = "0.0.0-next.6a3f818";
211
211
 
212
212
  /**
213
213
  * DynamicLink provides a way to dynamically resolve and delegate calls to other ClientLinks
214
214
  * based on the request path, input, and context.
215
215
  *
216
- * @see {@link https://orpc.unnoq.com/docs/client/dynamic-link Dynamic Link Docs}
216
+ * @see {@link https://orpc.dev/docs/client/dynamic-link Dynamic Link Docs}
217
217
  */
218
218
  declare class DynamicLink<TClientContext extends ClientContext> implements ClientLink<TClientContext> {
219
219
  private readonly linkResolver;
package/dist/index.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { N as NestedClient, C as ClientLink, I as InferClientContext, a as ClientPromiseResult, b as ClientContext, F as FriendlyClientOptions, c as ClientOptions, d as Client, e as ClientRest } from './shared/client.BH1AYT_p.js';
2
- export { f as HTTPMethod, H as HTTPPath, h as InferClientBodyInputs, j as InferClientBodyOutputs, l as InferClientErrorUnion, k as InferClientErrors, g as InferClientInputs, i as InferClientOutputs } from './shared/client.BH1AYT_p.js';
1
+ import { N as NestedClient, C as ClientLink, I as InferClientContext, a as ClientPromiseResult, b as ClientContext, F as FriendlyClientOptions, c as ClientOptions, d as Client, e as ClientRest } from './shared/client.i2uoJbEp.js';
2
+ export { f as HTTPMethod, H as HTTPPath, h as InferClientBodyInputs, j as InferClientBodyOutputs, l as InferClientErrorUnion, k as InferClientErrors, g as InferClientInputs, i as InferClientOutputs } from './shared/client.i2uoJbEp.js';
3
3
  import { MaybeOptionalOptions, ThrowableError, OnFinishState, Promisable, AsyncIteratorClass } from '@orpc/shared';
4
4
  export { AsyncIteratorClass, EventPublisher, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, Registry, ThrowableError, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
5
- export { ErrorEvent } from '@orpc/standard-server';
5
+ export { ErrorEvent, EventMeta, getEventMeta, withEventMeta } from '@orpc/standard-server';
6
6
 
7
7
  interface createORPCClientOptions {
8
8
  /**
@@ -13,7 +13,7 @@ interface createORPCClientOptions {
13
13
  /**
14
14
  * Create a oRPC client-side client from a link.
15
15
  *
16
- * @see {@link https://orpc.unnoq.com/docs/client/client-side Client-side Client Docs}
16
+ * @see {@link https://orpc.dev/docs/client/client-side Client-side Client Docs}
17
17
  */
18
18
  declare function createORPCClient<T extends NestedClient<any>>(link: ClientLink<InferClientContext<T>>, options?: createORPCClientOptions): T;
19
19
 
@@ -156,7 +156,7 @@ type SafeResult<TOutput, TError> = [error: null, data: TOutput, isDefined: false
156
156
  * Works like try/catch, but can infer error types.
157
157
  *
158
158
  * @info support both tuple `[error, data, isDefined, isSuccess]` and object `{ error, data, isDefined, isSuccess }` styles.
159
- * @see {@link https://orpc.unnoq.com/docs/client/error-handling Client Error Handling Docs}
159
+ * @see {@link https://orpc.dev/docs/client/error-handling Client Error Handling Docs}
160
160
  */
161
161
  declare function safe<TOutput, TError = ThrowableError>(promise: ClientPromiseResult<TOutput, TError>): Promise<SafeResult<TOutput, TError>>;
162
162
  declare function resolveFriendlyClientOptions<T extends ClientContext>(options: FriendlyClientOptions<T>): ClientOptions<T>;
@@ -202,18 +202,18 @@ type SafeClient<T extends NestedClient<any>> = T extends Client<infer UContext,
202
202
  * const { error, data, isDefined } = await safeClient.doSomething({ id: '123' })
203
203
  * ```
204
204
  *
205
- * @see {@link https://orpc.unnoq.com/docs/client/error-handling#using-createsafeclient Safe Client Docs}
205
+ * @see {@link https://orpc.dev/docs/client/error-handling#using-createsafeclient Safe Client Docs}
206
206
  */
207
207
  declare function createSafeClient<T extends NestedClient<any>>(client: T): SafeClient<T>;
208
208
 
209
209
  declare const ORPC_CLIENT_PACKAGE_NAME = "@orpc/client";
210
- declare const ORPC_CLIENT_PACKAGE_VERSION = "0.0.0-next.6a2fc81";
210
+ declare const ORPC_CLIENT_PACKAGE_VERSION = "0.0.0-next.6a3f818";
211
211
 
212
212
  /**
213
213
  * DynamicLink provides a way to dynamically resolve and delegate calls to other ClientLinks
214
214
  * based on the request path, input, and context.
215
215
  *
216
- * @see {@link https://orpc.unnoq.com/docs/client/dynamic-link Dynamic Link Docs}
216
+ * @see {@link https://orpc.dev/docs/client/dynamic-link Dynamic Link Docs}
217
217
  */
218
218
  declare class DynamicLink<TClientContext extends ClientContext> implements ClientLink<TClientContext> {
219
219
  private readonly linkResolver;
package/dist/index.mjs CHANGED
@@ -1,8 +1,9 @@
1
1
  import { preventNativeAwait, isTypescriptObject } from '@orpc/shared';
2
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.CKLkYKOx.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, m as mapEventIterator, t as toORPCError } from './shared/client.CKLkYKOx.mjs';
5
- export { ErrorEvent } from '@orpc/standard-server';
3
+ import { i as isDefinedError } from './shared/client.BvT2y6vS.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.BvT2y6vS.mjs';
5
+ export { m as mapEventIterator } from './shared/client.BLtwTQUg.mjs';
6
+ export { ErrorEvent, getEventMeta, withEventMeta } from '@orpc/standard-server';
6
7
 
7
8
  async function safe(promise) {
8
9
  try {
@@ -1,8 +1,8 @@
1
1
  import { Value, Promisable } from '@orpc/shared';
2
- import { StandardHeaders, StandardRequest } from '@orpc/standard-server';
2
+ import { StandardHeaders, StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
3
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';
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';
6
6
 
7
7
  interface BatchLinkPluginGroup<T extends ClientContext> {
8
8
  condition(options: StandardLinkClientInterceptorOptions<T>): boolean;
@@ -62,7 +62,7 @@ interface BatchLinkPluginOptions<T extends ClientContext> {
62
62
  * The Batch Requests Plugin allows you to combine multiple requests and responses into a single batch,
63
63
  * reducing the overhead of sending each one separately.
64
64
  *
65
- * @see {@link https://orpc.unnoq.com/docs/plugins/batch-requests Batch Requests Plugin Docs}
65
+ * @see {@link https://orpc.dev/docs/plugins/batch-requests Batch Requests Plugin Docs}
66
66
  */
67
67
  declare class BatchLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
68
68
  #private;
@@ -103,7 +103,7 @@ interface DedupeRequestsPluginOptions<T extends ClientContext> {
103
103
  /**
104
104
  * Prevents duplicate requests by deduplicating similar ones to reduce server load.
105
105
  *
106
- * @see {@link https://orpc.unnoq.com/docs/plugins/dedupe-requests Dedupe Requests Plugin}
106
+ * @see {@link https://orpc.dev/docs/plugins/dedupe-requests Dedupe Requests Plugin}
107
107
  */
108
108
  declare class DedupeRequestsPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
109
109
  #private;
@@ -150,7 +150,7 @@ interface ClientRetryPluginOptions {
150
150
  /**
151
151
  * The Client Retry Plugin enables retrying client calls when errors occur.
152
152
  *
153
- * @see {@link https://orpc.unnoq.com/docs/plugins/client-retry Client Retry Plugin Docs}
153
+ * @see {@link https://orpc.dev/docs/plugins/client-retry Client Retry Plugin Docs}
154
154
  */
155
155
  declare class ClientRetryPlugin<T extends ClientRetryPluginContext> implements StandardLinkPlugin<T> {
156
156
  private readonly defaultRetry;
@@ -162,6 +162,52 @@ declare class ClientRetryPlugin<T extends ClientRetryPluginContext> implements S
162
162
  init(options: StandardLinkOptions<T>): void;
163
163
  }
164
164
 
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
+
165
211
  interface SimpleCsrfProtectionLinkPluginOptions<T extends ClientContext> {
166
212
  /**
167
213
  * The name of the header to check.
@@ -188,7 +234,7 @@ interface SimpleCsrfProtectionLinkPluginOptions<T extends ClientContext> {
188
234
  * It helps ensure that requests to your procedures originate from JavaScript code,
189
235
  * not from other sources like standard HTML forms or direct browser navigation.
190
236
  *
191
- * @see {@link https://orpc.unnoq.com/docs/plugins/simple-csrf-protection Simple CSRF Protection Plugin Docs}
237
+ * @see {@link https://orpc.dev/docs/plugins/simple-csrf-protection Simple CSRF Protection Plugin Docs}
192
238
  */
193
239
  declare class SimpleCsrfProtectionLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
194
240
  private readonly headerName;
@@ -199,5 +245,5 @@ declare class SimpleCsrfProtectionLinkPlugin<T extends ClientContext> implements
199
245
  init(options: StandardLinkOptions<T>): void;
200
246
  }
201
247
 
202
- export { BatchLinkPlugin, ClientRetryPlugin, ClientRetryPluginInvalidEventIteratorRetryResponse, DedupeRequestsPlugin, SimpleCsrfProtectionLinkPlugin };
203
- export type { BatchLinkPluginGroup, BatchLinkPluginOptions, ClientRetryPluginAttemptOptions, ClientRetryPluginContext, ClientRetryPluginOptions, DedupeRequestsPluginGroup, DedupeRequestsPluginOptions, SimpleCsrfProtectionLinkPluginOptions };
248
+ export { BatchLinkPlugin, ClientRetryPlugin, ClientRetryPluginInvalidEventIteratorRetryResponse, DedupeRequestsPlugin, RetryAfterPlugin, SimpleCsrfProtectionLinkPlugin };
249
+ export type { BatchLinkPluginGroup, BatchLinkPluginOptions, ClientRetryPluginAttemptOptions, ClientRetryPluginContext, ClientRetryPluginOptions, DedupeRequestsPluginGroup, DedupeRequestsPluginOptions, RetryAfterPluginOptions, SimpleCsrfProtectionLinkPluginOptions };
@@ -1,8 +1,8 @@
1
1
  import { Value, Promisable } from '@orpc/shared';
2
- import { StandardHeaders, StandardRequest } from '@orpc/standard-server';
2
+ import { StandardHeaders, StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
3
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';
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';
6
6
 
7
7
  interface BatchLinkPluginGroup<T extends ClientContext> {
8
8
  condition(options: StandardLinkClientInterceptorOptions<T>): boolean;
@@ -62,7 +62,7 @@ interface BatchLinkPluginOptions<T extends ClientContext> {
62
62
  * The Batch Requests Plugin allows you to combine multiple requests and responses into a single batch,
63
63
  * reducing the overhead of sending each one separately.
64
64
  *
65
- * @see {@link https://orpc.unnoq.com/docs/plugins/batch-requests Batch Requests Plugin Docs}
65
+ * @see {@link https://orpc.dev/docs/plugins/batch-requests Batch Requests Plugin Docs}
66
66
  */
67
67
  declare class BatchLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
68
68
  #private;
@@ -103,7 +103,7 @@ interface DedupeRequestsPluginOptions<T extends ClientContext> {
103
103
  /**
104
104
  * Prevents duplicate requests by deduplicating similar ones to reduce server load.
105
105
  *
106
- * @see {@link https://orpc.unnoq.com/docs/plugins/dedupe-requests Dedupe Requests Plugin}
106
+ * @see {@link https://orpc.dev/docs/plugins/dedupe-requests Dedupe Requests Plugin}
107
107
  */
108
108
  declare class DedupeRequestsPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
109
109
  #private;
@@ -150,7 +150,7 @@ interface ClientRetryPluginOptions {
150
150
  /**
151
151
  * The Client Retry Plugin enables retrying client calls when errors occur.
152
152
  *
153
- * @see {@link https://orpc.unnoq.com/docs/plugins/client-retry Client Retry Plugin Docs}
153
+ * @see {@link https://orpc.dev/docs/plugins/client-retry Client Retry Plugin Docs}
154
154
  */
155
155
  declare class ClientRetryPlugin<T extends ClientRetryPluginContext> implements StandardLinkPlugin<T> {
156
156
  private readonly defaultRetry;
@@ -162,6 +162,52 @@ declare class ClientRetryPlugin<T extends ClientRetryPluginContext> implements S
162
162
  init(options: StandardLinkOptions<T>): void;
163
163
  }
164
164
 
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
+
165
211
  interface SimpleCsrfProtectionLinkPluginOptions<T extends ClientContext> {
166
212
  /**
167
213
  * The name of the header to check.
@@ -188,7 +234,7 @@ interface SimpleCsrfProtectionLinkPluginOptions<T extends ClientContext> {
188
234
  * It helps ensure that requests to your procedures originate from JavaScript code,
189
235
  * not from other sources like standard HTML forms or direct browser navigation.
190
236
  *
191
- * @see {@link https://orpc.unnoq.com/docs/plugins/simple-csrf-protection Simple CSRF Protection Plugin Docs}
237
+ * @see {@link https://orpc.dev/docs/plugins/simple-csrf-protection Simple CSRF Protection Plugin Docs}
192
238
  */
193
239
  declare class SimpleCsrfProtectionLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
194
240
  private readonly headerName;
@@ -199,5 +245,5 @@ declare class SimpleCsrfProtectionLinkPlugin<T extends ClientContext> implements
199
245
  init(options: StandardLinkOptions<T>): void;
200
246
  }
201
247
 
202
- export { BatchLinkPlugin, ClientRetryPlugin, ClientRetryPluginInvalidEventIteratorRetryResponse, DedupeRequestsPlugin, SimpleCsrfProtectionLinkPlugin };
203
- export type { BatchLinkPluginGroup, BatchLinkPluginOptions, ClientRetryPluginAttemptOptions, ClientRetryPluginContext, ClientRetryPluginOptions, DedupeRequestsPluginGroup, DedupeRequestsPluginOptions, SimpleCsrfProtectionLinkPluginOptions };
248
+ export { BatchLinkPlugin, ClientRetryPlugin, ClientRetryPluginInvalidEventIteratorRetryResponse, DedupeRequestsPlugin, RetryAfterPlugin, SimpleCsrfProtectionLinkPlugin };
249
+ export type { BatchLinkPluginGroup, BatchLinkPluginOptions, ClientRetryPluginAttemptOptions, ClientRetryPluginContext, ClientRetryPluginOptions, DedupeRequestsPluginGroup, DedupeRequestsPluginOptions, RetryAfterPluginOptions, SimpleCsrfProtectionLinkPluginOptions };
@@ -1,6 +1,7 @@
1
1
  import { isAsyncIteratorObject, defer, value, splitInHalf, toArray, stringifyJSON, overlayProxy, AsyncIteratorClass } from '@orpc/shared';
2
2
  import { toBatchRequest, parseBatchResponse, toBatchAbortSignal } from '@orpc/standard-server/batch';
3
- import { replicateStandardLazyResponse, getEventMeta } from '@orpc/standard-server';
3
+ import { replicateStandardLazyResponse, getEventMeta, flattenHeader } from '@orpc/standard-server';
4
+ import { C as COMMON_ORPC_ERROR_DEFS } from '../shared/client.BvT2y6vS.mjs';
4
5
 
5
6
  class BatchLinkPlugin {
6
7
  groups;
@@ -371,6 +372,83 @@ class ClientRetryPlugin {
371
372
  }
372
373
  }
373
374
 
375
+ class RetryAfterPlugin {
376
+ condition;
377
+ maxAttempts;
378
+ timeout;
379
+ order = 19e5;
380
+ constructor(options = {}) {
381
+ this.condition = options.condition ?? ((response) => response.status === COMMON_ORPC_ERROR_DEFS.TOO_MANY_REQUESTS.status || response.status === COMMON_ORPC_ERROR_DEFS.SERVICE_UNAVAILABLE.status);
382
+ this.maxAttempts = options.maxAttempts ?? 3;
383
+ this.timeout = options.timeout ?? 5 * 60 * 1e3;
384
+ }
385
+ init(options) {
386
+ options.clientInterceptors ??= [];
387
+ options.clientInterceptors.push(async (interceptorOptions) => {
388
+ const startTime = Date.now();
389
+ let attemptCount = 0;
390
+ while (true) {
391
+ attemptCount++;
392
+ const response = await interceptorOptions.next();
393
+ if (!value(this.condition, response, interceptorOptions)) {
394
+ return response;
395
+ }
396
+ const retryAfterHeader = flattenHeader(response.headers["retry-after"]);
397
+ const retryAfterMs = this.parseRetryAfterHeader(retryAfterHeader);
398
+ if (retryAfterMs === void 0) {
399
+ return response;
400
+ }
401
+ if (attemptCount >= value(this.maxAttempts, response, interceptorOptions)) {
402
+ return response;
403
+ }
404
+ const timeoutMs = value(this.timeout, response, interceptorOptions);
405
+ const elapsedTime = Date.now() - startTime;
406
+ if (elapsedTime + retryAfterMs > timeoutMs) {
407
+ return response;
408
+ }
409
+ await this.delayExecution(retryAfterMs, interceptorOptions.signal);
410
+ if (interceptorOptions.signal?.aborted) {
411
+ return response;
412
+ }
413
+ }
414
+ });
415
+ }
416
+ parseRetryAfterHeader(value2) {
417
+ value2 = value2?.trim();
418
+ if (!value2) {
419
+ return void 0;
420
+ }
421
+ const seconds = Number(value2);
422
+ if (Number.isFinite(seconds)) {
423
+ return Math.max(0, seconds * 1e3);
424
+ }
425
+ const retryDate = Date.parse(value2);
426
+ if (!Number.isNaN(retryDate)) {
427
+ return Math.max(0, retryDate - Date.now());
428
+ }
429
+ return void 0;
430
+ }
431
+ delayExecution(ms, signal) {
432
+ return new Promise((resolve) => {
433
+ if (signal?.aborted) {
434
+ resolve();
435
+ return;
436
+ }
437
+ let timeout;
438
+ const onAbort = () => {
439
+ clearTimeout(timeout);
440
+ timeout = void 0;
441
+ resolve();
442
+ };
443
+ signal?.addEventListener("abort", onAbort, { once: true });
444
+ timeout = setTimeout(() => {
445
+ signal?.removeEventListener("abort", onAbort);
446
+ resolve();
447
+ }, ms);
448
+ });
449
+ }
450
+ }
451
+
374
452
  class SimpleCsrfProtectionLinkPlugin {
375
453
  headerName;
376
454
  headerValue;
@@ -404,4 +482,4 @@ class SimpleCsrfProtectionLinkPlugin {
404
482
  }
405
483
  }
406
484
 
407
- export { BatchLinkPlugin, ClientRetryPlugin, ClientRetryPluginInvalidEventIteratorRetryResponse, DedupeRequestsPlugin, SimpleCsrfProtectionLinkPlugin };
485
+ export { BatchLinkPlugin, ClientRetryPlugin, ClientRetryPluginInvalidEventIteratorRetryResponse, DedupeRequestsPlugin, RetryAfterPlugin, SimpleCsrfProtectionLinkPlugin };
@@ -1,6 +1,6 @@
1
1
  import { Interceptor } from '@orpc/shared';
2
2
  import { StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
3
- import { b as ClientContext, c as ClientOptions, C as ClientLink } from './client.BH1AYT_p.js';
3
+ import { b as ClientContext, c as ClientOptions, C as ClientLink } from './client.i2uoJbEp.js';
4
4
 
5
5
  interface StandardLinkPlugin<T extends ClientContext> {
6
6
  order?: number;
@@ -1,5 +1,5 @@
1
- import { b as ClientContext, c as ClientOptions, f as HTTPMethod } from './client.BH1AYT_p.js';
2
- import { e as StandardLinkCodec, b as StandardLinkOptions, d as StandardLink, f as StandardLinkClient } from './client.De8SW4Kw.js';
1
+ import { b as ClientContext, c as ClientOptions, f as HTTPMethod } from './client.i2uoJbEp.js';
2
+ import { e as StandardLinkCodec, b as StandardLinkOptions, d as StandardLink, f as StandardLinkClient } from './client.2jUAqzYU.js';
3
3
  import { Segment, Value, Promisable } from '@orpc/shared';
4
4
  import { StandardHeaders, StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
5
5
 
@@ -1,5 +1,5 @@
1
- import { b as ClientContext, c as ClientOptions, f as HTTPMethod } from './client.BH1AYT_p.mjs';
2
- import { e as StandardLinkCodec, b as StandardLinkOptions, d as StandardLink, f as StandardLinkClient } from './client.CPgZaUox.mjs';
1
+ import { b as ClientContext, c as ClientOptions, f as HTTPMethod } from './client.i2uoJbEp.mjs';
2
+ import { e as StandardLinkCodec, b as StandardLinkOptions, d as StandardLink, f as StandardLinkClient } from './client.CpCa3si8.mjs';
3
3
  import { Segment, Value, Promisable } from '@orpc/shared';
4
4
  import { StandardHeaders, StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
5
5
 
@@ -0,0 +1,40 @@
1
+ import { AsyncIteratorClass, isTypescriptObject } from '@orpc/shared';
2
+ import { getEventMeta, withEventMeta } from '@orpc/standard-server';
3
+
4
+ function mapEventIterator(iterator, maps) {
5
+ const mapError = async (error) => {
6
+ let mappedError = await maps.error(error);
7
+ if (mappedError !== error) {
8
+ const meta = getEventMeta(error);
9
+ if (meta && isTypescriptObject(mappedError)) {
10
+ mappedError = withEventMeta(mappedError, meta);
11
+ }
12
+ }
13
+ return mappedError;
14
+ };
15
+ return new AsyncIteratorClass(async () => {
16
+ const { done, value } = await (async () => {
17
+ try {
18
+ return await iterator.next();
19
+ } catch (error) {
20
+ throw await mapError(error);
21
+ }
22
+ })();
23
+ let mappedValue = await maps.value(value, done);
24
+ if (mappedValue !== value) {
25
+ const meta = getEventMeta(value);
26
+ if (meta && isTypescriptObject(mappedValue)) {
27
+ mappedValue = withEventMeta(mappedValue, meta);
28
+ }
29
+ }
30
+ return { done, value: mappedValue };
31
+ }, async () => {
32
+ try {
33
+ await iterator.return?.();
34
+ } catch (error) {
35
+ throw await mapError(error);
36
+ }
37
+ });
38
+ }
39
+
40
+ export { mapEventIterator as m };
@@ -1,7 +1,8 @@
1
1
  import { toArray, runWithSpan, ORPC_NAME, isAsyncIteratorObject, asyncIteratorWithSpan, intercept, getGlobalOtelConfig, isObject, value, stringifyJSON } from '@orpc/shared';
2
2
  import { mergeStandardHeaders, ErrorEvent } from '@orpc/standard-server';
3
- import { C as COMMON_ORPC_ERROR_DEFS, d as isORPCErrorStatus, e as isORPCErrorJson, g as createORPCErrorFromJson, c as ORPCError, m as mapEventIterator, t as toORPCError } from './client.CKLkYKOx.mjs';
3
+ import { C as COMMON_ORPC_ERROR_DEFS, d as isORPCErrorStatus, e as isORPCErrorJson, g as createORPCErrorFromJson, c as ORPCError, t as toORPCError } from './client.BvT2y6vS.mjs';
4
4
  import { toStandardHeaders as toStandardHeaders$1 } from '@orpc/standard-server-fetch';
5
+ import { m as mapEventIterator } from './client.BLtwTQUg.mjs';
5
6
 
6
7
  class CompositeStandardLinkPlugin {
7
8
  plugins;
@@ -144,7 +145,7 @@ class StandardRPCJsonSerializer {
144
145
  const json = data.map((v, i) => {
145
146
  if (v === void 0) {
146
147
  meta.push([STANDARD_RPC_JSON_SERIALIZER_BUILT_IN_TYPES.UNDEFINED, ...segments, i]);
147
- return v;
148
+ return null;
148
149
  }
149
150
  return this.serialize(v, [...segments, i], meta, maps, blobs)[0];
150
151
  });
@@ -171,6 +172,9 @@ class StandardRPCJsonSerializer {
171
172
  segments.forEach((segment) => {
172
173
  currentRef = currentRef[preSegment];
173
174
  preSegment = segment;
175
+ if (!Object.hasOwn(currentRef, preSegment)) {
176
+ throw new Error(`Security error: accessing non-existent path during deserialization. Path segment: ${preSegment}`);
177
+ }
174
178
  });
175
179
  currentRef[preSegment] = getBlob(i);
176
180
  });
@@ -182,6 +186,9 @@ class StandardRPCJsonSerializer {
182
186
  for (let i = 1; i < item.length; i++) {
183
187
  currentRef = currentRef[preSegment];
184
188
  preSegment = item[i];
189
+ if (!Object.hasOwn(currentRef, preSegment)) {
190
+ throw new Error(`Security error: accessing non-existent path during deserialization. Path segment: ${preSegment}`);
191
+ }
185
192
  }
186
193
  for (const custom of this.customSerializers) {
187
194
  if (custom.type === type) {
@@ -1,8 +1,7 @@
1
- import { resolveMaybeOptionalOptions, getConstructor, isObject, AsyncIteratorClass, isTypescriptObject } from '@orpc/shared';
2
- import { getEventMeta, withEventMeta } from '@orpc/standard-server';
1
+ import { resolveMaybeOptionalOptions, getConstructor, isObject } from '@orpc/shared';
3
2
 
4
3
  const ORPC_CLIENT_PACKAGE_NAME = "@orpc/client";
5
- const ORPC_CLIENT_PACKAGE_VERSION = "0.0.0-next.6a2fc81";
4
+ const ORPC_CLIENT_PACKAGE_VERSION = "0.0.0-next.6a3f818";
6
5
 
7
6
  const COMMON_ORPC_ERROR_DEFS = {
8
7
  BAD_REQUEST: {
@@ -169,40 +168,4 @@ function createORPCErrorFromJson(json, options = {}) {
169
168
  });
170
169
  }
171
170
 
172
- function mapEventIterator(iterator, maps) {
173
- const mapError = async (error) => {
174
- let mappedError = await maps.error(error);
175
- if (mappedError !== error) {
176
- const meta = getEventMeta(error);
177
- if (meta && isTypescriptObject(mappedError)) {
178
- mappedError = withEventMeta(mappedError, meta);
179
- }
180
- }
181
- return mappedError;
182
- };
183
- return new AsyncIteratorClass(async () => {
184
- const { done, value } = await (async () => {
185
- try {
186
- return await iterator.next();
187
- } catch (error) {
188
- throw await mapError(error);
189
- }
190
- })();
191
- let mappedValue = await maps.value(value, done);
192
- if (mappedValue !== value) {
193
- const meta = getEventMeta(value);
194
- if (meta && isTypescriptObject(mappedValue)) {
195
- mappedValue = withEventMeta(mappedValue, meta);
196
- }
197
- }
198
- return { done, value: mappedValue };
199
- }, async () => {
200
- try {
201
- await iterator.return?.();
202
- } catch (error) {
203
- throw await mapError(error);
204
- }
205
- });
206
- }
207
-
208
- export { COMMON_ORPC_ERROR_DEFS as C, ORPC_CLIENT_PACKAGE_NAME as O, ORPC_CLIENT_PACKAGE_VERSION as a, fallbackORPCErrorMessage as b, ORPCError as c, isORPCErrorStatus as d, isORPCErrorJson as e, fallbackORPCErrorStatus as f, createORPCErrorFromJson as g, isDefinedError as i, mapEventIterator as m, toORPCError as t };
171
+ export { COMMON_ORPC_ERROR_DEFS as C, ORPC_CLIENT_PACKAGE_NAME as O, ORPC_CLIENT_PACKAGE_VERSION as a, fallbackORPCErrorMessage as b, ORPCError as c, isORPCErrorStatus as d, isORPCErrorJson as e, fallbackORPCErrorStatus as f, createORPCErrorFromJson as g, isDefinedError as i, toORPCError as t };
@@ -1,6 +1,6 @@
1
1
  import { Interceptor } from '@orpc/shared';
2
2
  import { StandardRequest, StandardLazyResponse } from '@orpc/standard-server';
3
- import { b as ClientContext, c as ClientOptions, C as ClientLink } from './client.BH1AYT_p.mjs';
3
+ import { b as ClientContext, c as ClientOptions, C as ClientLink } from './client.i2uoJbEp.mjs';
4
4
 
5
5
  interface StandardLinkPlugin<T extends ClientContext> {
6
6
  order?: number;
@@ -64,7 +64,7 @@ type InferClientBodyOutputs<T extends NestedClient<any>> = T extends Client<any,
64
64
  [K in keyof T]: T[K] extends NestedClient<any> ? InferClientBodyOutputs<T[K]> : never;
65
65
  };
66
66
  /**
67
- * Recursively infers the **error types** from a client when you use [type-safe errors](https://orpc.unnoq.com/docs/error-handling#type‐safe-error-handling).
67
+ * Recursively infers the **error types** from a client when you use [type-safe errors](https://orpc.dev/docs/error-handling#type‐safe-error-handling).
68
68
  *
69
69
  * Produces a nested map where each endpoint's error type is preserved.
70
70
  */
@@ -72,7 +72,7 @@ type InferClientErrors<T extends NestedClient<any>> = T extends Client<any, any,
72
72
  [K in keyof T]: T[K] extends NestedClient<any> ? InferClientErrors<T[K]> : never;
73
73
  };
74
74
  /**
75
- * Recursively infers a **union of all error types** from a client when you use [type-safe errors](https://orpc.unnoq.com/docs/error-handling#type‐safe-error-handling).
75
+ * Recursively infers a **union of all error types** from a client when you use [type-safe errors](https://orpc.dev/docs/error-handling#type‐safe-error-handling).
76
76
  *
77
77
  * Useful when you want to handle all possible errors from any endpoint at once.
78
78
  */
@@ -64,7 +64,7 @@ type InferClientBodyOutputs<T extends NestedClient<any>> = T extends Client<any,
64
64
  [K in keyof T]: T[K] extends NestedClient<any> ? InferClientBodyOutputs<T[K]> : never;
65
65
  };
66
66
  /**
67
- * Recursively infers the **error types** from a client when you use [type-safe errors](https://orpc.unnoq.com/docs/error-handling#type‐safe-error-handling).
67
+ * Recursively infers the **error types** from a client when you use [type-safe errors](https://orpc.dev/docs/error-handling#type‐safe-error-handling).
68
68
  *
69
69
  * Produces a nested map where each endpoint's error type is preserved.
70
70
  */
@@ -72,7 +72,7 @@ type InferClientErrors<T extends NestedClient<any>> = T extends Client<any, any,
72
72
  [K in keyof T]: T[K] extends NestedClient<any> ? InferClientErrors<T[K]> : never;
73
73
  };
74
74
  /**
75
- * Recursively infers a **union of all error types** from a client when you use [type-safe errors](https://orpc.unnoq.com/docs/error-handling#type‐safe-error-handling).
75
+ * Recursively infers a **union of all error types** from a client when you use [type-safe errors](https://orpc.dev/docs/error-handling#type‐safe-error-handling).
76
76
  *
77
77
  * Useful when you want to handle all possible errors from any endpoint at once.
78
78
  */