@orpc/server 0.43.0 → 0.45.0

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 (80) hide show
  1. package/README.md +1 -1
  2. package/dist/adapters/fetch/index.d.mts +27 -0
  3. package/dist/adapters/fetch/index.d.ts +27 -0
  4. package/dist/adapters/fetch/index.mjs +9 -0
  5. package/dist/adapters/hono/index.d.mts +20 -0
  6. package/dist/adapters/hono/index.d.ts +20 -0
  7. package/dist/{hono.js → adapters/hono/index.mjs} +11 -13
  8. package/dist/adapters/next/index.d.mts +27 -0
  9. package/dist/adapters/next/index.d.ts +27 -0
  10. package/dist/{next.js → adapters/next/index.mjs} +11 -13
  11. package/dist/adapters/node/index.d.mts +35 -0
  12. package/dist/adapters/node/index.d.ts +35 -0
  13. package/dist/adapters/node/index.mjs +28 -0
  14. package/dist/adapters/standard/index.d.mts +29 -0
  15. package/dist/adapters/standard/index.d.ts +29 -0
  16. package/dist/adapters/standard/index.mjs +7 -0
  17. package/dist/index.d.mts +255 -0
  18. package/dist/index.d.ts +255 -0
  19. package/dist/{index.js → index.mjs} +33 -113
  20. package/dist/plugins/index.d.mts +31 -0
  21. package/dist/plugins/index.d.ts +31 -0
  22. package/dist/{chunk-TXHKQO7N.js → plugins/index.mjs} +11 -28
  23. package/dist/{chunk-TV5DRAST.js → shared/server.BBGuTxHE.mjs} +12 -31
  24. package/dist/shared/server.B_cAGti1.d.mts +9 -0
  25. package/dist/{chunk-WDY5PTME.js → shared/server.CUE4Aija.mjs} +8 -16
  26. package/dist/shared/server.Cn9ybJtE.d.mts +152 -0
  27. package/dist/shared/server.Cn9ybJtE.d.ts +152 -0
  28. package/dist/shared/server.CynXWJja.d.ts +9 -0
  29. package/dist/shared/server.D86dtDX_.d.mts +77 -0
  30. package/dist/shared/server.Q6ZmnTgO.mjs +12 -0
  31. package/dist/{chunk-MHVECKBC.js → shared/server.V6zT5iYQ.mjs} +48 -90
  32. package/dist/shared/server.dPmfqnQI.d.ts +77 -0
  33. package/package.json +29 -34
  34. package/dist/fetch.js +0 -10
  35. package/dist/node.js +0 -31
  36. package/dist/plugins.js +0 -11
  37. package/dist/src/adapters/fetch/index.d.ts +0 -3
  38. package/dist/src/adapters/fetch/rpc-handler.d.ts +0 -11
  39. package/dist/src/adapters/fetch/types.d.ts +0 -14
  40. package/dist/src/adapters/hono/index.d.ts +0 -3
  41. package/dist/src/adapters/hono/middleware.d.ts +0 -12
  42. package/dist/src/adapters/next/index.d.ts +0 -3
  43. package/dist/src/adapters/next/serve.d.ts +0 -19
  44. package/dist/src/adapters/node/index.d.ts +0 -3
  45. package/dist/src/adapters/node/rpc-handler.d.ts +0 -11
  46. package/dist/src/adapters/node/types.d.ts +0 -22
  47. package/dist/src/adapters/standard/handler.d.ts +0 -53
  48. package/dist/src/adapters/standard/index.d.ts +0 -6
  49. package/dist/src/adapters/standard/rpc-codec.d.ts +0 -16
  50. package/dist/src/adapters/standard/rpc-handler.d.ts +0 -8
  51. package/dist/src/adapters/standard/rpc-matcher.d.ts +0 -10
  52. package/dist/src/adapters/standard/types.d.ts +0 -21
  53. package/dist/src/builder-variants.d.ts +0 -75
  54. package/dist/src/builder.d.ts +0 -58
  55. package/dist/src/config.d.ts +0 -6
  56. package/dist/src/context.d.ts +0 -8
  57. package/dist/src/error.d.ts +0 -12
  58. package/dist/src/hidden.d.ts +0 -8
  59. package/dist/src/implementer-procedure.d.ts +0 -33
  60. package/dist/src/implementer-variants.d.ts +0 -18
  61. package/dist/src/implementer.d.ts +0 -29
  62. package/dist/src/index.d.ts +0 -25
  63. package/dist/src/lazy-utils.d.ts +0 -6
  64. package/dist/src/lazy.d.ts +0 -22
  65. package/dist/src/middleware-decorated.d.ts +0 -11
  66. package/dist/src/middleware-utils.d.ts +0 -5
  67. package/dist/src/middleware.d.ts +0 -38
  68. package/dist/src/plugins/base.d.ts +0 -11
  69. package/dist/src/plugins/cors.d.ts +0 -19
  70. package/dist/src/plugins/index.d.ts +0 -4
  71. package/dist/src/plugins/response-headers.d.ts +0 -10
  72. package/dist/src/procedure-client.d.ts +0 -33
  73. package/dist/src/procedure-decorated.d.ts +0 -24
  74. package/dist/src/procedure-utils.d.ts +0 -19
  75. package/dist/src/procedure.d.ts +0 -31
  76. package/dist/src/router-accessible-lazy.d.ts +0 -8
  77. package/dist/src/router-client.d.ts +0 -12
  78. package/dist/src/router.d.ts +0 -30
  79. package/dist/src/utils.d.ts +0 -24
  80. package/dist/standard.js +0 -13
