@orpc/server 0.0.0-next.e39a46e → 0.0.0-next.e49bee7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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/message-port/index.d.mts +30 -4
- package/dist/adapters/message-port/index.d.ts +30 -4
- package/dist/adapters/message-port/index.mjs +26 -10
- package/dist/adapters/node/index.d.mts +1 -1
- package/dist/adapters/node/index.d.ts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +5 -2
- package/package.json +21 -12
|
@@ -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 };
|
|
@@ -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,6 +1,6 @@
|
|
|
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';
|
|
@@ -11,18 +11,34 @@ import '../../shared/server.DZ5BIITo.mjs';
|
|
|
11
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;
|
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
|
@@ -4,8 +4,8 @@ import { P as Procedure, b as addMiddleware, c as createProcedureClient, e as en
|
|
|
4
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/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.e49bee7",
|
|
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/
|
|
106
|
-
"@orpc/
|
|
107
|
-
"@orpc/
|
|
108
|
-
"@orpc/
|
|
109
|
-
"@orpc/standard-server": "0.0.0-next.
|
|
110
|
-
"@orpc/standard-server-
|
|
111
|
-
"@orpc/standard-server-
|
|
112
|
-
"@orpc/standard-server-
|
|
113
|
-
"@orpc/standard-server-peer": "0.0.0-next.
|
|
110
|
+
"@orpc/client": "0.0.0-next.e49bee7",
|
|
111
|
+
"@orpc/contract": "0.0.0-next.e49bee7",
|
|
112
|
+
"@orpc/shared": "0.0.0-next.e49bee7",
|
|
113
|
+
"@orpc/standard-server": "0.0.0-next.e49bee7",
|
|
114
|
+
"@orpc/standard-server-aws-lambda": "0.0.0-next.e49bee7",
|
|
115
|
+
"@orpc/standard-server-fastify": "0.0.0-next.e49bee7",
|
|
116
|
+
"@orpc/standard-server-fetch": "0.0.0-next.e49bee7",
|
|
117
|
+
"@orpc/standard-server-node": "0.0.0-next.e49bee7",
|
|
118
|
+
"@orpc/standard-server-peer": "0.0.0-next.e49bee7",
|
|
119
|
+
"@orpc/interop": "0.0.0-next.e49bee7"
|
|
114
120
|
},
|
|
115
121
|
"devDependencies": {
|
|
122
|
+
"@tanstack/router-core": "^1.136.8",
|
|
116
123
|
"@types/ws": "^8.18.1",
|
|
117
124
|
"crossws": "^0.4.1",
|
|
118
|
-
"
|
|
125
|
+
"fastify": "^5.6.2",
|
|
126
|
+
"next": "^16.0.3",
|
|
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",
|