@orpc/server 0.0.0-next.eae6003 → 0.0.0-next.eaec0b2

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 (66) hide show
  1. package/README.md +20 -17
  2. package/dist/adapters/aws-lambda/index.d.mts +46 -0
  3. package/dist/adapters/aws-lambda/index.d.ts +46 -0
  4. package/dist/adapters/aws-lambda/index.mjs +42 -0
  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 +16 -20
  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 +11 -17
  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 +59 -13
  15. package/dist/adapters/fetch/index.d.ts +59 -13
  16. package/dist/adapters/fetch/index.mjs +75 -5
  17. package/dist/adapters/message-port/index.d.mts +57 -0
  18. package/dist/adapters/message-port/index.d.ts +57 -0
  19. package/dist/adapters/message-port/index.mjs +55 -0
  20. package/dist/adapters/node/index.d.mts +36 -14
  21. package/dist/adapters/node/index.d.ts +36 -14
  22. package/dist/adapters/node/index.mjs +71 -14
  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 +41 -12
  30. package/dist/adapters/websocket/index.d.ts +41 -12
  31. package/dist/adapters/websocket/index.mjs +49 -20
  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 -14
  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 +44 -0
  39. package/dist/hibernation/index.d.ts +44 -0
  40. package/dist/hibernation/index.mjs +65 -0
  41. package/dist/index.d.mts +116 -142
  42. package/dist/index.d.ts +116 -142
  43. package/dist/index.mjs +52 -34
  44. package/dist/plugins/index.d.mts +67 -19
  45. package/dist/plugins/index.d.ts +67 -19
  46. package/dist/plugins/index.mjs +137 -60
  47. package/dist/shared/{server.YZzrREz9.d.ts → server.7cEtMB30.d.ts} +8 -8
  48. package/dist/shared/server.B8gYOD5g.d.mts +12 -0
  49. package/dist/shared/{server.eWLxY3lq.d.mts → server.BqadksTP.d.mts} +8 -8
  50. package/dist/shared/{server.4FnxLwwr.mjs → server.Bxx6tqNe.mjs} +75 -42
  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.BVwwTHyO.mjs → server.DZ5BIITo.mjs} +1 -1
  55. package/dist/shared/{server.DG7Tamti.mjs → server.Ds4HPpvH.mjs} +116 -74
  56. package/dist/shared/server.EfTOZ2Q7.d.ts +12 -0
  57. package/dist/shared/{server.BW-nUGgA.mjs → server.TEVCLCFC.mjs} +3 -0
  58. package/dist/shared/server.UVMTOWrk.mjs +26 -0
  59. package/dist/shared/{server.DPWk5pjW.d.mts → server.qKsRrdxW.d.mts} +18 -17
  60. package/dist/shared/{server.DPWk5pjW.d.ts → server.qKsRrdxW.d.ts} +18 -17
  61. package/dist/shared/server.yoEB3Fx4.d.ts +32 -0
  62. package/package.json +51 -15
  63. package/dist/shared/server.BRoxSiSC.d.mts +0 -12
  64. package/dist/shared/server.BjiJH9Vo.d.ts +0 -10
  65. package/dist/shared/server.Cy1vfSiG.d.ts +0 -12
  66. package/dist/shared/server.QUe9N8P4.d.mts +0 -10
