@orpc/server 0.0.0-next.dbce934 → 0.0.0-next.dc2afcb

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 (58) hide show
  1. package/README.md +11 -8
  2. package/dist/adapters/aws-lambda/index.d.mts +7 -7
  3. package/dist/adapters/aws-lambda/index.d.ts +7 -7
  4. package/dist/adapters/aws-lambda/index.mjs +3 -3
  5. package/dist/adapters/bun-ws/index.d.mts +7 -7
  6. package/dist/adapters/bun-ws/index.d.ts +7 -7
  7. package/dist/adapters/bun-ws/index.mjs +2 -2
  8. package/dist/adapters/crossws/index.d.mts +7 -7
  9. package/dist/adapters/crossws/index.d.ts +7 -7
  10. package/dist/adapters/crossws/index.mjs +2 -2
  11. package/dist/adapters/fastify/index.d.mts +53 -0
  12. package/dist/adapters/fastify/index.d.ts +53 -0
  13. package/dist/adapters/fastify/index.mjs +54 -0
  14. package/dist/adapters/fetch/index.d.mts +10 -10
  15. package/dist/adapters/fetch/index.d.ts +10 -10
  16. package/dist/adapters/fetch/index.mjs +3 -3
  17. package/dist/adapters/message-port/index.d.mts +37 -11
  18. package/dist/adapters/message-port/index.d.ts +37 -11
  19. package/dist/adapters/message-port/index.mjs +28 -12
  20. package/dist/adapters/node/index.d.mts +11 -11
  21. package/dist/adapters/node/index.d.ts +11 -11
  22. package/dist/adapters/node/index.mjs +3 -3
  23. package/dist/adapters/standard/index.d.mts +6 -6
  24. package/dist/adapters/standard/index.d.ts +6 -6
  25. package/dist/adapters/standard/index.mjs +2 -2
  26. package/dist/adapters/standard-peer/index.d.mts +3 -3
  27. package/dist/adapters/standard-peer/index.d.ts +3 -3
  28. package/dist/adapters/websocket/index.d.mts +11 -9
  29. package/dist/adapters/websocket/index.d.ts +11 -9
  30. package/dist/adapters/websocket/index.mjs +2 -2
  31. package/dist/adapters/ws/index.d.mts +7 -7
  32. package/dist/adapters/ws/index.d.ts +7 -7
  33. package/dist/adapters/ws/index.mjs +2 -2
  34. package/dist/helpers/index.d.mts +16 -1
  35. package/dist/helpers/index.d.ts +16 -1
  36. package/dist/helpers/index.mjs +11 -1
  37. package/dist/hibernation/index.d.mts +4 -4
  38. package/dist/hibernation/index.d.ts +4 -4
  39. package/dist/index.d.mts +101 -101
  40. package/dist/index.d.ts +101 -101
  41. package/dist/index.mjs +32 -29
  42. package/dist/plugins/index.d.mts +46 -11
  43. package/dist/plugins/index.d.ts +46 -11
  44. package/dist/plugins/index.mjs +43 -2
  45. package/dist/shared/{server.DPIFWpxG.d.ts → server.7cEtMB30.d.ts} +1 -1
  46. package/dist/shared/{server.CVKCo60T.d.mts → server.B8gYOD5g.d.mts} +2 -2
  47. package/dist/shared/{server.DBCUJijK.d.mts → server.BqadksTP.d.mts} +1 -1
  48. package/dist/shared/{server.vzZSq5UM.mjs → server.Bxx6tqNe.mjs} +1 -1
  49. package/dist/shared/{server.DzV1hr3z.d.mts → server.C8_sRzQB.d.mts} +1 -1
  50. package/dist/shared/{server.Ck-gOLzq.d.mts → server.ChUyt5-i.d.mts} +3 -3
  51. package/dist/shared/{server.Cb6yD7DZ.d.ts → server.ChyoA9XY.d.ts} +1 -1
  52. package/dist/shared/{server.CaqDCZX1.mjs → server.Ds4HPpvH.mjs} +3 -3
  53. package/dist/shared/{server.DNtJ-p60.d.ts → server.EfTOZ2Q7.d.ts} +2 -2
  54. package/dist/shared/{server.BW-nUGgA.mjs → server.TEVCLCFC.mjs} +3 -0
  55. package/dist/shared/{server.B4BGqy3Y.d.mts → server.qKsRrdxW.d.mts} +8 -8
  56. package/dist/shared/{server.B4BGqy3Y.d.ts → server.qKsRrdxW.d.ts} +8 -8
  57. package/dist/shared/{server.COL12UTb.d.ts → server.yoEB3Fx4.d.ts} +3 -3
  58. package/package.json +25 -17
package/dist/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  import { mergeErrorMap, mergeMeta, mergeRoute, mergePrefix, mergeTags, isContractProcedure, getContractRouter, fallbackContractConfig } from '@orpc/contract';
2
2
  export { ValidationError, eventIterator, type, validateORPCError } from '@orpc/contract';
