@orpc/server 0.0.0-next.b12bcdb → 0.0.0-next.b1b9914
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 +3 -0
- package/dist/adapters/aws-lambda/index.mjs +3 -3
- package/dist/adapters/bun-ws/index.mjs +2 -2
- package/dist/adapters/crossws/index.mjs +2 -2
- package/dist/adapters/fastify/index.d.mts +53 -0
- package/dist/adapters/fastify/index.d.ts +53 -0
- package/dist/adapters/fastify/index.mjs +54 -0
- package/dist/adapters/fetch/index.mjs +3 -3
- package/dist/adapters/message-port/index.d.mts +30 -4
- package/dist/adapters/message-port/index.d.ts +30 -4
- package/dist/adapters/message-port/index.mjs +28 -12
- package/dist/adapters/node/index.d.mts +1 -1
- package/dist/adapters/node/index.d.ts +1 -1
- package/dist/adapters/node/index.mjs +3 -3
- package/dist/adapters/standard/index.mjs +2 -2
- package/dist/adapters/websocket/index.d.mts +4 -2
- package/dist/adapters/websocket/index.d.ts +4 -2
- package/dist/adapters/websocket/index.mjs +2 -2
- package/dist/adapters/ws/index.mjs +2 -2
- package/dist/helpers/index.d.mts +16 -1
- package/dist/helpers/index.d.ts +16 -1
- package/dist/helpers/index.mjs +11 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +7 -4
- package/dist/plugins/index.d.mts +3 -0
- package/dist/plugins/index.d.ts +3 -0
- package/dist/plugins/index.mjs +13 -11
- package/dist/shared/{server.vzZSq5UM.mjs → server.Bxx6tqNe.mjs} +1 -1
- package/dist/shared/{server.CaqDCZX1.mjs → server.Ds4HPpvH.mjs} +3 -3
- package/dist/shared/{server.BW-nUGgA.mjs → server.TEVCLCFC.mjs} +3 -0
- package/package.json +21 -12
package/README.md
CHANGED
|
@@ -17,6 +17,9 @@
|
|
|
17
17
|
<a href="https://discord.gg/TXEbwRBvQn">
|
|
18
18
|
<img alt="Discord" src="https://img.shields.io/discord/1308966753044398161?color=7389D8&label&logo=discord&logoColor=ffffff" />
|
|
19
19
|
</a>
|
|
20
|
+
<a href="https://deepwiki.com/unnoq/orpc">
|
|
21
|
+
<img src="https://deepwiki.com/badge.svg" alt="Ask DeepWiki">
|
|
22
|
+
</a>
|
|
20
23
|
</div>
|
|
21
24
|
|
|
22
25
|
<h3 align="center">Typesafe APIs Made Simple 🪄</h3>
|
|
@@ -5,11 +5,11 @@ import '@orpc/standard-server';
|
|
|
5
5
|
import '@orpc/standard-server/batch';
|
|
6
6
|
import '@orpc/standard-server-fetch';
|
|
7
7
|
import '@orpc/client';
|
|
8
|
-
import { S as StrictGetMethodPlugin } from '../../shared/server.
|
|
8
|
+
import { S as StrictGetMethodPlugin } from '../../shared/server.TEVCLCFC.mjs';
|
|
9
9
|
import '@orpc/contract';
|
|
10
|
-
import { b as StandardRPCHandler } from '../../shared/server.
|
|
10
|
+
import { b as StandardRPCHandler } from '../../shared/server.Bxx6tqNe.mjs';
|
|
11
11
|
import '@orpc/client/standard';
|
|
12
|
-
import '../../shared/server.
|
|
12
|
+
import '../../shared/server.Ds4HPpvH.mjs';
|
|
13
13
|
|
|
14
14
|
class AwsLambdaHandler {
|
|
15
15
|
constructor(standardHandler, options = {}) {
|
|
@@ -4,10 +4,10 @@ import { c as createServerPeerHandleRequestFn } from '../../shared/server.UVMTOW
|
|
|
4
4
|
import '@orpc/client';
|
|
5
5
|
import '@orpc/standard-server';
|
|
6
6
|
import '@orpc/contract';
|
|
7
|
-
import { b as StandardRPCHandler } from '../../shared/server.
|
|
7
|
+
import { b as StandardRPCHandler } from '../../shared/server.Bxx6tqNe.mjs';
|
|
8
8
|
import '@orpc/client/standard';
|
|
9
9
|
import '../../shared/server.DZ5BIITo.mjs';
|
|
10
|
-
import '../../shared/server.
|
|
10
|
+
import '../../shared/server.Ds4HPpvH.mjs';
|
|
11
11
|
|
|
12
12
|
class BunWsHandler {
|
|
13
13
|
constructor(standardHandler) {
|
|
@@ -4,10 +4,10 @@ import { c as createServerPeerHandleRequestFn } from '../../shared/server.UVMTOW
|
|
|
4
4
|
import '@orpc/client';
|
|
5
5
|
import '@orpc/standard-server';
|
|
6
6
|
import '@orpc/contract';
|
|
7
|
-
import { b as StandardRPCHandler } from '../../shared/server.
|
|
7
|
+
import { b as StandardRPCHandler } from '../../shared/server.Bxx6tqNe.mjs';
|
|
8
8
|
import '@orpc/client/standard';
|
|
9
9
|
import '../../shared/server.DZ5BIITo.mjs';
|
|
10
|
-
import '../../shared/server.
|
|
10
|
+
import '../../shared/server.Ds4HPpvH.mjs';
|
|
11
11
|
|
|
12
12
|
class experimental_CrosswsHandler {
|
|
13
13
|
constructor(standardHandler) {
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
|
2
|
+
import { FastifyRequest, FastifyReply, SendStandardResponseOptions } from '@orpc/standard-server-fastify';
|
|
3
|
+
import { C as Context, R as Router } from '../../shared/server.B4BGqy3Y.mjs';
|
|
4
|
+
import { b as StandardHandleOptions, f as StandardHandler } from '../../shared/server.DBCUJijK.mjs';
|
|
5
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.CVKCo60T.mjs';
|
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.Ck-gOLzq.mjs';
|
|
7
|
+
import '@orpc/client';
|
|
8
|
+
import '@orpc/contract';
|
|
9
|
+
import '@orpc/standard-server';
|
|
10
|
+
import '@orpc/client/standard';
|
|
11
|
+
import '../../shared/server.DzV1hr3z.mjs';
|
|
12
|
+
|
|
13
|
+
type FastifyHandleResult = {
|
|
14
|
+
matched: true;
|
|
15
|
+
} | {
|
|
16
|
+
matched: false;
|
|
17
|
+
};
|
|
18
|
+
interface FastifyInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
|
|
19
|
+
request: FastifyRequest;
|
|
20
|
+
reply: FastifyReply;
|
|
21
|
+
sendStandardResponseOptions: SendStandardResponseOptions;
|
|
22
|
+
}
|
|
23
|
+
interface FastifyHandlerOptions<T extends Context> extends SendStandardResponseOptions {
|
|
24
|
+
adapterInterceptors?: Interceptor<FastifyInterceptorOptions<T>, Promise<FastifyHandleResult>>[];
|
|
25
|
+
}
|
|
26
|
+
declare class FastifyHandler<T extends Context> {
|
|
27
|
+
private readonly standardHandler;
|
|
28
|
+
private readonly sendStandardResponseOptions;
|
|
29
|
+
private readonly adapterInterceptors;
|
|
30
|
+
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<FastifyHandlerOptions<T>>);
|
|
31
|
+
handle(request: FastifyRequest, reply: FastifyReply, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<T>>): Promise<FastifyHandleResult>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface RPCHandlerOptions<T extends Context> extends FastifyHandlerOptions<T>, StandardRPCHandlerOptions<T> {
|
|
35
|
+
/**
|
|
36
|
+
* Enables or disables the StrictGetMethodPlugin.
|
|
37
|
+
*
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
strictGetMethodPluginEnabled?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* RPC Handler for Fastify Server
|
|
44
|
+
*
|
|
45
|
+
* @see {@link https://orpc.unnoq.com/docs/rpc-handler RPC Handler Docs}
|
|
46
|
+
* @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
|
|
47
|
+
*/
|
|
48
|
+
declare class RPCHandler<T extends Context> extends FastifyHandler<T> {
|
|
49
|
+
constructor(router: Router<any, T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { FastifyHandler, RPCHandler };
|
|
53
|
+
export type { FastifyHandleResult, FastifyHandlerOptions, FastifyInterceptorOptions, RPCHandlerOptions };
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
|
2
|
+
import { FastifyRequest, FastifyReply, SendStandardResponseOptions } from '@orpc/standard-server-fastify';
|
|
3
|
+
import { C as Context, R as Router } from '../../shared/server.B4BGqy3Y.js';
|
|
4
|
+
import { b as StandardHandleOptions, f as StandardHandler } from '../../shared/server.DPIFWpxG.js';
|
|
5
|
+
import { F as FriendlyStandardHandleOptions } from '../../shared/server.DNtJ-p60.js';
|
|
6
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.COL12UTb.js';
|
|
7
|
+
import '@orpc/client';
|
|
8
|
+
import '@orpc/contract';
|
|
9
|
+
import '@orpc/standard-server';
|
|
10
|
+
import '@orpc/client/standard';
|
|
11
|
+
import '../../shared/server.Cb6yD7DZ.js';
|
|
12
|
+
|
|
13
|
+
type FastifyHandleResult = {
|
|
14
|
+
matched: true;
|
|
15
|
+
} | {
|
|
16
|
+
matched: false;
|
|
17
|
+
};
|
|
18
|
+
interface FastifyInterceptorOptions<T extends Context> extends StandardHandleOptions<T> {
|
|
19
|
+
request: FastifyRequest;
|
|
20
|
+
reply: FastifyReply;
|
|
21
|
+
sendStandardResponseOptions: SendStandardResponseOptions;
|
|
22
|
+
}
|
|
23
|
+
interface FastifyHandlerOptions<T extends Context> extends SendStandardResponseOptions {
|
|
24
|
+
adapterInterceptors?: Interceptor<FastifyInterceptorOptions<T>, Promise<FastifyHandleResult>>[];
|
|
25
|
+
}
|
|
26
|
+
declare class FastifyHandler<T extends Context> {
|
|
27
|
+
private readonly standardHandler;
|
|
28
|
+
private readonly sendStandardResponseOptions;
|
|
29
|
+
private readonly adapterInterceptors;
|
|
30
|
+
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<FastifyHandlerOptions<T>>);
|
|
31
|
+
handle(request: FastifyRequest, reply: FastifyReply, ...rest: MaybeOptionalOptions<FriendlyStandardHandleOptions<T>>): Promise<FastifyHandleResult>;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface RPCHandlerOptions<T extends Context> extends FastifyHandlerOptions<T>, StandardRPCHandlerOptions<T> {
|
|
35
|
+
/**
|
|
36
|
+
* Enables or disables the StrictGetMethodPlugin.
|
|
37
|
+
*
|
|
38
|
+
* @default true
|
|
39
|
+
*/
|
|
40
|
+
strictGetMethodPluginEnabled?: boolean;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* RPC Handler for Fastify Server
|
|
44
|
+
*
|
|
45
|
+
* @see {@link https://orpc.unnoq.com/docs/rpc-handler RPC Handler Docs}
|
|
46
|
+
* @see {@link https://orpc.unnoq.com/docs/adapters/http HTTP Adapter Docs}
|
|
47
|
+
*/
|
|
48
|
+
declare class RPCHandler<T extends Context> extends FastifyHandler<T> {
|
|
49
|
+
constructor(router: Router<any, T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export { FastifyHandler, RPCHandler };
|
|
53
|
+
export type { FastifyHandleResult, FastifyHandlerOptions, FastifyInterceptorOptions, RPCHandlerOptions };
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { toArray, intercept, resolveMaybeOptionalOptions } from '@orpc/shared';
|
|
2
|
+
import { toStandardLazyRequest, sendStandardResponse } from '@orpc/standard-server-fastify';
|
|
3
|
+
import { r as resolveFriendlyStandardHandleOptions } from '../../shared/server.DZ5BIITo.mjs';
|
|
4
|
+
import '@orpc/standard-server';
|
|
5
|
+
import '@orpc/standard-server/batch';
|
|
6
|
+
import '@orpc/standard-server-fetch';
|
|
7
|
+
import '@orpc/client';
|
|
8
|
+
import { S as StrictGetMethodPlugin } from '../../shared/server.TEVCLCFC.mjs';
|
|
9
|
+
import '@orpc/contract';
|
|
10
|
+
import { b as StandardRPCHandler } from '../../shared/server.Bxx6tqNe.mjs';
|
|
11
|
+
import '@orpc/client/standard';
|
|
12
|
+
import '../../shared/server.Ds4HPpvH.mjs';
|
|
13
|
+
|
|
14
|
+
class FastifyHandler {
|
|
15
|
+
constructor(standardHandler, options = {}) {
|
|
16
|
+
this.standardHandler = standardHandler;
|
|
17
|
+
this.adapterInterceptors = toArray(options.adapterInterceptors);
|
|
18
|
+
this.sendStandardResponseOptions = options;
|
|
19
|
+
}
|
|
20
|
+
sendStandardResponseOptions;
|
|
21
|
+
adapterInterceptors;
|
|
22
|
+
async handle(request, reply, ...rest) {
|
|
23
|
+
return intercept(
|
|
24
|
+
this.adapterInterceptors,
|
|
25
|
+
{
|
|
26
|
+
...resolveFriendlyStandardHandleOptions(resolveMaybeOptionalOptions(rest)),
|
|
27
|
+
request,
|
|
28
|
+
reply,
|
|
29
|
+
sendStandardResponseOptions: this.sendStandardResponseOptions
|
|
30
|
+
},
|
|
31
|
+
async ({ request: request2, reply: reply2, sendStandardResponseOptions, ...options }) => {
|
|
32
|
+
const standardRequest = toStandardLazyRequest(request2, reply2);
|
|
33
|
+
const result = await this.standardHandler.handle(standardRequest, options);
|
|
34
|
+
if (!result.matched) {
|
|
35
|
+
return { matched: false };
|
|
36
|
+
}
|
|
37
|
+
await sendStandardResponse(reply2, result.response, sendStandardResponseOptions);
|
|
38
|
+
return { matched: true };
|
|
39
|
+
}
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
class RPCHandler extends FastifyHandler {
|
|
45
|
+
constructor(router, options = {}) {
|
|
46
|
+
if (options.strictGetMethodPluginEnabled ?? true) {
|
|
47
|
+
options.plugins ??= [];
|
|
48
|
+
options.plugins.push(new StrictGetMethodPlugin());
|
|
49
|
+
}
|
|
50
|
+
super(new StandardRPCHandler(router, options), options);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export { FastifyHandler, RPCHandler };
|
|
@@ -4,11 +4,11 @@ import { toStandardLazyRequest, toFetchResponse } from '@orpc/standard-server-fe
|
|
|
4
4
|
import { r as resolveFriendlyStandardHandleOptions } from '../../shared/server.DZ5BIITo.mjs';
|
|
5
5
|
import '@orpc/standard-server';
|
|
6
6
|
import '@orpc/contract';
|
|
7
|
-
import { C as CompositeStandardHandlerPlugin, b as StandardRPCHandler } from '../../shared/server.
|
|
7
|
+
import { C as CompositeStandardHandlerPlugin, b as StandardRPCHandler } from '../../shared/server.Bxx6tqNe.mjs';
|
|
8
8
|
import '@orpc/client/standard';
|
|
9
9
|
import '@orpc/standard-server/batch';
|
|
10
|
-
import { S as StrictGetMethodPlugin } from '../../shared/server.
|
|
11
|
-
import '../../shared/server.
|
|
10
|
+
import { S as StrictGetMethodPlugin } from '../../shared/server.TEVCLCFC.mjs';
|
|
11
|
+
import '../../shared/server.Ds4HPpvH.mjs';
|
|
12
12
|
|
|
13
13
|
class BodyLimitPlugin {
|
|
14
14
|
maxBodySize;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SupportedMessagePort } from '@orpc/client/message-port';
|
|
2
|
-
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
2
|
+
import { Value, Promisable, MaybeOptionalOptions } from '@orpc/shared';
|
|
3
|
+
import { DecodedResponseMessage } from '@orpc/standard-server-peer';
|
|
3
4
|
import { C as Context, R as Router } from '../../shared/server.B4BGqy3Y.mjs';
|
|
4
5
|
import { f as StandardHandler } from '../../shared/server.DBCUJijK.mjs';
|
|
5
6
|
import { HandleStandardServerPeerMessageOptions } from '../standard-peer/index.mjs';
|
|
@@ -7,17 +8,41 @@ import { S as StandardRPCHandlerOptions } from '../../shared/server.Ck-gOLzq.mjs
|
|
|
7
8
|
import '@orpc/client';
|
|
8
9
|
import '@orpc/contract';
|
|
9
10
|
import '@orpc/standard-server';
|
|
10
|
-
import '@orpc/standard-server-peer';
|
|
11
11
|
import '../../shared/server.CVKCo60T.mjs';
|
|
12
12
|
import '@orpc/client/standard';
|
|
13
13
|
import '../../shared/server.DzV1hr3z.mjs';
|
|
14
14
|
|
|
15
|
+
interface MessagePortHandlerOptions<_T extends Context> {
|
|
16
|
+
/**
|
|
17
|
+
* By default, oRPC serializes request/response messages to string/binary data before sending over message port.
|
|
18
|
+
* If needed, you can define the this option to utilize full power of [MessagePort: postMessage() method](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/postMessage),
|
|
19
|
+
* such as transferring ownership of objects to the other side or support unserializable objects like `OffscreenCanvas`.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* - return null | undefined to disable this feature
|
|
23
|
+
*
|
|
24
|
+
* @warning Make sure your message port supports `transfer` before using this feature.
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* experimental_transfer: (message, port) => {
|
|
28
|
+
* const transfer = deepFindTransferableObjects(message) // implement your own logic
|
|
29
|
+
* return transfer.length ? transfer : null // only enable when needed
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @see {@link https://orpc.unnoq.com/docs/adapters/message-port#transfer Message Port Transfer Docs}
|
|
34
|
+
*/
|
|
35
|
+
experimental_transfer?: Value<Promisable<object[] | null | undefined>, [message: DecodedResponseMessage, port: SupportedMessagePort]>;
|
|
36
|
+
}
|
|
15
37
|
declare class MessagePortHandler<T extends Context> {
|
|
16
38
|
private readonly standardHandler;
|
|
17
|
-
|
|
39
|
+
private readonly transfer;
|
|
40
|
+
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<MessagePortHandlerOptions<T>>);
|
|
18
41
|
upgrade(port: SupportedMessagePort, ...rest: MaybeOptionalOptions<HandleStandardServerPeerMessageOptions<T>>): void;
|
|
19
42
|
}
|
|
20
43
|
|
|
44
|
+
interface RPCHandlerOptions<T extends Context> extends StandardRPCHandlerOptions<T>, MessagePortHandlerOptions<T> {
|
|
45
|
+
}
|
|
21
46
|
/**
|
|
22
47
|
* RPC Handler for common message port implementations.
|
|
23
48
|
*
|
|
@@ -25,7 +50,8 @@ declare class MessagePortHandler<T extends Context> {
|
|
|
25
50
|
* @see {@link https://orpc.unnoq.com/docs/adapters/message-port Message Port Adapter Docs}
|
|
26
51
|
*/
|
|
27
52
|
declare class RPCHandler<T extends Context> extends MessagePortHandler<T> {
|
|
28
|
-
constructor(router: Router<any, T>, options?: NoInfer<
|
|
53
|
+
constructor(router: Router<any, T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
29
54
|
}
|
|
30
55
|
|
|
31
56
|
export { MessagePortHandler, RPCHandler };
|
|
57
|
+
export type { MessagePortHandlerOptions, RPCHandlerOptions };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { SupportedMessagePort } from '@orpc/client/message-port';
|
|
2
|
-
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
2
|
+
import { Value, Promisable, MaybeOptionalOptions } from '@orpc/shared';
|
|
3
|
+
import { DecodedResponseMessage } from '@orpc/standard-server-peer';
|
|
3
4
|
import { C as Context, R as Router } from '../../shared/server.B4BGqy3Y.js';
|
|
4
5
|
import { f as StandardHandler } from '../../shared/server.DPIFWpxG.js';
|
|
5
6
|
import { HandleStandardServerPeerMessageOptions } from '../standard-peer/index.js';
|
|
@@ -7,17 +8,41 @@ import { S as StandardRPCHandlerOptions } from '../../shared/server.COL12UTb.js'
|
|
|
7
8
|
import '@orpc/client';
|
|
8
9
|
import '@orpc/contract';
|
|
9
10
|
import '@orpc/standard-server';
|
|
10
|
-
import '@orpc/standard-server-peer';
|
|
11
11
|
import '../../shared/server.DNtJ-p60.js';
|
|
12
12
|
import '@orpc/client/standard';
|
|
13
13
|
import '../../shared/server.Cb6yD7DZ.js';
|
|
14
14
|
|
|
15
|
+
interface MessagePortHandlerOptions<_T extends Context> {
|
|
16
|
+
/**
|
|
17
|
+
* By default, oRPC serializes request/response messages to string/binary data before sending over message port.
|
|
18
|
+
* If needed, you can define the this option to utilize full power of [MessagePort: postMessage() method](https://developer.mozilla.org/en-US/docs/Web/API/MessagePort/postMessage),
|
|
19
|
+
* such as transferring ownership of objects to the other side or support unserializable objects like `OffscreenCanvas`.
|
|
20
|
+
*
|
|
21
|
+
* @remarks
|
|
22
|
+
* - return null | undefined to disable this feature
|
|
23
|
+
*
|
|
24
|
+
* @warning Make sure your message port supports `transfer` before using this feature.
|
|
25
|
+
* @example
|
|
26
|
+
* ```ts
|
|
27
|
+
* experimental_transfer: (message, port) => {
|
|
28
|
+
* const transfer = deepFindTransferableObjects(message) // implement your own logic
|
|
29
|
+
* return transfer.length ? transfer : null // only enable when needed
|
|
30
|
+
* }
|
|
31
|
+
* ```
|
|
32
|
+
*
|
|
33
|
+
* @see {@link https://orpc.unnoq.com/docs/adapters/message-port#transfer Message Port Transfer Docs}
|
|
34
|
+
*/
|
|
35
|
+
experimental_transfer?: Value<Promisable<object[] | null | undefined>, [message: DecodedResponseMessage, port: SupportedMessagePort]>;
|
|
36
|
+
}
|
|
15
37
|
declare class MessagePortHandler<T extends Context> {
|
|
16
38
|
private readonly standardHandler;
|
|
17
|
-
|
|
39
|
+
private readonly transfer;
|
|
40
|
+
constructor(standardHandler: StandardHandler<T>, options?: NoInfer<MessagePortHandlerOptions<T>>);
|
|
18
41
|
upgrade(port: SupportedMessagePort, ...rest: MaybeOptionalOptions<HandleStandardServerPeerMessageOptions<T>>): void;
|
|
19
42
|
}
|
|
20
43
|
|
|
44
|
+
interface RPCHandlerOptions<T extends Context> extends StandardRPCHandlerOptions<T>, MessagePortHandlerOptions<T> {
|
|
45
|
+
}
|
|
21
46
|
/**
|
|
22
47
|
* RPC Handler for common message port implementations.
|
|
23
48
|
*
|
|
@@ -25,7 +50,8 @@ declare class MessagePortHandler<T extends Context> {
|
|
|
25
50
|
* @see {@link https://orpc.unnoq.com/docs/adapters/message-port Message Port Adapter Docs}
|
|
26
51
|
*/
|
|
27
52
|
declare class RPCHandler<T extends Context> extends MessagePortHandler<T> {
|
|
28
|
-
constructor(router: Router<any, T>, options?: NoInfer<
|
|
53
|
+
constructor(router: Router<any, T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
29
54
|
}
|
|
30
55
|
|
|
31
56
|
export { MessagePortHandler, RPCHandler };
|
|
57
|
+
export type { MessagePortHandlerOptions, RPCHandlerOptions };
|
|
@@ -1,28 +1,44 @@
|
|
|
1
1
|
import { postMessagePortMessage, onMessagePortMessage, onMessagePortClose } from '@orpc/client/message-port';
|
|
2
|
-
import { resolveMaybeOptionalOptions } from '@orpc/shared';
|
|
3
|
-
import {
|
|
2
|
+
import { value, resolveMaybeOptionalOptions, isObject } from '@orpc/shared';
|
|
3
|
+
import { experimental_ServerPeerWithoutCodec, serializeResponseMessage, encodeResponseMessage, deserializeRequestMessage, decodeRequestMessage } from '@orpc/standard-server-peer';
|
|
4
4
|
import { c as createServerPeerHandleRequestFn } from '../../shared/server.UVMTOWrk.mjs';
|
|
5
5
|
import '@orpc/client';
|
|
6
6
|
import '@orpc/standard-server';
|
|
7
7
|
import '@orpc/contract';
|
|
8
|
-
import { b as StandardRPCHandler } from '../../shared/server.
|
|
8
|
+
import { b as StandardRPCHandler } from '../../shared/server.Bxx6tqNe.mjs';
|
|
9
9
|
import '@orpc/client/standard';
|
|
10
10
|
import '../../shared/server.DZ5BIITo.mjs';
|
|
11
|
-
import '../../shared/server.
|
|
11
|
+
import '../../shared/server.Ds4HPpvH.mjs';
|
|
12
12
|
|
|
13
13
|
class MessagePortHandler {
|
|
14
|
-
constructor(standardHandler) {
|
|
14
|
+
constructor(standardHandler, options = {}) {
|
|
15
15
|
this.standardHandler = standardHandler;
|
|
16
|
+
this.transfer = options.experimental_transfer;
|
|
16
17
|
}
|
|
18
|
+
transfer;
|
|
17
19
|
upgrade(port, ...rest) {
|
|
18
|
-
const peer = new
|
|
19
|
-
|
|
20
|
+
const peer = new experimental_ServerPeerWithoutCodec(async (message) => {
|
|
21
|
+
const [id, type, payload] = message;
|
|
22
|
+
const transfer = await value(this.transfer, message, port);
|
|
23
|
+
if (transfer) {
|
|
24
|
+
postMessagePortMessage(port, serializeResponseMessage(id, type, payload), transfer);
|
|
25
|
+
} else {
|
|
26
|
+
postMessagePortMessage(port, await encodeResponseMessage(id, type, payload));
|
|
27
|
+
}
|
|
20
28
|
});
|
|
21
29
|
onMessagePortMessage(port, async (message) => {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
30
|
+
const handleFn = createServerPeerHandleRequestFn(this.standardHandler, resolveMaybeOptionalOptions(rest));
|
|
31
|
+
if (isObject(message)) {
|
|
32
|
+
await peer.message(
|
|
33
|
+
deserializeRequestMessage(message),
|
|
34
|
+
handleFn
|
|
35
|
+
);
|
|
36
|
+
} else {
|
|
37
|
+
await peer.message(
|
|
38
|
+
await decodeRequestMessage(message),
|
|
39
|
+
handleFn
|
|
40
|
+
);
|
|
41
|
+
}
|
|
26
42
|
});
|
|
27
43
|
onMessagePortClose(port, () => {
|
|
28
44
|
peer.close();
|
|
@@ -32,7 +48,7 @@ class MessagePortHandler {
|
|
|
32
48
|
|
|
33
49
|
class RPCHandler extends MessagePortHandler {
|
|
34
50
|
constructor(router, options = {}) {
|
|
35
|
-
super(new StandardRPCHandler(router, options));
|
|
51
|
+
super(new StandardRPCHandler(router, options), options);
|
|
36
52
|
}
|
|
37
53
|
}
|
|
38
54
|
|
|
@@ -32,7 +32,7 @@ interface NodeHttpHandlerOptions<T extends Context> extends SendStandardResponse
|
|
|
32
32
|
adapterInterceptors?: Interceptor<NodeHttpHandlerInterceptorOptions<T>, Promise<NodeHttpHandleResult>>[];
|
|
33
33
|
plugins?: NodeHttpHandlerPlugin<T>[];
|
|
34
34
|
}
|
|
35
|
-
declare class NodeHttpHandler<T extends Context>
|
|
35
|
+
declare class NodeHttpHandler<T extends Context> {
|
|
36
36
|
private readonly standardHandler;
|
|
37
37
|
private readonly sendStandardResponseOptions;
|
|
38
38
|
private readonly adapterInterceptors;
|
|
@@ -32,7 +32,7 @@ interface NodeHttpHandlerOptions<T extends Context> extends SendStandardResponse
|
|
|
32
32
|
adapterInterceptors?: Interceptor<NodeHttpHandlerInterceptorOptions<T>, Promise<NodeHttpHandleResult>>[];
|
|
33
33
|
plugins?: NodeHttpHandlerPlugin<T>[];
|
|
34
34
|
}
|
|
35
|
-
declare class NodeHttpHandler<T extends Context>
|
|
35
|
+
declare class NodeHttpHandler<T extends Context> {
|
|
36
36
|
private readonly standardHandler;
|
|
37
37
|
private readonly sendStandardResponseOptions;
|
|
38
38
|
private readonly adapterInterceptors;
|
|
@@ -5,12 +5,12 @@ import { toStandardLazyRequest, sendStandardResponse } from '@orpc/standard-serv
|
|
|
5
5
|
import { r as resolveFriendlyStandardHandleOptions } from '../../shared/server.DZ5BIITo.mjs';
|
|
6
6
|
import '@orpc/standard-server';
|
|
7
7
|
import '@orpc/contract';
|
|
8
|
-
import { C as CompositeStandardHandlerPlugin, b as StandardRPCHandler } from '../../shared/server.
|
|
8
|
+
import { C as CompositeStandardHandlerPlugin, b as StandardRPCHandler } from '../../shared/server.Bxx6tqNe.mjs';
|
|
9
9
|
import '@orpc/client/standard';
|
|
10
10
|
import '@orpc/standard-server/batch';
|
|
11
11
|
import '@orpc/standard-server-fetch';
|
|
12
|
-
import { S as StrictGetMethodPlugin } from '../../shared/server.
|
|
13
|
-
import '../../shared/server.
|
|
12
|
+
import { S as StrictGetMethodPlugin } from '../../shared/server.TEVCLCFC.mjs';
|
|
13
|
+
import '../../shared/server.Ds4HPpvH.mjs';
|
|
14
14
|
|
|
15
15
|
class BodyLimitPlugin {
|
|
16
16
|
maxBodySize;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export { C as CompositeStandardHandlerPlugin, S as StandardHandler, a as StandardRPCCodec, b as StandardRPCHandler, c as StandardRPCMatcher } from '../../shared/server.
|
|
1
|
+
export { C as CompositeStandardHandlerPlugin, S as StandardHandler, a as StandardRPCCodec, b as StandardRPCHandler, c as StandardRPCMatcher } from '../../shared/server.Bxx6tqNe.mjs';
|
|
2
2
|
export { r as resolveFriendlyStandardHandleOptions } from '../../shared/server.DZ5BIITo.mjs';
|
|
3
3
|
import '@orpc/client/standard';
|
|
4
4
|
import '@orpc/client';
|
|
5
5
|
import '@orpc/shared';
|
|
6
6
|
import '@orpc/standard-server';
|
|
7
|
-
import '../../shared/server.
|
|
7
|
+
import '../../shared/server.Ds4HPpvH.mjs';
|
|
8
8
|
import '@orpc/contract';
|
|
@@ -40,6 +40,8 @@ declare class WebsocketHandler<T extends Context> {
|
|
|
40
40
|
close(ws: MinimalWebsocket): void;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
interface RPCHandlerOptions<T extends Context> extends StandardRPCHandlerOptions<T> {
|
|
44
|
+
}
|
|
43
45
|
/**
|
|
44
46
|
* RPC Handler for Websocket adapter
|
|
45
47
|
*
|
|
@@ -47,8 +49,8 @@ declare class WebsocketHandler<T extends Context> {
|
|
|
47
49
|
* @see {@link https://orpc.unnoq.com/docs/adapters/websocket Websocket Adapter Docs}
|
|
48
50
|
*/
|
|
49
51
|
declare class RPCHandler<T extends Context> extends WebsocketHandler<T> {
|
|
50
|
-
constructor(router: Router<any, T>, options?: NoInfer<
|
|
52
|
+
constructor(router: Router<any, T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
export { RPCHandler, WebsocketHandler };
|
|
54
|
-
export type { MinimalWebsocket };
|
|
56
|
+
export type { MinimalWebsocket, RPCHandlerOptions };
|
|
@@ -40,6 +40,8 @@ declare class WebsocketHandler<T extends Context> {
|
|
|
40
40
|
close(ws: MinimalWebsocket): void;
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
+
interface RPCHandlerOptions<T extends Context> extends StandardRPCHandlerOptions<T> {
|
|
44
|
+
}
|
|
43
45
|
/**
|
|
44
46
|
* RPC Handler for Websocket adapter
|
|
45
47
|
*
|
|
@@ -47,8 +49,8 @@ declare class WebsocketHandler<T extends Context> {
|
|
|
47
49
|
* @see {@link https://orpc.unnoq.com/docs/adapters/websocket Websocket Adapter Docs}
|
|
48
50
|
*/
|
|
49
51
|
declare class RPCHandler<T extends Context> extends WebsocketHandler<T> {
|
|
50
|
-
constructor(router: Router<any, T>, options?: NoInfer<
|
|
52
|
+
constructor(router: Router<any, T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
51
53
|
}
|
|
52
54
|
|
|
53
55
|
export { RPCHandler, WebsocketHandler };
|
|
54
|
-
export type { MinimalWebsocket };
|
|
56
|
+
export type { MinimalWebsocket, RPCHandlerOptions };
|
|
@@ -4,10 +4,10 @@ import { c as createServerPeerHandleRequestFn } from '../../shared/server.UVMTOW
|
|
|
4
4
|
import '@orpc/client';
|
|
5
5
|
import '@orpc/standard-server';
|
|
6
6
|
import '@orpc/contract';
|
|
7
|
-
import { b as StandardRPCHandler } from '../../shared/server.
|
|
7
|
+
import { b as StandardRPCHandler } from '../../shared/server.Bxx6tqNe.mjs';
|
|
8
8
|
import '@orpc/client/standard';
|
|
9
9
|
import '../../shared/server.DZ5BIITo.mjs';
|
|
10
|
-
import '../../shared/server.
|
|
10
|
+
import '../../shared/server.Ds4HPpvH.mjs';
|
|
11
11
|
|
|
12
12
|
class WebsocketHandler {
|
|
13
13
|
#peers = /* @__PURE__ */ new WeakMap();
|
|
@@ -4,10 +4,10 @@ import { c as createServerPeerHandleRequestFn } from '../../shared/server.UVMTOW
|
|
|
4
4
|
import '@orpc/client';
|
|
5
5
|
import '@orpc/standard-server';
|
|
6
6
|
import '@orpc/contract';
|
|
7
|
-
import { b as StandardRPCHandler } from '../../shared/server.
|
|
7
|
+
import { b as StandardRPCHandler } from '../../shared/server.Bxx6tqNe.mjs';
|
|
8
8
|
import '@orpc/client/standard';
|
|
9
9
|
import '../../shared/server.DZ5BIITo.mjs';
|
|
10
|
-
import '../../shared/server.
|
|
10
|
+
import '../../shared/server.Ds4HPpvH.mjs';
|
|
11
11
|
|
|
12
12
|
class WsHandler {
|
|
13
13
|
constructor(standardHandler) {
|
package/dist/helpers/index.d.mts
CHANGED
|
@@ -129,6 +129,21 @@ declare function sign(value: string, secret: string): Promise<string>;
|
|
|
129
129
|
* ```
|
|
130
130
|
*/
|
|
131
131
|
declare function unsign(signedValue: string | undefined | null, secret: string): Promise<string | undefined>;
|
|
132
|
+
/**
|
|
133
|
+
* Extracts the value part from a signed string without verification.
|
|
134
|
+
*
|
|
135
|
+
* This function simply extracts the original value from a signed string
|
|
136
|
+
* without performing any signature verification. It's useful when you need
|
|
137
|
+
* to access the value quickly without the overhead of cryptographic verification.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* const signedValue = "user123.oneQsU0r5dvwQFHFEjjV1uOI_IR3gZfkYHij3TRauVA"
|
|
142
|
+
* const value = getSignedValue(signedValue)
|
|
143
|
+
* expect(value).toEqual("user123")
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
declare function getSignedValue(signedValue: string | undefined | null): string | undefined;
|
|
132
147
|
|
|
133
|
-
export { decodeBase64url, decrypt, deleteCookie, encodeBase64url, encrypt, getCookie, setCookie, sign, unsign };
|
|
148
|
+
export { decodeBase64url, decrypt, deleteCookie, encodeBase64url, encrypt, getCookie, getSignedValue, setCookie, sign, unsign };
|
|
134
149
|
export type { GetCookieOptions, SetCookieOptions };
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -129,6 +129,21 @@ declare function sign(value: string, secret: string): Promise<string>;
|
|
|
129
129
|
* ```
|
|
130
130
|
*/
|
|
131
131
|
declare function unsign(signedValue: string | undefined | null, secret: string): Promise<string | undefined>;
|
|
132
|
+
/**
|
|
133
|
+
* Extracts the value part from a signed string without verification.
|
|
134
|
+
*
|
|
135
|
+
* This function simply extracts the original value from a signed string
|
|
136
|
+
* without performing any signature verification. It's useful when you need
|
|
137
|
+
* to access the value quickly without the overhead of cryptographic verification.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* const signedValue = "user123.oneQsU0r5dvwQFHFEjjV1uOI_IR3gZfkYHij3TRauVA"
|
|
142
|
+
* const value = getSignedValue(signedValue)
|
|
143
|
+
* expect(value).toEqual("user123")
|
|
144
|
+
* ```
|
|
145
|
+
*/
|
|
146
|
+
declare function getSignedValue(signedValue: string | undefined | null): string | undefined;
|
|
132
147
|
|
|
133
|
-
export { decodeBase64url, decrypt, deleteCookie, encodeBase64url, encrypt, getCookie, setCookie, sign, unsign };
|
|
148
|
+
export { decodeBase64url, decrypt, deleteCookie, encodeBase64url, encrypt, getCookie, getSignedValue, setCookie, sign, unsign };
|
|
134
149
|
export type { GetCookieOptions, SetCookieOptions };
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -184,5 +184,15 @@ async function unsign(signedValue, secret) {
|
|
|
184
184
|
);
|
|
185
185
|
return isValid ? value : void 0;
|
|
186
186
|
}
|
|
187
|
+
function getSignedValue(signedValue) {
|
|
188
|
+
if (typeof signedValue !== "string") {
|
|
189
|
+
return void 0;
|
|
190
|
+
}
|
|
191
|
+
const lastDotIndex = signedValue.lastIndexOf(".");
|
|
192
|
+
if (lastDotIndex === -1) {
|
|
193
|
+
return void 0;
|
|
194
|
+
}
|
|
195
|
+
return signedValue.slice(0, lastDotIndex);
|
|
196
|
+
}
|
|
187
197
|
|
|
188
|
-
export { decodeBase64url, decrypt, deleteCookie, encodeBase64url, encrypt, getCookie, setCookie, sign, unsign };
|
|
198
|
+
export { decodeBase64url, decrypt, deleteCookie, encodeBase64url, encrypt, getCookie, getSignedValue, setCookie, sign, unsign };
|
package/dist/index.d.mts
CHANGED
|
@@ -3,7 +3,7 @@ export { ClientContext, HTTPMethod, HTTPPath, ORPCError, isDefinedError, safe }
|
|
|
3
3
|
import { AnySchema, ErrorMap, InferSchemaInput, InferSchemaOutput, ErrorFromErrorMap, Meta, MergedErrorMap, Route, Schema, ContractRouter, ContractProcedureDef, AnyContractRouter, ContractProcedure, InferContractRouterErrorMap, InferContractRouterMeta, AnyContractProcedure } from '@orpc/contract';
|
|
4
4
|
export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, InputStructure, MergedErrorMap, Meta, OutputStructure, Route, Schema, ValidationError, eventIterator, type, validateORPCError } from '@orpc/contract';
|
|
5
5
|
import { ThrowableError, IntersectPick, MaybeOptionalOptions } from '@orpc/shared';
|
|
6
|
-
export { AsyncIteratorClass, EventPublisher, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, IntersectPick, Registry, ThrowableError, asyncIteratorToStream as eventIteratorToStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
|
|
6
|
+
export { AsyncIteratorClass, EventPublisher, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, IntersectPick, Registry, ThrowableError, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
|
|
7
7
|
import { C as Context, P as Procedure, e as Middleware, O as ORPCErrorConstructorMap, M as MergedInitialContext, f as MergedCurrentContext, g as MapInputMiddleware, h as CreateProcedureClientOptions, i as ProcedureClient, j as ProcedureHandler, R as Router, c as Lazy, a as AnyMiddleware, b as AnyRouter, A as AnyProcedure, L as Lazyable, I as InferRouterInitialContext } from './shared/server.B4BGqy3Y.mjs';
|
|
8
8
|
export { H as InferRouterCurrentContexts, G as InferRouterInitialContexts, J as InferRouterInputs, K as InferRouterOutputs, o as LAZY_SYMBOL, p as LazyMeta, w as MiddlewareNextFn, v as MiddlewareNextFnOptions, y as MiddlewareOptions, x as MiddlewareOutputFn, t as MiddlewareResult, l as ORPCErrorConstructorMapItem, k as ORPCErrorConstructorMapItemOptions, d as ProcedureClientInterceptorOptions, D as ProcedureDef, B as ProcedureHandlerOptions, n as createORPCErrorConstructorMap, F as createProcedureClient, s as getLazyMeta, r as isLazy, E as isProcedure, q as lazy, m as mergeCurrentContext, z as middlewareOutputFn, u as unlazy } from './shared/server.B4BGqy3Y.mjs';
|
|
9
9
|
import { E as EnhanceRouterOptions, a as EnhancedRouter } from './shared/server.DzV1hr3z.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export { ClientContext, HTTPMethod, HTTPPath, ORPCError, isDefinedError, safe }
|
|
|
3
3
|
import { AnySchema, ErrorMap, InferSchemaInput, InferSchemaOutput, ErrorFromErrorMap, Meta, MergedErrorMap, Route, Schema, ContractRouter, ContractProcedureDef, AnyContractRouter, ContractProcedure, InferContractRouterErrorMap, InferContractRouterMeta, AnyContractProcedure } from '@orpc/contract';
|
|
4
4
|
export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, InputStructure, MergedErrorMap, Meta, OutputStructure, Route, Schema, ValidationError, eventIterator, type, validateORPCError } from '@orpc/contract';
|
|
5
5
|
import { ThrowableError, IntersectPick, MaybeOptionalOptions } from '@orpc/shared';
|
|
6
|
-
export { AsyncIteratorClass, EventPublisher, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, IntersectPick, Registry, ThrowableError, asyncIteratorToStream as eventIteratorToStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
|
|
6
|
+
export { AsyncIteratorClass, EventPublisher, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, IntersectPick, Registry, ThrowableError, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
|
|
7
7
|
import { C as Context, P as Procedure, e as Middleware, O as ORPCErrorConstructorMap, M as MergedInitialContext, f as MergedCurrentContext, g as MapInputMiddleware, h as CreateProcedureClientOptions, i as ProcedureClient, j as ProcedureHandler, R as Router, c as Lazy, a as AnyMiddleware, b as AnyRouter, A as AnyProcedure, L as Lazyable, I as InferRouterInitialContext } from './shared/server.B4BGqy3Y.js';
|
|
8
8
|
export { H as InferRouterCurrentContexts, G as InferRouterInitialContexts, J as InferRouterInputs, K as InferRouterOutputs, o as LAZY_SYMBOL, p as LazyMeta, w as MiddlewareNextFn, v as MiddlewareNextFnOptions, y as MiddlewareOptions, x as MiddlewareOutputFn, t as MiddlewareResult, l as ORPCErrorConstructorMapItem, k as ORPCErrorConstructorMapItemOptions, d as ProcedureClientInterceptorOptions, D as ProcedureDef, B as ProcedureHandlerOptions, n as createORPCErrorConstructorMap, F as createProcedureClient, s as getLazyMeta, r as isLazy, E as isProcedure, q as lazy, m as mergeCurrentContext, z as middlewareOutputFn, u as unlazy } from './shared/server.B4BGqy3Y.js';
|
|
9
9
|
import { E as EnhanceRouterOptions, a as EnhancedRouter } from './shared/server.Cb6yD7DZ.js';
|
package/dist/index.mjs
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { mergeErrorMap, mergeMeta, mergeRoute, mergePrefix, mergeTags, isContractProcedure, getContractRouter, fallbackContractConfig } from '@orpc/contract';
|
|
2
2
|
export { ValidationError, eventIterator, type, validateORPCError } from '@orpc/contract';
|
|
3
|
-
import { P as Procedure, b as addMiddleware, c as createProcedureClient, e as enhanceRouter, l as lazy, s as setHiddenRouterContract, u as unlazy, g as getRouter, i as isProcedure, d as isLazy, f as createAssertedLazyProcedure } from './shared/server.
|
|
4
|
-
export { L as LAZY_SYMBOL, p as call, r as createAccessibleLazyRouter, a as createContractedProcedure, h as createORPCErrorConstructorMap, q as getHiddenRouterContract, j as getLazyMeta, n as isStartWithMiddlewares, m as mergeCurrentContext, o as mergeMiddlewares, k as middlewareOutputFn, v as resolveContractProcedures, t as traverseContractProcedures, w as unlazyRouter } from './shared/server.
|
|
3
|
+
import { P as Procedure, b as addMiddleware, c as createProcedureClient, e as enhanceRouter, l as lazy, s as setHiddenRouterContract, u as unlazy, g as getRouter, i as isProcedure, d as isLazy, f as createAssertedLazyProcedure } from './shared/server.Ds4HPpvH.mjs';
|
|
4
|
+
export { L as LAZY_SYMBOL, p as call, r as createAccessibleLazyRouter, a as createContractedProcedure, h as createORPCErrorConstructorMap, q as getHiddenRouterContract, j as getLazyMeta, n as isStartWithMiddlewares, m as mergeCurrentContext, o as mergeMiddlewares, k as middlewareOutputFn, v as resolveContractProcedures, t as traverseContractProcedures, w as unlazyRouter } from './shared/server.Ds4HPpvH.mjs';
|
|
5
5
|
import { toORPCError } from '@orpc/client';
|
|
6
6
|
export { ORPCError, isDefinedError, safe } from '@orpc/client';
|
|
7
|
-
import { resolveMaybeOptionalOptions } from '@orpc/shared';
|
|
8
|
-
export { AsyncIteratorClass, EventPublisher, asyncIteratorToStream as eventIteratorToStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
|
|
7
|
+
import { isObject, resolveMaybeOptionalOptions } from '@orpc/shared';
|
|
8
|
+
export { AsyncIteratorClass, EventPublisher, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@orpc/shared';
|
|
9
9
|
export { getEventMeta, withEventMeta } from '@orpc/standard-server';
|
|
10
10
|
|
|
11
11
|
const DEFAULT_CONFIG = {
|
|
@@ -54,6 +54,9 @@ function createActionableClient(client) {
|
|
|
54
54
|
if (error instanceof Error && "digest" in error && typeof error.digest === "string" && error.digest.startsWith("NEXT_")) {
|
|
55
55
|
throw error;
|
|
56
56
|
}
|
|
57
|
+
if (error instanceof Response && "options" in error && isObject(error.options) || isObject(error) && error.isNotFound === true) {
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
57
60
|
return [toORPCError(error).toJSON(), void 0];
|
|
58
61
|
}
|
|
59
62
|
};
|
package/dist/plugins/index.d.mts
CHANGED
|
@@ -160,6 +160,9 @@ interface StrictGetMethodPluginOptions {
|
|
|
160
160
|
*/
|
|
161
161
|
declare class StrictGetMethodPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
162
162
|
private readonly error;
|
|
163
|
+
/**
|
|
164
|
+
* make sure execute before batch plugin to get real method
|
|
165
|
+
*/
|
|
163
166
|
order: number;
|
|
164
167
|
constructor(options?: StrictGetMethodPluginOptions);
|
|
165
168
|
init(options: StandardHandlerOptions<T>): void;
|
package/dist/plugins/index.d.ts
CHANGED
|
@@ -160,6 +160,9 @@ interface StrictGetMethodPluginOptions {
|
|
|
160
160
|
*/
|
|
161
161
|
declare class StrictGetMethodPlugin<T extends Context> implements StandardHandlerPlugin<T> {
|
|
162
162
|
private readonly error;
|
|
163
|
+
/**
|
|
164
|
+
* make sure execute before batch plugin to get real method
|
|
165
|
+
*/
|
|
163
166
|
order: number;
|
|
164
167
|
constructor(options?: StrictGetMethodPluginOptions);
|
|
165
168
|
init(options: StandardHandlerOptions<T>): void;
|
package/dist/plugins/index.mjs
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { runWithSpan, value, setSpanError, isAsyncIteratorObject, clone } from '@orpc/shared';
|
|
1
|
+
import { runWithSpan, value, setSpanError, isAsyncIteratorObject, AsyncIteratorClass, clone } from '@orpc/shared';
|
|
2
2
|
import { flattenHeader } from '@orpc/standard-server';
|
|
3
3
|
import { parseBatchRequest, toBatchResponse } from '@orpc/standard-server/batch';
|
|
4
4
|
import { toFetchHeaders } from '@orpc/standard-server-fetch';
|
|
5
5
|
import { ORPCError } from '@orpc/client';
|
|
6
|
-
export { S as StrictGetMethodPlugin } from '../shared/server.
|
|
6
|
+
export { S as StrictGetMethodPlugin } from '../shared/server.TEVCLCFC.mjs';
|
|
7
7
|
import '@orpc/contract';
|
|
8
8
|
|
|
9
9
|
class BatchHandlerPlugin {
|
|
@@ -79,22 +79,24 @@ class BatchHandlerPlugin {
|
|
|
79
79
|
await Promise.race(responses);
|
|
80
80
|
const status = await value(this.successStatus, responses, options2);
|
|
81
81
|
const headers = await value(this.headers, responses, options2);
|
|
82
|
+
const promises = [...responses];
|
|
82
83
|
const response = await toBatchResponse({
|
|
83
84
|
status,
|
|
84
85
|
headers,
|
|
85
86
|
mode,
|
|
86
|
-
body:
|
|
87
|
-
|
|
88
|
-
while (true) {
|
|
87
|
+
body: new AsyncIteratorClass(
|
|
88
|
+
async () => {
|
|
89
89
|
const handling = promises.filter((p) => p !== void 0);
|
|
90
|
-
if (handling.length
|
|
91
|
-
return;
|
|
90
|
+
if (handling.length <= 0) {
|
|
91
|
+
return { done: true, value: void 0 };
|
|
92
92
|
}
|
|
93
|
-
const
|
|
94
|
-
promises[
|
|
95
|
-
|
|
93
|
+
const value2 = await Promise.race(handling);
|
|
94
|
+
promises[value2.index] = void 0;
|
|
95
|
+
return { done: false, value: value2 };
|
|
96
|
+
},
|
|
97
|
+
async () => {
|
|
96
98
|
}
|
|
97
|
-
|
|
99
|
+
)
|
|
98
100
|
});
|
|
99
101
|
return {
|
|
100
102
|
matched: true,
|
|
@@ -2,7 +2,7 @@ import { toHttpPath, StandardRPCJsonSerializer, StandardRPCSerializer } from '@o
|
|
|
2
2
|
import { ORPCError, toORPCError } from '@orpc/client';
|
|
3
3
|
import { toArray, intercept, runWithSpan, ORPC_NAME, isAsyncIteratorObject, asyncIteratorWithSpan, setSpanError, parseEmptyableJSON, NullProtoObj, value } from '@orpc/shared';
|
|
4
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.
|
|
5
|
+
import { c as createProcedureClient, t as traverseContractProcedures, i as isProcedure, u as unlazy, g as getRouter, a as createContractedProcedure } from './server.Ds4HPpvH.mjs';
|
|
6
6
|
|
|
7
7
|
class CompositeStandardHandlerPlugin {
|
|
8
8
|
plugins;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isContractProcedure, validateORPCError, ValidationError, mergePrefix, mergeErrorMap, enhanceRoute } from '@orpc/contract';
|
|
2
|
-
import { resolveMaybeOptionalOptions, toArray, value, runWithSpan, intercept, isAsyncIteratorObject, asyncIteratorWithSpan } from '@orpc/shared';
|
|
2
|
+
import { resolveMaybeOptionalOptions, toArray, value, runWithSpan, intercept, isAsyncIteratorObject, overlayProxy, asyncIteratorWithSpan } from '@orpc/shared';
|
|
3
3
|
import { ORPCError, mapEventIterator } from '@orpc/client';
|
|
4
4
|
import { HibernationEventIterator } from '@orpc/standard-server';
|
|
5
5
|
|
|
@@ -132,7 +132,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
132
132
|
if (output instanceof HibernationEventIterator) {
|
|
133
133
|
return output;
|
|
134
134
|
}
|
|
135
|
-
return mapEventIterator(
|
|
135
|
+
return overlayProxy(output, mapEventIterator(
|
|
136
136
|
asyncIteratorWithSpan(
|
|
137
137
|
{ name: "consume_event_iterator_output", signal: callerOptions?.signal },
|
|
138
138
|
output
|
|
@@ -141,7 +141,7 @@ function createProcedureClient(lazyableProcedure, ...rest) {
|
|
|
141
141
|
value: (v) => v,
|
|
142
142
|
error: (e) => validateError(e)
|
|
143
143
|
}
|
|
144
|
-
);
|
|
144
|
+
));
|
|
145
145
|
}
|
|
146
146
|
return output;
|
|
147
147
|
} catch (e) {
|
|
@@ -3,6 +3,9 @@ import { ORPCError, fallbackContractConfig } from '@orpc/contract';
|
|
|
3
3
|
const STRICT_GET_METHOD_PLUGIN_IS_GET_METHOD_CONTEXT_SYMBOL = Symbol("STRICT_GET_METHOD_PLUGIN_IS_GET_METHOD_CONTEXT");
|
|
4
4
|
class StrictGetMethodPlugin {
|
|
5
5
|
error;
|
|
6
|
+
/**
|
|
7
|
+
* make sure execute before batch plugin to get real method
|
|
8
|
+
*/
|
|
6
9
|
order = 7e6;
|
|
7
10
|
constructor(options = {}) {
|
|
8
11
|
this.error = options.error ?? new ORPCError("METHOD_NOT_SUPPORTED");
|
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.b1b9914",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
|
7
7
|
"repository": {
|
|
@@ -54,6 +54,11 @@
|
|
|
54
54
|
"import": "./dist/adapters/node/index.mjs",
|
|
55
55
|
"default": "./dist/adapters/node/index.mjs"
|
|
56
56
|
},
|
|
57
|
+
"./fastify": {
|
|
58
|
+
"types": "./dist/adapters/fastify/index.d.mts",
|
|
59
|
+
"import": "./dist/adapters/fastify/index.mjs",
|
|
60
|
+
"default": "./dist/adapters/fastify/index.mjs"
|
|
61
|
+
},
|
|
57
62
|
"./aws-lambda": {
|
|
58
63
|
"types": "./dist/adapters/aws-lambda/index.d.mts",
|
|
59
64
|
"import": "./dist/adapters/aws-lambda/index.mjs",
|
|
@@ -102,22 +107,26 @@
|
|
|
102
107
|
},
|
|
103
108
|
"dependencies": {
|
|
104
109
|
"cookie": "^1.0.2",
|
|
105
|
-
"@orpc/client": "0.0.0-next.
|
|
106
|
-
"@orpc/
|
|
107
|
-
"@orpc/
|
|
108
|
-
"@orpc/standard-server": "0.0.0-next.
|
|
109
|
-
"@orpc/
|
|
110
|
-
"@orpc/standard-server-
|
|
111
|
-
"@orpc/
|
|
112
|
-
"@orpc/standard-server-
|
|
113
|
-
"@orpc/standard-server-node": "0.0.0-next.
|
|
110
|
+
"@orpc/client": "0.0.0-next.b1b9914",
|
|
111
|
+
"@orpc/interop": "0.0.0-next.b1b9914",
|
|
112
|
+
"@orpc/contract": "0.0.0-next.b1b9914",
|
|
113
|
+
"@orpc/standard-server": "0.0.0-next.b1b9914",
|
|
114
|
+
"@orpc/standard-server-aws-lambda": "0.0.0-next.b1b9914",
|
|
115
|
+
"@orpc/standard-server-fastify": "0.0.0-next.b1b9914",
|
|
116
|
+
"@orpc/shared": "0.0.0-next.b1b9914",
|
|
117
|
+
"@orpc/standard-server-fetch": "0.0.0-next.b1b9914",
|
|
118
|
+
"@orpc/standard-server-node": "0.0.0-next.b1b9914",
|
|
119
|
+
"@orpc/standard-server-peer": "0.0.0-next.b1b9914"
|
|
114
120
|
},
|
|
115
121
|
"devDependencies": {
|
|
122
|
+
"@tanstack/router-core": "^1.133.36",
|
|
116
123
|
"@types/ws": "^8.18.1",
|
|
117
124
|
"crossws": "^0.4.1",
|
|
118
|
-
"
|
|
125
|
+
"fastify": "^5.6.1",
|
|
126
|
+
"next": "^16.0.1",
|
|
119
127
|
"supertest": "^7.1.4",
|
|
120
|
-
"ws": "^8.18.3"
|
|
128
|
+
"ws": "^8.18.3",
|
|
129
|
+
"zod": "^4.1.12"
|
|
121
130
|
},
|
|
122
131
|
"scripts": {
|
|
123
132
|
"build": "unbuild",
|