@orpc/server 2.0.0-beta.2 → 2.0.0-beta.21
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 +32 -21
- package/dist/adapters/crossws/index.d.mts +11 -8
- package/dist/adapters/crossws/index.d.ts +11 -8
- package/dist/adapters/crossws/index.mjs +10 -7
- package/dist/adapters/fetch/index.d.mts +8 -56
- package/dist/adapters/fetch/index.d.ts +8 -56
- package/dist/adapters/fetch/index.mjs +6 -136
- package/dist/adapters/message-port/index.d.mts +11 -13
- package/dist/adapters/message-port/index.d.ts +11 -13
- package/dist/adapters/message-port/index.mjs +28 -32
- package/dist/adapters/node/index.d.mts +7 -37
- package/dist/adapters/node/index.d.ts +7 -37
- package/dist/adapters/node/index.mjs +6 -112
- package/dist/adapters/standard/index.d.mts +6 -6
- package/dist/adapters/standard/index.d.ts +6 -6
- package/dist/adapters/standard/index.mjs +3 -3
- package/dist/adapters/standard-peer/index.d.mts +2 -2
- package/dist/adapters/standard-peer/index.d.ts +2 -2
- package/dist/adapters/websocket/index.d.mts +36 -26
- package/dist/adapters/websocket/index.d.ts +36 -26
- package/dist/adapters/websocket/index.mjs +33 -25
- package/dist/extensions/callable.d.mts +1 -1
- package/dist/extensions/callable.d.ts +1 -1
- package/dist/extensions/callable.mjs +2 -2
- package/dist/helpers/index.d.mts +3 -3
- package/dist/helpers/index.d.ts +3 -3
- package/dist/helpers/index.mjs +13 -5
- package/dist/index.d.mts +19 -16
- package/dist/index.d.ts +19 -16
- package/dist/index.mjs +36 -22
- package/dist/plugins/index.d.mts +136 -5
- package/dist/plugins/index.d.ts +136 -5
- package/dist/plugins/index.mjs +394 -6
- package/dist/shared/{server.BsNNjG5J.d.mts → server.15O7oC1p.d.mts} +1 -1
- package/dist/shared/{server.B_U9y00a.d.mts → server.B4BnEWWm.d.mts} +6 -5
- package/dist/shared/{server.EOHJ3NJr.d.ts → server.BhsVw7m7.d.ts} +2 -2
- package/dist/shared/{server.BwHnWUuN.mjs → server.BoiFpNT7.mjs} +4 -2
- package/dist/shared/{server.GDpX6Df8.mjs → server.COPVXhDG.mjs} +3 -3
- package/dist/shared/{server.BL22TloH.d.mts → server.CcR4kgje.d.mts} +25 -3
- package/dist/shared/{server.BL22TloH.d.ts → server.CcR4kgje.d.ts} +25 -3
- package/dist/shared/{server.T9F3bzZx.d.ts → server.CnN50DHH.d.ts} +6 -5
- package/dist/shared/{server.CjOb6ItT.mjs → server.DBs0rrf9.mjs} +1 -1
- package/dist/shared/{server.BB_Ik9Ph.d.mts → server.DDFizwfU.d.mts} +2 -2
- package/dist/shared/{server.CrlKQucM.mjs → server.DofEOwf-.mjs} +11 -7
- package/dist/shared/{server.Pa0F03f_.d.ts → server.m3szVJGU.d.ts} +1 -1
- package/package.json +9 -10
|
@@ -1,16 +1,22 @@
|
|
|
1
|
-
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
1
|
+
import { Arrayable, MaybeOptionalOptions } from '@orpc/shared';
|
|
2
2
|
import { EncodePeerMessageOptions, DecodePeerMessageOptions } from '@standardserver/peer';
|
|
3
|
-
import { C as Context } from '../../shared/server.
|
|
4
|
-
import { S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.
|
|
3
|
+
import { C as Context } from '../../shared/server.CcR4kgje.js';
|
|
4
|
+
import { S as StandardHandler, a as StandardHandlerOptions } from '../../shared/server.BhsVw7m7.js';
|
|
5
5
|
import { StandardPeerRequestHandlerOptions } from '../standard-peer/index.js';
|
|
6
|
-
import { R as Router } from '../../shared/server.
|
|
7
|
-
import { R as RPCHandlerCodecOptions } from '../../shared/server.
|
|
6
|
+
import { R as Router } from '../../shared/server.m3szVJGU.js';
|
|
7
|
+
import { R as RPCHandlerCodecOptions } from '../../shared/server.CnN50DHH.js';
|
|
8
8
|
import '@orpc/client';
|
|
9
9
|
import '@orpc/contract';
|
|
10
10
|
import '@standardserver/core';
|
|
11
11
|
|
|
12
|
-
|
|
13
|
-
|
|
12
|
+
/**
|
|
13
|
+
* Supports standard WebSocket instances, Bun ServerWebSocket, "ws" ServerWebSocket,
|
|
14
|
+
* Cloudflare WebSocket Hibernation, and similar implementations.
|
|
15
|
+
*/
|
|
16
|
+
type WebSocketLike = {
|
|
17
|
+
send: (data: string | Uint8Array<ArrayBuffer>) => unknown;
|
|
18
|
+
};
|
|
19
|
+
interface WebSocketHandlerOptions<_T extends Context> {
|
|
14
20
|
/**
|
|
15
21
|
* Options for encoding peer messages. such as `prefix` for distinguishing messages on the same channel..
|
|
16
22
|
*/
|
|
@@ -20,42 +26,46 @@ interface WebsocketHandlerOptions<_T extends Context> {
|
|
|
20
26
|
*/
|
|
21
27
|
decodePeerMessage?: DecodePeerMessageOptions | undefined;
|
|
22
28
|
}
|
|
23
|
-
declare class
|
|
29
|
+
declare class WebSocketHandler<T extends Context> {
|
|
24
30
|
private readonly handler;
|
|
25
31
|
private readonly peers;
|
|
26
32
|
private readonly encodePeerMessageOptions;
|
|
27
33
|
private readonly decodePeerMessageOptions;
|
|
28
|
-
constructor(handler: StandardHandler<T>, options?: NoInfer<
|
|
34
|
+
constructor(handler: StandardHandler<T>, options?: NoInfer<WebSocketHandlerOptions<T>>);
|
|
29
35
|
/**
|
|
30
|
-
*
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
* Handles a single message received from a WebSocket.
|
|
36
|
+
* Handles a single WebSocket message.
|
|
37
|
+
*
|
|
38
|
+
* Message order matters. Call this immediately after receiving a message,
|
|
39
|
+
* before any other async work, to preserve ordering.
|
|
35
40
|
*
|
|
36
|
-
*
|
|
41
|
+
* To avoid async Blob reads, configure `ws.binaryType` to return binary data
|
|
42
|
+
* directly (for example, `arraybuffer`).
|
|
37
43
|
*
|
|
38
|
-
* @param ws The WebSocket instance
|
|
39
|
-
* @param data The message data
|
|
44
|
+
* @param ws The WebSocket instance. Use the same instance for all messages.
|
|
45
|
+
* @param data The received message. Binary data should already be loaded (not a `Blob`).
|
|
40
46
|
*/
|
|
41
|
-
message(ws:
|
|
47
|
+
message(ws: WebSocketLike, data: Arrayable<string | ArrayBuffer | Pick<Uint8Array<ArrayBuffer>, 'buffer' | 'byteOffset' | 'byteLength'>>, ...rest: MaybeOptionalOptions<StandardPeerRequestHandlerOptions<T>>): Promise<{
|
|
42
48
|
matched: boolean;
|
|
43
49
|
}>;
|
|
44
50
|
/**
|
|
45
|
-
*
|
|
51
|
+
* Cleans up peer state for a closed WebSocket.
|
|
46
52
|
*
|
|
47
|
-
* @
|
|
53
|
+
* @param ws The same WebSocket instance passed to `.message()`.
|
|
54
|
+
*/
|
|
55
|
+
close(ws: WebSocketLike): Promise<void>;
|
|
56
|
+
/**
|
|
57
|
+
* Attaches message and close event listeners to a WebSocket.
|
|
48
58
|
*
|
|
49
|
-
*
|
|
59
|
+
* Prefer this over calling `.message()` and `.close()` manually.
|
|
50
60
|
*/
|
|
51
|
-
|
|
61
|
+
upgrade(ws: Pick<WebSocket, 'send' | 'addEventListener' | 'removeEventListener'>, ...rest: MaybeOptionalOptions<StandardPeerRequestHandlerOptions<T>>): void;
|
|
52
62
|
}
|
|
53
63
|
|
|
54
|
-
interface RPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, RPCHandlerCodecOptions<T>,
|
|
64
|
+
interface RPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, RPCHandlerCodecOptions<T>, WebSocketHandlerOptions<T> {
|
|
55
65
|
}
|
|
56
|
-
declare class RPCHandler<T extends Context> extends
|
|
66
|
+
declare class RPCHandler<T extends Context> extends WebSocketHandler<T> {
|
|
57
67
|
constructor(router: Router<T>, options?: NoInfer<RPCHandlerOptions<T>>);
|
|
58
68
|
}
|
|
59
69
|
|
|
60
|
-
export { RPCHandler,
|
|
61
|
-
export type { RPCHandlerOptions,
|
|
70
|
+
export { RPCHandler, WebSocketHandler };
|
|
71
|
+
export type { RPCHandlerOptions, WebSocketHandlerOptions, WebSocketLike };
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { toStringOrBytes, resolveMaybeOptionalOptions } from '@orpc/shared';
|
|
1
|
+
import { toStringOrBytes, resolveMaybeOptionalOptions, sequential, loadBytes } from '@orpc/shared';
|
|
2
2
|
import { ServerPeer, encodePeerMessage, decodePeerMessage, isClientPeerSendMessage } from '@standardserver/peer';
|
|
3
3
|
import { c as createStandardPeerRequestHandler } from '../../shared/server.CX4vUnDk.mjs';
|
|
4
|
-
import { R as RPCHandlerCodec, S as StandardHandler } from '../../shared/server.
|
|
4
|
+
import { R as RPCHandlerCodec, S as StandardHandler } from '../../shared/server.COPVXhDG.mjs';
|
|
5
5
|
import '@orpc/client';
|
|
6
6
|
import '@standardserver/core';
|
|
7
|
-
import '../../shared/server.
|
|
7
|
+
import '../../shared/server.DofEOwf-.mjs';
|
|
8
8
|
import '@orpc/contract';
|
|
9
|
-
import '../../shared/server.
|
|
9
|
+
import '../../shared/server.BoiFpNT7.mjs';
|
|
10
10
|
|
|
11
|
-
class
|
|
11
|
+
class WebSocketHandler {
|
|
12
12
|
constructor(handler, options = {}) {
|
|
13
13
|
this.handler = handler;
|
|
14
14
|
this.encodePeerMessageOptions = options.encodePeerMessage;
|
|
@@ -18,28 +18,26 @@ class WebsocketHandler {
|
|
|
18
18
|
encodePeerMessageOptions;
|
|
19
19
|
decodePeerMessageOptions;
|
|
20
20
|
/**
|
|
21
|
-
*
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
ws.addEventListener("close", () => this.close(ws));
|
|
26
|
-
}
|
|
27
|
-
/**
|
|
28
|
-
* Handles a single message received from a WebSocket.
|
|
21
|
+
* Handles a single WebSocket message.
|
|
22
|
+
*
|
|
23
|
+
* Message order matters. Call this immediately after receiving a message,
|
|
24
|
+
* before any other async work, to preserve ordering.
|
|
29
25
|
*
|
|
30
|
-
*
|
|
26
|
+
* To avoid async Blob reads, configure `ws.binaryType` to return binary data
|
|
27
|
+
* directly (for example, `arraybuffer`).
|
|
31
28
|
*
|
|
32
|
-
* @param ws The WebSocket instance
|
|
33
|
-
* @param data The message data
|
|
29
|
+
* @param ws The WebSocket instance. Use the same instance for all messages.
|
|
30
|
+
* @param data The received message. Binary data should already be loaded (not a `Blob`).
|
|
34
31
|
*/
|
|
35
32
|
async message(ws, data, ...rest) {
|
|
36
33
|
let peer = this.peers.get(ws);
|
|
37
34
|
if (!peer) {
|
|
38
35
|
this.peers.set(ws, peer = new ServerPeer(async (message) => {
|
|
39
|
-
|
|
36
|
+
const encoded2 = await encodePeerMessage(message, this.encodePeerMessageOptions);
|
|
37
|
+
await ws.send(encoded2);
|
|
40
38
|
}));
|
|
41
39
|
}
|
|
42
|
-
const encoded =
|
|
40
|
+
const encoded = toStringOrBytes(data);
|
|
43
41
|
const result = decodePeerMessage(encoded, this.decodePeerMessageOptions);
|
|
44
42
|
if (result.matched && isClientPeerSendMessage(result.message)) {
|
|
45
43
|
await peer.message(
|
|
@@ -50,22 +48,32 @@ class WebsocketHandler {
|
|
|
50
48
|
return result;
|
|
51
49
|
}
|
|
52
50
|
/**
|
|
53
|
-
*
|
|
51
|
+
* Cleans up peer state for a closed WebSocket.
|
|
54
52
|
*
|
|
55
|
-
* @
|
|
56
|
-
*
|
|
57
|
-
* @param ws The WebSocket instance to clean up, must be the same instance used in `.message()` calls to properly clean up
|
|
53
|
+
* @param ws The same WebSocket instance passed to `.message()`.
|
|
58
54
|
*/
|
|
59
55
|
async close(ws) {
|
|
60
56
|
const peer = this.peers.get(ws);
|
|
61
57
|
if (peer) {
|
|
62
|
-
await peer.close();
|
|
63
58
|
this.peers.delete(ws);
|
|
59
|
+
await peer.close();
|
|
64
60
|
}
|
|
65
61
|
}
|
|
62
|
+
/**
|
|
63
|
+
* Attaches message and close event listeners to a WebSocket.
|
|
64
|
+
*
|
|
65
|
+
* Prefer this over calling `.message()` and `.close()` manually.
|
|
66
|
+
*/
|
|
67
|
+
upgrade(ws, ...rest) {
|
|
68
|
+
ws.addEventListener("message", sequential(async (event) => {
|
|
69
|
+
const data = event.data instanceof Blob ? await loadBytes(event.data) : event.data;
|
|
70
|
+
this.message(ws, data, ...rest);
|
|
71
|
+
}));
|
|
72
|
+
ws.addEventListener("close", () => this.close(ws));
|
|
73
|
+
}
|
|
66
74
|
}
|
|
67
75
|
|
|
68
|
-
class RPCHandler extends
|
|
76
|
+
class RPCHandler extends WebSocketHandler {
|
|
69
77
|
constructor(router, options = {}) {
|
|
70
78
|
const codec = new RPCHandlerCodec(router, options);
|
|
71
79
|
const handler = new StandardHandler(codec, options);
|
|
@@ -73,4 +81,4 @@ class RPCHandler extends WebsocketHandler {
|
|
|
73
81
|
}
|
|
74
82
|
}
|
|
75
83
|
|
|
76
|
-
export { RPCHandler,
|
|
84
|
+
export { RPCHandler, WebSocketHandler };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnyORPCError, ClientContext } from '@orpc/client';
|
|
2
2
|
import { AnySchema, ErrorMap } from '@orpc/contract';
|
|
3
3
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
4
|
-
import { C as Context, P as ProcedureClientOptions, a as Procedure, b as ProcedureClient } from '../shared/server.
|
|
4
|
+
import { C as Context, P as ProcedureClientOptions, a as Procedure, b as ProcedureClient } from '../shared/server.CcR4kgje.mjs';
|
|
5
5
|
|
|
6
6
|
declare module "../index" {
|
|
7
7
|
interface DecoratedProcedure<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TReturnedError extends AnyORPCError> {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AnyORPCError, ClientContext } from '@orpc/client';
|
|
2
2
|
import { AnySchema, ErrorMap } from '@orpc/contract';
|
|
3
3
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
|
4
|
-
import { C as Context, P as ProcedureClientOptions, a as Procedure, b as ProcedureClient } from '../shared/server.
|
|
4
|
+
import { C as Context, P as ProcedureClientOptions, a as Procedure, b as ProcedureClient } from '../shared/server.CcR4kgje.js';
|
|
5
5
|
|
|
6
6
|
declare module "../index" {
|
|
7
7
|
interface DecoratedProcedure<TInitialContext extends Context, TInjectedContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TReturnedError extends AnyORPCError> {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { c as createProcedureClient } from '../shared/server.
|
|
2
|
-
import { D as DecoratedProcedure } from '../shared/server.
|
|
1
|
+
import { c as createProcedureClient } from '../shared/server.DofEOwf-.mjs';
|
|
2
|
+
import { D as DecoratedProcedure } from '../shared/server.DBs0rrf9.mjs';
|
|
3
3
|
import '@orpc/client';
|
|
4
4
|
import '@orpc/contract';
|
|
5
5
|
import '@orpc/shared';
|
package/dist/helpers/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ParseOptions,
|
|
1
|
+
import { ParseOptions, SetCookie, StringifyOptions } from 'cookie';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Encodes a Uint8Array to base64url format
|
|
@@ -27,7 +27,7 @@ declare function encodeBase64url(data: Uint8Array): string;
|
|
|
27
27
|
*/
|
|
28
28
|
declare function decodeBase64url(base64url: string | undefined | null): Uint8Array<ArrayBuffer> | undefined;
|
|
29
29
|
|
|
30
|
-
interface SetCookieOptions extends
|
|
30
|
+
interface SetCookieOptions extends Omit<SetCookie, 'name' | 'value'>, StringifyOptions {
|
|
31
31
|
/**
|
|
32
32
|
* Specifies the value for the [`Path` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.4).
|
|
33
33
|
*
|
|
@@ -46,7 +46,7 @@ interface SetCookieOptions extends SerializeOptions {
|
|
|
46
46
|
*
|
|
47
47
|
* setCookie(headers, 'sessionId', 'abc123', { httpOnly: true, maxAge: 3600 })
|
|
48
48
|
*
|
|
49
|
-
* expect(headers.get('Set-Cookie')).toBe('sessionId=abc123;
|
|
49
|
+
* expect(headers.get('Set-Cookie')).toBe('sessionId=abc123; Max-Age=3600; Path=/; HttpOnly')
|
|
50
50
|
* ```
|
|
51
51
|
*
|
|
52
52
|
*/
|
package/dist/helpers/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ParseOptions,
|
|
1
|
+
import { ParseOptions, SetCookie, StringifyOptions } from 'cookie';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Encodes a Uint8Array to base64url format
|
|
@@ -27,7 +27,7 @@ declare function encodeBase64url(data: Uint8Array): string;
|
|
|
27
27
|
*/
|
|
28
28
|
declare function decodeBase64url(base64url: string | undefined | null): Uint8Array<ArrayBuffer> | undefined;
|
|
29
29
|
|
|
30
|
-
interface SetCookieOptions extends
|
|
30
|
+
interface SetCookieOptions extends Omit<SetCookie, 'name' | 'value'>, StringifyOptions {
|
|
31
31
|
/**
|
|
32
32
|
* Specifies the value for the [`Path` `Set-Cookie` attribute](https://tools.ietf.org/html/rfc6265#section-5.2.4).
|
|
33
33
|
*
|
|
@@ -46,7 +46,7 @@ interface SetCookieOptions extends SerializeOptions {
|
|
|
46
46
|
*
|
|
47
47
|
* setCookie(headers, 'sessionId', 'abc123', { httpOnly: true, maxAge: 3600 })
|
|
48
48
|
*
|
|
49
|
-
* expect(headers.get('Set-Cookie')).toBe('sessionId=abc123;
|
|
49
|
+
* expect(headers.get('Set-Cookie')).toBe('sessionId=abc123; Max-Age=3600; Path=/; HttpOnly')
|
|
50
50
|
* ```
|
|
51
51
|
*
|
|
52
52
|
*/
|
package/dist/helpers/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { parseCookie, stringifySetCookie } from 'cookie';
|
|
2
2
|
|
|
3
3
|
function encodeBase64url(data) {
|
|
4
4
|
const chunkSize = 8192;
|
|
@@ -34,10 +34,17 @@ function setCookie(headers, name, value, options = {}) {
|
|
|
34
34
|
if (headers === void 0) {
|
|
35
35
|
return;
|
|
36
36
|
}
|
|
37
|
-
const cookieString =
|
|
37
|
+
const cookieString = stringifySetCookie({
|
|
38
|
+
// Force path to '/' by default so the cookie is available across the
|
|
39
|
+
// entire app, not just under the directory of the request that set it
|
|
40
|
+
// (which is what browsers do per RFC 6265 §5.1.4 when Path is omitted).
|
|
38
41
|
path: "/",
|
|
39
|
-
...options
|
|
40
|
-
|
|
42
|
+
...options,
|
|
43
|
+
name,
|
|
44
|
+
// prioritize
|
|
45
|
+
value
|
|
46
|
+
// prioritize
|
|
47
|
+
}, options);
|
|
41
48
|
headers.append("Set-Cookie", cookieString);
|
|
42
49
|
}
|
|
43
50
|
function getCookie(headers, name, options = {}) {
|
|
@@ -48,12 +55,13 @@ function getCookie(headers, name, options = {}) {
|
|
|
48
55
|
if (cookieHeader === null) {
|
|
49
56
|
return void 0;
|
|
50
57
|
}
|
|
51
|
-
return
|
|
58
|
+
return parseCookie(cookieHeader, options)[name];
|
|
52
59
|
}
|
|
53
60
|
function deleteCookie(headers, name, options = {}) {
|
|
54
61
|
return setCookie(headers, name, "", {
|
|
55
62
|
...options,
|
|
56
63
|
maxAge: 0
|
|
64
|
+
// prioritize
|
|
57
65
|
});
|
|
58
66
|
}
|
|
59
67
|
|
package/dist/index.d.mts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { AnyORPCError, ClientOptions, ClientContext } from '@orpc/client';
|
|
2
|
-
export { AnyORPCError, AnyORPCErrorJSON, COMMON_ERROR_STATUS_MAP, ORPCError, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, RPCJsonSerialization, RPCJsonSerializationMeta, RPCJsonSerializer, RPCJsonSerializerHandler, RPCJsonSerializerOptions, RPCSerializer, RPCSerializerOptions, RPCSerializerSerializeOptions, cloneORPCError, isDefinedError, isInferableError, safe, toORPCError } from '@orpc/client';
|
|
2
|
+
export { AnyORPCError, AnyORPCErrorJSON, COMMON_ERROR_STATUS_MAP, Client, ClientContext, ClientOptions, ClientRest, FriendlyClientOptions, ORPCError, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, RPCJsonSerialization, RPCJsonSerializationMeta, RPCJsonSerializer, RPCJsonSerializerHandler, RPCJsonSerializerOptions, RPCSerializer, RPCSerializerOptions, RPCSerializerSerializeOptions, SafeResult, cloneORPCError, isDefinedError, isInferableError, safe, toORPCError } from '@orpc/client';
|
|
3
3
|
import { ErrorMap, MergedErrorMap, AnySchema, MetaPlugin, InferSchemaOutput, InferSchemaInput, AugmentContractRouterOptions, RouterContract, AnyProcedureContract, InitialInputSchema, InitialOutputSchema, MergedSchema, Schema, ProcedureContractDefinition, ProcedureContract, InferRouterContractErrorMap, ORPCErrorFromErrorMap } from '@orpc/contract';
|
|
4
|
-
export { AnyMetaPlugin, AnySchema, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, MergedErrorMap, Meta, MetaPlugin, MetaPluginDefinition, ORPCErrorFromErrorMap, ProcedureContract, ProcedureContractDefinition, RouterContract, Schema, ValidationError, defineMeta, eventIterator, reconcileORPCError, type } from '@orpc/contract';
|
|
4
|
+
export { AnyMetaPlugin, AnySchema, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, InitialInputSchema, InitialOutputSchema, MergedErrorMap, Meta, MetaPlugin, MetaPluginDefinition, ORPCErrorFromErrorMap, ProcedureContract, ProcedureContractDefinition, RouterContract, Schema, ValidationError, asyncIteratorObject, defineMeta, eventIterator, reconcileORPCError, type } from '@orpc/contract';
|
|
5
5
|
import { IntersectPick, Promisable, Public, PromiseWithError, ThrowableError, MaybeOptionalOptions } from '@orpc/shared';
|
|
6
|
-
export { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, Registry, ThrowableError, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onError, onFinish, onStart, onSuccess,
|
|
7
|
-
import { C as Context, d as Middleware, M as MergedContext, e as MergedInitialContext, a as Procedure, f as
|
|
8
|
-
export {
|
|
9
|
-
import { A as AnyRouter, R as Router, C as ContractedRouter, I as InferRouterInitialContext } from './shared/server.
|
|
10
|
-
export { a as InferRouterError, b as InferRouterErrors, c as InferRouterFinalContexts, d as InferRouterInitialContexts, e as InferRouterInputs, f as InferRouterOutputs } from './shared/server.
|
|
11
|
-
export { ErrorEvent, getEventMeta, unwrapEvent, withEventMeta } from '@standardserver/core';
|
|
6
|
+
export { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, MaybeOptionalOptions, PromiseWithError, Registry, ThrowableError, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject, streamToAsyncIteratorObject as streamToEventIterator } from '@orpc/shared';
|
|
7
|
+
import { C as Context, d as Middleware, M as MergedContext, e as MergedInitialContext, a as Procedure, f as ProcedureConfig, g as AnyMiddleware, h as Lazy, A as AnyProcedure, L as Lazyable, i as ProcedureHandler, O as ORPCErrorConstructorMap, j as OrderedMiddleware, P as ProcedureClientOptions, b as ProcedureClient } from './shared/server.CcR4kgje.mjs';
|
|
8
|
+
export { k as LazyDefinition, l as MiddlewareDefinition, m as MiddlewareDone, n as MiddlewareDoneOptions, o as MiddlewareNext, p as MiddlewareNextOptions, q as MiddlewareOptions, r as MiddlewareResult, s as ORPCErrorConstructorMapItem, t as ORPCErrorConstructorMapItemOptions, c as ProcedureClientInterceptor, u as ProcedureClientInterceptorOptions, v as ProcedureDefinition, w as ProcedureHandlerOptions, x as createORPCErrorConstructorMap, y as createProcedureClient, z as unlazy } from './shared/server.CcR4kgje.mjs';
|
|
9
|
+
import { A as AnyRouter, R as Router, C as ContractedRouter, I as InferRouterInitialContext } from './shared/server.15O7oC1p.mjs';
|
|
10
|
+
export { a as InferRouterError, b as InferRouterErrors, c as InferRouterFinalContexts, d as InferRouterInitialContexts, e as InferRouterInputs, f as InferRouterOutputs } from './shared/server.15O7oC1p.mjs';
|
|
11
|
+
export { ErrorEvent, EventMeta, getEventMeta, unwrapEvent, withEventMeta } from '@standardserver/core';
|
|
12
12
|
|
|
13
13
|
interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorMap extends ErrorMap> extends Middleware<TInContext, TOutContext, TInput, TOutput, TErrorMap> {
|
|
14
14
|
adaptInput<T>(adapt: (input: T) => TInput): DecoratedMiddleware<TInContext, TOutContext, T, TOutput, TErrorMap>;
|
|
@@ -29,11 +29,11 @@ type AugmentedRouter<T extends AnyRouter, TErrorMap extends ErrorMap> = T extend
|
|
|
29
29
|
type AugmentedRouterWithMiddlewares<T extends AnyRouter, TInitialContext extends Context, TInjectedContext extends Context, TErrorMap extends ErrorMap> = T extends Procedure<infer $InitialContext, infer $CurrentContext, infer $InputSchema, infer $OutputSchema, infer $ErrorMap, infer $ReturnedORPCError> ? Procedure<MergedInitialContext<TInitialContext, TInjectedContext, $InitialContext>, $CurrentContext, $InputSchema, $OutputSchema, MergedErrorMap<TErrorMap, $ErrorMap>, $ReturnedORPCError> : {
|
|
30
30
|
[K in keyof T]: T[K] extends Lazy<infer $ extends AnyRouter> ? Lazy<AugmentedRouterWithMiddlewares<$, TInitialContext, TInjectedContext, TErrorMap>> : T[K] extends AnyRouter ? AugmentedRouterWithMiddlewares<T[K], TInitialContext, TInjectedContext, TErrorMap> : never;
|
|
31
31
|
};
|
|
32
|
-
interface AugmentRouterOptions<TErrorMap extends ErrorMap> extends AugmentContractRouterOptions<TErrorMap
|
|
32
|
+
interface AugmentRouterOptions<TErrorMap extends ErrorMap> extends AugmentContractRouterOptions<TErrorMap>, ProcedureConfig {
|
|
33
33
|
middlewares: AnyMiddleware[];
|
|
34
34
|
}
|
|
35
35
|
declare function augmentRouter<T extends AnyRouter, TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap>(router: T, options: AugmentRouterOptions<TErrorMap>): AugmentedRouter<T, TErrorMap> | AugmentedRouterWithMiddlewares<T, TInitialContext, TCurrentContext, TErrorMap>;
|
|
36
|
-
interface AugmentImplementedRouterOptions {
|
|
36
|
+
interface AugmentImplementedRouterOptions extends ProcedureConfig {
|
|
37
37
|
middlewares: AnyMiddleware[];
|
|
38
38
|
}
|
|
39
39
|
declare function augmentImplementedRouter<T extends AnyRouter, TInitialContext extends Context, TCurrentContext extends Context>(router: T, options: AugmentImplementedRouterOptions): AugmentedRouter<T, object> | AugmentedRouterWithMiddlewares<T, TInitialContext, TCurrentContext, object>;
|
|
@@ -93,7 +93,7 @@ interface BuilderWithInputOutput<TInitialContext extends Context, TInjectedConte
|
|
|
93
93
|
|
|
94
94
|
interface DefaultInitialContext {
|
|
95
95
|
}
|
|
96
|
-
interface BuilderDefinition<TInputSchema extends AnySchema, TInjectedContext extends AnySchema, TErrorMap extends ErrorMap> extends ProcedureContractDefinition<TInputSchema, TInjectedContext, TErrorMap
|
|
96
|
+
interface BuilderDefinition<TInputSchema extends AnySchema, TInjectedContext extends AnySchema, TErrorMap extends ErrorMap> extends ProcedureContractDefinition<TInputSchema, TInjectedContext, TErrorMap>, ProcedureConfig {
|
|
97
97
|
orderedMiddlewares: OrderedMiddleware[];
|
|
98
98
|
}
|
|
99
99
|
declare class Builder<TInitialContext extends Context, TErrorMap extends ErrorMap> {
|
|
@@ -101,6 +101,7 @@ declare class Builder<TInitialContext extends Context, TErrorMap extends ErrorMa
|
|
|
101
101
|
private constructor();
|
|
102
102
|
static create<T extends Context = DefaultInitialContext>(): Builder<T & object, Record<never, never>>;
|
|
103
103
|
$context<T extends Context = DefaultInitialContext>(): Builder<T & object, TErrorMap>;
|
|
104
|
+
$config(config: ProcedureConfig): Builder<TInitialContext, TErrorMap>;
|
|
104
105
|
meta(...plugins: MetaPlugin<InitialInputSchema, InitialOutputSchema, TErrorMap>[]): Builder<TInitialContext, TErrorMap>;
|
|
105
106
|
errors<U extends ErrorMap>(errors: U): Builder<TInitialContext, MergedErrorMap<TErrorMap, U>>;
|
|
106
107
|
use<$OutContext extends IntersectPick<TInitialContext, $OutContext>, $InContext extends Context = TInitialContext, $ErrorMap extends ErrorMap = TErrorMap>(middleware: Middleware<$InContext | TInitialContext, $OutContext, InferSchemaOutput<InitialInputSchema>, InferSchemaInput<InitialOutputSchema>, $ErrorMap>): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, object, $InContext>, $OutContext, MergedErrorMap<$ErrorMap, TErrorMap>>;
|
|
@@ -130,10 +131,11 @@ declare class ImplementedProcedure<TInitialContext extends Context, TInjectedCon
|
|
|
130
131
|
|
|
131
132
|
declare class SharedRouterImplementer<TContract extends RouterContract, TInitialContext extends Context> {
|
|
132
133
|
private readonly contract;
|
|
134
|
+
private readonly config;
|
|
133
135
|
private readonly middlewares;
|
|
134
136
|
private constructor();
|
|
135
|
-
static create<TContract extends RouterContract, TInitialContext extends Context>(contract: TContract): SharedRouterImplementer<TContract, TInitialContext>;
|
|
136
|
-
static create<TContract extends RouterContract, TInitialContext extends Context, TInjectedContext extends Context>(contract: TContract, middlewares: AnyMiddleware[]): SharedRouterImplementerWithMiddlewares<TContract, TInitialContext, TInjectedContext>;
|
|
137
|
+
static create<TContract extends RouterContract, TInitialContext extends Context>(contract: TContract, config: ProcedureConfig): SharedRouterImplementer<TContract, TInitialContext>;
|
|
138
|
+
static create<TContract extends RouterContract, TInitialContext extends Context, TInjectedContext extends Context>(contract: TContract, config: ProcedureConfig, middlewares: AnyMiddleware[]): SharedRouterImplementerWithMiddlewares<TContract, TInitialContext, TInjectedContext>;
|
|
137
139
|
use<$OutContext extends IntersectPick<TInitialContext, $OutContext>, $InContext extends Context = TInitialContext, $ErrorMap extends ErrorMap = InferRouterContractErrorMap<TContract>>(middleware: Middleware<$InContext | TInitialContext, $OutContext, unknown, unknown, $ErrorMap>): RouterImplementerWithMiddlewares<TContract, MergedInitialContext<TInitialContext, object, $InContext>, $OutContext>;
|
|
138
140
|
middleware<$OutContext extends IntersectPick<TInitialContext, $OutContext>, $Input, $InContext extends Context = TInitialContext, $Output = any>(middleware: Middleware<$InContext | TInitialContext, $OutContext, $Input, $Output, InferRouterContractErrorMap<TContract>>): DecoratedMiddleware<MergedInitialContext<TInitialContext, object, $InContext>, $OutContext, $Input, $Output, object>;
|
|
139
141
|
router<T extends ContractedRouter<TContract, any>>(router: T): T;
|
|
@@ -155,12 +157,13 @@ type RouterImplementer<TContract extends RouterContract, TInitialContext extends
|
|
|
155
157
|
type RouterImplementerWithMiddlewares<TContract extends RouterContract, TInitialContext extends Context, TInjectedContext extends Context> = TContract extends ProcedureContract<infer $InputSchema, infer $OutputSchema, infer $ErrorMap> ? ProcedureImplementer<TInitialContext, TInjectedContext, $InputSchema, $OutputSchema, $ErrorMap> : SharedRouterImplementerWithMiddlewares<TContract, TInitialContext, TInjectedContext> & {
|
|
156
158
|
[K in keyof TContract]: TContract[K] extends RouterContract ? RouterImplementerWithMiddlewares<TContract[K], TInitialContext, TInjectedContext> : never;
|
|
157
159
|
};
|
|
158
|
-
declare function createRouterImplementer<TContract extends RouterContract, TInitialContext extends Context>(contract: TContract): RouterImplementer<TContract, TInitialContext>;
|
|
160
|
+
declare function createRouterImplementer<TContract extends RouterContract, TInitialContext extends Context>(contract: TContract, config: ProcedureConfig): RouterImplementer<TContract, TInitialContext>;
|
|
159
161
|
|
|
160
162
|
type Implementer<TContract extends RouterContract, TInitialContext extends Context> = {
|
|
161
163
|
$context<T extends Context = DefaultInitialContext>(): Implementer<TContract, T & object>;
|
|
164
|
+
$config(config: ProcedureConfig): Implementer<TContract, TInitialContext>;
|
|
162
165
|
} & RouterImplementer<TContract, TInitialContext>;
|
|
163
|
-
declare function implement<TContract extends RouterContract, TInitialContext extends Context = DefaultInitialContext>(contract: TContract): Implementer<TContract, TInitialContext & object>;
|
|
166
|
+
declare function implement<TContract extends RouterContract, TInitialContext extends Context = DefaultInitialContext>(contract: TContract, config?: ProcedureConfig): Implementer<TContract, TInitialContext & object>;
|
|
164
167
|
|
|
165
168
|
declare function createGuardedProcedureLazy(lazy: Lazy<unknown>): Lazy<AnyProcedure>;
|
|
166
169
|
/**
|
|
@@ -192,5 +195,5 @@ declare function createRouterClient<T extends AnyRouter, TClientContext extends
|
|
|
192
195
|
declare function withHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: RouterContract): T;
|
|
193
196
|
declare function getHiddenRouterContract(router: Lazyable<AnyRouter | RouterContract>): RouterContract | undefined;
|
|
194
197
|
|
|
195
|
-
export { AnyMiddleware, AnyProcedure, AnyRouter, Builder, Context, ContractedRouter, DEFAULT_ERROR_STATUS, DEFAULT_SUCCESS_STATUS, DecoratedProcedure, ImplementedProcedure, InferRouterInitialContext, Lazy, Lazyable, MergedContext, MergedInitialContext, Middleware, ORPCErrorConstructorMap, OrderedMiddleware, Procedure, ProcedureClient, ProcedureClientOptions, ProcedureHandler, ProcedureImplementer, Router, SharedRouterImplementer, augmentImplementedRouter, augmentRouter, call, createContractProcedure, createGuardedProcedureLazy, createRouterClient, createRouterImplementer, decorateMiddleware, getHiddenRouterContract, getRouter, implement, os, unlazyRouter, walkProcedureContractsAsync, walkProcedureContractsSync, withHiddenRouterContract };
|
|
198
|
+
export { AnyMiddleware, AnyProcedure, AnyRouter, Builder, Context, ContractedRouter, DEFAULT_ERROR_STATUS, DEFAULT_SUCCESS_STATUS, DecoratedProcedure, ImplementedProcedure, InferRouterInitialContext, Lazy, Lazyable, MergedContext, MergedInitialContext, Middleware, ORPCErrorConstructorMap, OrderedMiddleware, Procedure, ProcedureClient, ProcedureClientOptions, ProcedureConfig, ProcedureHandler, ProcedureImplementer, Router, SharedRouterImplementer, augmentImplementedRouter, augmentRouter, call, createContractProcedure, createGuardedProcedureLazy, createRouterClient, createRouterImplementer, decorateMiddleware, getHiddenRouterContract, getRouter, implement, os, unlazyRouter, walkProcedureContractsAsync, walkProcedureContractsSync, withHiddenRouterContract };
|
|
196
199
|
export type { AugmentImplementedRouterOptions, AugmentRouterOptions, AugmentedRouter, AugmentedRouterWithMiddlewares, BuilderDefinition, BuilderWithInput, BuilderWithInputOutput, BuilderWithMiddlewares, BuilderWithOutput, CallOptions, CallRest, DecoratedMiddleware, DefaultInitialContext, Implementer, RouterClient, RouterImplementer, RouterImplementerWithMiddlewares, SharedRouterImplementerWithMiddlewares, UnlaziedRouter, WalkProcedureContractsLazyResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import { AnyORPCError, ClientOptions, ClientContext } from '@orpc/client';
|
|
2
|
-
export { AnyORPCError, AnyORPCErrorJSON, COMMON_ERROR_STATUS_MAP, ORPCError, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, RPCJsonSerialization, RPCJsonSerializationMeta, RPCJsonSerializer, RPCJsonSerializerHandler, RPCJsonSerializerOptions, RPCSerializer, RPCSerializerOptions, RPCSerializerSerializeOptions, cloneORPCError, isDefinedError, isInferableError, safe, toORPCError } from '@orpc/client';
|
|
2
|
+
export { AnyORPCError, AnyORPCErrorJSON, COMMON_ERROR_STATUS_MAP, Client, ClientContext, ClientOptions, ClientRest, FriendlyClientOptions, ORPCError, ORPCErrorCode, ORPCErrorJSON, ORPCErrorOptions, RPCJsonSerialization, RPCJsonSerializationMeta, RPCJsonSerializer, RPCJsonSerializerHandler, RPCJsonSerializerOptions, RPCSerializer, RPCSerializerOptions, RPCSerializerSerializeOptions, SafeResult, cloneORPCError, isDefinedError, isInferableError, safe, toORPCError } from '@orpc/client';
|
|
3
3
|
import { ErrorMap, MergedErrorMap, AnySchema, MetaPlugin, InferSchemaOutput, InferSchemaInput, AugmentContractRouterOptions, RouterContract, AnyProcedureContract, InitialInputSchema, InitialOutputSchema, MergedSchema, Schema, ProcedureContractDefinition, ProcedureContract, InferRouterContractErrorMap, ORPCErrorFromErrorMap } from '@orpc/contract';
|
|
4
|
-
export { AnyMetaPlugin, AnySchema, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, MergedErrorMap, Meta, MetaPlugin, MetaPluginDefinition, ORPCErrorFromErrorMap, ProcedureContract, ProcedureContractDefinition, RouterContract, Schema, ValidationError, defineMeta, eventIterator, reconcileORPCError, type } from '@orpc/contract';
|
|
4
|
+
export { AnyMetaPlugin, AnySchema, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, InitialInputSchema, InitialOutputSchema, MergedErrorMap, Meta, MetaPlugin, MetaPluginDefinition, ORPCErrorFromErrorMap, ProcedureContract, ProcedureContractDefinition, RouterContract, Schema, ValidationError, asyncIteratorObject, defineMeta, eventIterator, reconcileORPCError, type } from '@orpc/contract';
|
|
5
5
|
import { IntersectPick, Promisable, Public, PromiseWithError, ThrowableError, MaybeOptionalOptions } from '@orpc/shared';
|
|
6
|
-
export { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, Registry, ThrowableError, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onError, onFinish, onStart, onSuccess,
|
|
7
|
-
import { C as Context, d as Middleware, M as MergedContext, e as MergedInitialContext, a as Procedure, f as
|
|
8
|
-
export {
|
|
9
|
-
import { A as AnyRouter, R as Router, C as ContractedRouter, I as InferRouterInitialContext } from './shared/server.
|
|
10
|
-
export { a as InferRouterError, b as InferRouterErrors, c as InferRouterFinalContexts, d as InferRouterInitialContexts, e as InferRouterInputs, f as InferRouterOutputs } from './shared/server.
|
|
11
|
-
export { ErrorEvent, getEventMeta, unwrapEvent, withEventMeta } from '@standardserver/core';
|
|
6
|
+
export { AsyncCleanupFn, AsyncIteratorClass, AsyncIteratorClassNextFn, MaybeOptionalOptions, PromiseWithError, Registry, ThrowableError, asyncIteratorToStream, asyncIteratorToUnproxiedDataStream, asyncIteratorToStream as eventIteratorToStream, asyncIteratorToUnproxiedDataStream as eventIteratorToUnproxiedDataStream, onAsyncIteratorObjectError, onError, onFinish, onReadableStreamError, onStart, onSuccess, streamToAsyncIteratorObject, streamToAsyncIteratorObject as streamToEventIterator } from '@orpc/shared';
|
|
7
|
+
import { C as Context, d as Middleware, M as MergedContext, e as MergedInitialContext, a as Procedure, f as ProcedureConfig, g as AnyMiddleware, h as Lazy, A as AnyProcedure, L as Lazyable, i as ProcedureHandler, O as ORPCErrorConstructorMap, j as OrderedMiddleware, P as ProcedureClientOptions, b as ProcedureClient } from './shared/server.CcR4kgje.js';
|
|
8
|
+
export { k as LazyDefinition, l as MiddlewareDefinition, m as MiddlewareDone, n as MiddlewareDoneOptions, o as MiddlewareNext, p as MiddlewareNextOptions, q as MiddlewareOptions, r as MiddlewareResult, s as ORPCErrorConstructorMapItem, t as ORPCErrorConstructorMapItemOptions, c as ProcedureClientInterceptor, u as ProcedureClientInterceptorOptions, v as ProcedureDefinition, w as ProcedureHandlerOptions, x as createORPCErrorConstructorMap, y as createProcedureClient, z as unlazy } from './shared/server.CcR4kgje.js';
|
|
9
|
+
import { A as AnyRouter, R as Router, C as ContractedRouter, I as InferRouterInitialContext } from './shared/server.m3szVJGU.js';
|
|
10
|
+
export { a as InferRouterError, b as InferRouterErrors, c as InferRouterFinalContexts, d as InferRouterInitialContexts, e as InferRouterInputs, f as InferRouterOutputs } from './shared/server.m3szVJGU.js';
|
|
11
|
+
export { ErrorEvent, EventMeta, getEventMeta, unwrapEvent, withEventMeta } from '@standardserver/core';
|
|
12
12
|
|
|
13
13
|
interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorMap extends ErrorMap> extends Middleware<TInContext, TOutContext, TInput, TOutput, TErrorMap> {
|
|
14
14
|
adaptInput<T>(adapt: (input: T) => TInput): DecoratedMiddleware<TInContext, TOutContext, T, TOutput, TErrorMap>;
|
|
@@ -29,11 +29,11 @@ type AugmentedRouter<T extends AnyRouter, TErrorMap extends ErrorMap> = T extend
|
|
|
29
29
|
type AugmentedRouterWithMiddlewares<T extends AnyRouter, TInitialContext extends Context, TInjectedContext extends Context, TErrorMap extends ErrorMap> = T extends Procedure<infer $InitialContext, infer $CurrentContext, infer $InputSchema, infer $OutputSchema, infer $ErrorMap, infer $ReturnedORPCError> ? Procedure<MergedInitialContext<TInitialContext, TInjectedContext, $InitialContext>, $CurrentContext, $InputSchema, $OutputSchema, MergedErrorMap<TErrorMap, $ErrorMap>, $ReturnedORPCError> : {
|
|
30
30
|
[K in keyof T]: T[K] extends Lazy<infer $ extends AnyRouter> ? Lazy<AugmentedRouterWithMiddlewares<$, TInitialContext, TInjectedContext, TErrorMap>> : T[K] extends AnyRouter ? AugmentedRouterWithMiddlewares<T[K], TInitialContext, TInjectedContext, TErrorMap> : never;
|
|
31
31
|
};
|
|
32
|
-
interface AugmentRouterOptions<TErrorMap extends ErrorMap> extends AugmentContractRouterOptions<TErrorMap
|
|
32
|
+
interface AugmentRouterOptions<TErrorMap extends ErrorMap> extends AugmentContractRouterOptions<TErrorMap>, ProcedureConfig {
|
|
33
33
|
middlewares: AnyMiddleware[];
|
|
34
34
|
}
|
|
35
35
|
declare function augmentRouter<T extends AnyRouter, TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap>(router: T, options: AugmentRouterOptions<TErrorMap>): AugmentedRouter<T, TErrorMap> | AugmentedRouterWithMiddlewares<T, TInitialContext, TCurrentContext, TErrorMap>;
|
|
36
|
-
interface AugmentImplementedRouterOptions {
|
|
36
|
+
interface AugmentImplementedRouterOptions extends ProcedureConfig {
|
|
37
37
|
middlewares: AnyMiddleware[];
|
|
38
38
|
}
|
|
39
39
|
declare function augmentImplementedRouter<T extends AnyRouter, TInitialContext extends Context, TCurrentContext extends Context>(router: T, options: AugmentImplementedRouterOptions): AugmentedRouter<T, object> | AugmentedRouterWithMiddlewares<T, TInitialContext, TCurrentContext, object>;
|
|
@@ -93,7 +93,7 @@ interface BuilderWithInputOutput<TInitialContext extends Context, TInjectedConte
|
|
|
93
93
|
|
|
94
94
|
interface DefaultInitialContext {
|
|
95
95
|
}
|
|
96
|
-
interface BuilderDefinition<TInputSchema extends AnySchema, TInjectedContext extends AnySchema, TErrorMap extends ErrorMap> extends ProcedureContractDefinition<TInputSchema, TInjectedContext, TErrorMap
|
|
96
|
+
interface BuilderDefinition<TInputSchema extends AnySchema, TInjectedContext extends AnySchema, TErrorMap extends ErrorMap> extends ProcedureContractDefinition<TInputSchema, TInjectedContext, TErrorMap>, ProcedureConfig {
|
|
97
97
|
orderedMiddlewares: OrderedMiddleware[];
|
|
98
98
|
}
|
|
99
99
|
declare class Builder<TInitialContext extends Context, TErrorMap extends ErrorMap> {
|
|
@@ -101,6 +101,7 @@ declare class Builder<TInitialContext extends Context, TErrorMap extends ErrorMa
|
|
|
101
101
|
private constructor();
|
|
102
102
|
static create<T extends Context = DefaultInitialContext>(): Builder<T & object, Record<never, never>>;
|
|
103
103
|
$context<T extends Context = DefaultInitialContext>(): Builder<T & object, TErrorMap>;
|
|
104
|
+
$config(config: ProcedureConfig): Builder<TInitialContext, TErrorMap>;
|
|
104
105
|
meta(...plugins: MetaPlugin<InitialInputSchema, InitialOutputSchema, TErrorMap>[]): Builder<TInitialContext, TErrorMap>;
|
|
105
106
|
errors<U extends ErrorMap>(errors: U): Builder<TInitialContext, MergedErrorMap<TErrorMap, U>>;
|
|
106
107
|
use<$OutContext extends IntersectPick<TInitialContext, $OutContext>, $InContext extends Context = TInitialContext, $ErrorMap extends ErrorMap = TErrorMap>(middleware: Middleware<$InContext | TInitialContext, $OutContext, InferSchemaOutput<InitialInputSchema>, InferSchemaInput<InitialOutputSchema>, $ErrorMap>): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, object, $InContext>, $OutContext, MergedErrorMap<$ErrorMap, TErrorMap>>;
|
|
@@ -130,10 +131,11 @@ declare class ImplementedProcedure<TInitialContext extends Context, TInjectedCon
|
|
|
130
131
|
|
|
131
132
|
declare class SharedRouterImplementer<TContract extends RouterContract, TInitialContext extends Context> {
|
|
132
133
|
private readonly contract;
|
|
134
|
+
private readonly config;
|
|
133
135
|
private readonly middlewares;
|
|
134
136
|
private constructor();
|
|
135
|
-
static create<TContract extends RouterContract, TInitialContext extends Context>(contract: TContract): SharedRouterImplementer<TContract, TInitialContext>;
|
|
136
|
-
static create<TContract extends RouterContract, TInitialContext extends Context, TInjectedContext extends Context>(contract: TContract, middlewares: AnyMiddleware[]): SharedRouterImplementerWithMiddlewares<TContract, TInitialContext, TInjectedContext>;
|
|
137
|
+
static create<TContract extends RouterContract, TInitialContext extends Context>(contract: TContract, config: ProcedureConfig): SharedRouterImplementer<TContract, TInitialContext>;
|
|
138
|
+
static create<TContract extends RouterContract, TInitialContext extends Context, TInjectedContext extends Context>(contract: TContract, config: ProcedureConfig, middlewares: AnyMiddleware[]): SharedRouterImplementerWithMiddlewares<TContract, TInitialContext, TInjectedContext>;
|
|
137
139
|
use<$OutContext extends IntersectPick<TInitialContext, $OutContext>, $InContext extends Context = TInitialContext, $ErrorMap extends ErrorMap = InferRouterContractErrorMap<TContract>>(middleware: Middleware<$InContext | TInitialContext, $OutContext, unknown, unknown, $ErrorMap>): RouterImplementerWithMiddlewares<TContract, MergedInitialContext<TInitialContext, object, $InContext>, $OutContext>;
|
|
138
140
|
middleware<$OutContext extends IntersectPick<TInitialContext, $OutContext>, $Input, $InContext extends Context = TInitialContext, $Output = any>(middleware: Middleware<$InContext | TInitialContext, $OutContext, $Input, $Output, InferRouterContractErrorMap<TContract>>): DecoratedMiddleware<MergedInitialContext<TInitialContext, object, $InContext>, $OutContext, $Input, $Output, object>;
|
|
139
141
|
router<T extends ContractedRouter<TContract, any>>(router: T): T;
|
|
@@ -155,12 +157,13 @@ type RouterImplementer<TContract extends RouterContract, TInitialContext extends
|
|
|
155
157
|
type RouterImplementerWithMiddlewares<TContract extends RouterContract, TInitialContext extends Context, TInjectedContext extends Context> = TContract extends ProcedureContract<infer $InputSchema, infer $OutputSchema, infer $ErrorMap> ? ProcedureImplementer<TInitialContext, TInjectedContext, $InputSchema, $OutputSchema, $ErrorMap> : SharedRouterImplementerWithMiddlewares<TContract, TInitialContext, TInjectedContext> & {
|
|
156
158
|
[K in keyof TContract]: TContract[K] extends RouterContract ? RouterImplementerWithMiddlewares<TContract[K], TInitialContext, TInjectedContext> : never;
|
|
157
159
|
};
|
|
158
|
-
declare function createRouterImplementer<TContract extends RouterContract, TInitialContext extends Context>(contract: TContract): RouterImplementer<TContract, TInitialContext>;
|
|
160
|
+
declare function createRouterImplementer<TContract extends RouterContract, TInitialContext extends Context>(contract: TContract, config: ProcedureConfig): RouterImplementer<TContract, TInitialContext>;
|
|
159
161
|
|
|
160
162
|
type Implementer<TContract extends RouterContract, TInitialContext extends Context> = {
|
|
161
163
|
$context<T extends Context = DefaultInitialContext>(): Implementer<TContract, T & object>;
|
|
164
|
+
$config(config: ProcedureConfig): Implementer<TContract, TInitialContext>;
|
|
162
165
|
} & RouterImplementer<TContract, TInitialContext>;
|
|
163
|
-
declare function implement<TContract extends RouterContract, TInitialContext extends Context = DefaultInitialContext>(contract: TContract): Implementer<TContract, TInitialContext & object>;
|
|
166
|
+
declare function implement<TContract extends RouterContract, TInitialContext extends Context = DefaultInitialContext>(contract: TContract, config?: ProcedureConfig): Implementer<TContract, TInitialContext & object>;
|
|
164
167
|
|
|
165
168
|
declare function createGuardedProcedureLazy(lazy: Lazy<unknown>): Lazy<AnyProcedure>;
|
|
166
169
|
/**
|
|
@@ -192,5 +195,5 @@ declare function createRouterClient<T extends AnyRouter, TClientContext extends
|
|
|
192
195
|
declare function withHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: RouterContract): T;
|
|
193
196
|
declare function getHiddenRouterContract(router: Lazyable<AnyRouter | RouterContract>): RouterContract | undefined;
|
|
194
197
|
|
|
195
|
-
export { AnyMiddleware, AnyProcedure, AnyRouter, Builder, Context, ContractedRouter, DEFAULT_ERROR_STATUS, DEFAULT_SUCCESS_STATUS, DecoratedProcedure, ImplementedProcedure, InferRouterInitialContext, Lazy, Lazyable, MergedContext, MergedInitialContext, Middleware, ORPCErrorConstructorMap, OrderedMiddleware, Procedure, ProcedureClient, ProcedureClientOptions, ProcedureHandler, ProcedureImplementer, Router, SharedRouterImplementer, augmentImplementedRouter, augmentRouter, call, createContractProcedure, createGuardedProcedureLazy, createRouterClient, createRouterImplementer, decorateMiddleware, getHiddenRouterContract, getRouter, implement, os, unlazyRouter, walkProcedureContractsAsync, walkProcedureContractsSync, withHiddenRouterContract };
|
|
198
|
+
export { AnyMiddleware, AnyProcedure, AnyRouter, Builder, Context, ContractedRouter, DEFAULT_ERROR_STATUS, DEFAULT_SUCCESS_STATUS, DecoratedProcedure, ImplementedProcedure, InferRouterInitialContext, Lazy, Lazyable, MergedContext, MergedInitialContext, Middleware, ORPCErrorConstructorMap, OrderedMiddleware, Procedure, ProcedureClient, ProcedureClientOptions, ProcedureConfig, ProcedureHandler, ProcedureImplementer, Router, SharedRouterImplementer, augmentImplementedRouter, augmentRouter, call, createContractProcedure, createGuardedProcedureLazy, createRouterClient, createRouterImplementer, decorateMiddleware, getHiddenRouterContract, getRouter, implement, os, unlazyRouter, walkProcedureContractsAsync, walkProcedureContractsSync, withHiddenRouterContract };
|
|
196
199
|
export type { AugmentImplementedRouterOptions, AugmentRouterOptions, AugmentedRouter, AugmentedRouterWithMiddlewares, BuilderDefinition, BuilderWithInput, BuilderWithInputOutput, BuilderWithMiddlewares, BuilderWithOutput, CallOptions, CallRest, DecoratedMiddleware, DefaultInitialContext, Implementer, RouterClient, RouterImplementer, RouterImplementerWithMiddlewares, SharedRouterImplementerWithMiddlewares, UnlaziedRouter, WalkProcedureContractsLazyResult };
|