@orpc/server 0.0.0-next.1b15515 → 0.0.0-next.1d3318c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/fetch/index.d.mts +4 -5
- package/dist/adapters/fetch/index.d.ts +4 -5
- package/dist/adapters/fetch/index.mjs +4 -4
- package/dist/adapters/hono/index.d.mts +2 -3
- package/dist/adapters/hono/index.d.ts +2 -3
- package/dist/adapters/hono/index.mjs +4 -4
- package/dist/adapters/next/index.d.mts +2 -3
- package/dist/adapters/next/index.d.ts +2 -3
- package/dist/adapters/next/index.mjs +4 -4
- package/dist/adapters/node/index.d.mts +4 -5
- package/dist/adapters/node/index.d.ts +4 -5
- package/dist/adapters/node/index.mjs +12 -9
- package/dist/adapters/standard/index.d.mts +8 -12
- package/dist/adapters/standard/index.d.ts +8 -12
- package/dist/adapters/standard/index.mjs +2 -3
- package/dist/index.d.mts +113 -103
- package/dist/index.d.ts +113 -103
- package/dist/index.mjs +31 -25
- package/dist/plugins/index.d.mts +6 -6
- package/dist/plugins/index.d.ts +6 -6
- package/dist/shared/{server.BBGuTxHE.mjs → server.3cSam35R.mjs} +11 -16
- package/dist/shared/{server.V6zT5iYQ.mjs → server.BFBhsdJr.mjs} +118 -152
- package/dist/shared/{server.D86dtDX_.d.mts → server.BZRSVRDu.d.ts} +14 -14
- package/dist/shared/server.CPteJIPP.d.mts +143 -0
- package/dist/shared/server.CPteJIPP.d.ts +143 -0
- package/dist/shared/server.CjB_m7jG.mjs +28 -0
- package/dist/shared/{server.dPmfqnQI.d.ts → server.iM8li30u.d.mts} +14 -14
- package/package.json +7 -7
- package/dist/shared/server.B_cAGti1.d.mts +0 -9
- package/dist/shared/server.CUE4Aija.mjs +0 -24
- package/dist/shared/server.Cn9ybJtE.d.mts +0 -152
- package/dist/shared/server.Cn9ybJtE.d.ts +0 -152
- package/dist/shared/server.CynXWJja.d.ts +0 -9
package/dist/index.d.mts
CHANGED
@@ -1,97 +1,121 @@
|
|
1
|
-
import {
|
2
|
-
export { ValidationError, eventIterator, type } from '@orpc/contract';
|
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, ORPCErrorFromErrorMap, 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 ConflictContextGuard, d as MergedContext, 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.CPteJIPP.mjs';
|
4
|
+
export { E as InferRouterCurrentContexts, D as InferRouterInitialContexts, F as InferRouterInputs, G as InferRouterOutputs, k as LAZY_SYMBOL, l as LazyMeta, s as MiddlewareNextFn, r as MiddlewareNextFnOptions, v as MiddlewareOptions, t as MiddlewareOutputFn, q as MiddlewareResult, P as ProcedureClientInterceptorOptions, y as ProcedureDef, x as ProcedureHandlerOptions, B as createProcedureClient, p as getLazyMeta, o as isLazy, z as isProcedure, n as lazy, m as mergeContext, w as middlewareOutputFn, u as unlazy } from './shared/server.CPteJIPP.mjs';
|
5
5
|
import { ClientContext, ClientRest, ClientPromiseResult } from '@orpc/client';
|
6
6
|
export { ORPCError, isDefinedError, safe } from '@orpc/client';
|
7
7
|
import { 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<U extends Context>(middleware: Middleware<TCurrentContext, U, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, U>> & DecoratedProcedure<TInitialContext, MergedContext<TCurrentContext, U>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
16
|
+
use<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & DecoratedProcedure<TInitialContext, MergedContext<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>>): Procedure<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>>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, InferSchemaInput<TInputSchema>>) => Promise<InferSchemaOutput<TOutputSchema>>);
|
29
25
|
}
|
30
26
|
|
31
|
-
|
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, TErrorMap extends ErrorMap> = T extends Lazy<infer U extends AnyRouter> ? AccessibleLazyRouter<EnhancedRouter<U, TInitialContext, TErrorMap>> : T extends Procedure<any, infer UCurrentContext, infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, UCurrentContext, UInputSchema, UOutputSchema, MergedErrorMap<TErrorMap, UErrorMap>, UMeta> : {
|
33
|
+
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? EnhancedRouter<T[K], TInitialContext, TErrorMap> : never;
|
34
|
+
};
|
35
|
+
interface EnhanceRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
|
36
|
+
middlewares: readonly AnyMiddleware[];
|
37
|
+
errorMap: TErrorMap;
|
38
|
+
}
|
39
|
+
declare function enhanceRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TErrorMap extends ErrorMap>(router: T, options: EnhanceRouterOptions<TErrorMap>): EnhancedRouter<T, TInitialContext, TErrorMap>;
|
40
|
+
interface TraverseContractProceduresOptions {
|
41
|
+
router: AnyContractRouter | AnyRouter;
|
42
|
+
path: readonly string[];
|
43
|
+
}
|
44
|
+
interface ContractProcedureCallbackOptions {
|
45
|
+
contract: AnyContractProcedure;
|
46
|
+
path: readonly string[];
|
47
|
+
}
|
48
|
+
interface LazyTraverseContractProceduresOptions {
|
49
|
+
router: Lazy<AnyRouter>;
|
50
|
+
path: readonly string[];
|
51
|
+
}
|
52
|
+
declare function traverseContractProcedures(options: TraverseContractProceduresOptions, callback: (options: ContractProcedureCallbackOptions) => void, lazyOptions?: LazyTraverseContractProceduresOptions[]): LazyTraverseContractProceduresOptions[];
|
53
|
+
declare function resolveContractProcedures(options: TraverseContractProceduresOptions, callback: (options: ContractProcedureCallbackOptions) => void): Promise<void>;
|
54
|
+
|
55
|
+
interface BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
32
56
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
33
57
|
'errors'<U extends ErrorMap>(errors: U): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
34
58
|
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & BuilderWithMiddlewares<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
35
59
|
'meta'(meta: TMeta): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
36
60
|
'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,
|
61
|
+
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
62
|
+
'output'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
63
|
+
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, unknown, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
40
64
|
'prefix'(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
41
65
|
'tag'(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
42
|
-
'router'<U extends Router<
|
43
|
-
'lazy'<U extends Router<
|
66
|
+
'router'<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TErrorMap>;
|
67
|
+
'lazy'<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(loader: () => Promise<{
|
44
68
|
default: U;
|
45
|
-
}>):
|
69
|
+
}>): EnhancedRouter<Lazy<U>, TInitialContext, TErrorMap>;
|
46
70
|
}
|
47
|
-
interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
71
|
+
interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
48
72
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
49
73
|
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
50
74
|
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilder<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
51
75
|
'meta'(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
52
76
|
'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,
|
77
|
+
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
78
|
+
'output'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
79
|
+
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, unknown, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
56
80
|
}
|
57
|
-
interface ProcedureBuilderWithInput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
81
|
+
interface ProcedureBuilderWithInput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
58
82
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
59
83
|
'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<
|
84
|
+
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
85
|
+
'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
62
86
|
'meta'(meta: TMeta): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
63
87
|
'route'(route: Route): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
64
|
-
'output'<USchema extends
|
65
|
-
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext,
|
88
|
+
'output'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
89
|
+
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
66
90
|
}
|
67
|
-
interface ProcedureBuilderWithOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
91
|
+
interface ProcedureBuilderWithOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
68
92
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
69
93
|
'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,
|
94
|
+
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, unknown, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithOutput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
71
95
|
'meta'(meta: TMeta): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
72
96
|
'route'(route: Route): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
73
|
-
'input'<USchema extends
|
74
|
-
'handler'(handler: ProcedureHandler<TCurrentContext, unknown,
|
97
|
+
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
98
|
+
'handler'(handler: ProcedureHandler<TCurrentContext, unknown, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
75
99
|
}
|
76
|
-
interface ProcedureBuilderWithInputOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
100
|
+
interface ProcedureBuilderWithInputOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
77
101
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
78
102
|
'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,
|
103
|
+
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInputOutput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
104
|
+
'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInputOutput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
81
105
|
'meta'(meta: TMeta): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
82
106
|
'route'(route: Route): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
83
|
-
'handler'(handler: ProcedureHandler<TCurrentContext,
|
107
|
+
'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
84
108
|
}
|
85
109
|
interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
86
|
-
'~orpc':
|
110
|
+
'~orpc': EnhanceRouterOptions<TErrorMap>;
|
87
111
|
'errors'<U extends ErrorMap>(errors: U): RouterBuilder<TInitialContext, TCurrentContext, MergedErrorMap<TErrorMap, U>, TMeta>;
|
88
112
|
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & RouterBuilder<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TErrorMap, TMeta>;
|
89
113
|
'prefix'(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
90
114
|
'tag'(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
91
|
-
'router'<U extends Router<
|
92
|
-
'lazy'<U extends Router<
|
115
|
+
'router'<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TErrorMap>;
|
116
|
+
'lazy'<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(loader: () => Promise<{
|
93
117
|
default: U;
|
94
|
-
}>):
|
118
|
+
}>): EnhancedRouter<Lazy<U>, TInitialContext, TErrorMap>;
|
95
119
|
}
|
96
120
|
|
97
121
|
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> {
|
@@ -105,13 +129,13 @@ interface BuilderConfig {
|
|
105
129
|
initialInputValidationIndex?: number;
|
106
130
|
initialOutputValidationIndex?: number;
|
107
131
|
}
|
108
|
-
interface BuilderDef<TInputSchema extends
|
132
|
+
interface BuilderDef<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>, EnhanceRouterOptions<TErrorMap> {
|
109
133
|
middlewares: AnyMiddleware[];
|
110
134
|
inputValidationIndex: number;
|
111
135
|
outputValidationIndex: number;
|
112
136
|
config: BuilderConfig;
|
113
137
|
}
|
114
|
-
declare class Builder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
138
|
+
declare class Builder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
115
139
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
116
140
|
constructor(def: BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>);
|
117
141
|
/**
|
@@ -130,6 +154,7 @@ declare class Builder<TInitialContext extends Context, TCurrentContext extends C
|
|
130
154
|
* Reset initial route
|
131
155
|
*/
|
132
156
|
$route(initialRoute: Route): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
157
|
+
$input<U extends AnySchema>(initialInputSchema?: U): Builder<TInitialContext, TCurrentContext, U, TOutputSchema, TErrorMap, TMeta>;
|
133
158
|
middleware<UOutContext extends Context, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
134
159
|
middleware: Middleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): DecoratedMiddleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<any>, TMeta>;
|
135
160
|
errors<U extends ErrorMap>(errors: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
@@ -137,17 +162,17 @@ declare class Builder<TInitialContext extends Context, TCurrentContext extends C
|
|
137
162
|
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>;
|
138
163
|
meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
139
164
|
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,
|
165
|
+
input<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
166
|
+
output<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
167
|
+
handler<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, unknown, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
143
168
|
prefix(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
144
169
|
tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
145
|
-
router<U extends Router<
|
146
|
-
lazy<U extends Router<
|
170
|
+
router<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TErrorMap>;
|
171
|
+
lazy<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(loader: () => Promise<{
|
147
172
|
default: U;
|
148
|
-
}>):
|
173
|
+
}>): EnhancedRouter<Lazy<U>, TInitialContext, TErrorMap>;
|
149
174
|
}
|
150
|
-
declare const os: Builder<
|
175
|
+
declare const os: Builder<Record<never, never>, Record<never, never>, Schema<unknown, unknown>, Schema<unknown, unknown>, Record<never, never>, Record<never, never>>;
|
151
176
|
|
152
177
|
interface Config {
|
153
178
|
initialInputValidationIndex: number;
|
@@ -155,66 +180,66 @@ interface Config {
|
|
155
180
|
}
|
156
181
|
declare function fallbackConfig<T extends keyof Config>(key: T, value?: Config[T]): Config[T];
|
157
182
|
|
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
183
|
/**
|
164
184
|
* Like `DecoratedProcedure`, but removed all method that can change the contract.
|
165
185
|
*/
|
166
|
-
interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
167
|
-
use<U extends Context>(middleware: Middleware<TCurrentContext, U,
|
168
|
-
use<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput,
|
186
|
+
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> {
|
187
|
+
use<U extends Context>(middleware: Middleware<TCurrentContext, U, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, U>> & DecoratedProcedure<TInitialContext, MergedContext<TCurrentContext, U>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
188
|
+
use<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & DecoratedProcedure<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
169
189
|
/**
|
170
190
|
* Make this procedure callable (works like a function while still being a procedure).
|
171
191
|
*/
|
172
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema,
|
192
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
173
193
|
/**
|
174
194
|
* Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
|
175
195
|
*/
|
176
|
-
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema,
|
196
|
+
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, InferSchemaInput<TInputSchema>>) => Promise<InferSchemaOutput<TOutputSchema>>);
|
177
197
|
}
|
178
198
|
/**
|
179
199
|
* Like `ProcedureBuilderWithoutHandler`, but removed all method that can change the contract.
|
180
200
|
*/
|
181
|
-
interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
201
|
+
interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
182
202
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
183
|
-
'use'<U extends Context>(middleware: Middleware<TCurrentContext, U,
|
184
|
-
'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput,
|
185
|
-
'handler'(handler: ProcedureHandler<TCurrentContext,
|
203
|
+
'use'<U extends Context>(middleware: Middleware<TCurrentContext, U, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, U>> & ProcedureImplementer<TInitialContext, MergedContext<TCurrentContext, U>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
204
|
+
'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureImplementer<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
205
|
+
'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
186
206
|
}
|
187
207
|
|
188
|
-
interface RouterImplementerWithMiddlewares<
|
189
|
-
use<U extends Context>(middleware: Middleware<TCurrentContext, U, unknown, unknown, ORPCErrorConstructorMap<
|
190
|
-
router<U extends Router<
|
191
|
-
lazy<U extends Router<
|
208
|
+
interface RouterImplementerWithMiddlewares<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
209
|
+
use<U extends Context>(middleware: Middleware<TCurrentContext, U, unknown, unknown, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): ConflictContextGuard<MergedContext<TCurrentContext, U>> & ImplementerInternalWithMiddlewares<T, TInitialContext, MergedContext<TCurrentContext, U>>;
|
210
|
+
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, Record<never, never>>;
|
211
|
+
lazy<U extends Router<T, TInitialContext>>(loader: () => Promise<{
|
192
212
|
default: U;
|
193
|
-
}>):
|
213
|
+
}>): EnhancedRouter<Lazy<U>, TInitialContext, Record<never, never>>;
|
194
214
|
}
|
195
215
|
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
216
|
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternalWithMiddlewares<TContract[K], TInitialContext, TCurrentContext> : never;
|
197
217
|
});
|
198
218
|
|
199
|
-
interface RouterImplementer<
|
219
|
+
interface RouterImplementer<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
200
220
|
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<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<
|
202
|
-
use<U extends Context>(middleware: Middleware<TCurrentContext, U, unknown, unknown, ORPCErrorConstructorMap<
|
203
|
-
router<U extends Router<
|
204
|
-
lazy<U extends Router<
|
221
|
+
middleware: Middleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): DecoratedMiddleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<any>, InferContractRouterMeta<T>>;
|
222
|
+
use<U extends Context>(middleware: Middleware<TCurrentContext, U, unknown, unknown, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): ConflictContextGuard<MergedContext<TCurrentContext, U>> & ImplementerInternalWithMiddlewares<T, TInitialContext, MergedContext<TCurrentContext, U>>;
|
223
|
+
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, Record<never, never>>;
|
224
|
+
lazy<U extends Router<T, TCurrentContext>>(loader: () => Promise<{
|
205
225
|
default: U;
|
206
|
-
}>):
|
226
|
+
}>): EnhancedRouter<Lazy<U>, TInitialContext, Record<never, never>>;
|
207
227
|
}
|
208
228
|
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
229
|
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternal<TContract[K], TInitialContext, TCurrentContext> : never;
|
210
230
|
});
|
211
|
-
declare function implementerInternal<
|
231
|
+
declare function implementerInternal<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context>(contract: T, config: BuilderConfig, middlewares: AnyMiddleware[]): ImplementerInternal<T, TInitialContext, TCurrentContext>;
|
212
232
|
type Implementer<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = {
|
213
233
|
$context<U extends Context>(): Implementer<TContract, U, U>;
|
214
234
|
$config(config: BuilderConfig): Implementer<TContract, TInitialContext, TCurrentContext>;
|
215
235
|
} & ImplementerInternal<TContract, TInitialContext, TCurrentContext>;
|
216
236
|
declare function implement<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context>(contract: TContract, config?: BuilderConfig): Implementer<TContract, TInitialContext, TCurrentContext>;
|
217
237
|
|
238
|
+
declare function createAssertedLazyProcedure(lazied: Lazy<any>): Lazy<AnyProcedure>;
|
239
|
+
/**
|
240
|
+
* Create a new procedure that ensure the contract is applied to the procedure.
|
241
|
+
*/
|
242
|
+
declare function createContractedProcedure(procedure: AnyProcedure, contract: AnyContractProcedure): AnyProcedure;
|
218
243
|
/**
|
219
244
|
* Directly call a procedure without creating a client.
|
220
245
|
*
|
@@ -225,31 +250,16 @@ declare function implement<TContract extends AnyContractRouter, TInitialContext
|
|
225
250
|
* ```
|
226
251
|
*
|
227
252
|
*/
|
228
|
-
declare function call<TInitialContext extends Context, TInputSchema extends
|
253
|
+
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
254
|
|
230
|
-
type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends
|
231
|
-
[K in keyof TRouter]: TRouter[K] extends AnyRouter ? RouterClient<
|
255
|
+
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> : {
|
256
|
+
[K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
|
232
257
|
};
|
233
|
-
declare function createRouterClient<
|
258
|
+
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
259
|
|
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;
|
260
|
+
declare function setHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: AnyContractRouter): T;
|
261
|
+
declare function getHiddenRouterContract(router: Lazyable<AnyRouter | AnyContractRouter>): AnyContractRouter | undefined;
|
262
|
+
|
263
|
+
declare function toHttpPath(path: readonly string[]): HTTPPath;
|
254
264
|
|
255
|
-
export {
|
265
|
+
export { type AccessibleLazyRouter, AnyMiddleware, AnyProcedure, AnyRouter, Builder, type BuilderConfig, type BuilderDef, type BuilderWithMiddlewares, type Config, ConflictContextGuard, 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, MergedContext, Middleware, Procedure, type ProcedureBuilder, type ProcedureBuilderWithInput, type ProcedureBuilderWithInputOutput, type ProcedureBuilderWithOutput, ProcedureClient, ProcedureHandler, type ProcedureImplementer, Router, type RouterBuilder, type RouterClient, type RouterImplementer, type RouterImplementerWithMiddlewares, type TraverseContractProceduresOptions, call, createAccessibleLazyRouter, createAssertedLazyProcedure, createContractedProcedure, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getHiddenRouterContract, getRouter, implement, implementerInternal, os, resolveContractProcedures, setHiddenRouterContract, toHttpPath, traverseContractProcedures };
|