@orpc/server 0.0.0-next.b45a533 → 0.0.0-next.b4fc1d9
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 +2 -0
- package/dist/adapters/fetch/index.d.mts +5 -3
- package/dist/adapters/fetch/index.d.ts +5 -3
- package/dist/adapters/fetch/index.mjs +4 -4
- package/dist/adapters/hono/index.d.mts +4 -2
- package/dist/adapters/hono/index.d.ts +4 -2
- package/dist/adapters/hono/index.mjs +4 -4
- package/dist/adapters/next/index.d.mts +4 -2
- package/dist/adapters/next/index.d.ts +4 -2
- package/dist/adapters/next/index.mjs +4 -4
- package/dist/adapters/node/index.d.mts +5 -3
- package/dist/adapters/node/index.d.ts +5 -3
- package/dist/adapters/node/index.mjs +8 -7
- package/dist/adapters/standard/index.d.mts +9 -8
- package/dist/adapters/standard/index.d.ts +9 -8
- package/dist/adapters/standard/index.mjs +3 -3
- package/dist/index.d.mts +29 -30
- package/dist/index.d.ts +29 -30
- package/dist/index.mjs +3 -7
- package/dist/plugins/index.d.mts +3 -3
- package/dist/plugins/index.d.ts +3 -3
- package/dist/plugins/index.mjs +1 -1
- package/dist/shared/{server.3mOimouH.mjs → server.BY9sDlwl.mjs} +6 -6
- package/dist/shared/server.BqBN5WhH.d.mts +8 -0
- package/dist/shared/{server.B_5ZADvP.mjs → server.BtxZnWJ9.mjs} +16 -5
- package/dist/shared/{server.hqPWnakL.d.ts → server.CPqNKiJp.d.ts} +3 -3
- package/dist/shared/{server.Q6ZmnTgO.mjs → server.Dba3Iiyp.mjs} +2 -2
- package/dist/shared/{server.BgDZnmUZ.mjs → server.Del5OmaY.mjs} +6 -5
- package/dist/shared/server.Dm3ZuTuI.d.ts +8 -0
- package/dist/shared/{server.DnmJuN02.d.mts → server.MZvbGc3n.d.mts} +1 -2
- package/dist/shared/{server.DnmJuN02.d.ts → server.MZvbGc3n.d.ts} +1 -2
- package/dist/shared/{server.CL84X8p4.d.mts → server.P4_D9lKb.d.mts} +3 -3
- package/package.json +7 -7
package/README.md
CHANGED
@@ -60,6 +60,8 @@ You can find the full documentation [here](https://orpc.unnoq.com).
|
|
60
60
|
- [@orpc/vue-colada](https://www.npmjs.com/package/@orpc/vue-colada): Integration with [Pinia Colada](https://pinia-colada.esm.dev/).
|
61
61
|
- [@orpc/openapi](https://www.npmjs.com/package/@orpc/openapi): Generate OpenAPI specs and handle OpenAPI requests.
|
62
62
|
- [@orpc/zod](https://www.npmjs.com/package/@orpc/zod): More schemas that [Zod](https://zod.dev/) doesn't support yet.
|
63
|
+
- [@orpc/valibot](https://www.npmjs.com/package/@orpc/valibot): OpenAPI spec generation from [Valibot](https://valibot.dev/).
|
64
|
+
- [@orpc/arktype](https://www.npmjs.com/package/@orpc/arktype): OpenAPI spec generation from [ArkType](https://arktype.io/).
|
63
65
|
|
64
66
|
## `@orpc/server`
|
65
67
|
|
@@ -1,10 +1,12 @@
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
2
2
|
import { ToFetchResponseOptions } from '@orpc/standard-server-fetch';
|
3
|
-
import { C as Context, R as Router } from '../../shared/server.
|
4
|
-
import { S as StandardHandleOptions
|
3
|
+
import { C as Context, R as Router } from '../../shared/server.MZvbGc3n.mjs';
|
4
|
+
import { S as StandardHandleOptions } from '../../shared/server.P4_D9lKb.mjs';
|
5
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.BqBN5WhH.mjs';
|
5
6
|
import '@orpc/client';
|
6
7
|
import '@orpc/contract';
|
7
8
|
import '@orpc/standard-server';
|
9
|
+
import '@orpc/client/standard';
|
8
10
|
|
9
11
|
type FetchHandleResult = {
|
10
12
|
matched: true;
|
@@ -19,7 +21,7 @@ interface FetchHandler<T extends Context> {
|
|
19
21
|
|
20
22
|
declare class RPCHandler<T extends Context> implements FetchHandler<T> {
|
21
23
|
private readonly standardHandler;
|
22
|
-
constructor(router: Router<any, T>, options?: NoInfer<
|
24
|
+
constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T>>);
|
23
25
|
handle(request: Request, ...[options,]: MaybeOptionalOptions<StandardHandleOptions<T> & ToFetchResponseOptions>): Promise<FetchHandleResult>;
|
24
26
|
}
|
25
27
|
|
@@ -1,10 +1,12 @@
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
2
2
|
import { ToFetchResponseOptions } from '@orpc/standard-server-fetch';
|
3
|
-
import { C as Context, R as Router } from '../../shared/server.
|
4
|
-
import { S as StandardHandleOptions
|
3
|
+
import { C as Context, R as Router } from '../../shared/server.MZvbGc3n.js';
|
4
|
+
import { S as StandardHandleOptions } from '../../shared/server.CPqNKiJp.js';
|
5
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.Dm3ZuTuI.js';
|
5
6
|
import '@orpc/client';
|
6
7
|
import '@orpc/contract';
|
7
8
|
import '@orpc/standard-server';
|
9
|
+
import '@orpc/client/standard';
|
8
10
|
|
9
11
|
type FetchHandleResult = {
|
10
12
|
matched: true;
|
@@ -19,7 +21,7 @@ interface FetchHandler<T extends Context> {
|
|
19
21
|
|
20
22
|
declare class RPCHandler<T extends Context> implements FetchHandler<T> {
|
21
23
|
private readonly standardHandler;
|
22
|
-
constructor(router: Router<any, T>, options?: NoInfer<
|
24
|
+
constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T>>);
|
23
25
|
handle(request: Request, ...[options,]: MaybeOptionalOptions<StandardHandleOptions<T> & ToFetchResponseOptions>): Promise<FetchHandleResult>;
|
24
26
|
}
|
25
27
|
|
@@ -1,9 +1,9 @@
|
|
1
|
-
export { R as RPCHandler } from '../../shared/server.
|
1
|
+
export { R as RPCHandler } from '../../shared/server.Del5OmaY.mjs';
|
2
2
|
import '@orpc/client/standard';
|
3
3
|
import '@orpc/standard-server-fetch';
|
4
|
-
import '../../shared/server.
|
4
|
+
import '../../shared/server.BY9sDlwl.mjs';
|
5
5
|
import '@orpc/client';
|
6
6
|
import '@orpc/shared';
|
7
|
-
import '../../shared/server.
|
8
|
-
import '../../shared/server.
|
7
|
+
import '../../shared/server.Dba3Iiyp.mjs';
|
8
|
+
import '../../shared/server.BtxZnWJ9.mjs';
|
9
9
|
import '@orpc/contract';
|
@@ -2,9 +2,11 @@ import { FetchHandler } from '../fetch/index.mjs';
|
|
2
2
|
export { FetchHandleResult, RPCHandler } from '../fetch/index.mjs';
|
3
3
|
import { Value, MaybeOptionalOptions } from '@orpc/shared';
|
4
4
|
import { Context as Context$1, MiddlewareHandler } from 'hono';
|
5
|
-
import { C as Context } from '../../shared/server.
|
6
|
-
import { S as StandardHandleOptions } from '../../shared/server.
|
5
|
+
import { C as Context } from '../../shared/server.MZvbGc3n.mjs';
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.P4_D9lKb.mjs';
|
7
7
|
import '@orpc/standard-server-fetch';
|
8
|
+
import '../../shared/server.BqBN5WhH.mjs';
|
9
|
+
import '@orpc/client/standard';
|
8
10
|
import '@orpc/client';
|
9
11
|
import '@orpc/contract';
|
10
12
|
import '@orpc/standard-server';
|
@@ -2,9 +2,11 @@ import { FetchHandler } from '../fetch/index.js';
|
|
2
2
|
export { FetchHandleResult, RPCHandler } from '../fetch/index.js';
|
3
3
|
import { Value, MaybeOptionalOptions } from '@orpc/shared';
|
4
4
|
import { Context as Context$1, MiddlewareHandler } from 'hono';
|
5
|
-
import { C as Context } from '../../shared/server.
|
6
|
-
import { S as StandardHandleOptions } from '../../shared/server.
|
5
|
+
import { C as Context } from '../../shared/server.MZvbGc3n.js';
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.CPqNKiJp.js';
|
7
7
|
import '@orpc/standard-server-fetch';
|
8
|
+
import '../../shared/server.Dm3ZuTuI.js';
|
9
|
+
import '@orpc/client/standard';
|
8
10
|
import '@orpc/client';
|
9
11
|
import '@orpc/contract';
|
10
12
|
import '@orpc/standard-server';
|
@@ -1,11 +1,11 @@
|
|
1
|
-
export { R as RPCHandler } from '../../shared/server.
|
1
|
+
export { R as RPCHandler } from '../../shared/server.Del5OmaY.mjs';
|
2
2
|
import { value } from '@orpc/shared';
|
3
3
|
import '@orpc/client/standard';
|
4
4
|
import '@orpc/standard-server-fetch';
|
5
|
-
import '../../shared/server.
|
5
|
+
import '../../shared/server.BY9sDlwl.mjs';
|
6
6
|
import '@orpc/client';
|
7
|
-
import '../../shared/server.
|
8
|
-
import '../../shared/server.
|
7
|
+
import '../../shared/server.Dba3Iiyp.mjs';
|
8
|
+
import '../../shared/server.BtxZnWJ9.mjs';
|
9
9
|
import '@orpc/contract';
|
10
10
|
|
11
11
|
function createMiddleware(handler, ...[options]) {
|
@@ -2,9 +2,11 @@ import { FetchHandler } from '../fetch/index.mjs';
|
|
2
2
|
export { FetchHandleResult, RPCHandler } from '../fetch/index.mjs';
|
3
3
|
import { Value, MaybeOptionalOptions } from '@orpc/shared';
|
4
4
|
import { NextRequest } from 'next/server';
|
5
|
-
import { C as Context } from '../../shared/server.
|
6
|
-
import { S as StandardHandleOptions } from '../../shared/server.
|
5
|
+
import { C as Context } from '../../shared/server.MZvbGc3n.mjs';
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.P4_D9lKb.mjs';
|
7
7
|
import '@orpc/standard-server-fetch';
|
8
|
+
import '../../shared/server.BqBN5WhH.mjs';
|
9
|
+
import '@orpc/client/standard';
|
8
10
|
import '@orpc/client';
|
9
11
|
import '@orpc/contract';
|
10
12
|
import '@orpc/standard-server';
|
@@ -2,9 +2,11 @@ import { FetchHandler } from '../fetch/index.js';
|
|
2
2
|
export { FetchHandleResult, RPCHandler } from '../fetch/index.js';
|
3
3
|
import { Value, MaybeOptionalOptions } from '@orpc/shared';
|
4
4
|
import { NextRequest } from 'next/server';
|
5
|
-
import { C as Context } from '../../shared/server.
|
6
|
-
import { S as StandardHandleOptions } from '../../shared/server.
|
5
|
+
import { C as Context } from '../../shared/server.MZvbGc3n.js';
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.CPqNKiJp.js';
|
7
7
|
import '@orpc/standard-server-fetch';
|
8
|
+
import '../../shared/server.Dm3ZuTuI.js';
|
9
|
+
import '@orpc/client/standard';
|
8
10
|
import '@orpc/client';
|
9
11
|
import '@orpc/contract';
|
10
12
|
import '@orpc/standard-server';
|
@@ -1,11 +1,11 @@
|
|
1
|
-
export { R as RPCHandler } from '../../shared/server.
|
1
|
+
export { R as RPCHandler } from '../../shared/server.Del5OmaY.mjs';
|
2
2
|
import { value } from '@orpc/shared';
|
3
3
|
import '@orpc/client/standard';
|
4
4
|
import '@orpc/standard-server-fetch';
|
5
|
-
import '../../shared/server.
|
5
|
+
import '../../shared/server.BY9sDlwl.mjs';
|
6
6
|
import '@orpc/client';
|
7
|
-
import '../../shared/server.
|
8
|
-
import '../../shared/server.
|
7
|
+
import '../../shared/server.Dba3Iiyp.mjs';
|
8
|
+
import '../../shared/server.BtxZnWJ9.mjs';
|
9
9
|
import '@orpc/contract';
|
10
10
|
|
11
11
|
function serve(handler, ...[options]) {
|
@@ -1,12 +1,14 @@
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
2
2
|
import { SendStandardResponseOptions } from '@orpc/standard-server-node';
|
3
|
-
import { C as Context, R as Router } from '../../shared/server.
|
4
|
-
import { S as StandardHandleOptions
|
3
|
+
import { C as Context, R as Router } from '../../shared/server.MZvbGc3n.mjs';
|
4
|
+
import { S as StandardHandleOptions } from '../../shared/server.P4_D9lKb.mjs';
|
5
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.BqBN5WhH.mjs';
|
5
6
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
6
7
|
import { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
|
7
8
|
import '@orpc/client';
|
8
9
|
import '@orpc/contract';
|
9
10
|
import '@orpc/standard-server';
|
11
|
+
import '@orpc/client/standard';
|
10
12
|
|
11
13
|
type NodeHttpRequest = (IncomingMessage | Http2ServerRequest) & {
|
12
14
|
/**
|
@@ -27,7 +29,7 @@ interface NodeHttpHandler<T extends Context> {
|
|
27
29
|
|
28
30
|
declare class RPCHandler<T extends Context> implements NodeHttpHandler<T> {
|
29
31
|
private readonly standardHandler;
|
30
|
-
constructor(router: Router<any, T>, options?: NoInfer<
|
32
|
+
constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T>>);
|
31
33
|
handle(req: NodeHttpRequest, res: NodeHttpResponse, ...[options,]: MaybeOptionalOptions<StandardHandleOptions<T> & SendStandardResponseOptions>): Promise<NodeHttpHandleResult>;
|
32
34
|
}
|
33
35
|
|
@@ -1,12 +1,14 @@
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
2
2
|
import { SendStandardResponseOptions } from '@orpc/standard-server-node';
|
3
|
-
import { C as Context, R as Router } from '../../shared/server.
|
4
|
-
import { S as StandardHandleOptions
|
3
|
+
import { C as Context, R as Router } from '../../shared/server.MZvbGc3n.js';
|
4
|
+
import { S as StandardHandleOptions } from '../../shared/server.CPqNKiJp.js';
|
5
|
+
import { S as StandardRPCHandlerOptions } from '../../shared/server.Dm3ZuTuI.js';
|
5
6
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
6
7
|
import { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
|
7
8
|
import '@orpc/client';
|
8
9
|
import '@orpc/contract';
|
9
10
|
import '@orpc/standard-server';
|
11
|
+
import '@orpc/client/standard';
|
10
12
|
|
11
13
|
type NodeHttpRequest = (IncomingMessage | Http2ServerRequest) & {
|
12
14
|
/**
|
@@ -27,7 +29,7 @@ interface NodeHttpHandler<T extends Context> {
|
|
27
29
|
|
28
30
|
declare class RPCHandler<T extends Context> implements NodeHttpHandler<T> {
|
29
31
|
private readonly standardHandler;
|
30
|
-
constructor(router: Router<any, T>, options?: NoInfer<
|
32
|
+
constructor(router: Router<any, T>, options?: NoInfer<StandardRPCHandlerOptions<T>>);
|
31
33
|
handle(req: NodeHttpRequest, res: NodeHttpResponse, ...[options,]: MaybeOptionalOptions<StandardHandleOptions<T> & SendStandardResponseOptions>): Promise<NodeHttpHandleResult>;
|
32
34
|
}
|
33
35
|
|
@@ -1,18 +1,19 @@
|
|
1
|
-
import {
|
1
|
+
import { StandardRPCJsonSerializer, StandardRPCSerializer } from '@orpc/client/standard';
|
2
2
|
import { toStandardLazyRequest, sendStandardResponse } from '@orpc/standard-server-node';
|
3
|
-
import { S as StandardHandler,
|
3
|
+
import { S as StandardHandler, b as StandardRPCMatcher, a as StandardRPCCodec } from '../../shared/server.BY9sDlwl.mjs';
|
4
4
|
import '@orpc/client';
|
5
5
|
import '@orpc/shared';
|
6
|
-
import '../../shared/server.
|
7
|
-
import '../../shared/server.
|
6
|
+
import '../../shared/server.Dba3Iiyp.mjs';
|
7
|
+
import '../../shared/server.BtxZnWJ9.mjs';
|
8
8
|
import '@orpc/contract';
|
9
9
|
|
10
10
|
class RPCHandler {
|
11
11
|
standardHandler;
|
12
12
|
constructor(router, options = {}) {
|
13
|
-
const
|
14
|
-
const
|
15
|
-
const
|
13
|
+
const jsonSerializer = new StandardRPCJsonSerializer(options);
|
14
|
+
const serializer = new StandardRPCSerializer(jsonSerializer);
|
15
|
+
const matcher = new StandardRPCMatcher();
|
16
|
+
const codec = new StandardRPCCodec(serializer);
|
16
17
|
this.standardHandler = new StandardHandler(router, matcher, codec, options);
|
17
18
|
}
|
18
19
|
async handle(req, res, ...[
|
@@ -1,25 +1,26 @@
|
|
1
|
-
import { c as StandardCodec, d as StandardParams, e as StandardMatcher, f as StandardMatchResult } from '../../shared/server.
|
2
|
-
export { S as StandardHandleOptions, g as StandardHandleResult, h as StandardHandler,
|
1
|
+
import { c as StandardCodec, d as StandardParams, e as StandardMatcher, f as StandardMatchResult } from '../../shared/server.P4_D9lKb.mjs';
|
2
|
+
export { S as StandardHandleOptions, g as StandardHandleResult, h as StandardHandler, b as StandardHandlerInterceptorOptions, a as StandardHandlerOptions } from '../../shared/server.P4_D9lKb.mjs';
|
3
3
|
import { ORPCError } from '@orpc/client';
|
4
|
-
import {
|
4
|
+
import { StandardRPCSerializer } from '@orpc/client/standard';
|
5
5
|
import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
|
6
|
-
import { A as AnyProcedure, a as AnyRouter } from '../../shared/server.
|
6
|
+
import { A as AnyProcedure, a as AnyRouter } from '../../shared/server.MZvbGc3n.mjs';
|
7
|
+
export { S as StandardRPCHandlerOptions } from '../../shared/server.BqBN5WhH.mjs';
|
7
8
|
import { HTTPPath } from '@orpc/contract';
|
8
9
|
import '@orpc/shared';
|
9
10
|
|
10
|
-
declare class
|
11
|
+
declare class StandardRPCCodec implements StandardCodec {
|
11
12
|
private readonly serializer;
|
12
|
-
constructor(serializer:
|
13
|
+
constructor(serializer: StandardRPCSerializer);
|
13
14
|
decode(request: StandardLazyRequest, _params: StandardParams | undefined, _procedure: AnyProcedure): Promise<unknown>;
|
14
15
|
encode(output: unknown, _procedure: AnyProcedure): StandardResponse;
|
15
16
|
encodeError(error: ORPCError<any, any>): StandardResponse;
|
16
17
|
}
|
17
18
|
|
18
|
-
declare class
|
19
|
+
declare class StandardRPCMatcher implements StandardMatcher {
|
19
20
|
private readonly tree;
|
20
21
|
private pendingRouters;
|
21
22
|
init(router: AnyRouter, path?: readonly string[]): void;
|
22
23
|
match(_method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
23
24
|
}
|
24
25
|
|
25
|
-
export {
|
26
|
+
export { StandardCodec, StandardMatchResult, StandardMatcher, StandardParams, StandardRPCCodec, StandardRPCMatcher };
|
@@ -1,25 +1,26 @@
|
|
1
|
-
import { c as StandardCodec, d as StandardParams, e as StandardMatcher, f as StandardMatchResult } from '../../shared/server.
|
2
|
-
export { S as StandardHandleOptions, g as StandardHandleResult, h as StandardHandler,
|
1
|
+
import { c as StandardCodec, d as StandardParams, e as StandardMatcher, f as StandardMatchResult } from '../../shared/server.CPqNKiJp.js';
|
2
|
+
export { S as StandardHandleOptions, g as StandardHandleResult, h as StandardHandler, b as StandardHandlerInterceptorOptions, a as StandardHandlerOptions } from '../../shared/server.CPqNKiJp.js';
|
3
3
|
import { ORPCError } from '@orpc/client';
|
4
|
-
import {
|
4
|
+
import { StandardRPCSerializer } from '@orpc/client/standard';
|
5
5
|
import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
|
6
|
-
import { A as AnyProcedure, a as AnyRouter } from '../../shared/server.
|
6
|
+
import { A as AnyProcedure, a as AnyRouter } from '../../shared/server.MZvbGc3n.js';
|
7
|
+
export { S as StandardRPCHandlerOptions } from '../../shared/server.Dm3ZuTuI.js';
|
7
8
|
import { HTTPPath } from '@orpc/contract';
|
8
9
|
import '@orpc/shared';
|
9
10
|
|
10
|
-
declare class
|
11
|
+
declare class StandardRPCCodec implements StandardCodec {
|
11
12
|
private readonly serializer;
|
12
|
-
constructor(serializer:
|
13
|
+
constructor(serializer: StandardRPCSerializer);
|
13
14
|
decode(request: StandardLazyRequest, _params: StandardParams | undefined, _procedure: AnyProcedure): Promise<unknown>;
|
14
15
|
encode(output: unknown, _procedure: AnyProcedure): StandardResponse;
|
15
16
|
encodeError(error: ORPCError<any, any>): StandardResponse;
|
16
17
|
}
|
17
18
|
|
18
|
-
declare class
|
19
|
+
declare class StandardRPCMatcher implements StandardMatcher {
|
19
20
|
private readonly tree;
|
20
21
|
private pendingRouters;
|
21
22
|
init(router: AnyRouter, path?: readonly string[]): void;
|
22
23
|
match(_method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
23
24
|
}
|
24
25
|
|
25
|
-
export {
|
26
|
+
export { StandardCodec, StandardMatchResult, StandardMatcher, StandardParams, StandardRPCCodec, StandardRPCMatcher };
|
@@ -1,6 +1,6 @@
|
|
1
|
-
export {
|
1
|
+
export { S as StandardHandler, a as StandardRPCCodec, b as StandardRPCMatcher } from '../../shared/server.BY9sDlwl.mjs';
|
2
2
|
import '@orpc/client';
|
3
3
|
import '@orpc/shared';
|
4
|
-
import '../../shared/server.
|
5
|
-
import '../../shared/server.
|
4
|
+
import '../../shared/server.Dba3Iiyp.mjs';
|
5
|
+
import '../../shared/server.BtxZnWJ9.mjs';
|
6
6
|
import '@orpc/contract';
|
package/dist/index.d.mts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
import { AnySchema, ErrorMap, Meta, MergedErrorMap, Route, InferSchemaOutput, InferSchemaInput, EnhanceRouteOptions, AnyContractRouter, AnyContractProcedure, Schema, HTTPPath, ContractRouter, ContractProcedureDef, ContractProcedure, InferContractRouterErrorMap, InferContractRouterMeta, ErrorFromErrorMap } from '@orpc/contract';
|
2
2
|
export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, HTTPMethod, HTTPPath, InferSchemaInput, InferSchemaOutput, InputStructure, Meta, OutputStructure, Route, Schema, ValidationError, eventIterator, type } from '@orpc/contract';
|
3
|
-
import { C as Context, b as Procedure, M as Middleware, O as ORPCErrorConstructorMap, c as
|
4
|
-
export {
|
3
|
+
import { C as Context, b as Procedure, M as Middleware, O as ORPCErrorConstructorMap, c as MergedInitialContext, d as MergedCurrentContext, e as MapInputMiddleware, f as CreateProcedureClientOptions, g as ProcedureClient, h as AnyMiddleware, L as Lazyable, a as AnyRouter, i as Lazy, A as AnyProcedure, j as ProcedureHandler, R as Router, I as InferRouterInitialContext } from './shared/server.MZvbGc3n.mjs';
|
4
|
+
export { J as InferRouterCurrentContexts, H as InferRouterInitialContexts, K as InferRouterInputs, N as InferRouterOutputs, o as LAZY_SYMBOL, p as LazyMeta, x as MiddlewareNextFn, w as MiddlewareNextFnOptions, z as MiddlewareOptions, y as MiddlewareOutputFn, t as MiddlewareResult, l as ORPCErrorConstructorMapItem, k as ORPCErrorConstructorMapItemOptions, P as ProcedureClientInterceptorOptions, E as ProcedureDef, D as ProcedureHandlerOptions, n as createORPCErrorConstructorMap, G as createProcedureClient, s as getLazyMeta, r as isLazy, F as isProcedure, q as lazy, m as mergeCurrentContext, B as middlewareOutputFn, u as unlazy, v as validateORPCError } from './shared/server.MZvbGc3n.mjs';
|
5
5
|
import { ClientContext, ClientRest, ClientPromiseResult } from '@orpc/client';
|
6
6
|
export { ORPCError, isDefinedError, safe } from '@orpc/client';
|
7
|
-
import { MaybeOptionalOptions } from '@orpc/shared';
|
7
|
+
import { IntersectPick, MaybeOptionalOptions } from '@orpc/shared';
|
8
8
|
export { onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
9
9
|
export { getEventMeta, withEventMeta } from '@orpc/standard-server';
|
10
10
|
|
@@ -12,8 +12,8 @@ declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContex
|
|
12
12
|
errors<U extends ErrorMap>(errors: U): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
13
13
|
meta(meta: TMeta): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
14
14
|
route(route: Route): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
15
|
-
use<UOutContext extends
|
16
|
-
use<UOutContext extends
|
15
|
+
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): DecoratedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
16
|
+
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): DecoratedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
17
17
|
/**
|
18
18
|
* Make this procedure callable (works like a function while still being a procedure).
|
19
19
|
*/
|
@@ -60,7 +60,7 @@ declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedR
|
|
60
60
|
interface BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
61
61
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
62
62
|
'errors'<U extends ErrorMap>(errors: U): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
63
|
-
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>):
|
63
|
+
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
64
64
|
'meta'(meta: TMeta): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
65
65
|
'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
66
66
|
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
@@ -76,7 +76,7 @@ interface BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContex
|
|
76
76
|
interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
77
77
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
78
78
|
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
79
|
-
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>):
|
79
|
+
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureBuilder<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
80
80
|
'meta'(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
81
81
|
'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
82
82
|
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
@@ -86,8 +86,8 @@ interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext exte
|
|
86
86
|
interface ProcedureBuilderWithInput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
87
87
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
88
88
|
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
89
|
-
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, InferSchemaOutput<TInputSchema>, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>):
|
90
|
-
'use'<UOutContext extends Context, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, UInput, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>):
|
89
|
+
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureBuilderWithInput<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
90
|
+
'use'<UOutContext extends Context, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ProcedureBuilderWithInput<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
91
91
|
'meta'(meta: TMeta): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
92
92
|
'route'(route: Route): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
93
93
|
'output'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
@@ -96,7 +96,7 @@ interface ProcedureBuilderWithInput<TInitialContext extends Context, TCurrentCon
|
|
96
96
|
interface ProcedureBuilderWithOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
97
97
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
98
98
|
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
99
|
-
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, unknown, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>):
|
99
|
+
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureBuilderWithOutput<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
100
100
|
'meta'(meta: TMeta): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
101
101
|
'route'(route: Route): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
102
102
|
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
@@ -105,8 +105,8 @@ interface ProcedureBuilderWithOutput<TInitialContext extends Context, TCurrentCo
|
|
105
105
|
interface ProcedureBuilderWithInputOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
106
106
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
107
107
|
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
108
|
-
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>):
|
109
|
-
'use'<UOutContext extends Context, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>):
|
108
|
+
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureBuilderWithInputOutput<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
109
|
+
'use'<UOutContext extends Context, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ProcedureBuilderWithInputOutput<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
110
110
|
'meta'(meta: TMeta): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
111
111
|
'route'(route: Route): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
112
112
|
'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
@@ -114,7 +114,7 @@ interface ProcedureBuilderWithInputOutput<TInitialContext extends Context, TCurr
|
|
114
114
|
interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
115
115
|
'~orpc': EnhanceRouterOptions<TErrorMap>;
|
116
116
|
'errors'<U extends ErrorMap>(errors: U): RouterBuilder<TInitialContext, TCurrentContext, MergedErrorMap<TErrorMap, U>, TMeta>;
|
117
|
-
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>):
|
117
|
+
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): RouterBuilder<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TErrorMap, TMeta>;
|
118
118
|
'prefix'(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
119
119
|
'tag'(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
120
120
|
'router'<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>;
|
@@ -125,8 +125,8 @@ interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends
|
|
125
125
|
|
126
126
|
interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> extends Middleware<TInContext, TOutContext, TInput, TOutput, TErrorConstructorMap, TMeta> {
|
127
127
|
mapInput<UInput>(map: MapInputMiddleware<UInput, TInput>): DecoratedMiddleware<TInContext, TOutContext, UInput, TOutput, TErrorConstructorMap, TMeta>;
|
128
|
-
concat<UOutContext extends Context, UInContext extends Context = MergedCurrentContext<TInContext, TOutContext>>(middleware: Middleware<UInContext, UOutContext, TInput, TOutput, TErrorConstructorMap, TMeta>):
|
129
|
-
concat<UOutContext extends Context, UMappedInput, UInContext extends Context = MergedCurrentContext<TInContext, TOutContext>>(middleware: Middleware<UInContext, UOutContext, UMappedInput, TOutput, TErrorConstructorMap, TMeta>, mapInput: MapInputMiddleware<TInput, UMappedInput>):
|
128
|
+
concat<UOutContext extends Context, UInContext extends Context = MergedCurrentContext<TInContext, TOutContext>>(middleware: Middleware<UInContext | MergedCurrentContext<TInContext, TOutContext>, UOutContext, TInput, TOutput, TErrorConstructorMap, TMeta>): DecoratedMiddleware<MergedInitialContext<TInContext, UInContext, MergedCurrentContext<TInContext, TOutContext>>, MergedCurrentContext<TOutContext, UOutContext>, TInput, TOutput, TErrorConstructorMap, TMeta>;
|
129
|
+
concat<UOutContext extends Context, UMappedInput, UInContext extends Context = MergedCurrentContext<TInContext, TOutContext>>(middleware: Middleware<UInContext | MergedCurrentContext<TInContext, TOutContext>, UOutContext, UMappedInput, TOutput, TErrorConstructorMap, TMeta>, mapInput: MapInputMiddleware<TInput, UMappedInput>): DecoratedMiddleware<MergedInitialContext<TInContext, UInContext, MergedCurrentContext<TInContext, TOutContext>>, MergedCurrentContext<TOutContext, UOutContext>, TInput, TOutput, TErrorConstructorMap, TMeta>;
|
130
130
|
}
|
131
131
|
declare function decorateMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta>(middleware: Middleware<TInContext, TOutContext, TInput, TOutput, TErrorConstructorMap, TMeta>): DecoratedMiddleware<TInContext, TOutContext, TInput, TOutput, TErrorConstructorMap, TMeta>;
|
132
132
|
|
@@ -151,21 +151,20 @@ declare class Builder<TInitialContext extends Context, TCurrentContext extends C
|
|
151
151
|
/**
|
152
152
|
* Reset initial context
|
153
153
|
*/
|
154
|
-
$context<U extends Context>(): Builder<U, U, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
154
|
+
$context<U extends Context>(): Builder<U & Record<never, never>, U, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
155
155
|
/**
|
156
156
|
* Reset initial meta
|
157
157
|
*/
|
158
|
-
$meta<U extends Meta>(initialMeta: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, U
|
158
|
+
$meta<U extends Meta>(initialMeta: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, U & Record<never, never>>;
|
159
159
|
/**
|
160
160
|
* Reset initial route
|
161
161
|
*/
|
162
162
|
$route(initialRoute: Route): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
163
163
|
$input<U extends AnySchema>(initialInputSchema?: U): Builder<TInitialContext, TCurrentContext, U, TOutputSchema, TErrorMap, TMeta>;
|
164
164
|
middleware<UOutContext extends Context, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
165
|
-
middleware: Middleware<
|
165
|
+
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, TMeta>;
|
166
166
|
errors<U extends ErrorMap>(errors: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
167
|
-
use<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>):
|
168
|
-
use<UOutContext extends Context, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, UInput, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<unknown, UInput>): ContextExtendsGuard<TCurrentContext, UInContext> & BuilderWithMiddlewares<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
167
|
+
use<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
169
168
|
meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
170
169
|
route(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
171
170
|
input<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
@@ -191,8 +190,8 @@ declare function fallbackConfig<T extends keyof Config>(key: T, value?: Config[T
|
|
191
190
|
* Like `DecoratedProcedure`, but removed all method that can change the contract.
|
192
191
|
*/
|
193
192
|
interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
194
|
-
use<UOutContext extends
|
195
|
-
use<UOutContext extends
|
193
|
+
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ImplementedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
194
|
+
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ImplementedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
196
195
|
/**
|
197
196
|
* Make this procedure callable (works like a function while still being a procedure).
|
198
197
|
*/
|
@@ -207,13 +206,13 @@ interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext
|
|
207
206
|
*/
|
208
207
|
interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
209
208
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
210
|
-
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>):
|
211
|
-
'use'<UOutContext extends Context, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>):
|
209
|
+
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
210
|
+
'use'<UOutContext extends Context, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
212
211
|
'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
213
212
|
}
|
214
213
|
|
215
214
|
interface RouterImplementerWithMiddlewares<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
216
|
-
use<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>):
|
215
|
+
use<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): ImplementerInternalWithMiddlewares<T, MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>>;
|
217
216
|
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
218
217
|
lazy<U extends Router<T, TInitialContext>>(loader: () => Promise<{
|
219
218
|
default: U;
|
@@ -225,8 +224,8 @@ type ImplementerInternalWithMiddlewares<TContract extends AnyContractRouter, TIn
|
|
225
224
|
|
226
225
|
interface RouterImplementer<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
227
226
|
middleware<UOutContext extends Context, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
228
|
-
middleware: Middleware<
|
229
|
-
use<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>):
|
227
|
+
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, InferContractRouterMeta<T>>;
|
228
|
+
use<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): ImplementerInternalWithMiddlewares<T, MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>>;
|
230
229
|
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
231
230
|
lazy<U extends Router<T, TCurrentContext>>(loader: () => Promise<{
|
232
231
|
default: U;
|
@@ -237,10 +236,10 @@ type ImplementerInternal<TContract extends AnyContractRouter, TInitialContext ex
|
|
237
236
|
});
|
238
237
|
declare function implementerInternal<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context>(contract: T, config: BuilderConfig, middlewares: AnyMiddleware[]): ImplementerInternal<T, TInitialContext, TCurrentContext>;
|
239
238
|
type Implementer<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = {
|
240
|
-
$context<U extends Context>(): Implementer<TContract, U, U>;
|
239
|
+
$context<U extends Context>(): Implementer<TContract, U & Record<never, never>, U>;
|
241
240
|
$config(config: BuilderConfig): Implementer<TContract, TInitialContext, TCurrentContext>;
|
242
241
|
} & ImplementerInternal<TContract, TInitialContext, TCurrentContext>;
|
243
|
-
declare function implement<
|
242
|
+
declare function implement<T extends AnyContractRouter, TContext extends Context = Record<never, never>>(contract: T, config?: BuilderConfig): Implementer<T, TContext, TContext>;
|
244
243
|
|
245
244
|
declare function isStartWithMiddlewares(middlewares: readonly AnyMiddleware[], compare: readonly AnyMiddleware[]): boolean;
|
246
245
|
declare function mergeMiddlewares(first: readonly AnyMiddleware[], second: readonly AnyMiddleware[], options: {
|
@@ -275,4 +274,4 @@ declare function getHiddenRouterContract(router: Lazyable<AnyRouter | AnyContrac
|
|
275
274
|
|
276
275
|
declare function toHttpPath(path: readonly string[]): HTTPPath;
|
277
276
|
|
278
|
-
export { type AccessibleLazyRouter, AnyMiddleware, AnyProcedure, AnyRouter, Builder, type BuilderConfig, type BuilderDef, type BuilderWithMiddlewares, type Config, Context,
|
277
|
+
export { type AccessibleLazyRouter, AnyMiddleware, AnyProcedure, AnyRouter, Builder, type BuilderConfig, type BuilderDef, type BuilderWithMiddlewares, type Config, Context, type ContractProcedureCallbackOptions, CreateProcedureClientOptions, type DecoratedMiddleware, DecoratedProcedure, type EnhanceRouterOptions, type EnhancedRouter, type ImplementedProcedure, type Implementer, type ImplementerInternal, type ImplementerInternalWithMiddlewares, InferRouterInitialContext, Lazy, type LazyTraverseContractProceduresOptions, Lazyable, MapInputMiddleware, MergedCurrentContext, MergedInitialContext, Middleware, ORPCErrorConstructorMap, Procedure, type ProcedureBuilder, type ProcedureBuilderWithInput, type ProcedureBuilderWithInputOutput, type ProcedureBuilderWithOutput, ProcedureClient, ProcedureHandler, type ProcedureImplementer, Router, type RouterBuilder, type RouterClient, type RouterImplementer, type RouterImplementerWithMiddlewares, type TraverseContractProceduresOptions, type UnlaziedRouter, addMiddleware, call, createAccessibleLazyRouter, createAssertedLazyProcedure, createContractedProcedure, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getHiddenRouterContract, getRouter, implement, implementerInternal, isStartWithMiddlewares, mergeMiddlewares, os, resolveContractProcedures, setHiddenRouterContract, toHttpPath, traverseContractProcedures, unlazyRouter };
|
package/dist/index.d.ts
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
import { AnySchema, ErrorMap, Meta, MergedErrorMap, Route, InferSchemaOutput, InferSchemaInput, EnhanceRouteOptions, AnyContractRouter, AnyContractProcedure, Schema, HTTPPath, ContractRouter, ContractProcedureDef, ContractProcedure, InferContractRouterErrorMap, InferContractRouterMeta, ErrorFromErrorMap } from '@orpc/contract';
|
2
2
|
export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, HTTPMethod, HTTPPath, InferSchemaInput, InferSchemaOutput, InputStructure, Meta, OutputStructure, Route, Schema, ValidationError, eventIterator, type } from '@orpc/contract';
|
3
|
-
import { C as Context, b as Procedure, M as Middleware, O as ORPCErrorConstructorMap, c as
|
4
|
-
export {
|
3
|
+
import { C as Context, b as Procedure, M as Middleware, O as ORPCErrorConstructorMap, c as MergedInitialContext, d as MergedCurrentContext, e as MapInputMiddleware, f as CreateProcedureClientOptions, g as ProcedureClient, h as AnyMiddleware, L as Lazyable, a as AnyRouter, i as Lazy, A as AnyProcedure, j as ProcedureHandler, R as Router, I as InferRouterInitialContext } from './shared/server.MZvbGc3n.js';
|
4
|
+
export { J as InferRouterCurrentContexts, H as InferRouterInitialContexts, K as InferRouterInputs, N as InferRouterOutputs, o as LAZY_SYMBOL, p as LazyMeta, x as MiddlewareNextFn, w as MiddlewareNextFnOptions, z as MiddlewareOptions, y as MiddlewareOutputFn, t as MiddlewareResult, l as ORPCErrorConstructorMapItem, k as ORPCErrorConstructorMapItemOptions, P as ProcedureClientInterceptorOptions, E as ProcedureDef, D as ProcedureHandlerOptions, n as createORPCErrorConstructorMap, G as createProcedureClient, s as getLazyMeta, r as isLazy, F as isProcedure, q as lazy, m as mergeCurrentContext, B as middlewareOutputFn, u as unlazy, v as validateORPCError } from './shared/server.MZvbGc3n.js';
|
5
5
|
import { ClientContext, ClientRest, ClientPromiseResult } from '@orpc/client';
|
6
6
|
export { ORPCError, isDefinedError, safe } from '@orpc/client';
|
7
|
-
import { MaybeOptionalOptions } from '@orpc/shared';
|
7
|
+
import { IntersectPick, MaybeOptionalOptions } from '@orpc/shared';
|
8
8
|
export { onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
9
9
|
export { getEventMeta, withEventMeta } from '@orpc/standard-server';
|
10
10
|
|
@@ -12,8 +12,8 @@ declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContex
|
|
12
12
|
errors<U extends ErrorMap>(errors: U): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
13
13
|
meta(meta: TMeta): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
14
14
|
route(route: Route): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
15
|
-
use<UOutContext extends
|
16
|
-
use<UOutContext extends
|
15
|
+
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): DecoratedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
16
|
+
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): DecoratedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
17
17
|
/**
|
18
18
|
* Make this procedure callable (works like a function while still being a procedure).
|
19
19
|
*/
|
@@ -60,7 +60,7 @@ declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedR
|
|
60
60
|
interface BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
61
61
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
62
62
|
'errors'<U extends ErrorMap>(errors: U): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
63
|
-
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>):
|
63
|
+
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
64
64
|
'meta'(meta: TMeta): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
65
65
|
'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
66
66
|
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
@@ -76,7 +76,7 @@ interface BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContex
|
|
76
76
|
interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
77
77
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
78
78
|
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
79
|
-
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>):
|
79
|
+
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureBuilder<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
80
80
|
'meta'(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
81
81
|
'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
82
82
|
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
@@ -86,8 +86,8 @@ interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext exte
|
|
86
86
|
interface ProcedureBuilderWithInput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
87
87
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
88
88
|
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
89
|
-
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, InferSchemaOutput<TInputSchema>, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>):
|
90
|
-
'use'<UOutContext extends Context, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, UInput, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>):
|
89
|
+
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureBuilderWithInput<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
90
|
+
'use'<UOutContext extends Context, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ProcedureBuilderWithInput<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
91
91
|
'meta'(meta: TMeta): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
92
92
|
'route'(route: Route): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
93
93
|
'output'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
@@ -96,7 +96,7 @@ interface ProcedureBuilderWithInput<TInitialContext extends Context, TCurrentCon
|
|
96
96
|
interface ProcedureBuilderWithOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
97
97
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
98
98
|
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
99
|
-
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, unknown, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>):
|
99
|
+
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureBuilderWithOutput<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
100
100
|
'meta'(meta: TMeta): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
101
101
|
'route'(route: Route): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
102
102
|
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
@@ -105,8 +105,8 @@ interface ProcedureBuilderWithOutput<TInitialContext extends Context, TCurrentCo
|
|
105
105
|
interface ProcedureBuilderWithInputOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
106
106
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
107
107
|
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
108
|
-
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>):
|
109
|
-
'use'<UOutContext extends Context, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>):
|
108
|
+
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureBuilderWithInputOutput<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
109
|
+
'use'<UOutContext extends Context, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ProcedureBuilderWithInputOutput<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
110
110
|
'meta'(meta: TMeta): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
111
111
|
'route'(route: Route): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
112
112
|
'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
@@ -114,7 +114,7 @@ interface ProcedureBuilderWithInputOutput<TInitialContext extends Context, TCurr
|
|
114
114
|
interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
115
115
|
'~orpc': EnhanceRouterOptions<TErrorMap>;
|
116
116
|
'errors'<U extends ErrorMap>(errors: U): RouterBuilder<TInitialContext, TCurrentContext, MergedErrorMap<TErrorMap, U>, TMeta>;
|
117
|
-
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>):
|
117
|
+
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): RouterBuilder<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TErrorMap, TMeta>;
|
118
118
|
'prefix'(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
119
119
|
'tag'(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
120
120
|
'router'<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>;
|
@@ -125,8 +125,8 @@ interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends
|
|
125
125
|
|
126
126
|
interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> extends Middleware<TInContext, TOutContext, TInput, TOutput, TErrorConstructorMap, TMeta> {
|
127
127
|
mapInput<UInput>(map: MapInputMiddleware<UInput, TInput>): DecoratedMiddleware<TInContext, TOutContext, UInput, TOutput, TErrorConstructorMap, TMeta>;
|
128
|
-
concat<UOutContext extends Context, UInContext extends Context = MergedCurrentContext<TInContext, TOutContext>>(middleware: Middleware<UInContext, UOutContext, TInput, TOutput, TErrorConstructorMap, TMeta>):
|
129
|
-
concat<UOutContext extends Context, UMappedInput, UInContext extends Context = MergedCurrentContext<TInContext, TOutContext>>(middleware: Middleware<UInContext, UOutContext, UMappedInput, TOutput, TErrorConstructorMap, TMeta>, mapInput: MapInputMiddleware<TInput, UMappedInput>):
|
128
|
+
concat<UOutContext extends Context, UInContext extends Context = MergedCurrentContext<TInContext, TOutContext>>(middleware: Middleware<UInContext | MergedCurrentContext<TInContext, TOutContext>, UOutContext, TInput, TOutput, TErrorConstructorMap, TMeta>): DecoratedMiddleware<MergedInitialContext<TInContext, UInContext, MergedCurrentContext<TInContext, TOutContext>>, MergedCurrentContext<TOutContext, UOutContext>, TInput, TOutput, TErrorConstructorMap, TMeta>;
|
129
|
+
concat<UOutContext extends Context, UMappedInput, UInContext extends Context = MergedCurrentContext<TInContext, TOutContext>>(middleware: Middleware<UInContext | MergedCurrentContext<TInContext, TOutContext>, UOutContext, UMappedInput, TOutput, TErrorConstructorMap, TMeta>, mapInput: MapInputMiddleware<TInput, UMappedInput>): DecoratedMiddleware<MergedInitialContext<TInContext, UInContext, MergedCurrentContext<TInContext, TOutContext>>, MergedCurrentContext<TOutContext, UOutContext>, TInput, TOutput, TErrorConstructorMap, TMeta>;
|
130
130
|
}
|
131
131
|
declare function decorateMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta>(middleware: Middleware<TInContext, TOutContext, TInput, TOutput, TErrorConstructorMap, TMeta>): DecoratedMiddleware<TInContext, TOutContext, TInput, TOutput, TErrorConstructorMap, TMeta>;
|
132
132
|
|
@@ -151,21 +151,20 @@ declare class Builder<TInitialContext extends Context, TCurrentContext extends C
|
|
151
151
|
/**
|
152
152
|
* Reset initial context
|
153
153
|
*/
|
154
|
-
$context<U extends Context>(): Builder<U, U, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
154
|
+
$context<U extends Context>(): Builder<U & Record<never, never>, U, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
155
155
|
/**
|
156
156
|
* Reset initial meta
|
157
157
|
*/
|
158
|
-
$meta<U extends Meta>(initialMeta: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, U
|
158
|
+
$meta<U extends Meta>(initialMeta: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, U & Record<never, never>>;
|
159
159
|
/**
|
160
160
|
* Reset initial route
|
161
161
|
*/
|
162
162
|
$route(initialRoute: Route): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
163
163
|
$input<U extends AnySchema>(initialInputSchema?: U): Builder<TInitialContext, TCurrentContext, U, TOutputSchema, TErrorMap, TMeta>;
|
164
164
|
middleware<UOutContext extends Context, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
165
|
-
middleware: Middleware<
|
165
|
+
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, TMeta>;
|
166
166
|
errors<U extends ErrorMap>(errors: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
167
|
-
use<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>):
|
168
|
-
use<UOutContext extends Context, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, UInput, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<unknown, UInput>): ContextExtendsGuard<TCurrentContext, UInContext> & BuilderWithMiddlewares<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
167
|
+
use<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
169
168
|
meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
170
169
|
route(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
171
170
|
input<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
@@ -191,8 +190,8 @@ declare function fallbackConfig<T extends keyof Config>(key: T, value?: Config[T
|
|
191
190
|
* Like `DecoratedProcedure`, but removed all method that can change the contract.
|
192
191
|
*/
|
193
192
|
interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
194
|
-
use<UOutContext extends
|
195
|
-
use<UOutContext extends
|
193
|
+
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ImplementedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
194
|
+
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ImplementedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
196
195
|
/**
|
197
196
|
* Make this procedure callable (works like a function while still being a procedure).
|
198
197
|
*/
|
@@ -207,13 +206,13 @@ interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext
|
|
207
206
|
*/
|
208
207
|
interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
209
208
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
210
|
-
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>):
|
211
|
-
'use'<UOutContext extends Context, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>):
|
209
|
+
'use'<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
210
|
+
'use'<UOutContext extends Context, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
212
211
|
'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
213
212
|
}
|
214
213
|
|
215
214
|
interface RouterImplementerWithMiddlewares<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
216
|
-
use<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>):
|
215
|
+
use<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): ImplementerInternalWithMiddlewares<T, MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>>;
|
217
216
|
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
218
217
|
lazy<U extends Router<T, TInitialContext>>(loader: () => Promise<{
|
219
218
|
default: U;
|
@@ -225,8 +224,8 @@ type ImplementerInternalWithMiddlewares<TContract extends AnyContractRouter, TIn
|
|
225
224
|
|
226
225
|
interface RouterImplementer<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
227
226
|
middleware<UOutContext extends Context, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
228
|
-
middleware: Middleware<
|
229
|
-
use<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>):
|
227
|
+
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, InferContractRouterMeta<T>>;
|
228
|
+
use<UOutContext extends Context, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): ImplementerInternalWithMiddlewares<T, MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>>;
|
230
229
|
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
231
230
|
lazy<U extends Router<T, TCurrentContext>>(loader: () => Promise<{
|
232
231
|
default: U;
|
@@ -237,10 +236,10 @@ type ImplementerInternal<TContract extends AnyContractRouter, TInitialContext ex
|
|
237
236
|
});
|
238
237
|
declare function implementerInternal<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context>(contract: T, config: BuilderConfig, middlewares: AnyMiddleware[]): ImplementerInternal<T, TInitialContext, TCurrentContext>;
|
239
238
|
type Implementer<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = {
|
240
|
-
$context<U extends Context>(): Implementer<TContract, U, U>;
|
239
|
+
$context<U extends Context>(): Implementer<TContract, U & Record<never, never>, U>;
|
241
240
|
$config(config: BuilderConfig): Implementer<TContract, TInitialContext, TCurrentContext>;
|
242
241
|
} & ImplementerInternal<TContract, TInitialContext, TCurrentContext>;
|
243
|
-
declare function implement<
|
242
|
+
declare function implement<T extends AnyContractRouter, TContext extends Context = Record<never, never>>(contract: T, config?: BuilderConfig): Implementer<T, TContext, TContext>;
|
244
243
|
|
245
244
|
declare function isStartWithMiddlewares(middlewares: readonly AnyMiddleware[], compare: readonly AnyMiddleware[]): boolean;
|
246
245
|
declare function mergeMiddlewares(first: readonly AnyMiddleware[], second: readonly AnyMiddleware[], options: {
|
@@ -275,4 +274,4 @@ declare function getHiddenRouterContract(router: Lazyable<AnyRouter | AnyContrac
|
|
275
274
|
|
276
275
|
declare function toHttpPath(path: readonly string[]): HTTPPath;
|
277
276
|
|
278
|
-
export { type AccessibleLazyRouter, AnyMiddleware, AnyProcedure, AnyRouter, Builder, type BuilderConfig, type BuilderDef, type BuilderWithMiddlewares, type Config, Context,
|
277
|
+
export { type AccessibleLazyRouter, AnyMiddleware, AnyProcedure, AnyRouter, Builder, type BuilderConfig, type BuilderDef, type BuilderWithMiddlewares, type Config, Context, type ContractProcedureCallbackOptions, CreateProcedureClientOptions, type DecoratedMiddleware, DecoratedProcedure, type EnhanceRouterOptions, type EnhancedRouter, type ImplementedProcedure, type Implementer, type ImplementerInternal, type ImplementerInternalWithMiddlewares, InferRouterInitialContext, Lazy, type LazyTraverseContractProceduresOptions, Lazyable, MapInputMiddleware, MergedCurrentContext, MergedInitialContext, Middleware, ORPCErrorConstructorMap, Procedure, type ProcedureBuilder, type ProcedureBuilderWithInput, type ProcedureBuilderWithInputOutput, type ProcedureBuilderWithOutput, ProcedureClient, ProcedureHandler, type ProcedureImplementer, Router, type RouterBuilder, type RouterClient, type RouterImplementer, type RouterImplementerWithMiddlewares, type TraverseContractProceduresOptions, type UnlaziedRouter, addMiddleware, call, createAccessibleLazyRouter, createAssertedLazyProcedure, createContractedProcedure, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getHiddenRouterContract, getRouter, implement, implementerInternal, isStartWithMiddlewares, mergeMiddlewares, os, resolveContractProcedures, setHiddenRouterContract, toHttpPath, traverseContractProcedures, unlazyRouter };
|
package/dist/index.mjs
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import { mergeErrorMap, mergeMeta, mergeRoute, mergePrefix, mergeTags, isContractProcedure, getContractRouter } from '@orpc/contract';
|
2
2
|
export { ValidationError, eventIterator, type } from '@orpc/contract';
|
3
|
-
import { P as Procedure, d as addMiddleware, c as createProcedureClient, e as enhanceRouter, l as lazy, s as setHiddenRouterContract, i as isProcedure, f as isLazy, h as createAssertedLazyProcedure, g as getRouter } from './shared/server.
|
4
|
-
export { L as LAZY_SYMBOL,
|
3
|
+
import { P as Procedure, d as addMiddleware, c as createProcedureClient, e as enhanceRouter, l as lazy, s as setHiddenRouterContract, i as isProcedure, f as isLazy, h as createAssertedLazyProcedure, g as getRouter } from './shared/server.BtxZnWJ9.mjs';
|
4
|
+
export { L as LAZY_SYMBOL, q as call, w as createAccessibleLazyRouter, b as createContractedProcedure, j as createORPCErrorConstructorMap, r as getHiddenRouterContract, k as getLazyMeta, o as isStartWithMiddlewares, m as mergeCurrentContext, p as mergeMiddlewares, n as middlewareOutputFn, x as resolveContractProcedures, a as toHttpPath, t as traverseContractProcedures, u as unlazy, y as unlazyRouter, v as validateORPCError } from './shared/server.BtxZnWJ9.mjs';
|
5
5
|
export { ORPCError, isDefinedError, safe } from '@orpc/client';
|
6
6
|
export { onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
7
7
|
export { getEventMeta, withEventMeta } from '@orpc/standard-server';
|
@@ -223,10 +223,6 @@ const os = new Builder({
|
|
223
223
|
dedupeLeadingMiddlewares: true
|
224
224
|
});
|
225
225
|
|
226
|
-
function mergeCurrentContext(context, other) {
|
227
|
-
return { ...context, ...other };
|
228
|
-
}
|
229
|
-
|
230
226
|
function implementerInternal(contract, config, middlewares) {
|
231
227
|
if (isContractProcedure(contract)) {
|
232
228
|
const impl2 = new Builder({
|
@@ -343,4 +339,4 @@ function createRouterClient(router, ...[options]) {
|
|
343
339
|
return recursive;
|
344
340
|
}
|
345
341
|
|
346
|
-
export { Builder, DecoratedProcedure, Procedure, addMiddleware, createAssertedLazyProcedure, createProcedureClient, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getRouter, implement, implementerInternal, isLazy, isProcedure, lazy,
|
342
|
+
export { Builder, DecoratedProcedure, Procedure, addMiddleware, createAssertedLazyProcedure, createProcedureClient, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getRouter, implement, implementerInternal, isLazy, isProcedure, lazy, os, setHiddenRouterContract };
|
package/dist/plugins/index.d.mts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
import {
|
2
|
-
export { C as
|
1
|
+
import { b as StandardHandlerInterceptorOptions, H as HandlerPlugin, a as StandardHandlerOptions } from '../shared/server.P4_D9lKb.mjs';
|
2
|
+
export { C as CompositeHandlerPlugin } from '../shared/server.P4_D9lKb.mjs';
|
3
3
|
import { Value } from '@orpc/shared';
|
4
|
-
import { C as Context } from '../shared/server.
|
4
|
+
import { C as Context } from '../shared/server.MZvbGc3n.mjs';
|
5
5
|
import '@orpc/contract';
|
6
6
|
import '@orpc/standard-server';
|
7
7
|
import '@orpc/client';
|
package/dist/plugins/index.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
import {
|
2
|
-
export { C as
|
1
|
+
import { b as StandardHandlerInterceptorOptions, H as HandlerPlugin, a as StandardHandlerOptions } from '../shared/server.CPqNKiJp.js';
|
2
|
+
export { C as CompositeHandlerPlugin } from '../shared/server.CPqNKiJp.js';
|
3
3
|
import { Value } from '@orpc/shared';
|
4
|
-
import { C as Context } from '../shared/server.
|
4
|
+
import { C as Context } from '../shared/server.MZvbGc3n.js';
|
5
5
|
import '@orpc/contract';
|
6
6
|
import '@orpc/standard-server';
|
7
7
|
import '@orpc/client';
|
package/dist/plugins/index.mjs
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
import { ORPCError, toORPCError } from '@orpc/client';
|
2
2
|
import { intercept, trim, parseEmptyableJSON } from '@orpc/shared';
|
3
|
-
import { C as
|
4
|
-
import { c as createProcedureClient, t as traverseContractProcedures, a as toHttpPath, i as isProcedure, u as unlazy, g as getRouter, b as createContractedProcedure } from './server.
|
3
|
+
import { C as CompositeHandlerPlugin } from './server.Dba3Iiyp.mjs';
|
4
|
+
import { c as createProcedureClient, t as traverseContractProcedures, a as toHttpPath, i as isProcedure, u as unlazy, g as getRouter, b as createContractedProcedure } from './server.BtxZnWJ9.mjs';
|
5
5
|
|
6
6
|
class StandardHandler {
|
7
7
|
constructor(router, matcher, codec, options) {
|
8
8
|
this.matcher = matcher;
|
9
9
|
this.codec = codec;
|
10
10
|
this.options = options;
|
11
|
-
this.plugin = new
|
11
|
+
this.plugin = new CompositeHandlerPlugin(options.plugins);
|
12
12
|
this.plugin.init(this.options);
|
13
13
|
this.matcher.init(router);
|
14
14
|
}
|
@@ -69,7 +69,7 @@ class StandardHandler {
|
|
69
69
|
}
|
70
70
|
}
|
71
71
|
|
72
|
-
class
|
72
|
+
class StandardRPCCodec {
|
73
73
|
constructor(serializer) {
|
74
74
|
this.serializer = serializer;
|
75
75
|
}
|
@@ -93,7 +93,7 @@ class RPCCodec {
|
|
93
93
|
}
|
94
94
|
}
|
95
95
|
|
96
|
-
class
|
96
|
+
class StandardRPCMatcher {
|
97
97
|
tree = {};
|
98
98
|
pendingRouters = [];
|
99
99
|
init(router, path = []) {
|
@@ -155,4 +155,4 @@ class RPCMatcher {
|
|
155
155
|
}
|
156
156
|
}
|
157
157
|
|
158
|
-
export {
|
158
|
+
export { StandardHandler as S, StandardRPCCodec as a, StandardRPCMatcher as b };
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
|
2
|
+
import { C as Context } from './server.MZvbGc3n.mjs';
|
3
|
+
import { a as StandardHandlerOptions } from './server.P4_D9lKb.mjs';
|
4
|
+
|
5
|
+
interface StandardRPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardRPCJsonSerializerOptions {
|
6
|
+
}
|
7
|
+
|
8
|
+
export type { StandardRPCHandlerOptions as S };
|
@@ -58,6 +58,10 @@ function isProcedure(item) {
|
|
58
58
|
return isContractProcedure(item) && "middlewares" in item["~orpc"] && "inputValidationIndex" in item["~orpc"] && "outputValidationIndex" in item["~orpc"] && "handler" in item["~orpc"];
|
59
59
|
}
|
60
60
|
|
61
|
+
function mergeCurrentContext(context, other) {
|
62
|
+
return { ...context, ...other };
|
63
|
+
}
|
64
|
+
|
61
65
|
function createORPCErrorConstructorMap(errors) {
|
62
66
|
const proxy = new Proxy(errors, {
|
63
67
|
get(target, code) {
|
@@ -170,23 +174,30 @@ async function executeProcedureInternal(procedure, options) {
|
|
170
174
|
let currentInput = options.input;
|
171
175
|
const next = async (...[nextOptions]) => {
|
172
176
|
const index = currentIndex;
|
177
|
+
const midContext = nextOptions?.context ?? {};
|
173
178
|
currentIndex += 1;
|
174
|
-
currentContext =
|
179
|
+
currentContext = mergeCurrentContext(currentContext, midContext);
|
175
180
|
if (index === inputValidationIndex) {
|
176
181
|
currentInput = await validateInput(procedure, currentInput);
|
177
182
|
}
|
178
183
|
const mid = middlewares[index];
|
179
|
-
const result = mid ?
|
184
|
+
const result = mid ? {
|
185
|
+
context: midContext,
|
186
|
+
output: (await mid({ ...options, context: currentContext, next }, currentInput, middlewareOutputFn)).output
|
187
|
+
} : {
|
188
|
+
context: midContext,
|
189
|
+
output: await procedure["~orpc"].handler({ ...options, context: currentContext, input: currentInput })
|
190
|
+
};
|
180
191
|
if (index === outputValidationIndex) {
|
181
192
|
const validatedOutput = await validateOutput(procedure, result.output);
|
182
193
|
return {
|
183
|
-
|
194
|
+
context: result.context,
|
184
195
|
output: validatedOutput
|
185
196
|
};
|
186
197
|
}
|
187
198
|
return result;
|
188
199
|
};
|
189
|
-
return (await next(
|
200
|
+
return (await next()).output;
|
190
201
|
}
|
191
202
|
|
192
203
|
const HIDDEN_ROUTER_CONTRACT_SYMBOL = Symbol("ORPC_HIDDEN_ROUTER_CONTRACT");
|
@@ -360,4 +371,4 @@ function toHttpPath(path) {
|
|
360
371
|
return `/${path.map(encodeURIComponent).join("/")}`;
|
361
372
|
}
|
362
373
|
|
363
|
-
export { LAZY_SYMBOL as L, Procedure as P, toHttpPath as a, createContractedProcedure as b, createProcedureClient as c, addMiddleware as d, enhanceRouter as e, isLazy as f, getRouter as g, createAssertedLazyProcedure as h, isProcedure as i, createORPCErrorConstructorMap as j, getLazyMeta as k, lazy as l,
|
374
|
+
export { LAZY_SYMBOL as L, Procedure as P, toHttpPath as a, createContractedProcedure as b, createProcedureClient as c, addMiddleware as d, enhanceRouter as e, isLazy as f, getRouter as g, createAssertedLazyProcedure as h, isProcedure as i, createORPCErrorConstructorMap as j, getLazyMeta as k, lazy as l, mergeCurrentContext as m, middlewareOutputFn as n, isStartWithMiddlewares as o, mergeMiddlewares as p, call as q, getHiddenRouterContract as r, setHiddenRouterContract as s, traverseContractProcedures as t, unlazy as u, validateORPCError as v, createAccessibleLazyRouter as w, resolveContractProcedures as x, unlazyRouter as y };
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { HTTPPath, AnySchema, Meta, InferSchemaOutput, ErrorFromErrorMap } from '@orpc/contract';
|
2
2
|
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
3
3
|
import { StandardResponse, StandardLazyRequest } from '@orpc/standard-server';
|
4
|
-
import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.
|
4
|
+
import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.MZvbGc3n.js';
|
5
5
|
import { ORPCError } from '@orpc/client';
|
6
6
|
|
7
7
|
type StandardParams = Record<string, string>;
|
@@ -66,10 +66,10 @@ declare class StandardHandler<T extends Context> {
|
|
66
66
|
interface HandlerPlugin<TContext extends Context> {
|
67
67
|
init?(options: StandardHandlerOptions<TContext>): void;
|
68
68
|
}
|
69
|
-
declare class
|
69
|
+
declare class CompositeHandlerPlugin<TContext extends Context> implements HandlerPlugin<TContext> {
|
70
70
|
private readonly plugins;
|
71
71
|
constructor(plugins?: HandlerPlugin<TContext>[]);
|
72
72
|
init(options: StandardHandlerOptions<TContext>): void;
|
73
73
|
}
|
74
74
|
|
75
|
-
export {
|
75
|
+
export { CompositeHandlerPlugin as C, type HandlerPlugin as H, type StandardHandleOptions as S, type StandardHandlerOptions as a, type StandardHandlerInterceptorOptions as b, type StandardCodec as c, type StandardParams as d, type StandardMatcher as e, type StandardMatchResult as f, type StandardHandleResult as g, StandardHandler as h };
|
@@ -1,13 +1,14 @@
|
|
1
|
-
import {
|
1
|
+
import { StandardRPCJsonSerializer, StandardRPCSerializer } from '@orpc/client/standard';
|
2
2
|
import { toStandardLazyRequest, toFetchResponse } from '@orpc/standard-server-fetch';
|
3
|
-
import { S as StandardHandler,
|
3
|
+
import { S as StandardHandler, b as StandardRPCMatcher, a as StandardRPCCodec } from './server.BY9sDlwl.mjs';
|
4
4
|
|
5
5
|
class RPCHandler {
|
6
6
|
standardHandler;
|
7
7
|
constructor(router, options = {}) {
|
8
|
-
const
|
9
|
-
const
|
10
|
-
const
|
8
|
+
const jsonSerializer = new StandardRPCJsonSerializer(options);
|
9
|
+
const serializer = new StandardRPCSerializer(jsonSerializer);
|
10
|
+
const matcher = new StandardRPCMatcher();
|
11
|
+
const codec = new StandardRPCCodec(serializer);
|
11
12
|
this.standardHandler = new StandardHandler(router, matcher, codec, options);
|
12
13
|
}
|
13
14
|
async handle(request, ...[
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { StandardRPCJsonSerializerOptions } from '@orpc/client/standard';
|
2
|
+
import { C as Context } from './server.MZvbGc3n.js';
|
3
|
+
import { a as StandardHandlerOptions } from './server.CPqNKiJp.js';
|
4
|
+
|
5
|
+
interface StandardRPCHandlerOptions<T extends Context> extends StandardHandlerOptions<T>, StandardRPCJsonSerializerOptions {
|
6
|
+
}
|
7
|
+
|
8
|
+
export type { StandardRPCHandlerOptions as S };
|
@@ -6,7 +6,6 @@ type Context = Record<string, any>;
|
|
6
6
|
type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
|
7
7
|
type MergedCurrentContext<T extends Context, U extends Context> = Omit<T, keyof U> & U;
|
8
8
|
declare function mergeCurrentContext<T extends Context, U extends Context>(context: T, other: U): MergedCurrentContext<T, U>;
|
9
|
-
type ContextExtendsGuard<T extends Context, U extends Context> = T extends T & U ? unknown : never;
|
10
9
|
|
11
10
|
type ORPCErrorConstructorMapItemOptions<TData> = Omit<ORPCErrorOptions<TData>, 'defined' | 'status'>;
|
12
11
|
type ORPCErrorConstructorMapItem<TCode extends ORPCErrorCode, TInData> = (...rest: MaybeOptionalOptions<ORPCErrorConstructorMapItemOptions<TInData>>) => ORPCError<TCode, TInData>;
|
@@ -141,4 +140,4 @@ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any
|
|
141
140
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
|
142
141
|
};
|
143
142
|
|
144
|
-
export { type AnyProcedure as A,
|
143
|
+
export { type AnyProcedure as A, middlewareOutputFn as B, type Context as C, type ProcedureHandlerOptions as D, type ProcedureDef as E, isProcedure as F, createProcedureClient as G, type InferRouterInitialContexts as H, type InferRouterInitialContext as I, type InferRouterCurrentContexts as J, type InferRouterInputs as K, type Lazyable as L, type Middleware as M, type InferRouterOutputs as N, type ORPCErrorConstructorMap as O, type ProcedureClientInterceptorOptions as P, type Router as R, type AnyRouter as a, Procedure as b, type MergedInitialContext as c, type MergedCurrentContext as d, type MapInputMiddleware as e, type CreateProcedureClientOptions as f, type ProcedureClient as g, type AnyMiddleware as h, type Lazy as i, type ProcedureHandler as j, type ORPCErrorConstructorMapItemOptions as k, type ORPCErrorConstructorMapItem as l, mergeCurrentContext as m, createORPCErrorConstructorMap as n, LAZY_SYMBOL as o, type LazyMeta as p, lazy as q, isLazy as r, getLazyMeta as s, type MiddlewareResult as t, unlazy as u, validateORPCError as v, type MiddlewareNextFnOptions as w, type MiddlewareNextFn as x, type MiddlewareOutputFn as y, type MiddlewareOptions as z };
|
@@ -6,7 +6,6 @@ type Context = Record<string, any>;
|
|
6
6
|
type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
|
7
7
|
type MergedCurrentContext<T extends Context, U extends Context> = Omit<T, keyof U> & U;
|
8
8
|
declare function mergeCurrentContext<T extends Context, U extends Context>(context: T, other: U): MergedCurrentContext<T, U>;
|
9
|
-
type ContextExtendsGuard<T extends Context, U extends Context> = T extends T & U ? unknown : never;
|
10
9
|
|
11
10
|
type ORPCErrorConstructorMapItemOptions<TData> = Omit<ORPCErrorOptions<TData>, 'defined' | 'status'>;
|
12
11
|
type ORPCErrorConstructorMapItem<TCode extends ORPCErrorCode, TInData> = (...rest: MaybeOptionalOptions<ORPCErrorConstructorMapItemOptions<TInData>>) => ORPCError<TCode, TInData>;
|
@@ -141,4 +140,4 @@ type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any
|
|
141
140
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
|
142
141
|
};
|
143
142
|
|
144
|
-
export { type AnyProcedure as A,
|
143
|
+
export { type AnyProcedure as A, middlewareOutputFn as B, type Context as C, type ProcedureHandlerOptions as D, type ProcedureDef as E, isProcedure as F, createProcedureClient as G, type InferRouterInitialContexts as H, type InferRouterInitialContext as I, type InferRouterCurrentContexts as J, type InferRouterInputs as K, type Lazyable as L, type Middleware as M, type InferRouterOutputs as N, type ORPCErrorConstructorMap as O, type ProcedureClientInterceptorOptions as P, type Router as R, type AnyRouter as a, Procedure as b, type MergedInitialContext as c, type MergedCurrentContext as d, type MapInputMiddleware as e, type CreateProcedureClientOptions as f, type ProcedureClient as g, type AnyMiddleware as h, type Lazy as i, type ProcedureHandler as j, type ORPCErrorConstructorMapItemOptions as k, type ORPCErrorConstructorMapItem as l, mergeCurrentContext as m, createORPCErrorConstructorMap as n, LAZY_SYMBOL as o, type LazyMeta as p, lazy as q, isLazy as r, getLazyMeta as s, type MiddlewareResult as t, unlazy as u, validateORPCError as v, type MiddlewareNextFnOptions as w, type MiddlewareNextFn as x, type MiddlewareOutputFn as y, type MiddlewareOptions as z };
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { HTTPPath, AnySchema, Meta, InferSchemaOutput, ErrorFromErrorMap } from '@orpc/contract';
|
2
2
|
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
3
3
|
import { StandardResponse, StandardLazyRequest } from '@orpc/standard-server';
|
4
|
-
import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.
|
4
|
+
import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.MZvbGc3n.mjs';
|
5
5
|
import { ORPCError } from '@orpc/client';
|
6
6
|
|
7
7
|
type StandardParams = Record<string, string>;
|
@@ -66,10 +66,10 @@ declare class StandardHandler<T extends Context> {
|
|
66
66
|
interface HandlerPlugin<TContext extends Context> {
|
67
67
|
init?(options: StandardHandlerOptions<TContext>): void;
|
68
68
|
}
|
69
|
-
declare class
|
69
|
+
declare class CompositeHandlerPlugin<TContext extends Context> implements HandlerPlugin<TContext> {
|
70
70
|
private readonly plugins;
|
71
71
|
constructor(plugins?: HandlerPlugin<TContext>[]);
|
72
72
|
init(options: StandardHandlerOptions<TContext>): void;
|
73
73
|
}
|
74
74
|
|
75
|
-
export {
|
75
|
+
export { CompositeHandlerPlugin as C, type HandlerPlugin as H, type StandardHandleOptions as S, type StandardHandlerOptions as a, type StandardHandlerInterceptorOptions as b, type StandardCodec as c, type StandardParams as d, type StandardMatcher as e, type StandardMatchResult as f, type StandardHandleResult as g, StandardHandler as h };
|
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.b4fc1d9",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -58,12 +58,12 @@
|
|
58
58
|
"next": ">=14.0.0"
|
59
59
|
},
|
60
60
|
"dependencies": {
|
61
|
-
"@orpc/client": "0.0.0-next.
|
62
|
-
"@orpc/
|
63
|
-
"@orpc/
|
64
|
-
"@orpc/standard-server-fetch": "0.0.0-next.
|
65
|
-
"@orpc/
|
66
|
-
"@orpc/standard-server": "0.0.0-next.
|
61
|
+
"@orpc/client": "0.0.0-next.b4fc1d9",
|
62
|
+
"@orpc/shared": "0.0.0-next.b4fc1d9",
|
63
|
+
"@orpc/standard-server": "0.0.0-next.b4fc1d9",
|
64
|
+
"@orpc/standard-server-fetch": "0.0.0-next.b4fc1d9",
|
65
|
+
"@orpc/contract": "0.0.0-next.b4fc1d9",
|
66
|
+
"@orpc/standard-server-node": "0.0.0-next.b4fc1d9"
|
67
67
|
},
|
68
68
|
"devDependencies": {
|
69
69
|
"light-my-request": "^6.5.1"
|