@orpc/server 0.0.0-next.d16a1b6 → 0.0.0-next.d3b4900
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 +13 -1
- package/dist/adapters/fetch/index.d.mts +38 -11
- package/dist/adapters/fetch/index.d.ts +38 -11
- package/dist/adapters/fetch/index.mjs +6 -6
- package/dist/adapters/hono/index.d.mts +6 -4
- package/dist/adapters/hono/index.d.ts +6 -4
- package/dist/adapters/hono/index.mjs +6 -6
- package/dist/adapters/next/index.d.mts +6 -4
- package/dist/adapters/next/index.d.ts +6 -4
- package/dist/adapters/next/index.mjs +6 -6
- package/dist/adapters/node/index.d.mts +40 -22
- package/dist/adapters/node/index.d.ts +40 -22
- package/dist/adapters/node/index.mjs +77 -20
- package/dist/adapters/standard/index.d.mts +10 -13
- package/dist/adapters/standard/index.d.ts +10 -13
- package/dist/adapters/standard/index.mjs +2 -4
- package/dist/index.d.mts +140 -118
- package/dist/index.d.ts +140 -118
- package/dist/index.mjs +55 -46
- package/dist/plugins/index.d.mts +14 -15
- package/dist/plugins/index.d.ts +14 -15
- package/dist/plugins/index.mjs +10 -6
- package/dist/shared/{server.B-ewprcf.d.ts → server.23VRZIfj.d.ts} +19 -30
- package/dist/shared/server.B4eSvRkD.mjs +98 -0
- package/dist/shared/server.BG5ftPWa.d.ts +10 -0
- package/dist/shared/server.BVwwTHyO.mjs +9 -0
- package/dist/shared/{server.V6zT5iYQ.mjs → server.BtxZnWJ9.mjs} +155 -160
- package/dist/shared/server.C-CCcROC.d.mts +10 -0
- package/dist/shared/server.CIbpOMZX.d.mts +8 -0
- package/dist/shared/server.DCcCuA52.d.ts +8 -0
- package/dist/shared/{server.DJrh0Ceu.d.mts → server.DJqfB27m.d.mts} +19 -30
- package/dist/shared/{server.BBGuTxHE.mjs → server.DnR6v9pj.mjs} +42 -45
- package/dist/shared/server.MZvbGc3n.d.mts +143 -0
- package/dist/shared/server.MZvbGc3n.d.ts +143 -0
- package/package.json +8 -8
- package/dist/shared/server.CA-o8cUY.d.mts +0 -9
- package/dist/shared/server.Cn9ybJtE.d.mts +0 -152
- package/dist/shared/server.Cn9ybJtE.d.ts +0 -152
- package/dist/shared/server.DPQt9YYq.d.ts +0 -9
- package/dist/shared/server.Q6ZmnTgO.mjs +0 -12
- package/dist/shared/server.pW-fRQNZ.mjs +0 -24
@@ -1,29 +1,26 @@
|
|
1
|
-
import {
|
2
|
-
export { S as StandardHandleOptions,
|
1
|
+
import { d as StandardCodec, e as StandardParams, f as StandardMatcher, g as StandardMatchResult } from '../../shared/server.23VRZIfj.js';
|
2
|
+
export { S as StandardHandleOptions, h as StandardHandleResult, i as StandardHandler, b as StandardHandlerInterceptorOptions, a as StandardHandlerOptions, c as StandardHandlerPlugin } from '../../shared/server.23VRZIfj.js';
|
3
3
|
import { ORPCError } from '@orpc/client';
|
4
|
+
import { StandardRPCSerializer } from '@orpc/client/standard';
|
4
5
|
import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
|
5
|
-
import { A as AnyProcedure, a as AnyRouter } from '../../shared/server.
|
6
|
-
|
7
|
-
export { R as RPCHandlerOptions } from '../../shared/server.DPQt9YYq.js';
|
6
|
+
import { A as AnyProcedure, a as AnyRouter } from '../../shared/server.MZvbGc3n.js';
|
7
|
+
export { S as StandardRPCHandlerOptions } from '../../shared/server.DCcCuA52.js';
|
8
8
|
import { HTTPPath } from '@orpc/contract';
|
9
9
|
import '@orpc/shared';
|
10
10
|
|
11
|
-
|
12
|
-
serializer?: RPCSerializer;
|
13
|
-
}
|
14
|
-
declare class RPCCodec implements StandardCodec {
|
11
|
+
declare class StandardRPCCodec implements StandardCodec {
|
15
12
|
private readonly serializer;
|
16
|
-
constructor(
|
13
|
+
constructor(serializer: StandardRPCSerializer);
|
17
14
|
decode(request: StandardLazyRequest, _params: StandardParams | undefined, _procedure: AnyProcedure): Promise<unknown>;
|
18
15
|
encode(output: unknown, _procedure: AnyProcedure): StandardResponse;
|
19
16
|
encodeError(error: ORPCError<any, any>): StandardResponse;
|
20
17
|
}
|
21
18
|
|
22
|
-
declare class
|
19
|
+
declare class StandardRPCMatcher implements StandardMatcher {
|
23
20
|
private readonly tree;
|
24
21
|
private pendingRouters;
|
25
|
-
init(router: AnyRouter, path?: string[]): void;
|
22
|
+
init(router: AnyRouter, path?: readonly string[]): void;
|
26
23
|
match(_method: string, pathname: HTTPPath): Promise<StandardMatchResult>;
|
27
24
|
}
|
28
25
|
|
29
|
-
export {
|
26
|
+
export { StandardCodec, StandardMatchResult, StandardMatcher, StandardParams, StandardRPCCodec, StandardRPCMatcher };
|
@@ -1,7 +1,5 @@
|
|
1
|
-
export {
|
1
|
+
export { S as StandardHandler, a as StandardRPCCodec, b as StandardRPCMatcher } from '../../shared/server.DnR6v9pj.mjs';
|
2
2
|
import '@orpc/client';
|
3
3
|
import '@orpc/shared';
|
4
|
-
import '../../shared/server.
|
5
|
-
import '../../shared/server.V6zT5iYQ.mjs';
|
4
|
+
import '../../shared/server.BtxZnWJ9.mjs';
|
6
5
|
import '@orpc/contract';
|
7
|
-
import '@orpc/client/standard';
|
package/dist/index.d.mts
CHANGED
@@ -1,117 +1,147 @@
|
|
1
|
-
import {
|
2
|
-
export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, HTTPMethod, HTTPPath, InputStructure, Meta,
|
3
|
-
import {
|
4
|
-
export {
|
1
|
+
import { AnySchema, ErrorMap, Meta, MergedErrorMap, Route, InferSchemaOutput, InferSchemaInput, EnhanceRouteOptions, AnyContractRouter, AnyContractProcedure, Schema, HTTPPath, ContractRouter, ContractProcedureDef, ContractProcedure, InferContractRouterErrorMap, InferContractRouterMeta, ErrorFromErrorMap } from '@orpc/contract';
|
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 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
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
meta(meta: TMeta): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>;
|
18
|
-
route(route: Route): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>;
|
19
|
-
use<U extends Context>(middleware: Middleware<TCurrentContext, U, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema, THandlerOutput>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, U>> & DecoratedProcedure<TInitialContext, MergedContext<TCurrentContext, U>, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>;
|
20
|
-
use<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, SchemaInput<TOutputSchema, THandlerOutput>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & DecoratedProcedure<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>;
|
11
|
+
declare class DecoratedProcedure<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> {
|
12
|
+
errors<U extends ErrorMap>(errors: U): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
13
|
+
meta(meta: TMeta): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
14
|
+
route(route: Route): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
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>;
|
21
17
|
/**
|
22
18
|
* Make this procedure callable (works like a function while still being a procedure).
|
23
19
|
*/
|
24
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema,
|
20
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
25
21
|
/**
|
26
22
|
* Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
|
27
23
|
*/
|
28
|
-
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema,
|
24
|
+
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, InferSchemaInput<TInputSchema>>) => Promise<InferSchemaOutput<TOutputSchema>>);
|
25
|
+
}
|
26
|
+
|
27
|
+
declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
|
28
|
+
type AccessibleLazyRouter<T extends Lazyable<AnyRouter | undefined>> = T extends Lazy<infer U extends AnyRouter | undefined | Lazy<AnyRouter | undefined>> ? AccessibleLazyRouter<U> : T extends AnyProcedure | undefined ? Lazy<T> : Lazy<T> & {
|
29
|
+
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? AccessibleLazyRouter<T[K]> : never;
|
30
|
+
};
|
31
|
+
declare function createAccessibleLazyRouter<T extends Lazy<AnyRouter | undefined>>(lazied: T): AccessibleLazyRouter<T>;
|
32
|
+
type EnhancedRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap> = T extends Lazy<infer U extends AnyRouter> ? AccessibleLazyRouter<EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>> : T extends Procedure<infer UInitialContext, infer UCurrentContext, infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? Procedure<MergedInitialContext<TInitialContext, UInitialContext, TCurrentContext>, UCurrentContext, UInputSchema, UOutputSchema, MergedErrorMap<TErrorMap, UErrorMap>, UMeta> : {
|
33
|
+
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? EnhancedRouter<T[K], TInitialContext, TCurrentContext, TErrorMap> : never;
|
34
|
+
};
|
35
|
+
interface EnhanceRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
|
36
|
+
middlewares: readonly AnyMiddleware[];
|
37
|
+
errorMap: TErrorMap;
|
38
|
+
dedupeLeadingMiddlewares: boolean;
|
39
|
+
}
|
40
|
+
declare function enhanceRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap>(router: T, options: EnhanceRouterOptions<TErrorMap>): EnhancedRouter<T, TInitialContext, TCurrentContext, TErrorMap>;
|
41
|
+
interface TraverseContractProceduresOptions {
|
42
|
+
router: AnyContractRouter | AnyRouter;
|
43
|
+
path: readonly string[];
|
29
44
|
}
|
45
|
+
interface ContractProcedureCallbackOptions {
|
46
|
+
contract: AnyContractProcedure;
|
47
|
+
path: readonly string[];
|
48
|
+
}
|
49
|
+
interface LazyTraverseContractProceduresOptions {
|
50
|
+
router: Lazy<AnyRouter>;
|
51
|
+
path: readonly string[];
|
52
|
+
}
|
53
|
+
declare function traverseContractProcedures(options: TraverseContractProceduresOptions, callback: (options: ContractProcedureCallbackOptions) => void, lazyOptions?: LazyTraverseContractProceduresOptions[]): LazyTraverseContractProceduresOptions[];
|
54
|
+
declare function resolveContractProcedures(options: TraverseContractProceduresOptions, callback: (options: ContractProcedureCallbackOptions) => void): Promise<void>;
|
55
|
+
type UnlaziedRouter<T extends AnyRouter> = T extends AnyProcedure ? T : {
|
56
|
+
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? UnlaziedRouter<U> : never;
|
57
|
+
};
|
58
|
+
declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedRouter<T>>;
|
30
59
|
|
31
|
-
interface BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
60
|
+
interface BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
32
61
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
33
62
|
'errors'<U extends ErrorMap>(errors: U): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
34
|
-
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, 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>;
|
35
64
|
'meta'(meta: TMeta): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
36
65
|
'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
37
|
-
'input'<USchema extends
|
38
|
-
'output'<USchema extends
|
39
|
-
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, unknown, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema,
|
66
|
+
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
67
|
+
'output'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
68
|
+
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, unknown, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
40
69
|
'prefix'(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
41
70
|
'tag'(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
42
|
-
'router'<U extends Router<
|
43
|
-
'lazy'<U extends Router<
|
71
|
+
'router'<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>;
|
72
|
+
'lazy'<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(loader: () => Promise<{
|
44
73
|
default: U;
|
45
|
-
}>):
|
74
|
+
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, TErrorMap>;
|
46
75
|
}
|
47
|
-
interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
76
|
+
interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
48
77
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
49
78
|
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
50
|
-
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, 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>;
|
51
80
|
'meta'(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
52
81
|
'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
53
|
-
'input'<USchema extends
|
54
|
-
'output'<USchema extends
|
55
|
-
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, unknown, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema,
|
82
|
+
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
83
|
+
'output'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
84
|
+
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, unknown, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
56
85
|
}
|
57
|
-
interface ProcedureBuilderWithInput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
86
|
+
interface ProcedureBuilderWithInput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
58
87
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
59
88
|
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
60
|
-
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext,
|
61
|
-
'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<
|
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>;
|
62
91
|
'meta'(meta: TMeta): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
63
92
|
'route'(route: Route): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
64
|
-
'output'<USchema extends
|
65
|
-
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext,
|
93
|
+
'output'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
94
|
+
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
66
95
|
}
|
67
|
-
interface ProcedureBuilderWithOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
96
|
+
interface ProcedureBuilderWithOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
68
97
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
69
98
|
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
70
|
-
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, unknown,
|
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>;
|
71
100
|
'meta'(meta: TMeta): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
72
101
|
'route'(route: Route): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
73
|
-
'input'<USchema extends
|
74
|
-
'handler'(handler: ProcedureHandler<TCurrentContext, unknown,
|
102
|
+
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
103
|
+
'handler'(handler: ProcedureHandler<TCurrentContext, unknown, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
75
104
|
}
|
76
|
-
interface ProcedureBuilderWithInputOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
105
|
+
interface ProcedureBuilderWithInputOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
77
106
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
78
107
|
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
79
|
-
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext,
|
80
|
-
'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, 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>;
|
81
110
|
'meta'(meta: TMeta): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
82
111
|
'route'(route: Route): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
83
|
-
'handler'(handler: ProcedureHandler<TCurrentContext,
|
112
|
+
'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
84
113
|
}
|
85
114
|
interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
86
|
-
'~orpc':
|
115
|
+
'~orpc': EnhanceRouterOptions<TErrorMap>;
|
87
116
|
'errors'<U extends ErrorMap>(errors: U): RouterBuilder<TInitialContext, TCurrentContext, MergedErrorMap<TErrorMap, U>, TMeta>;
|
88
|
-
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, 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>;
|
89
118
|
'prefix'(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
90
119
|
'tag'(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
91
|
-
'router'<U extends Router<
|
92
|
-
'lazy'<U extends Router<
|
120
|
+
'router'<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>;
|
121
|
+
'lazy'<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(loader: () => Promise<{
|
93
122
|
default: U;
|
94
|
-
}>):
|
123
|
+
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, TErrorMap>;
|
95
124
|
}
|
96
125
|
|
97
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> {
|
98
|
-
|
99
|
-
concat<UOutContext extends Context,
|
100
|
-
|
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 | 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>;
|
101
130
|
}
|
102
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>;
|
103
132
|
|
104
133
|
interface BuilderConfig {
|
105
134
|
initialInputValidationIndex?: number;
|
106
135
|
initialOutputValidationIndex?: number;
|
136
|
+
dedupeLeadingMiddlewares?: boolean;
|
107
137
|
}
|
108
|
-
interface BuilderDef<TInputSchema extends
|
109
|
-
middlewares: AnyMiddleware[];
|
138
|
+
interface BuilderDef<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>, EnhanceRouterOptions<TErrorMap> {
|
139
|
+
middlewares: readonly AnyMiddleware[];
|
110
140
|
inputValidationIndex: number;
|
111
141
|
outputValidationIndex: number;
|
112
142
|
config: BuilderConfig;
|
113
143
|
}
|
114
|
-
declare class Builder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
144
|
+
declare class Builder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
115
145
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
116
146
|
constructor(def: BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>);
|
117
147
|
/**
|
@@ -121,100 +151,107 @@ declare class Builder<TInitialContext extends Context, TCurrentContext extends C
|
|
121
151
|
/**
|
122
152
|
* Reset initial context
|
123
153
|
*/
|
124
|
-
$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>;
|
125
155
|
/**
|
126
156
|
* Reset initial meta
|
127
157
|
*/
|
128
|
-
$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>>;
|
129
159
|
/**
|
130
160
|
* Reset initial route
|
131
161
|
*/
|
132
162
|
$route(initialRoute: Route): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
163
|
+
$input<U extends AnySchema>(initialInputSchema?: U): Builder<TInitialContext, TCurrentContext, U, TOutputSchema, TErrorMap, TMeta>;
|
133
164
|
middleware<UOutContext extends Context, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
134
|
-
middleware: Middleware<
|
165
|
+
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, TMeta>;
|
135
166
|
errors<U extends ErrorMap>(errors: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
136
|
-
use<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>):
|
137
|
-
use<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<unknown, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & BuilderWithMiddlewares<TInitialContext, MergedContext<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>;
|
138
168
|
meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
139
169
|
route(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
140
|
-
input<USchema extends
|
141
|
-
output<USchema extends
|
142
|
-
handler<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, unknown, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema,
|
170
|
+
input<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
171
|
+
output<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
172
|
+
handler<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, unknown, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
143
173
|
prefix(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
144
174
|
tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
145
|
-
router<U extends Router<
|
146
|
-
lazy<U extends Router<
|
175
|
+
router<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>;
|
176
|
+
lazy<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(loader: () => Promise<{
|
147
177
|
default: U;
|
148
|
-
}>):
|
178
|
+
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, TErrorMap>;
|
149
179
|
}
|
150
|
-
declare const os: Builder<
|
180
|
+
declare const os: Builder<Record<never, never>, Record<never, never>, Schema<unknown, unknown>, Schema<unknown, unknown>, Record<never, never>, Record<never, never>>;
|
151
181
|
|
152
182
|
interface Config {
|
153
183
|
initialInputValidationIndex: number;
|
154
184
|
initialOutputValidationIndex: number;
|
185
|
+
dedupeLeadingMiddlewares: boolean;
|
155
186
|
}
|
156
187
|
declare function fallbackConfig<T extends keyof Config>(key: T, value?: Config[T]): Config[T];
|
157
188
|
|
158
|
-
declare function setRouterContract<T extends AnyRouter>(obj: T, contract: AnyContractRouter): T;
|
159
|
-
declare function getRouterContract(obj: object): ContractRouter<any> | undefined;
|
160
|
-
declare function deepSetLazyRouterPrefix<T extends Lazy<any>>(router: T, prefix: HTTPPath): T;
|
161
|
-
declare function getLazyRouterPrefix(obj: object): HTTPPath | undefined;
|
162
|
-
|
163
189
|
/**
|
164
190
|
* Like `DecoratedProcedure`, but removed all method that can change the contract.
|
165
191
|
*/
|
166
|
-
interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
167
|
-
use<
|
168
|
-
use<UOutContext extends
|
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> {
|
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>;
|
169
195
|
/**
|
170
196
|
* Make this procedure callable (works like a function while still being a procedure).
|
171
197
|
*/
|
172
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema,
|
198
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
173
199
|
/**
|
174
200
|
* Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
|
175
201
|
*/
|
176
|
-
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema,
|
202
|
+
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, InferSchemaInput<TInputSchema>>) => Promise<InferSchemaOutput<TOutputSchema>>);
|
177
203
|
}
|
178
204
|
/**
|
179
205
|
* Like `ProcedureBuilderWithoutHandler`, but removed all method that can change the contract.
|
180
206
|
*/
|
181
|
-
interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
207
|
+
interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
182
208
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
183
|
-
'use'<
|
184
|
-
'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput,
|
185
|
-
'handler'(handler: ProcedureHandler<TCurrentContext,
|
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>;
|
211
|
+
'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
186
212
|
}
|
187
213
|
|
188
|
-
interface RouterImplementerWithMiddlewares<
|
189
|
-
use<
|
190
|
-
router<U extends Router<
|
191
|
-
lazy<U extends Router<
|
214
|
+
interface RouterImplementerWithMiddlewares<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
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>>;
|
216
|
+
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
217
|
+
lazy<U extends Router<T, TInitialContext>>(loader: () => Promise<{
|
192
218
|
default: U;
|
193
|
-
}>):
|
219
|
+
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, Record<never, never>>;
|
194
220
|
}
|
195
221
|
type ImplementerInternalWithMiddlewares<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = (TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? ProcedureImplementer<TInitialContext, TCurrentContext, UInputSchema, UOutputSchema, UErrorMap, UMeta> : RouterImplementerWithMiddlewares<TContract, TInitialContext, TCurrentContext> & {
|
196
222
|
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternalWithMiddlewares<TContract[K], TInitialContext, TCurrentContext> : never;
|
197
223
|
});
|
198
224
|
|
199
|
-
interface RouterImplementer<
|
225
|
+
interface RouterImplementer<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
200
226
|
middleware<UOutContext extends Context, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
201
|
-
middleware: Middleware<
|
202
|
-
use<
|
203
|
-
router<U extends Router<
|
204
|
-
lazy<U extends Router<
|
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>>;
|
229
|
+
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
230
|
+
lazy<U extends Router<T, TCurrentContext>>(loader: () => Promise<{
|
205
231
|
default: U;
|
206
|
-
}>):
|
232
|
+
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, Record<never, never>>;
|
207
233
|
}
|
208
234
|
type ImplementerInternal<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = (TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? ProcedureImplementer<TInitialContext, TCurrentContext, UInputSchema, UOutputSchema, UErrorMap, UMeta> : RouterImplementer<TContract, TInitialContext, TCurrentContext> & {
|
209
235
|
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternal<TContract[K], TInitialContext, TCurrentContext> : never;
|
210
236
|
});
|
211
|
-
declare function implementerInternal<
|
237
|
+
declare function implementerInternal<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context>(contract: T, config: BuilderConfig, middlewares: AnyMiddleware[]): ImplementerInternal<T, TInitialContext, TCurrentContext>;
|
212
238
|
type Implementer<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = {
|
213
|
-
$context<U extends Context>(): Implementer<TContract, U, U>;
|
239
|
+
$context<U extends Context>(): Implementer<TContract, U & Record<never, never>, U>;
|
214
240
|
$config(config: BuilderConfig): Implementer<TContract, TInitialContext, TCurrentContext>;
|
215
241
|
} & ImplementerInternal<TContract, TInitialContext, TCurrentContext>;
|
216
|
-
declare function implement<
|
242
|
+
declare function implement<T extends AnyContractRouter, TContext extends Context = Record<never, never>>(contract: T, config?: BuilderConfig): Implementer<T, TContext, TContext>;
|
243
|
+
|
244
|
+
declare function isStartWithMiddlewares(middlewares: readonly AnyMiddleware[], compare: readonly AnyMiddleware[]): boolean;
|
245
|
+
declare function mergeMiddlewares(first: readonly AnyMiddleware[], second: readonly AnyMiddleware[], options: {
|
246
|
+
dedupeLeading: boolean;
|
247
|
+
}): readonly AnyMiddleware[];
|
248
|
+
declare function addMiddleware(middlewares: readonly AnyMiddleware[], addition: AnyMiddleware): AnyMiddleware[];
|
217
249
|
|
250
|
+
declare function createAssertedLazyProcedure(lazied: Lazy<any>): Lazy<AnyProcedure>;
|
251
|
+
/**
|
252
|
+
* Create a new procedure that ensure the contract is applied to the procedure.
|
253
|
+
*/
|
254
|
+
declare function createContractedProcedure(procedure: AnyProcedure, contract: AnyContractProcedure): AnyProcedure;
|
218
255
|
/**
|
219
256
|
* Directly call a procedure without creating a client.
|
220
257
|
*
|
@@ -225,31 +262,16 @@ declare function implement<TContract extends AnyContractRouter, TInitialContext
|
|
225
262
|
* ```
|
226
263
|
*
|
227
264
|
*/
|
228
|
-
declare function call<TInitialContext extends Context, TInputSchema extends
|
265
|
+
declare function call<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta>(procedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, input: InferSchemaInput<TInputSchema>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, Record<never, never>>>): ClientPromiseResult<InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
|
229
266
|
|
230
|
-
type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends
|
231
|
-
[K in keyof TRouter]: TRouter[K] extends AnyRouter ? RouterClient<
|
267
|
+
type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UErrorMap, any> ? ProcedureClient<TClientContext, UInputSchema, UOutputSchema, UErrorMap> : {
|
268
|
+
[K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
|
232
269
|
};
|
233
|
-
declare function createRouterClient<
|
270
|
+
declare function createRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>, Schema<unknown, unknown>, Schema<unknown, unknown>, ErrorMap, Meta, TClientContext>>): RouterClient<T, TClientContext>;
|
234
271
|
|
235
|
-
|
236
|
-
|
237
|
-
|
238
|
-
|
239
|
-
interface EachContractProcedureCallbackOptions {
|
240
|
-
contract: AnyContractProcedure;
|
241
|
-
path: string[];
|
242
|
-
}
|
243
|
-
interface EachContractProcedureLaziedOptions {
|
244
|
-
lazied: Lazy<AnyProcedure> | Lazy<Record<string, AnyRouter> | AnyProcedure>;
|
245
|
-
path: string[];
|
246
|
-
}
|
247
|
-
declare function eachContractProcedure(options: EachContractProcedureOptions, callback: (options: EachContractProcedureCallbackOptions) => void, laziedOptions?: EachContractProcedureLaziedOptions[]): EachContractProcedureLaziedOptions[];
|
248
|
-
declare function eachAllContractProcedure(options: EachContractProcedureOptions, callback: (options: EachContractProcedureCallbackOptions) => void): Promise<void>;
|
249
|
-
declare function convertPathToHttpPath(path: string[]): HTTPPath;
|
250
|
-
/**
|
251
|
-
* Create a new procedure that ensure the contract is applied to the procedure.
|
252
|
-
*/
|
253
|
-
declare function createContractedProcedure(contract: AnyContractProcedure, procedure: AnyProcedure): AnyProcedure;
|
272
|
+
declare function setHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: AnyContractRouter): T;
|
273
|
+
declare function getHiddenRouterContract(router: Lazyable<AnyRouter | AnyContractRouter>): AnyContractRouter | undefined;
|
274
|
+
|
275
|
+
declare function toHttpPath(path: readonly string[]): HTTPPath;
|
254
276
|
|
255
|
-
export {
|
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 };
|