@orpc/server 0.0.0-next.fc23c8d → 0.0.0-next.fc2dc8f

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 (65) hide show
  1. package/README.md +11 -6
  2. package/dist/adapters/aws-lambda/index.d.mts +9 -8
  3. package/dist/adapters/aws-lambda/index.d.ts +9 -8
  4. package/dist/adapters/aws-lambda/index.mjs +6 -5
  5. package/dist/adapters/bun-ws/index.d.mts +14 -13
  6. package/dist/adapters/bun-ws/index.d.ts +14 -13
  7. package/dist/adapters/bun-ws/index.mjs +17 -16
  8. package/dist/adapters/crossws/index.d.mts +10 -7
  9. package/dist/adapters/crossws/index.d.ts +10 -7
  10. package/dist/adapters/crossws/index.mjs +9 -10
  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 +57 -11
  15. package/dist/adapters/fetch/index.d.ts +57 -11
  16. package/dist/adapters/fetch/index.mjs +74 -4
  17. package/dist/adapters/message-port/index.d.mts +42 -13
  18. package/dist/adapters/message-port/index.d.ts +42 -13
  19. package/dist/adapters/message-port/index.mjs +32 -18
  20. package/dist/adapters/node/index.d.mts +34 -12
  21. package/dist/adapters/node/index.d.ts +34 -12
  22. package/dist/adapters/node/index.mjs +70 -13
  23. package/dist/adapters/standard/index.d.mts +8 -13
  24. package/dist/adapters/standard/index.d.ts +8 -13
  25. package/dist/adapters/standard/index.mjs +3 -2
  26. package/dist/adapters/standard-peer/index.d.mts +18 -0
  27. package/dist/adapters/standard-peer/index.d.ts +18 -0
  28. package/dist/adapters/standard-peer/index.mjs +7 -0
  29. package/dist/adapters/websocket/index.d.mts +20 -15
  30. package/dist/adapters/websocket/index.d.ts +20 -15
  31. package/dist/adapters/websocket/index.mjs +13 -15
  32. package/dist/adapters/ws/index.d.mts +13 -10
  33. package/dist/adapters/ws/index.d.ts +13 -10
  34. package/dist/adapters/ws/index.mjs +13 -15
  35. package/dist/helpers/index.d.mts +149 -0
  36. package/dist/helpers/index.d.ts +149 -0
  37. package/dist/helpers/index.mjs +198 -0
  38. package/dist/hibernation/index.d.mts +13 -13
  39. package/dist/hibernation/index.d.ts +13 -13
  40. package/dist/hibernation/index.mjs +8 -8
  41. package/dist/index.d.mts +105 -136
  42. package/dist/index.d.ts +105 -136
  43. package/dist/index.mjs +37 -33
  44. package/dist/plugins/index.d.mts +58 -10
  45. package/dist/plugins/index.d.ts +58 -10
  46. package/dist/plugins/index.mjs +134 -59
  47. package/dist/shared/{server.-ACo36I0.d.ts → server.7cEtMB30.d.ts} +3 -3
  48. package/dist/shared/server.B8gYOD5g.d.mts +12 -0
  49. package/dist/shared/{server.Dq8xr7PQ.d.mts → server.BqadksTP.d.mts} +3 -3
  50. package/dist/shared/{server.CB8Snncu.mjs → server.Bxx6tqNe.mjs} +74 -41
  51. package/dist/shared/server.C8_sRzQB.d.mts +42 -0
  52. package/dist/shared/server.ChUyt5-i.d.mts +32 -0
  53. package/dist/shared/server.ChyoA9XY.d.ts +42 -0
  54. package/dist/shared/{server.DLJzqnSX.mjs → server.Ds4HPpvH.mjs} +114 -73
  55. package/dist/shared/server.EfTOZ2Q7.d.ts +12 -0
  56. package/dist/shared/{server.BW-nUGgA.mjs → server.TEVCLCFC.mjs} +3 -0
  57. package/dist/shared/server.UVMTOWrk.mjs +26 -0
  58. package/dist/shared/{server.DD2C4ujN.d.mts → server.qKsRrdxW.d.mts} +14 -13
  59. package/dist/shared/{server.DD2C4ujN.d.ts → server.qKsRrdxW.d.ts} +14 -13
  60. package/dist/shared/server.yoEB3Fx4.d.ts +32 -0
  61. package/package.json +34 -13
  62. package/dist/shared/server.BPAWobQg.d.ts +0 -12
  63. package/dist/shared/server.Bd52nNaH.d.mts +0 -12
  64. package/dist/shared/server.BliFSTnG.d.mts +0 -10
  65. package/dist/shared/server.IG2MjhrD.d.ts +0 -10
