@orpc/server 0.0.0-next.564695e → 0.0.0-next.56cbd20

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 (83) hide show
  1. package/README.md +118 -0
  2. package/dist/adapters/fetch/index.d.mts +26 -0
  3. package/dist/adapters/fetch/index.d.ts +26 -0
  4. package/dist/adapters/fetch/index.mjs +9 -0
  5. package/dist/adapters/hono/index.d.mts +19 -0
  6. package/dist/adapters/hono/index.d.ts +19 -0
  7. package/dist/{hono.js → adapters/hono/index.mjs} +11 -21
  8. package/dist/adapters/next/index.d.mts +26 -0
  9. package/dist/adapters/next/index.d.ts +26 -0
  10. package/dist/adapters/next/index.mjs +29 -0
  11. package/dist/adapters/node/index.d.mts +34 -0
  12. package/dist/adapters/node/index.d.ts +34 -0
  13. package/dist/adapters/node/index.mjs +31 -0
  14. package/dist/adapters/standard/index.d.mts +25 -0
  15. package/dist/adapters/standard/index.d.ts +25 -0
  16. package/dist/adapters/standard/index.mjs +6 -0
  17. package/dist/index.d.mts +255 -0
  18. package/dist/index.d.ts +255 -0
  19. package/dist/{index.js → index.mjs} +41 -112
  20. package/dist/plugins/index.d.mts +31 -0
  21. package/dist/plugins/index.d.ts +31 -0
  22. package/dist/{chunk-XFBAK67J.js → plugins/index.mjs} +17 -42
  23. package/dist/shared/server.BHIDiY4a.mjs +28 -0
  24. package/dist/shared/server.CtBp-i4f.d.mts +77 -0
  25. package/dist/shared/server.DKrKGnk2.mjs +161 -0
  26. package/dist/shared/server.Drm1Lma3.d.ts +77 -0
  27. package/dist/shared/server.Q6ZmnTgO.mjs +12 -0
  28. package/dist/{chunk-SV6DBVXJ.js → shared/server.V6zT5iYQ.mjs} +84 -82
  29. package/dist/shared/server.ptXwNGQr.d.mts +158 -0
  30. package/dist/shared/server.ptXwNGQr.d.ts +158 -0
  31. package/package.json +29 -31
  32. package/dist/chunk-F75AQ6KO.js +0 -313
  33. package/dist/chunk-GQ4376GR.js +0 -136
  34. package/dist/fetch.js +0 -18
  35. package/dist/next.js +0 -39
  36. package/dist/node.js +0 -175
  37. package/dist/plugins.js +0 -11
  38. package/dist/src/adapters/fetch/index.d.ts +0 -4
  39. package/dist/src/adapters/fetch/rpc-handler.d.ts +0 -10
  40. package/dist/src/adapters/fetch/types.d.ts +0 -13
  41. package/dist/src/adapters/fetch/utils.d.ts +0 -6
  42. package/dist/src/adapters/hono/index.d.ts +0 -3
  43. package/dist/src/adapters/hono/middleware.d.ts +0 -13
  44. package/dist/src/adapters/next/index.d.ts +0 -3
  45. package/dist/src/adapters/next/serve.d.ts +0 -20
  46. package/dist/src/adapters/node/index.d.ts +0 -4
  47. package/dist/src/adapters/node/rpc-handler.d.ts +0 -10
  48. package/dist/src/adapters/node/types.d.ts +0 -21
  49. package/dist/src/adapters/node/utils.d.ts +0 -5
  50. package/dist/src/adapters/standard/handler.d.ts +0 -51
  51. package/dist/src/adapters/standard/index.d.ts +0 -7
  52. package/dist/src/adapters/standard/rpc-codec.d.ts +0 -15
  53. package/dist/src/adapters/standard/rpc-handler.d.ts +0 -8
  54. package/dist/src/adapters/standard/rpc-matcher.d.ts +0 -10
  55. package/dist/src/adapters/standard/rpc-serializer.d.ts +0 -16
  56. package/dist/src/adapters/standard/types.d.ts +0 -44
  57. package/dist/src/builder-variants.d.ts +0 -74
  58. package/dist/src/builder.d.ts +0 -57
  59. package/dist/src/config.d.ts +0 -6
  60. package/dist/src/context.d.ts +0 -9
  61. package/dist/src/hidden.d.ts +0 -8
  62. package/dist/src/implementer-procedure.d.ts +0 -30
  63. package/dist/src/implementer-variants.d.ts +0 -17
  64. package/dist/src/implementer.d.ts +0 -28
  65. package/dist/src/index.d.ts +0 -23
  66. package/dist/src/lazy-utils.d.ts +0 -6
  67. package/dist/src/lazy.d.ts +0 -22
  68. package/dist/src/middleware-decorated.d.ts +0 -10
  69. package/dist/src/middleware-utils.d.ts +0 -5
  70. package/dist/src/middleware.d.ts +0 -37
  71. package/dist/src/plugins/base.d.ts +0 -13
  72. package/dist/src/plugins/cors.d.ts +0 -19
  73. package/dist/src/plugins/index.d.ts +0 -4
  74. package/dist/src/plugins/response-headers.d.ts +0 -10
  75. package/dist/src/procedure-client.d.ts +0 -31
  76. package/dist/src/procedure-decorated.d.ts +0 -21
  77. package/dist/src/procedure-utils.d.ts +0 -17
  78. package/dist/src/procedure.d.ts +0 -29
  79. package/dist/src/router-accessible-lazy.d.ts +0 -8
  80. package/dist/src/router-client.d.ts +0 -11
  81. package/dist/src/router.d.ts +0 -29
  82. package/dist/src/utils.d.ts +0 -24
  83. package/dist/standard.js +0 -17
