@orpc/server 0.0.0-next.eea495c → 0.0.0-next.f01f7b1

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 +15 -11
  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 +36 -0
  6. package/dist/adapters/bun-ws/index.d.ts +36 -0
  7. package/dist/adapters/bun-ws/index.mjs +47 -0
  8. package/dist/adapters/crossws/index.d.mts +33 -0
  9. package/dist/adapters/crossws/index.d.ts +33 -0
  10. package/dist/adapters/crossws/index.mjs +45 -0
  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 +66 -12
  15. package/dist/adapters/fetch/index.d.ts +66 -12
  16. package/dist/adapters/fetch/index.mjs +80 -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 +43 -13
  21. package/dist/adapters/node/index.d.ts +43 -13
  22. package/dist/adapters/node/index.mjs +76 -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 +5 -5
  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 +56 -0
  30. package/dist/adapters/websocket/index.d.ts +56 -0
  31. package/dist/adapters/websocket/index.mjs +67 -0
  32. package/dist/adapters/ws/index.d.mts +31 -0
  33. package/dist/adapters/ws/index.d.ts +31 -0
  34. package/dist/adapters/ws/index.mjs +37 -0
  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 +55 -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 +142 -66
  47. package/dist/shared/{server.D5fBlF9j.d.ts → server.7cEtMB30.d.ts} +11 -11
  48. package/dist/shared/server.B8gYOD5g.d.mts +12 -0
  49. package/dist/shared/{server.DY7OKEoj.d.mts → server.BqadksTP.d.mts} +11 -11
  50. package/dist/shared/{server.qf03T-Xn.mjs → server.Bxx6tqNe.mjs} +80 -51
  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 +83 -9
  63. package/dist/shared/server.CN0534_m.d.mts +0 -18
  64. package/dist/shared/server.CjlA3NKP.d.ts +0 -10
  65. package/dist/shared/server.CuD15qZB.d.ts +0 -18
  66. package/dist/shared/server.DjgtLwKi.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)
@@ -50,6 +51,12 @@ function createActionableClient(client) {
50
51
  try {
51
52
  return [null, await client(input)];
52
53
  } catch (error) {
54
+ if (error instanceof Error && "digest" in error && typeof error.digest === "string" && error.digest.startsWith("NEXT_")) {
55
+ throw error;
56
+ }
57
+ if (error instanceof Response && "options" in error && isObject(error.options) || isObject(error) && error.isNotFound === true) {
58
+ throw error;
59
+ }
53
60
  return [toORPCError(error).toJSON(), void 0];
54
61
  }
55
62
  };
@@ -61,7 +68,7 @@ class DecoratedProcedure extends Procedure {
61
68
  * Adds type-safe custom errors.
62
69
  * The provided errors are spared-merged with any existing errors.
63
70
  *
64
- * @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}
65
72
  */