package/dist/index.mjs CHANGED
@@ -1,10 +1,11 @@
1
- import { mergeErrorMap, mergeMeta, mergeRoute, mergePrefix, mergeTags, isContractProcedure, getContractRouter } 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, i as isProcedure, d as isLazy, f as createAssertedLazyProcedure, g as getRouter } from './shared/server.DG7Tamti.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, u as unlazy, x as unlazyRouter, v as validateORPCError } from './shared/server.DG7Tamti.mjs';
1
+ import { mergeErrorMap, mergeMeta, mergeRoute, mergePrefix, mergeTags, isContractProcedure, getContractRouter, fallbackContractConfig } from '@orpc/contract';
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
- export { 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';
8
9
  export { getEventMeta, withEventMeta } from '@orpc/standard-server';
9
10
 
10
11
  const DEFAULT_CONFIG = {
@@ -20,7 +21,7 @@ function fallbackConfig(key, value) {
20
21
  }
21
22
 
22
23
  function decorateMiddleware(middleware) {
23
- const decorated = (...args) => middleware(...args);
24
+ const decorated = ((...args) => middleware(...args));
24
25
  decorated.mapInput = (mapInput) => {
25
26
  const mapped = decorateMiddleware(
26
27
  (options, input, ...rest) => middleware(options, mapInput(input), ...rest)
@@ -53,6 +54,9 @@ function createActionableClient(client) {
53
54
  if (error instanceof Error && "digest" in error && typeof error.digest === "string" && error.digest.startsWith("NEXT_")) {
54
55
  throw error;
55
56
  }
57
+ if (error instanceof Response && "options" in error && isObject(error.options) || isObject(error) && error.isNotFound === true) {
58
+ throw error;
59
+ }
56
60
  return [toORPCError(error).toJSON(), void 0];
57
61
  }
58
62
  };
@@ -64,7 +68,7 @@ class DecoratedProcedure extends Procedure {
64
68
  * Adds type-safe custom errors.
65
69
  * The provided errors are spared-merged with any existing errors.
66
70
  *
67
- * @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}
68
72
  */
69
73
  errors(errors) {
70
74
  return new DecoratedProcedure({
@@ -76,7 +80,7 @@ class DecoratedProcedure extends Procedure {
76
80
  * Sets or updates the metadata.
77
81
  * The provided metadata is spared-merged with any existing metadata.
78
82
  *
79
- * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
83
+ * @see {@link https://orpc.dev/docs/metadata Metadata Docs}
80
84
  */
81
85
  meta(meta) {
82
86
  return new DecoratedProcedure({
@@ -89,8 +93,8 @@ class DecoratedProcedure extends Procedure {
89
93
  * The provided route is spared-merged with any existing route.
90
94
  * This option is typically relevant when integrating with OpenAPI.
91
95
  *
92
- * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
93
- * @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}
94
98
  */
95
99
  route(route) {
96
100
  return new DecoratedProcedure({
@@ -108,7 +112,7 @@ class DecoratedProcedure extends Procedure {
108
112
  /**
109
113
  * Make this procedure callable (works like a function while still being a procedure).
110
114
  *
111
- * @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}
112
116
  */
113
117
  callable(...rest) {
114
118
  const client = createProcedureClient(this, ...rest);
@@ -124,7 +128,7 @@ class DecoratedProcedure extends Procedure {
124
128
  /**
125
129
  * Make this procedure compatible with server action.
126
130
  *
127
- * @see {@link https://orpc.unnoq.com/docs/server-action Server Action Docs}
131
+ * @see {@link https://orpc.dev/docs/server-action Server Action Docs}
128
132
  */
129
133
  actionable(...rest) {
130
134
  const action = createActionableClient(createProcedureClient(this, ...rest));
@@ -150,8 +154,8 @@ class Builder {
150
154
  /**
151
155
  * Sets or overrides the config.
152
156
  *
153
- * @see {@link https://orpc.unnoq.com/docs/lifecycle#middlewares-order Middlewares Order Docs}
154
- * @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}
155
159
  */
156
160
  $config(config) {
157
161
  const inputValidationCount = this["~orpc"].inputValidationIndex - fallbackConfig("initialInputValidationIndex", this["~orpc"].config.initialInputValidationIndex);
@@ -167,7 +171,7 @@ class Builder {
167
171
  /**
168
172
  * Set or override the initial context.
169
173
  *
170
- * @see {@link https://orpc.unnoq.com/docs/context Context Docs}
174
+ * @see {@link https://orpc.dev/docs/context Context Docs}
171
175
  */
172
176
  $context() {
173
177
  return new Builder({
@@ -180,7 +184,7 @@ class Builder {
180
184
  /**
181
185
  * Sets or overrides the initial meta.
182
186
  *
183
- * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
187
+ * @see {@link https://orpc.dev/docs/metadata Metadata Docs}
184
188
  */
185
189
  $meta(initialMeta) {
186
190
  return new Builder({
@@ -192,8 +196,8 @@ class Builder {
192
196
  * Sets or overrides the initial route.
193
197
  * This option is typically relevant when integrating with OpenAPI.
194
198
  *
195
- * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
196
- * @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}
197
201
  */
198
202
  $route(initialRoute) {
199
203
  return new Builder({
@@ -204,7 +208,7 @@ class Builder {
204
208
  /**
205
209
  * Sets or overrides the initial input schema.
206
210
  *
207
- * @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}
208
212
  */
209
213
  $input(initialInputSchema) {
210
214
  return new Builder({
@@ -215,7 +219,7 @@ class Builder {
215
219
  /**
216
220
  * Creates a middleware.
217
221
  *
218
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
222
+ * @see {@link https://orpc.dev/docs/middleware Middleware Docs}
219
223
  */
220
224
  middleware(middleware) {
221
225
  return decorateMiddleware(middleware);
@@ -224,7 +228,7 @@ class Builder {
224
228
  * Adds type-safe custom errors.
225
229
  * The provided errors are spared-merged with any existing errors.
226
230
  *
227
- * @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}
228
232
  */
229
233
  errors(errors) {
230
234
  return new Builder({
@@ -243,7 +247,7 @@ class Builder {
243
247
  * Sets or updates the metadata.
244
248
  * The provided metadata is spared-merged with any existing metadata.
245
249
  *
246
- * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
250
+ * @see {@link https://orpc.dev/docs/metadata Metadata Docs}
247
251
  */
248
252
  meta(meta) {
249
253
  return new Builder({
@@ -256,8 +260,8 @@ class Builder {
256
260
  * The provided route is spared-merged with any existing route.
257
261
  * This option is typically relevant when integrating with OpenAPI.
258
262
  *
259
- * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
260
- * @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}
261
265
  */
262
266
  route(route) {
263
267
  return new Builder({
@@ -268,7 +272,7 @@ class Builder {
268
272
  /**
269
273
  * Defines the input validation schema.
270
274
  *
271
- * @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}
272
276
  */
273
277
  input(schema) {
274
278
  return new Builder({
@@ -280,7 +284,7 @@ class Builder {
280
284
  /**
281
285
  * Defines the output validation schema.
282
286
  *
283
- * @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}
284
288
  */
285
289
  output(schema) {
286
290
  return new Builder({
@@ -292,7 +296,7 @@ class Builder {
292
296
  /**
293
297
  * Defines the handler of the procedure.
294
298
  *
295
- * @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
299
+ * @see {@link https://orpc.dev/docs/procedure Procedure Docs}
296
300
  */
297
301
  handler(handler) {
298
302
  return new DecoratedProcedure({
@@ -306,7 +310,7 @@ class Builder {
306
310
  *
307
311
  * @note This option does not affect procedures that do not define a path in their route definition.
308
312
  *
309
- * @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}
310
314
  */
311
315
  prefix(prefix) {
312
316
  return new Builder({
@@ -318,7 +322,7 @@ class Builder {
318
322
  * Adds tags to all procedures in the router.
319
323
  * This helpful when you want to group procedures together in the OpenAPI specification.
320
324
  *
321
- * @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}
322
326
  */
323
327
  tag(...tags) {
324
328
  return new Builder({
@@ -329,7 +333,7 @@ class Builder {
329
333
  /**
330
334
  * Applies all of the previously defined options to the specified router.
331
335
  *
332
- * @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}
333
337
  */
334
338
  router(router) {
335
339
  return enhanceRouter(router, this["~orpc"]);
@@ -338,7 +342,7 @@ class Builder {
338
342
  * Create a lazy router
339
343
  * And applies all of the previously defined options to the specified router.
340
344
  *
341
- * @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}
342
346
  */
343
347
  lazy(loader) {
344
348
  return enhanceRouter(lazy(loader), this["~orpc"]);
@@ -447,12 +451,26 @@ function implement(contract, config = {}) {
447
451
  return impl;
448
452
  }
449
453
 
454
+ function inferRPCMethodFromRouter(router) {
455
+ return async (_, path) => {
456
+ const { default: procedure } = await unlazy(getRouter(router, path));
457
+ if (!isProcedure(procedure)) {
458
+ throw new Error(
459
+ `[inferRPCMethodFromRouter] No valid procedure found at path "${path.join(".")}". This may happen when the router is not properly configured.`
460
+ );
461
+ }
462
+ const method = fallbackContractConfig("defaultMethod", procedure["~orpc"].route.method);
463
+ return method === "HEAD" ? "GET" : method;
464
+ };
465
+ }
466
+
450
467
  function createRouterClient(router, ...rest) {
468
+ const options = resolveMaybeOptionalOptions(rest);
451
469
  if (isProcedure(router)) {
452
- const caller = createProcedureClient(router, ...rest);
470
+ const caller = createProcedureClient(router, options);
453
471
  return caller;
454
472
  }
455
- const procedureCaller = isLazy(router) ? createProcedureClient(createAssertedLazyProcedure(router), ...rest) : {};
473
+ const procedureCaller = isLazy(router) ? createProcedureClient(createAssertedLazyProcedure(router), options) : {};
456
474
  const recursive = new Proxy(procedureCaller, {
457
475
  get(target, key) {
458
476
  if (typeof key !== "string") {
@@ -471,4 +489,4 @@ function createRouterClient(router, ...rest) {
471
489
  return recursive;
472
490
  }
473
491
 
474
- export { Builder, DecoratedProcedure, Procedure, addMiddleware, createActionableClient, createAssertedLazyProcedure, createProcedureClient, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getRouter, implement, implementerInternal, isLazy, isProcedure, lazy, os, setHiddenRouterContract };
492
+ export { Builder, DecoratedProcedure, Procedure, addMiddleware, createActionableClient, createAssertedLazyProcedure, createProcedureClient, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getRouter, implement, implementerInternal, inferRPCMethodFromRouter, isLazy, isProcedure, lazy, os, setHiddenRouterContract, unlazy };
@@ -1,8 +1,8 @@
1
- import { Value } 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.eWLxY3lq.mjs';
5
- import { C as Context, F as ProcedureClientInterceptorOptions } from '../shared/server.DPWk5pjW.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
 
@@ -12,7 +12,7 @@ interface BatchHandlerOptions<T extends Context> {
12
12
  *
13
13
  * @default 10
14
14
  */
15
- maxSize?: Value<number, [StandardHandlerInterceptorOptions<T>]>;
15
+ maxSize?: Value<Promisable<number>, [StandardHandlerInterceptorOptions<T>]>;
16
16
  /**
17
17
  * Map the request before processing it.
18
18
  *
@@ -24,19 +24,19 @@ interface BatchHandlerOptions<T extends Context> {
24
24
  *
25
25
  * @default 207
26
26
  */
27
- successStatus?: Value<number, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
27
+ successStatus?: Value<Promisable<number>, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
28
28
  /**
29
29
  * success batch response headers.
30
30
  *
31
31
  * @default {}
32
32
  */
33
- headers?: Value<StandardHeaders, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
33
+ headers?: Value<Promisable<StandardHeaders>, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
34
34
  }
35
35
  /**
36
- * The Batch Request/Response Plugin allows you to combine multiple requests and responses into a single batch,
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-request-response Batch Request/Response 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;
@@ -49,8 +49,8 @@ declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPl
49
49
  }
50
50
 
51
51
  interface CORSOptions<T extends Context> {
52
- origin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
53
- timingOrigin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
52
+ origin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
53
+ timingOrigin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
54
54
  allowMethods?: readonly string[];
55
55
  allowHeaders?: readonly string[];
56
56
  maxAge?: number;
@@ -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,33 +89,65 @@ 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.
88
133
  *
89
134
  * @default 'x-csrf-token'
90
135
  */
91
- headerName?: Value<string, [options: StandardHandlerInterceptorOptions<T>]>;
136
+ headerName?: Value<Promisable<string>, [options: StandardHandlerInterceptorOptions<T>]>;
92
137
  /**
93
138
  * The value of the header to check.
94
139
  *
95
140
  * @default 'orpc'
96
141
  *
97
142
  */
98
- headerValue?: Value<string, [options: StandardHandlerInterceptorOptions<T>]>;
143
+ headerValue?: Value<Promisable<string>, [options: StandardHandlerInterceptorOptions<T>]>;
99
144
  /**
100
145
  * Exclude a procedure from the plugin.
101
146
  *
102
147
  * @default false
103
148
  *
104
149
  */
105
- exclude?: Value<boolean, [options: ProcedureClientInterceptorOptions<T, Record<never, never>, Meta>]>;
150
+ exclude?: Value<Promisable<boolean>, [options: ProcedureClientInterceptorOptions<T, Record<never, never>, Meta>]>;
106
151
  /**
107
152
  * The error thrown when the CSRF token is invalid.
108
153
  *
@@ -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 } 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.YZzrREz9.js';
5
- import { C as Context, F as ProcedureClientInterceptorOptions } from '../shared/server.DPWk5pjW.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
 
@@ -12,7 +12,7 @@ interface BatchHandlerOptions<T extends Context> {
12
12
  *
13
13
  * @default 10
14
14
  */
15
- maxSize?: Value<number, [StandardHandlerInterceptorOptions<T>]>;
15
+ maxSize?: Value<Promisable<number>, [StandardHandlerInterceptorOptions<T>]>;
16
16
  /**
17
17
  * Map the request before processing it.
18
18
  *
@@ -24,19 +24,19 @@ interface BatchHandlerOptions<T extends Context> {
24
24
  *
25
25
  * @default 207
26
26
  */
27
- successStatus?: Value<number, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
27
+ successStatus?: Value<Promisable<number>, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
28
28
  /**
29
29
  * success batch response headers.
30
30
  *
31
31
  * @default {}
32
32
  */
33
- headers?: Value<StandardHeaders, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
33
+ headers?: Value<Promisable<StandardHeaders>, [responses: Promise<BatchResponseBodyItem>[], batchOptions: StandardHandlerInterceptorOptions<T>]>;
34
34
  }
35
35
  /**
36
- * The Batch Request/Response Plugin allows you to combine multiple requests and responses into a single batch,
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-request-response Batch Request/Response 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;
@@ -49,8 +49,8 @@ declare class BatchHandlerPlugin<T extends Context> implements StandardHandlerPl
49
49
  }
50
50
 
51
51
  interface CORSOptions<T extends Context> {
52
- origin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
53
- timingOrigin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
52
+ origin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
53
+ timingOrigin?: Value<Promisable<string | readonly string[] | null | undefined>, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
54
54
  allowMethods?: readonly string[];
55
55
  allowHeaders?: readonly string[];
56
56
  maxAge?: number;
@@ -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,33 +89,65 @@ 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.
88
133
  *
89
134
  * @default 'x-csrf-token'
90
135
  */
91
- headerName?: Value<string, [options: StandardHandlerInterceptorOptions<T>]>;
136
+ headerName?: Value<Promisable<string>, [options: StandardHandlerInterceptorOptions<T>]>;
92
137
  /**
93
138
  * The value of the header to check.
94
139
  *
95
140
  * @default 'orpc'
96
141
  *
97
142
  */
98
- headerValue?: Value<string, [options: StandardHandlerInterceptorOptions<T>]>;
143
+ headerValue?: Value<Promisable<string>, [options: StandardHandlerInterceptorOptions<T>]>;
99
144
  /**
100
145
  * Exclude a procedure from the plugin.
101
146
  *
102
147
  * @default false
103
148
  *
104
149
  */
105
- exclude?: Value<boolean, [options: ProcedureClientInterceptorOptions<T, Record<never, never>, Meta>]>;
150
+ exclude?: Value<Promisable<boolean>, [options: ProcedureClientInterceptorOptions<T, Record<never, never>, Meta>]>;
106
151
  /**
107
152
  * The error thrown when the CSRF token is invalid.
108
153
  *
@@ -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 };