@orpc/server 0.0.0-next.d17ef5e → 0.0.0-next.d1f8ea3

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 (34) hide show
  1. package/README.md +1 -0
  2. package/dist/adapters/fetch/index.d.mts +19 -7
  3. package/dist/adapters/fetch/index.d.ts +19 -7
  4. package/dist/adapters/fetch/index.mjs +4 -4
  5. package/dist/adapters/hono/index.d.mts +5 -5
  6. package/dist/adapters/hono/index.d.ts +5 -5
  7. package/dist/adapters/hono/index.mjs +4 -4
  8. package/dist/adapters/next/index.d.mts +5 -5
  9. package/dist/adapters/next/index.d.ts +5 -5
  10. package/dist/adapters/next/index.mjs +4 -4
  11. package/dist/adapters/node/index.d.mts +24 -12
  12. package/dist/adapters/node/index.d.ts +24 -12
  13. package/dist/adapters/node/index.mjs +39 -7
  14. package/dist/adapters/standard/index.d.mts +6 -6
  15. package/dist/adapters/standard/index.d.ts +6 -6
  16. package/dist/adapters/standard/index.mjs +3 -2
  17. package/dist/index.d.mts +32 -18
  18. package/dist/index.d.ts +32 -18
  19. package/dist/index.mjs +27 -6
  20. package/dist/plugins/index.d.mts +3 -3
  21. package/dist/plugins/index.d.ts +3 -3
  22. package/dist/plugins/index.mjs +9 -4
  23. package/dist/shared/{server.BG5ftPWa.d.ts → server.BMB1RpPJ.d.ts} +2 -2
  24. package/dist/shared/{server.DJqfB27m.d.mts → server.BUBtakoQ.d.mts} +7 -7
  25. package/dist/shared/{server.CIbpOMZX.d.mts → server.CCwHyrSs.d.mts} +2 -2
  26. package/dist/shared/{server.MZvbGc3n.d.mts → server.CYBq7eu_.d.mts} +7 -7
  27. package/dist/shared/{server.MZvbGc3n.d.ts → server.CYBq7eu_.d.ts} +7 -7
  28. package/dist/shared/{server.C-CCcROC.d.mts → server.D0tJ5s6a.d.mts} +2 -2
  29. package/dist/shared/{server.23VRZIfj.d.ts → server.DRYXuxQn.d.ts} +7 -7
  30. package/dist/shared/{server.CVNC_Jz8.mjs → server.Dfx1jV-K.mjs} +8 -4
  31. package/dist/shared/{server.DCcCuA52.d.ts → server.DtZEvFhf.d.ts} +2 -2
  32. package/dist/shared/{server.CTt4UYhI.mjs → server.T5WmDoWQ.mjs} +49 -2
  33. package/dist/shared/{server.BtxZnWJ9.mjs → server.e3W6AG3-.mjs} +3 -7
  34. package/package.json +7 -7