66
73
  errors(errors) {
67
74
  return new DecoratedProcedure({
@@ -73,7 +80,7 @@ class DecoratedProcedure extends Procedure {
73
80
  * Sets or updates the metadata.
74
81
  * The provided metadata is spared-merged with any existing metadata.
75
82
  *
76
- * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
83
+ * @see {@link https://orpc.dev/docs/metadata Metadata Docs}
77
84
  */
78
85
  meta(meta) {
79
86
  return new DecoratedProcedure({
@@ -86,8 +93,8 @@ class DecoratedProcedure extends Procedure {
86
93
  * The provided route is spared-merged with any existing route.
87
94
  * This option is typically relevant when integrating with OpenAPI.
88
95
  *
89
- * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
90
- * @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}
91
98
  */
92
99
  route(route) {
93
100
  return new DecoratedProcedure({
@@ -105,7 +112,7 @@ class DecoratedProcedure extends Procedure {
105
112
  /**
106
113
  * Make this procedure callable (works like a function while still being a procedure).
107
114
  *
108
- * @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}
109
116
  */
110
117
  callable(...rest) {
111
118
  const client = createProcedureClient(this, ...rest);
@@ -121,7 +128,7 @@ class DecoratedProcedure extends Procedure {
121
128
  /**
122
129
  * Make this procedure compatible with server action.
123
130
  *
124
- * @see {@link https://orpc.unnoq.com/docs/server-action Server Action Docs}
131
+ * @see {@link https://orpc.dev/docs/server-action Server Action Docs}
125
132
  */
126
133
  actionable(...rest) {
127
134
  const action = createActionableClient(createProcedureClient(this, ...rest));
@@ -147,8 +154,8 @@ class Builder {
147
154
  /**
148
155
  * Sets or overrides the config.
149
156
  *
150
- * @see {@link https://orpc.unnoq.com/docs/lifecycle#middlewares-order Middlewares Order Docs}
151
- * @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}
152
159
  */
153
160
  $config(config) {
154
161
  const inputValidationCount = this["~orpc"].inputValidationIndex - fallbackConfig("initialInputValidationIndex", this["~orpc"].config.initialInputValidationIndex);
@@ -164,7 +171,7 @@ class Builder {
164
171
  /**
165
172
  * Set or override the initial context.
166
173
  *
167
- * @see {@link https://orpc.unnoq.com/docs/context Context Docs}
174
+ * @see {@link https://orpc.dev/docs/context Context Docs}
168
175
  */
169
176
  $context() {
170
177
  return new Builder({
@@ -177,7 +184,7 @@ class Builder {
177
184
  /**
178
185
  * Sets or overrides the initial meta.
179
186
  *
180
- * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
187
+ * @see {@link https://orpc.dev/docs/metadata Metadata Docs}
181
188
  */
182
189
  $meta(initialMeta) {
183
190
  return new Builder({
@@ -189,8 +196,8 @@ class Builder {
189
196
  * Sets or overrides the initial route.
190
197
  * This option is typically relevant when integrating with OpenAPI.
191
198
  *
192
- * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
193
- * @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}
194
201
  */
195
202
  $route(initialRoute) {
196
203
  return new Builder({
@@ -201,7 +208,7 @@ class Builder {
201
208
  /**
202
209
  * Sets or overrides the initial input schema.
203
210
  *
204
- * @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}
205
212
  */
206
213
  $input(initialInputSchema) {
207
214
  return new Builder({
@@ -212,7 +219,7 @@ class Builder {
212
219
  /**
213
220
  * Creates a middleware.
214
221
  *
215
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
222
+ * @see {@link https://orpc.dev/docs/middleware Middleware Docs}
216
223
  */
217
224
  middleware(middleware) {
218
225
  return decorateMiddleware(middleware);
@@ -221,7 +228,7 @@ class Builder {
221
228
  * Adds type-safe custom errors.
222
229
  * The provided errors are spared-merged with any existing errors.
223
230
  *
224
- * @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}
225
232
  */
226
233
  errors(errors) {
227
234
  return new Builder({
@@ -240,7 +247,7 @@ class Builder {
240
247
  * Sets or updates the metadata.
241
248
  * The provided metadata is spared-merged with any existing metadata.
242
249
  *
243
- * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
250
+ * @see {@link https://orpc.dev/docs/metadata Metadata Docs}
244
251
  */
245
252
  meta(meta) {
246
253
  return new Builder({
@@ -253,8 +260,8 @@ class Builder {
253
260
  * The provided route is spared-merged with any existing route.
254
261
  * This option is typically relevant when integrating with OpenAPI.
255
262
  *
256
- * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
257
- * @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}
258
265
  */
259
266
  route(route) {
260
267
  return new Builder({
@@ -265,7 +272,7 @@ class Builder {
265
272
  /**
266
273
  * Defines the input validation schema.
267
274
  *
268
- * @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}
269
276
  */
270
277
  input(schema) {
271
278
  return new Builder({
@@ -277,7 +284,7 @@ class Builder {
277
284
  /**
278
285
  * Defines the output validation schema.
279
286
  *
280
- * @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}
281
288
  */
282
289
  output(schema) {
283
290
  return new Builder({
@@ -289,7 +296,7 @@ class Builder {
289
296
  /**
290
297
  * Defines the handler of the procedure.
291
298
  *
292
- * @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
299
+ * @see {@link https://orpc.dev/docs/procedure Procedure Docs}
293
300
  */
294
301
  handler(handler) {
295
302
  return new DecoratedProcedure({
@@ -303,7 +310,7 @@ class Builder {
303
310
  *
304
311
  * @note This option does not affect procedures that do not define a path in their route definition.
305
312
  *
306
- * @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}
307
314
  */
308
315
  prefix(prefix) {
309
316
  return new Builder({
@@ -315,7 +322,7 @@ class Builder {
315
322
  * Adds tags to all procedures in the router.
316
323
  * This helpful when you want to group procedures together in the OpenAPI specification.
317
324
  *
318
- * @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}
319
326
  */
320
327
  tag(...tags) {
321
328
  return new Builder({
@@ -326,7 +333,7 @@ class Builder {
326
333
  /**
327
334
  * Applies all of the previously defined options to the specified router.
328
335
  *
329
- * @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}
330
337
  */
331
338
  router(router) {
332
339
  return enhanceRouter(router, this["~orpc"]);
@@ -335,7 +342,7 @@ class Builder {
335
342
  * Create a lazy router
336
343
  * And applies all of the previously defined options to the specified router.
337
344
  *
338
- * @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}
339
346
  */
340
347
  lazy(loader) {
341
348
  return enhanceRouter(lazy(loader), this["~orpc"]);
@@ -444,12 +451,26 @@ function implement(contract, config = {}) {
444
451
  return impl;
445
452
  }
446
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
+
447
467
  function createRouterClient(router, ...rest) {
468
+ const options = resolveMaybeOptionalOptions(rest);
448
469
  if (isProcedure(router)) {
449
- const caller = createProcedureClient(router, ...rest);
470
+ const caller = createProcedureClient(router, options);
450
471
  return caller;
451
472
  }
452
- const procedureCaller = isLazy(router) ? createProcedureClient(createAssertedLazyProcedure(router), ...rest) : {};
473
+ const procedureCaller = isLazy(router) ? createProcedureClient(createAssertedLazyProcedure(router), options) : {};
453
474
  const recursive = new Proxy(procedureCaller, {
454
475
  get(target, key) {
455
476
  if (typeof key !== "string") {
@@ -468,4 +489,4 @@ function createRouterClient(router, ...rest) {
468
489
  return recursive;
469
490
  }
470
491
 
471
- 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.DY7OKEoj.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.D5fBlF9j.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 };