@@ -0,0 +1,77 @@
1
+ import { HTTPPath, Schema, Meta, SchemaOutput, ErrorFromErrorMap } from '@orpc/contract';
2
+ import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
3
+ import { StandardResponse, StandardRequest } from '@orpc/standard-server';
4
+ import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.Cn9ybJtE.js';
5
+ import { ORPCError } from '@orpc/client';
6
+
7
+ type StandardParams = Record<string, string>;
8
+ type StandardMatchResult = {
9
+ path: string[];
10
+ procedure: AnyProcedure;
11
+ params?: StandardParams;
12
+ } | undefined;
13
+ interface StandardMatcher {
14
+ init(router: AnyRouter): void;
15
+ match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
16
+ }
17
+ interface StandardCodec {
18
+ encode(output: unknown, procedure: AnyProcedure): StandardResponse;
19
+ encodeError(error: ORPCError<any, any>): StandardResponse;
20
+ decode(request: StandardRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
21
+ }
22
+
23
+ type StandardHandleOptions<T extends Context> = {
24
+ prefix?: HTTPPath;
25
+ } & (Record<never, never> extends T ? {
26
+ context?: T;
27
+ } : {
28
+ context: T;
29
+ });
30
+ type WellStandardHandleOptions<T extends Context> = StandardHandleOptions<T> & {
31
+ context: T;
32
+ };
33
+ type StandardHandleResult = {
34
+ matched: true;
35
+ response: StandardResponse;
36
+ } | {
37
+ matched: false;
38
+ response: undefined;
39
+ };
40
+ type StandardHandlerInterceptorOptions<TContext extends Context> = WellStandardHandleOptions<TContext> & {
41
+ request: StandardRequest;
42
+ };
43
+ interface StandardHandlerOptions<TContext extends Context> {
44
+ plugins?: Plugin<TContext>[];
45
+ /**
46
+ * Interceptors at the request level, helpful when you want catch errors
47
+ */
48
+ interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
49
+ /**
50
+ * Interceptors at the root level, helpful when you want override the request/response
51
+ */
52
+ rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
53
+ /**
54
+ *
55
+ * Interceptors for procedure client.
56
+ */
57
+ clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Schema, Record<never, never>, Meta>, SchemaOutput<Schema, unknown>, ErrorFromErrorMap<Record<never, never>>>[];
58
+ }
59
+ declare class StandardHandler<T extends Context> {
60
+ private readonly matcher;
61
+ private readonly codec;
62
+ private readonly options;
63
+ private readonly plugin;
64
+ constructor(router: Router<T, any>, matcher: StandardMatcher, codec: StandardCodec, options?: NoInfer<StandardHandlerOptions<T>>);
65
+ handle(request: StandardRequest, ...[options]: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<StandardHandleResult>;
66
+ }
67
+
68
+ interface Plugin<TContext extends Context> {
69
+ init?(options: StandardHandlerOptions<TContext>): void;
70
+ }
71
+ declare class CompositePlugin<TContext extends Context> implements Plugin<TContext> {
72
+ private readonly plugins;
73
+ constructor(plugins?: Plugin<TContext>[]);
74
+ init(options: StandardHandlerOptions<TContext>): void;
75
+ }
76
+
77
+ export { CompositePlugin as C, type Plugin as P, type StandardHandleOptions as S, type WellStandardHandleOptions as W, type StandardHandlerOptions as a, type StandardMatcher as b, type StandardCodec as c, type StandardHandlerInterceptorOptions as d, type StandardParams as e, type StandardMatchResult as f, type StandardHandleResult as g, StandardHandler as h };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@orpc/server",
3
3
  "type": "module",
4
- "version": "0.43.0",
4
+ "version": "0.45.0",
5
5
  "license": "MIT",
6
6
  "homepage": "https://orpc.unnoq.com",
7
7
  "repository": {
@@ -15,47 +15,42 @@
15
15
  ],
16
16
  "exports": {
17
17
  ".": {
18
- "types": "./dist/src/index.d.ts",
19
- "import": "./dist/index.js",
20
- "default": "./dist/index.js"
18
+ "types": "./dist/index.d.mts",
19
+ "import": "./dist/index.mjs",
20
+ "default": "./dist/index.mjs"
21
21
  },
22
22
  "./plugins": {
23
- "types": "./dist/src/plugins/index.d.ts",
24
- "import": "./dist/plugins.js",
25
- "default": "./dist/plugins.js"
23
+ "types": "./dist/plugins/index.d.mts",
24
+ "import": "./dist/plugins/index.mjs",
25
+ "default": "./dist/plugins/index.mjs"
26
26
  },
27
27
  "./standard": {
28
- "types": "./dist/src/adapters/standard/index.d.ts",
29
- "import": "./dist/standard.js",
30
- "default": "./dist/standard.js"
28
+ "types": "./dist/adapters/standard/index.d.mts",
29
+ "import": "./dist/adapters/standard/index.mjs",
30
+ "default": "./dist/adapters/standard/index.mjs"
31
31
  },
32
32
  "./fetch": {
33
- "types": "./dist/src/adapters/fetch/index.d.ts",
34
- "import": "./dist/fetch.js",
35
- "default": "./dist/fetch.js"
33
+ "types": "./dist/adapters/fetch/index.d.mts",
34
+ "import": "./dist/adapters/fetch/index.mjs",
35
+ "default": "./dist/adapters/fetch/index.mjs"
36
36
  },
37
37
  "./hono": {
38
- "types": "./dist/src/adapters/hono/index.d.ts",
39
- "import": "./dist/hono.js",
40
- "default": "./dist/hono.js"
38
+ "types": "./dist/adapters/hono/index.d.mts",
39
+ "import": "./dist/adapters/hono/index.mjs",
40
+ "default": "./dist/adapters/hono/index.mjs"
41
41
  },
42
42
  "./next": {
43
- "types": "./dist/src/adapters/next/index.d.ts",
44
- "import": "./dist/next.js",
45
- "default": "./dist/next.js"
43
+ "types": "./dist/adapters/next/index.d.mts",
44
+ "import": "./dist/adapters/next/index.mjs",
45
+ "default": "./dist/adapters/next/index.mjs"
46
46
  },
47
47
  "./node": {
48
- "types": "./dist/src/adapters/node/index.d.ts",
49
- "import": "./dist/node.js",
50
- "default": "./dist/node.js"
51
- },
52
- "./🔒/*": {
53
- "types": "./dist/src/*.d.ts"
48
+ "types": "./dist/adapters/node/index.d.mts",
49
+ "import": "./dist/adapters/node/index.mjs",
50
+ "default": "./dist/adapters/node/index.mjs"
54
51
  }
55
52
  },
56
53
  "files": [
57
- "!**/*.map",
58
- "!**/*.tsbuildinfo",
59
54
  "dist"
60
55
  ],
61
56
  "peerDependencies": {
@@ -63,18 +58,18 @@
63
58
  "next": ">=14.0.0"
64
59
  },
65
60
  "dependencies": {
66
- "@orpc/client": "0.43.0",
67
- "@orpc/shared": "0.43.0",
68
- "@orpc/contract": "0.43.0",
69
- "@orpc/standard-server-fetch": "0.43.0",
70
- "@orpc/standard-server-node": "0.43.0",
71
- "@orpc/standard-server": "0.43.0"
61
+ "@orpc/client": "0.45.0",
62
+ "@orpc/contract": "0.45.0",
63
+ "@orpc/shared": "0.45.0",
64
+ "@orpc/standard-server": "0.45.0",
65
+ "@orpc/standard-server-node": "0.45.0",
66
+ "@orpc/standard-server-fetch": "0.45.0"
72
67
  },
73
68
  "devDependencies": {
74
69
  "light-my-request": "^6.5.1"
75
70
  },
76
71
  "scripts": {
77
- "build": "tsup --onSuccess='tsc -b --noCheck'",
72
+ "build": "unbuild",
78
73
  "build:watch": "pnpm run build --watch",
79
74
  "type:check": "tsc -b"
80
75
  }
package/dist/fetch.js DELETED
@@ -1,10 +0,0 @@
1
- import {
2
- RPCHandler
3
- } from "./chunk-WDY5PTME.js";
4
- import "./chunk-TV5DRAST.js";
5
- import "./chunk-MHVECKBC.js";
6
- import "./chunk-TXHKQO7N.js";
7
- export {
8
- RPCHandler
9
- };
10
- //# sourceMappingURL=fetch.js.map
package/dist/node.js DELETED
@@ -1,31 +0,0 @@
1
- import {
2
- RPCCodec,
3
- RPCMatcher,
4
- StandardHandler
5
- } from "./chunk-TV5DRAST.js";
6
- import "./chunk-MHVECKBC.js";
7
- import "./chunk-TXHKQO7N.js";
8
-
9
- // src/adapters/node/rpc-handler.ts
10
- import { sendStandardResponse, toStandardRequest } from "@orpc/standard-server-node";
11
- var RPCHandler = class {
12
- standardHandler;
13
- constructor(router, options) {
14
- const codec = options?.codec ?? new RPCCodec();
15
- const matcher = options?.matcher ?? new RPCMatcher();
16
- this.standardHandler = new StandardHandler(router, matcher, codec, options);
17
- }
18
- async handle(req, res, ...rest) {
19
- const standardRequest = toStandardRequest(req, res);
20
- const result = await this.standardHandler.handle(standardRequest, ...rest);
21
- if (!result.matched) {
22
- return { matched: false };
23
- }
24
- await sendStandardResponse(res, result.response);
25
- return { matched: true };
26
- }
27
- };
28
- export {
29
- RPCHandler
30
- };
31
- //# sourceMappingURL=node.js.map
package/dist/plugins.js DELETED
@@ -1,11 +0,0 @@
1
- import {
2
- CORSPlugin,
3
- CompositePlugin,
4
- ResponseHeadersPlugin
5
- } from "./chunk-TXHKQO7N.js";
6
- export {
7
- CORSPlugin,
8
- CompositePlugin,
9
- ResponseHeadersPlugin
10
- };
11
- //# sourceMappingURL=plugins.js.map
@@ -1,3 +0,0 @@
1
- export * from './rpc-handler';
2
- export * from './types';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,11 +0,0 @@
1
- import type { MaybeOptionalOptions } from '@orpc/shared';
2
- import type { Context } from '../../context';
3
- import type { Router } from '../../router';
4
- import type { RPCHandlerOptions, StandardHandleOptions } from '../standard';
5
- import type { FetchHandler, FetchHandleResult } from './types';
6
- export declare class RPCHandler<T extends Context> implements FetchHandler<T> {
7
- private readonly standardHandler;
8
- constructor(router: Router<T, any>, options?: NoInfer<RPCHandlerOptions<T>>);
9
- handle(request: Request, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<FetchHandleResult>;
10
- }
11
- //# sourceMappingURL=rpc-handler.d.ts.map
@@ -1,14 +0,0 @@
1
- import type { MaybeOptionalOptions } from '@orpc/shared';
2
- import type { Context } from '../../context';
3
- import type { StandardHandleOptions } from '../standard';
4
- export type FetchHandleResult = {
5
- matched: true;
6
- response: Response;
7
- } | {
8
- matched: false;
9
- response: undefined;
10
- };
11
- export interface FetchHandler<T extends Context> {
12
- handle(request: Request, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<FetchHandleResult>;
13
- }
14
- //# sourceMappingURL=types.d.ts.map
@@ -1,3 +0,0 @@
1
- export * from '../fetch';
2
- export * from './middleware';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,12 +0,0 @@
1
- import type { MaybeOptionalOptions, Value } from '@orpc/shared';
2
- import type { Context as HonoContext, MiddlewareHandler } from 'hono';
3
- import type { Context } from '../../context';
4
- import type { FetchHandler } from '../fetch';
5
- import type { StandardHandleOptions } from '../standard';
6
- export type CreateMiddlewareOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
7
- context?: Value<T, [HonoContext]>;
8
- } : {
9
- context: Value<T, [HonoContext]>;
10
- });
11
- export declare function createMiddleware<T extends Context>(handler: FetchHandler<T>, ...[options]: MaybeOptionalOptions<CreateMiddlewareOptions<T>>): MiddlewareHandler;
12
- //# sourceMappingURL=middleware.d.ts.map
@@ -1,3 +0,0 @@
1
- export * from '../fetch';
2
- export * from './serve';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,19 +0,0 @@
1
- import type { MaybeOptionalOptions, Value } from '@orpc/shared';
2
- import type { NextRequest } from 'next/server';
3
- import type { Context } from '../../context';
4
- import type { FetchHandler } from '../fetch';
5
- import type { StandardHandleOptions } from '../standard';
6
- export type ServeOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
7
- context?: Value<T, [NextRequest]>;
8
- } : {
9
- context: Value<T, [NextRequest]>;
10
- });
11
- export interface ServeResult {
12
- GET(req: NextRequest): Promise<Response>;
13
- POST(req: NextRequest): Promise<Response>;
14
- PUT(req: NextRequest): Promise<Response>;
15
- PATCH(req: NextRequest): Promise<Response>;
16
- DELETE(req: NextRequest): Promise<Response>;
17
- }
18
- export declare function serve<T extends Context>(handler: FetchHandler<T>, ...[options]: MaybeOptionalOptions<ServeOptions<T>>): ServeResult;
19
- //# sourceMappingURL=serve.d.ts.map
@@ -1,3 +0,0 @@
1
- export * from './rpc-handler';
2
- export * from './types';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,11 +0,0 @@
1
- import type { MaybeOptionalOptions } from '@orpc/shared';
2
- import type { Context } from '../../context';
3
- import type { Router } from '../../router';
4
- import type { RPCHandlerOptions, StandardHandleOptions } from '../standard';
5
- import type { NodeHttpHandler, NodeHttpHandleResult, NodeHttpRequest, NodeHttpResponse } from './types';
6
- export declare class RPCHandler<T extends Context> implements NodeHttpHandler<T> {
7
- private readonly standardHandler;
8
- constructor(router: Router<T, any>, options?: NoInfer<RPCHandlerOptions<T>>);
9
- handle(req: NodeHttpRequest, res: NodeHttpResponse, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<NodeHttpHandleResult>;
10
- }
11
- //# sourceMappingURL=rpc-handler.d.ts.map
@@ -1,22 +0,0 @@
1
- import type { MaybeOptionalOptions } from '@orpc/shared';
2
- import type { IncomingMessage, ServerResponse } from 'node:http';
3
- import type { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
4
- import type { Context } from '../../context';
5
- import type { StandardHandleOptions } from '../standard';
6
- export type NodeHttpRequest = (IncomingMessage | Http2ServerRequest) & {
7
- /**
8
- * Replace `req.url` with `req.originalUrl` when `req.originalUrl` is available.
9
- * This is useful for `express.js` middleware.
10
- */
11
- originalUrl?: string;
12
- };
13
- export type NodeHttpResponse = ServerResponse | Http2ServerResponse;
14
- export type NodeHttpHandleResult = {
15
- matched: true;
16
- } | {
17
- matched: false;
18
- };
19
- export interface NodeHttpHandler<T extends Context> {
20
- handle(req: NodeHttpRequest, res: NodeHttpResponse, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<NodeHttpHandleResult>;
21
- }
22
- //# sourceMappingURL=types.d.ts.map
@@ -1,53 +0,0 @@
1
- import type { ErrorFromErrorMap, HTTPPath, Meta, Schema, SchemaOutput } from '@orpc/contract';
2
- import type { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
3
- import type { StandardRequest, StandardResponse } from '@orpc/standard-server';
4
- import type { Context } from '../../context';
5
- import type { Plugin } from '../../plugins';
6
- import type { ProcedureClientInterceptorOptions } from '../../procedure-client';
7
- import type { Router } from '../../router';
8
- import type { StandardCodec, StandardMatcher } from './types';
9
- export type StandardHandleOptions<T extends Context> = {
10
- prefix?: HTTPPath;
11
- } & (Record<never, never> extends T ? {
12
- context?: T;
13
- } : {
14
- context: T;
15
- });
16
- export type WellStandardHandleOptions<T extends Context> = StandardHandleOptions<T> & {
17
- context: T;
18
- };
19
- export type StandardHandleResult = {
20
- matched: true;
21
- response: StandardResponse;
22
- } | {
23
- matched: false;
24
- response: undefined;
25
- };
26
- export type StandardHandlerInterceptorOptions<TContext extends Context> = WellStandardHandleOptions<TContext> & {
27
- request: StandardRequest;
28
- };
29
- export interface StandardHandlerOptions<TContext extends Context> {
30
- plugins?: Plugin<TContext>[];
31
- /**
32
- * Interceptors at the request level, helpful when you want catch errors
33
- */
34
- interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
35
- /**
36
- * Interceptors at the root level, helpful when you want override the request/response
37
- */
38
- rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
39
- /**
40
- *
41
- * Interceptors for procedure client.
42
- */
43
- clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Schema, Record<never, never>, Meta>, SchemaOutput<Schema, unknown>, ErrorFromErrorMap<Record<never, never>>>[];
44
- }
45
- export declare class StandardHandler<T extends Context> {
46
- private readonly matcher;
47
- private readonly codec;
48
- private readonly options;
49
- private readonly plugin;
50
- constructor(router: Router<T, any>, matcher: StandardMatcher, codec: StandardCodec, options?: NoInfer<StandardHandlerOptions<T>>);
51
- handle(request: StandardRequest, ...[options]: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<StandardHandleResult>;
52
- }
53
- //# sourceMappingURL=handler.d.ts.map
@@ -1,6 +0,0 @@
1
- export * from './handler';
2
- export * from './rpc-codec';
3
- export * from './rpc-handler';
4
- export * from './rpc-matcher';
5
- export * from './types';
6
- //# sourceMappingURL=index.d.ts.map
@@ -1,16 +0,0 @@
1
- import type { ORPCError } from '@orpc/client';
2
- import type { AnyProcedure } from '../../procedure';
3
- import type { StandardCodec, StandardParams } from './types';
4
- import { RPCSerializer } from '@orpc/client/rpc';
5
- import { type StandardRequest, type StandardResponse } from '@orpc/standard-server';
6
- export interface StandardCodecOptions {
7
- serializer?: RPCSerializer;
8
- }
9
- export declare class RPCCodec implements StandardCodec {
10
- private readonly serializer;
11
- constructor(options?: StandardCodecOptions);
12
- decode(request: StandardRequest, _params: StandardParams | undefined, _procedure: AnyProcedure): Promise<unknown>;
13
- encode(output: unknown, _procedure: AnyProcedure): StandardResponse;
14
- encodeError(error: ORPCError<any, any>): StandardResponse;
15
- }
16
- //# sourceMappingURL=rpc-codec.d.ts.map
@@ -1,8 +0,0 @@
1
- import type { Context } from '../../context';
2
- import type { StandardHandlerOptions } from './handler';
3
- import type { StandardCodec, StandardMatcher } from './types';
4
- export interface RPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T> {
5
- matcher?: StandardMatcher;
6
- codec?: StandardCodec;
7
- }
8
- //# sourceMappingURL=rpc-handler.d.ts.map
@@ -1,10 +0,0 @@
1
- import type { HTTPPath } from '@orpc/contract';
2
- import type { StandardMatcher, StandardMatchResult } from './types';
3
- import { type AnyRouter } from '../../router';
4
- export declare class RPCMatcher implements StandardMatcher {
5
- private readonly tree;
6
- private pendingRouters;
7
- init(router: AnyRouter, path?: string[]): void;
8
- match(_method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
9
- }
10
- //# sourceMappingURL=rpc-matcher.d.ts.map
@@ -1,21 +0,0 @@
1
- import type { ORPCError } from '@orpc/client';
2
- import type { HTTPPath } from '@orpc/contract';
3
- import type { StandardRequest, StandardResponse } from '@orpc/standard-server';
4
- import type { AnyProcedure } from '../../procedure';
5
- import type { AnyRouter } from '../../router';
6
- export type StandardParams = Record<string, string>;
7
- export type StandardMatchResult = {
8
- path: string[];
9
- procedure: AnyProcedure;
10
- params?: StandardParams;
11
- } | undefined;
12
- export interface StandardMatcher {
13
- init(router: AnyRouter): void;
14
- match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
15
- }
16
- export interface StandardCodec {
17
- encode(output: unknown, procedure: AnyProcedure): StandardResponse;
18
- encodeError(error: ORPCError<any, any>): StandardResponse;
19
- decode(request: StandardRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
20
- }
21
- //# sourceMappingURL=types.d.ts.map
@@ -1,75 +0,0 @@
1
- import type { ContractRouter, ErrorMap, HTTPPath, MergedErrorMap, Meta, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
2
- import type { BuilderDef } from './builder';
3
- import type { ConflictContextGuard, Context, MergedContext } from './context';
4
- import type { ORPCErrorConstructorMap } from './error';
5
- import type { FlattenLazy } from './lazy-utils';
6
- import type { MapInputMiddleware, Middleware } from './middleware';
7
- import type { ProcedureHandler } from './procedure';
8
- import type { DecoratedProcedure } from './procedure-decorated';
9
- import type { AdaptedRouter, AdaptRouterOptions, Router } from './router';
10
- export interface BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
11
- '~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
12
- 'errors'<U extends ErrorMap>(errors: U): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
13
- 'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & BuilderWithMiddlewares<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
14
- 'meta'(meta: TMeta): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
15
- 'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
16
- 'input'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
17
- 'output'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
18
- 'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
19
- 'prefix'(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
20
- 'tag'(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
21
- 'router'<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(router: U): AdaptedRouter<U, TInitialContext, TErrorMap>;
22
- 'lazy'<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(loader: () => Promise<{
23
- default: U;
24
- }>): AdaptedRouter<FlattenLazy<U>, TInitialContext, TErrorMap>;
25
- }
26
- export interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
27
- '~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
28
- 'errors'<U extends ErrorMap>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
29
- 'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilder<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
30
- 'meta'(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
31
- 'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
32
- 'input'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
33
- 'output'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
34
- 'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
35
- }
36
- export interface ProcedureBuilderWithInput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
37
- '~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
38
- 'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
39
- 'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
40
- 'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
41
- 'meta'(meta: TMeta): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
42
- 'route'(route: Route): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
43
- 'output'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
44
- 'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
45
- }
46
- export interface ProcedureBuilderWithOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
47
- '~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
48
- 'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
49
- 'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithOutput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
50
- 'meta'(meta: TMeta): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
51
- 'route'(route: Route): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
52
- 'input'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
53
- 'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
54
- }
55
- export interface ProcedureBuilderWithInputOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
56
- '~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
57
- 'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
58
- 'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInputOutput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
59
- 'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInputOutput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
60
- 'meta'(meta: TMeta): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
61
- 'route'(route: Route): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
62
- 'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
63
- }
64
- export interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
65
- '~orpc': AdaptRouterOptions<TErrorMap>;
66
- 'errors'<U extends ErrorMap>(errors: U): RouterBuilder<TInitialContext, TCurrentContext, MergedErrorMap<TErrorMap, U>, TMeta>;
67
- 'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & RouterBuilder<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TErrorMap, TMeta>;
68
- 'prefix'(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
69
- 'tag'(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
70
- 'router'<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(router: U): AdaptedRouter<U, TInitialContext, TErrorMap>;
71
- 'lazy'<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(loader: () => Promise<{
72
- default: U;
73
- }>): AdaptedRouter<FlattenLazy<U>, TInitialContext, TErrorMap>;
74
- }
75
- //# sourceMappingURL=builder-variants.d.ts.map
@@ -1,58 +0,0 @@
1
- import type { ContractProcedureDef, ContractRouter, ErrorMap, HTTPPath, MergedErrorMap, Meta, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
2
- import type { BuilderWithMiddlewares, ProcedureBuilder, ProcedureBuilderWithInput, ProcedureBuilderWithOutput, RouterBuilder } from './builder-variants';
3
- import type { ConflictContextGuard, Context, MergedContext } from './context';
4
- import type { ORPCErrorConstructorMap } from './error';
5
- import type { FlattenLazy } from './lazy-utils';
6
- import type { AnyMiddleware, MapInputMiddleware, Middleware } from './middleware';
7
- import type { DecoratedMiddleware } from './middleware-decorated';
8
- import type { ProcedureHandler } from './procedure';
9
- import type { AdaptedRouter, AdaptRouterOptions, Router } from './router';
10
- import { DecoratedProcedure } from './procedure-decorated';
11
- export interface BuilderConfig {
12
- initialInputValidationIndex?: number;
13
- initialOutputValidationIndex?: number;
14
- }
15
- export interface BuilderDef<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>, AdaptRouterOptions<TErrorMap> {
16
- middlewares: AnyMiddleware[];
17
- inputValidationIndex: number;
18
- outputValidationIndex: number;
19
- config: BuilderConfig;
20
- }
21
- export declare class Builder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
22
- '~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
23
- constructor(def: BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>);
24
- /**
25
- * Reset config
26
- */
27
- $config(config: BuilderConfig): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
28
- /**
29
- * Reset initial context
30
- */
31
- $context<U extends Context>(): Builder<U, U, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
32
- /**
33
- * Reset initial meta
34
- */
35
- $meta<U extends Meta>(initialMeta: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, U>;
36
- /**
37
- * Reset initial route
38
- */
39
- $route(initialRoute: Route): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
40
- middleware<UOutContext extends Context, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
41
- middleware: Middleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): DecoratedMiddleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<any>, TMeta>;
42
- errors<U extends ErrorMap>(errors: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
43
- use<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & BuilderWithMiddlewares<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
44
- use<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & BuilderWithMiddlewares<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
45
- meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
46
- route(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
47
- input<USchema extends Schema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
48
- output<USchema extends Schema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
49
- handler<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
50
- prefix(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
51
- tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
52
- router<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(router: U): AdaptedRouter<U, TInitialContext, TErrorMap>;
53
- lazy<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(loader: () => Promise<{
54
- default: U;
55
- }>): AdaptedRouter<FlattenLazy<U>, TInitialContext, TErrorMap>;
56
- }
57
- export declare const os: Builder<Context, Context, undefined, undefined, {}, {}>;
58
- //# sourceMappingURL=builder.d.ts.map