3
- import { P as Procedure, b as addMiddleware, c as createProcedureClient, e as enhanceRouter, l as lazy, s as setHiddenRouterContract, u as unlazy, g as getRouter, i as isProcedure, d as isLazy, f as createAssertedLazyProcedure } from './shared/server.CaqDCZX1.mjs';
4
- export { L as LAZY_SYMBOL, p as call, r as createAccessibleLazyRouter, a as createContractedProcedure, h as createORPCErrorConstructorMap, q as getHiddenRouterContract, j as getLazyMeta, n as isStartWithMiddlewares, m as mergeCurrentContext, o as mergeMiddlewares, k as middlewareOutputFn, v as resolveContractProcedures, t as traverseContractProcedures, w as unlazyRouter } from './shared/server.CaqDCZX1.mjs';
3
+ import { P as Procedure, b as addMiddleware, c as createProcedureClient, e as enhanceRouter, l as lazy, s as setHiddenRouterContract, u as unlazy, g as getRouter, i as isProcedure, d as isLazy, f as createAssertedLazyProcedure } from './shared/server.Ds4HPpvH.mjs';
4
+ export { L as LAZY_SYMBOL, p as call, r as createAccessibleLazyRouter, a as createContractedProcedure, h as createORPCErrorConstructorMap, q as getHiddenRouterContract, j as getLazyMeta, n as isStartWithMiddlewares, m as mergeCurrentContext, o as mergeMiddlewares, k as middlewareOutputFn, v as resolveContractProcedures, t as traverseContractProcedures, w as unlazyRouter } from './shared/server.Ds4HPpvH.mjs';
5
5
  import { toORPCError } from '@orpc/client';
6
6
  export { ORPCError, isDefinedError, safe } from '@orpc/client';
