@orpc/server 0.0.0-next.93e7a4c → 0.0.0-next.9486ab5
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 +131 -0
- package/dist/adapters/fetch/index.d.mts +54 -0
- package/dist/adapters/fetch/index.d.ts +54 -0
- package/dist/adapters/fetch/index.mjs +9 -0
- package/dist/adapters/hono/index.d.mts +22 -0
- package/dist/adapters/hono/index.d.ts +22 -0
- package/dist/adapters/hono/index.mjs +32 -0
- package/dist/adapters/next/index.d.mts +29 -0
- package/dist/adapters/next/index.d.ts +29 -0
- package/dist/adapters/next/index.mjs +29 -0
- package/dist/adapters/node/index.d.mts +53 -0
- package/dist/adapters/node/index.d.ts +53 -0
- package/dist/adapters/node/index.mjs +85 -0
- package/dist/adapters/standard/index.d.mts +26 -0
- package/dist/adapters/standard/index.d.ts +26 -0
- package/dist/adapters/standard/index.mjs +6 -0
- package/dist/index.d.mts +291 -0
- package/dist/index.d.ts +291 -0
- package/dist/index.mjs +363 -0
- package/dist/plugins/index.d.mts +30 -0
- package/dist/plugins/index.d.ts +30 -0
- package/dist/plugins/index.mjs +107 -0
- package/dist/shared/server.89QkKw3a.d.mts +10 -0
- package/dist/shared/server.B1S3zwuw.d.mts +8 -0
- package/dist/shared/server.BMkFIQUb.d.mts +66 -0
- package/dist/shared/server.BT0gne12.d.ts +8 -0
- package/dist/shared/server.BVwwTHyO.mjs +9 -0
- package/dist/shared/server.CjWkNG6l.mjs +370 -0
- package/dist/shared/server.D0YVcfZk.d.mts +143 -0
- package/dist/shared/server.D0YVcfZk.d.ts +143 -0
- package/dist/shared/server.D9QduY95.mjs +161 -0
- package/dist/shared/server.Et1O6Bm7.mjs +98 -0
- package/dist/shared/server.taqJyaMn.d.ts +10 -0
- package/dist/shared/server.ywWqDZgA.d.ts +66 -0
- package/package.json +43 -15
- package/dist/chunk-FN62GL22.js +0 -182
- package/dist/fetch.js +0 -286
- package/dist/index.js +0 -518
- package/dist/src/builder.d.ts +0 -35
- package/dist/src/fetch/composite-handler.d.ts +0 -8
- package/dist/src/fetch/index.d.ts +0 -6
- package/dist/src/fetch/orpc-handler.d.ts +0 -20
- package/dist/src/fetch/orpc-payload-codec.d.ts +0 -9
- package/dist/src/fetch/orpc-procedure-matcher.d.ts +0 -12
- package/dist/src/fetch/super-json.d.ts +0 -12
- package/dist/src/fetch/types.d.ts +0 -16
- package/dist/src/hidden.d.ts +0 -6
- package/dist/src/implementer-chainable.d.ts +0 -10
- package/dist/src/index.d.ts +0 -23
- package/dist/src/lazy-decorated.d.ts +0 -10
- package/dist/src/lazy-utils.d.ts +0 -4
- package/dist/src/lazy.d.ts +0 -18
- package/dist/src/middleware-decorated.d.ts +0 -8
- package/dist/src/middleware.d.ts +0 -23
- package/dist/src/procedure-builder.d.ts +0 -22
- package/dist/src/procedure-client.d.ts +0 -29
- package/dist/src/procedure-decorated.d.ts +0 -14
- package/dist/src/procedure-implementer.d.ts +0 -18
- package/dist/src/procedure.d.ts +0 -23
- package/dist/src/router-builder.d.ts +0 -29
- package/dist/src/router-client.d.ts +0 -25
- package/dist/src/router-implementer.d.ts +0 -21
- package/dist/src/router.d.ts +0 -16
- package/dist/src/types.d.ts +0 -12
- package/dist/src/utils.d.ts +0 -3
package/dist/index.d.ts
ADDED
@@ -0,0 +1,291 @@
|
|
1
|
+
import { ORPCErrorJSON, ORPCError, Client, ClientContext, HTTPPath, ClientPromiseResult } from '@orpc/client';
|
2
|
+
export { ORPCError, isDefinedError, safe } from '@orpc/client';
|
3
|
+
import { AnySchema, ErrorMap, InferSchemaInput, InferSchemaOutput, ErrorFromErrorMap, Meta, MergedErrorMap, Route, EnhanceRouteOptions, AnyContractRouter, AnyContractProcedure, Schema, ContractRouter, ContractProcedureDef, ContractProcedure, InferContractRouterErrorMap, InferContractRouterMeta } from '@orpc/contract';
|
4
|
+
export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, InputStructure, Meta, OutputStructure, Route, Schema, ValidationError, eventIterator, type } from '@orpc/contract';
|
5
|
+
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.D0YVcfZk.js';
|
6
|
+
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.D0YVcfZk.js';
|
7
|
+
import { IntersectPick, MaybeOptionalOptions } from '@orpc/shared';
|
8
|
+
export { onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
9
|
+
export { getEventMeta, withEventMeta } from '@orpc/standard-server';
|
10
|
+
|
11
|
+
type ActionableError<T extends Error> = T extends ORPCError<infer U, infer V> ? ORPCErrorJSON<U, V> & {
|
12
|
+
defined: true;
|
13
|
+
} : ORPCErrorJSON<string, unknown> & {
|
14
|
+
defined: false;
|
15
|
+
};
|
16
|
+
type UnactionableError<T> = T extends {
|
17
|
+
defined: true;
|
18
|
+
} & ORPCErrorJSON<infer U, infer V> ? ORPCError<U, V> : Error;
|
19
|
+
type ActionableClientRest<TInput> = [input: TInput] | (undefined extends TInput ? [input?: TInput] : [input: TInput]);
|
20
|
+
type ActionableClientResult<TOutput, TError extends ORPCErrorJSON<any, any>> = [error: null, data: TOutput] | [error: TError, data: undefined];
|
21
|
+
interface ActionableClient<TInput, TOutput, TError extends ORPCErrorJSON<any, any>> {
|
22
|
+
(...rest: ActionableClientRest<TInput>): Promise<ActionableClientResult<TOutput, TError>>;
|
23
|
+
}
|
24
|
+
type ProcedureActionableClient<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = ActionableClient<InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ActionableError<ErrorFromErrorMap<TErrorMap>>>;
|
25
|
+
declare function createActionableClient<TInput, TOutput, TError extends Error>(client: Client<Record<never, never>, TInput, TOutput, TError>): ActionableClient<TInput, TOutput, ActionableError<TError>>;
|
26
|
+
|
27
|
+
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> {
|
28
|
+
errors<U extends ErrorMap>(errors: U): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
29
|
+
meta(meta: TMeta): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
30
|
+
route(route: Route): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
31
|
+
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>;
|
32
|
+
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>;
|
33
|
+
/**
|
34
|
+
* Make this procedure callable (works like a function while still being a procedure).
|
35
|
+
*/
|
36
|
+
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>;
|
37
|
+
/**
|
38
|
+
* Make this procedure compatible with server action.
|
39
|
+
*/
|
40
|
+
actionable(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, Record<never, never>>>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureActionableClient<TInputSchema, TOutputSchema, TErrorMap>;
|
41
|
+
}
|
42
|
+
|
43
|
+
declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
|
44
|
+
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> & {
|
45
|
+
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? AccessibleLazyRouter<T[K]> : never;
|
46
|
+
};
|
47
|
+
declare function createAccessibleLazyRouter<T extends Lazy<AnyRouter | undefined>>(lazied: T): AccessibleLazyRouter<T>;
|
48
|
+
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> : {
|
49
|
+
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? EnhancedRouter<T[K], TInitialContext, TCurrentContext, TErrorMap> : never;
|
50
|
+
};
|
51
|
+
interface EnhanceRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
|
52
|
+
middlewares: readonly AnyMiddleware[];
|
53
|
+
errorMap: TErrorMap;
|
54
|
+
dedupeLeadingMiddlewares: boolean;
|
55
|
+
}
|
56
|
+
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>;
|
57
|
+
interface TraverseContractProceduresOptions {
|
58
|
+
router: AnyContractRouter | AnyRouter;
|
59
|
+
path: readonly string[];
|
60
|
+
}
|
61
|
+
interface ContractProcedureCallbackOptions {
|
62
|
+
contract: AnyContractProcedure;
|
63
|
+
path: readonly string[];
|
64
|
+
}
|
65
|
+
interface LazyTraverseContractProceduresOptions {
|
66
|
+
router: Lazy<AnyRouter>;
|
67
|
+
path: readonly string[];
|
68
|
+
}
|
69
|
+
declare function traverseContractProcedures(options: TraverseContractProceduresOptions, callback: (options: ContractProcedureCallbackOptions) => void, lazyOptions?: LazyTraverseContractProceduresOptions[]): LazyTraverseContractProceduresOptions[];
|
70
|
+
declare function resolveContractProcedures(options: TraverseContractProceduresOptions, callback: (options: ContractProcedureCallbackOptions) => void): Promise<void>;
|
71
|
+
type UnlaziedRouter<T extends AnyRouter> = T extends AnyProcedure ? T : {
|
72
|
+
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? UnlaziedRouter<U> : never;
|
73
|
+
};
|
74
|
+
declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedRouter<T>>;
|
75
|
+
|
76
|
+
interface BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
77
|
+
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
78
|
+
'errors'<U extends ErrorMap>(errors: U): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
79
|
+
'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>;
|
80
|
+
'meta'(meta: TMeta): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
81
|
+
'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
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>;
|
85
|
+
'prefix'(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
86
|
+
'tag'(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
87
|
+
'router'<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>;
|
88
|
+
'lazy'<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(loader: () => Promise<{
|
89
|
+
default: U;
|
90
|
+
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, TErrorMap>;
|
91
|
+
}
|
92
|
+
interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
93
|
+
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
94
|
+
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
95
|
+
'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>;
|
96
|
+
'meta'(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
97
|
+
'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
98
|
+
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
99
|
+
'output'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
100
|
+
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, unknown, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
101
|
+
}
|
102
|
+
interface ProcedureBuilderWithInput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
103
|
+
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
104
|
+
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
105
|
+
'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>;
|
106
|
+
'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>;
|
107
|
+
'meta'(meta: TMeta): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
108
|
+
'route'(route: Route): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
109
|
+
'output'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
110
|
+
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
111
|
+
}
|
112
|
+
interface ProcedureBuilderWithOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
113
|
+
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
114
|
+
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
115
|
+
'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>;
|
116
|
+
'meta'(meta: TMeta): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
117
|
+
'route'(route: Route): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
118
|
+
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
119
|
+
'handler'(handler: ProcedureHandler<TCurrentContext, unknown, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
120
|
+
}
|
121
|
+
interface ProcedureBuilderWithInputOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
122
|
+
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
123
|
+
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
124
|
+
'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>;
|
125
|
+
'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>;
|
126
|
+
'meta'(meta: TMeta): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
127
|
+
'route'(route: Route): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
128
|
+
'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
129
|
+
}
|
130
|
+
interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
131
|
+
'~orpc': EnhanceRouterOptions<TErrorMap>;
|
132
|
+
'errors'<U extends ErrorMap>(errors: U): RouterBuilder<TInitialContext, TCurrentContext, MergedErrorMap<TErrorMap, U>, TMeta>;
|
133
|
+
'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>;
|
134
|
+
'prefix'(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
135
|
+
'tag'(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
136
|
+
'router'<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>;
|
137
|
+
'lazy'<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(loader: () => Promise<{
|
138
|
+
default: U;
|
139
|
+
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, TErrorMap>;
|
140
|
+
}
|
141
|
+
|
142
|
+
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> {
|
143
|
+
mapInput<UInput>(map: MapInputMiddleware<UInput, TInput>): DecoratedMiddleware<TInContext, TOutContext, UInput, TOutput, TErrorConstructorMap, TMeta>;
|
144
|
+
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>;
|
145
|
+
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>;
|
146
|
+
}
|
147
|
+
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>;
|
148
|
+
|
149
|
+
interface BuilderConfig {
|
150
|
+
initialInputValidationIndex?: number;
|
151
|
+
initialOutputValidationIndex?: number;
|
152
|
+
dedupeLeadingMiddlewares?: boolean;
|
153
|
+
}
|
154
|
+
interface BuilderDef<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>, EnhanceRouterOptions<TErrorMap> {
|
155
|
+
middlewares: readonly AnyMiddleware[];
|
156
|
+
inputValidationIndex: number;
|
157
|
+
outputValidationIndex: number;
|
158
|
+
config: BuilderConfig;
|
159
|
+
}
|
160
|
+
declare class Builder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
161
|
+
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
162
|
+
constructor(def: BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>);
|
163
|
+
/**
|
164
|
+
* Reset config
|
165
|
+
*/
|
166
|
+
$config(config: BuilderConfig): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
167
|
+
/**
|
168
|
+
* Reset initial context
|
169
|
+
*/
|
170
|
+
$context<U extends Context>(): Builder<U & Record<never, never>, U, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
171
|
+
/**
|
172
|
+
* Reset initial meta
|
173
|
+
*/
|
174
|
+
$meta<U extends Meta>(initialMeta: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, U & Record<never, never>>;
|
175
|
+
/**
|
176
|
+
* Reset initial route
|
177
|
+
*/
|
178
|
+
$route(initialRoute: Route): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
179
|
+
$input<U extends AnySchema>(initialInputSchema?: U): Builder<TInitialContext, TCurrentContext, U, TOutputSchema, TErrorMap, TMeta>;
|
180
|
+
middleware<UOutContext extends Context, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
181
|
+
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, TMeta>;
|
182
|
+
errors<U extends ErrorMap>(errors: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
183
|
+
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>;
|
184
|
+
meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
185
|
+
route(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
186
|
+
input<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
187
|
+
output<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
188
|
+
handler<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, unknown, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
189
|
+
prefix(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
190
|
+
tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
191
|
+
router<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>;
|
192
|
+
lazy<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(loader: () => Promise<{
|
193
|
+
default: U;
|
194
|
+
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, TErrorMap>;
|
195
|
+
}
|
196
|
+
declare const os: Builder<Record<never, never>, Record<never, never>, Schema<unknown, unknown>, Schema<unknown, unknown>, Record<never, never>, Record<never, never>>;
|
197
|
+
|
198
|
+
interface Config {
|
199
|
+
initialInputValidationIndex: number;
|
200
|
+
initialOutputValidationIndex: number;
|
201
|
+
dedupeLeadingMiddlewares: boolean;
|
202
|
+
}
|
203
|
+
declare function fallbackConfig<T extends keyof Config>(key: T, value?: Config[T]): Config[T];
|
204
|
+
|
205
|
+
/**
|
206
|
+
* Like `DecoratedProcedure`, but removed all method that can change the contract.
|
207
|
+
*/
|
208
|
+
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> {
|
209
|
+
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>;
|
210
|
+
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>;
|
211
|
+
/**
|
212
|
+
* Make this procedure callable (works like a function while still being a procedure).
|
213
|
+
*/
|
214
|
+
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>;
|
215
|
+
/**
|
216
|
+
* Make this procedure compatible with server action.
|
217
|
+
*/
|
218
|
+
actionable(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, Record<never, never>>>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureActionableClient<TInputSchema, TOutputSchema, TErrorMap>;
|
219
|
+
}
|
220
|
+
/**
|
221
|
+
* Like `ProcedureBuilderWithoutHandler`, but removed all method that can change the contract.
|
222
|
+
*/
|
223
|
+
interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
224
|
+
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
225
|
+
'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>;
|
226
|
+
'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>;
|
227
|
+
'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
228
|
+
}
|
229
|
+
|
230
|
+
interface RouterImplementerWithMiddlewares<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
231
|
+
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>>;
|
232
|
+
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
233
|
+
lazy<U extends Router<T, TInitialContext>>(loader: () => Promise<{
|
234
|
+
default: U;
|
235
|
+
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, Record<never, never>>;
|
236
|
+
}
|
237
|
+
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> & {
|
238
|
+
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternalWithMiddlewares<TContract[K], TInitialContext, TCurrentContext> : never;
|
239
|
+
});
|
240
|
+
|
241
|
+
interface RouterImplementer<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
242
|
+
middleware<UOutContext extends Context, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
243
|
+
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, InferContractRouterMeta<T>>;
|
244
|
+
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>>;
|
245
|
+
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
246
|
+
lazy<U extends Router<T, TCurrentContext>>(loader: () => Promise<{
|
247
|
+
default: U;
|
248
|
+
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, Record<never, never>>;
|
249
|
+
}
|
250
|
+
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> & {
|
251
|
+
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternal<TContract[K], TInitialContext, TCurrentContext> : never;
|
252
|
+
});
|
253
|
+
declare function implementerInternal<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context>(contract: T, config: BuilderConfig, middlewares: AnyMiddleware[]): ImplementerInternal<T, TInitialContext, TCurrentContext>;
|
254
|
+
type Implementer<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = {
|
255
|
+
$context<U extends Context>(): Implementer<TContract, U & Record<never, never>, U>;
|
256
|
+
$config(config: BuilderConfig): Implementer<TContract, TInitialContext, TCurrentContext>;
|
257
|
+
} & ImplementerInternal<TContract, TInitialContext, TCurrentContext>;
|
258
|
+
declare function implement<T extends AnyContractRouter, TContext extends Context = Record<never, never>>(contract: T, config?: BuilderConfig): Implementer<T, TContext, TContext>;
|
259
|
+
|
260
|
+
declare function isStartWithMiddlewares(middlewares: readonly AnyMiddleware[], compare: readonly AnyMiddleware[]): boolean;
|
261
|
+
declare function mergeMiddlewares(first: readonly AnyMiddleware[], second: readonly AnyMiddleware[], options: {
|
262
|
+
dedupeLeading: boolean;
|
263
|
+
}): readonly AnyMiddleware[];
|
264
|
+
declare function addMiddleware(middlewares: readonly AnyMiddleware[], addition: AnyMiddleware): AnyMiddleware[];
|
265
|
+
|
266
|
+
declare function createAssertedLazyProcedure(lazied: Lazy<any>): Lazy<AnyProcedure>;
|
267
|
+
/**
|
268
|
+
* Create a new procedure that ensure the contract is applied to the procedure.
|
269
|
+
*/
|
270
|
+
declare function createContractedProcedure(procedure: AnyProcedure, contract: AnyContractProcedure): AnyProcedure;
|
271
|
+
/**
|
272
|
+
* Directly call a procedure without creating a client.
|
273
|
+
*
|
274
|
+
* @example
|
275
|
+
* ```ts
|
276
|
+
* const output = await call(getting, 'input')
|
277
|
+
* const output = await call(getting, 'input', { context: { db: 'postgres' } })
|
278
|
+
* ```
|
279
|
+
*
|
280
|
+
*/
|
281
|
+
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>>;
|
282
|
+
|
283
|
+
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> : {
|
284
|
+
[K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
|
285
|
+
};
|
286
|
+
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>;
|
287
|
+
|
288
|
+
declare function setHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: AnyContractRouter): T;
|
289
|
+
declare function getHiddenRouterContract(router: Lazyable<AnyRouter | AnyContractRouter>): AnyContractRouter | undefined;
|
290
|
+
|
291
|
+
export { type AccessibleLazyRouter, type ActionableClient, type ActionableClientRest, type ActionableClientResult, type ActionableError, 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 ProcedureActionableClient, type ProcedureBuilder, type ProcedureBuilderWithInput, type ProcedureBuilderWithInputOutput, type ProcedureBuilderWithOutput, ProcedureClient, ProcedureHandler, type ProcedureImplementer, Router, type RouterBuilder, type RouterClient, type RouterImplementer, type RouterImplementerWithMiddlewares, type TraverseContractProceduresOptions, type UnactionableError, type UnlaziedRouter, addMiddleware, call, createAccessibleLazyRouter, createActionableClient, createAssertedLazyProcedure, createContractedProcedure, createRouterClient, decorateMiddleware, enhanceRouter, fallbackConfig, getHiddenRouterContract, getRouter, implement, implementerInternal, isStartWithMiddlewares, mergeMiddlewares, os, resolveContractProcedures, setHiddenRouterContract, traverseContractProcedures, unlazyRouter };
|