@orpc/client 2.0.0-beta.18 → 2.0.0-beta.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -49,11 +49,14 @@ You can read the documentation [here](https://orpc.dev).
49
49
  **Framework & ecosystem integrations**
50
50
 
51
51
  - [@orpc/next](https://www.npmjs.com/package/@orpc/next): Integrate with [Next.js Server Functions](https://nextjs.org/docs/app/getting-started/mutating-data).
52
+ - [@orpc/ai-sdk](https://www.npmjs.com/package/@orpc/ai-sdk): Turn contracts and procedures into [AI SDK](https://ai-sdk.dev/) tools.
52
53
  - [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query): Integrate with [TanStack Query](https://tanstack.com/query/latest).
54
+ - [@orpc/pinia-colada](https://www.npmjs.com/package/@orpc/pinia-colada): Integrate with [Pinia Colada](https://pinia-colada.esm.dev/).
53
55
  - [@orpc/experimental-effect](https://www.npmjs.com/package/@orpc/experimental-effect): Integrate with [Effect](https://effect.website/).
54
56
  - [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Implement your contract with [NestJS](https://nestjs.com/).
55
57
  - [@orpc/bun](https://www.npmjs.com/package/@orpc/bun): Adapters for [Bun's Redis](https://bun.sh/).
56
58
  - [@orpc/cloudflare](https://www.npmjs.com/package/@orpc/cloudflare): Adapters for [Cloudflare's RateLimit and Durable Objects](https://developers.cloudflare.com/workers/).
59
+ - [@orpc/trpc](https://www.npmjs.com/package/@orpc/trpc): Reuse existing [tRPC](https://trpc.io/) routers within oRPC.
57
60
 
58
61
  **Observability**
59
62
 
@@ -105,11 +108,10 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
105
108
  <td align="center"><a href="https://github.com/valerii15298?ref=orpc" target="_blank" rel="noopener" title="Valerii Petryniak"><img src="https://avatars.githubusercontent.com/u/44531564?u=88ac74d9bacd20401518441907acad21063cd397&amp;v=4" width="139" alt="Valerii Petryniak"/><br />Valerii Petryniak</a></td>
106
109
  <td align="center"><a href="https://github.com/letstri?ref=orpc" target="_blank" rel="noopener" title="Valerii Strilets"><img src="https://avatars.githubusercontent.com/u/13253748?u=c7b10399ccc8f8081e24db94ec32cd9858e86ac3&amp;v=4" width="139" alt="Valerii Strilets"/><br />Valerii Strilets</a></td>
107
110
  <td align="center"><a href="https://github.com/K-Mistele?ref=orpc" target="_blank" rel="noopener" title="Kyle Mistele"><img src="https://avatars.githubusercontent.com/u/18430555?u=3afebeb81de666e35aaac3ed46f14159d7603ffb&amp;v=4" width="139" alt="Kyle Mistele"/><br />Kyle Mistele</a></td>
108
- <td align="center"><a href="https://github.com/andrewpeters9?ref=orpc" target="_blank" rel="noopener" title="Andrew Peters"><img src="https://avatars.githubusercontent.com/u/36251325?v=4" width="139" alt="Andrew Peters"/><br />Andrew Peters</a></td>
109
111
  <td align="center"><a href="https://github.com/R44VC0RP?ref=orpc" target="_blank" rel="noopener" title="Ryan Vogel"><img src="https://avatars.githubusercontent.com/u/89211796?u=1857347b9787d8d8a7ea5bfc333f96be92d5a683&amp;v=4" width="139" alt="Ryan Vogel"/><br />Ryan Vogel</a></td>
112
+ <td align="center"><a href="https://github.com/christ12938?ref=orpc" target="_blank" rel="noopener" title="christ12938"><img src="https://avatars.githubusercontent.com/u/25758598?v=4" width="139" alt="christ12938"/><br />christ12938</a></td>
110
113
  </tr>
111
114
  <tr>
112
- <td align="center"><a href="https://github.com/christ12938?ref=orpc" target="_blank" rel="noopener" title="christ12938"><img src="https://avatars.githubusercontent.com/u/25758598?v=4" width="139" alt="christ12938"/><br />christ12938</a></td>
113
115
  <td align="center"><a href="https://github.com/Ryanjso?ref=orpc" target="_blank" rel="noopener" title="Ryan Soderberg"><img src="https://avatars.githubusercontent.com/u/39172778?u=5ed913c31d57e7221b75784abcad48c7ebddde27&amp;v=4" width="139" alt="Ryan Soderberg"/><br />Ryan Soderberg</a></td>
114
116
  <td align="center"><a href="https://github.com/itigoore01?ref=orpc" target="_blank" rel="noopener" title="shota"><img src="https://avatars.githubusercontent.com/u/11831107?u=c976a6dc7e055eb026304c46c99100ed22b0c8e0&amp;v=4" width="139" alt="shota"/><br />shota</a></td>
115
117
  </tr>
@@ -169,6 +171,7 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
169
171
  <a href="https://github.com/nelsonlaidev?ref=orpc" target="_blank" rel="noopener" title="Nelson Lai"><img src="https://avatars.githubusercontent.com/u/75498339?u=2fc0e0b95dd184c5ffb744df977cb15a18b60672&amp;v=4" width="32" height="32" alt="Nelson Lai" /></a>
170
172
  <a href="https://github.com/nguyenlc1993?ref=orpc" target="_blank" rel="noopener" title="Lê Cao Nguyên"><img src="https://avatars.githubusercontent.com/u/13871971?u=83c8b69d9e35b589c4e1f066cc113b1d9461386f&amp;v=4" width="32" height="32" alt="Lê Cao Nguyên" /></a>
171
173
  <a href="https://github.com/wobsoriano?ref=orpc" target="_blank" rel="noopener" title="Robert Soriano"><img src="https://avatars.githubusercontent.com/u/13049130?u=6d72104182e7c9ed25934815313fb69107332111&amp;v=4" width="32" height="32" alt="Robert Soriano" /></a>
174
+ <a href="https://github.com/andrewpeters9?ref=orpc" target="_blank" rel="noopener" title="Andrew Peters"><img src="https://avatars.githubusercontent.com/u/36251325?v=4" width="32" height="32" alt="Andrew Peters" /></a>
172
175
  <a href="https://github.com/SKostyukovich?ref=orpc" target="_blank" rel="noopener" title="SKostyukovich"><img src="https://avatars.githubusercontent.com/u/10700067?v=4" width="32" height="32" alt="SKostyukovich" /></a>
173
176
  <a href="https://github.com/peter-adam-dy?ref=orpc" target="_blank" rel="noopener" title="Peter Adam"><img src="https://avatars.githubusercontent.com/u/132129459?u=4f3dbbb3b443990b56acb7d6a5d11ed2c555f6db&amp;v=4" width="32" height="32" alt="Peter Adam" /></a>
174
177
  <a href="https://github.com/FabworksHQ?ref=orpc" target="_blank" rel="noopener" title="Fabworks"><img src="https://avatars.githubusercontent.com/u/160179500?v=4" width="32" height="32" alt="Fabworks" /></a>
@@ -291,5 +291,28 @@ declare class RetryAfterLinkPlugin<T extends ClientContext> implements StandardL
291
291
  init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
292
292
  }
293
293
 
294
- export { BatchLinkPlugin, BatchLinkPluginError, DedupeLinkPlugin, RequestCompressionLinkPlugin, ResponseCompressionLinkPlugin, RetryAfterLinkPlugin, RetryLinkPlugin };
295
- export type { BatchLinkPluginGroup, BatchLinkPluginMode, BatchLinkPluginOptions, DedupeLinkPluginGroup, DedupeLinkPluginOptions, RequestCompressionLinkPluginOptions, ResponseCompressionLinkPluginOptions, RetryAfterLinkPluginOptions, RetryLinkPluginAttemptOptions, RetryLinkPluginContext, RetryLinkPluginOptions };
294
+ interface TimeoutLinkPluginOptions<T extends ClientContext> {
295
+ /**
296
+ * Timeout in milliseconds before the request is aborted.
297
+ * Use `null` or `undefined` to disable the timeout.
298
+ */
299
+ timeout: Value<number | null | undefined, [options: StandardLinkInterceptorOptions<T>]>;
300
+ }
301
+ /**
302
+ * The Timeout Link Plugin aborts requests that exceed a configured timeout with an `AbortError`.
303
+ *
304
+ * @see {@link https://orpc.dev/docs/plugins/timeout Timeout Plugin Docs}
305
+ */
306
+ declare class TimeoutLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
307
+ private readonly timeout;
308
+ name: string;
309
+ /**
310
+ * Should abort if the total retry time exceeds the configured timeout
311
+ */
312
+ after: string[];
313
+ constructor(options: NoInfer<TimeoutLinkPluginOptions<T>>);
314
+ init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
315
+ }
316
+
317
+ export { BatchLinkPlugin, BatchLinkPluginError, DedupeLinkPlugin, RequestCompressionLinkPlugin, ResponseCompressionLinkPlugin, RetryAfterLinkPlugin, RetryLinkPlugin, TimeoutLinkPlugin };
318
+ export type { BatchLinkPluginGroup, BatchLinkPluginMode, BatchLinkPluginOptions, DedupeLinkPluginGroup, DedupeLinkPluginOptions, RequestCompressionLinkPluginOptions, ResponseCompressionLinkPluginOptions, RetryAfterLinkPluginOptions, RetryLinkPluginAttemptOptions, RetryLinkPluginContext, RetryLinkPluginOptions, TimeoutLinkPluginOptions };
@@ -291,5 +291,28 @@ declare class RetryAfterLinkPlugin<T extends ClientContext> implements StandardL
291
291
  init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
292
292
  }
293
293
 
294
- export { BatchLinkPlugin, BatchLinkPluginError, DedupeLinkPlugin, RequestCompressionLinkPlugin, ResponseCompressionLinkPlugin, RetryAfterLinkPlugin, RetryLinkPlugin };
295
- export type { BatchLinkPluginGroup, BatchLinkPluginMode, BatchLinkPluginOptions, DedupeLinkPluginGroup, DedupeLinkPluginOptions, RequestCompressionLinkPluginOptions, ResponseCompressionLinkPluginOptions, RetryAfterLinkPluginOptions, RetryLinkPluginAttemptOptions, RetryLinkPluginContext, RetryLinkPluginOptions };
294
+ interface TimeoutLinkPluginOptions<T extends ClientContext> {
295
+ /**
296
+ * Timeout in milliseconds before the request is aborted.
297
+ * Use `null` or `undefined` to disable the timeout.
298
+ */
299
+ timeout: Value<number | null | undefined, [options: StandardLinkInterceptorOptions<T>]>;
300
+ }
301
+ /**
302
+ * The Timeout Link Plugin aborts requests that exceed a configured timeout with an `AbortError`.
303
+ *
304
+ * @see {@link https://orpc.dev/docs/plugins/timeout Timeout Plugin Docs}
305
+ */
306
+ declare class TimeoutLinkPlugin<T extends ClientContext> implements StandardLinkPlugin<T> {
307
+ private readonly timeout;
308
+ name: string;
309
+ /**
310
+ * Should abort if the total retry time exceeds the configured timeout
311
+ */
312
+ after: string[];
313
+ constructor(options: NoInfer<TimeoutLinkPluginOptions<T>>);
314
+ init(options: StandardLinkOptions<T>): StandardLinkOptions<T>;
315
+ }
316
+
317
+ export { BatchLinkPlugin, BatchLinkPluginError, DedupeLinkPlugin, RequestCompressionLinkPlugin, ResponseCompressionLinkPlugin, RetryAfterLinkPlugin, RetryLinkPlugin, TimeoutLinkPlugin };
318
+ export type { BatchLinkPluginGroup, BatchLinkPluginMode, BatchLinkPluginOptions, DedupeLinkPluginGroup, DedupeLinkPluginOptions, RequestCompressionLinkPluginOptions, ResponseCompressionLinkPluginOptions, RetryAfterLinkPluginOptions, RetryLinkPluginAttemptOptions, RetryLinkPluginContext, RetryLinkPluginOptions, TimeoutLinkPluginOptions };
@@ -1,4 +1,4 @@
1
- import { toArray, value, splitInHalf, stringifyJSON, isAsyncIteratorObject, defer, loadBytes, allAbortSignal, replicateAsyncIterator, replicateReadableStream, isCompressibleContentType, override, AsyncIteratorClass, sleep } from '@orpc/shared';
1
+ import { toArray, value, splitInHalf, stringifyJSON, isAsyncIteratorObject, defer, loadBytes, allAbortSignal, replicateAsyncIterator, replicateReadableStream, isCompressibleContentType, override, AsyncIteratorClass, sleep, AbortError, anyAbortSignal } from '@orpc/shared';
2
2
  import { parseStandardUrl, flattenStandardHeader, generateContentDisposition, getEventMeta } from '@standardserver/core';
3
3
  import { ClientPeer, isServerPeerSendMessage, decodePeerMessage } from '@standardserver/peer';
4
4
  import { toFetchHeaders, toStandardBody } from '@standardserver/fetch';
@@ -797,4 +797,35 @@ function parseRetryAfterHeader(value2) {
797
797
  return void 0;
798
798
  }
799
799
 
800
- export { BatchLinkPlugin, BatchLinkPluginError, DedupeLinkPlugin, RequestCompressionLinkPlugin, ResponseCompressionLinkPlugin, RetryAfterLinkPlugin, RetryLinkPlugin };
800
+ class TimeoutLinkPlugin {
801
+ timeout;
802
+ name = "~timeout";
803
+ /**
804
+ * Should abort if the total retry time exceeds the configured timeout
805
+ */
806
+ after = ["~retry"];
807
+ constructor(options) {
808
+ this.timeout = options.timeout;
809
+ }
810
+ init(options) {
811
+ const interceptor = async (interceptorOptions) => {
812
+ const timeoutMs = value(this.timeout, interceptorOptions);
813
+ if (timeoutMs === null || timeoutMs === void 0) {
814
+ return interceptorOptions.next();
815
+ }
816
+ const controller = new AbortController();
817
+ const timeoutId = setTimeout(() => {
818
+ controller.abort(new AbortError(`Request timed out after ${timeoutMs}ms`));
819
+ }, timeoutMs);
820
+ const signal = anyAbortSignal([interceptorOptions.signal, controller.signal]);
821
+ try {
822
+ return await interceptorOptions.next({ ...interceptorOptions, signal });
823
+ } finally {
824
+ clearTimeout(timeoutId);
825
+ }
826
+ };
827
+ return { ...options, interceptors: [interceptor, ...toArray(options.interceptors)] };
828
+ }
829
+ }
830
+
831
+ export { BatchLinkPlugin, BatchLinkPluginError, DedupeLinkPlugin, RequestCompressionLinkPlugin, ResponseCompressionLinkPlugin, RetryAfterLinkPlugin, RetryLinkPlugin, TimeoutLinkPlugin };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/client",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.18",
4
+ "version": "2.0.0-beta.19",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.dev",
7
7
  "repository": {
@@ -53,7 +53,7 @@
53
53
  "@standardserver/core": "^0.5.0",
54
54
  "@standardserver/fetch": "^0.5.0",
55
55
  "@standardserver/peer": "^0.5.0",
56
- "@orpc/shared": "2.0.0-beta.18"
56
+ "@orpc/shared": "2.0.0-beta.19"
57
57
  },
58
58
  "devDependencies": {
59
59
  "zod": "^4.4.3"