7
- import { resolveMaybeOptionalOptions } from '@orpc/shared';
8
- export { AsyncIteratorClass, EventPublisher, asyncIteratorToStream as eventIteratorToStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
7
+ import { isObject, resolveMaybeOptionalOptions } from '@orpc/shared';
8
+ export { AsyncIteratorClass, EventPublisher, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
9
9
  export { getEventMeta, withEventMeta } from '@orpc/standard-server';
10
10
 
11
11
  const DEFAULT_CONFIG = {
@@ -54,6 +54,9 @@ function createActionableClient(client) {
54
54
  if (error instanceof Error && "digest" in error && typeof error.digest === "string" && error.digest.startsWith("NEXT_")) {
55
55
  throw error;
56
56
  }
57
+ if (error instanceof Response && "options" in error && isObject(error.options) || isObject(error) && error.isNotFound === true) {
58
+ throw error;
59
+ }
57
60
  return [toORPCError(error).toJSON(), void 0];
58
61
  }
59
62
  };
@@ -65,7 +68,7 @@ class DecoratedProcedure extends Procedure {
65
68
  * Adds type-safe custom errors.
66
69
  * The provided errors are spared-merged with any existing errors.
67
70
  *
68
- * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
71
+ * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
69
72
  */
70
73
  errors(errors) {
71
74
  return new DecoratedProcedure({
@@ -77,7 +80,7 @@ class DecoratedProcedure extends Procedure {
77
80
  * Sets or updates the metadata.
78
81
  * The provided metadata is spared-merged with any existing metadata.
79
82
  *
80
- * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
83
+ * @see {@link https://orpc.dev/docs/metadata Metadata Docs}
81
84
  */
82
85
  meta(meta) {
83
86
  return new DecoratedProcedure({
@@ -90,8 +93,8 @@ class DecoratedProcedure extends Procedure {
90
93
  * The provided route is spared-merged with any existing route.
91
94
  * This option is typically relevant when integrating with OpenAPI.
92
95
  *
93
- * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
94
- * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
96
+ * @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
97
+ * @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
95
98
  */
96
99
  route(route) {
97
100
  return new DecoratedProcedure({
@@ -109,7 +112,7 @@ class DecoratedProcedure extends Procedure {
109
112
  /**
110
113
  * Make this procedure callable (works like a function while still being a procedure).
111
114
  *
112
- * @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
115
+ * @see {@link https://orpc.dev/docs/client/server-side Server-side Client Docs}
113
116
  */
114
117
  callable(...rest) {
115
118
  const client = createProcedureClient(this, ...rest);
@@ -125,7 +128,7 @@ class DecoratedProcedure extends Procedure {
125
128
  /**
126
129
  * Make this procedure compatible with server action.
127
130
  *
128
- * @see {@link https://orpc.unnoq.com/docs/server-action Server Action Docs}
131
+ * @see {@link https://orpc.dev/docs/server-action Server Action Docs}
129
132
  */
130
133
  actionable(...rest) {
131
134
  const action = createActionableClient(createProcedureClient(this, ...rest));
@@ -151,8 +154,8 @@ class Builder {
151
154
  /**
152
155
  * Sets or overrides the config.
153
156
  *
154
- * @see {@link https://orpc.unnoq.com/docs/client/server-side#middlewares-order Middlewares Order Docs}
155
- * @see {@link https://orpc.unnoq.com/docs/best-practices/dedupe-middleware#configuration Dedupe Middleware Docs}
157
+ * @see {@link https://orpc.dev/docs/client/server-side#middlewares-order Middlewares Order Docs}
158
+ * @see {@link https://orpc.dev/docs/best-practices/dedupe-middleware#configuration Dedupe Middleware Docs}
156
159
  */
157
160
  $config(config) {
158
161
  const inputValidationCount = this["~orpc"].inputValidationIndex - fallbackConfig("initialInputValidationIndex", this["~orpc"].config.initialInputValidationIndex);
@@ -168,7 +171,7 @@ class Builder {
168
171
  /**
169
172
  * Set or override the initial context.
170
173
  *
171
- * @see {@link https://orpc.unnoq.com/docs/context Context Docs}
174
+ * @see {@link https://orpc.dev/docs/context Context Docs}
172
175
  */
173
176
  $context() {
174
177
  return new Builder({
@@ -181,7 +184,7 @@ class Builder {
181
184
  /**
182
185
  * Sets or overrides the initial meta.
183
186
  *
184
- * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
187
+ * @see {@link https://orpc.dev/docs/metadata Metadata Docs}
185
188
  */
186
189
  $meta(initialMeta) {
187
190
  return new Builder({
@@ -193,8 +196,8 @@ class Builder {
193
196
  * Sets or overrides the initial route.
194
197
  * This option is typically relevant when integrating with OpenAPI.
195
198
  *
196
- * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
197
- * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
199
+ * @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
200
+ * @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
198
201
  */
199
202
  $route(initialRoute) {
200
203
  return new Builder({
@@ -205,7 +208,7 @@ class Builder {
205
208
  /**
206
209
  * Sets or overrides the initial input schema.
207
210
  *
208
- * @see {@link https://orpc.unnoq.com/docs/procedure#initial-configuration Initial Procedure Configuration Docs}
211
+ * @see {@link https://orpc.dev/docs/procedure#initial-configuration Initial Procedure Configuration Docs}
209
212
  */
210
213
  $input(initialInputSchema) {
211
214
  return new Builder({
@@ -216,7 +219,7 @@ class Builder {
216
219
  /**
217
220
  * Creates a middleware.
218
221
  *
219
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
222
+ * @see {@link https://orpc.dev/docs/middleware Middleware Docs}
220
223
  */
221
224
  middleware(middleware) {
222
225
  return decorateMiddleware(middleware);
@@ -225,7 +228,7 @@ class Builder {
225
228
  * Adds type-safe custom errors.
226
229
  * The provided errors are spared-merged with any existing errors.
227
230
  *
228
- * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
231
+ * @see {@link https://orpc.dev/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
229
232
  */
230
233
  errors(errors) {
231
234
  return new Builder({
@@ -244,7 +247,7 @@ class Builder {
244
247
  * Sets or updates the metadata.
245
248
  * The provided metadata is spared-merged with any existing metadata.
246
249
  *
247
- * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
250
+ * @see {@link https://orpc.dev/docs/metadata Metadata Docs}
248
251
  */
249
252
  meta(meta) {
250
253
  return new Builder({
@@ -257,8 +260,8 @@ class Builder {
257
260
  * The provided route is spared-merged with any existing route.
258
261
  * This option is typically relevant when integrating with OpenAPI.
259
262
  *
260
- * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
261
- * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
263
+ * @see {@link https://orpc.dev/docs/openapi/routing OpenAPI Routing Docs}
264
+ * @see {@link https://orpc.dev/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
262
265
  */
263
266
  route(route) {
264
267
  return new Builder({
@@ -269,7 +272,7 @@ class Builder {
269
272
  /**
270
273
  * Defines the input validation schema.
271
274
  *
272
- * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
275
+ * @see {@link https://orpc.dev/docs/procedure#input-output-validation Input Validation Docs}
273
276
  */
274
277
  input(schema) {
275
278
  return new Builder({
@@ -281,7 +284,7 @@ class Builder {
281
284
  /**
282
285
  * Defines the output validation schema.
283
286
  *
284
- * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
287
+ * @see {@link https://orpc.dev/docs/procedure#input-output-validation Output Validation Docs}
285
288
  */
286
289
  output(schema) {
287
290
  return new Builder({
@@ -293,7 +296,7 @@ class Builder {
293
296
  /**
294
297
  * Defines the handler of the procedure.
295
298
  *
296
- * @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
299
+ * @see {@link https://orpc.dev/docs/procedure Procedure Docs}
297
300
  */
298
301
  handler(handler) {
299
302
  return new DecoratedProcedure({
@@ -307,7 +310,7 @@ class Builder {
307
310
  *
308
311
  * @note This option does not affect procedures that do not define a path in their route definition.
309
312
  *
310
- * @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
313
+ * @see {@link https://orpc.dev/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
311
314
  */
312
315
  prefix(prefix) {
313
316
  return new Builder({
@@ -319,7 +322,7 @@ class Builder {
319
322
  * Adds tags to all procedures in the router.
320
323
  * This helpful when you want to group procedures together in the OpenAPI specification.
321
324
  *
322
- * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
325
+ * @see {@link https://orpc.dev/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
323
326
  */
324
327
  tag(...tags) {
325
328
  return new Builder({
@@ -330,7 +333,7 @@ class Builder {
330
333
  /**
331
334
  * Applies all of the previously defined options to the specified router.
332
335
  *
333
- * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
336
+ * @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs}
334
337
  */
335
338
  router(router) {
336
339
  return enhanceRouter(router, this["~orpc"]);
@@ -339,7 +342,7 @@ class Builder {
339
342
  * Create a lazy router
340
343
  * And applies all of the previously defined options to the specified router.
341
344
  *
342
- * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
345
+ * @see {@link https://orpc.dev/docs/router#extending-router Extending Router Docs}
343
346
  */
344
347
  lazy(loader) {
345
348
  return enhanceRouter(lazy(loader), this["~orpc"]);
@@ -1,8 +1,8 @@
1
- import { Value, Promisable } from '@orpc/shared';
1
+ import { Value, Promisable, ThrowableError } from '@orpc/shared';
2
2
  import { StandardRequest, StandardHeaders } from '@orpc/standard-server';
3
3
  import { BatchResponseBodyItem } from '@orpc/standard-server/batch';
4
- import { d as StandardHandlerInterceptorOptions, g as StandardHandlerPlugin, e as StandardHandlerOptions } from '../shared/server.DBCUJijK.mjs';
5
- import { C as Context, d as ProcedureClientInterceptorOptions } from '../shared/server.B4BGqy3Y.mjs';
4
+ import { d as StandardHandlerInterceptorOptions, g as StandardHandlerPlugin, e as StandardHandlerOptions } from '../shared/server.BqadksTP.mjs';
5
+ import { C as Context, d as ProcedureClientInterceptorOptions } from '../shared/server.qKsRrdxW.mjs';
6
6
  import { Meta, ORPCError as ORPCError$1 } from '@orpc/contract';
7
7
  import { ORPCError } from '@orpc/client';
8
8
 
@@ -36,7 +36,7 @@ interface BatchHandlerOptions<T extends Context> {
36
36
  * The Batch Requests Plugin allows you to combine multiple requests and responses into a single batch,
37
37
  * reducing the overhead of sending each one separately.
38
38
  *
39
- * @see {@link https://orpc.unnoq.com/docs/plugins/batch-requests Batch Requests Plugin Docs}
39
+ * @see {@link https://orpc.dev/docs/plugins/batch-requests Batch Requests Plugin Docs}
40
40
  */
41
41
  declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
42
42
  private readonly maxSize;
@@ -60,7 +60,7 @@ interface CORSOptions<T extends Context> {
60
60
  /**
61
61
  * CORSPlugin is a plugin for oRPC that allows you to configure CORS for your API.
62
62
  *
63
- * @see {@link https://orpc.unnoq.com/docs/plugins/cors CORS Plugin Docs}
63
+ * @see {@link https://orpc.dev/docs/plugins/cors CORS Plugin Docs}
64
64
  */
65
65
  declare class CORSPlugin<T extends Context> implements StandardHandlerPlugin<T> {
66
66
  private readonly options;
@@ -76,7 +76,7 @@ interface RequestHeadersPluginContext {
76
76
  * The Request Headers Plugin injects a `reqHeaders` instance into the context,
77
77
  * allowing access to request headers in oRPC.
78
78
  *
79
- * @see {@link https://orpc.unnoq.com/docs/plugins/request-headers Request Headers Plugin Docs}
79
+ * @see {@link https://orpc.dev/docs/plugins/request-headers Request Headers Plugin Docs}
80
80
  */
81
81
  declare class RequestHeadersPlugin<T extends RequestHeadersPluginContext> implements StandardHandlerPlugin<T> {
82
82
  init(options: StandardHandlerOptions<T>): void;
@@ -89,12 +89,44 @@ interface ResponseHeadersPluginContext {
89
89
  * The Response Headers Plugin allows you to set response headers in oRPC.
90
90
  * It injects a resHeaders instance into the context, enabling you to modify response headers easily.
91
91
  *
92
- * @see {@link https://orpc.unnoq.com/docs/plugins/response-headers Response Headers Plugin Docs}
92
+ * @see {@link https://orpc.dev/docs/plugins/response-headers Response Headers Plugin Docs}
93
93
  */
94
94
  declare class ResponseHeadersPlugin<T extends ResponseHeadersPluginContext> implements StandardHandlerPlugin<T> {
95
95
  init(options: StandardHandlerOptions<T>): void;
96
96
  }
97
97
 
98
+ interface experimental_RethrowHandlerPluginOptions<T extends Context> {
99
+ /**
100
+ * Decide which errors should be rethrown.
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * const rethrowPlugin = new RethrowHandlerPlugin({
105
+ * filter: (error) => {
106
+ * // Rethrow all non-ORPCError errors
107
+ * return !(error instanceof ORPCError)
108
+ * }
109
+ * })
110
+ * ```
111
+ */
112
+ filter: Value<boolean, [error: ThrowableError, options: StandardHandlerInterceptorOptions<T>]>;
113
+ }
114
+ /**
115
+ * The plugin allows you to catch and rethrow specific errors that occur during request handling.
116
+ * This is particularly useful when your framework has its own error handling mechanism
117
+ * (e.g., global exception filters in NestJS, error middleware in Express)
118
+ * and you want certain errors to be processed by that mechanism instead of being handled by the
119
+ * oRPC error handling flow.
120
+ *
121
+ * @see {@link https://orpc.dev/docs/plugins/rethrow-handler Rethrow Handler Plugin Docs}
122
+ */
123
+ declare class experimental_RethrowHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
124
+ private readonly filter;
125
+ CONTEXT_SYMBOL: symbol;
126
+ constructor(options: experimental_RethrowHandlerPluginOptions<T>);
127
+ init(options: StandardHandlerOptions<T>): void;
128
+ }
129
+
98
130
  interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
99
131
  /**
100
132
  * The name of the header to check.
@@ -131,7 +163,7 @@ interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
131
163
  * It helps ensure that requests to your procedures originate from JavaScript code,
132
164
  * not from other sources like standard HTML forms or direct browser navigation.
133
165
  *
134
- * @see {@link https://orpc.unnoq.com/docs/plugins/simple-csrf-protection Simple CSRF Protection Plugin Docs}
166
+ * @see {@link https://orpc.dev/docs/plugins/simple-csrf-protection Simple CSRF Protection Plugin Docs}
135
167
  */
136
168
  declare class SimpleCsrfProtectionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
137
169
  private readonly headerName;
@@ -156,14 +188,17 @@ interface StrictGetMethodPluginOptions {
156
188
  * can be called using the HTTP GET method for RPC Protocol. This helps prevent certain types of
157
189
  * Cross-Site Request Forgery (CSRF) attacks.
158
190
  *
159
- * @see {@link https://orpc.unnoq.com/docs/plugins/strict-get-method Strict Get Method Plugin Docs}
191
+ * @see {@link https://orpc.dev/docs/plugins/strict-get-method Strict Get Method Plugin Docs}
160
192
  */
161
193
  declare class StrictGetMethodPlugin<T extends Context> implements StandardHandlerPlugin<T> {
162
194
  private readonly error;
195
+ /**
196
+ * make sure execute before batch plugin to get real method
197
+ */
163
198
  order: number;
164
199
  constructor(options?: StrictGetMethodPluginOptions);
165
200
  init(options: StandardHandlerOptions<T>): void;
166
201
  }
167
202
 
168
- export { BatchHandlerPlugin, CORSPlugin, RequestHeadersPlugin, ResponseHeadersPlugin, SimpleCsrfProtectionHandlerPlugin, StrictGetMethodPlugin };
169
- export type { BatchHandlerOptions, CORSOptions, RequestHeadersPluginContext, ResponseHeadersPluginContext, SimpleCsrfProtectionHandlerPluginOptions, StrictGetMethodPluginOptions };
203
+ export { BatchHandlerPlugin, CORSPlugin, RequestHeadersPlugin, ResponseHeadersPlugin, SimpleCsrfProtectionHandlerPlugin, StrictGetMethodPlugin, experimental_RethrowHandlerPlugin };
204
+ export type { BatchHandlerOptions, CORSOptions, RequestHeadersPluginContext, ResponseHeadersPluginContext, SimpleCsrfProtectionHandlerPluginOptions, StrictGetMethodPluginOptions, experimental_RethrowHandlerPluginOptions };
@@ -1,8 +1,8 @@
1
- import { Value, Promisable } from '@orpc/shared';
1
+ import { Value, Promisable, ThrowableError } from '@orpc/shared';
2
2
  import { StandardRequest, StandardHeaders } from '@orpc/standard-server';
3
3
  import { BatchResponseBodyItem } from '@orpc/standard-server/batch';
4
- import { d as StandardHandlerInterceptorOptions, g as StandardHandlerPlugin, e as StandardHandlerOptions } from '../shared/server.DPIFWpxG.js';
5
- import { C as Context, d as ProcedureClientInterceptorOptions } from '../shared/server.B4BGqy3Y.js';
4
+ import { d as StandardHandlerInterceptorOptions, g as StandardHandlerPlugin, e as StandardHandlerOptions } from '../shared/server.7cEtMB30.js';
5
+ import { C as Context, d as ProcedureClientInterceptorOptions } from '../shared/server.qKsRrdxW.js';
6
6
  import { Meta, ORPCError as ORPCError$1 } from '@orpc/contract';
7
7
  import { ORPCError } from '@orpc/client';
8
8
 
@@ -36,7 +36,7 @@ interface BatchHandlerOptions<T extends Context> {
36
36
  * The Batch Requests Plugin allows you to combine multiple requests and responses into a single batch,
37
37
  * reducing the overhead of sending each one separately.
38
38
  *
39
- * @see {@link https://orpc.unnoq.com/docs/plugins/batch-requests Batch Requests Plugin Docs}
39
+ * @see {@link https://orpc.dev/docs/plugins/batch-requests Batch Requests Plugin Docs}
40
40
  */
41
41
  declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
42
42
  private readonly maxSize;
@@ -60,7 +60,7 @@ interface CORSOptions<T extends Context> {
60
60
  /**
61
61
  * CORSPlugin is a plugin for oRPC that allows you to configure CORS for your API.
62
62
  *
63
- * @see {@link https://orpc.unnoq.com/docs/plugins/cors CORS Plugin Docs}
63
+ * @see {@link https://orpc.dev/docs/plugins/cors CORS Plugin Docs}
64
64
  */
65
65
  declare class CORSPlugin<T extends Context> implements StandardHandlerPlugin<T> {
66
66
  private readonly options;
@@ -76,7 +76,7 @@ interface RequestHeadersPluginContext {
76
76
  * The Request Headers Plugin injects a `reqHeaders` instance into the context,
77
77
  * allowing access to request headers in oRPC.
78
78
  *
79
- * @see {@link https://orpc.unnoq.com/docs/plugins/request-headers Request Headers Plugin Docs}
79
+ * @see {@link https://orpc.dev/docs/plugins/request-headers Request Headers Plugin Docs}
80
80
  */
81
81
  declare class RequestHeadersPlugin<T extends RequestHeadersPluginContext> implements StandardHandlerPlugin<T> {
82
82
  init(options: StandardHandlerOptions<T>): void;
@@ -89,12 +89,44 @@ interface ResponseHeadersPluginContext {
89
89
  * The Response Headers Plugin allows you to set response headers in oRPC.
90
90
  * It injects a resHeaders instance into the context, enabling you to modify response headers easily.
91
91
  *
92
- * @see {@link https://orpc.unnoq.com/docs/plugins/response-headers Response Headers Plugin Docs}
92
+ * @see {@link https://orpc.dev/docs/plugins/response-headers Response Headers Plugin Docs}
93
93
  */
94
94
  declare class ResponseHeadersPlugin<T extends ResponseHeadersPluginContext> implements StandardHandlerPlugin<T> {
95
95
  init(options: StandardHandlerOptions<T>): void;
96
96
  }
97
97
 
98
+ interface experimental_RethrowHandlerPluginOptions<T extends Context> {
99
+ /**
100
+ * Decide which errors should be rethrown.
101
+ *
102
+ * @example
103
+ * ```ts
104
+ * const rethrowPlugin = new RethrowHandlerPlugin({
105
+ * filter: (error) => {
106
+ * // Rethrow all non-ORPCError errors
107
+ * return !(error instanceof ORPCError)
108
+ * }
109
+ * })
110
+ * ```
111
+ */
112
+ filter: Value<boolean, [error: ThrowableError, options: StandardHandlerInterceptorOptions<T>]>;
113
+ }
114
+ /**
115
+ * The plugin allows you to catch and rethrow specific errors that occur during request handling.
116
+ * This is particularly useful when your framework has its own error handling mechanism
117
+ * (e.g., global exception filters in NestJS, error middleware in Express)
118
+ * and you want certain errors to be processed by that mechanism instead of being handled by the
119
+ * oRPC error handling flow.
120
+ *
121
+ * @see {@link https://orpc.dev/docs/plugins/rethrow-handler Rethrow Handler Plugin Docs}
122
+ */
123
+ declare class experimental_RethrowHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
124
+ private readonly filter;
125
+ CONTEXT_SYMBOL: symbol;
126
+ constructor(options: experimental_RethrowHandlerPluginOptions<T>);
127
+ init(options: StandardHandlerOptions<T>): void;
128
+ }
129
+
98
130
  interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
99
131
  /**
100
132
  * The name of the header to check.
@@ -131,7 +163,7 @@ interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
131
163
  * It helps ensure that requests to your procedures originate from JavaScript code,
132
164
  * not from other sources like standard HTML forms or direct browser navigation.
133
165
  *
134
- * @see {@link https://orpc.unnoq.com/docs/plugins/simple-csrf-protection Simple CSRF Protection Plugin Docs}
166
+ * @see {@link https://orpc.dev/docs/plugins/simple-csrf-protection Simple CSRF Protection Plugin Docs}
135
167
  */
136
168
  declare class SimpleCsrfProtectionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
137
169
  private readonly headerName;
@@ -156,14 +188,17 @@ interface StrictGetMethodPluginOptions {
156
188
  * can be called using the HTTP GET method for RPC Protocol. This helps prevent certain types of
157
189
  * Cross-Site Request Forgery (CSRF) attacks.
158
190
  *
159
- * @see {@link https://orpc.unnoq.com/docs/plugins/strict-get-method Strict Get Method Plugin Docs}
191
+ * @see {@link https://orpc.dev/docs/plugins/strict-get-method Strict Get Method Plugin Docs}
160
192
  */
161
193
  declare class StrictGetMethodPlugin<T extends Context> implements StandardHandlerPlugin<T> {
162
194
  private readonly error;
195
+ /**
196
+ * make sure execute before batch plugin to get real method
197
+ */
163
198
  order: number;
164
199
  constructor(options?: StrictGetMethodPluginOptions);
165
200
  init(options: StandardHandlerOptions<T>): void;
166
201
  }
167
202
 
168
- export { BatchHandlerPlugin, CORSPlugin, RequestHeadersPlugin, ResponseHeadersPlugin, SimpleCsrfProtectionHandlerPlugin, StrictGetMethodPlugin };
169
- export type { BatchHandlerOptions, CORSOptions, RequestHeadersPluginContext, ResponseHeadersPluginContext, SimpleCsrfProtectionHandlerPluginOptions, StrictGetMethodPluginOptions };
203
+ export { BatchHandlerPlugin, CORSPlugin, RequestHeadersPlugin, ResponseHeadersPlugin, SimpleCsrfProtectionHandlerPlugin, StrictGetMethodPlugin, experimental_RethrowHandlerPlugin };
204
+ export type { BatchHandlerOptions, CORSOptions, RequestHeadersPluginContext, ResponseHeadersPluginContext, SimpleCsrfProtectionHandlerPluginOptions, StrictGetMethodPluginOptions, experimental_RethrowHandlerPluginOptions };
@@ -3,7 +3,7 @@ import { flattenHeader } from '@orpc/standard-server';
3
3
  import { parseBatchRequest, toBatchResponse } from '@orpc/standard-server/batch';
4
4
  import { toFetchHeaders } from '@orpc/standard-server-fetch';
5
5
  import { ORPCError } from '@orpc/client';
6
- export { S as StrictGetMethodPlugin } from '../shared/server.BW-nUGgA.mjs';
6
+ export { S as StrictGetMethodPlugin } from '../shared/server.TEVCLCFC.mjs';
7
7
  import '@orpc/contract';
8
8
 
9
9
  class BatchHandlerPlugin {
@@ -241,6 +241,47 @@ class ResponseHeadersPlugin {
241
241
  }
242
242
  }
243
243
 
244
+ class experimental_RethrowHandlerPlugin {
245
+ filter;
246
+ CONTEXT_SYMBOL = Symbol("ORPC_RETHROW_HANDLER_PLUGIN_CONTEXT");
247
+ constructor(options) {
248
+ this.filter = options.filter;
249
+ }
250
+ init(options) {
251
+ options.rootInterceptors ??= [];
252
+ options.interceptors ??= [];
253
+ options.rootInterceptors.push(async (options2) => {
254
+ const pluginContext = {};
255
+ const result = await options2.next({
256
+ ...options2,
257
+ context: {
258
+ ...options2.context,
259
+ [this.CONTEXT_SYMBOL]: pluginContext
260
+ }
261
+ });
262
+ if (pluginContext.error) {
263
+ throw pluginContext.error.value;
264
+ }
265
+ return result;
266
+ });
267
+ options.interceptors.unshift(async (options2) => {
268
+ const pluginContext = options2.context[this.CONTEXT_SYMBOL];
269
+ if (!pluginContext) {
270
+ throw new TypeError("[RethrowHandlerPlugin] Rethrow handler context has been corrupted or modified by another plugin or interceptor");
271
+ }
272
+ try {
273
+ return await options2.next();
274
+ } catch (error) {
275
+ if (value(this.filter, error, options2)) {
276
+ pluginContext.error = { value: error };
277
+ return { matched: false, response: void 0 };
278
+ }
279
+ throw error;
280
+ }
281
+ });
282
+ }
283
+ }
284
+
244
285
  const SIMPLE_CSRF_PROTECTION_CONTEXT_SYMBOL = Symbol("SIMPLE_CSRF_PROTECTION_CONTEXT");
245
286
  class SimpleCsrfProtectionHandlerPlugin {
246
287
  headerName;
@@ -284,4 +325,4 @@ class SimpleCsrfProtectionHandlerPlugin {
284
325
  }
285
326
  }
286
327
 
287
- export { BatchHandlerPlugin, CORSPlugin, RequestHeadersPlugin, ResponseHeadersPlugin, SimpleCsrfProtectionHandlerPlugin };
328
+ export { BatchHandlerPlugin, CORSPlugin, RequestHeadersPlugin, ResponseHeadersPlugin, SimpleCsrfProtectionHandlerPlugin, experimental_RethrowHandlerPlugin };
@@ -2,7 +2,7 @@ import { HTTPPath, ORPCError } from '@orpc/client';
2
2
  import { Meta } from '@orpc/contract';
3
3
  import { Interceptor } from '@orpc/shared';
4
4
  import { StandardResponse, StandardLazyRequest } from '@orpc/standard-server';
5
- import { C as Context, R as Router, b as AnyRouter, A as AnyProcedure, d as ProcedureClientInterceptorOptions } from './server.B4BGqy3Y.js';
5
+ import { C as Context, R as Router, b as AnyRouter, A as AnyProcedure, d as ProcedureClientInterceptorOptions } from './server.qKsRrdxW.js';
6
6
 
7
7
  interface StandardHandlerPlugin<T extends Context> {
8
8
  order?: number;
@@ -1,5 +1,5 @@
1
- import { C as Context } from './server.B4BGqy3Y.mjs';
2
- import { b as StandardHandleOptions } from './server.DBCUJijK.mjs';
1
+ import { C as Context } from './server.qKsRrdxW.mjs';
2
+ import { b as StandardHandleOptions } from './server.BqadksTP.mjs';
3
3
 
4
4
  type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
5
5
  context?: T;
@@ -2,7 +2,7 @@ import { HTTPPath, ORPCError } from '@orpc/client';
2
2
  import { Meta } from '@orpc/contract';
3
3
  import { Interceptor } from '@orpc/shared';
4
4
  import { StandardResponse, StandardLazyRequest } from '@orpc/standard-server';
5
- import { C as Context, R as Router, b as AnyRouter, A as AnyProcedure, d as ProcedureClientInterceptorOptions } from './server.B4BGqy3Y.mjs';
5
+ import { C as Context, R as Router, b as AnyRouter, A as AnyProcedure, d as ProcedureClientInterceptorOptions } from './server.qKsRrdxW.mjs';
6
6
 
7
7
  interface StandardHandlerPlugin<T extends Context> {
8
8
  order?: number;
@@ -2,7 +2,7 @@ import { toHttpPath, StandardRPCJsonSerializer, StandardRPCSerializer } from '@o
2
2
  import { ORPCError, toORPCError } from '@orpc/client';
3
3
  import { toArray, intercept, runWithSpan, ORPC_NAME, isAsyncIteratorObject, asyncIteratorWithSpan, setSpanError, parseEmptyableJSON, NullProtoObj, value } from '@orpc/shared';
4
4
  import { flattenHeader } from '@orpc/standard-server';
5
- import { c as createProcedureClient, t as traverseContractProcedures, i as isProcedure, u as unlazy, g as getRouter, a as createContractedProcedure } from './server.CaqDCZX1.mjs';
5
+ import { c as createProcedureClient, t as traverseContractProcedures, i as isProcedure, u as unlazy, g as getRouter, a as createContractedProcedure } from './server.Ds4HPpvH.mjs';
6
6
 
7
7
  class CompositeStandardHandlerPlugin {
8
8
  plugins;
@@ -1,5 +1,5 @@
1
1
  import { ErrorMap, EnhanceRouteOptions, MergedErrorMap, AnyContractRouter, AnyContractProcedure } from '@orpc/contract';
2
- import { a as AnyMiddleware, L as Lazyable, b as AnyRouter, C as Context, c as Lazy, A as AnyProcedure, P as Procedure, M as MergedInitialContext } from './server.B4BGqy3Y.mjs';
2
+ import { a as AnyMiddleware, L as Lazyable, b as AnyRouter, C as Context, c as Lazy, A as AnyProcedure, P as Procedure, M as MergedInitialContext } from './server.qKsRrdxW.mjs';
3
3
 
4
4
  declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
5
5
  type AccessibleLazyRouter<T extends Lazyable<AnyRouter | undefined>> = T extends Lazy<infer U extends AnyRouter | undefined | Lazy<AnyRouter | undefined>> ? AccessibleLazyRouter<U> : T extends AnyProcedure | undefined ? Lazy<T> : Lazy<T> & {
@@ -1,9 +1,9 @@
1
1
  import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
2
- import { b as AnyRouter, C as Context, R as Router } from './server.B4BGqy3Y.mjs';
3
- import { i as StandardMatcher, h as StandardMatchResult, e as StandardHandlerOptions, f as StandardHandler } from './server.DBCUJijK.mjs';
2
+ import { b as AnyRouter, C as Context, R as Router } from './server.qKsRrdxW.mjs';
3
+ import { i as StandardMatcher, h as StandardMatchResult, e as StandardHandlerOptions, f as StandardHandler } from './server.BqadksTP.mjs';
4
4
  import { HTTPPath } from '@orpc/client';
5
5
  import { Value } from '@orpc/shared';
6
- import { T as TraverseContractProcedureCallbackOptions } from './server.DzV1hr3z.mjs';
6
+ import { T as TraverseContractProcedureCallbackOptions } from './server.C8_sRzQB.mjs';
7
7
 
8
8
  interface StandardRPCMatcherOptions {
9
9
  /**
@@ -1,5 +1,5 @@
1
1
  import { ErrorMap, EnhanceRouteOptions, MergedErrorMap, AnyContractRouter, AnyContractProcedure } from '@orpc/contract';
2
- import { a as AnyMiddleware, L as Lazyable, b as AnyRouter, C as Context, c as Lazy, A as AnyProcedure, P as Procedure, M as MergedInitialContext } from './server.B4BGqy3Y.js';
2
+ import { a as AnyMiddleware, L as Lazyable, b as AnyRouter, C as Context, c as Lazy, A as AnyProcedure, P as Procedure, M as MergedInitialContext } from './server.qKsRrdxW.js';
3
3
 
4
4
  declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
5
5
  type AccessibleLazyRouter<T extends Lazyable<AnyRouter | undefined>> = T extends Lazy<infer U extends AnyRouter | undefined | Lazy<AnyRouter | undefined>> ? AccessibleLazyRouter<U> : T extends AnyProcedure | undefined ? Lazy<T> : Lazy<T> & {
@@ -1,5 +1,5 @@
1
1
  import { isContractProcedure, validateORPCError, ValidationError, mergePrefix, mergeErrorMap, enhanceRoute } from '@orpc/contract';
2
- import { resolveMaybeOptionalOptions, toArray, value, runWithSpan, intercept, isAsyncIteratorObject, asyncIteratorWithSpan } from '@orpc/shared';
2
+ import { resolveMaybeOptionalOptions, toArray, value, runWithSpan, intercept, isAsyncIteratorObject, overlayProxy, asyncIteratorWithSpan } from '@orpc/shared';
3
3
  import { ORPCError, mapEventIterator } from '@orpc/client';
4
4
  import { HibernationEventIterator } from '@orpc/standard-server';
5
5
 
@@ -132,7 +132,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
132
132
  if (output instanceof HibernationEventIterator) {
133
133
  return output;
134
134
  }
135
- return mapEventIterator(
135
+ return overlayProxy(output, mapEventIterator(
136
136
  asyncIteratorWithSpan(
137
137
  { name: "consume_event_iterator_output", signal: callerOptions?.signal },
138
138
  output
@@ -141,7 +141,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
141
141
  value: (v) => v,
142
142
  error: (e) => validateError(e)
143
143
  }
144
- );
144
+ ));
145
145
  }
146
146
  return output;
147
147
  } catch (e) {
@@ -1,5 +1,5 @@
1
- import { C as Context } from './server.B4BGqy3Y.js';
2
- import { b as StandardHandleOptions } from './server.DPIFWpxG.js';
1
+ import { C as Context } from './server.qKsRrdxW.js';
2
+ import { b as StandardHandleOptions } from './server.7cEtMB30.js';
3
3
 
4
4
  type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
5
5
  context?: T;
@@ -3,6 +3,9 @@ import { ORPCError, fallbackContractConfig } from '@orpc/contract';
3
3
  const STRICT_GET_METHOD_PLUGIN_IS_GET_METHOD_CONTEXT_SYMBOL = Symbol("STRICT_GET_METHOD_PLUGIN_IS_GET_METHOD_CONTEXT");
4
4
  class StrictGetMethodPlugin {
5
5
  error;
6
+ /**
7
+ * make sure execute before batch plugin to get real method
8
+ */
6
9
  order = 7e6;
7
10
  constructor(options = {}) {
8
11
  this.error = options.error ?? new ORPCError("METHOD_NOT_SUPPORTED");