package/dist/index.mjs CHANGED
@@ -1,11 +1,11 @@
1
1
  import { mergeErrorMap, mergeMeta, mergeRoute, mergePrefix, mergeTags, isContractProcedure, getContractRouter, fallbackContractConfig } from '@orpc/contract';
2
- export { ValidationError, eventIterator, type } 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.DLJzqnSX.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, w as resolveContractProcedures, t as traverseContractProcedures, x as unlazyRouter, v as validateORPCError } from './shared/server.DLJzqnSX.mjs';
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.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 { EventPublisher, onError, onFinish, onStart, onSuccess } 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 = {
@@ -21,7 +21,7 @@ function fallbackConfig(key, value) {
21
21
  }
22
22
 
23
23
  function decorateMiddleware(middleware) {
24
- const decorated = (...args) => middleware(...args);
24
+ const decorated = ((...args) => middleware(...args));
25
25
  decorated.mapInput = (mapInput) => {
26
26
  const mapped = decorateMiddleware(
27
27
  (options, input, ...rest) => middleware(options, mapInput(input), ...rest)
@@ -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/lifecycle#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"]);
@@ -462,11 +465,12 @@ function inferRPCMethodFromRouter(router) {
462
465
  }
463
466
 
464
467
  function createRouterClient(router, ...rest) {
468
+ const options = resolveMaybeOptionalOptions(rest);
465
469
  if (isProcedure(router)) {
466
- const caller = createProcedureClient(router, resolveMaybeOptionalOptions(rest));
470
+ const caller = createProcedureClient(router, options);
467
471
  return caller;
468
472
  }
469
- const procedureCaller = isLazy(router) ? createProcedureClient(createAssertedLazyProcedure(router), resolveMaybeOptionalOptions(rest)) : {};
473
+ const procedureCaller = isLazy(router) ? createProcedureClient(createAssertedLazyProcedure(router), options) : {};
470
474
  const recursive = new Proxy(procedureCaller, {
471
475
  get(target, key) {
472
476
  if (typeof key !== "string") {
@@ -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 { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.Dq8xr7PQ.mjs';
5
- import { C as Context, F as ProcedureClientInterceptorOptions } from '../shared/server.DD2C4ujN.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;
@@ -69,6 +69,19 @@ declare class CORSPlugin<T extends Context> implements StandardHandlerPlugin<T>
69
69
  init(options: StandardHandlerOptions<T>): void;
70
70
  }
71
71
 
72
+ interface RequestHeadersPluginContext {
73
+ reqHeaders?: Headers;
74
+ }
75
+ /**
76
+ * The Request Headers Plugin injects a `reqHeaders` instance into the context,
77
+ * allowing access to request headers in oRPC.
78
+ *
79
+ * @see {@link https://orpc.dev/docs/plugins/request-headers Request Headers Plugin Docs}
80
+ */
81
+ declare class RequestHeadersPlugin<T extends RequestHeadersPluginContext> implements StandardHandlerPlugin<T> {
82
+ init(options: StandardHandlerOptions<T>): void;
83
+ }
84
+
72
85
  interface ResponseHeadersPluginContext {
73
86
  resHeaders?: Headers;
74
87
  }
@@ -76,12 +89,44 @@ interface ResponseHeadersPluginContext {
76
89
  * The Response Headers Plugin allows you to set response headers in oRPC.
77
90
  * It injects a resHeaders instance into the context, enabling you to modify response headers easily.
78
91
  *
79
- * @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}
80
93
  */
81
94
  declare class ResponseHeadersPlugin<T extends ResponseHeadersPluginContext> implements StandardHandlerPlugin<T> {
82
95
  init(options: StandardHandlerOptions<T>): void;
83
96
  }
84
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
+
85
130
  interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
86
131
  /**
87
132
  * The name of the header to check.
@@ -118,7 +163,7 @@ interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
118
163
  * It helps ensure that requests to your procedures originate from JavaScript code,
119
164
  * not from other sources like standard HTML forms or direct browser navigation.
120
165
  *
121
- * @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}
122
167
  */
123
168
  declare class SimpleCsrfProtectionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
124
169
  private readonly headerName;
@@ -143,14 +188,17 @@ interface StrictGetMethodPluginOptions {
143
188
  * can be called using the HTTP GET method for RPC Protocol. This helps prevent certain types of
144
189
  * Cross-Site Request Forgery (CSRF) attacks.
145
190
  *
146
- * @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}
147
192
  */
148
193
  declare class StrictGetMethodPlugin<T extends Context> implements StandardHandlerPlugin<T> {
149
194
  private readonly error;
195
+ /**
196
+ * make sure execute before batch plugin to get real method
197
+ */
150
198
  order: number;
151
199
  constructor(options?: StrictGetMethodPluginOptions);
152
200
  init(options: StandardHandlerOptions<T>): void;
153
201
  }
154
202
 
155
- export { BatchHandlerPlugin, CORSPlugin, ResponseHeadersPlugin, SimpleCsrfProtectionHandlerPlugin, StrictGetMethodPlugin };
156
- export type { BatchHandlerOptions, CORSOptions, 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 { S as StandardHandlerInterceptorOptions, a as StandardHandlerPlugin, b as StandardHandlerOptions } from '../shared/server.-ACo36I0.js';
5
- import { C as Context, F as ProcedureClientInterceptorOptions } from '../shared/server.DD2C4ujN.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;
@@ -69,6 +69,19 @@ declare class CORSPlugin<T extends Context> implements StandardHandlerPlugin<T>
69
69
  init(options: StandardHandlerOptions<T>): void;
70
70
  }
71
71
 
72
+ interface RequestHeadersPluginContext {
73
+ reqHeaders?: Headers;
74
+ }
75
+ /**
76
+ * The Request Headers Plugin injects a `reqHeaders` instance into the context,
77
+ * allowing access to request headers in oRPC.
78
+ *
79
+ * @see {@link https://orpc.dev/docs/plugins/request-headers Request Headers Plugin Docs}
80
+ */
81
+ declare class RequestHeadersPlugin<T extends RequestHeadersPluginContext> implements StandardHandlerPlugin<T> {
82
+ init(options: StandardHandlerOptions<T>): void;
83
+ }
84
+
72
85
  interface ResponseHeadersPluginContext {
73
86
  resHeaders?: Headers;
74
87
  }
@@ -76,12 +89,44 @@ interface ResponseHeadersPluginContext {
76
89
  * The Response Headers Plugin allows you to set response headers in oRPC.
77
90
  * It injects a resHeaders instance into the context, enabling you to modify response headers easily.
78
91
  *
79
- * @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}
80
93
  */
81
94
  declare class ResponseHeadersPlugin<T extends ResponseHeadersPluginContext> implements StandardHandlerPlugin<T> {
82
95
  init(options: StandardHandlerOptions<T>): void;
83
96
  }
84
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
+
85
130
  interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
86
131
  /**
87
132
  * The name of the header to check.
@@ -118,7 +163,7 @@ interface SimpleCsrfProtectionHandlerPluginOptions<T extends Context> {
118
163
  * It helps ensure that requests to your procedures originate from JavaScript code,
119
164
  * not from other sources like standard HTML forms or direct browser navigation.
120
165
  *
121
- * @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}
122
167
  */
123
168
  declare class SimpleCsrfProtectionHandlerPlugin<T extends Context> implements StandardHandlerPlugin<T> {
124
169
  private readonly headerName;
@@ -143,14 +188,17 @@ interface StrictGetMethodPluginOptions {
143
188
  * can be called using the HTTP GET method for RPC Protocol. This helps prevent certain types of
144
189
  * Cross-Site Request Forgery (CSRF) attacks.
145
190
  *
146
- * @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}
147
192
  */
148
193
  declare class StrictGetMethodPlugin<T extends Context> implements StandardHandlerPlugin<T> {
149
194
  private readonly error;
195
+ /**
196
+ * make sure execute before batch plugin to get real method
197
+ */
150
198
  order: number;
151
199
  constructor(options?: StrictGetMethodPluginOptions);
152
200
  init(options: StandardHandlerOptions<T>): void;
153
201
  }
154
202
 
155
- export { BatchHandlerPlugin, CORSPlugin, ResponseHeadersPlugin, SimpleCsrfProtectionHandlerPlugin, StrictGetMethodPlugin };
156
- export type { BatchHandlerOptions, CORSOptions, ResponseHeadersPluginContext, SimpleCsrfProtectionHandlerPluginOptions, StrictGetMethodPluginOptions };
203
+ export { BatchHandlerPlugin, CORSPlugin, RequestHeadersPlugin, ResponseHeadersPlugin, SimpleCsrfProtectionHandlerPlugin, StrictGetMethodPlugin, experimental_RethrowHandlerPlugin };
204
+ export type { BatchHandlerOptions, CORSOptions, RequestHeadersPluginContext, ResponseHeadersPluginContext, SimpleCsrfProtectionHandlerPluginOptions, StrictGetMethodPluginOptions, experimental_RethrowHandlerPluginOptions };