@orpc/server 0.0.0-next.bc564a6 → 0.0.0-next.bf323bf
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.
- package/dist/chunk-6TBBWYQ3.js +351 -0
- package/dist/{chunk-KK4SDLC7.js → chunk-RDEUEBK3.js} +86 -27
- package/dist/chunk-SVWPMCP4.js +32 -0
- package/dist/chunk-XI6WGCB3.js +125 -0
- package/dist/fetch.js +6 -11
- package/dist/hono.js +17 -13
- package/dist/index.js +20 -3
- package/dist/next.js +5 -10
- package/dist/node.js +18 -74
- package/dist/plugins.js +11 -0
- package/dist/src/adapters/fetch/index.d.ts +1 -4
- package/dist/src/adapters/fetch/rpc-handler.d.ts +11 -0
- package/dist/src/adapters/fetch/types.d.ts +3 -10
- package/dist/src/adapters/hono/middleware.d.ts +5 -5
- package/dist/src/adapters/next/serve.d.ts +5 -5
- package/dist/src/adapters/node/index.d.ts +1 -3
- package/dist/src/adapters/node/rpc-handler.d.ts +11 -0
- package/dist/src/adapters/node/types.d.ts +14 -14
- package/dist/src/adapters/standard/handler.d.ts +51 -0
- package/dist/src/adapters/standard/index.d.ts +7 -0
- package/dist/src/adapters/standard/rpc-codec.d.ts +16 -0
- package/dist/src/adapters/standard/rpc-handler.d.ts +8 -0
- package/dist/src/adapters/standard/rpc-matcher.d.ts +10 -0
- package/dist/src/adapters/standard/rpc-serializer.d.ts +22 -0
- package/dist/src/adapters/standard/types.d.ts +20 -0
- package/dist/src/implementer-procedure.d.ts +5 -4
- package/dist/src/implementer-variants.d.ts +6 -5
- package/dist/src/implementer.d.ts +7 -6
- package/dist/src/index.d.ts +4 -1
- package/dist/src/middleware.d.ts +4 -4
- package/dist/src/plugins/base.d.ts +13 -0
- package/dist/src/plugins/cors.d.ts +19 -0
- package/dist/src/plugins/index.d.ts +4 -0
- package/dist/src/plugins/response-headers.d.ts +10 -0
- package/dist/src/procedure-client.d.ts +19 -8
- package/dist/src/procedure-decorated.d.ts +5 -4
- package/dist/src/procedure-utils.d.ts +4 -3
- package/dist/src/procedure.d.ts +2 -1
- package/dist/src/router-client.d.ts +6 -17
- package/dist/src/router.d.ts +1 -0
- package/dist/src/utils.d.ts +24 -0
- package/dist/standard.js +17 -0
- package/package.json +19 -3
- package/dist/chunk-ESTRJAOX.js +0 -299
- package/dist/chunk-WUOGVGWG.js +0 -1
- package/dist/src/adapters/fetch/orpc-handler.d.ts +0 -20
- package/dist/src/adapters/fetch/orpc-payload-codec.d.ts +0 -16
- package/dist/src/adapters/fetch/orpc-procedure-matcher.d.ts +0 -12
- package/dist/src/adapters/fetch/super-json.d.ts +0 -12
- package/dist/src/adapters/node/orpc-handler.d.ts +0 -12
- package/dist/src/adapters/node/request-listener.d.ts +0 -28
package/dist/hono.js
CHANGED
@@ -1,30 +1,34 @@
|
|
1
|
-
import "./chunk-WUOGVGWG.js";
|
2
1
|
import {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
import "./chunk-KK4SDLC7.js";
|
2
|
+
RPCHandler
|
3
|
+
} from "./chunk-SVWPMCP4.js";
|
4
|
+
import "./chunk-6TBBWYQ3.js";
|
5
|
+
import "./chunk-RDEUEBK3.js";
|
6
|
+
import "./chunk-XI6WGCB3.js";
|
9
7
|
|
10
8
|
// src/adapters/hono/middleware.ts
|
11
9
|
import { value } from "@orpc/shared";
|
12
10
|
function createMiddleware(handler, ...[options]) {
|
13
11
|
return async (c, next) => {
|
12
|
+
const bodyProps = /* @__PURE__ */ new Set(["arrayBuffer", "blob", "formData", "json", "text"]);
|
13
|
+
const request = c.req.method === "GET" || c.req.method === "HEAD" ? c.req.raw : new Proxy(c.req.raw, {
|
14
|
+
// https://github.com/honojs/middleware/blob/main/packages/trpc-server/src/index.ts#L39
|
15
|
+
get(target, prop) {
|
16
|
+
if (bodyProps.has(prop)) {
|
17
|
+
return () => c.req[prop]();
|
18
|
+
}
|
19
|
+
return Reflect.get(target, prop, target);
|
20
|
+
}
|
21
|
+
});
|
14
22
|
const context = await value(options?.context ?? {}, c);
|
15
|
-
const { matched, response } = await handler.handle(
|
23
|
+
const { matched, response } = await handler.handle(request, { ...options, context });
|
16
24
|
if (matched) {
|
17
|
-
c.
|
18
|
-
return;
|
25
|
+
return c.newResponse(response.body, response);
|
19
26
|
}
|
20
27
|
await next();
|
21
28
|
};
|
22
29
|
}
|
23
30
|
export {
|
24
|
-
ORPCPayloadCodec,
|
25
|
-
ORPCProcedureMatcher,
|
26
31
|
RPCHandler,
|
27
|
-
super_json_exports as SuperJSON,
|
28
32
|
createMiddleware
|
29
33
|
};
|
30
34
|
//# sourceMappingURL=hono.js.map
|
package/dist/index.js
CHANGED
@@ -3,10 +3,14 @@ import {
|
|
3
3
|
Procedure,
|
4
4
|
adaptRouter,
|
5
5
|
addMiddleware,
|
6
|
+
convertPathToHttpPath,
|
6
7
|
createAccessibleLazyRouter,
|
8
|
+
createContractedProcedure,
|
7
9
|
createLazyProcedureFormAnyLazy,
|
8
10
|
createProcedureClient,
|
9
11
|
deepSetLazyRouterPrefix,
|
12
|
+
eachAllContractProcedure,
|
13
|
+
eachContractProcedure,
|
10
14
|
flatLazy,
|
11
15
|
getLazyRouterPrefix,
|
12
16
|
getRouterChild,
|
@@ -17,7 +21,7 @@ import {
|
|
17
21
|
middlewareOutputFn,
|
18
22
|
setRouterContract,
|
19
23
|
unlazy
|
20
|
-
} from "./chunk-
|
24
|
+
} from "./chunk-RDEUEBK3.js";
|
21
25
|
|
22
26
|
// src/builder.ts
|
23
27
|
import { mergeErrorMap as mergeErrorMap2, mergeMeta as mergeMeta2, mergePrefix, mergeRoute as mergeRoute2, mergeTags } from "@orpc/contract";
|
@@ -353,7 +357,9 @@ function createRouterClient(router, ...rest) {
|
|
353
357
|
}
|
354
358
|
|
355
359
|
// src/index.ts
|
356
|
-
import { isDefinedError, ORPCError, safe, type, ValidationError } from "@orpc/contract";
|
360
|
+
import { eventIterator, isDefinedError, ORPCError, safe, type, ValidationError } from "@orpc/contract";
|
361
|
+
import { getEventMeta, withEventMeta } from "@orpc/server-standard";
|
362
|
+
import { onError, onFinish, onStart, onSuccess } from "@orpc/shared";
|
357
363
|
export {
|
358
364
|
Builder,
|
359
365
|
DecoratedProcedure,
|
@@ -363,14 +369,20 @@ export {
|
|
363
369
|
ValidationError,
|
364
370
|
adaptRouter,
|
365
371
|
call,
|
372
|
+
convertPathToHttpPath,
|
366
373
|
createAccessibleLazyRouter,
|
374
|
+
createContractedProcedure,
|
367
375
|
createLazyProcedureFormAnyLazy,
|
368
376
|
createProcedureClient,
|
369
377
|
createRouterClient,
|
370
378
|
decorateMiddleware,
|
371
379
|
deepSetLazyRouterPrefix,
|
380
|
+
eachAllContractProcedure,
|
381
|
+
eachContractProcedure,
|
382
|
+
eventIterator,
|
372
383
|
fallbackConfig,
|
373
384
|
flatLazy,
|
385
|
+
getEventMeta,
|
374
386
|
getLazyRouterPrefix,
|
375
387
|
getRouterChild,
|
376
388
|
getRouterContract,
|
@@ -382,10 +394,15 @@ export {
|
|
382
394
|
lazy,
|
383
395
|
mergeContext,
|
384
396
|
middlewareOutputFn,
|
397
|
+
onError,
|
398
|
+
onFinish,
|
399
|
+
onStart,
|
400
|
+
onSuccess,
|
385
401
|
os,
|
386
402
|
safe,
|
387
403
|
setRouterContract,
|
388
404
|
type,
|
389
|
-
unlazy
|
405
|
+
unlazy,
|
406
|
+
withEventMeta
|
390
407
|
};
|
391
408
|
//# sourceMappingURL=index.js.map
|
package/dist/next.js
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
-
import "./chunk-WUOGVGWG.js";
|
2
1
|
import {
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
import "./chunk-KK4SDLC7.js";
|
2
|
+
RPCHandler
|
3
|
+
} from "./chunk-SVWPMCP4.js";
|
4
|
+
import "./chunk-6TBBWYQ3.js";
|
5
|
+
import "./chunk-RDEUEBK3.js";
|
6
|
+
import "./chunk-XI6WGCB3.js";
|
9
7
|
|
10
8
|
// src/adapters/next/serve.ts
|
11
9
|
import { value } from "@orpc/shared";
|
@@ -27,10 +25,7 @@ function serve(handler, ...[options]) {
|
|
27
25
|
};
|
28
26
|
}
|
29
27
|
export {
|
30
|
-
ORPCPayloadCodec,
|
31
|
-
ORPCProcedureMatcher,
|
32
28
|
RPCHandler,
|
33
|
-
super_json_exports as SuperJSON,
|
34
29
|
serve
|
35
30
|
};
|
36
31
|
//# sourceMappingURL=next.js.map
|
package/dist/node.js
CHANGED
@@ -1,87 +1,31 @@
|
|
1
1
|
import {
|
2
|
-
|
3
|
-
|
4
|
-
|
2
|
+
RPCCodec,
|
3
|
+
RPCMatcher,
|
4
|
+
StandardHandler
|
5
|
+
} from "./chunk-6TBBWYQ3.js";
|
6
|
+
import "./chunk-RDEUEBK3.js";
|
7
|
+
import "./chunk-XI6WGCB3.js";
|
5
8
|
|
6
|
-
// src/adapters/node/
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
controller.abort();
|
11
|
-
});
|
12
|
-
const method = req.method ?? "GET";
|
13
|
-
const headers = createHeaders(req);
|
14
|
-
const protocol = "encrypted" in req.socket && req.socket.encrypted ? "https:" : "http:";
|
15
|
-
const host = headers.get("Host") ?? "localhost";
|
16
|
-
const url = new URL(req.originalUrl ?? req.url ?? "/", `${protocol}//${host}`);
|
17
|
-
const init = { method, headers, signal: controller.signal };
|
18
|
-
if (method !== "GET" && method !== "HEAD") {
|
19
|
-
init.body = new ReadableStream({
|
20
|
-
start(controller2) {
|
21
|
-
req.on("data", (chunk) => {
|
22
|
-
controller2.enqueue(new Uint8Array(chunk.buffer, chunk.byteOffset, chunk.byteLength));
|
23
|
-
});
|
24
|
-
req.on("end", () => {
|
25
|
-
controller2.close();
|
26
|
-
});
|
27
|
-
}
|
28
|
-
});
|
29
|
-
init.duplex = "half";
|
30
|
-
}
|
31
|
-
return new Request(url, init);
|
32
|
-
}
|
33
|
-
function createHeaders(req) {
|
34
|
-
const headers = new Headers();
|
35
|
-
const rawHeaders = req.rawHeaders;
|
36
|
-
for (let i = 0; i < rawHeaders.length; i += 2) {
|
37
|
-
headers.append(rawHeaders[i], rawHeaders[i + 1]);
|
38
|
-
}
|
39
|
-
return headers;
|
40
|
-
}
|
41
|
-
async function sendResponse(res, response) {
|
42
|
-
const headers = {};
|
43
|
-
for (const [key, value] of response.headers) {
|
44
|
-
if (key in headers) {
|
45
|
-
if (Array.isArray(headers[key])) {
|
46
|
-
headers[key].push(value);
|
47
|
-
} else {
|
48
|
-
headers[key] = [headers[key], value];
|
49
|
-
}
|
50
|
-
} else {
|
51
|
-
headers[key] = value;
|
52
|
-
}
|
53
|
-
}
|
54
|
-
res.writeHead(response.status, headers);
|
55
|
-
if (response.body != null && res.req.method !== "HEAD") {
|
56
|
-
for await (const chunk of response.body) {
|
57
|
-
res.write(chunk);
|
58
|
-
}
|
59
|
-
}
|
60
|
-
res.end();
|
61
|
-
}
|
62
|
-
|
63
|
-
// src/adapters/node/orpc-handler.ts
|
64
|
-
var RPCHandler2 = class {
|
65
|
-
orpcFetchHandler;
|
9
|
+
// src/adapters/node/rpc-handler.ts
|
10
|
+
import { sendStandardResponse, toStandardRequest } from "@orpc/server-standard-node";
|
11
|
+
var RPCHandler = class {
|
12
|
+
standardHandler;
|
66
13
|
constructor(router, options) {
|
67
|
-
|
14
|
+
const codec = options?.codec ?? new RPCCodec();
|
15
|
+
const matcher = options?.matcher ?? new RPCMatcher();
|
16
|
+
this.standardHandler = new StandardHandler(router, matcher, codec, options);
|
68
17
|
}
|
69
18
|
async handle(req, res, ...rest) {
|
70
|
-
const
|
71
|
-
const result = await this.
|
72
|
-
if (result.matched
|
19
|
+
const standardRequest = toStandardRequest(req, res);
|
20
|
+
const result = await this.standardHandler.handle(standardRequest, ...rest);
|
21
|
+
if (!result.matched) {
|
73
22
|
return { matched: false };
|
74
23
|
}
|
75
|
-
|
76
|
-
await rest[0]?.beforeSend?.(result.response, context);
|
77
|
-
await sendResponse(res, result.response);
|
24
|
+
await sendStandardResponse(res, result.response);
|
78
25
|
return { matched: true };
|
79
26
|
}
|
80
27
|
};
|
81
28
|
export {
|
82
|
-
|
83
|
-
createHeaders,
|
84
|
-
createRequest,
|
85
|
-
sendResponse
|
29
|
+
RPCHandler
|
86
30
|
};
|
87
31
|
//# sourceMappingURL=node.js.map
|
package/dist/plugins.js
ADDED
@@ -0,0 +1,11 @@
|
|
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,13 +1,6 @@
|
|
1
|
-
import type {
|
1
|
+
import type { MaybeOptionalOptions } from '@orpc/shared';
|
2
2
|
import type { Context } from '../../context';
|
3
|
-
|
4
|
-
prefix?: HTTPPath;
|
5
|
-
} & (Record<never, never> extends T ? {
|
6
|
-
context?: T;
|
7
|
-
} : {
|
8
|
-
context: T;
|
9
|
-
});
|
10
|
-
export type FetchHandleRest<T extends Context> = [options: FetchHandleOptions<T>] | (Record<never, never> extends T ? [] : never);
|
3
|
+
import type { StandardHandleOptions } from '../standard';
|
11
4
|
export type FetchHandleResult = {
|
12
5
|
matched: true;
|
13
6
|
response: Response;
|
@@ -16,6 +9,6 @@ export type FetchHandleResult = {
|
|
16
9
|
response: undefined;
|
17
10
|
};
|
18
11
|
export interface FetchHandler<T extends Context> {
|
19
|
-
handle(request: Request, ...rest:
|
12
|
+
handle(request: Request, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<FetchHandleResult>;
|
20
13
|
}
|
21
14
|
//# sourceMappingURL=types.d.ts.map
|
@@ -1,12 +1,12 @@
|
|
1
|
+
import type { MaybeOptionalOptions, Value } from '@orpc/shared';
|
1
2
|
import type { Context as HonoContext, MiddlewareHandler } from 'hono';
|
2
3
|
import type { Context } from '../../context';
|
3
|
-
import type {
|
4
|
-
import {
|
5
|
-
export type CreateMiddlewareOptions<T extends Context> = Omit<
|
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 ? {
|
6
7
|
context?: Value<T, [HonoContext]>;
|
7
8
|
} : {
|
8
9
|
context: Value<T, [HonoContext]>;
|
9
10
|
});
|
10
|
-
export
|
11
|
-
export declare function createMiddleware<T extends Context>(handler: FetchHandler<T>, ...[options]: CreateMiddlewareRest<T>): MiddlewareHandler;
|
11
|
+
export declare function createMiddleware<T extends Context>(handler: FetchHandler<T>, ...[options]: MaybeOptionalOptions<CreateMiddlewareOptions<T>>): MiddlewareHandler;
|
12
12
|
//# sourceMappingURL=middleware.d.ts.map
|
@@ -1,13 +1,13 @@
|
|
1
|
+
import type { MaybeOptionalOptions, Value } from '@orpc/shared';
|
1
2
|
import type { NextRequest } from 'next/server';
|
2
3
|
import type { Context } from '../../context';
|
3
|
-
import type {
|
4
|
-
import {
|
5
|
-
export type ServeOptions<T extends Context> = Omit<
|
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 ? {
|
6
7
|
context?: Value<T, [NextRequest]>;
|
7
8
|
} : {
|
8
9
|
context: Value<T, [NextRequest]>;
|
9
10
|
});
|
10
|
-
export type ServeRest<T extends Context> = [options: ServeOptions<T>] | (Record<never, never> extends T ? [] : never);
|
11
11
|
export interface ServeResult {
|
12
12
|
GET(req: NextRequest): Promise<Response>;
|
13
13
|
POST(req: NextRequest): Promise<Response>;
|
@@ -15,5 +15,5 @@ export interface ServeResult {
|
|
15
15
|
PATCH(req: NextRequest): Promise<Response>;
|
16
16
|
DELETE(req: NextRequest): Promise<Response>;
|
17
17
|
}
|
18
|
-
export declare function serve<T extends Context>(handler: FetchHandler<T>, ...[options]:
|
18
|
+
export declare function serve<T extends Context>(handler: FetchHandler<T>, ...[options]: MaybeOptionalOptions<ServeOptions<T>>): ServeResult;
|
19
19
|
//# sourceMappingURL=serve.d.ts.map
|
@@ -0,0 +1,11 @@
|
|
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 +1,22 @@
|
|
1
|
-
import type {
|
2
|
-
import type { Promisable } from '@orpc/shared';
|
1
|
+
import type { MaybeOptionalOptions } from '@orpc/shared';
|
3
2
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
3
|
+
import type { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
|
4
4
|
import type { Context } from '../../context';
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
}
|
13
|
-
export type
|
14
|
-
export type
|
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
15
|
matched: true;
|
16
16
|
} | {
|
17
17
|
matched: false;
|
18
18
|
};
|
19
|
-
export interface
|
20
|
-
handle(req:
|
19
|
+
export interface NodeHttpHandler<T extends Context> {
|
20
|
+
handle(req: NodeHttpRequest, res: NodeHttpResponse, ...rest: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<NodeHttpHandleResult>;
|
21
21
|
}
|
22
22
|
//# sourceMappingURL=types.d.ts.map
|
@@ -0,0 +1,51 @@
|
|
1
|
+
import type { ErrorMap, HTTPPath, Meta, Schema } from '@orpc/contract';
|
2
|
+
import type { StandardRequest, StandardResponse } from '@orpc/server-standard';
|
3
|
+
import type { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
4
|
+
import type { Context } from '../../context';
|
5
|
+
import type { Plugin } from '../../plugins';
|
6
|
+
import type { CreateProcedureClientOptions } 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 type WellCreateProcedureClientOptions<TContext extends Context> = CreateProcedureClientOptions<TContext, Schema, Schema, unknown, ErrorMap, Meta, Record<never, never>> & {
|
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<T extends Context> {
|
44
|
+
private readonly matcher;
|
45
|
+
private readonly codec;
|
46
|
+
private readonly options;
|
47
|
+
private readonly plugin;
|
48
|
+
constructor(router: Router<T, any>, matcher: StandardMatcher, codec: StandardCodec, options?: NoInfer<StandardHandlerOptions<T>>);
|
49
|
+
handle(request: StandardRequest, ...[options]: MaybeOptionalOptions<StandardHandleOptions<T>>): Promise<StandardHandleResult>;
|
50
|
+
}
|
51
|
+
//# sourceMappingURL=handler.d.ts.map
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import type { ORPCError } from '@orpc/contract';
|
2
|
+
import type { StandardRequest, StandardResponse } from '@orpc/server-standard';
|
3
|
+
import type { AnyProcedure } from '../../procedure';
|
4
|
+
import type { StandardCodec, StandardParams } from './types';
|
5
|
+
import { RPCSerializer } from './rpc-serializer';
|
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
|
@@ -0,0 +1,8 @@
|
|
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
|
@@ -0,0 +1,10 @@
|
|
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
|
@@ -0,0 +1,22 @@
|
|
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 | AsyncIteratorObject<{
|
7
|
+
json: unknown;
|
8
|
+
meta: RPCSerializedJsonMeta;
|
9
|
+
}, {
|
10
|
+
json: unknown;
|
11
|
+
meta: RPCSerializedJsonMeta;
|
12
|
+
}, void>;
|
13
|
+
export type RPCSerializedFormDataMaps = Segment[][];
|
14
|
+
export declare class RPCSerializer {
|
15
|
+
serialize(data: unknown): RPCSerialized;
|
16
|
+
deserialize(serialized: RPCSerialized): unknown;
|
17
|
+
}
|
18
|
+
export declare function serializeRPCJson(value: unknown, segments?: Segment[], meta?: RPCSerializedJsonMeta): {
|
19
|
+
json: unknown;
|
20
|
+
meta: RPCSerializedJsonMeta;
|
21
|
+
};
|
22
|
+
//# sourceMappingURL=rpc-serializer.d.ts.map
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import type { HTTPPath, ORPCError } from '@orpc/contract';
|
2
|
+
import type { StandardRequest, StandardResponse } from '@orpc/server-standard';
|
3
|
+
import type { AnyProcedure } from '../../procedure';
|
4
|
+
import type { AnyRouter } from '../../router';
|
5
|
+
export type StandardParams = Record<string, string>;
|
6
|
+
export type StandardMatchResult = {
|
7
|
+
path: string[];
|
8
|
+
procedure: AnyProcedure;
|
9
|
+
params?: StandardParams;
|
10
|
+
} | undefined;
|
11
|
+
export interface StandardMatcher {
|
12
|
+
init(router: AnyRouter): void;
|
13
|
+
match(method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
14
|
+
}
|
15
|
+
export interface StandardCodec {
|
16
|
+
encode(output: unknown, procedure: AnyProcedure): StandardResponse;
|
17
|
+
encodeError(error: ORPCError<any, any>): StandardResponse;
|
18
|
+
decode(request: StandardRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
|
19
|
+
}
|
20
|
+
//# sourceMappingURL=types.d.ts.map
|
@@ -1,9 +1,10 @@
|
|
1
|
-
import type { ClientRest, ErrorMap, Meta, ORPCErrorConstructorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
1
|
+
import type { ClientContext, ClientRest, ErrorMap, Meta, ORPCErrorConstructorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
+
import type { MaybeOptionalOptions } from '@orpc/shared';
|
2
3
|
import type { BuilderDef } from './builder';
|
3
4
|
import type { ConflictContextGuard, Context, MergedContext } from './context';
|
4
5
|
import type { MapInputMiddleware, Middleware } from './middleware';
|
5
6
|
import type { Procedure, ProcedureHandler } from './procedure';
|
6
|
-
import type {
|
7
|
+
import type { CreateProcedureClientOptions, ProcedureClient } from './procedure-client';
|
7
8
|
import type { DecoratedProcedure } from './procedure-decorated';
|
8
9
|
/**
|
9
10
|
* Like `DecoratedProcedure`, but removed all method that can change the contract.
|
@@ -13,11 +14,11 @@ export interface ImplementedProcedure<TInitialContext extends Context, TCurrentC
|
|
13
14
|
/**
|
14
15
|
* Make this procedure callable (works like a function while still being a procedure).
|
15
16
|
*/
|
16
|
-
callable<TClientContext>(...rest:
|
17
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta, TClientContext>>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
17
18
|
/**
|
18
19
|
* Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
|
19
20
|
*/
|
20
|
-
actionable<TClientContext>(...rest:
|
21
|
+
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta, TClientContext>>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, SchemaInput<TInputSchema>>) => Promise<SchemaOutput<TOutputSchema, THandlerOutput>>);
|
21
22
|
}
|
22
23
|
/**
|
23
24
|
* Like `ProcedureBuilderWithoutHandler`, but removed all method that can change the contract.
|
@@ -1,16 +1,17 @@
|
|
1
|
-
import type { AnyContractRouter, ContractProcedure,
|
1
|
+
import type { AnyContractRouter, ContractProcedure, ContractRouterToErrorMap, ContractRouterToMeta, ORPCErrorConstructorMap } from '@orpc/contract';
|
2
2
|
import type { ConflictContextGuard, Context, MergedContext } from './context';
|
3
3
|
import type { ProcedureImplementer } from './implementer-procedure';
|
4
4
|
import type { FlattenLazy } from './lazy-utils';
|
5
5
|
import type { Middleware } from './middleware';
|
6
6
|
import type { AdaptedRouter, Router } from './router';
|
7
|
-
export
|
8
|
-
use<U extends Context>(middleware: Middleware<TCurrentContext, U, unknown, unknown, ORPCErrorConstructorMap<ContractRouterToErrorMap<TContract>>,
|
7
|
+
export interface RouterImplementerWithMiddlewares<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
8
|
+
use<U extends Context>(middleware: Middleware<TCurrentContext, U, unknown, unknown, ORPCErrorConstructorMap<ContractRouterToErrorMap<TContract>>, ContractRouterToMeta<TContract>>): ConflictContextGuard<MergedContext<TCurrentContext, U>> & ImplementerInternalWithMiddlewares<TContract, TInitialContext, MergedContext<TCurrentContext, U>>;
|
9
9
|
router<U extends Router<TCurrentContext, TContract>>(router: U): AdaptedRouter<U, TInitialContext, Record<never, never>>;
|
10
10
|
lazy<U extends Router<TInitialContext, TContract>>(loader: () => Promise<{
|
11
11
|
default: U;
|
12
12
|
}>): AdaptedRouter<FlattenLazy<U>, TInitialContext, Record<never, never>>;
|
13
|
-
}
|
13
|
+
}
|
14
|
+
export type ImplementerInternalWithMiddlewares<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = (TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? ProcedureImplementer<TInitialContext, TCurrentContext, UInputSchema, UOutputSchema, UErrorMap, UMeta> : RouterImplementerWithMiddlewares<TContract, TInitialContext, TCurrentContext> & {
|
14
15
|
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternalWithMiddlewares<TContract[K], TInitialContext, TCurrentContext> : never;
|
15
|
-
}
|
16
|
+
});
|
16
17
|
//# sourceMappingURL=implementer-variants.d.ts.map
|