@orpc/server 0.0.0-next.a5c2886 → 0.0.0-next.a6dec3e
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/README.md +11 -0
- package/dist/adapters/fetch/index.d.mts +42 -10
- package/dist/adapters/fetch/index.d.ts +42 -10
- package/dist/adapters/fetch/index.mjs +8 -6
- package/dist/adapters/hono/index.d.mts +7 -4
- package/dist/adapters/hono/index.d.ts +7 -4
- package/dist/adapters/hono/index.mjs +12 -9
- package/dist/adapters/next/index.d.mts +7 -4
- package/dist/adapters/next/index.d.ts +7 -4
- package/dist/adapters/next/index.mjs +12 -9
- package/dist/adapters/node/index.d.mts +44 -21
- package/dist/adapters/node/index.d.ts +44 -21
- package/dist/adapters/node/index.mjs +82 -23
- package/dist/adapters/standard/index.d.mts +11 -10
- package/dist/adapters/standard/index.d.ts +11 -10
- package/dist/adapters/standard/index.mjs +6 -4
- package/dist/index.d.mts +83 -61
- package/dist/index.d.ts +83 -61
- package/dist/index.mjs +50 -30
- package/dist/plugins/index.d.mts +108 -15
- package/dist/plugins/index.d.ts +108 -15
- package/dist/plugins/index.mjs +147 -6
- package/dist/shared/server.BVwwTHyO.mjs +9 -0
- package/dist/shared/server.BW-nUGgA.mjs +36 -0
- package/dist/shared/server.Bm0UqHzd.mjs +103 -0
- package/dist/shared/{server.CMrS28Go.mjs → server.C37gDhSZ.mjs} +42 -24
- package/dist/shared/server.C8NkqxHo.d.ts +17 -0
- package/dist/shared/server.CGCwEAt_.d.mts +10 -0
- package/dist/shared/server.DCQgF_JR.d.mts +17 -0
- package/dist/shared/{server.CM3tWr3C.d.mts → server.DFFT_EZo.d.ts} +27 -29
- package/dist/shared/{server.CSZRzcSW.mjs → server.DFuJLDuo.mjs} +62 -30
- package/dist/shared/{server.CPteJIPP.d.mts → server.DLt5njUb.d.mts} +19 -19
- package/dist/shared/{server.CPteJIPP.d.ts → server.DLt5njUb.d.ts} +19 -19
- package/dist/shared/{server.DmW25ynm.d.ts → server.DOYDVeMX.d.mts} +27 -29
- package/dist/shared/server._2UufoXA.d.ts +10 -0
- package/package.json +8 -8
- package/dist/shared/server.Cq3B6PoL.mjs +0 -28
- package/dist/shared/server.Q6ZmnTgO.mjs +0 -12
@@ -1,8 +1,8 @@
|
|
1
|
-
import { HTTPPath,
|
2
|
-
import {
|
1
|
+
import { HTTPPath, ORPCError } from '@orpc/client';
|
2
|
+
import { Meta, InferSchemaOutput, AnySchema, ErrorFromErrorMap } from '@orpc/contract';
|
3
|
+
import { Interceptor, ThrowableError } from '@orpc/shared';
|
3
4
|
import { StandardResponse, StandardLazyRequest } from '@orpc/standard-server';
|
4
|
-
import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.
|
5
|
-
import { ORPCError } from '@orpc/client';
|
5
|
+
import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.DLt5njUb.mjs';
|
6
6
|
|
7
7
|
type StandardParams = Record<string, string>;
|
8
8
|
type StandardMatchResult = {
|
@@ -20,13 +20,20 @@ interface StandardCodec {
|
|
20
20
|
decode(request: StandardLazyRequest, params: StandardParams | undefined, procedure: AnyProcedure): Promise<unknown>;
|
21
21
|
}
|
22
22
|
|
23
|
-
|
23
|
+
interface StandardHandlerPlugin<TContext extends Context> {
|
24
|
+
order?: number;
|
25
|
+
init?(options: StandardHandlerOptions<TContext>): void;
|
26
|
+
}
|
27
|
+
declare class CompositeStandardHandlerPlugin<T extends Context, TPlugin extends StandardHandlerPlugin<T>> implements StandardHandlerPlugin<T> {
|
28
|
+
protected readonly plugins: TPlugin[];
|
29
|
+
constructor(plugins?: readonly TPlugin[]);
|
30
|
+
init(options: StandardHandlerOptions<T>): void;
|
31
|
+
}
|
32
|
+
|
33
|
+
interface StandardHandleOptions<T extends Context> {
|
24
34
|
prefix?: HTTPPath;
|
25
|
-
} & (Record<never, never> extends T ? {
|
26
|
-
context?: T;
|
27
|
-
} : {
|
28
35
|
context: T;
|
29
|
-
}
|
36
|
+
}
|
30
37
|
type StandardHandleResult = {
|
31
38
|
matched: true;
|
32
39
|
response: StandardResponse;
|
@@ -34,42 +41,33 @@ type StandardHandleResult = {
|
|
34
41
|
matched: false;
|
35
42
|
response: undefined;
|
36
43
|
};
|
37
|
-
|
38
|
-
context: T;
|
44
|
+
interface StandardHandlerInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
|
39
45
|
request: StandardLazyRequest;
|
40
|
-
}
|
46
|
+
}
|
41
47
|
interface StandardHandlerOptions<TContext extends Context> {
|
42
|
-
plugins?:
|
48
|
+
plugins?: StandardHandlerPlugin<TContext>[];
|
43
49
|
/**
|
44
50
|
* Interceptors at the request level, helpful when you want catch errors
|
45
51
|
*/
|
46
|
-
interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult,
|
52
|
+
interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, ThrowableError>[];
|
47
53
|
/**
|
48
54
|
* Interceptors at the root level, helpful when you want override the request/response
|
49
55
|
*/
|
50
|
-
rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult,
|
56
|
+
rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult, ThrowableError>[];
|
51
57
|
/**
|
52
58
|
*
|
53
59
|
* Interceptors for procedure client.
|
54
60
|
*/
|
55
|
-
clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext,
|
61
|
+
clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>, InferSchemaOutput<AnySchema>, ErrorFromErrorMap<Record<never, never>>>[];
|
56
62
|
}
|
57
63
|
declare class StandardHandler<T extends Context> {
|
58
64
|
private readonly matcher;
|
59
65
|
private readonly codec;
|
60
|
-
private readonly
|
61
|
-
private readonly
|
66
|
+
private readonly interceptors;
|
67
|
+
private readonly clientInterceptors;
|
68
|
+
private readonly rootInterceptors;
|
62
69
|
constructor(router: Router<any, T>, matcher: StandardMatcher, codec: StandardCodec, options: NoInfer<StandardHandlerOptions<T>>);
|
63
|
-
handle(request: StandardLazyRequest,
|
64
|
-
}
|
65
|
-
|
66
|
-
interface HandlerPlugin<TContext extends Context> {
|
67
|
-
init?(options: StandardHandlerOptions<TContext>): void;
|
68
|
-
}
|
69
|
-
declare class CompositePlugin<TContext extends Context> implements HandlerPlugin<TContext> {
|
70
|
-
private readonly plugins;
|
71
|
-
constructor(plugins?: HandlerPlugin<TContext>[]);
|
72
|
-
init(options: StandardHandlerOptions<TContext>): void;
|
70
|
+
handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
|
73
71
|
}
|
74
72
|
|
75
|
-
export {
|
73
|
+
export { CompositeStandardHandlerPlugin as C, type StandardHandleOptions as S, type StandardHandlerOptions as a, StandardHandler as b, type StandardCodec as c, type StandardParams as d, type StandardMatcher as e, type StandardMatchResult as f, type StandardHandleResult as g, type StandardHandlerInterceptorOptions as h, type StandardHandlerPlugin as i };
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import { C as Context } from './server.DLt5njUb.js';
|
2
|
+
import { S as StandardHandleOptions } from './server.DFFT_EZo.js';
|
3
|
+
|
4
|
+
type FriendlyStandardHandleOptions<T extends Context> = Omit<StandardHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
5
|
+
context?: T;
|
6
|
+
} : {
|
7
|
+
context: T;
|
8
|
+
});
|
9
|
+
|
10
|
+
export type { FriendlyStandardHandleOptions as F };
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/server",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.0-next.
|
4
|
+
"version": "0.0.0-next.a6dec3e",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -58,15 +58,15 @@
|
|
58
58
|
"next": ">=14.0.0"
|
59
59
|
},
|
60
60
|
"dependencies": {
|
61
|
-
"@orpc/client": "0.0.0-next.
|
62
|
-
"@orpc/
|
63
|
-
"@orpc/
|
64
|
-
"@orpc/standard-server-fetch": "0.0.0-next.
|
65
|
-
"@orpc/
|
66
|
-
"@orpc/standard-server": "0.0.0-next.
|
61
|
+
"@orpc/client": "0.0.0-next.a6dec3e",
|
62
|
+
"@orpc/shared": "0.0.0-next.a6dec3e",
|
63
|
+
"@orpc/standard-server": "0.0.0-next.a6dec3e",
|
64
|
+
"@orpc/standard-server-fetch": "0.0.0-next.a6dec3e",
|
65
|
+
"@orpc/contract": "0.0.0-next.a6dec3e",
|
66
|
+
"@orpc/standard-server-node": "0.0.0-next.a6dec3e"
|
67
67
|
},
|
68
68
|
"devDependencies": {
|
69
|
-
"
|
69
|
+
"supertest": "^7.0.0"
|
70
70
|
},
|
71
71
|
"scripts": {
|
72
72
|
"build": "unbuild",
|
@@ -1,28 +0,0 @@
|
|
1
|
-
import { RPCSerializer } from '@orpc/client/standard';
|
2
|
-
import { toStandardLazyRequest, toFetchResponse } from '@orpc/standard-server-fetch';
|
3
|
-
import { S as StandardHandler, a as RPCMatcher, R as RPCCodec } from './server.CSZRzcSW.mjs';
|
4
|
-
|
5
|
-
class RPCHandler {
|
6
|
-
standardHandler;
|
7
|
-
constructor(router, options = {}) {
|
8
|
-
const serializer = new RPCSerializer();
|
9
|
-
const matcher = new RPCMatcher();
|
10
|
-
const codec = new RPCCodec(serializer);
|
11
|
-
this.standardHandler = new StandardHandler(router, matcher, codec, options);
|
12
|
-
}
|
13
|
-
async handle(request, ...[
|
14
|
-
options = {}
|
15
|
-
]) {
|
16
|
-
const standardRequest = toStandardLazyRequest(request);
|
17
|
-
const result = await this.standardHandler.handle(standardRequest, options);
|
18
|
-
if (!result.matched) {
|
19
|
-
return result;
|
20
|
-
}
|
21
|
-
return {
|
22
|
-
matched: true,
|
23
|
-
response: toFetchResponse(result.response, options)
|
24
|
-
};
|
25
|
-
}
|
26
|
-
}
|
27
|
-
|
28
|
-
export { RPCHandler as R };
|