package/README.md CHANGED
@@ -53,6 +53,7 @@ You can find the full documentation [here](https://orpc.unnoq.com).
53
53
  - [@orpc/contract](https://www.npmjs.com/package/@orpc/contract): Build your API contract.
54
54
  - [@orpc/server](https://www.npmjs.com/package/@orpc/server): Build your API or implement API contract.
55
55
  - [@orpc/client](https://www.npmjs.com/package/@orpc/client): Consume your API on the client with type-safety.
56
+ - [@orpc/react](https://www.npmjs.com/package/@orpc/react): Utilities for integrating oRPC with React and React Server Actions.
56
57
  - [@orpc/react-query](https://www.npmjs.com/package/@orpc/react-query): Integration with [React Query](https://tanstack.com/query/latest/docs/framework/react/overview).
57
58
  - [@orpc/vue-query](https://www.npmjs.com/package/@orpc/vue-query): Integration with [Vue Query](https://tanstack.com/query/latest/docs/framework/vue/overview).
58
59
  - [@orpc/solid-query](https://www.npmjs.com/package/@orpc/solid-query): Integration with [Solid Query](https://tanstack.com/query/latest/docs/framework/solid/overview).
@@ -1,9 +1,9 @@
1
- import { C as Context, R as Router } from '../../shared/server.MZvbGc3n.mjs';
2
- import { c as StandardHandlerPlugin, S as StandardHandleOptions, i as StandardHandler } from '../../shared/server.DJqfB27m.mjs';
3
- import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
4
- import { F as FriendlyStandardHandleOptions } from '../../shared/server.C-CCcROC.mjs';
1
+ import { C as Context, R as Router } from '../../shared/server.CYBq7eu_.mjs';
2
+ import { Interceptor, ThrowableError, MaybeOptionalOptions } from '@orpc/shared';
3
+ import { c as StandardHandlerPlugin, S as StandardHandleOptions, i as StandardHandler } from '../../shared/server.BUBtakoQ.mjs';
4
+ import { F as FriendlyStandardHandleOptions } from '../../shared/server.D0tJ5s6a.mjs';
5
5
  import { ToFetchResponseOptions } from '@orpc/standard-server-fetch';
6
- import { S as StandardRPCHandlerOptions } from '../../shared/server.CIbpOMZX.mjs';
6
+ import { S as StandardRPCHandlerOptions } from '../../shared/server.CCwHyrSs.mjs';
7
7
  import '@orpc/client';
8
8
  import '@orpc/contract';
9
9
  import '@orpc/standard-server';
@@ -24,7 +24,7 @@ interface FetchHandlerInterceptorOptions<T extends Context> extends StandardHand
24
24
  toFetchResponseOptions: ToFetchResponseOptions;
25
25
  }
26
26
  interface FetchHandlerOptions<T extends Context> extends ToFetchResponseOptions {
27
- adapterInterceptors?: Interceptor<FetchHandlerInterceptorOptions<T>, FetchHandleResult, unknown>[];
27
+ adapterInterceptors?: Interceptor<FetchHandlerInterceptorOptions<T>, FetchHandleResult, ThrowableError>[];
28
28
  plugins?: FetchHandlerPlugin<T>[];
29
29
  }
30
30
  declare class FetchHandler<T extends Context> {
@@ -35,8 +35,20 @@ declare class FetchHandler<T extends Context> {
35
35
  handle(request: Request, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<T>>): Promise<FetchHandleResult>;
36
36
  }
37
37
 
38
+ interface BodyLimitPluginOptions {
39
+ /**
40
+ * The maximum size of the body in bytes.
41
+ */
42
+ maxBodySize: number;
43
+ }
44
+ declare class BodyLimitPlugin<T extends Context> implements FetchHandlerPlugin<T> {
45
+ private readonly maxBodySize;
46
+ constructor(options: BodyLimitPluginOptions);
47
+ initRuntimeAdapter(options: FetchHandlerOptions<T>): void;
48
+ }
49
+
38
50
  declare class RPCHandler<T extends Context> extends FetchHandler<T> {
39
51
  constructor(router: Router<any, T>, options?: NoInfer<FetchHandlerOptions<T> & StandardRPCHandlerOptions<T>>);
40
52
  }
41
53
 
42
- export { type FetchHandleResult, FetchHandler, type FetchHandlerInterceptorOptions, type FetchHandlerOptions, type FetchHandlerPlugin, RPCHandler };
54
+ export { BodyLimitPlugin, type BodyLimitPluginOptions, type FetchHandleResult, FetchHandler, type FetchHandlerInterceptorOptions, type FetchHandlerOptions, type FetchHandlerPlugin, RPCHandler };
@@ -1,9 +1,9 @@
1
- import { C as Context, R as Router } from '../../shared/server.MZvbGc3n.js';
2
- import { c as StandardHandlerPlugin, S as StandardHandleOptions, i as StandardHandler } from '../../shared/server.23VRZIfj.js';
3
- import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
4
- import { F as FriendlyStandardHandleOptions } from '../../shared/server.BG5ftPWa.js';
1
+ import { C as Context, R as Router } from '../../shared/server.CYBq7eu_.js';
2
+ import { Interceptor, ThrowableError, MaybeOptionalOptions } from '@orpc/shared';
3
+ import { c as StandardHandlerPlugin, S as StandardHandleOptions, i as StandardHandler } from '../../shared/server.DRYXuxQn.js';
4
+ import { F as FriendlyStandardHandleOptions } from '../../shared/server.BMB1RpPJ.js';
5
5
  import { ToFetchResponseOptions } from '@orpc/standard-server-fetch';
6
- import { S as StandardRPCHandlerOptions } from '../../shared/server.DCcCuA52.js';
6
+ import { S as StandardRPCHandlerOptions } from '../../shared/server.DtZEvFhf.js';
7
7
  import '@orpc/client';
8
8
  import '@orpc/contract';
9
9
  import '@orpc/standard-server';
@@ -24,7 +24,7 @@ interface FetchHandlerInterceptorOptions<T extends Context> extends StandardHand
24
24
  toFetchResponseOptions: ToFetchResponseOptions;
25
25
  }
26
26
  interface FetchHandlerOptions<T extends Context> extends ToFetchResponseOptions {
27
- adapterInterceptors?: Interceptor<FetchHandlerInterceptorOptions<T>, FetchHandleResult, unknown>[];
27
+ adapterInterceptors?: Interceptor<FetchHandlerInterceptorOptions<T>, FetchHandleResult, ThrowableError>[];
28
28
  plugins?: FetchHandlerPlugin<T>[];
29
29
  }
30
30
  declare class FetchHandler<T extends Context> {
@@ -35,8 +35,20 @@ declare class FetchHandler<T extends Context> {
35
35
  handle(request: Request, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<T>>): Promise<FetchHandleResult>;
36
36
  }
37
37
 
38
+ interface BodyLimitPluginOptions {
39
+ /**
40
+ * The maximum size of the body in bytes.
41
+ */
42
+ maxBodySize: number;
43
+ }
44
+ declare class BodyLimitPlugin<T extends Context> implements FetchHandlerPlugin<T> {
45
+ private readonly maxBodySize;
46
+ constructor(options: BodyLimitPluginOptions);
47
+ initRuntimeAdapter(options: FetchHandlerOptions<T>): void;
48
+ }
49
+
38
50
  declare class RPCHandler<T extends Context> extends FetchHandler<T> {
39
51
  constructor(router: Router<any, T>, options?: NoInfer<FetchHandlerOptions<T> & StandardRPCHandlerOptions<T>>);
40
52
  }
41
53
 
42
- export { type FetchHandleResult, FetchHandler, type FetchHandlerInterceptorOptions, type FetchHandlerOptions, type FetchHandlerPlugin, RPCHandler };
54
+ export { BodyLimitPlugin, type BodyLimitPluginOptions, type FetchHandleResult, FetchHandler, type FetchHandlerInterceptorOptions, type FetchHandlerOptions, type FetchHandlerPlugin, RPCHandler };
@@ -1,9 +1,9 @@
1
- export { F as FetchHandler, R as RPCHandler } from '../../shared/server.CTt4UYhI.mjs';
2
- import '@orpc/client/standard';
3
- import '../../shared/server.CVNC_Jz8.mjs';
1
+ export { B as BodyLimitPlugin, F as FetchHandler, R as RPCHandler } from '../../shared/server.T5WmDoWQ.mjs';
4
2
  import '@orpc/client';
3
+ import '@orpc/client/standard';
4
+ import '../../shared/server.Dfx1jV-K.mjs';
5
5
  import '@orpc/shared';
6
- import '../../shared/server.BtxZnWJ9.mjs';
6
+ import '../../shared/server.e3W6AG3-.mjs';
7
7
  import '@orpc/contract';
8
8
  import '@orpc/standard-server-fetch';
9
9
  import '../../shared/server.BVwwTHyO.mjs';
@@ -1,12 +1,12 @@
1
1
  import { FetchHandler } from '../fetch/index.mjs';
2
- export { FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin, RPCHandler } from '../fetch/index.mjs';
2
+ export { BodyLimitPlugin, BodyLimitPluginOptions, FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin, RPCHandler } from '../fetch/index.mjs';
3
3
  import { Value, MaybeOptionalOptions } from '@orpc/shared';
4
4
  import { Context as Context$1, MiddlewareHandler } from 'hono';
5
- import { C as Context } from '../../shared/server.MZvbGc3n.mjs';
6
- import { S as StandardHandleOptions } from '../../shared/server.DJqfB27m.mjs';
7
- import '../../shared/server.C-CCcROC.mjs';
5
+ import { C as Context } from '../../shared/server.CYBq7eu_.mjs';
6
+ import { S as StandardHandleOptions } from '../../shared/server.BUBtakoQ.mjs';
7
+ import '../../shared/server.D0tJ5s6a.mjs';
8
8
  import '@orpc/standard-server-fetch';
9
- import '../../shared/server.CIbpOMZX.mjs';
9
+ import '../../shared/server.CCwHyrSs.mjs';
10
10
  import '@orpc/client/standard';
11
11
  import '@orpc/client';
12
12
  import '@orpc/contract';
@@ -1,12 +1,12 @@
1
1
  import { FetchHandler } from '../fetch/index.js';
2
- export { FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin, RPCHandler } from '../fetch/index.js';
2
+ export { BodyLimitPlugin, BodyLimitPluginOptions, FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin, RPCHandler } from '../fetch/index.js';
3
3
  import { Value, MaybeOptionalOptions } from '@orpc/shared';
4
4
  import { Context as Context$1, MiddlewareHandler } from 'hono';
5
- import { C as Context } from '../../shared/server.MZvbGc3n.js';
6
- import { S as StandardHandleOptions } from '../../shared/server.23VRZIfj.js';
7
- import '../../shared/server.BG5ftPWa.js';
5
+ import { C as Context } from '../../shared/server.CYBq7eu_.js';
6
+ import { S as StandardHandleOptions } from '../../shared/server.DRYXuxQn.js';
7
+ import '../../shared/server.BMB1RpPJ.js';
8
8
  import '@orpc/standard-server-fetch';
9
- import '../../shared/server.DCcCuA52.js';
9
+ import '../../shared/server.DtZEvFhf.js';
10
10
  import '@orpc/client/standard';
11
11
  import '@orpc/client';
12
12
  import '@orpc/contract';
@@ -1,9 +1,9 @@
1
- export { F as FetchHandler, R as RPCHandler } from '../../shared/server.CTt4UYhI.mjs';
1
+ export { B as BodyLimitPlugin, F as FetchHandler, R as RPCHandler } from '../../shared/server.T5WmDoWQ.mjs';
2
2
  import { value } from '@orpc/shared';
3
- import '@orpc/client/standard';
4
- import '../../shared/server.CVNC_Jz8.mjs';
5
3
  import '@orpc/client';
6
- import '../../shared/server.BtxZnWJ9.mjs';
4
+ import '@orpc/client/standard';
5
+ import '../../shared/server.Dfx1jV-K.mjs';
6
+ import '../../shared/server.e3W6AG3-.mjs';
7
7
  import '@orpc/contract';
8
8
  import '@orpc/standard-server-fetch';
9
9
  import '../../shared/server.BVwwTHyO.mjs';
@@ -1,12 +1,12 @@
1
1
  import { FetchHandler } from '../fetch/index.mjs';
2
- export { FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin, RPCHandler } from '../fetch/index.mjs';
2
+ export { BodyLimitPlugin, BodyLimitPluginOptions, FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin, RPCHandler } from '../fetch/index.mjs';
3
3
  import { Value, MaybeOptionalOptions } from '@orpc/shared';
4
4
  import { NextRequest } from 'next/server';
5
- import { C as Context } from '../../shared/server.MZvbGc3n.mjs';
6
- import { S as StandardHandleOptions } from '../../shared/server.DJqfB27m.mjs';
7
- import '../../shared/server.C-CCcROC.mjs';
5
+ import { C as Context } from '../../shared/server.CYBq7eu_.mjs';
6
+ import { S as StandardHandleOptions } from '../../shared/server.BUBtakoQ.mjs';
7
+ import '../../shared/server.D0tJ5s6a.mjs';
8
8
  import '@orpc/standard-server-fetch';
9
- import '../../shared/server.CIbpOMZX.mjs';
9
+ import '../../shared/server.CCwHyrSs.mjs';
10
10
  import '@orpc/client/standard';
11
11
  import '@orpc/client';
12
12
  import '@orpc/contract';
@@ -1,12 +1,12 @@
1
1
  import { FetchHandler } from '../fetch/index.js';
2
- export { FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin, RPCHandler } from '../fetch/index.js';
2
+ export { BodyLimitPlugin, BodyLimitPluginOptions, FetchHandleResult, FetchHandlerInterceptorOptions, FetchHandlerOptions, FetchHandlerPlugin, RPCHandler } from '../fetch/index.js';
3
3
  import { Value, MaybeOptionalOptions } from '@orpc/shared';
4
4
  import { NextRequest } from 'next/server';
5
- import { C as Context } from '../../shared/server.MZvbGc3n.js';
6
- import { S as StandardHandleOptions } from '../../shared/server.23VRZIfj.js';
7
- import '../../shared/server.BG5ftPWa.js';
5
+ import { C as Context } from '../../shared/server.CYBq7eu_.js';
6
+ import { S as StandardHandleOptions } from '../../shared/server.DRYXuxQn.js';
7
+ import '../../shared/server.BMB1RpPJ.js';
8
8
  import '@orpc/standard-server-fetch';
9
- import '../../shared/server.DCcCuA52.js';
9
+ import '../../shared/server.DtZEvFhf.js';
10
10
  import '@orpc/client/standard';
11
11
  import '@orpc/client';
12
12
  import '@orpc/contract';
@@ -1,9 +1,9 @@
1
- export { F as FetchHandler, R as RPCHandler } from '../../shared/server.CTt4UYhI.mjs';
1
+ export { B as BodyLimitPlugin, F as FetchHandler, R as RPCHandler } from '../../shared/server.T5WmDoWQ.mjs';
2
2
  import { value } from '@orpc/shared';
3
- import '@orpc/client/standard';
4
- import '../../shared/server.CVNC_Jz8.mjs';
5
3
  import '@orpc/client';
6
- import '../../shared/server.BtxZnWJ9.mjs';
4
+ import '@orpc/client/standard';
5
+ import '../../shared/server.Dfx1jV-K.mjs';
6
+ import '../../shared/server.e3W6AG3-.mjs';
7
7
  import '@orpc/contract';
8
8
  import '@orpc/standard-server-fetch';
9
9
  import '../../shared/server.BVwwTHyO.mjs';
@@ -1,9 +1,9 @@
1
+ import { C as Context, R as Router } from '../../shared/server.CYBq7eu_.mjs';
2
+ import { Interceptor, ThrowableError, MaybeOptionalOptions } from '@orpc/shared';
1
3
  import { SendStandardResponseOptions, NodeHttpRequest, NodeHttpResponse } from '@orpc/standard-server-node';
2
- import { C as Context, R as Router } from '../../shared/server.MZvbGc3n.mjs';
3
- import { c as StandardHandlerPlugin, S as StandardHandleOptions, i as StandardHandler } from '../../shared/server.DJqfB27m.mjs';
4
- import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
5
- import { F as FriendlyStandardHandleOptions } from '../../shared/server.C-CCcROC.mjs';
6
- import { S as StandardRPCHandlerOptions } from '../../shared/server.CIbpOMZX.mjs';
4
+ import { c as StandardHandlerPlugin, S as StandardHandleOptions, i as StandardHandler } from '../../shared/server.BUBtakoQ.mjs';
5
+ import { F as FriendlyStandardHandleOptions } from '../../shared/server.D0tJ5s6a.mjs';
6
+ import { S as StandardRPCHandlerOptions } from '../../shared/server.CCwHyrSs.mjs';
7
7
  import '@orpc/client';
8
8
  import '@orpc/contract';
9
9
  import '@orpc/standard-server';
@@ -17,13 +17,13 @@ type NodeHttpHandleResult = {
17
17
  interface NodeHttpHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
18
18
  initRuntimeAdapter?(options: NodeHttpHandlerOptions<T>): void;
19
19
  }
20
+ interface NodeHttpHandlerInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
21
+ request: NodeHttpRequest;
22
+ response: NodeHttpResponse;
23
+ sendStandardResponseOptions: SendStandardResponseOptions;
24
+ }
20
25
  interface NodeHttpHandlerOptions<T extends Context> extends SendStandardResponseOptions {
21
- adapterInterceptors?: Interceptor<{
22
- request: NodeHttpRequest;
23
- response: NodeHttpResponse;
24
- sendStandardResponseOptions: SendStandardResponseOptions;
25
- options: StandardHandleOptions<T>;
26
- }, NodeHttpHandleResult, unknown>[];
26
+ adapterInterceptors?: Interceptor<NodeHttpHandlerInterceptorOptions<T>, NodeHttpHandleResult, ThrowableError>[];
27
27
  plugins?: NodeHttpHandlerPlugin<T>[];
28
28
  }
29
29
  declare class NodeHttpHandler<T extends Context> implements NodeHttpHandler<T> {
@@ -34,8 +34,20 @@ declare class NodeHttpHandler<T extends Context> implements NodeHttpHandler<T> {
34
34
  handle(request: NodeHttpRequest, response: NodeHttpResponse, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<T>>): Promise<NodeHttpHandleResult>;
35
35
  }
36
36
 
37
+ interface BodyLimitPluginOptions {
38
+ /**
39
+ * The maximum size of the body in bytes.
40
+ */
41
+ maxBodySize: number;
42
+ }
43
+ declare class BodyLimitPlugin<T extends Context> implements NodeHttpHandlerPlugin<T> {
44
+ private readonly maxBodySize;
45
+ constructor(options: BodyLimitPluginOptions);
46
+ initRuntimeAdapter(options: NodeHttpHandlerOptions<T>): void;
47
+ }
48
+
37
49
  declare class RPCHandler<T extends Context> extends NodeHttpHandler<T> {
38
50
  constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T> & NodeHttpHandlerOptions<T>>);
39
51
  }
40
52
 
41
- export { type NodeHttpHandleResult, NodeHttpHandler, type NodeHttpHandlerOptions, type NodeHttpHandlerPlugin, RPCHandler };
53
+ export { BodyLimitPlugin, type BodyLimitPluginOptions, type NodeHttpHandleResult, NodeHttpHandler, type NodeHttpHandlerInterceptorOptions, type NodeHttpHandlerOptions, type NodeHttpHandlerPlugin, RPCHandler };
@@ -1,9 +1,9 @@
1
+ import { C as Context, R as Router } from '../../shared/server.CYBq7eu_.js';
2
+ import { Interceptor, ThrowableError, MaybeOptionalOptions } from '@orpc/shared';
1
3
  import { SendStandardResponseOptions, NodeHttpRequest, NodeHttpResponse } from '@orpc/standard-server-node';
2
- import { C as Context, R as Router } from '../../shared/server.MZvbGc3n.js';
3
- import { c as StandardHandlerPlugin, S as StandardHandleOptions, i as StandardHandler } from '../../shared/server.23VRZIfj.js';
4
- import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
5
- import { F as FriendlyStandardHandleOptions } from '../../shared/server.BG5ftPWa.js';
6
- import { S as StandardRPCHandlerOptions } from '../../shared/server.DCcCuA52.js';
4
+ import { c as StandardHandlerPlugin, S as StandardHandleOptions, i as StandardHandler } from '../../shared/server.DRYXuxQn.js';
5
+ import { F as FriendlyStandardHandleOptions } from '../../shared/server.BMB1RpPJ.js';
6
+ import { S as StandardRPCHandlerOptions } from '../../shared/server.DtZEvFhf.js';
7
7
  import '@orpc/client';
8
8
  import '@orpc/contract';
9
9
  import '@orpc/standard-server';
@@ -17,13 +17,13 @@ type NodeHttpHandleResult = {
17
17
  interface NodeHttpHandlerPlugin<T extends Context> extends StandardHandlerPlugin<T> {
18
18
  initRuntimeAdapter?(options: NodeHttpHandlerOptions<T>): void;
19
19
  }
20
+ interface NodeHttpHandlerInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
21
+ request: NodeHttpRequest;
22
+ response: NodeHttpResponse;
23
+ sendStandardResponseOptions: SendStandardResponseOptions;
24
+ }
20
25
  interface NodeHttpHandlerOptions<T extends Context> extends SendStandardResponseOptions {
21
- adapterInterceptors?: Interceptor<{
22
- request: NodeHttpRequest;
23
- response: NodeHttpResponse;
24
- sendStandardResponseOptions: SendStandardResponseOptions;
25
- options: StandardHandleOptions<T>;
26
- }, NodeHttpHandleResult, unknown>[];
26
+ adapterInterceptors?: Interceptor<NodeHttpHandlerInterceptorOptions<T>, NodeHttpHandleResult, ThrowableError>[];
27
27
  plugins?: NodeHttpHandlerPlugin<T>[];
28
28
  }
29
29
  declare class NodeHttpHandler<T extends Context> implements NodeHttpHandler<T> {
@@ -34,8 +34,20 @@ declare class NodeHttpHandler<T extends Context> implements NodeHttpHandler<T> {
34
34
  handle(request: NodeHttpRequest, response: NodeHttpResponse, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<T>>): Promise<NodeHttpHandleResult>;
35
35
  }
36
36
 
37
+ interface BodyLimitPluginOptions {
38
+ /**
39
+ * The maximum size of the body in bytes.
40
+ */
41
+ maxBodySize: number;
42
+ }
43
+ declare class BodyLimitPlugin<T extends Context> implements NodeHttpHandlerPlugin<T> {
44
+ private readonly maxBodySize;
45
+ constructor(options: BodyLimitPluginOptions);
46
+ initRuntimeAdapter(options: NodeHttpHandlerOptions<T>): void;
47
+ }
48
+
37
49
  declare class RPCHandler<T extends Context> extends NodeHttpHandler<T> {
38
50
  constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T> & NodeHttpHandlerOptions<T>>);
39
51
  }
40
52
 
41
- export { type NodeHttpHandleResult, NodeHttpHandler, type NodeHttpHandlerOptions, type NodeHttpHandlerPlugin, RPCHandler };
53
+ export { BodyLimitPlugin, type BodyLimitPluginOptions, type NodeHttpHandleResult, NodeHttpHandler, type NodeHttpHandlerInterceptorOptions, type NodeHttpHandlerOptions, type NodeHttpHandlerPlugin, RPCHandler };
@@ -1,12 +1,44 @@
1
+ import { ORPCError } from '@orpc/client';
1
2
  import { toArray, intercept, resolveMaybeOptionalOptions } from '@orpc/shared';
2
3
  import { toStandardLazyRequest, sendStandardResponse } from '@orpc/standard-server-node';
3
4
  import { r as resolveFriendlyStandardHandleOptions } from '../../shared/server.BVwwTHyO.mjs';
4
5
  import { StandardRPCJsonSerializer, StandardRPCSerializer } from '@orpc/client/standard';
5
- import { S as StandardHandler, b as StandardRPCMatcher, a as StandardRPCCodec } from '../../shared/server.CVNC_Jz8.mjs';
6
- import '@orpc/client';
7
- import '../../shared/server.BtxZnWJ9.mjs';
6
+ import { S as StandardHandler, b as StandardRPCMatcher, a as StandardRPCCodec } from '../../shared/server.Dfx1jV-K.mjs';
7
+ import '../../shared/server.e3W6AG3-.mjs';
8
8
  import '@orpc/contract';
9
9
 
10
+ class BodyLimitPlugin {
11
+ maxBodySize;
12
+ constructor(options) {
13
+ this.maxBodySize = options.maxBodySize;
14
+ }
15
+ initRuntimeAdapter(options) {
16
+ options.adapterInterceptors ??= [];
17
+ options.adapterInterceptors.push(async (options2) => {
18
+ let isHeaderChecked = false;
19
+ const checkHeader = () => {
20
+ if (!isHeaderChecked && Number(options2.request.headers["content-length"]) > this.maxBodySize) {
21
+ throw new ORPCError("PAYLOAD_TOO_LARGE");
22
+ }
23
+ isHeaderChecked = true;
24
+ };
25
+ const originalEmit = options2.request.emit.bind(options2.request);
26
+ let currentBodySize = 0;
27
+ options2.request.emit = (event, ...args) => {
28
+ if (event === "data") {
29
+ checkHeader();
30
+ currentBodySize += args[0].length;
31
+ if (currentBodySize > this.maxBodySize) {
32
+ throw new ORPCError("PAYLOAD_TOO_LARGE");
33
+ }
34
+ }
35
+ return originalEmit(event, ...args);
36
+ };
37
+ return options2.next();
38
+ });
39
+ }
40
+ }
41
+
10
42
  class NodeHttpHandler {
11
43
  constructor(standardHandler, options = {}) {
12
44
  this.standardHandler = standardHandler;
@@ -22,12 +54,12 @@ class NodeHttpHandler {
22
54
  return intercept(
23
55
  this.adapterInterceptors,
24
56
  {
57
+ ...resolveFriendlyStandardHandleOptions(resolveMaybeOptionalOptions(rest)),
25
58
  request,
26
59
  response,
27
- sendStandardResponseOptions: this.sendStandardResponseOptions,
28
- options: resolveFriendlyStandardHandleOptions(resolveMaybeOptionalOptions(rest))
60
+ sendStandardResponseOptions: this.sendStandardResponseOptions
29
61
  },
30
- async ({ request: request2, response: response2, sendStandardResponseOptions, options }) => {
62
+ async ({ request: request2, response: response2, sendStandardResponseOptions, ...options }) => {
31
63
  const standardRequest = toStandardLazyRequest(request2, response2);
32
64
  const result = await this.standardHandler.handle(standardRequest, options);
33
65
  if (!result.matched) {
@@ -50,4 +82,4 @@ class RPCHandler extends NodeHttpHandler {
50
82
  }
51
83
  }
52
84
 
53
- export { NodeHttpHandler, RPCHandler };
85
+ export { BodyLimitPlugin, NodeHttpHandler, RPCHandler };
@@ -1,11 +1,11 @@
1
- import { d as StandardCodec, e as StandardParams, f as StandardMatcher, g as StandardMatchResult } from '../../shared/server.DJqfB27m.mjs';
2
- export { S as StandardHandleOptions, h as StandardHandleResult, i as StandardHandler, b as StandardHandlerInterceptorOptions, a as StandardHandlerOptions, c as StandardHandlerPlugin } from '../../shared/server.DJqfB27m.mjs';
3
- import { ORPCError } from '@orpc/client';
1
+ import { d as StandardCodec, e as StandardParams, f as StandardMatcher, g as StandardMatchResult } from '../../shared/server.BUBtakoQ.mjs';
2
+ export { S as StandardHandleOptions, h as StandardHandleResult, i as StandardHandler, b as StandardHandlerInterceptorOptions, a as StandardHandlerOptions, c as StandardHandlerPlugin } from '../../shared/server.BUBtakoQ.mjs';
3
+ import { ORPCError, HTTPPath } from '@orpc/client';
4
4
  import { StandardRPCSerializer } from '@orpc/client/standard';
5
5
  import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
6
- import { A as AnyProcedure, a as AnyRouter } from '../../shared/server.MZvbGc3n.mjs';
7
- export { S as StandardRPCHandlerOptions } from '../../shared/server.CIbpOMZX.mjs';
8
- import { HTTPPath } from '@orpc/contract';
6
+ import { A as AnyProcedure, a as AnyRouter } from '../../shared/server.CYBq7eu_.mjs';
7
+ export { S as StandardRPCHandlerOptions } from '../../shared/server.CCwHyrSs.mjs';
8
+ import '@orpc/contract';
9
9
  import '@orpc/shared';
10
10
 
11
11
  declare class StandardRPCCodec implements StandardCodec {
@@ -1,11 +1,11 @@
1
- import { d as StandardCodec, e as StandardParams, f as StandardMatcher, g as StandardMatchResult } from '../../shared/server.23VRZIfj.js';
2
- export { S as StandardHandleOptions, h as StandardHandleResult, i as StandardHandler, b as StandardHandlerInterceptorOptions, a as StandardHandlerOptions, c as StandardHandlerPlugin } from '../../shared/server.23VRZIfj.js';
3
- import { ORPCError } from '@orpc/client';
1
+ import { d as StandardCodec, e as StandardParams, f as StandardMatcher, g as StandardMatchResult } from '../../shared/server.DRYXuxQn.js';
2
+ export { S as StandardHandleOptions, h as StandardHandleResult, i as StandardHandler, b as StandardHandlerInterceptorOptions, a as StandardHandlerOptions, c as StandardHandlerPlugin } from '../../shared/server.DRYXuxQn.js';
3
+ import { ORPCError, HTTPPath } from '@orpc/client';
4
4
  import { StandardRPCSerializer } from '@orpc/client/standard';
5
5
  import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
6
- import { A as AnyProcedure, a as AnyRouter } from '../../shared/server.MZvbGc3n.js';
7
- export { S as StandardRPCHandlerOptions } from '../../shared/server.DCcCuA52.js';
8
- import { HTTPPath } from '@orpc/contract';
6
+ import { A as AnyProcedure, a as AnyRouter } from '../../shared/server.CYBq7eu_.js';
7
+ export { S as StandardRPCHandlerOptions } from '../../shared/server.DtZEvFhf.js';
8
+ import '@orpc/contract';
9
9
  import '@orpc/shared';
10
10
 
11
11
  declare class StandardRPCCodec implements StandardCodec {
@@ -1,5 +1,6 @@
1
- export { S as StandardHandler, a as StandardRPCCodec, b as StandardRPCMatcher } from '../../shared/server.CVNC_Jz8.mjs';
1
+ export { S as StandardHandler, a as StandardRPCCodec, b as StandardRPCMatcher } from '../../shared/server.Dfx1jV-K.mjs';
2
2
  import '@orpc/client';
3
3
  import '@orpc/shared';
4
- import '../../shared/server.BtxZnWJ9.mjs';
4
+ import '../../shared/server.e3W6AG3-.mjs';
5
5
  import '@orpc/contract';
6
+ import '@orpc/client/standard';
package/dist/index.d.mts CHANGED
@@ -1,13 +1,29 @@
1
- import { AnySchema, ErrorMap, Meta, MergedErrorMap, Route, InferSchemaOutput, InferSchemaInput, EnhanceRouteOptions, AnyContractRouter, AnyContractProcedure, Schema, HTTPPath, ContractRouter, ContractProcedureDef, ContractProcedure, InferContractRouterErrorMap, InferContractRouterMeta, ErrorFromErrorMap } from '@orpc/contract';
2
- export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, HTTPMethod, HTTPPath, InferSchemaInput, InferSchemaOutput, InputStructure, Meta, OutputStructure, Route, Schema, ValidationError, eventIterator, type } from '@orpc/contract';
3
- import { C as Context, b as Procedure, M as Middleware, O as ORPCErrorConstructorMap, c as MergedInitialContext, d as MergedCurrentContext, e as MapInputMiddleware, f as CreateProcedureClientOptions, g as ProcedureClient, h as AnyMiddleware, L as Lazyable, a as AnyRouter, i as Lazy, A as AnyProcedure, j as ProcedureHandler, R as Router, I as InferRouterInitialContext } from './shared/server.MZvbGc3n.mjs';
4
- export { J as InferRouterCurrentContexts, H as InferRouterInitialContexts, K as InferRouterInputs, N as InferRouterOutputs, o as LAZY_SYMBOL, p as LazyMeta, x as MiddlewareNextFn, w as MiddlewareNextFnOptions, z as MiddlewareOptions, y as MiddlewareOutputFn, t as MiddlewareResult, l as ORPCErrorConstructorMapItem, k as ORPCErrorConstructorMapItemOptions, P as ProcedureClientInterceptorOptions, E as ProcedureDef, D as ProcedureHandlerOptions, n as createORPCErrorConstructorMap, G as createProcedureClient, s as getLazyMeta, r as isLazy, F as isProcedure, q as lazy, m as mergeCurrentContext, B as middlewareOutputFn, u as unlazy, v as validateORPCError } from './shared/server.MZvbGc3n.mjs';
5
- import { ClientContext, ClientRest, ClientPromiseResult } from '@orpc/client';
1
+ import { ORPCErrorJSON, ORPCError, Client, ClientContext, HTTPPath, ClientPromiseResult } from '@orpc/client';
6
2
  export { ORPCError, isDefinedError, safe } from '@orpc/client';
7
- import { IntersectPick, MaybeOptionalOptions } from '@orpc/shared';
8
- export { onError, onFinish, onStart, onSuccess } from '@orpc/shared';
3
+ import { AnySchema, ErrorMap, InferSchemaInput, InferSchemaOutput, ErrorFromErrorMap, Meta, MergedErrorMap, Route, EnhanceRouteOptions, AnyContractRouter, AnyContractProcedure, Schema, ContractRouter, ContractProcedureDef, ContractProcedure, InferContractRouterErrorMap, InferContractRouterMeta } from '@orpc/contract';
4
+ export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, InputStructure, Meta, OutputStructure, Route, Schema, ValidationError, eventIterator, type } from '@orpc/contract';
5
+ import { C as Context, b as Procedure, M as Middleware, O as ORPCErrorConstructorMap, c as MergedInitialContext, d as MergedCurrentContext, e as MapInputMiddleware, f as CreateProcedureClientOptions, g as ProcedureClient, h as AnyMiddleware, L as Lazyable, a as AnyRouter, i as Lazy, A as AnyProcedure, j as ProcedureHandler, R as Router, I as InferRouterInitialContext } from './shared/server.CYBq7eu_.mjs';
6
+ export { J as InferRouterCurrentContexts, H as InferRouterInitialContexts, K as InferRouterInputs, N as InferRouterOutputs, o as LAZY_SYMBOL, p as LazyMeta, x as MiddlewareNextFn, w as MiddlewareNextFnOptions, z as MiddlewareOptions, y as MiddlewareOutputFn, t as MiddlewareResult, l as ORPCErrorConstructorMapItem, k as ORPCErrorConstructorMapItemOptions, P as ProcedureClientInterceptorOptions, E as ProcedureDef, D as ProcedureHandlerOptions, n as createORPCErrorConstructorMap, G as createProcedureClient, s as getLazyMeta, r as isLazy, F as isProcedure, q as lazy, m as mergeCurrentContext, B as middlewareOutputFn, u as unlazy, v as validateORPCError } from './shared/server.CYBq7eu_.mjs';
7
+ import { ThrowableError, IntersectPick, MaybeOptionalOptions } from '@orpc/shared';
8
+ export { Registry, ThrowableError, onError, onFinish, onStart, onSuccess } from '@orpc/shared';
9
9
  export { getEventMeta, withEventMeta } from '@orpc/standard-server';
10
10
 
11
+ type ActionableError<T> = T extends ORPCError<infer U, infer V> ? ORPCErrorJSON<U, V> & {
12
+ defined: true;
13
+ } : ORPCErrorJSON<string, unknown> & {
14
+ defined: false;
15
+ };
16
+ type UnactionableError<T> = T extends {
17
+ defined: true;
18
+ } & ORPCErrorJSON<infer U, infer V> ? ORPCError<U, V> : ThrowableError;
19
+ type ActionableClientRest<TInput> = [input: TInput] | (undefined extends TInput ? [input?: TInput] : [input: TInput]);
20
+ type ActionableClientResult<TOutput, TError extends ORPCErrorJSON<any, any>> = [error: null, data: TOutput] | [error: TError, data: undefined];
21
+ interface ActionableClient<TInput, TOutput, TError extends ORPCErrorJSON<any, any>> {
22
+ (...rest: ActionableClientRest<TInput>): Promise<ActionableClientResult<TOutput, TError>>;
23
+ }
24
+ type ProcedureActionableClient<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = ActionableClient<InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ActionableError<ErrorFromErrorMap<TErrorMap>>>;
25
+ declare function createActionableClient<TInput, TOutput, TError>(client: Client<Record<never, never>, TInput, TOutput, TError>): ActionableClient<TInput, TOutput, ActionableError<TError>>;
26
+
11
27
  declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> {
12
28
  errors<U extends ErrorMap>(errors: U): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
13
29
  meta(meta: TMeta): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
@@ -17,11 +33,11 @@ declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContex
17
33
  /**
18
34
  * Make this procedure callable (works like a function while still being a procedure).
19
35
  */
20
- callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
36
+ callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
21
37
  /**
22
- * Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
38
+ * Make this procedure compatible with server action.
23
39
  */
24
- actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, InferSchemaInput<TInputSchema>>) => Promise<InferSchemaOutput<TOutputSchema>>);
40
+ actionable(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, Record<never, never>>>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureActionableClient<TInputSchema, TOutputSchema, TErrorMap>;
25
41
  }
26
42
 
27
43
  declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
@@ -195,11 +211,11 @@ interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext
195
211
  /**
196
212
  * Make this procedure callable (works like a function while still being a procedure).
197
213
  */
198
- callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
214
+ callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
199
215
  /**
200
- * Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
216
+ * Make this procedure compatible with server action.
201
217
  */
202
- actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, InferSchemaInput<TInputSchema>>) => Promise<InferSchemaOutput<TOutputSchema>>);
218
+ actionable(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, Record<never, never>>>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureActionableClient<TInputSchema, TOutputSchema, TErrorMap>;
203
219
  }
204
220
  /**
205
221
  * Like `ProcedureBuilderWithoutHandler`, but removed all method that can change the contract.
@@ -262,16 +278,14 @@ declare function createContractedProcedure(procedure: AnyProcedure, contract: An
262
278
  * ```
263
279
  *
264
280
  */
265
- declare function call<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta>(procedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, input: InferSchemaInput<TInputSchema>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, Record<never, never>>>): ClientPromiseResult<InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
281
+ declare function call<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta>(procedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, input: InferSchemaInput<TInputSchema>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, Record<never, never>>>): ClientPromiseResult<InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
266
282
 
267
283
  type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UErrorMap, any> ? ProcedureClient<TClientContext, UInputSchema, UOutputSchema, UErrorMap> : {
268
284
  [K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
269
285
  };
270
- declare function createRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>, Schema<unknown, unknown>, Schema<unknown, unknown>, ErrorMap, Meta, TClientContext>>): RouterClient<T, TClientContext>;
286
+ declare function createRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>, Schema<unknown, unknown>, ErrorMap, Meta, TClientContext>>): RouterClient<T, TClientContext>;
271
287
 
272
288
  declare function setHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: AnyContractRouter): T;
273
289
  declare function getHiddenRouterContract(router: Lazyable<AnyRouter | AnyContractRouter>): AnyContractRouter | undefined;
274
290
 
275
- declare function toHttpPath(path: readonly string[]): HTTPPath;
276
-
277
- export { type AccessibleLazyRouter, AnyMiddleware, AnyProcedure, AnyRouter, Builder, type BuilderConfig, type BuilderDef, type BuilderWithMiddlewares, type Config, Context, type ContractProcedureCallbackOptions, CreateProcedureClientOptions, type DecoratedMiddleware, DecoratedProcedure, type EnhanceRouterOptions, type EnhancedRouter, type ImplementedProcedure, type Implementer, type ImplementerInternal, type ImplementerInternalWithMiddlewares, InferRouterInitialContext, Lazy, type LazyTraverseContractProceduresOptions, Lazyable, MapInputMiddleware, MergedCurrentContext, MergedInitialContext, Middleware, ORPCErrorConstructorMap, Procedure, type ProcedureBuilder, type ProcedureBuilderWithInput, type ProcedureBuilderWithInputOutput, type ProcedureBuilderWithOutput, ProcedureClient, ProcedureHandler, type ProcedureImplementer, Router, type RouterBuilder, type RouterClient, type RouterImplementer, type RouterImplementerWithMiddlewares, type TraverseContractProceduresOptions, type UnlaziedRouter, addMiddleware, call, createAccessibleLazyRouter, createAssertedLazyProcedure, createContractedProcedure, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getHiddenRouterContract, getRouter, implement, implementerInternal, isStartWithMiddlewares, mergeMiddlewares, os, resolveContractProcedures, setHiddenRouterContract, toHttpPath, traverseContractProcedures, unlazyRouter };
291
+ export { type AccessibleLazyRouter, type ActionableClient, type ActionableClientRest, type ActionableClientResult, type ActionableError, AnyMiddleware, AnyProcedure, AnyRouter, Builder, type BuilderConfig, type BuilderDef, type BuilderWithMiddlewares, type Config, Context, type ContractProcedureCallbackOptions, CreateProcedureClientOptions, type DecoratedMiddleware, DecoratedProcedure, type EnhanceRouterOptions, type EnhancedRouter, type ImplementedProcedure, type Implementer, type ImplementerInternal, type ImplementerInternalWithMiddlewares, InferRouterInitialContext, Lazy, type LazyTraverseContractProceduresOptions, Lazyable, MapInputMiddleware, MergedCurrentContext, MergedInitialContext, Middleware, ORPCErrorConstructorMap, Procedure, type ProcedureActionableClient, type ProcedureBuilder, type ProcedureBuilderWithInput, type ProcedureBuilderWithInputOutput, type ProcedureBuilderWithOutput, ProcedureClient, ProcedureHandler, type ProcedureImplementer, Router, type RouterBuilder, type RouterClient, type RouterImplementer, type RouterImplementerWithMiddlewares, type TraverseContractProceduresOptions, type UnactionableError, type UnlaziedRouter, addMiddleware, call, createAccessibleLazyRouter, createActionableClient, createAssertedLazyProcedure, createContractedProcedure, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getHiddenRouterContract, getRouter, implement, implementerInternal, isStartWithMiddlewares, mergeMiddlewares, os, resolveContractProcedures, setHiddenRouterContract, traverseContractProcedures, unlazyRouter };
package/dist/index.d.ts CHANGED
@@ -1,13 +1,29 @@
1
- import { AnySchema, ErrorMap, Meta, MergedErrorMap, Route, InferSchemaOutput, InferSchemaInput, EnhanceRouteOptions, AnyContractRouter, AnyContractProcedure, Schema, HTTPPath, ContractRouter, ContractProcedureDef, ContractProcedure, InferContractRouterErrorMap, InferContractRouterMeta, ErrorFromErrorMap } from '@orpc/contract';
2
- export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, HTTPMethod, HTTPPath, InferSchemaInput, InferSchemaOutput, InputStructure, Meta, OutputStructure, Route, Schema, ValidationError, eventIterator, type } from '@orpc/contract';
3
- import { C as Context, b as Procedure, M as Middleware, O as ORPCErrorConstructorMap, c as MergedInitialContext, d as MergedCurrentContext, e as MapInputMiddleware, f as CreateProcedureClientOptions, g as ProcedureClient, h as AnyMiddleware, L as Lazyable, a as AnyRouter, i as Lazy, A as AnyProcedure, j as ProcedureHandler, R as Router, I as InferRouterInitialContext } from './shared/server.MZvbGc3n.js';
4
- export { J as InferRouterCurrentContexts, H as InferRouterInitialContexts, K as InferRouterInputs, N as InferRouterOutputs, o as LAZY_SYMBOL, p as LazyMeta, x as MiddlewareNextFn, w as MiddlewareNextFnOptions, z as MiddlewareOptions, y as MiddlewareOutputFn, t as MiddlewareResult, l as ORPCErrorConstructorMapItem, k as ORPCErrorConstructorMapItemOptions, P as ProcedureClientInterceptorOptions, E as ProcedureDef, D as ProcedureHandlerOptions, n as createORPCErrorConstructorMap, G as createProcedureClient, s as getLazyMeta, r as isLazy, F as isProcedure, q as lazy, m as mergeCurrentContext, B as middlewareOutputFn, u as unlazy, v as validateORPCError } from './shared/server.MZvbGc3n.js';
5
- import { ClientContext, ClientRest, ClientPromiseResult } from '@orpc/client';
1
+ import { ORPCErrorJSON, ORPCError, Client, ClientContext, HTTPPath, ClientPromiseResult } from '@orpc/client';
6
2
  export { ORPCError, isDefinedError, safe } from '@orpc/client';
7
- import { IntersectPick, MaybeOptionalOptions } from '@orpc/shared';
8
- export { onError, onFinish, onStart, onSuccess } from '@orpc/shared';
3
+ import { AnySchema, ErrorMap, InferSchemaInput, InferSchemaOutput, ErrorFromErrorMap, Meta, MergedErrorMap, Route, EnhanceRouteOptions, AnyContractRouter, AnyContractProcedure, Schema, ContractRouter, ContractProcedureDef, ContractProcedure, InferContractRouterErrorMap, InferContractRouterMeta } from '@orpc/contract';
4
+ export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, InputStructure, Meta, OutputStructure, Route, Schema, ValidationError, eventIterator, type } from '@orpc/contract';
5
+ import { C as Context, b as Procedure, M as Middleware, O as ORPCErrorConstructorMap, c as MergedInitialContext, d as MergedCurrentContext, e as MapInputMiddleware, f as CreateProcedureClientOptions, g as ProcedureClient, h as AnyMiddleware, L as Lazyable, a as AnyRouter, i as Lazy, A as AnyProcedure, j as ProcedureHandler, R as Router, I as InferRouterInitialContext } from './shared/server.CYBq7eu_.js';
6
+ export { J as InferRouterCurrentContexts, H as InferRouterInitialContexts, K as InferRouterInputs, N as InferRouterOutputs, o as LAZY_SYMBOL, p as LazyMeta, x as MiddlewareNextFn, w as MiddlewareNextFnOptions, z as MiddlewareOptions, y as MiddlewareOutputFn, t as MiddlewareResult, l as ORPCErrorConstructorMapItem, k as ORPCErrorConstructorMapItemOptions, P as ProcedureClientInterceptorOptions, E as ProcedureDef, D as ProcedureHandlerOptions, n as createORPCErrorConstructorMap, G as createProcedureClient, s as getLazyMeta, r as isLazy, F as isProcedure, q as lazy, m as mergeCurrentContext, B as middlewareOutputFn, u as unlazy, v as validateORPCError } from './shared/server.CYBq7eu_.js';
7
+ import { ThrowableError, IntersectPick, MaybeOptionalOptions } from '@orpc/shared';
8
+ export { Registry, ThrowableError, onError, onFinish, onStart, onSuccess } from '@orpc/shared';
9
9
  export { getEventMeta, withEventMeta } from '@orpc/standard-server';
10
10
 
11
+ type ActionableError<T> = T extends ORPCError<infer U, infer V> ? ORPCErrorJSON<U, V> & {
12
+ defined: true;
13
+ } : ORPCErrorJSON<string, unknown> & {
14
+ defined: false;
15
+ };
16
+ type UnactionableError<T> = T extends {
17
+ defined: true;
18
+ } & ORPCErrorJSON<infer U, infer V> ? ORPCError<U, V> : ThrowableError;
19
+ type ActionableClientRest<TInput> = [input: TInput] | (undefined extends TInput ? [input?: TInput] : [input: TInput]);
20
+ type ActionableClientResult<TOutput, TError extends ORPCErrorJSON<any, any>> = [error: null, data: TOutput] | [error: TError, data: undefined];
21
+ interface ActionableClient<TInput, TOutput, TError extends ORPCErrorJSON<any, any>> {
22
+ (...rest: ActionableClientRest<TInput>): Promise<ActionableClientResult<TOutput, TError>>;
23
+ }
24
+ type ProcedureActionableClient<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = ActionableClient<InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ActionableError<ErrorFromErrorMap<TErrorMap>>>;
25
+ declare function createActionableClient<TInput, TOutput, TError>(client: Client<Record<never, never>, TInput, TOutput, TError>): ActionableClient<TInput, TOutput, ActionableError<TError>>;
26
+
11
27
  declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> {
12
28
  errors<U extends ErrorMap>(errors: U): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
13
29
  meta(meta: TMeta): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
@@ -17,11 +33,11 @@ declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContex
17
33
  /**
18
34
  * Make this procedure callable (works like a function while still being a procedure).
19
35
  */
20
- callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
36
+ callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
21
37
  /**
22
- * Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
38
+ * Make this procedure compatible with server action.
23
39
  */
24
- actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, InferSchemaInput<TInputSchema>>) => Promise<InferSchemaOutput<TOutputSchema>>);
40
+ actionable(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, Record<never, never>>>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureActionableClient<TInputSchema, TOutputSchema, TErrorMap>;
25
41
  }
26
42
 
27
43
  declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
@@ -195,11 +211,11 @@ interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext
195
211
  /**
196
212
  * Make this procedure callable (works like a function while still being a procedure).
197
213
  */
198
- callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
214
+ callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
199
215
  /**
200
- * Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
216
+ * Make this procedure compatible with server action.
201
217
  */
202
- actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, InferSchemaInput<TInputSchema>>) => Promise<InferSchemaOutput<TOutputSchema>>);
218
+ actionable(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, Record<never, never>>>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureActionableClient<TInputSchema, TOutputSchema, TErrorMap>;
203
219
  }
204
220
  /**
205
221
  * Like `ProcedureBuilderWithoutHandler`, but removed all method that can change the contract.
@@ -262,16 +278,14 @@ declare function createContractedProcedure(procedure: AnyProcedure, contract: An
262
278
  * ```
263
279
  *
264
280
  */
265
- declare function call<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta>(procedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, input: InferSchemaInput<TInputSchema>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, Record<never, never>>>): ClientPromiseResult<InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
281
+ declare function call<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta>(procedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, input: InferSchemaInput<TInputSchema>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, Record<never, never>>>): ClientPromiseResult<InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
266
282
 
267
283
  type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UErrorMap, any> ? ProcedureClient<TClientContext, UInputSchema, UOutputSchema, UErrorMap> : {
268
284
  [K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
269
285
  };
270
- declare function createRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>, Schema<unknown, unknown>, Schema<unknown, unknown>, ErrorMap, Meta, TClientContext>>): RouterClient<T, TClientContext>;
286
+ declare function createRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>, Schema<unknown, unknown>, ErrorMap, Meta, TClientContext>>): RouterClient<T, TClientContext>;
271
287
 
272
288
  declare function setHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: AnyContractRouter): T;
273
289
  declare function getHiddenRouterContract(router: Lazyable<AnyRouter | AnyContractRouter>): AnyContractRouter | undefined;
274
290
 
275
- declare function toHttpPath(path: readonly string[]): HTTPPath;
276
-
277
- export { type AccessibleLazyRouter, AnyMiddleware, AnyProcedure, AnyRouter, Builder, type BuilderConfig, type BuilderDef, type BuilderWithMiddlewares, type Config, Context, type ContractProcedureCallbackOptions, CreateProcedureClientOptions, type DecoratedMiddleware, DecoratedProcedure, type EnhanceRouterOptions, type EnhancedRouter, type ImplementedProcedure, type Implementer, type ImplementerInternal, type ImplementerInternalWithMiddlewares, InferRouterInitialContext, Lazy, type LazyTraverseContractProceduresOptions, Lazyable, MapInputMiddleware, MergedCurrentContext, MergedInitialContext, Middleware, ORPCErrorConstructorMap, Procedure, type ProcedureBuilder, type ProcedureBuilderWithInput, type ProcedureBuilderWithInputOutput, type ProcedureBuilderWithOutput, ProcedureClient, ProcedureHandler, type ProcedureImplementer, Router, type RouterBuilder, type RouterClient, type RouterImplementer, type RouterImplementerWithMiddlewares, type TraverseContractProceduresOptions, type UnlaziedRouter, addMiddleware, call, createAccessibleLazyRouter, createAssertedLazyProcedure, createContractedProcedure, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getHiddenRouterContract, getRouter, implement, implementerInternal, isStartWithMiddlewares, mergeMiddlewares, os, resolveContractProcedures, setHiddenRouterContract, toHttpPath, traverseContractProcedures, unlazyRouter };
291
+ export { type AccessibleLazyRouter, type ActionableClient, type ActionableClientRest, type ActionableClientResult, type ActionableError, AnyMiddleware, AnyProcedure, AnyRouter, Builder, type BuilderConfig, type BuilderDef, type BuilderWithMiddlewares, type Config, Context, type ContractProcedureCallbackOptions, CreateProcedureClientOptions, type DecoratedMiddleware, DecoratedProcedure, type EnhanceRouterOptions, type EnhancedRouter, type ImplementedProcedure, type Implementer, type ImplementerInternal, type ImplementerInternalWithMiddlewares, InferRouterInitialContext, Lazy, type LazyTraverseContractProceduresOptions, Lazyable, MapInputMiddleware, MergedCurrentContext, MergedInitialContext, Middleware, ORPCErrorConstructorMap, Procedure, type ProcedureActionableClient, type ProcedureBuilder, type ProcedureBuilderWithInput, type ProcedureBuilderWithInputOutput, type ProcedureBuilderWithOutput, ProcedureClient, ProcedureHandler, type ProcedureImplementer, Router, type RouterBuilder, type RouterClient, type RouterImplementer, type RouterImplementerWithMiddlewares, type TraverseContractProceduresOptions, type UnactionableError, type UnlaziedRouter, addMiddleware, call, createAccessibleLazyRouter, createActionableClient, createAssertedLazyProcedure, createContractedProcedure, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getHiddenRouterContract, getRouter, implement, implementerInternal, isStartWithMiddlewares, mergeMiddlewares, os, resolveContractProcedures, setHiddenRouterContract, traverseContractProcedures, unlazyRouter };
package/dist/index.mjs CHANGED
@@ -1,7 +1,8 @@
1
1
  import { mergeErrorMap, mergeMeta, mergeRoute, mergePrefix, mergeTags, isContractProcedure, getContractRouter } from '@orpc/contract';
2
2
  export { ValidationError, eventIterator, type } from '@orpc/contract';
3
- import { P as Procedure, d as addMiddleware, c as createProcedureClient, e as enhanceRouter, l as lazy, s as setHiddenRouterContract, i as isProcedure, f as isLazy, h as createAssertedLazyProcedure, g as getRouter } from './shared/server.BtxZnWJ9.mjs';
4
- export { L as LAZY_SYMBOL, q as call, w as createAccessibleLazyRouter, b as createContractedProcedure, j as createORPCErrorConstructorMap, r as getHiddenRouterContract, k as getLazyMeta, o as isStartWithMiddlewares, m as mergeCurrentContext, p as mergeMiddlewares, n as middlewareOutputFn, x as resolveContractProcedures, a as toHttpPath, t as traverseContractProcedures, u as unlazy, y as unlazyRouter, v as validateORPCError } from './shared/server.BtxZnWJ9.mjs';
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.e3W6AG3-.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.e3W6AG3-.mjs';
5
+ import { toORPCError } from '@orpc/client';
5
6
  export { ORPCError, isDefinedError, safe } from '@orpc/client';
6
7
  export { onError, onFinish, onStart, onSuccess } from '@orpc/shared';
7
8
  export { getEventMeta, withEventMeta } from '@orpc/standard-server';
@@ -44,6 +45,17 @@ function decorateMiddleware(middleware) {
44
45
  return decorated;
45
46
  }
46
47
 
48
+ function createActionableClient(client) {
49
+ const action = async (input) => {
50
+ try {
51
+ return [null, await client(input)];
52
+ } catch (error) {
53
+ return [toORPCError(error).toJSON(), void 0];
54
+ }
55
+ };
56
+ return action;
57
+ }
58
+
47
59
  class DecoratedProcedure extends Procedure {
48
60
  errors(errors) {
49
61
  return new DecoratedProcedure({
@@ -74,7 +86,8 @@ class DecoratedProcedure extends Procedure {
74
86
  * Make this procedure callable (works like a function while still being a procedure).
75
87
  */
76
88
  callable(...rest) {
77
- return new Proxy(createProcedureClient(this, ...rest), {
89
+ const client = createProcedureClient(this, ...rest);
90
+ return new Proxy(client, {
78
91
  get: (target, key) => {
79
92
  return Reflect.has(this, key) ? Reflect.get(this, key) : Reflect.get(target, key);
80
93
  },
@@ -84,10 +97,18 @@ class DecoratedProcedure extends Procedure {
84
97
  });
85
98
  }
86
99
  /**
87
- * Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
100
+ * Make this procedure compatible with server action.
88
101
  */
89
102
  actionable(...rest) {
90
- return this.callable(...rest);
103
+ const action = createActionableClient(createProcedureClient(this, ...rest));
104
+ return new Proxy(action, {
105
+ get: (target, key) => {
106
+ return Reflect.has(this, key) ? Reflect.get(this, key) : Reflect.get(target, key);
107
+ },
108
+ has: (target, key) => {
109
+ return Reflect.has(this, key) || Reflect.has(target, key);
110
+ }
111
+ });
91
112
  }
92
113
  }
93
114
 
@@ -339,4 +360,4 @@ function createRouterClient(router, ...[options]) {
339
360
  return recursive;
340
361
  }
341
362
 
342
- export { Builder, DecoratedProcedure, Procedure, addMiddleware, createAssertedLazyProcedure, createProcedureClient, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getRouter, implement, implementerInternal, isLazy, isProcedure, lazy, os, setHiddenRouterContract };
363
+ export { Builder, DecoratedProcedure, Procedure, addMiddleware, createActionableClient, createAssertedLazyProcedure, createProcedureClient, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getRouter, implement, implementerInternal, isLazy, isProcedure, lazy, os, setHiddenRouterContract };
@@ -1,9 +1,9 @@
1
- import { b as StandardHandlerInterceptorOptions, c as StandardHandlerPlugin, a as StandardHandlerOptions } from '../shared/server.DJqfB27m.mjs';
1
+ import { b as StandardHandlerInterceptorOptions, c as StandardHandlerPlugin, a as StandardHandlerOptions } from '../shared/server.BUBtakoQ.mjs';
2
2
  import { Value } from '@orpc/shared';
3
- import { C as Context } from '../shared/server.MZvbGc3n.mjs';
3
+ import { C as Context } from '../shared/server.CYBq7eu_.mjs';
4
+ import '@orpc/client';
4
5
  import '@orpc/contract';
5
6
  import '@orpc/standard-server';
6
- import '@orpc/client';
7
7
 
8
8
  interface CORSOptions<T extends Context> {
9
9
  origin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
@@ -1,9 +1,9 @@
1
- import { b as StandardHandlerInterceptorOptions, c as StandardHandlerPlugin, a as StandardHandlerOptions } from '../shared/server.23VRZIfj.js';
1
+ import { b as StandardHandlerInterceptorOptions, c as StandardHandlerPlugin, a as StandardHandlerOptions } from '../shared/server.DRYXuxQn.js';
2
2
  import { Value } from '@orpc/shared';
3
- import { C as Context } from '../shared/server.MZvbGc3n.js';
3
+ import { C as Context } from '../shared/server.CYBq7eu_.js';
4
+ import '@orpc/client';
4
5
  import '@orpc/contract';
5
6
  import '@orpc/standard-server';
6
- import '@orpc/client';
7
7
 
8
8
  interface CORSOptions<T extends Context> {
9
9
  origin?: Value<string | readonly string[] | null | undefined, [origin: string, options: StandardHandlerInterceptorOptions<T>]>;
@@ -78,14 +78,19 @@ class ResponseHeadersPlugin {
78
78
  init(options) {
79
79
  options.rootInterceptors ??= [];
80
80
  options.rootInterceptors.push(async (interceptorOptions) => {
81
- const headers = new Headers();
82
- interceptorOptions.context.resHeaders = headers;
83
- const result = await interceptorOptions.next();
81
+ const resHeaders = interceptorOptions.context.resHeaders ?? new Headers();
82
+ const result = await interceptorOptions.next({
83
+ ...interceptorOptions,
84
+ context: {
85
+ ...interceptorOptions.context,
86
+ resHeaders
87
+ }
88
+ });
84
89
  if (!result.matched) {
85
90
  return result;
86
91
  }
87
92
  const responseHeaders = result.response.headers;
88
- for (const [key, value] of headers) {
93
+ for (const [key, value] of resHeaders) {
89
94
  if (Array.isArray(responseHeaders[key])) {
90
95
  responseHeaders[key].push(value);
91
96
  } else if (responseHeaders[key] !== void 0) {
@@ -1,5 +1,5 @@
1
- import { C as Context } from './server.MZvbGc3n.js';
2
- import { S as StandardHandleOptions } from './server.23VRZIfj.js';
1
+ import { C as Context } from './server.CYBq7eu_.js';
2
+ import { S as StandardHandleOptions } from './server.DRYXuxQn.js';
3
3
 
4
4
  type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
5
5
  context?: T;
@@ -1,8 +1,8 @@
1
- import { HTTPPath, AnySchema, Meta, InferSchemaOutput, ErrorFromErrorMap } from '@orpc/contract';
2
- import { Interceptor } from '@orpc/shared';
1
+ import { HTTPPath, ORPCError } from '@orpc/client';
2
+ import { Meta, InferSchemaOutput, AnySchema, ErrorFromErrorMap } from '@orpc/contract';
3
+ import { Interceptor, ThrowableError } from '@orpc/shared';
3
4
  import { StandardResponse, StandardLazyRequest } from '@orpc/standard-server';
4
- import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.MZvbGc3n.mjs';
5
- import { ORPCError } from '@orpc/client';
5
+ import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.CYBq7eu_.mjs';
6
6
 
7
7
  type StandardParams = Record<string, string>;
8
8
  type StandardMatchResult = {
@@ -42,16 +42,16 @@ interface StandardHandlerOptions<TContext extends Context> {
42
42
  /**
43
43
  * Interceptors at the request level, helpful when you want catch errors
44
44
  */
45
- interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
45
+ interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, ThrowableError>[];
46
46
  /**
47
47
  * Interceptors at the root level, helpful when you want override the request/response
48
48
  */
49
- rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
49
+ rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, ThrowableError>[];
50
50
  /**
51
51
  *
52
52
  * Interceptors for procedure client.
53
53
  */
54
- clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, AnySchema, Record<never, never>, Meta>, InferSchemaOutput<AnySchema>, ErrorFromErrorMap<Record<never, never>>>[];
54
+ clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>, InferSchemaOutput<AnySchema>, ErrorFromErrorMap<Record<never, never>>>[];
55
55
  }
56
56
  declare class StandardHandler<T extends Context> {
57
57
  private readonly matcher;
@@ -1,6 +1,6 @@
1
1
  import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
2
- import { C as Context } from './server.MZvbGc3n.mjs';
3
- import { a as StandardHandlerOptions } from './server.DJqfB27m.mjs';
2
+ import { C as Context } from './server.CYBq7eu_.mjs';
3
+ import { a as StandardHandlerOptions } from './server.BUBtakoQ.mjs';
4
4
 
5
5
  interface StandardRPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardRPCJsonSerializerOptions {
6
6
  }
@@ -1,6 +1,6 @@
1
- import { ORPCErrorCode, ORPCErrorOptions, ORPCError, ClientContext, Client } from '@orpc/client';
1
+ import { ORPCErrorCode, ORPCErrorOptions, ORPCError, HTTPPath, ClientContext, Client } from '@orpc/client';
2
2
  import { MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
3
- import { ErrorMap, ErrorMapItem, InferSchemaInput, HTTPPath, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@orpc/contract';
3
+ import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@orpc/contract';
4
4
 
5
5
  type Context = Record<string, any>;
6
6
  type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
@@ -97,9 +97,9 @@ interface MapInputMiddleware<TInput, TMappedInput> {
97
97
  declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
98
98
 
99
99
  type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
100
- interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TInputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
100
+ interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
101
101
  context: TInitialContext;
102
- input: InferSchemaInput<TInputSchema>;
102
+ input: unknown;
103
103
  errors: ORPCErrorConstructorMap<TErrorMap>;
104
104
  path: readonly string[];
105
105
  procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
@@ -109,18 +109,18 @@ interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TIn
109
109
  /**
110
110
  * Options for creating a procedure caller with comprehensive type safety
111
111
  */
112
- type CreateProcedureClientOptions<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
112
+ type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
113
113
  /**
114
114
  * This is helpful for logging and analytics.
115
115
  */
116
116
  path?: readonly string[];
117
- interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TInputSchema, TErrorMap, TMeta>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>[];
117
+ interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TErrorMap, TMeta>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>[];
118
118
  } & (Record<never, never> extends TInitialContext ? {
119
119
  context?: Value<TInitialContext, [clientContext: TClientContext]>;
120
120
  } : {
121
121
  context: Value<TInitialContext, [clientContext: TClientContext]>;
122
122
  });
123
- declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
123
+ declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
124
124
 
125
125
  type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, UInputSchema, UOutputSchema, UErrorMap, UMeta> : {
126
126
  [K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
@@ -1,6 +1,6 @@
1
- import { ORPCErrorCode, ORPCErrorOptions, ORPCError, ClientContext, Client } from '@orpc/client';
1
+ import { ORPCErrorCode, ORPCErrorOptions, ORPCError, HTTPPath, ClientContext, Client } from '@orpc/client';
2
2
  import { MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
3
- import { ErrorMap, ErrorMapItem, InferSchemaInput, HTTPPath, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@orpc/contract';
3
+ import { ErrorMap, ErrorMapItem, InferSchemaInput, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@orpc/contract';
4
4
 
5
5
  type Context = Record<string, any>;
6
6
  type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
@@ -97,9 +97,9 @@ interface MapInputMiddleware<TInput, TMappedInput> {
97
97
  declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
98
98
 
99
99
  type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
100
- interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TInputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
100
+ interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
101
101
  context: TInitialContext;
102
- input: InferSchemaInput<TInputSchema>;
102
+ input: unknown;
103
103
  errors: ORPCErrorConstructorMap<TErrorMap>;
104
104
  path: readonly string[];
105
105
  procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
@@ -109,18 +109,18 @@ interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TIn
109
109
  /**
110
110
  * Options for creating a procedure caller with comprehensive type safety
111
111
  */
112
- type CreateProcedureClientOptions<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
112
+ type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
113
113
  /**
114
114
  * This is helpful for logging and analytics.
115
115
  */
116
116
  path?: readonly string[];
117
- interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TInputSchema, TErrorMap, TMeta>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>[];
117
+ interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TErrorMap, TMeta>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>[];
118
118
  } & (Record<never, never> extends TInitialContext ? {
119
119
  context?: Value<TInitialContext, [clientContext: TClientContext]>;
120
120
  } : {
121
121
  context: Value<TInitialContext, [clientContext: TClientContext]>;
122
122
  });
123
- declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
123
+ declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
124
124
 
125
125
  type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, UInputSchema, UOutputSchema, UErrorMap, UMeta> : {
126
126
  [K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
@@ -1,5 +1,5 @@
1
- import { C as Context } from './server.MZvbGc3n.mjs';
2
- import { S as StandardHandleOptions } from './server.DJqfB27m.mjs';
1
+ import { C as Context } from './server.CYBq7eu_.mjs';
2
+ import { S as StandardHandleOptions } from './server.BUBtakoQ.mjs';
3
3
 
4
4
  type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
5
5
  context?: T;
@@ -1,8 +1,8 @@
1
- import { HTTPPath, AnySchema, Meta, InferSchemaOutput, ErrorFromErrorMap } from '@orpc/contract';
2
- import { Interceptor } from '@orpc/shared';
1
+ import { HTTPPath, ORPCError } from '@orpc/client';
2
+ import { Meta, InferSchemaOutput, AnySchema, ErrorFromErrorMap } from '@orpc/contract';
3
+ import { Interceptor, ThrowableError } from '@orpc/shared';
3
4
  import { StandardResponse, StandardLazyRequest } from '@orpc/standard-server';
4
- import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.MZvbGc3n.js';
5
- import { ORPCError } from '@orpc/client';
5
+ import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.CYBq7eu_.js';
6
6
 
7
7
  type StandardParams = Record<string, string>;
8
8
  type StandardMatchResult = {
@@ -42,16 +42,16 @@ interface StandardHandlerOptions<TContext extends Context> {
42
42
  /**
43
43
  * Interceptors at the request level, helpful when you want catch errors
44
44
  */
45
- interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
45
+ interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, ThrowableError>[];
46
46
  /**
47
47
  * Interceptors at the root level, helpful when you want override the request/response
48
48
  */
49
- rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
49
+ rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, ThrowableError>[];
50
50
  /**
51
51
  *
52
52
  * Interceptors for procedure client.
53
53
  */
54
- clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, AnySchema, Record<never, never>, Meta>, InferSchemaOutput<AnySchema>, ErrorFromErrorMap<Record<never, never>>>[];
54
+ clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>, InferSchemaOutput<AnySchema>, ErrorFromErrorMap<Record<never, never>>>[];
55
55
  }
56
56
  declare class StandardHandler<T extends Context> {
57
57
  private readonly matcher;
@@ -1,6 +1,7 @@
1
1
  import { ORPCError, toORPCError } from '@orpc/client';
2
- import { toArray, intercept, trim, parseEmptyableJSON } from '@orpc/shared';
3
- import { c as createProcedureClient, t as traverseContractProcedures, a as toHttpPath, i as isProcedure, u as unlazy, g as getRouter, b as createContractedProcedure } from './server.BtxZnWJ9.mjs';
2
+ import { toArray, intercept, parseEmptyableJSON } from '@orpc/shared';
3
+ import { c as createProcedureClient, t as traverseContractProcedures, i as isProcedure, u as unlazy, g as getRouter, a as createContractedProcedure } from './server.e3W6AG3-.mjs';
4
+ import { toHttpPath } from '@orpc/client/standard';
4
5
 
5
6
  class StandardHandler {
6
7
  constructor(router, matcher, codec, options) {
@@ -30,8 +31,11 @@ class StandardHandler {
30
31
  async ({ request: request2, context, prefix }) => {
31
32
  const method = request2.method;
32
33
  const url = request2.url;
33
- const pathname = `/${trim(url.pathname.replace(prefix ?? "", ""), "/")}`;
34
- const match = await this.matcher.match(method, pathname);
34
+ if (prefix && !url.pathname.startsWith(prefix)) {
35
+ return { matched: false, response: void 0 };
36
+ }
37
+ const pathname = prefix ? url.pathname.replace(prefix, "") : url.pathname;
38
+ const match = await this.matcher.match(method, `/${pathname.replace(/^\/|\/$/g, "")}`);
35
39
  if (!match) {
36
40
  return { matched: false, response: void 0 };
37
41
  }
@@ -1,6 +1,6 @@
1
1
  import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
2
- import { C as Context } from './server.MZvbGc3n.js';
3
- import { a as StandardHandlerOptions } from './server.23VRZIfj.js';
2
+ import { C as Context } from './server.CYBq7eu_.js';
3
+ import { a as StandardHandlerOptions } from './server.DRYXuxQn.js';
4
4
 
5
5
  interface StandardRPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardRPCJsonSerializerOptions {
6
6
  }
@@ -1,9 +1,56 @@
1
+ import { ORPCError } from '@orpc/client';
1
2
  import { StandardRPCJsonSerializer, StandardRPCSerializer } from '@orpc/client/standard';
2
- import { S as StandardHandler, b as StandardRPCMatcher, a as StandardRPCCodec } from './server.CVNC_Jz8.mjs';
3
+ import { S as StandardHandler, b as StandardRPCMatcher, a as StandardRPCCodec } from './server.Dfx1jV-K.mjs';
3
4
  import { toArray, intercept, resolveMaybeOptionalOptions } from '@orpc/shared';
4
5
  import { toStandardLazyRequest, toFetchResponse } from '@orpc/standard-server-fetch';
5
6
  import { r as resolveFriendlyStandardHandleOptions } from './server.BVwwTHyO.mjs';
6
7
 
8
+ class BodyLimitPlugin {
9
+ maxBodySize;
10
+ constructor(options) {
11
+ this.maxBodySize = options.maxBodySize;
12
+ }
13
+ initRuntimeAdapter(options) {
14
+ options.adapterInterceptors ??= [];
15
+ options.adapterInterceptors.push(async (options2) => {
16
+ if (!options2.request.body) {
17
+ return options2.next();
18
+ }
19
+ let currentBodySize = 0;
20
+ const rawReader = options2.request.body.getReader();
21
+ const reader = new ReadableStream({
22
+ start: async (controller) => {
23
+ try {
24
+ if (Number(options2.request.headers.get("content-length")) > this.maxBodySize) {
25
+ controller.error(new ORPCError("PAYLOAD_TOO_LARGE"));
26
+ return;
27
+ }
28
+ while (true) {
29
+ const { done, value } = await rawReader.read();
30
+ if (done) {
31
+ break;
32
+ }
33
+ currentBodySize += value.length;
34
+ if (currentBodySize > this.maxBodySize) {
35
+ controller.error(new ORPCError("PAYLOAD_TOO_LARGE"));
36
+ break;
37
+ }
38
+ controller.enqueue(value);
39
+ }
40
+ } finally {
41
+ controller.close();
42
+ }
43
+ }
44
+ });
45
+ const requestInit = { body: reader, duplex: "half" };
46
+ return options2.next({
47
+ ...options2,
48
+ request: new Request(options2.request, requestInit)
49
+ });
50
+ });
51
+ }
52
+ }
53
+
7
54
  class FetchHandler {
8
55
  constructor(standardHandler, options = {}) {
9
56
  this.standardHandler = standardHandler;
@@ -48,4 +95,4 @@ class RPCHandler extends FetchHandler {
48
95
  }
49
96
  }
50
97
 
51
- export { FetchHandler as F, RPCHandler as R };
98
+ export { BodyLimitPlugin as B, FetchHandler as F, RPCHandler as R };
@@ -1,6 +1,6 @@
1
1
  import { isContractProcedure, ValidationError, mergePrefix, mergeErrorMap, enhanceRoute } from '@orpc/contract';
2
2
  import { fallbackORPCErrorStatus, ORPCError } from '@orpc/client';
3
- import { value, intercept, toError } from '@orpc/shared';
3
+ import { value, intercept } from '@orpc/shared';
4
4
 
5
5
  const LAZY_SYMBOL = Symbol("ORPC_LAZY_SYMBOL");
6
6
  function lazy(loader, meta = {}) {
@@ -127,7 +127,7 @@ function createProcedureClient(lazyableProcedure, ...[options]) {
127
127
  );
128
128
  } catch (e) {
129
129
  if (!(e instanceof ORPCError)) {
130
- throw toError(e);
130
+ throw e;
131
131
  }
132
132
  const validated = await validateORPCError(procedure["~orpc"].errorMap, e);
133
133
  throw validated;
@@ -367,8 +367,4 @@ function call(procedure, input, ...rest) {
367
367
  return createProcedureClient(procedure, ...rest)(input);
368
368
  }
369
369
 
370
- function toHttpPath(path) {
371
- return `/${path.map(encodeURIComponent).join("/")}`;
372
- }
373
-
374
- export { LAZY_SYMBOL as L, Procedure as P, toHttpPath as a, createContractedProcedure as b, createProcedureClient as c, addMiddleware as d, enhanceRouter as e, isLazy as f, getRouter as g, createAssertedLazyProcedure as h, isProcedure as i, createORPCErrorConstructorMap as j, getLazyMeta as k, lazy as l, mergeCurrentContext as m, middlewareOutputFn as n, isStartWithMiddlewares as o, mergeMiddlewares as p, call as q, getHiddenRouterContract as r, setHiddenRouterContract as s, traverseContractProcedures as t, unlazy as u, validateORPCError as v, createAccessibleLazyRouter as w, resolveContractProcedures as x, unlazyRouter as y };
370
+ export { LAZY_SYMBOL as L, Procedure as P, createContractedProcedure as a, addMiddleware as b, createProcedureClient as c, isLazy as d, enhanceRouter as e, createAssertedLazyProcedure as f, getRouter as g, createORPCErrorConstructorMap as h, isProcedure as i, getLazyMeta as j, middlewareOutputFn as k, lazy as l, mergeCurrentContext as m, isStartWithMiddlewares as n, mergeMiddlewares as o, call as p, getHiddenRouterContract as q, createAccessibleLazyRouter as r, setHiddenRouterContract as s, traverseContractProcedures as t, unlazy as u, validateORPCError as v, resolveContractProcedures as w, unlazyRouter as x };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/server",
3
3
  "type": "module",
4
- "version": "0.0.0-next.d17ef5e",
4
+ "version": "0.0.0-next.d1f8ea3",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -58,12 +58,12 @@
58
58
  "next": ">=14.0.0"
59
59
  },
60
60
  "dependencies": {
61
- "@orpc/client": "0.0.0-next.d17ef5e",
62
- "@orpc/standard-server": "0.0.0-next.d17ef5e",
63
- "@orpc/contract": "0.0.0-next.d17ef5e",
64
- "@orpc/standard-server-fetch": "0.0.0-next.d17ef5e",
65
- "@orpc/standard-server-node": "0.0.0-next.d17ef5e",
66
- "@orpc/shared": "0.0.0-next.d17ef5e"
61
+ "@orpc/shared": "0.0.0-next.d1f8ea3",
62
+ "@orpc/contract": "0.0.0-next.d1f8ea3",
63
+ "@orpc/standard-server": "0.0.0-next.d1f8ea3",
64
+ "@orpc/standard-server-fetch": "0.0.0-next.d1f8ea3",
65
+ "@orpc/client": "0.0.0-next.d1f8ea3",
66
+ "@orpc/standard-server-node": "0.0.0-next.d1f8ea3"
67
67
  },
68
68
  "devDependencies": {
69
69
  "supertest": "^7.0.0"