@orpc/server 2.0.0-beta.1 → 2.0.0-beta.11

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
@@ -26,10 +26,10 @@ You can read the documentation [here](https://orpc.dev).
26
26
 
27
27
  **Core**
28
28
 
29
- - [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Define type-safe contracts for your API.
30
- - [@orpc/server](https://www.npmjs.com/package/@orpc/server): Implement your API or contract on the server.
31
- - [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API from the client with full type safety.
32
- - [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Bring OpenAPI compatibility to your APIs.
29
+ - [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Define API contract as the single source of truth.
30
+ - [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build APIs or implement contracts.
31
+ - [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume APIs with end-to-end type safety.
32
+ - [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Add OpenAPI compatibility to APIs.
33
33
 
34
34
  **Schema validation**
35
35
 
@@ -37,23 +37,25 @@ You can read the documentation [here](https://orpc.dev).
37
37
  - [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): Integrate with [Valibot](https://valibot.dev/).
38
38
  - [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): Integrate with [ArkType](https://arktype.io/).
39
39
 
40
+ **Built-in features**
41
+
42
+ - [@orpc/publisher](https://www.npmjs.com/package/@orpc/publisher): Pub/Sub with memory, Redis, and Upstash adapters.
43
+ - [@orpc/ratelimit](https://www.npmjs.com/package/@orpc/ratelimit): Rate limiting with memory, Redis, and Upstash adapters.
44
+ - [@orpc/json-schema](https://www.npmjs.com/package/@orpc/json-schema): Smart coercion for OpenAPI requests.
45
+
40
46
  **Framework & ecosystem integrations**
41
47
 
42
- - [@orpc/next](https://www.npmjs.com/package/@orpc/react): Use oRPC with [Next.js Server Functions](https://nextjs.org/docs/app/getting-started/mutating-data).
48
+ - [@orpc/next](https://www.npmjs.com/package/@orpc/next): Integrate with [Next.js Server Functions](https://nextjs.org/docs/app/getting-started/mutating-data).
43
49
  - [@orpc/tanstack-query](https://www.npmjs.com/package/@orpc/tanstack-query): Integrate with [TanStack Query](https://tanstack.com/query/latest).
44
50
  - [@orpc/experimental-effect](https://www.npmjs.com/package/@orpc/experimental-effect): Integrate with [Effect](https://effect.website/).
45
-
46
- **Built-in features**
47
-
48
- - [@orpc/publisher](https://www.npmjs.com/package/@orpc/publisher): Pub/Sub.
49
- - [@orpc/ratelimit](https://www.npmjs.com/package/@orpc/ratelimit): Rate limiting.
50
- - [@orpc/json-schema](https://www.npmjs.com/package/@orpc/json-schema): Smart coercion for OpenAPI requests.
51
+ - [@orpc/nest](https://www.npmjs.com/package/@orpc/nest): Implement your contract with [NestJS](https://nestjs.com/).
52
+ - [@orpc/bun](https://www.npmjs.com/package/@orpc/bun): Adapters for [Bun's Redis](https://bun.sh/).
51
53
 
52
54
  **Observability**
53
55
 
54
- - [@orpc/opentelemetry](https://www.npmjs.com/package/@orpc/opentelemetry): Instrument your API with [OpenTelemetry](https://opentelemetry.io/).
55
- - [@orpc/pino](https://www.npmjs.com/package/@orpc/pino): Log with [Pino](https://getpino.io/).
56
- - [@orpc/evlog](https://www.npmjs.com/package/@orpc/evlog): Log with [Evlog](https://evlog.dev/).
56
+ - [@orpc/opentelemetry](https://www.npmjs.com/package/@orpc/opentelemetry): Integrate with [OpenTelemetry](https://opentelemetry.io/) for distributed tracing.
57
+ - [@orpc/pino](https://www.npmjs.com/package/@orpc/pino): Integrate with [Pino](https://getpino.io/) for logging.
58
+ - [@orpc/evlog](https://www.npmjs.com/package/@orpc/evlog): Integrate with [Evlog](https://evlog.dev/) for logging.
57
59
 
58
60
  ## Sponsors
59
61
 
@@ -115,25 +117,25 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
115
117
  <table>
116
118
  <tr>
117
119
  <td align="center"><a href="https://github.com/rhinodavid?ref=orpc" target="_blank" rel="noopener" title="David Walsh"><img src="https://avatars.githubusercontent.com/u/5778036?u=b5521f07d2f88c3db2a0dae62b5f2f8357214af0&amp;v=4" width="119" alt="David Walsh"/><br />David Walsh</a></td>
120
+ <td align="center"><a href="https://github.com/Nic13Gamer?ref=orpc" target="_blank" rel="noopener" title="Nicholas"><img src="https://avatars.githubusercontent.com/u/54724556?u=56a7ab430ce7a80d648ab6eba051d454a818ed0b&amp;v=4" width="119" alt="Nicholas"/><br />Nicholas</a></td>
118
121
  <td align="center"><a href="https://github.com/Robbe95?ref=orpc" target="_blank" rel="noopener" title="Robbe Vaes"><img src="https://avatars.githubusercontent.com/u/44748019?u=e0232402c045ad4eac7cbd217f1f47e083103b89&amp;v=4" width="119" alt="Robbe Vaes"/><br />Robbe Vaes</a></td>
119
122
  <td align="center"><a href="https://github.com/aidansunbury?ref=orpc" target="_blank" rel="noopener" title="Aidan Sunbury"><img src="https://avatars.githubusercontent.com/u/64103161?v=4" width="119" alt="Aidan Sunbury"/><br />Aidan Sunbury</a></td>
120
123
  <td align="center"><a href="https://github.com/soonoo?ref=orpc" target="_blank" rel="noopener" title="soonoo"><img src="https://avatars.githubusercontent.com/u/5436405?u=5d0b4aa955c87e30e6bda7f0cccae5402da99528&amp;v=4" width="119" alt="soonoo"/><br />soonoo</a></td>
121
124
  <td align="center"><a href="https://github.com/kporten?ref=orpc" target="_blank" rel="noopener" title="Kevin Porten"><img src="https://avatars.githubusercontent.com/u/1839345?u=dc2263d5cfe0d927ce1a0be04a1d55dd6b55405c&amp;v=4" width="119" alt="Kevin Porten"/><br />Kevin Porten</a></td>
122
125
  <td align="center"><a href="https://github.com/pumpkinlink?ref=orpc" target="_blank" rel="noopener" title="Denis"><img src="https://avatars.githubusercontent.com/u/11864620?u=5f47bbe6c65d0f6f5cf011021490238e4b0593d0&amp;v=4" width="119" alt="Denis"/><br />Denis</a></td>
123
- <td align="center"><a href="https://github.com/christopher-kapic?ref=orpc" target="_blank" rel="noopener" title="Christopher Kapic"><img src="https://avatars.githubusercontent.com/u/59740769?u=e7ad4b72b5bf6c9eb1644c26dbf3332a8f987377&amp;v=4" width="119" alt="Christopher Kapic"/><br />Christopher Kapic</a></td>
124
126
  </tr>
125
127
  <tr>
128
+ <td align="center"><a href="https://github.com/christopher-kapic?ref=orpc" target="_blank" rel="noopener" title="Christopher Kapic"><img src="https://avatars.githubusercontent.com/u/59740769?u=e7ad4b72b5bf6c9eb1644c26dbf3332a8f987377&amp;v=4" width="119" alt="Christopher Kapic"/><br />Christopher Kapic</a></td>
126
129
  <td align="center"><a href="https://github.com/thomasballinger?ref=orpc" target="_blank" rel="noopener" title="Tom Ballinger"><img src="https://avatars.githubusercontent.com/u/458879?u=4b045ac75d721b6ac2b42a74d7d37f61f0414031&amp;v=4" width="119" alt="Tom Ballinger"/><br />Tom Ballinger</a></td>
127
130
  <td align="center"><a href="https://github.com/SSam0419?ref=orpc" target="_blank" rel="noopener" title="Sam"><img src="https://avatars.githubusercontent.com/u/102863520?u=3c89611f549d5070be232eb4532f690c8f2e7a65&amp;v=4" width="119" alt="Sam"/><br />Sam</a></td>
128
131
  <td align="center"><a href="https://github.com/Titoine?ref=orpc" target="_blank" rel="noopener" title="Titoine"><img src="https://avatars.githubusercontent.com/u/3514286?u=1bb1e86b0c99c8a1121372e56d51a177eea12191&amp;v=4" width="119" alt="Titoine"/><br />Titoine</a></td>
129
132
  <td align="center"><a href="https://github.com/Mnigos?ref=orpc" target="_blank" rel="noopener" title="Igor Makowski"><img src="https://avatars.githubusercontent.com/u/56691628?u=ee8c879478f7c151b9156aef6c74243fa3e247a8&amp;v=4" width="119" alt="Igor Makowski"/><br />Igor Makowski</a></td>
130
133
  <td align="center"><a href="https://github.com/hanayashiki?ref=orpc" target="_blank" rel="noopener" title="hanayashiki"><img src="https://avatars.githubusercontent.com/u/26056783?u=06c3b9205a16fd41a871e82da1cc2a09306d53f5&amp;v=4" width="119" alt="hanayashiki"/><br />hanayashiki</a></td>
131
134
  <td align="center"><a href="https://github.com/ldub?ref=orpc" target="_blank" rel="noopener" title="Lev Dubinets"><img src="https://avatars.githubusercontent.com/u/3114081?u=f547f5d5012cab54851f1b1ad72d10e537f78fc2&amp;v=4" width="119" alt="Lev Dubinets"/><br />Lev Dubinets</a></td>
132
- <td align="center"><a href="https://github.com/mr-kelly?ref=orpc" target="_blank" rel="noopener" title="Kelly Peilin Chan"><img src="https://avatars.githubusercontent.com/u/520852?u=6b0f7105f694e7b5cacf410a3f04c7044b469dc8&amp;v=4" width="119" alt="Kelly Peilin Chan"/><br />Kelly Peilin Chan</a></td>
133
135
  </tr>
134
136
  <tr>
137
+ <td align="center"><a href="https://github.com/mr-kelly?ref=orpc" target="_blank" rel="noopener" title="Kelly Peilin Chan"><img src="https://avatars.githubusercontent.com/u/520852?u=6b0f7105f694e7b5cacf410a3f04c7044b469dc8&amp;v=4" width="119" alt="Kelly Peilin Chan"/><br />Kelly Peilin Chan</a></td>
135
138
  <td align="center"><a href="https://github.com/piscis?ref=orpc" target="_blank" rel="noopener" title="Alex"><img src="https://avatars.githubusercontent.com/u/326163?u=b245f368bd940cf51d08c0b6bf55f8257f359437&amp;v=4" width="119" alt="Alex"/><br />Alex</a></td>
136
- <td align="center"><a href="https://github.com/nattstack?ref=orpc" target="_blank" rel="noopener" title="nattstack"><img src="https://avatars.githubusercontent.com/u/31426677?u=fa9dbb8b3e66eb0ea3c88db5dc07f31c8c5418fe&amp;v=4" width="119" alt="nattstack"/><br />nattstack</a></td>
137
139
  <td align="center"><a href="https://github.com/finom?ref=orpc" target="_blank" rel="noopener" title="Andrey Gubanov"><img src="https://avatars.githubusercontent.com/u/1082083?u=29e91400dbd4a9c217048a8f59562c4f740498e6&amp;v=4" width="119" alt="Andrey Gubanov"/><br />Andrey Gubanov</a></td>
138
140
  </tr>
139
141
  </table>
@@ -150,7 +152,7 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
150
152
  <a href="https://github.com/theoludwig?ref=orpc" target="_blank" rel="noopener" title="Théo LUDWIG"><img src="https://avatars.githubusercontent.com/u/25207499?u=a6a9653725a2f574c07893748806668e0598cdbe&amp;v=4" width="32" height="32" alt="Théo LUDWIG" /></a>
151
153
  <a href="https://github.com/abhay-ramesh?ref=orpc" target="_blank" rel="noopener" title="Abhay Ramesh"><img src="https://avatars.githubusercontent.com/u/66196314?u=c5c2b0327b26606c2efcfaf17046ab18c3d25c57&amp;v=4" width="32" height="32" alt="Abhay Ramesh" /></a>
152
154
  <a href="https://github.com/shr-ink?ref=orpc" target="_blank" rel="noopener" title="shr.ink oü"><img src="https://avatars.githubusercontent.com/u/139700438?v=4" width="32" height="32" alt="shr.ink oü" /></a>
153
- <a href="https://github.com/johngerome?ref=orpc" target="_blank" rel="noopener" title="0x4e32"><img src="https://avatars.githubusercontent.com/u/2002000?u=24e8dd943cfc862aa284d858a023532c75071ade&amp;v=4" width="32" height="32" alt="0x4e32" /></a>
155
+ <a href="https://github.com/johngerome?ref=orpc" target="_blank" rel="noopener" title="0x4e32"><img src="https://avatars.githubusercontent.com/u/2002000?u=505e54608466ab53754f702973687b04c6424c1f&amp;v=4" width="32" height="32" alt="0x4e32" /></a>
154
156
  <a href="https://github.com/yzuyr?ref=orpc" target="_blank" rel="noopener" title="Ryuz"><img src="https://avatars.githubusercontent.com/u/196539378?u=d38374588d219b6748b16406982f6559411466d4&amp;v=4" width="32" height="32" alt="Ryuz" /></a>
155
157
  <a href="https://github.com/happyboy2022?ref=orpc" target="_blank" rel="noopener" title="happyboy"><img src="https://avatars.githubusercontent.com/u/103669586?u=65b49c4b893ed3703909fbb3a7a22313f3f9c121&amp;v=4" width="32" height="32" alt="happyboy" /></a>
156
158
  <a href="https://github.com/YiCChi?ref=orpc" target="_blank" rel="noopener" title="yicchi"><img src="https://avatars.githubusercontent.com/u/86967274?u=6c2756f09fe15dd94d572f560e979cd157982852&amp;v=4" width="32" height="32" alt="yicchi" /></a>
@@ -172,6 +174,7 @@ Like what we build over at [middleapi](https://github.com/middleapi)? You can he
172
174
  <a href="https://github.com/illarionvk?ref=orpc" target="_blank" rel="noopener" title="Illarion Koperski"><img src="https://avatars.githubusercontent.com/u/5012724?u=7cfa13652f7ac5fb3c56d880e3eb3fbe40c3ea34&amp;v=4" width="32" height="32" alt="Illarion Koperski" /></a>
173
175
  <a href="https://github.com/steelbrain?ref=orpc" target="_blank" rel="noopener" title="Anees Iqbal"><img src="https://avatars.githubusercontent.com/u/4278113?u=22b80b5399eed68ac76cd58b02961b0481f1db11&amp;v=4" width="32" height="32" alt="Anees Iqbal" /></a>
174
176
  <a href="https://github.com/Scrumplex?ref=orpc" target="_blank" rel="noopener" title="Sefa Eyeoglu"><img src="https://avatars.githubusercontent.com/u/11587657?u=ab503582165c0bbff0cca47ce31c9450bb1553c9&amp;v=4" width="32" height="32" alt="Sefa Eyeoglu" /></a>
177
+ <a href="https://github.com/nattstack?ref=orpc" target="_blank" rel="noopener" title="Natt"><img src="https://avatars.githubusercontent.com/u/31426677?u=fa9dbb8b3e66eb0ea3c88db5dc07f31c8c5418fe&amp;v=4" width="32" height="32" alt="Natt" /></a>
175
178
  <a href="https://github.com/ChromeGG?ref=orpc" target="_blank" rel="noopener" title="Adam Tkaczyk"><img src="https://avatars.githubusercontent.com/u/39050595?u=a58ca6042a6950e94e6e92442db76ef584279bc0&amp;v=4" width="32" height="32" alt="Adam Tkaczyk" /></a>
176
179
  <a href="https://github.com/plancraft?ref=orpc" target="_blank" rel="noopener" title="plancraft"><img src="https://avatars.githubusercontent.com/u/46482287?v=4" width="32" height="32" alt="plancraft" /></a>
177
180
  </p>
@@ -2,10 +2,10 @@ import { MaybeOptionalOptions } from '@orpc/shared';
2
2
  import { EncodePeerMessageOptions, DecodePeerMessageOptions } from '@standardserver/peer';
3
3
  import { Message, Peer } from 'crossws';
4
4
  import { C as Context } from '../../shared/server.BL22TloH.mjs';
5
- import { S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.BB_Ik9Ph.mjs';
5
+ import { S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.DJIkub_t.mjs';
6
6
  import { StandardPeerRequestHandlerOptions } from '../standard-peer/index.mjs';
7
7
  import { R as Router } from '../../shared/server.BsNNjG5J.mjs';
8
- import { R as RPCHandlerCodecOptions } from '../../shared/server.B_U9y00a.mjs';
8
+ import { R as RPCHandlerCodecOptions } from '../../shared/server.Cj5lgPuG.mjs';
9
9
  import '@orpc/client';
10
10
  import '@orpc/contract';
11
11
  import '@standardserver/core';
@@ -2,10 +2,10 @@ import { MaybeOptionalOptions } from '@orpc/shared';
2
2
  import { EncodePeerMessageOptions, DecodePeerMessageOptions } from '@standardserver/peer';
3
3
  import { Message, Peer } from 'crossws';
4
4
  import { C as Context } from '../../shared/server.BL22TloH.js';
5
- import { S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.EOHJ3NJr.js';
5
+ import { S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.DBANIheG.js';
6
6
  import { StandardPeerRequestHandlerOptions } from '../standard-peer/index.js';
7
7
  import { R as Router } from '../../shared/server.Pa0F03f_.js';
8
- import { R as RPCHandlerCodecOptions } from '../../shared/server.T9F3bzZx.js';
8
+ import { R as RPCHandlerCodecOptions } from '../../shared/server.d_2NS3g5.js';
9
9
  import '@orpc/client';
10
10
  import '@orpc/contract';
11
11
  import '@standardserver/core';
@@ -1,10 +1,10 @@
1
1
  import { C as Context } from '../../shared/server.BL22TloH.mjs';
2
2
  import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
3
3
  import { ToFetchResponseOptions } from '@standardserver/fetch';
4
- import { e as StandardHandlerPlugin, b as StandardHandlerHandleOptions, S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.BB_Ik9Ph.mjs';
4
+ import { e as StandardHandlerPlugin, b as StandardHandlerHandleOptions, S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.DJIkub_t.mjs';
5
5
  import { FriendlyStandardHandlerHandleOptions } from '../standard/index.mjs';
6
6
  import { R as Router } from '../../shared/server.BsNNjG5J.mjs';
7
- import { R as RPCHandlerCodecOptions } from '../../shared/server.B_U9y00a.mjs';
7
+ import { R as RPCHandlerCodecOptions } from '../../shared/server.Cj5lgPuG.mjs';
8
8
  import '@orpc/client';
9
9
  import '@orpc/contract';
10
10
  import '@standardserver/core';
@@ -53,9 +53,9 @@ interface FetchHandlerFetchInterceptorOptions<T extends Context> extends Standar
53
53
  type FetchHandlerFetchInterceptor<T extends Context> = Interceptor<FetchHandlerFetchInterceptorOptions<T>, Promise<FetchHandlerHandleResult>>;
54
54
  interface FetchHandlerOptions<T extends Context> {
55
55
  /**
56
- * Custom options for `toFetchResponse`, used to map a `Standard Response` to a `Fetch Response`.
56
+ * Options for how to convert the Fetch Response to a Standard Response, like event iterator options, etc.
57
57
  */
58
- toFetchResponse?: ToFetchResponseOptions;
58
+ toFetchResponse?: undefined | ToFetchResponseOptions;
59
59
  /**
60
60
  * Interceptors that run before the mapping between the Standard API and Fetch API,
61
61
  * useful for customizing the mapping behavior (e.g. extending the body parser).
@@ -1,10 +1,10 @@
1
1
  import { C as Context } from '../../shared/server.BL22TloH.js';
2
2
  import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
3
3
  import { ToFetchResponseOptions } from '@standardserver/fetch';
4
- import { e as StandardHandlerPlugin, b as StandardHandlerHandleOptions, S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.EOHJ3NJr.js';
4
+ import { e as StandardHandlerPlugin, b as StandardHandlerHandleOptions, S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.DBANIheG.js';
5
5
  import { FriendlyStandardHandlerHandleOptions } from '../standard/index.js';
6
6
  import { R as Router } from '../../shared/server.Pa0F03f_.js';
7
- import { R as RPCHandlerCodecOptions } from '../../shared/server.T9F3bzZx.js';
7
+ import { R as RPCHandlerCodecOptions } from '../../shared/server.d_2NS3g5.js';
8
8
  import '@orpc/client';
9
9
  import '@orpc/contract';
10
10
  import '@standardserver/core';
@@ -53,9 +53,9 @@ interface FetchHandlerFetchInterceptorOptions<T extends Context> extends Standar
53
53
  type FetchHandlerFetchInterceptor<T extends Context> = Interceptor<FetchHandlerFetchInterceptorOptions<T>, Promise<FetchHandlerHandleResult>>;
54
54
  interface FetchHandlerOptions<T extends Context> {
55
55
  /**
56
- * Custom options for `toFetchResponse`, used to map a `Standard Response` to a `Fetch Response`.
56
+ * Options for how to convert the Fetch Response to a Standard Response, like event iterator options, etc.
57
57
  */
58
- toFetchResponse?: ToFetchResponseOptions;
58
+ toFetchResponse?: undefined | ToFetchResponseOptions;
59
59
  /**
60
60
  * Interceptors that run before the mapping between the Standard API and Fetch API,
61
61
  * useful for customizing the mapping behavior (e.g. extending the body parser).
@@ -2,10 +2,10 @@ import { SupportedMessagePort } from '@orpc/client/message-port';
2
2
  import { Value, Promisable, MaybeOptionalOptions } from '@orpc/shared';
3
3
  import { ServerPeer, EncodePeerMessageOptions, DecodePeerMessageOptions } from '@standardserver/peer';
4
4
  import { C as Context } from '../../shared/server.BL22TloH.mjs';
5
- import { S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.BB_Ik9Ph.mjs';
5
+ import { S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.DJIkub_t.mjs';
6
6
  import { StandardPeerRequestHandlerOptions } from '../standard-peer/index.mjs';
7
7
  import { R as Router } from '../../shared/server.BsNNjG5J.mjs';
8
- import { R as RPCHandlerCodecOptions } from '../../shared/server.B_U9y00a.mjs';
8
+ import { R as RPCHandlerCodecOptions } from '../../shared/server.Cj5lgPuG.mjs';
9
9
  import '@orpc/client';
10
10
  import '@orpc/contract';
11
11
  import '@standardserver/core';
@@ -2,10 +2,10 @@ import { SupportedMessagePort } from '@orpc/client/message-port';
2
2
  import { Value, Promisable, MaybeOptionalOptions } from '@orpc/shared';
3
3
  import { ServerPeer, EncodePeerMessageOptions, DecodePeerMessageOptions } from '@standardserver/peer';
4
4
  import { C as Context } from '../../shared/server.BL22TloH.js';
5
- import { S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.EOHJ3NJr.js';
5
+ import { S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.DBANIheG.js';
6
6
  import { StandardPeerRequestHandlerOptions } from '../standard-peer/index.js';
7
7
  import { R as Router } from '../../shared/server.Pa0F03f_.js';
8
- import { R as RPCHandlerCodecOptions } from '../../shared/server.T9F3bzZx.js';
8
+ import { R as RPCHandlerCodecOptions } from '../../shared/server.d_2NS3g5.js';
9
9
  import '@orpc/client';
10
10
  import '@orpc/contract';
11
11
  import '@standardserver/core';
@@ -1,11 +1,11 @@
1
1
  import { SendStandardResponseOptions, NodeHttpRequest, NodeHttpResponse } from '@standardserver/node';
2
2
  import { C as Context } from '../../shared/server.BL22TloH.mjs';
3
3
  import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
4
- import { e as StandardHandlerPlugin, b as StandardHandlerHandleOptions, S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.BB_Ik9Ph.mjs';
4
+ import { e as StandardHandlerPlugin, b as StandardHandlerHandleOptions, S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.DJIkub_t.mjs';
5
5
  import { FriendlyStandardHandlerHandleOptions } from '../standard/index.mjs';
6
6
  import compression from '@orpc/interop/compression';
7
7
  import { R as Router } from '../../shared/server.BsNNjG5J.mjs';
8
- import { R as RPCHandlerCodecOptions } from '../../shared/server.B_U9y00a.mjs';
8
+ import { R as RPCHandlerCodecOptions } from '../../shared/server.Cj5lgPuG.mjs';
9
9
  import '@orpc/client';
10
10
  import '@orpc/contract';
11
11
  import '@standardserver/core';
@@ -1,11 +1,11 @@
1
1
  import { SendStandardResponseOptions, NodeHttpRequest, NodeHttpResponse } from '@standardserver/node';
2
2
  import { C as Context } from '../../shared/server.BL22TloH.js';
3
3
  import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
4
- import { e as StandardHandlerPlugin, b as StandardHandlerHandleOptions, S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.EOHJ3NJr.js';
4
+ import { e as StandardHandlerPlugin, b as StandardHandlerHandleOptions, S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.DBANIheG.js';
5
5
  import { FriendlyStandardHandlerHandleOptions } from '../standard/index.js';
6
6
  import compression from '@orpc/interop/compression';
7
7
  import { R as Router } from '../../shared/server.Pa0F03f_.js';
8
- import { R as RPCHandlerCodecOptions } from '../../shared/server.T9F3bzZx.js';
8
+ import { R as RPCHandlerCodecOptions } from '../../shared/server.d_2NS3g5.js';
9
9
  import '@orpc/client';
10
10
  import '@orpc/contract';
11
11
  import '@standardserver/core';
@@ -1,10 +1,10 @@
1
- import { b as StandardHandlerHandleOptions } from '../../shared/server.BB_Ik9Ph.mjs';
2
- export { C as CompositeStandardHandlerPlugin, O as OtelHandlerPlugin, S as StandardHandler, c as StandardHandlerCodec, d as StandardHandlerCodecResolvedProcedure, g as StandardHandlerHandleResult, h as StandardHandlerInterceptor, i as StandardHandlerInterceptorOptions, a as StandardHandlerOptions, e as StandardHandlerPlugin, j as StandardHandlerRoutingInterceptor, f as StandardHandlerRoutingInterceptorOptions } from '../../shared/server.BB_Ik9Ph.mjs';
3
- export { a as RPCHandlerCodec, R as RPCHandlerCodecOptions, b as RPCMatcher, c as RPCMatcherOptions } from '../../shared/server.B_U9y00a.mjs';
1
+ import { b as StandardHandlerHandleOptions } from '../../shared/server.DJIkub_t.mjs';
2
+ export { C as CompositeStandardHandlerPlugin, O as OtelHandlerPlugin, S as StandardHandler, c as StandardHandlerCodec, d as StandardHandlerCodecResolvedProcedure, h as StandardHandlerHandleResult, i as StandardHandlerInterceptor, g as StandardHandlerInterceptorOptions, a as StandardHandlerOptions, e as StandardHandlerPlugin, j as StandardHandlerRoutingInterceptor, f as StandardHandlerRoutingInterceptorOptions } from '../../shared/server.DJIkub_t.mjs';
3
+ export { a as RPCHandlerCodec, R as RPCHandlerCodecOptions, b as RPCMatcher, c as RPCMatcherOptions } from '../../shared/server.Cj5lgPuG.mjs';
4
4
  import { C as Context } from '../../shared/server.BL22TloH.mjs';
5
+ export { StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl } from '@standardserver/core';
5
6
  import '@orpc/client';
6
7
  import '@orpc/shared';
7
- import '@standardserver/core';
8
8
  import '@orpc/contract';
9
9
  import '../../shared/server.BsNNjG5J.mjs';
10
10
 
@@ -1,10 +1,10 @@
1
- import { b as StandardHandlerHandleOptions } from '../../shared/server.EOHJ3NJr.js';
2
- export { C as CompositeStandardHandlerPlugin, O as OtelHandlerPlugin, S as StandardHandler, c as StandardHandlerCodec, d as StandardHandlerCodecResolvedProcedure, g as StandardHandlerHandleResult, h as StandardHandlerInterceptor, i as StandardHandlerInterceptorOptions, a as StandardHandlerOptions, e as StandardHandlerPlugin, j as StandardHandlerRoutingInterceptor, f as StandardHandlerRoutingInterceptorOptions } from '../../shared/server.EOHJ3NJr.js';
3
- export { a as RPCHandlerCodec, R as RPCHandlerCodecOptions, b as RPCMatcher, c as RPCMatcherOptions } from '../../shared/server.T9F3bzZx.js';
1
+ import { b as StandardHandlerHandleOptions } from '../../shared/server.DBANIheG.js';
2
+ export { C as CompositeStandardHandlerPlugin, O as OtelHandlerPlugin, S as StandardHandler, c as StandardHandlerCodec, d as StandardHandlerCodecResolvedProcedure, h as StandardHandlerHandleResult, i as StandardHandlerInterceptor, g as StandardHandlerInterceptorOptions, a as StandardHandlerOptions, e as StandardHandlerPlugin, j as StandardHandlerRoutingInterceptor, f as StandardHandlerRoutingInterceptorOptions } from '../../shared/server.DBANIheG.js';
3
+ export { a as RPCHandlerCodec, R as RPCHandlerCodecOptions, b as RPCMatcher, c as RPCMatcherOptions } from '../../shared/server.d_2NS3g5.js';
4
4
  import { C as Context } from '../../shared/server.BL22TloH.js';
5
+ export { StandardBody, StandardBodyHint, StandardHeaders, StandardLazyRequest, StandardLazyResponse, StandardMethod, StandardRequest, StandardResponse, StandardUrl } from '@standardserver/core';
5
6
  import '@orpc/client';
6
7
  import '@orpc/shared';
7
- import '@standardserver/core';
8
8
  import '@orpc/contract';
9
9
  import '../../shared/server.Pa0F03f_.js';
10
10
 
@@ -1,7 +1,7 @@
1
1
  import { Value, Promisable } from '@orpc/shared';
2
2
  import { StandardLazyRequest, StandardResponse } from '@standardserver/core';
3
3
  import { C as Context } from '../../shared/server.BL22TloH.mjs';
4
- import { b as StandardHandlerHandleOptions, S as StandardHandler } from '../../shared/server.BB_Ik9Ph.mjs';
4
+ import { b as StandardHandlerHandleOptions, S as StandardHandler } from '../../shared/server.DJIkub_t.mjs';
5
5
  import '@orpc/client';
6
6
  import '@orpc/contract';
7
7
 
@@ -1,7 +1,7 @@
1
1
  import { Value, Promisable } from '@orpc/shared';
2
2
  import { StandardLazyRequest, StandardResponse } from '@standardserver/core';
3
3
  import { C as Context } from '../../shared/server.BL22TloH.js';
4
- import { b as StandardHandlerHandleOptions, S as StandardHandler } from '../../shared/server.EOHJ3NJr.js';
4
+ import { b as StandardHandlerHandleOptions, S as StandardHandler } from '../../shared/server.DBANIheG.js';
5
5
  import '@orpc/client';
6
6
  import '@orpc/contract';
7
7
 
@@ -1,16 +1,22 @@
1
1
  import { MaybeOptionalOptions } from '@orpc/shared';
2
2
  import { EncodePeerMessageOptions, DecodePeerMessageOptions } from '@standardserver/peer';
3
3
  import { C as Context } from '../../shared/server.BL22TloH.mjs';
4
- import { S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.BB_Ik9Ph.mjs';
4
+ import { S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.DJIkub_t.mjs';
5
5
  import { StandardPeerRequestHandlerOptions } from '../standard-peer/index.mjs';
6
6
  import { R as Router } from '../../shared/server.BsNNjG5J.mjs';
7
- import { R as RPCHandlerCodecOptions } from '../../shared/server.B_U9y00a.mjs';
7
+ import { R as RPCHandlerCodecOptions } from '../../shared/server.Cj5lgPuG.mjs';
8
8
  import '@orpc/client';
9
9
  import '@orpc/contract';
10
10
  import '@standardserver/core';
11
11
 
12
- type WebsocketLike = Pick<WebSocket, 'addEventListener' | 'removeEventListener' | 'send'>;
13
- interface WebsocketHandlerOptions<_T extends Context> {
12
+ /**
13
+ * Supports standard WebSocket instances, Bun ServerWebSocket, "ws" ServerWebSocket,
14
+ * Cloudflare WebSocket Hibernation, and similar implementations.
15
+ */
16
+ type WebSocketLike = {
17
+ send: (data: string | Uint8Array<ArrayBuffer>) => unknown;
18
+ };
19
+ interface WebSocketHandlerOptions<_T extends Context> {
14
20
  /**
15
21
  * Options for encoding peer messages. such as `prefix` for distinguishing messages on the same channel..
16
22
  */
@@ -20,16 +26,12 @@ interface WebsocketHandlerOptions<_T extends Context> {
20
26
  */
21
27
  decodePeerMessage?: DecodePeerMessageOptions | undefined;
22
28
  }
23
- declare class WebsocketHandler<T extends Context> {
29
+ declare class WebSocketHandler<T extends Context> {
24
30
  private readonly handler;
25
31
  private readonly peers;
26
32
  private readonly encodePeerMessageOptions;
27
33
  private readonly decodePeerMessageOptions;
28
- constructor(handler: StandardHandler<T>, options?: NoInfer<WebsocketHandlerOptions<T>>);
29
- /**
30
- * Attaches necessary event listeners to a WebSocket to handle incoming messages and peer management.
31
- */
32
- upgrade(ws: WebsocketLike, ...rest: MaybeOptionalOptions<StandardPeerRequestHandlerOptions<T>>): void;
34
+ constructor(handler: StandardHandler<T>, options?: NoInfer<WebSocketHandlerOptions<T>>);
33
35
  /**
34
36
  * Handles a single message received from a WebSocket.
35
37
  *
@@ -38,7 +40,7 @@ declare class WebsocketHandler<T extends Context> {
38
40
  * @param ws The WebSocket instance, require consistent instance across messages for proper peer management
39
41
  * @param data The message data received from the WebSocket, can be string, ArrayBuffer, Blob, ...
40
42
  */
41
- message(ws: WebsocketLike, data: string | ArrayBuffer | Blob | Exclude<ConstructorParameters<typeof Blob>[0], undefined>[0][] | Pick<Uint8Array<ArrayBuffer>, 'buffer' | 'byteOffset' | 'byteLength'>, ...rest: MaybeOptionalOptions<StandardPeerRequestHandlerOptions<T>>): Promise<{
43
+ message(ws: WebSocketLike, data: string | ArrayBuffer | Blob | Exclude<ConstructorParameters<typeof Blob>[0], undefined>[0][] | Pick<Uint8Array<ArrayBuffer>, 'buffer' | 'byteOffset' | 'byteLength'>, ...rest: MaybeOptionalOptions<StandardPeerRequestHandlerOptions<T>>): Promise<{
42
44
  matched: boolean;
43
45
  }>;
44
46
  /**
@@ -48,14 +50,21 @@ declare class WebsocketHandler<T extends Context> {
48
50
  *
49
51
  * @param ws The WebSocket instance to clean up, must be the same instance used in `.message()` calls to properly clean up
50
52
  */
51
- close(ws: WebsocketLike): Promise<void>;
53
+ close(ws: WebSocketLike): Promise<void>;
54
+ /**
55
+ * Attaches websocket event listeners for message and close handling.
56
+ *
57
+ * Use this instead of calling `.message()` and `.close()` manually.
58
+ * Requires a websocket-like object that supports `addEventListener` and `removeEventListener`.
59
+ */
60
+ upgrade(ws: Pick<WebSocket, 'send' | 'addEventListener' | 'removeEventListener'>, ...rest: MaybeOptionalOptions<StandardPeerRequestHandlerOptions<T>>): void;
52
61
  }
53
62
 
54
- interface RPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, RPCHandlerCodecOptions<T>, WebsocketHandlerOptions<T> {
63
+ interface RPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, RPCHandlerCodecOptions<T>, WebSocketHandlerOptions<T> {
55
64
  }
56
- declare class RPCHandler<T extends Context> extends WebsocketHandler<T> {
65
+ declare class RPCHandler<T extends Context> extends WebSocketHandler<T> {
57
66
  constructor(router: Router<T>, options?: NoInfer<RPCHandlerOptions<T>>);
58
67
  }
59
68
 
60
- export { RPCHandler, WebsocketHandler };
61
- export type { RPCHandlerOptions, WebsocketHandlerOptions, WebsocketLike };
69
+ export { RPCHandler, WebSocketHandler };
70
+ export type { RPCHandlerOptions, WebSocketHandlerOptions, WebSocketLike };
@@ -1,16 +1,22 @@
1
1
  import { MaybeOptionalOptions } from '@orpc/shared';
2
2
  import { EncodePeerMessageOptions, DecodePeerMessageOptions } from '@standardserver/peer';
3
3
  import { C as Context } from '../../shared/server.BL22TloH.js';
4
- import { S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.EOHJ3NJr.js';
4
+ import { S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.DBANIheG.js';
5
5
  import { StandardPeerRequestHandlerOptions } from '../standard-peer/index.js';
6
6
  import { R as Router } from '../../shared/server.Pa0F03f_.js';
7
- import { R as RPCHandlerCodecOptions } from '../../shared/server.T9F3bzZx.js';
7
+ import { R as RPCHandlerCodecOptions } from '../../shared/server.d_2NS3g5.js';
8
8
  import '@orpc/client';
9
9
  import '@orpc/contract';
10
10
  import '@standardserver/core';
11
11
 
12
- type WebsocketLike = Pick<WebSocket, 'addEventListener' | 'removeEventListener' | 'send'>;
13
- interface WebsocketHandlerOptions<_T extends Context> {
12
+ /**
13
+ * Supports standard WebSocket instances, Bun ServerWebSocket, "ws" ServerWebSocket,
14
+ * Cloudflare WebSocket Hibernation, and similar implementations.
15
+ */
16
+ type WebSocketLike = {
17
+ send: (data: string | Uint8Array<ArrayBuffer>) => unknown;
18
+ };
19
+ interface WebSocketHandlerOptions<_T extends Context> {
14
20
  /**
15
21
  * Options for encoding peer messages. such as `prefix` for distinguishing messages on the same channel..
16
22
  */
@@ -20,16 +26,12 @@ interface WebsocketHandlerOptions<_T extends Context> {
20
26
  */
21
27
  decodePeerMessage?: DecodePeerMessageOptions | undefined;
22
28
  }
23
- declare class WebsocketHandler<T extends Context> {
29
+ declare class WebSocketHandler<T extends Context> {
24
30
  private readonly handler;
25
31
  private readonly peers;
26
32
  private readonly encodePeerMessageOptions;
27
33
  private readonly decodePeerMessageOptions;
28
- constructor(handler: StandardHandler<T>, options?: NoInfer<WebsocketHandlerOptions<T>>);
29
- /**
30
- * Attaches necessary event listeners to a WebSocket to handle incoming messages and peer management.
31
- */
32
- upgrade(ws: WebsocketLike, ...rest: MaybeOptionalOptions<StandardPeerRequestHandlerOptions<T>>): void;
34
+ constructor(handler: StandardHandler<T>, options?: NoInfer<WebSocketHandlerOptions<T>>);
33
35
  /**
34
36
  * Handles a single message received from a WebSocket.
35
37
  *
@@ -38,7 +40,7 @@ declare class WebsocketHandler<T extends Context> {
38
40
  * @param ws The WebSocket instance, require consistent instance across messages for proper peer management
39
41
  * @param data The message data received from the WebSocket, can be string, ArrayBuffer, Blob, ...
40
42
  */
41
- message(ws: WebsocketLike, data: string | ArrayBuffer | Blob | Exclude<ConstructorParameters<typeof Blob>[0], undefined>[0][] | Pick<Uint8Array<ArrayBuffer>, 'buffer' | 'byteOffset' | 'byteLength'>, ...rest: MaybeOptionalOptions<StandardPeerRequestHandlerOptions<T>>): Promise<{
43
+ message(ws: WebSocketLike, data: string | ArrayBuffer | Blob | Exclude<ConstructorParameters<typeof Blob>[0], undefined>[0][] | Pick<Uint8Array<ArrayBuffer>, 'buffer' | 'byteOffset' | 'byteLength'>, ...rest: MaybeOptionalOptions<StandardPeerRequestHandlerOptions<T>>): Promise<{
42
44
  matched: boolean;
43
45
  }>;
44
46
  /**
@@ -48,14 +50,21 @@ declare class WebsocketHandler<T extends Context> {
48
50
  *
49
51
  * @param ws The WebSocket instance to clean up, must be the same instance used in `.message()` calls to properly clean up
50
52
  */
51
- close(ws: WebsocketLike): Promise<void>;
53
+ close(ws: WebSocketLike): Promise<void>;
54
+ /**
55
+ * Attaches websocket event listeners for message and close handling.
56
+ *
57
+ * Use this instead of calling `.message()` and `.close()` manually.
58
+ * Requires a websocket-like object that supports `addEventListener` and `removeEventListener`.
59
+ */
60
+ upgrade(ws: Pick<WebSocket, 'send' | 'addEventListener' | 'removeEventListener'>, ...rest: MaybeOptionalOptions<StandardPeerRequestHandlerOptions<T>>): void;
52
61
  }
53
62
 
54
- interface RPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, RPCHandlerCodecOptions<T>, WebsocketHandlerOptions<T> {
63
+ interface RPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, RPCHandlerCodecOptions<T>, WebSocketHandlerOptions<T> {
55
64
  }
56
- declare class RPCHandler<T extends Context> extends WebsocketHandler<T> {
65
+ declare class RPCHandler<T extends Context> extends WebSocketHandler<T> {
57
66
  constructor(router: Router<T>, options?: NoInfer<RPCHandlerOptions<T>>);
58
67
  }
59
68
 
60
- export { RPCHandler, WebsocketHandler };
61
- export type { RPCHandlerOptions, WebsocketHandlerOptions, WebsocketLike };
69
+ export { RPCHandler, WebSocketHandler };
70
+ export type { RPCHandlerOptions, WebSocketHandlerOptions, WebSocketLike };
@@ -8,7 +8,7 @@ import '../../shared/server.CrlKQucM.mjs';
8
8
  import '@orpc/contract';
9
9
  import '../../shared/server.BwHnWUuN.mjs';
10
10
 
11
- class WebsocketHandler {
11
+ class WebSocketHandler {
12
12
  constructor(handler, options = {}) {
13
13
  this.handler = handler;
14
14
  this.encodePeerMessageOptions = options.encodePeerMessage;
@@ -17,13 +17,6 @@ class WebsocketHandler {
17
17
  peers = /* @__PURE__ */ new WeakMap();
18
18
  encodePeerMessageOptions;
19
19
  decodePeerMessageOptions;
20
- /**
21
- * Attaches necessary event listeners to a WebSocket to handle incoming messages and peer management.
22
- */
23
- upgrade(ws, ...rest) {
24
- ws.addEventListener("message", (event) => this.message(ws, event.data, ...rest));
25
- ws.addEventListener("close", () => this.close(ws));
26
- }
27
20
  /**
28
21
  * Handles a single message received from a WebSocket.
29
22
  *
@@ -36,7 +29,8 @@ class WebsocketHandler {
36
29
  let peer = this.peers.get(ws);
37
30
  if (!peer) {
38
31
  this.peers.set(ws, peer = new ServerPeer(async (message) => {
39
- return ws.send(await encodePeerMessage(message, this.encodePeerMessageOptions));
32
+ const encoded2 = await encodePeerMessage(message, this.encodePeerMessageOptions);
33
+ await ws.send(encoded2);
40
34
  }));
41
35
  }
42
36
  const encoded = await toStringOrBytes(data);
@@ -63,9 +57,19 @@ class WebsocketHandler {
63
57
  this.peers.delete(ws);
64
58
  }
65
59
  }
60
+ /**
61
+ * Attaches websocket event listeners for message and close handling.
62
+ *
63
+ * Use this instead of calling `.message()` and `.close()` manually.
64
+ * Requires a websocket-like object that supports `addEventListener` and `removeEventListener`.
65
+ */
66
+ upgrade(ws, ...rest) {
67
+ ws.addEventListener("message", (event) => this.message(ws, event.data, ...rest));
68
+ ws.addEventListener("close", () => this.close(ws));
69
+ }
66
70
  }
67
71
 
68
- class RPCHandler extends WebsocketHandler {
72
+ class RPCHandler extends WebSocketHandler {
69
73
  constructor(router, options = {}) {
70
74
  const codec = new RPCHandlerCodec(router, options);
71
75
  const handler = new StandardHandler(codec, options);
@@ -73,4 +77,4 @@ class RPCHandler extends WebsocketHandler {
73
77
  }
74
78
  }
75
79
 
76
- export { RPCHandler, WebsocketHandler };
80
+ export { RPCHandler, WebSocketHandler };
package/dist/index.d.mts CHANGED
@@ -1,14 +1,14 @@
1
1
  import { AnyORPCError, ClientOptions, ClientContext } from '@orpc/client';
2
- export { AnyORPCError, AnyORPCErrorJSON, COMMON_ERROR_STATUS_MAP, ORPCError, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, RPCJsonSerialization, RPCJsonSerializationMeta, RPCJsonSerializer, RPCJsonSerializerHandler, RPCJsonSerializerOptions, RPCSerializer, RPCSerializerOptions, RPCSerializerSerializeOptions, cloneORPCError, isDefinedError, isInferableError, safe, toORPCError } from '@orpc/client';
2
+ export { AnyORPCError, AnyORPCErrorJSON, COMMON_ERROR_STATUS_MAP, Client, ClientContext, ClientOptions, ClientRest, FriendlyClientOptions, ORPCError, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, RPCJsonSerialization, RPCJsonSerializationMeta, RPCJsonSerializer, RPCJsonSerializerHandler, RPCJsonSerializerOptions, RPCSerializer, RPCSerializerOptions, RPCSerializerSerializeOptions, SafeResult, cloneORPCError, isDefinedError, isInferableError, safe, toORPCError } from '@orpc/client';
3
3
  import { ErrorMap, MergedErrorMap, AnySchema, MetaPlugin, InferSchemaOutput, InferSchemaInput, AugmentContractRouterOptions, RouterContract, AnyProcedureContract, InitialInputSchema, InitialOutputSchema, MergedSchema, Schema, ProcedureContractDefinition, ProcedureContract, InferRouterContractErrorMap, ORPCErrorFromErrorMap } from '@orpc/contract';
4
4
  export { AnyMetaPlugin, AnySchema, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, MergedErrorMap, Meta, MetaPlugin, MetaPluginDefinition, ORPCErrorFromErrorMap, ProcedureContract, ProcedureContractDefinition, RouterContract, Schema, ValidationError, defineMeta, eventIterator, reconcileORPCError, type } from '@orpc/contract';
5
5
  import { IntersectPick, Promisable, Public, PromiseWithError, ThrowableError, MaybeOptionalOptions } from '@orpc/shared';
6
- export { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, Registry, ThrowableError, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
6
+ export { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, MaybeOptionalOptions, PromiseWithError, Registry, ThrowableError, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
7
7
  import { C as Context, d as Middleware, M as MergedContext, e as MergedInitialContext, a as Procedure, f as AnyMiddleware, g as Lazy, A as AnyProcedure, L as Lazyable, h as ProcedureHandler, O as ORPCErrorConstructorMap, i as OrderedMiddleware, P as ProcedureClientOptions, b as ProcedureClient } from './shared/server.BL22TloH.mjs';
8
8
  export { j as LazyDefinition, k as MiddlewareDefinition, l as MiddlewareDone, m as MiddlewareDoneOptions, n as MiddlewareNext, o as MiddlewareNextOptions, p as MiddlewareOptions, q as MiddlewareResult, r as ORPCErrorConstructorMapItem, s as ORPCErrorConstructorMapItemOptions, c as ProcedureClientInterceptor, t as ProcedureClientInterceptorOptions, u as ProcedureDefinition, v as ProcedureHandlerOptions, w as createORPCErrorConstructorMap, x as createProcedureClient, y as unlazy } from './shared/server.BL22TloH.mjs';
9
9
  import { A as AnyRouter, R as Router, C as ContractedRouter, I as InferRouterInitialContext } from './shared/server.BsNNjG5J.mjs';
10
10
  export { a as InferRouterError, b as InferRouterErrors, c as InferRouterFinalContexts, d as InferRouterInitialContexts, e as InferRouterInputs, f as InferRouterOutputs } from './shared/server.BsNNjG5J.mjs';
11
- export { ErrorEvent, getEventMeta, unwrapEvent, withEventMeta } from '@standardserver/core';
11
+ export { ErrorEvent, EventMeta, getEventMeta, unwrapEvent, withEventMeta } from '@standardserver/core';
12
12
 
13
13
  interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorMap extends ErrorMap> extends Middleware<TInContext, TOutContext, TInput, TOutput, TErrorMap> {
14
14
  adaptInput<T>(adapt: (input: T) => TInput): DecoratedMiddleware<TInContext, TOutContext, T, TOutput, TErrorMap>;
package/dist/index.d.ts CHANGED
@@ -1,14 +1,14 @@
1
1
  import { AnyORPCError, ClientOptions, ClientContext } from '@orpc/client';
2
- export { AnyORPCError, AnyORPCErrorJSON, COMMON_ERROR_STATUS_MAP, ORPCError, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, RPCJsonSerialization, RPCJsonSerializationMeta, RPCJsonSerializer, RPCJsonSerializerHandler, RPCJsonSerializerOptions, RPCSerializer, RPCSerializerOptions, RPCSerializerSerializeOptions, cloneORPCError, isDefinedError, isInferableError, safe, toORPCError } from '@orpc/client';
2
+ export { AnyORPCError, AnyORPCErrorJSON, COMMON_ERROR_STATUS_MAP, Client, ClientContext, ClientOptions, ClientRest, FriendlyClientOptions, ORPCError, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, RPCJsonSerialization, RPCJsonSerializationMeta, RPCJsonSerializer, RPCJsonSerializerHandler, RPCJsonSerializerOptions, RPCSerializer, RPCSerializerOptions, RPCSerializerSerializeOptions, SafeResult, cloneORPCError, isDefinedError, isInferableError, safe, toORPCError } from '@orpc/client';
3
3
  import { ErrorMap, MergedErrorMap, AnySchema, MetaPlugin, InferSchemaOutput, InferSchemaInput, AugmentContractRouterOptions, RouterContract, AnyProcedureContract, InitialInputSchema, InitialOutputSchema, MergedSchema, Schema, ProcedureContractDefinition, ProcedureContract, InferRouterContractErrorMap, ORPCErrorFromErrorMap } from '@orpc/contract';
4
4
  export { AnyMetaPlugin, AnySchema, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, MergedErrorMap, Meta, MetaPlugin, MetaPluginDefinition, ORPCErrorFromErrorMap, ProcedureContract, ProcedureContractDefinition, RouterContract, Schema, ValidationError, defineMeta, eventIterator, reconcileORPCError, type } from '@orpc/contract';
5
5
  import { IntersectPick, Promisable, Public, PromiseWithError, ThrowableError, MaybeOptionalOptions } from '@orpc/shared';
6
- export { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, Registry, ThrowableError, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
6
+ export { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, MaybeOptionalOptions, PromiseWithError, Registry, ThrowableError, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
7
7
  import { C as Context, d as Middleware, M as MergedContext, e as MergedInitialContext, a as Procedure, f as AnyMiddleware, g as Lazy, A as AnyProcedure, L as Lazyable, h as ProcedureHandler, O as ORPCErrorConstructorMap, i as OrderedMiddleware, P as ProcedureClientOptions, b as ProcedureClient } from './shared/server.BL22TloH.js';
8
8
  export { j as LazyDefinition, k as MiddlewareDefinition, l as MiddlewareDone, m as MiddlewareDoneOptions, n as MiddlewareNext, o as MiddlewareNextOptions, p as MiddlewareOptions, q as MiddlewareResult, r as ORPCErrorConstructorMapItem, s as ORPCErrorConstructorMapItemOptions, c as ProcedureClientInterceptor, t as ProcedureClientInterceptorOptions, u as ProcedureDefinition, v as ProcedureHandlerOptions, w as createORPCErrorConstructorMap, x as createProcedureClient, y as unlazy } from './shared/server.BL22TloH.js';
9
9
  import { A as AnyRouter, R as Router, C as ContractedRouter, I as InferRouterInitialContext } from './shared/server.Pa0F03f_.js';
10
10
  export { a as InferRouterError, b as InferRouterErrors, c as InferRouterFinalContexts, d as InferRouterInitialContexts, e as InferRouterInputs, f as InferRouterOutputs } from './shared/server.Pa0F03f_.js';
11
- export { ErrorEvent, getEventMeta, unwrapEvent, withEventMeta } from '@standardserver/core';
11
+ export { ErrorEvent, EventMeta, getEventMeta, unwrapEvent, withEventMeta } from '@standardserver/core';
12
12
 
13
13
  interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorMap extends ErrorMap> extends Middleware<TInContext, TOutContext, TInput, TOutput, TErrorMap> {
14
14
  adaptInput<T>(adapt: (input: T) => TInput): DecoratedMiddleware<TInContext, TOutContext, T, TOutput, TErrorMap>;
@@ -1,7 +1,7 @@
1
- import { Value, Promisable } from '@orpc/shared';
1
+ import { Value, Promisable, ThrowableError } from '@orpc/shared';
2
2
  import { StandardLazyRequest, StandardHeaders } from '@standardserver/core';
3
3
  import { C as Context } from '../shared/server.BL22TloH.mjs';
4
- import { e as StandardHandlerPlugin, f as StandardHandlerRoutingInterceptorOptions, a as StandardHandlerOptions } from '../shared/server.BB_Ik9Ph.mjs';
4
+ import { e as StandardHandlerPlugin, f as StandardHandlerRoutingInterceptorOptions, a as StandardHandlerOptions, g as StandardHandlerInterceptorOptions } from '../shared/server.DJIkub_t.mjs';
5
5
  import '@orpc/client';
6
6
  import '@orpc/contract';
7
7
 
@@ -162,5 +162,36 @@ declare class ResponseHeadersHandlerPlugin<T extends ResponseHeadersHandlerPlugi
162
162
  init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
163
163
  }
164
164
 
165
- export { BatchHandlerPlugin, CORSHandlerPlugin, CSRFGuardHandlerPlugin, RequestHeadersHandlerPlugin, ResponseHeadersHandlerPlugin };
166
- export type { BatchHandlerPluginOptions, CORSHandlerPluginOptions, RequestHeadersHandlerPluginContext, ResponseHeadersHandlerPluginContext };
165
+ interface RethrowHandlerPluginOptions<T extends Context> {
166
+ /**
167
+ * Decide which errors should be rethrown.
168
+ *
169
+ * @example
170
+ * ```ts
171
+ * const rethrowPlugin = new RethrowHandlerPlugin({
172
+ * filter: (error) => {
173
+ * // Rethrow all non-ORPCError errors
174
+ * return !(error instanceof ORPCError)
175
+ * }
176
+ * })
177
+ * ```
178
+ */
179
+ filter: (error: ThrowableError, options: StandardHandlerInterceptorOptions<T>) => boolean;
180
+ }
181
+ /**
182
+ * The plugin can bypass oRPC's built-in error handling
183
+ * and rethrow matching errors directly to your framework's error handling mechanism
184
+ * (e.g., NestJS exception filters, Express error middleware).
185
+ *
186
+ * @see {@link https://orpc.dev/docs/plugins/rethrow Rethrow Plugin Documentation}
187
+ */
188
+ declare class RethrowHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
189
+ name: string;
190
+ private readonly filter;
191
+ private readonly CONTEXT_SYMBOL;
192
+ constructor(options: RethrowHandlerPluginOptions<T>);
193
+ init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
194
+ }
195
+
196
+ export { BatchHandlerPlugin, CORSHandlerPlugin, CSRFGuardHandlerPlugin, RequestHeadersHandlerPlugin, ResponseHeadersHandlerPlugin, RethrowHandlerPlugin };
197
+ export type { BatchHandlerPluginOptions, CORSHandlerPluginOptions, RequestHeadersHandlerPluginContext, ResponseHeadersHandlerPluginContext, RethrowHandlerPluginOptions };
@@ -1,7 +1,7 @@
1
- import { Value, Promisable } from '@orpc/shared';
1
+ import { Value, Promisable, ThrowableError } from '@orpc/shared';
2
2
  import { StandardLazyRequest, StandardHeaders } from '@standardserver/core';
3
3
  import { C as Context } from '../shared/server.BL22TloH.js';
4
- import { e as StandardHandlerPlugin, f as StandardHandlerRoutingInterceptorOptions, a as StandardHandlerOptions } from '../shared/server.EOHJ3NJr.js';
4
+ import { e as StandardHandlerPlugin, f as StandardHandlerRoutingInterceptorOptions, a as StandardHandlerOptions, g as StandardHandlerInterceptorOptions } from '../shared/server.DBANIheG.js';
5
5
  import '@orpc/client';
6
6
  import '@orpc/contract';
7
7
 
@@ -162,5 +162,36 @@ declare class ResponseHeadersHandlerPlugin<T extends ResponseHeadersHandlerPlugi
162
162
  init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
163
163
  }
164
164
 
165
- export { BatchHandlerPlugin, CORSHandlerPlugin, CSRFGuardHandlerPlugin, RequestHeadersHandlerPlugin, ResponseHeadersHandlerPlugin };
166
- export type { BatchHandlerPluginOptions, CORSHandlerPluginOptions, RequestHeadersHandlerPluginContext, ResponseHeadersHandlerPluginContext };
165
+ interface RethrowHandlerPluginOptions<T extends Context> {
166
+ /**
167
+ * Decide which errors should be rethrown.
168
+ *
169
+ * @example
170
+ * ```ts
171
+ * const rethrowPlugin = new RethrowHandlerPlugin({
172
+ * filter: (error) => {
173
+ * // Rethrow all non-ORPCError errors
174
+ * return !(error instanceof ORPCError)
175
+ * }
176
+ * })
177
+ * ```
178
+ */
179
+ filter: (error: ThrowableError, options: StandardHandlerInterceptorOptions<T>) => boolean;
180
+ }
181
+ /**
182
+ * The plugin can bypass oRPC's built-in error handling
183
+ * and rethrow matching errors directly to your framework's error handling mechanism
184
+ * (e.g., NestJS exception filters, Express error middleware).
185
+ *
186
+ * @see {@link https://orpc.dev/docs/plugins/rethrow Rethrow Plugin Documentation}
187
+ */
188
+ declare class RethrowHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
189
+ name: string;
190
+ private readonly filter;
191
+ private readonly CONTEXT_SYMBOL;
192
+ constructor(options: RethrowHandlerPluginOptions<T>);
193
+ init(options: StandardHandlerOptions<T>): StandardHandlerOptions<T>;
194
+ }
195
+
196
+ export { BatchHandlerPlugin, CORSHandlerPlugin, CSRFGuardHandlerPlugin, RequestHeadersHandlerPlugin, ResponseHeadersHandlerPlugin, RethrowHandlerPlugin };
197
+ export type { BatchHandlerPluginOptions, CORSHandlerPluginOptions, RequestHeadersHandlerPluginContext, ResponseHeadersHandlerPluginContext, RethrowHandlerPluginOptions };
@@ -302,4 +302,56 @@ class ResponseHeadersHandlerPlugin {
302
302
  }
303
303
  }
304
304
 
305
- export { BatchHandlerPlugin, CORSHandlerPlugin, RequestHeadersHandlerPlugin, ResponseHeadersHandlerPlugin };
305
+ class RethrowHandlerPlugin {
306
+ name = "~rethrow";
307
+ filter;
308
+ CONTEXT_SYMBOL = Symbol("ORPC_RETHROW_HANDLER_PLUGIN_CONTEXT");
309
+ constructor(options) {
310
+ this.filter = options.filter;
311
+ }
312
+ init(options) {
313
+ const routingInterceptor = async (options2) => {
314
+ const pluginContext = {};
315
+ const result = await options2.next({
316
+ ...options2,
317
+ context: {
318
+ ...options2.context,
319
+ [this.CONTEXT_SYMBOL]: pluginContext
320
+ }
321
+ });
322
+ if (pluginContext.error) {
323
+ throw pluginContext.error.value;
324
+ }
325
+ return result;
326
+ };
327
+ const interceptor = async (options2) => {
328
+ const pluginContext = options2.context[this.CONTEXT_SYMBOL];
329
+ if (!pluginContext) {
330
+ throw new TypeError("[RethrowHandlerPlugin] Rethrow handler context has been corrupted or modified by another plugin or interceptor");
331
+ }
332
+ try {
333
+ return await options2.next();
334
+ } catch (error) {
335
+ if (this.filter(error, options2)) {
336
+ pluginContext.error = { value: error };
337
+ }
338
+ throw error;
339
+ }
340
+ };
341
+ return {
342
+ ...options,
343
+ routingInterceptors: [
344
+ ...toArray(options.routingInterceptors),
345
+ routingInterceptor
346
+ // rethrow as early as possible and keep it close to `interceptor` to avoid a corrupted or modified context
347
+ ],
348
+ interceptors: [
349
+ interceptor,
350
+ // catch as many errors as possible
351
+ ...toArray(options.interceptors)
352
+ ]
353
+ };
354
+ }
355
+ }
356
+
357
+ export { BatchHandlerPlugin, CORSHandlerPlugin, RequestHeadersHandlerPlugin, ResponseHeadersHandlerPlugin, RethrowHandlerPlugin };
@@ -4,7 +4,7 @@ import { StandardMethod, StandardLazyRequest, StandardResponse } from '@standard
4
4
  import { A as AnyProcedure, C as Context } from './server.BL22TloH.mjs';
5
5
  import { A as AnyRouter } from './server.BsNNjG5J.mjs';
6
6
  import { AnyProcedureContract } from '@orpc/contract';
7
- import { b as StandardHandlerHandleOptions, c as StandardHandlerCodec, d as StandardHandlerCodecResolvedProcedure } from './server.BB_Ik9Ph.mjs';
7
+ import { b as StandardHandlerHandleOptions, c as StandardHandlerCodec, d as StandardHandlerCodecResolvedProcedure } from './server.DJIkub_t.mjs';
8
8
 
9
9
  interface RPCMatcherOptions {
10
10
  /**
@@ -101,4 +101,4 @@ interface StandardHandlerCodec<T extends Context> {
101
101
  }
102
102
 
103
103
  export { CompositeStandardHandlerPlugin as C, OtelHandlerPlugin as O, StandardHandler as S };
104
- export type { StandardHandlerOptions as a, StandardHandlerHandleOptions as b, StandardHandlerCodec as c, StandardHandlerCodecResolvedProcedure as d, StandardHandlerPlugin as e, StandardHandlerRoutingInterceptorOptions as f, StandardHandlerHandleResult as g, StandardHandlerInterceptor as h, StandardHandlerInterceptorOptions as i, StandardHandlerRoutingInterceptor as j };
104
+ export type { StandardHandlerOptions as a, StandardHandlerHandleOptions as b, StandardHandlerCodec as c, StandardHandlerCodecResolvedProcedure as d, StandardHandlerPlugin as e, StandardHandlerRoutingInterceptorOptions as f, StandardHandlerInterceptorOptions as g, StandardHandlerHandleResult as h, StandardHandlerInterceptor as i, StandardHandlerRoutingInterceptor as j };
@@ -101,4 +101,4 @@ interface StandardHandlerCodec<T extends Context> {
101
101
  }
102
102
 
103
103
  export { CompositeStandardHandlerPlugin as C, OtelHandlerPlugin as O, StandardHandler as S };
104
- export type { StandardHandlerOptions as a, StandardHandlerHandleOptions as b, StandardHandlerCodec as c, StandardHandlerCodecResolvedProcedure as d, StandardHandlerPlugin as e, StandardHandlerRoutingInterceptorOptions as f, StandardHandlerHandleResult as g, StandardHandlerInterceptor as h, StandardHandlerInterceptorOptions as i, StandardHandlerRoutingInterceptor as j };
104
+ export type { StandardHandlerOptions as a, StandardHandlerHandleOptions as b, StandardHandlerCodec as c, StandardHandlerCodecResolvedProcedure as d, StandardHandlerPlugin as e, StandardHandlerRoutingInterceptorOptions as f, StandardHandlerInterceptorOptions as g, StandardHandlerHandleResult as h, StandardHandlerInterceptor as i, StandardHandlerRoutingInterceptor as j };
@@ -4,7 +4,7 @@ import { StandardMethod, StandardLazyRequest, StandardResponse } from '@standard
4
4
  import { A as AnyProcedure, C as Context } from './server.BL22TloH.js';
5
5
  import { A as AnyRouter } from './server.Pa0F03f_.js';
6
6
  import { AnyProcedureContract } from '@orpc/contract';
7
- import { b as StandardHandlerHandleOptions, c as StandardHandlerCodec, d as StandardHandlerCodecResolvedProcedure } from './server.EOHJ3NJr.js';
7
+ import { b as StandardHandlerHandleOptions, c as StandardHandlerCodec, d as StandardHandlerCodecResolvedProcedure } from './server.DBANIheG.js';
8
8
 
9
9
  interface RPCMatcherOptions {
10
10
  /**
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/server",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.1",
4
+ "version": "2.0.0-beta.11",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.dev",
7
7
  "repository": {
@@ -85,15 +85,15 @@
85
85
  }
86
86
  },
87
87
  "dependencies": {
88
- "@standardserver/core": "^0.0.24",
89
- "@standardserver/fetch": "^0.0.24",
90
- "@standardserver/node": "^0.0.24",
91
- "@standardserver/peer": "^0.0.24",
88
+ "@standardserver/core": "^0.0.25",
89
+ "@standardserver/fetch": "^0.0.25",
90
+ "@standardserver/node": "^0.0.25",
91
+ "@standardserver/peer": "^0.0.25",
92
92
  "cookie": "^1.1.1",
93
- "@orpc/client": "2.0.0-beta.1",
94
- "@orpc/interop": "2.0.0-beta.1",
95
- "@orpc/contract": "2.0.0-beta.1",
96
- "@orpc/shared": "2.0.0-beta.1"
93
+ "@orpc/client": "2.0.0-beta.11",
94
+ "@orpc/contract": "2.0.0-beta.11",
95
+ "@orpc/shared": "2.0.0-beta.11",
96
+ "@orpc/interop": "2.0.0-beta.11"
97
97
  },
98
98
  "devDependencies": {
99
99
  "crossws": "^0.4.6",