@orpc/server 1.6.8 → 1.7.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.
- package/README.md +1 -1
- package/dist/adapters/aws-lambda/index.d.mts +6 -5
- package/dist/adapters/aws-lambda/index.d.ts +6 -5
- package/dist/adapters/aws-lambda/index.mjs +4 -3
- package/dist/adapters/bun-ws/index.d.mts +11 -10
- package/dist/adapters/bun-ws/index.d.ts +11 -10
- package/dist/adapters/bun-ws/index.mjs +13 -11
- package/dist/adapters/crossws/index.d.mts +7 -4
- package/dist/adapters/crossws/index.d.ts +7 -4
- package/dist/adapters/crossws/index.mjs +10 -8
- package/dist/adapters/fetch/index.d.mts +4 -3
- package/dist/adapters/fetch/index.d.ts +4 -3
- package/dist/adapters/fetch/index.mjs +2 -1
- package/dist/adapters/message-port/index.d.mts +10 -7
- package/dist/adapters/message-port/index.d.ts +10 -7
- package/dist/adapters/message-port/index.mjs +12 -11
- package/dist/adapters/node/index.d.mts +4 -3
- package/dist/adapters/node/index.d.ts +4 -3
- package/dist/adapters/node/index.mjs +2 -1
- package/dist/adapters/standard/index.d.mts +5 -4
- package/dist/adapters/standard/index.d.ts +5 -4
- package/dist/adapters/standard/index.mjs +2 -1
- 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 +14 -11
- package/dist/adapters/websocket/index.d.ts +14 -11
- package/dist/adapters/websocket/index.mjs +14 -13
- package/dist/adapters/ws/index.d.mts +10 -7
- package/dist/adapters/ws/index.d.ts +10 -7
- package/dist/adapters/ws/index.mjs +14 -13
- package/dist/hibernation/index.d.mts +2 -2
- package/dist/hibernation/index.d.ts +2 -2
- package/dist/index.d.mts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/index.d.ts +2 -2
- package/dist/shared/{server.DD2C4ujN.d.mts → server.6ohwBdwx.d.mts} +2 -2
- package/dist/shared/{server.DD2C4ujN.d.ts → server.6ohwBdwx.d.ts} +2 -2
- package/dist/shared/server.B3dVpAsJ.d.mts +12 -0
- package/dist/shared/server.B6GspgNq.d.ts +12 -0
- package/dist/shared/{server.-ACo36I0.d.ts → server.BE3B4vij.d.ts} +3 -3
- package/dist/shared/{server.Dq8xr7PQ.d.mts → server.BtQsqpPB.d.mts} +3 -3
- package/dist/shared/server.C6Q5sqYw.mjs +20 -0
- package/dist/shared/{server.CQ4gr8z6.mjs → server.CB8Snncu.mjs} +1 -9
- package/dist/shared/server.CKafa5G2.d.mts +12 -0
- package/dist/shared/server.CeW2jMCj.d.ts +12 -0
- package/dist/shared/server.DZ5BIITo.mjs +9 -0
- package/package.json +15 -10
- package/dist/shared/server.CLcOiNNH.d.ts +0 -19
- package/dist/shared/server.D2T2AlNJ.d.mts +0 -19
@@ -0,0 +1,7 @@
|
|
1
|
+
export { h as handleStandardServerPeerMessage } from '../../shared/server.C6Q5sqYw.mjs';
|
2
|
+
import '@orpc/client';
|
3
|
+
import '@orpc/shared';
|
4
|
+
import '@orpc/standard-server';
|
5
|
+
import '@orpc/contract';
|
6
|
+
import '@orpc/client/standard';
|
7
|
+
import '../../shared/server.DZ5BIITo.mjs';
|
@@ -1,14 +1,17 @@
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
2
|
-
import { C as Context, R as Router } from '../../shared/server.
|
3
|
-
import {
|
4
|
-
import {
|
2
|
+
import { C as Context, R as Router } from '../../shared/server.6ohwBdwx.mjs';
|
3
|
+
import { a as StandardHandler } from '../../shared/server.BtQsqpPB.mjs';
|
4
|
+
import { HandleStandardServerPeerMessageOptions } from '../standard-peer/index.mjs';
|
5
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.CKafa5G2.mjs';
|
5
6
|
import '@orpc/client';
|
6
7
|
import '@orpc/contract';
|
7
8
|
import '@orpc/standard-server';
|
9
|
+
import '@orpc/standard-server-peer';
|
10
|
+
import '../../shared/server.B3dVpAsJ.mjs';
|
8
11
|
import '@orpc/client/standard';
|
9
12
|
|
10
|
-
type
|
11
|
-
declare class
|
13
|
+
type MinimalWebsocket = Pick<WebSocket, 'addEventListener' | 'send'>;
|
14
|
+
declare class WebsocketHandler<T extends Context> {
|
12
15
|
#private;
|
13
16
|
constructor(standardHandler: StandardHandler<T>);
|
14
17
|
/**
|
@@ -18,7 +21,7 @@ declare class experimental_WebsocketHandler<T extends Context> {
|
|
18
21
|
*
|
19
22
|
* @warning Do not use this method if you're using `.message()` or `.close()`
|
20
23
|
*/
|
21
|
-
upgrade(ws:
|
24
|
+
upgrade(ws: MinimalWebsocket, ...rest: MaybeOptionalOptions<HandleStandardServerPeerMessageOptions<T>>): void;
|
22
25
|
/**
|
23
26
|
* Handles a single message received from a WebSocket.
|
24
27
|
*
|
@@ -27,13 +30,13 @@ declare class experimental_WebsocketHandler<T extends Context> {
|
|
27
30
|
* @param ws The WebSocket instance
|
28
31
|
* @param data The message payload, usually place in `event.data`
|
29
32
|
*/
|
30
|
-
message(ws:
|
33
|
+
message(ws: MinimalWebsocket, data: string | ArrayBuffer | Blob, ...rest: MaybeOptionalOptions<HandleStandardServerPeerMessageOptions<T>>): Promise<void>;
|
31
34
|
/**
|
32
35
|
* Closes the WebSocket peer and cleans up.
|
33
36
|
*
|
34
37
|
* @warning Avoid calling this directly if `.upgrade()` is used.
|
35
38
|
*/
|
36
|
-
close(ws:
|
39
|
+
close(ws: MinimalWebsocket): void;
|
37
40
|
}
|
38
41
|
|
39
42
|
/**
|
@@ -42,9 +45,9 @@ declare class experimental_WebsocketHandler<T extends Context> {
|
|
42
45
|
* @see {@link https://orpc.unnoq.com/docs/rpc-handler RPC Handler Docs}
|
43
46
|
* @see {@link https://orpc.unnoq.com/docs/adapters/websocket Websocket Adapter Docs}
|
44
47
|
*/
|
45
|
-
declare class
|
48
|
+
declare class RPCHandler<T extends Context> extends WebsocketHandler<T> {
|
46
49
|
constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T>>);
|
47
50
|
}
|
48
51
|
|
49
|
-
export {
|
50
|
-
export type {
|
52
|
+
export { RPCHandler, WebsocketHandler };
|
53
|
+
export type { MinimalWebsocket };
|
@@ -1,14 +1,17 @@
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
2
|
-
import { C as Context, R as Router } from '../../shared/server.
|
3
|
-
import {
|
4
|
-
import {
|
2
|
+
import { C as Context, R as Router } from '../../shared/server.6ohwBdwx.js';
|
3
|
+
import { a as StandardHandler } from '../../shared/server.BE3B4vij.js';
|
4
|
+
import { HandleStandardServerPeerMessageOptions } from '../standard-peer/index.js';
|
5
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.B6GspgNq.js';
|
5
6
|
import '@orpc/client';
|
6
7
|
import '@orpc/contract';
|
7
8
|
import '@orpc/standard-server';
|
9
|
+
import '@orpc/standard-server-peer';
|
10
|
+
import '../../shared/server.CeW2jMCj.js';
|
8
11
|
import '@orpc/client/standard';
|
9
12
|
|
10
|
-
type
|
11
|
-
declare class
|
13
|
+
type MinimalWebsocket = Pick<WebSocket, 'addEventListener' | 'send'>;
|
14
|
+
declare class WebsocketHandler<T extends Context> {
|
12
15
|
#private;
|
13
16
|
constructor(standardHandler: StandardHandler<T>);
|
14
17
|
/**
|
@@ -18,7 +21,7 @@ declare class experimental_WebsocketHandler<T extends Context> {
|
|
18
21
|
*
|
19
22
|
* @warning Do not use this method if you're using `.message()` or `.close()`
|
20
23
|
*/
|
21
|
-
upgrade(ws:
|
24
|
+
upgrade(ws: MinimalWebsocket, ...rest: MaybeOptionalOptions<HandleStandardServerPeerMessageOptions<T>>): void;
|
22
25
|
/**
|
23
26
|
* Handles a single message received from a WebSocket.
|
24
27
|
*
|
@@ -27,13 +30,13 @@ declare class experimental_WebsocketHandler<T extends Context> {
|
|
27
30
|
* @param ws The WebSocket instance
|
28
31
|
* @param data The message payload, usually place in `event.data`
|
29
32
|
*/
|
30
|
-
message(ws:
|
33
|
+
message(ws: MinimalWebsocket, data: string | ArrayBuffer | Blob, ...rest: MaybeOptionalOptions<HandleStandardServerPeerMessageOptions<T>>): Promise<void>;
|
31
34
|
/**
|
32
35
|
* Closes the WebSocket peer and cleans up.
|
33
36
|
*
|
34
37
|
* @warning Avoid calling this directly if `.upgrade()` is used.
|
35
38
|
*/
|
36
|
-
close(ws:
|
39
|
+
close(ws: MinimalWebsocket): void;
|
37
40
|
}
|
38
41
|
|
39
42
|
/**
|
@@ -42,9 +45,9 @@ declare class experimental_WebsocketHandler<T extends Context> {
|
|
42
45
|
* @see {@link https://orpc.unnoq.com/docs/rpc-handler RPC Handler Docs}
|
43
46
|
* @see {@link https://orpc.unnoq.com/docs/adapters/websocket Websocket Adapter Docs}
|
44
47
|
*/
|
45
|
-
declare class
|
48
|
+
declare class RPCHandler<T extends Context> extends WebsocketHandler<T> {
|
46
49
|
constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T>>);
|
47
50
|
}
|
48
51
|
|
49
|
-
export {
|
50
|
-
export type {
|
52
|
+
export { RPCHandler, WebsocketHandler };
|
53
|
+
export type { MinimalWebsocket };
|
@@ -1,13 +1,15 @@
|
|
1
|
-
import { resolveMaybeOptionalOptions } from '@orpc/shared';
|
1
|
+
import { readAsBuffer, resolveMaybeOptionalOptions } from '@orpc/shared';
|
2
2
|
import { ServerPeer } from '@orpc/standard-server-peer';
|
3
|
-
import {
|
3
|
+
import { h as handleStandardServerPeerMessage } from '../../shared/server.C6Q5sqYw.mjs';
|
4
4
|
import '@orpc/client';
|
5
5
|
import '@orpc/standard-server';
|
6
6
|
import '@orpc/contract';
|
7
|
+
import { b as StandardRPCHandler } from '../../shared/server.CB8Snncu.mjs';
|
7
8
|
import '@orpc/client/standard';
|
9
|
+
import '../../shared/server.DZ5BIITo.mjs';
|
8
10
|
import '../../shared/server.DLJzqnSX.mjs';
|
9
11
|
|
10
|
-
class
|
12
|
+
class WebsocketHandler {
|
11
13
|
#peers = /* @__PURE__ */ new WeakMap();
|
12
14
|
#handler;
|
13
15
|
constructor(standardHandler) {
|
@@ -37,14 +39,13 @@ class experimental_WebsocketHandler {
|
|
37
39
|
if (!peer) {
|
38
40
|
this.#peers.set(ws, peer = new ServerPeer(ws.send.bind(ws)));
|
39
41
|
}
|
40
|
-
const message = data instanceof Blob ? await data
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
await peer.response(id, response ?? { status: 404, headers: {}, body: "No procedure matched" });
|
42
|
+
const message = data instanceof Blob ? await readAsBuffer(data) : data;
|
43
|
+
await handleStandardServerPeerMessage(
|
44
|
+
this.#handler,
|
45
|
+
peer,
|
46
|
+
message,
|
47
|
+
resolveMaybeOptionalOptions(rest)
|
48
|
+
);
|
48
49
|
}
|
49
50
|
/**
|
50
51
|
* Closes the WebSocket peer and cleans up.
|
@@ -59,10 +60,10 @@ class experimental_WebsocketHandler {
|
|
59
60
|
}
|
60
61
|
}
|
61
62
|
|
62
|
-
class
|
63
|
+
class RPCHandler extends WebsocketHandler {
|
63
64
|
constructor(router, options = {}) {
|
64
65
|
super(new StandardRPCHandler(router, options));
|
65
66
|
}
|
66
67
|
}
|
67
68
|
|
68
|
-
export {
|
69
|
+
export { RPCHandler, WebsocketHandler };
|
@@ -1,17 +1,20 @@
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
2
2
|
import { WebSocket } from 'ws';
|
3
|
-
import { C as Context, R as Router } from '../../shared/server.
|
4
|
-
import {
|
5
|
-
import {
|
3
|
+
import { C as Context, R as Router } from '../../shared/server.6ohwBdwx.mjs';
|
4
|
+
import { a as StandardHandler } from '../../shared/server.BtQsqpPB.mjs';
|
5
|
+
import { HandleStandardServerPeerMessageOptions } from '../standard-peer/index.mjs';
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.CKafa5G2.mjs';
|
6
7
|
import '@orpc/client';
|
7
8
|
import '@orpc/contract';
|
8
9
|
import '@orpc/standard-server';
|
10
|
+
import '@orpc/standard-server-peer';
|
11
|
+
import '../../shared/server.B3dVpAsJ.mjs';
|
9
12
|
import '@orpc/client/standard';
|
10
13
|
|
11
|
-
declare class
|
14
|
+
declare class WsHandler<T extends Context> {
|
12
15
|
private readonly standardHandler;
|
13
16
|
constructor(standardHandler: StandardHandler<T>);
|
14
|
-
upgrade(ws: Pick<WebSocket, 'addEventListener' | 'send'>, ...rest: MaybeOptionalOptions<
|
17
|
+
upgrade(ws: Pick<WebSocket, 'addEventListener' | 'send'>, ...rest: MaybeOptionalOptions<HandleStandardServerPeerMessageOptions<T>>): Promise<void>;
|
15
18
|
}
|
16
19
|
|
17
20
|
/**
|
@@ -20,8 +23,8 @@ declare class experimental_WsHandler<T extends Context> {
|
|
20
23
|
* @see {@link https://orpc.unnoq.com/docs/rpc-handler RPC Handler Docs}
|
21
24
|
* @see {@link https://orpc.unnoq.com/docs/adapters/websocket Websocket Adapter Docs}
|
22
25
|
*/
|
23
|
-
declare class
|
26
|
+
declare class RPCHandler<T extends Context> extends WsHandler<T> {
|
24
27
|
constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T>>);
|
25
28
|
}
|
26
29
|
|
27
|
-
export {
|
30
|
+
export { RPCHandler, WsHandler };
|
@@ -1,17 +1,20 @@
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
2
2
|
import { WebSocket } from 'ws';
|
3
|
-
import { C as Context, R as Router } from '../../shared/server.
|
4
|
-
import {
|
5
|
-
import {
|
3
|
+
import { C as Context, R as Router } from '../../shared/server.6ohwBdwx.js';
|
4
|
+
import { a as StandardHandler } from '../../shared/server.BE3B4vij.js';
|
5
|
+
import { HandleStandardServerPeerMessageOptions } from '../standard-peer/index.js';
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.B6GspgNq.js';
|
6
7
|
import '@orpc/client';
|
7
8
|
import '@orpc/contract';
|
8
9
|
import '@orpc/standard-server';
|
10
|
+
import '@orpc/standard-server-peer';
|
11
|
+
import '../../shared/server.CeW2jMCj.js';
|
9
12
|
import '@orpc/client/standard';
|
10
13
|
|
11
|
-
declare class
|
14
|
+
declare class WsHandler<T extends Context> {
|
12
15
|
private readonly standardHandler;
|
13
16
|
constructor(standardHandler: StandardHandler<T>);
|
14
|
-
upgrade(ws: Pick<WebSocket, 'addEventListener' | 'send'>, ...rest: MaybeOptionalOptions<
|
17
|
+
upgrade(ws: Pick<WebSocket, 'addEventListener' | 'send'>, ...rest: MaybeOptionalOptions<HandleStandardServerPeerMessageOptions<T>>): Promise<void>;
|
15
18
|
}
|
16
19
|
|
17
20
|
/**
|
@@ -20,8 +23,8 @@ declare class experimental_WsHandler<T extends Context> {
|
|
20
23
|
* @see {@link https://orpc.unnoq.com/docs/rpc-handler RPC Handler Docs}
|
21
24
|
* @see {@link https://orpc.unnoq.com/docs/adapters/websocket Websocket Adapter Docs}
|
22
25
|
*/
|
23
|
-
declare class
|
26
|
+
declare class RPCHandler<T extends Context> extends WsHandler<T> {
|
24
27
|
constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T>>);
|
25
28
|
}
|
26
29
|
|
27
|
-
export {
|
30
|
+
export { RPCHandler, WsHandler };
|
@@ -1,27 +1,28 @@
|
|
1
|
-
import { resolveMaybeOptionalOptions } from '@orpc/shared';
|
1
|
+
import { readAsBuffer, resolveMaybeOptionalOptions } from '@orpc/shared';
|
2
2
|
import { ServerPeer } from '@orpc/standard-server-peer';
|
3
|
-
import {
|
3
|
+
import { h as handleStandardServerPeerMessage } from '../../shared/server.C6Q5sqYw.mjs';
|
4
4
|
import '@orpc/client';
|
5
5
|
import '@orpc/standard-server';
|
6
6
|
import '@orpc/contract';
|
7
|
+
import { b as StandardRPCHandler } from '../../shared/server.CB8Snncu.mjs';
|
7
8
|
import '@orpc/client/standard';
|
9
|
+
import '../../shared/server.DZ5BIITo.mjs';
|
8
10
|
import '../../shared/server.DLJzqnSX.mjs';
|
9
11
|
|
10
|
-
class
|
12
|
+
class WsHandler {
|
11
13
|
constructor(standardHandler) {
|
12
14
|
this.standardHandler = standardHandler;
|
13
15
|
}
|
14
16
|
async upgrade(ws, ...rest) {
|
15
17
|
const peer = new ServerPeer(ws.send.bind(ws));
|
16
18
|
ws.addEventListener("message", async (event) => {
|
17
|
-
const message = Array.isArray(event.data) ? await new Blob(event.data)
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
await peer.response(id, response ?? { status: 404, headers: {}, body: "No procedure matched" });
|
19
|
+
const message = Array.isArray(event.data) ? await readAsBuffer(new Blob(event.data)) : event.data;
|
20
|
+
await handleStandardServerPeerMessage(
|
21
|
+
this.standardHandler,
|
22
|
+
peer,
|
23
|
+
message,
|
24
|
+
resolveMaybeOptionalOptions(rest)
|
25
|
+
);
|
25
26
|
});
|
26
27
|
ws.addEventListener("close", () => {
|
27
28
|
peer.close();
|
@@ -29,10 +30,10 @@ class experimental_WsHandler {
|
|
29
30
|
}
|
30
31
|
}
|
31
32
|
|
32
|
-
class
|
33
|
+
class RPCHandler extends WsHandler {
|
33
34
|
constructor(router, options = {}) {
|
34
35
|
super(new StandardRPCHandler(router, options));
|
35
36
|
}
|
36
37
|
}
|
37
38
|
|
38
|
-
export {
|
39
|
+
export { RPCHandler, WsHandler };
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
|
2
|
-
import {
|
2
|
+
import { c as StandardHandlerPlugin, S as StandardHandlerOptions } from '../shared/server.BtQsqpPB.mjs';
|
3
3
|
import { experimental_HibernationEventIterator } from '@orpc/standard-server';
|
4
4
|
export { experimental_HibernationEventIterator, experimental_HibernationEventIteratorCallback } from '@orpc/standard-server';
|
5
|
-
import { C as Context, R as Router } from '../shared/server.
|
5
|
+
import { C as Context, R as Router } from '../shared/server.6ohwBdwx.mjs';
|
6
6
|
import '@orpc/client';
|
7
7
|
import '@orpc/contract';
|
8
8
|
import '@orpc/shared';
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
|
2
|
-
import {
|
2
|
+
import { c as StandardHandlerPlugin, S as StandardHandlerOptions } from '../shared/server.BE3B4vij.js';
|
3
3
|
import { experimental_HibernationEventIterator } from '@orpc/standard-server';
|
4
4
|
export { experimental_HibernationEventIterator, experimental_HibernationEventIteratorCallback } from '@orpc/standard-server';
|
5
|
-
import { C as Context, R as Router } from '../shared/server.
|
5
|
+
import { C as Context, R as Router } from '../shared/server.6ohwBdwx.js';
|
6
6
|
import '@orpc/client';
|
7
7
|
import '@orpc/contract';
|
8
8
|
import '@orpc/shared';
|
package/dist/index.d.mts
CHANGED
@@ -4,8 +4,8 @@ import { AnySchema, ErrorMap, InferSchemaInput, InferSchemaOutput, ErrorFromErro
|
|
4
4
|
export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, InputStructure, MergedErrorMap, Meta, OutputStructure, Route, Schema, ValidationError, eventIterator, type } from '@orpc/contract';
|
5
5
|
import { ThrowableError, IntersectPick, MaybeOptionalOptions } from '@orpc/shared';
|
6
6
|
export { EventPublisher, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, IntersectPick, Registry, ThrowableError, onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
7
|
-
import { C as Context,
|
8
|
-
export { J as InferRouterCurrentContexts, H as InferRouterInitialContexts, K as InferRouterInputs, N as InferRouterOutputs,
|
7
|
+
import { C as Context, b as Procedure, M as Middleware, O as ORPCErrorConstructorMap, c as MergedInitialContext, d as MergedCurrentContext, e as MapInputMiddleware, f as CreateProcedureClientOptions, g as ProcedureClient, h as AnyMiddleware, L as Lazyable, a as AnyRouter, i as Lazy, A as AnyProcedure, j as ProcedureHandler, R as Router, I as InferRouterInitialContext } from './shared/server.6ohwBdwx.mjs';
|
8
|
+
export { J as InferRouterCurrentContexts, H as InferRouterInitialContexts, K as InferRouterInputs, N as InferRouterOutputs, o as LAZY_SYMBOL, p as LazyMeta, x as MiddlewareNextFn, w as MiddlewareNextFnOptions, z as MiddlewareOptions, y as MiddlewareOutputFn, t as MiddlewareResult, l as ORPCErrorConstructorMapItem, k as ORPCErrorConstructorMapItemOptions, P as ProcedureClientInterceptorOptions, E as ProcedureDef, D as ProcedureHandlerOptions, n as createORPCErrorConstructorMap, G as createProcedureClient, s as getLazyMeta, r as isLazy, F as isProcedure, q as lazy, m as mergeCurrentContext, B as middlewareOutputFn, u as unlazy, v as validateORPCError } from './shared/server.6ohwBdwx.mjs';
|
9
9
|
export { getEventMeta, withEventMeta } from '@orpc/standard-server';
|
10
10
|
|
11
11
|
type ActionableError<T> = T extends ORPCError<infer U, infer V> ? ORPCErrorJSON<U, V> & {
|
package/dist/index.d.ts
CHANGED
@@ -4,8 +4,8 @@ import { AnySchema, ErrorMap, InferSchemaInput, InferSchemaOutput, ErrorFromErro
|
|
4
4
|
export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, InputStructure, MergedErrorMap, Meta, OutputStructure, Route, Schema, ValidationError, eventIterator, type } from '@orpc/contract';
|
5
5
|
import { ThrowableError, IntersectPick, MaybeOptionalOptions } from '@orpc/shared';
|
6
6
|
export { EventPublisher, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, IntersectPick, Registry, ThrowableError, onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
7
|
-
import { C as Context,
|
8
|
-
export { J as InferRouterCurrentContexts, H as InferRouterInitialContexts, K as InferRouterInputs, N as InferRouterOutputs,
|
7
|
+
import { C as Context, b as Procedure, M as Middleware, O as ORPCErrorConstructorMap, c as MergedInitialContext, d as MergedCurrentContext, e as MapInputMiddleware, f as CreateProcedureClientOptions, g as ProcedureClient, h as AnyMiddleware, L as Lazyable, a as AnyRouter, i as Lazy, A as AnyProcedure, j as ProcedureHandler, R as Router, I as InferRouterInitialContext } from './shared/server.6ohwBdwx.js';
|
8
|
+
export { J as InferRouterCurrentContexts, H as InferRouterInitialContexts, K as InferRouterInputs, N as InferRouterOutputs, o as LAZY_SYMBOL, p as LazyMeta, x as MiddlewareNextFn, w as MiddlewareNextFnOptions, z as MiddlewareOptions, y as MiddlewareOutputFn, t as MiddlewareResult, l as ORPCErrorConstructorMapItem, k as ORPCErrorConstructorMapItemOptions, P as ProcedureClientInterceptorOptions, E as ProcedureDef, D as ProcedureHandlerOptions, n as createORPCErrorConstructorMap, G as createProcedureClient, s as getLazyMeta, r as isLazy, F as isProcedure, q as lazy, m as mergeCurrentContext, B as middlewareOutputFn, u as unlazy, v as validateORPCError } from './shared/server.6ohwBdwx.js';
|
9
9
|
export { getEventMeta, withEventMeta } from '@orpc/standard-server';
|
10
10
|
|
11
11
|
type ActionableError<T> = T extends ORPCError<infer U, infer V> ? ORPCErrorJSON<U, V> & {
|
package/dist/plugins/index.d.mts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import { Value, Promisable } from '@orpc/shared';
|
2
2
|
import { StandardRequest, StandardHeaders } from '@orpc/standard-server';
|
3
3
|
import { BatchResponseBodyItem } from '@orpc/standard-server/batch';
|
4
|
-
import {
|
5
|
-
import { C as Context,
|
4
|
+
import { i as StandardHandlerInterceptorOptions, c as StandardHandlerPlugin, S as StandardHandlerOptions } from '../shared/server.BtQsqpPB.mjs';
|
5
|
+
import { C as Context, P as ProcedureClientInterceptorOptions } from '../shared/server.6ohwBdwx.mjs';
|
6
6
|
import { Meta, ORPCError as ORPCError$1 } from '@orpc/contract';
|
7
7
|
import { ORPCError } from '@orpc/client';
|
8
8
|
|
package/dist/plugins/index.d.ts
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
import { Value, Promisable } from '@orpc/shared';
|
2
2
|
import { StandardRequest, StandardHeaders } from '@orpc/standard-server';
|
3
3
|
import { BatchResponseBodyItem } from '@orpc/standard-server/batch';
|
4
|
-
import {
|
5
|
-
import { C as Context,
|
4
|
+
import { i as StandardHandlerInterceptorOptions, c as StandardHandlerPlugin, S as StandardHandlerOptions } from '../shared/server.BE3B4vij.js';
|
5
|
+
import { C as Context, P as ProcedureClientInterceptorOptions } from '../shared/server.6ohwBdwx.js';
|
6
6
|
import { Meta, ORPCError as ORPCError$1 } from '@orpc/contract';
|
7
7
|
import { ORPCError } from '@orpc/client';
|
8
8
|
|
@@ -188,5 +188,5 @@ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any
|
|
188
188
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
|
189
189
|
};
|
190
190
|
|
191
|
-
export { isProcedure as
|
192
|
-
export type {
|
191
|
+
export { middlewareOutputFn as B, isProcedure as F, createProcedureClient as G, Procedure as b, mergeCurrentContext as m, createORPCErrorConstructorMap as n, LAZY_SYMBOL as o, lazy as q, isLazy as r, getLazyMeta as s, unlazy as u, validateORPCError as v };
|
192
|
+
export type { AnyProcedure as A, Context as C, ProcedureHandlerOptions as D, ProcedureDef as E, InferRouterInitialContexts as H, InferRouterInitialContext as I, InferRouterCurrentContexts as J, InferRouterInputs as K, Lazyable as L, Middleware as M, InferRouterOutputs as N, ORPCErrorConstructorMap as O, ProcedureClientInterceptorOptions as P, Router as R, AnyRouter as a, MergedInitialContext as c, MergedCurrentContext as d, MapInputMiddleware as e, CreateProcedureClientOptions as f, ProcedureClient as g, AnyMiddleware as h, Lazy as i, ProcedureHandler as j, ORPCErrorConstructorMapItemOptions as k, ORPCErrorConstructorMapItem as l, LazyMeta as p, MiddlewareResult as t, MiddlewareNextFnOptions as w, MiddlewareNextFn as x, MiddlewareOutputFn as y, MiddlewareOptions as z };
|
@@ -188,5 +188,5 @@ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any
|
|
188
188
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
|
189
189
|
};
|
190
190
|
|
191
|
-
export { isProcedure as
|
192
|
-
export type {
|
191
|
+
export { middlewareOutputFn as B, isProcedure as F, createProcedureClient as G, Procedure as b, mergeCurrentContext as m, createORPCErrorConstructorMap as n, LAZY_SYMBOL as o, lazy as q, isLazy as r, getLazyMeta as s, unlazy as u, validateORPCError as v };
|
192
|
+
export type { AnyProcedure as A, Context as C, ProcedureHandlerOptions as D, ProcedureDef as E, InferRouterInitialContexts as H, InferRouterInitialContext as I, InferRouterCurrentContexts as J, InferRouterInputs as K, Lazyable as L, Middleware as M, InferRouterOutputs as N, ORPCErrorConstructorMap as O, ProcedureClientInterceptorOptions as P, Router as R, AnyRouter as a, MergedInitialContext as c, MergedCurrentContext as d, MapInputMiddleware as e, CreateProcedureClientOptions as f, ProcedureClient as g, AnyMiddleware as h, Lazy as i, ProcedureHandler as j, ORPCErrorConstructorMapItemOptions as k, ORPCErrorConstructorMapItem as l, LazyMeta as p, MiddlewareResult as t, MiddlewareNextFnOptions as w, MiddlewareNextFn as x, MiddlewareOutputFn as y, MiddlewareOptions as z };
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { C as Context } from './server.6ohwBdwx.mjs';
|
2
|
+
import { b as StandardHandleOptions } from './server.BtQsqpPB.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
|
+
declare function resolveFriendlyStandardHandleOptions<T extends Context>(options: FriendlyStandardHandleOptions<T>): StandardHandleOptions<T>;
|
10
|
+
|
11
|
+
export { resolveFriendlyStandardHandleOptions as r };
|
12
|
+
export type { FriendlyStandardHandleOptions as F };
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
|
2
|
+
import { C as Context, R as Router } from './server.6ohwBdwx.js';
|
3
|
+
import { S as StandardHandlerOptions, a as StandardHandler } from './server.BE3B4vij.js';
|
4
|
+
|
5
|
+
interface StandardRPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardRPCJsonSerializerOptions {
|
6
|
+
}
|
7
|
+
declare class StandardRPCHandler<T extends Context> extends StandardHandler<T> {
|
8
|
+
constructor(router: Router<any, T>, options?: StandardRPCHandlerOptions<T>);
|
9
|
+
}
|
10
|
+
|
11
|
+
export { StandardRPCHandler as a };
|
12
|
+
export type { StandardRPCHandlerOptions as S };
|
@@ -2,7 +2,7 @@ import { HTTPPath, ORPCError } from '@orpc/client';
|
|
2
2
|
import { Meta } from '@orpc/contract';
|
3
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.js';
|
6
6
|
|
7
7
|
interface StandardHandlerPlugin<T extends Context> {
|
8
8
|
order?: number;
|
@@ -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 };
|
@@ -2,7 +2,7 @@ import { HTTPPath, ORPCError } from '@orpc/client';
|
|
2
2
|
import { Meta } from '@orpc/contract';
|
3
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;
|
@@ -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 };
|
@@ -183,12 +183,4 @@ class StandardRPCHandler extends StandardHandler {
|
|
183
183
|
}
|
184
184
|
}
|
185
185
|
|
186
|
-
|
187
|
-
return {
|
188
|
-
...options,
|
189
|
-
context: options.context ?? {}
|
190
|
-
// Context only optional if all fields are optional
|
191
|
-
};
|
192
|
-
}
|
193
|
-
|
194
|
-
export { CompositeStandardHandlerPlugin as C, StandardHandler as S, StandardRPCCodec as a, StandardRPCHandler as b, StandardRPCMatcher as c, resolveFriendlyStandardHandleOptions as r };
|
186
|
+
export { CompositeStandardHandlerPlugin as C, StandardHandler as S, StandardRPCCodec as a, StandardRPCHandler as b, StandardRPCMatcher as c };
|
@@ -0,0 +1,12 @@
|
|
1
|
+
import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
|
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
|
+
|
5
|
+
interface StandardRPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardRPCJsonSerializerOptions {
|
6
|
+
}
|
7
|
+
declare class StandardRPCHandler<T extends Context> extends StandardHandler<T> {
|
8
|
+
constructor(router: Router<any, T>, options?: StandardRPCHandlerOptions<T>);
|
9
|
+
}
|
10
|
+
|
11
|
+
export { StandardRPCHandler as a };
|
12
|
+
export type { StandardRPCHandlerOptions as S };
|
@@ -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 };
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/server",
|
3
3
|
"type": "module",
|
4
|
-
"version": "1.
|
4
|
+
"version": "1.7.0",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -34,6 +34,11 @@
|
|
34
34
|
"import": "./dist/adapters/standard/index.mjs",
|
35
35
|
"default": "./dist/adapters/standard/index.mjs"
|
36
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
|
+
},
|
37
42
|
"./fetch": {
|
38
43
|
"types": "./dist/adapters/fetch/index.d.mts",
|
39
44
|
"import": "./dist/adapters/fetch/index.mjs",
|
@@ -91,20 +96,20 @@
|
|
91
96
|
}
|
92
97
|
},
|
93
98
|
"dependencies": {
|
94
|
-
"@orpc/
|
95
|
-
"@orpc/
|
96
|
-
"@orpc/
|
97
|
-
"@orpc/standard-server-
|
98
|
-
"@orpc/
|
99
|
-
"@orpc/standard-server-
|
100
|
-
"@orpc/standard-server
|
101
|
-
"@orpc/standard-server-
|
99
|
+
"@orpc/client": "1.7.0",
|
100
|
+
"@orpc/shared": "1.7.0",
|
101
|
+
"@orpc/contract": "1.7.0",
|
102
|
+
"@orpc/standard-server-aws-lambda": "1.7.0",
|
103
|
+
"@orpc/standard-server-fetch": "1.7.0",
|
104
|
+
"@orpc/standard-server-node": "1.7.0",
|
105
|
+
"@orpc/standard-server": "1.7.0",
|
106
|
+
"@orpc/standard-server-peer": "1.7.0"
|
102
107
|
},
|
103
108
|
"devDependencies": {
|
104
109
|
"@types/ws": "^8.18.1",
|
105
110
|
"crossws": "^0.4.1",
|
106
111
|
"next": "^15.3.5",
|
107
|
-
"supertest": "^7.1.
|
112
|
+
"supertest": "^7.1.3",
|
108
113
|
"ws": "^8.18.3"
|
109
114
|
},
|
110
115
|
"scripts": {
|