@@ -1,136 +0,0 @@
1
- import {
2
- RPCCodec,
3
- RPCMatcher,
4
- StandardHandler
5
- } from "./chunk-F75AQ6KO.js";
6
-
7
- // src/adapters/fetch/utils.ts
8
- import { once } from "@orpc/shared";
9
- import { contentDisposition, parse as parseContentDisposition } from "@tinyhttp/content-disposition";
10
- function fetchHeadersToStandardHeaders(headers) {
11
- const standardHeaders = {};
12
- for (const [key, value] of headers) {
13
- if (Array.isArray(standardHeaders[key])) {
14
- standardHeaders[key].push(value);
15
- } else if (standardHeaders[key] !== void 0) {
16
- standardHeaders[key] = [standardHeaders[key], value];
17
- } else {
18
- standardHeaders[key] = value;
19
- }
20
- }
21
- return standardHeaders;
22
- }
23
- async function fetchReToStandardBody(re) {
24
- if (!re.body) {
25
- return void 0;
26
- }
27
- const contentDisposition2 = re.headers.get("content-disposition");
28
- const fileName = contentDisposition2 ? parseContentDisposition(contentDisposition2).parameters.filename : void 0;
29
- if (typeof fileName === "string") {
30
- const blob2 = await re.blob();
31
- return new File([blob2], fileName, {
32
- type: blob2.type
33
- });
34
- }
35
- const contentType = re.headers.get("content-type");
36
- if (!contentType || contentType.startsWith("application/json")) {
37
- const text = await re.text();
38
- if (!text) {
39
- return void 0;
40
- }
41
- return JSON.parse(text);
42
- }
43
- if (contentType.startsWith("multipart/form-data")) {
44
- return await re.formData();
45
- }
46
- if (contentType.startsWith("application/x-www-form-urlencoded")) {
47
- return new URLSearchParams(await re.text());
48
- }
49
- if (contentType.startsWith("text/")) {
50
- return await re.text();
51
- }
52
- const blob = await re.blob();
53
- return new File([blob], "blob", {
54
- type: blob.type
55
- });
56
- }
57
- function fetchRequestToStandardRequest(request) {
58
- const url = new URL(request.url);
59
- return {
60
- raw: { request },
61
- url,
62
- signal: request.signal,
63
- method: request.method,
64
- body: once(() => {
65
- return fetchReToStandardBody(request);
66
- }),
67
- get headers() {
68
- const headers = fetchHeadersToStandardHeaders(request.headers);
69
- Object.defineProperty(this, "headers", { value: headers, writable: true });
70
- return headers;
71
- },
72
- set headers(value) {
73
- Object.defineProperty(this, "headers", { value, writable: true });
74
- }
75
- };
76
- }
77
- function standardResponseToFetchHeaders(response) {
78
- const fetchHeaders = new Headers();
79
- for (const [key, value] of Object.entries(response.headers)) {
80
- if (Array.isArray(value)) {
81
- for (const v of value) {
82
- fetchHeaders.append(key, v);
83
- }
84
- } else if (value !== void 0) {
85
- fetchHeaders.append(key, value);
86
- }
87
- }
88
- if (response.body instanceof Blob && !fetchHeaders.has("content-disposition")) {
89
- fetchHeaders.set("content-disposition", contentDisposition(response.body instanceof File ? response.body.name : "blob"));
90
- } else if (!(response.body instanceof Blob) && !(response.body instanceof URLSearchParams) && !(response.body instanceof FormData) && response.body !== void 0 && !fetchHeaders.has("content-type")) {
91
- fetchHeaders.set("content-type", "application/json");
92
- }
93
- return fetchHeaders;
94
- }
95
- function standardBodyToFetchBody(body) {
96
- if (body instanceof Blob || body instanceof FormData || body instanceof URLSearchParams) {
97
- return body;
98
- }
99
- return JSON.stringify(body);
100
- }
101
- function standardResponseToFetchResponse(response) {
102
- return new Response(standardBodyToFetchBody(response.body), {
103
- headers: standardResponseToFetchHeaders(response),
104
- status: response.status
105
- });
106
- }
107
-
108
- // src/adapters/fetch/rpc-handler.ts
109
- var RPCHandler = class {
110
- standardHandler;
111
- constructor(router, options) {
112
- const matcher = options?.matcher ?? new RPCMatcher();
113
- const codec = options?.codec ?? new RPCCodec();
114
- this.standardHandler = new StandardHandler(router, matcher, codec, options);
115
- }
116
- async handle(request, ...rest) {
117
- const standardRequest = fetchRequestToStandardRequest(request);
118
- const result = await this.standardHandler.handle(standardRequest, ...rest);
119
- if (!result.matched) {
120
- return result;
121
- }
122
- return {
123
- matched: true,
124
- response: standardResponseToFetchResponse(result.response)
125
- };
126
- }
127
- };
128
-
129
- export {
130
- fetchReToStandardBody,
131
- fetchRequestToStandardRequest,
132
- standardBodyToFetchBody,
133
- standardResponseToFetchResponse,
134
- RPCHandler
135
- };
136
- //# sourceMappingURL=chunk-GQ4376GR.js.map
package/dist/fetch.js DELETED
@@ -1,18 +0,0 @@
1
- import {
2
- RPCHandler,
3
- fetchReToStandardBody,
4
- fetchRequestToStandardRequest,
5
- standardBodyToFetchBody,
6
- standardResponseToFetchResponse
7
- } from "./chunk-GQ4376GR.js";
8
- import "./chunk-F75AQ6KO.js";
9
- import "./chunk-SV6DBVXJ.js";
10
- import "./chunk-XFBAK67J.js";
11
- export {
12
- RPCHandler,
13
- fetchReToStandardBody,
14
- fetchRequestToStandardRequest,
15
- standardBodyToFetchBody,
16
- standardResponseToFetchResponse
17
- };
18
- //# sourceMappingURL=fetch.js.map
package/dist/next.js DELETED
@@ -1,39 +0,0 @@
1
- import {
2
- RPCHandler,
3
- fetchReToStandardBody,
4
- fetchRequestToStandardRequest,
5
- standardBodyToFetchBody,
6
- standardResponseToFetchResponse
7
- } from "./chunk-GQ4376GR.js";
8
- import "./chunk-F75AQ6KO.js";
9
- import "./chunk-SV6DBVXJ.js";
10
- import "./chunk-XFBAK67J.js";
11
-
12
- // src/adapters/next/serve.ts
13
- import { value } from "@orpc/shared";
14
- function serve(handler, ...[options]) {
15
- const main = async (req) => {
16
- const context = await value(options?.context ?? {}, req);
17
- const { matched, response } = await handler.handle(req, { ...options, context });
18
- if (matched) {
19
- return response;
20
- }
21
- return new Response(`Cannot find a matching procedure for ${req.url}`, { status: 404 });
22
- };
23
- return {
24
- GET: main,
25
- POST: main,
26
- PUT: main,
27
- PATCH: main,
28
- DELETE: main
29
- };
30
- }
31
- export {
32
- RPCHandler,
33
- fetchReToStandardBody,
34
- fetchRequestToStandardRequest,
35
- serve,
36
- standardBodyToFetchBody,
37
- standardResponseToFetchResponse
38
- };
39
- //# sourceMappingURL=next.js.map
package/dist/node.js DELETED
@@ -1,175 +0,0 @@
1
- import {
2
- RPCCodec,
3
- RPCMatcher,
4
- StandardHandler
5
- } from "./chunk-F75AQ6KO.js";
6
- import "./chunk-SV6DBVXJ.js";
7
- import "./chunk-XFBAK67J.js";
8
-
9
- // src/adapters/node/utils.ts
10
- import { Buffer, File } from "node:buffer";
11
- import { Readable } from "node:stream";
12
- import { once } from "@orpc/shared";
13
- import { contentDisposition, parse as parseContentDisposition } from "@tinyhttp/content-disposition";
14
- function nodeHttpToStandardRequest(req, res) {
15
- const method = req.method ?? "GET";
16
- const protocol = "encrypted" in req.socket && req.socket.encrypted ? "https:" : "http:";
17
- const host = req.headers.host ?? "localhost";
18
- const url = new URL(req.originalUrl ?? req.url ?? "/", `${protocol}//${host}`);
19
- return {
20
- raw: { request: req, response: res },
21
- method,
22
- url,
23
- headers: req.headers,
24
- body: once(() => {
25
- return nodeHttpRequestToStandardBody(req);
26
- }),
27
- get signal() {
28
- const signal = nodeHttpResponseToAbortSignal(res);
29
- Object.defineProperty(this, "signal", { value: signal, writable: true });
30
- return signal;
31
- },
32
- set signal(value) {
33
- Object.defineProperty(this, "signal", { value, writable: true });
34
- }
35
- };
36
- }
37
- function nodeHttpResponseSendStandardResponse(res, standardResponse) {
38
- return new Promise((resolve, reject) => {
39
- res.on("error", reject);
40
- res.on("finish", resolve);
41
- if (standardResponse.body === void 0) {
42
- res.writeHead(standardResponse.status, standardResponse.headers);
43
- res.end();
44
- return;
45
- }
46
- if (standardResponse.body instanceof Blob) {
47
- const resHeaders = {
48
- ...standardResponse.headers,
49
- "content-type": standardResponse.body.type,
50
- "content-length": standardResponse.body.size.toString()
51
- };
52
- if (!standardResponse.headers["content-disposition"] && standardResponse.body instanceof Blob) {
53
- resHeaders["content-disposition"] = contentDisposition(standardResponse.body instanceof File ? standardResponse.body.name : "blob");
54
- }
55
- res.writeHead(standardResponse.status, resHeaders);
56
- Readable.fromWeb(
57
- standardResponse.body.stream()
58
- // Conflict between types=node and lib=dom so we need to cast it
59
- ).pipe(res);
60
- return;
61
- }
62
- if (standardResponse.body instanceof FormData) {
63
- const response = new Response(standardResponse.body);
64
- res.writeHead(standardResponse.status, {
65
- ...standardResponse.headers,
66
- "content-type": response.headers.get("content-type")
67
- });
68
- Readable.fromWeb(
69
- response.body
70
- // Conflict between types=node and lib=dom so we need to cast it
71
- ).pipe(res);
72
- return;
73
- }
74
- if (standardResponse.body instanceof URLSearchParams) {
75
- res.writeHead(standardResponse.status, {
76
- ...standardResponse.headers,
77
- "content-type": "application/x-www-form-urlencoded"
78
- });
79
- const string2 = standardResponse.body.toString();
80
- res.end(string2);
81
- return;
82
- }
83
- res.writeHead(standardResponse.status, {
84
- ...standardResponse.headers,
85
- "content-type": "application/json"
86
- });
87
- const string = JSON.stringify(standardResponse.body);
88
- res.end(string);
89
- });
90
- }
91
- async function nodeHttpRequestToStandardBody(req) {
92
- const method = req.method ?? "GET";
93
- if (method === "GET" || method === "HEAD") {
94
- return void 0;
95
- }
96
- const contentDisposition2 = req.headers["content-disposition"];
97
- const fileName = contentDisposition2 ? parseContentDisposition(contentDisposition2).parameters.filename : void 0;
98
- const contentType = req.headers["content-type"];
99
- if (typeof fileName === "string") {
100
- return await streamToFile(req, fileName, contentType || "application/octet-stream");
101
- }
102
- if (!contentType || contentType.startsWith("application/json")) {
103
- const text = await streamToString(req);
104
- if (!text) {
105
- return void 0;
106
- }
107
- return JSON.parse(text);
108
- }
109
- if (contentType.startsWith("multipart/form-data")) {
110
- return await streamToFormData(req, contentType);
111
- }
112
- if (contentType.startsWith("application/x-www-form-urlencoded")) {
113
- const text = await streamToString(req);
114
- return new URLSearchParams(text);
115
- }
116
- if (contentType.startsWith("text/")) {
117
- return await streamToString(req);
118
- }
119
- return streamToFile(req, "blob", contentType);
120
- }
121
- function streamToFormData(stream, contentType) {
122
- const response = new Response(stream, {
123
- // Conflict between types=node and lib=dom so we need to cast it
124
- headers: {
125
- "content-type": contentType
126
- }
127
- });
128
- return response.formData();
129
- }
130
- async function streamToString(stream) {
131
- let string = "";
132
- for await (const chunk of stream) {
133
- string += chunk.toString();
134
- }
135
- return string;
136
- }
137
- async function streamToFile(stream, fileName, contentType) {
138
- const chunks = [];
139
- for await (const chunk of stream) {
140
- chunks.push(chunk);
141
- }
142
- return new File([Buffer.concat(chunks)], fileName, { type: contentType });
143
- }
144
- function nodeHttpResponseToAbortSignal(res) {
145
- const controller = new AbortController();
146
- res.on("close", () => {
147
- controller.abort();
148
- });
149
- return controller.signal;
150
- }
151
-
152
- // src/adapters/node/rpc-handler.ts
153
- var RPCHandler = class {
154
- standardHandler;
155
- constructor(router, options) {
156
- const codec = options?.codec ?? new RPCCodec();
157
- const matcher = options?.matcher ?? new RPCMatcher();
158
- this.standardHandler = new StandardHandler(router, matcher, codec, options);
159
- }
160
- async handle(req, res, ...rest) {
161
- const standardRequest = nodeHttpToStandardRequest(req, res);
162
- const result = await this.standardHandler.handle(standardRequest, ...rest);
163
- if (!result.matched) {
164
- return { matched: false };
165
- }
166
- await nodeHttpResponseSendStandardResponse(res, result.response);
167
- return { matched: true };
168
- }
169
- };
170
- export {
171
- RPCHandler,
172
- nodeHttpResponseSendStandardResponse,
173
- nodeHttpToStandardRequest
174
- };
175
- //# sourceMappingURL=node.js.map
package/dist/plugins.js DELETED
@@ -1,11 +0,0 @@
1
- import {
2
- CORSPlugin,
3
- CompositePlugin,
4
- ResponseHeadersPlugin
5
- } from "./chunk-XFBAK67J.js";
6
- export {
7
- CORSPlugin,
8
- CompositePlugin,
9
- ResponseHeadersPlugin
10
- };
11
- //# sourceMappingURL=plugins.js.map
@@ -1,4 +0,0 @@
1
- export * from './rpc-handler';
2
- export * from './types';
3
- export * from './utils';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1,10 +0,0 @@
1
- import type { Context } from '../../context';
2
- import type { Router } from '../../router';
3
- import type { RPCHandlerOptions, StandardHandleRest } from '../standard';
4
- import type { FetchHandler, FetchHandleResult } from './types';
5
- export declare class RPCHandler<T extends Context> implements FetchHandler<T> {
6
- private readonly standardHandler;
7
- constructor(router: Router<T, any>, options?: NoInfer<RPCHandlerOptions<T>>);
8
- handle(request: Request, ...rest: StandardHandleRest<T>): Promise<FetchHandleResult>;
9
- }
10
- //# sourceMappingURL=rpc-handler.d.ts.map
@@ -1,13 +0,0 @@
1
- import type { Context } from '../../context';
2
- import type { StandardHandleRest } from '../standard';
3
- export type FetchHandleResult = {
4
- matched: true;
5
- response: Response;
6
- } | {
7
- matched: false;
8
- response: undefined;
9
- };
10
- export interface FetchHandler<T extends Context> {
11
- handle(request: Request, ...rest: StandardHandleRest<T>): Promise<FetchHandleResult>;
12
- }
13
- //# sourceMappingURL=types.d.ts.map
@@ -1,6 +0,0 @@
1
- import type { StandardBody, StandardRequest, StandardResponse } from '../standard';
2
- export declare function fetchReToStandardBody(re: Request | Response): Promise<StandardBody>;
3
- export declare function fetchRequestToStandardRequest(request: Request): StandardRequest;
4
- export declare function standardBodyToFetchBody(body: StandardBody): Blob | FormData | URLSearchParams | string | undefined;
5
- export declare function standardResponseToFetchResponse(response: StandardResponse): Response;
6
- //# sourceMappingURL=utils.d.ts.map
@@ -1,3 +0,0 @@
1
- export * from '../fetch';
2
- export * from './middleware';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,13 +0,0 @@
1
- import type { Context as HonoContext, MiddlewareHandler } from 'hono';
2
- import type { Context } from '../../context';
3
- import type { FetchHandler } from '../fetch';
4
- import type { StandardHandleOptions } from '../standard';
5
- import { type Value } from '@orpc/shared';
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 type CreateMiddlewareRest<T extends Context> = [options: CreateMiddlewareOptions<T>] | (Record<never, never> extends T ? [] : never);
12
- export declare function createMiddleware<T extends Context>(handler: FetchHandler<T>, ...[options]: CreateMiddlewareRest<T>): MiddlewareHandler;
13
- //# sourceMappingURL=middleware.d.ts.map
@@ -1,3 +0,0 @@
1
- export * from '../fetch';
2
- export * from './serve';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1,20 +0,0 @@
1
- import type { NextRequest } from 'next/server';
2
- import type { Context } from '../../context';
3
- import type { FetchHandler } from '../fetch';
4
- import type { StandardHandleOptions } from '../standard';
5
- import { type Value } from '@orpc/shared';
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 type ServeRest<T extends Context> = [options: ServeOptions<T>] | (Record<never, never> extends T ? [] : never);
12
- export interface ServeResult {
13
- GET(req: NextRequest): Promise<Response>;
14
- POST(req: NextRequest): Promise<Response>;
15
- PUT(req: NextRequest): Promise<Response>;
16
- PATCH(req: NextRequest): Promise<Response>;
17
- DELETE(req: NextRequest): Promise<Response>;
18
- }
19
- export declare function serve<T extends Context>(handler: FetchHandler<T>, ...[options]: ServeRest<T>): ServeResult;
20
- //# sourceMappingURL=serve.d.ts.map
@@ -1,4 +0,0 @@
1
- export * from './rpc-handler';
2
- export * from './types';
3
- export * from './utils';
4
- //# sourceMappingURL=index.d.ts.map
@@ -1,10 +0,0 @@
1
- import type { Context } from '../../context';
2
- import type { Router } from '../../router';
3
- import type { RPCHandlerOptions, StandardHandleRest } from '../standard';
4
- import type { NodeHttpHandler, NodeHttpHandleResult, NodeHttpRequest, NodeHttpResponse } from './types';
5
- export declare class RPCHandler<T extends Context> implements NodeHttpHandler<T> {
6
- private readonly standardHandler;
7
- constructor(router: Router<T, any>, options?: NoInfer<RPCHandlerOptions<T>>);
8
- handle(req: NodeHttpRequest, res: NodeHttpResponse, ...rest: StandardHandleRest<T>): Promise<NodeHttpHandleResult>;
9
- }
10
- //# sourceMappingURL=rpc-handler.d.ts.map
@@ -1,21 +0,0 @@
1
- import type { IncomingMessage, ServerResponse } from 'node:http';
2
- import type { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
3
- import type { Context } from '../../context';
4
- import type { StandardHandleRest } from '../standard';
5
- export type NodeHttpRequest = (IncomingMessage | Http2ServerRequest) & {
6
- /**
7
- * Replace `req.url` with `req.originalUrl` when `req.originalUrl` is available.
8
- * This is useful for `express.js` middleware.
9
- */
10
- originalUrl?: string;
11
- };
12
- export type NodeHttpResponse = ServerResponse | Http2ServerResponse;
13
- export type NodeHttpHandleResult = {
14
- matched: true;
15
- } | {
16
- matched: false;
17
- };
18
- export interface NodeHttpHandler<T extends Context> {
19
- handle(req: NodeHttpRequest, res: NodeHttpResponse, ...rest: StandardHandleRest<T>): Promise<NodeHttpHandleResult>;
20
- }
21
- //# sourceMappingURL=types.d.ts.map
@@ -1,5 +0,0 @@
1
- import type { StandardRequest, StandardResponse } from '../standard';
2
- import type { NodeHttpRequest, NodeHttpResponse } from './types';
3
- export declare function nodeHttpToStandardRequest(req: NodeHttpRequest, res: NodeHttpResponse): StandardRequest;
4
- export declare function nodeHttpResponseSendStandardResponse(res: NodeHttpResponse, standardResponse: StandardResponse): Promise<void>;
5
- //# sourceMappingURL=utils.d.ts.map
@@ -1,51 +0,0 @@
1
- import type { ErrorMap, HTTPPath, Meta, Schema } from '@orpc/contract';
2
- import type { Interceptor } from '@orpc/shared';
3
- import type { Context } from '../../context';
4
- import type { Plugin } from '../../plugins';
5
- import type { CreateProcedureClientOptions } from '../../procedure-client';
6
- import type { Router } from '../../router';
7
- import type { StandardCodec, StandardMatcher, StandardRequest, StandardResponse } from './types';
8
- export type StandardHandleOptions<T extends Context> = {
9
- prefix?: HTTPPath;
10
- } & (Record<never, never> extends T ? {
11
- context?: T;
12
- } : {
13
- context: T;
14
- });
15
- export type WellStandardHandleOptions<T extends Context> = StandardHandleOptions<T> & {
16
- context: T;
17
- };
18
- export type StandardHandleRest<T extends Context> = [options: StandardHandleOptions<T>] | (Record<never, never> extends T ? [] : never);
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 type WellCreateProcedureClientOptions<TContext extends Context> = CreateProcedureClientOptions<TContext, Schema, Schema, unknown, ErrorMap, Meta, unknown> & {
30
- context: TContext;
31
- };
32
- export interface StandardHandlerOptions<TContext extends Context> {
33
- plugins?: Plugin<TContext>[];
34
- /**
35
- * Interceptors at the request level, helpful when you want catch errors
36
- */
37
- interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
38
- /**
39
- * Interceptors at the root level, helpful when you want override the response
40
- */
41
- interceptorsRoot?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, unknown>[];
42
- }
43
- export declare class StandardHandler<TContext extends Context> {
44
- private readonly matcher;
45
- private readonly codec;
46
- private readonly options;
47
- private readonly plugin;
48
- constructor(router: Router<TContext, any>, matcher: StandardMatcher, codec: StandardCodec, options?: NoInfer<StandardHandlerOptions<TContext>>);
49
- handle(request: StandardRequest, ...[options]: StandardHandleRest<TContext>): Promise<StandardHandleResult>;
50
- }
51
- //# sourceMappingURL=handler.d.ts.map
@@ -1,7 +0,0 @@
1
- export * from './handler';
2
- export * from './rpc-codec';
3
- export * from './rpc-handler';
4
- export * from './rpc-matcher';
5
- export * from './rpc-serializer';
6
- export * from './types';
7
- //# sourceMappingURL=index.d.ts.map
@@ -1,15 +0,0 @@
1
- import type { ORPCError } from '@orpc/contract';
2
- import type { AnyProcedure } from '../../procedure';
3
- import type { StandardCodec, StandardParams, StandardRequest, StandardResponse } from './types';
4
- import { RPCSerializer } from './rpc-serializer';
5
- export interface StandardCodecOptions {
6
- serializer?: RPCSerializer;
7
- }
8
- export declare class RPCCodec implements StandardCodec {
9
- private readonly serializer;
10
- constructor(options?: StandardCodecOptions);
11
- decode(request: StandardRequest, _params: StandardParams | undefined, _procedure: AnyProcedure): Promise<unknown>;
12
- encode(output: unknown, _procedure: AnyProcedure): StandardResponse;
13
- encodeError(error: ORPCError<any, any>): StandardResponse;
14
- }
15
- //# 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,16 +0,0 @@
1
- import type { Segment } from '@orpc/shared';
2
- export type RPCSerializedJsonMeta = ['bigint' | 'date' | 'nan' | 'undefined' | 'set' | 'map' | 'regexp' | 'url', Segment[]][];
3
- export type RPCSerialized = {
4
- json: unknown;
5
- meta: RPCSerializedJsonMeta;
6
- } | FormData | Blob;
7
- export type RPCSerializedFormDataMaps = Segment[][];
8
- export declare class RPCSerializer {
9
- serialize(data: unknown): RPCSerialized;
10
- deserialize(serialized: RPCSerialized): unknown;
11
- }
12
- export declare function serializeRPCJson(value: unknown, segments?: Segment[], meta?: RPCSerializedJsonMeta): {
13
- json: unknown;
14
- meta: RPCSerializedJsonMeta;
15
- };
16
- //# sourceMappingURL=rpc-serializer.d.ts.map