@orpc/server 0.0.0-next.a439c82 → 0.0.0-next.a4bc49e
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 +6 -7
- package/dist/adapters/aws-lambda/index.d.mts +45 -0
- package/dist/adapters/aws-lambda/index.d.ts +45 -0
- package/dist/adapters/aws-lambda/index.mjs +41 -0
- package/dist/adapters/bun-ws/index.d.mts +11 -11
- package/dist/adapters/bun-ws/index.d.ts +11 -11
- package/dist/adapters/bun-ws/index.mjs +17 -20
- package/dist/adapters/crossws/index.d.mts +7 -5
- package/dist/adapters/crossws/index.d.ts +7 -5
- package/dist/adapters/crossws/index.mjs +14 -17
- package/dist/adapters/fetch/index.d.mts +6 -6
- package/dist/adapters/fetch/index.d.ts +6 -6
- package/dist/adapters/fetch/index.mjs +4 -4
- package/dist/adapters/message-port/index.d.mts +30 -0
- package/dist/adapters/message-port/index.d.ts +30 -0
- package/dist/adapters/message-port/index.mjs +41 -0
- package/dist/adapters/node/index.d.mts +6 -6
- package/dist/adapters/node/index.d.ts +6 -6
- package/dist/adapters/node/index.mjs +4 -4
- package/dist/adapters/standard/index.d.mts +5 -4
- package/dist/adapters/standard/index.d.ts +5 -4
- package/dist/adapters/standard/index.mjs +4 -2
- package/dist/adapters/standard-peer/index.d.mts +14 -0
- package/dist/adapters/standard-peer/index.d.ts +14 -0
- package/dist/adapters/standard-peer/index.mjs +7 -0
- package/dist/adapters/websocket/index.d.mts +35 -9
- package/dist/adapters/websocket/index.d.ts +35 -9
- package/dist/adapters/websocket/index.mjs +52 -20
- package/dist/adapters/ws/index.d.mts +10 -8
- package/dist/adapters/ws/index.d.ts +10 -8
- package/dist/adapters/ws/index.mjs +16 -14
- package/dist/hibernation/index.d.mts +44 -0
- package/dist/hibernation/index.d.ts +44 -0
- package/dist/hibernation/index.mjs +65 -0
- package/dist/index.d.mts +17 -12
- package/dist/index.d.ts +17 -12
- package/dist/index.mjs +22 -8
- package/dist/plugins/index.d.mts +13 -13
- package/dist/plugins/index.d.ts +13 -13
- package/dist/plugins/index.mjs +14 -6
- package/dist/shared/{server.DPWk5pjW.d.mts → server.6ohwBdwx.d.mts} +6 -6
- package/dist/shared/{server.DPWk5pjW.d.ts → server.6ohwBdwx.d.ts} +6 -6
- package/dist/shared/server.B3dVpAsJ.d.mts +12 -0
- package/dist/shared/{server.Cy1vfSiG.d.ts → server.B6GspgNq.d.ts} +2 -2
- package/dist/shared/{server.YZzrREz9.d.ts → server.BE3B4vij.d.ts} +8 -8
- package/dist/shared/{server.eWLxY3lq.d.mts → server.BtQsqpPB.d.mts} +8 -8
- package/dist/shared/server.C6Q5sqYw.mjs +20 -0
- package/dist/shared/{server.SxlTJfG2.mjs → server.CB8Snncu.mjs} +8 -5
- package/dist/shared/{server.BRoxSiSC.d.mts → server.CKafa5G2.d.mts} +2 -2
- package/dist/shared/server.CeW2jMCj.d.ts +12 -0
- package/dist/shared/{server.DG7Tamti.mjs → server.DLJzqnSX.mjs} +3 -2
- package/dist/shared/{server.BVwwTHyO.mjs → server.DZ5BIITo.mjs} +1 -1
- package/package.json +41 -12
- package/dist/shared/server.BjiJH9Vo.d.ts +0 -10
- package/dist/shared/server.QUe9N8P4.d.mts +0 -10
@@ -1,8 +1,8 @@
|
|
1
1
|
import { HTTPPath, ORPCError } from '@orpc/client';
|
2
|
-
import { Meta
|
3
|
-
import { Interceptor
|
2
|
+
import { Meta } from '@orpc/contract';
|
3
|
+
import { Interceptor } from '@orpc/shared';
|
4
4
|
import { StandardResponse, StandardLazyRequest } from '@orpc/standard-server';
|
5
|
-
import { C as Context, R as Router,
|
5
|
+
import { C as Context, R as Router, a as AnyRouter, A as AnyProcedure, P as ProcedureClientInterceptorOptions } from './server.6ohwBdwx.mjs';
|
6
6
|
|
7
7
|
interface StandardHandlerPlugin<T extends Context> {
|
8
8
|
order?: number;
|
@@ -49,16 +49,16 @@ interface StandardHandlerOptions<TContext extends Context> {
|
|
49
49
|
/**
|
50
50
|
* Interceptors at the request level, helpful when you want catch errors
|
51
51
|
*/
|
52
|
-
interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult
|
52
|
+
interceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, Promise<StandardHandleResult>>[];
|
53
53
|
/**
|
54
54
|
* Interceptors at the root level, helpful when you want override the request/response
|
55
55
|
*/
|
56
|
-
rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, StandardHandleResult
|
56
|
+
rootInterceptors?: Interceptor<StandardHandlerInterceptorOptions<TContext>, Promise<StandardHandleResult>>[];
|
57
57
|
/**
|
58
58
|
*
|
59
59
|
* Interceptors for procedure client.
|
60
60
|
*/
|
61
|
-
clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>,
|
61
|
+
clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, Record<never, never>, Meta>, Promise<unknown>>[];
|
62
62
|
}
|
63
63
|
declare class StandardHandler<T extends Context> {
|
64
64
|
private readonly matcher;
|
@@ -70,5 +70,5 @@ declare class StandardHandler<T extends Context> {
|
|
70
70
|
handle(request: StandardLazyRequest, options: StandardHandleOptions<T>): Promise<StandardHandleResult>;
|
71
71
|
}
|
72
72
|
|
73
|
-
export { CompositeStandardHandlerPlugin as C, StandardHandler as
|
74
|
-
export type {
|
73
|
+
export { CompositeStandardHandlerPlugin as C, StandardHandler as a };
|
74
|
+
export type { StandardHandlerOptions as S, StandardHandleOptions as b, StandardHandlerPlugin as c, StandardCodec as d, StandardParams as e, StandardMatcher as f, StandardMatchResult as g, StandardHandleResult as h, StandardHandlerInterceptorOptions as i };
|
@@ -0,0 +1,20 @@
|
|
1
|
+
import '@orpc/client';
|
2
|
+
import '@orpc/shared';
|
3
|
+
import '@orpc/standard-server';
|
4
|
+
import '@orpc/contract';
|
5
|
+
import '@orpc/client/standard';
|
6
|
+
import { r as resolveFriendlyStandardHandleOptions } from './server.DZ5BIITo.mjs';
|
7
|
+
|
8
|
+
async function handleStandardServerPeerMessage(handler, peer, message, options) {
|
9
|
+
const [id, request] = await peer.message(message);
|
10
|
+
if (!request) {
|
11
|
+
return;
|
12
|
+
}
|
13
|
+
const { response } = await handler.handle(
|
14
|
+
{ ...request, body: () => Promise.resolve(request.body) },
|
15
|
+
resolveFriendlyStandardHandleOptions(options)
|
16
|
+
);
|
17
|
+
await peer.response(id, response ?? { status: 404, headers: {}, body: "No procedure matched" });
|
18
|
+
}
|
19
|
+
|
20
|
+
export { handleStandardServerPeerMessage as h };
|
@@ -1,7 +1,8 @@
|
|
1
1
|
import { toHttpPath, StandardRPCJsonSerializer, StandardRPCSerializer } from '@orpc/client/standard';
|
2
2
|
import { ORPCError, toORPCError } from '@orpc/client';
|
3
|
-
import { toArray, intercept, parseEmptyableJSON } from '@orpc/shared';
|
4
|
-
import {
|
3
|
+
import { toArray, intercept, parseEmptyableJSON, NullProtoObj } from '@orpc/shared';
|
4
|
+
import { flattenHeader } from '@orpc/standard-server';
|
5
|
+
import { c as createProcedureClient, t as traverseContractProcedures, i as isProcedure, u as unlazy, g as getRouter, a as createContractedProcedure } from './server.DLJzqnSX.mjs';
|
5
6
|
|
6
7
|
class CompositeStandardHandlerPlugin {
|
7
8
|
plugins;
|
@@ -59,8 +60,10 @@ class StandardHandler {
|
|
59
60
|
isDecoding = true;
|
60
61
|
const input = await this.codec.decode(request2, match.params, match.procedure);
|
61
62
|
isDecoding = false;
|
62
|
-
const
|
63
|
-
|
63
|
+
const output = await client(input, {
|
64
|
+
signal: request2.signal,
|
65
|
+
lastEventId: flattenHeader(request2.headers["last-event-id"])
|
66
|
+
});
|
64
67
|
const response = this.codec.encode(output, match.procedure);
|
65
68
|
return {
|
66
69
|
matched: true,
|
@@ -109,7 +112,7 @@ class StandardRPCCodec {
|
|
109
112
|
}
|
110
113
|
|
111
114
|
class StandardRPCMatcher {
|
112
|
-
tree =
|
115
|
+
tree = new NullProtoObj();
|
113
116
|
pendingRouters = [];
|
114
117
|
init(router, path = []) {
|
115
118
|
const laziedOptions = traverseContractProcedures({ router, path }, ({ path: path2, contract }) => {
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
|
2
|
-
import { C as Context, R as Router } from './server.
|
3
|
-
import {
|
2
|
+
import { C as Context, R as Router } from './server.6ohwBdwx.mjs';
|
3
|
+
import { S as StandardHandlerOptions, a as StandardHandler } from './server.BtQsqpPB.mjs';
|
4
4
|
|
5
5
|
interface StandardRPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardRPCJsonSerializerOptions {
|
6
6
|
}
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { C as Context } from './server.6ohwBdwx.js';
|
2
|
+
import { b as StandardHandleOptions } from './server.BE3B4vij.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
|
+
declare function resolveFriendlyStandardHandleOptions<T extends Context>(options: FriendlyStandardHandleOptions<T>): StandardHandleOptions<T>;
|
10
|
+
|
11
|
+
export { resolveFriendlyStandardHandleOptions as r };
|
12
|
+
export type { FriendlyStandardHandleOptions as F };
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { isContractProcedure, ValidationError, mergePrefix, mergeErrorMap, enhanceRoute } from '@orpc/contract';
|
2
|
+
import { value, intercept, resolveMaybeOptionalOptions } from '@orpc/shared';
|
2
3
|
import { fallbackORPCErrorStatus, ORPCError } from '@orpc/client';
|
3
|
-
import { value, intercept } from '@orpc/shared';
|
4
4
|
|
5
5
|
const LAZY_SYMBOL = Symbol("ORPC_LAZY_SYMBOL");
|
6
6
|
function lazy(loader, meta = {}) {
|
@@ -361,7 +361,8 @@ function createContractedProcedure(procedure, contract) {
|
|
361
361
|
});
|
362
362
|
}
|
363
363
|
function call(procedure, input, ...rest) {
|
364
|
-
|
364
|
+
const options = resolveMaybeOptionalOptions(rest);
|
365
|
+
return createProcedureClient(procedure, options)(input, options);
|
365
366
|
}
|
366
367
|
|
367
368
|
export { LAZY_SYMBOL as L, Procedure as P, createContractedProcedure as a, addMiddleware as b, createProcedureClient as c, isLazy as d, enhanceRouter as e, createAssertedLazyProcedure as f, getRouter as g, createORPCErrorConstructorMap as h, isProcedure as i, getLazyMeta as j, middlewareOutputFn as k, lazy as l, mergeCurrentContext as m, isStartWithMiddlewares as n, mergeMiddlewares as o, call as p, getHiddenRouterContract as q, createAccessibleLazyRouter as r, setHiddenRouterContract as s, traverseContractProcedures as t, unlazy as u, validateORPCError as v, resolveContractProcedures as w, unlazyRouter as x };
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/server",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.0-next.
|
4
|
+
"version": "0.0.0-next.a4bc49e",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -24,11 +24,21 @@
|
|
24
24
|
"import": "./dist/plugins/index.mjs",
|
25
25
|
"default": "./dist/plugins/index.mjs"
|
26
26
|
},
|
27
|
+
"./hibernation": {
|
28
|
+
"types": "./dist/hibernation/index.d.mts",
|
29
|
+
"import": "./dist/hibernation/index.mjs",
|
30
|
+
"default": "./dist/hibernation/index.mjs"
|
31
|
+
},
|
27
32
|
"./standard": {
|
28
33
|
"types": "./dist/adapters/standard/index.d.mts",
|
29
34
|
"import": "./dist/adapters/standard/index.mjs",
|
30
35
|
"default": "./dist/adapters/standard/index.mjs"
|
31
36
|
},
|
37
|
+
"./standard-peer": {
|
38
|
+
"types": "./dist/adapters/standard-peer/index.d.mts",
|
39
|
+
"import": "./dist/adapters/standard-peer/index.mjs",
|
40
|
+
"default": "./dist/adapters/standard-peer/index.mjs"
|
41
|
+
},
|
32
42
|
"./fetch": {
|
33
43
|
"types": "./dist/adapters/fetch/index.d.mts",
|
34
44
|
"import": "./dist/adapters/fetch/index.mjs",
|
@@ -39,6 +49,11 @@
|
|
39
49
|
"import": "./dist/adapters/node/index.mjs",
|
40
50
|
"default": "./dist/adapters/node/index.mjs"
|
41
51
|
},
|
52
|
+
"./aws-lambda": {
|
53
|
+
"types": "./dist/adapters/aws-lambda/index.d.mts",
|
54
|
+
"import": "./dist/adapters/aws-lambda/index.mjs",
|
55
|
+
"default": "./dist/adapters/aws-lambda/index.mjs"
|
56
|
+
},
|
42
57
|
"./websocket": {
|
43
58
|
"types": "./dist/adapters/websocket/index.d.mts",
|
44
59
|
"import": "./dist/adapters/websocket/index.mjs",
|
@@ -58,6 +73,11 @@
|
|
58
73
|
"types": "./dist/adapters/bun-ws/index.d.mts",
|
59
74
|
"import": "./dist/adapters/bun-ws/index.mjs",
|
60
75
|
"default": "./dist/adapters/bun-ws/index.mjs"
|
76
|
+
},
|
77
|
+
"./message-port": {
|
78
|
+
"types": "./dist/adapters/message-port/index.d.mts",
|
79
|
+
"import": "./dist/adapters/message-port/index.mjs",
|
80
|
+
"default": "./dist/adapters/message-port/index.mjs"
|
61
81
|
}
|
62
82
|
},
|
63
83
|
"files": [
|
@@ -67,21 +87,30 @@
|
|
67
87
|
"crossws": ">=0.3.4",
|
68
88
|
"ws": ">=8.18.1"
|
69
89
|
},
|
90
|
+
"peerDependenciesMeta": {
|
91
|
+
"crossws": {
|
92
|
+
"optional": true
|
93
|
+
},
|
94
|
+
"ws": {
|
95
|
+
"optional": true
|
96
|
+
}
|
97
|
+
},
|
70
98
|
"dependencies": {
|
71
|
-
"@orpc/client": "0.0.0-next.
|
72
|
-
"@orpc/
|
73
|
-
"@orpc/
|
74
|
-
"@orpc/standard-server
|
75
|
-
"@orpc/standard-server-
|
76
|
-
"@orpc/standard-server-
|
77
|
-
"@orpc/
|
99
|
+
"@orpc/client": "0.0.0-next.a4bc49e",
|
100
|
+
"@orpc/shared": "0.0.0-next.a4bc49e",
|
101
|
+
"@orpc/contract": "0.0.0-next.a4bc49e",
|
102
|
+
"@orpc/standard-server": "0.0.0-next.a4bc49e",
|
103
|
+
"@orpc/standard-server-aws-lambda": "0.0.0-next.a4bc49e",
|
104
|
+
"@orpc/standard-server-fetch": "0.0.0-next.a4bc49e",
|
105
|
+
"@orpc/standard-server-peer": "0.0.0-next.a4bc49e",
|
106
|
+
"@orpc/standard-server-node": "0.0.0-next.a4bc49e"
|
78
107
|
},
|
79
108
|
"devDependencies": {
|
80
109
|
"@types/ws": "^8.18.1",
|
81
|
-
"crossws": "^0.
|
82
|
-
"next": "^15.3.
|
83
|
-
"supertest": "^7.1.
|
84
|
-
"ws": "^8.18.
|
110
|
+
"crossws": "^0.4.1",
|
111
|
+
"next": "^15.3.5",
|
112
|
+
"supertest": "^7.1.3",
|
113
|
+
"ws": "^8.18.3"
|
85
114
|
},
|
86
115
|
"scripts": {
|
87
116
|
"build": "unbuild",
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import { C as Context } from './server.DPWk5pjW.js';
|
2
|
-
import { g as StandardHandleOptions } from './server.YZzrREz9.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 };
|
@@ -1,10 +0,0 @@
|
|
1
|
-
import { C as Context } from './server.DPWk5pjW.mjs';
|
2
|
-
import { g as StandardHandleOptions } from './server.eWLxY3lq.mjs';
|
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 };
|