@orpc/server 0.16.0 → 0.17.0
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/chunk-FN62GL22.js +182 -0
- package/dist/fetch.js +39 -39
- package/dist/index.js +366 -315
- package/dist/src/builder.d.ts +25 -43
- package/dist/src/fetch/handle-request.d.ts +7 -0
- package/dist/src/fetch/index.d.ts +2 -2
- package/dist/src/fetch/{handler.d.ts → orpc-handler.d.ts} +1 -1
- package/dist/src/fetch/types.d.ts +12 -12
- package/dist/src/hidden.d.ts +6 -0
- package/dist/src/implementer-chainable.d.ts +10 -0
- package/dist/src/index.d.ts +9 -3
- package/dist/src/lazy-decorated.d.ts +10 -0
- package/dist/src/lazy-utils.d.ts +4 -0
- package/dist/src/lazy.d.ts +6 -11
- package/dist/src/middleware-decorated.d.ts +8 -0
- package/dist/src/middleware.d.ts +3 -6
- package/dist/src/procedure-builder.d.ts +15 -24
- package/dist/src/procedure-client.d.ts +29 -0
- package/dist/src/procedure-decorated.d.ts +14 -0
- package/dist/src/procedure-implementer.d.ts +13 -17
- package/dist/src/procedure.d.ts +15 -24
- package/dist/src/router-builder.d.ts +23 -21
- package/dist/src/router-client.d.ts +25 -0
- package/dist/src/router-implementer.d.ts +17 -20
- package/dist/src/router.d.ts +11 -16
- package/dist/src/types.d.ts +6 -8
- package/package.json +6 -6
- package/dist/chunk-Z2PQ6UAM.js +0 -273
- package/dist/src/fetch/handle.d.ts +0 -7
- package/dist/src/procedure-caller.d.ts +0 -26
- package/dist/src/router-caller.d.ts +0 -25
package/dist/src/builder.d.ts
CHANGED
@@ -1,53 +1,35 @@
|
|
1
|
-
import type {
|
2
|
-
import type {
|
3
|
-
import type {
|
4
|
-
import type {
|
5
|
-
import type {
|
6
|
-
import
|
7
|
-
import {
|
1
|
+
import type { ANY_CONTRACT_PROCEDURE, ContractRouter, HTTPPath, RouteOptions, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
+
import type { FlattenLazy } from './lazy';
|
3
|
+
import type { Middleware } from './middleware';
|
4
|
+
import type { DecoratedMiddleware } from './middleware-decorated';
|
5
|
+
import type { Router } from './router';
|
6
|
+
import type { AdaptedRouter } from './router-builder';
|
7
|
+
import type { Context, MergeContext, WELL_CONTEXT } from './types';
|
8
|
+
import { type ChainableImplementer } from './implementer-chainable';
|
9
|
+
import { type ProcedureFunc } from './procedure';
|
8
10
|
import { ProcedureBuilder } from './procedure-builder';
|
9
|
-
import {
|
11
|
+
import { type DecoratedProcedure } from './procedure-decorated';
|
10
12
|
import { RouterBuilder } from './router-builder';
|
11
|
-
|
13
|
+
export interface BuilderDef<TContext extends Context, TExtraContext extends Context> {
|
14
|
+
middlewares?: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, unknown, any>[];
|
15
|
+
}
|
12
16
|
export declare class Builder<TContext extends Context, TExtraContext extends Context> {
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
* Self chainable
|
21
|
-
*/
|
22
|
-
context<UContext extends Context>(): IsEqual<UContext, Context> extends true ? Builder<TContext, TExtraContext> : Builder<UContext, TExtraContext>;
|
23
|
-
use<UExtraContext extends Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, unknown, unknown>): Builder<TContext, MergeContext<TExtraContext, UExtraContext>>;
|
24
|
-
use<UExtraContext extends Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>> | undefined = undefined, UMappedInput = unknown>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, UMappedInput, unknown>, mapInput: MapInputMiddleware<unknown, UMappedInput>): Builder<TContext, MergeContext<TExtraContext, UExtraContext>>;
|
25
|
-
/**
|
26
|
-
* Convert to ContractProcedureBuilder
|
27
|
-
*/
|
28
|
-
route(opts: RouteOptions): ProcedureBuilder<TContext, TExtraContext, undefined, undefined>;
|
17
|
+
'~type': "Builder";
|
18
|
+
'~orpc': BuilderDef<TContext, TExtraContext>;
|
19
|
+
constructor(def: BuilderDef<TContext, TExtraContext>);
|
20
|
+
context<UContext extends Context = WELL_CONTEXT>(): Builder<UContext, undefined>;
|
21
|
+
use<U extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, unknown, unknown>): Builder<TContext, MergeContext<TExtraContext, U>>;
|
22
|
+
middleware<UExtraContext extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined, TInput = unknown, TOutput = any>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, TInput, TOutput>): DecoratedMiddleware<MergeContext<TContext, TExtraContext>, UExtraContext, TInput, TOutput>;
|
23
|
+
route(route: RouteOptions): ProcedureBuilder<TContext, TExtraContext, undefined, undefined>;
|
29
24
|
input<USchema extends Schema = undefined>(schema: USchema, example?: SchemaInput<USchema>): ProcedureBuilder<TContext, TExtraContext, USchema, undefined>;
|
30
25
|
output<USchema extends Schema = undefined>(schema: USchema, example?: SchemaOutput<USchema>): ProcedureBuilder<TContext, TExtraContext, undefined, USchema>;
|
31
|
-
/**
|
32
|
-
* Convert to Procedure
|
33
|
-
*/
|
34
26
|
func<UFuncOutput = undefined>(func: ProcedureFunc<TContext, TExtraContext, undefined, undefined, UFuncOutput>): DecoratedProcedure<TContext, TExtraContext, undefined, undefined, UFuncOutput>;
|
35
|
-
/**
|
36
|
-
* Convert to ProcedureImplementer | RouterBuilder
|
37
|
-
*/
|
38
|
-
contract<UContract extends ContractProcedure<any, any> | ContractRouter>(contract: UContract): UContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema> ? ProcedureImplementer<TContext, TExtraContext, UInputSchema, UOutputSchema> : UContract extends ContractRouter ? ChainedRouterImplementer<TContext, UContract, TExtraContext> : never;
|
39
|
-
/**
|
40
|
-
* Create ExtendedMiddleware
|
41
|
-
*/
|
42
|
-
middleware<UExtraContext extends Context = undefined, TInput = unknown, TOutput = any>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, TInput, TOutput>): DecoratedMiddleware<MergeContext<TContext, TExtraContext>, UExtraContext, TInput, TOutput>;
|
43
27
|
prefix(prefix: HTTPPath): RouterBuilder<TContext, TExtraContext>;
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
*/
|
48
|
-
router<URouter extends Router<TContext>>(router: URouter): HandledRouter<URouter>;
|
49
|
-
lazy<U extends Router<TContext> | Procedure<TContext, any, any, any, any>>(loader: () => Promise<{
|
28
|
+
tag(...tags: string[]): RouterBuilder<TContext, TExtraContext>;
|
29
|
+
router<U extends Router<MergeContext<TContext, TExtraContext>, any>>(router: U): AdaptedRouter<TContext, U>;
|
30
|
+
lazy<U extends Router<MergeContext<TContext, TExtraContext>, any>>(loader: () => Promise<{
|
50
31
|
default: U;
|
51
|
-
}>):
|
32
|
+
}>): AdaptedRouter<TContext, FlattenLazy<U>>;
|
33
|
+
contract<U extends ANY_CONTRACT_PROCEDURE | ContractRouter>(contract: U): ChainableImplementer<TContext, TExtraContext, U>;
|
52
34
|
}
|
53
35
|
//# sourceMappingURL=builder.d.ts.map
|
@@ -0,0 +1,7 @@
|
|
1
|
+
import type { Context } from '../types';
|
2
|
+
import type { FetchHandler, FetchHandlerOptions } from './types';
|
3
|
+
export type HandleFetchRequestOptions<T extends Context> = FetchHandlerOptions<T> & {
|
4
|
+
handlers: readonly [FetchHandler, ...FetchHandler[]];
|
5
|
+
};
|
6
|
+
export declare function handleFetchRequest<T extends Context>(options: HandleFetchRequestOptions<T>): Promise<Response>;
|
7
|
+
//# sourceMappingURL=handle-request.d.ts.map
|
@@ -1,12 +1,13 @@
|
|
1
|
-
import type {
|
1
|
+
import type { HTTPPath } from '@orpc/contract';
|
2
|
+
import type { Hooks, Value } from '@orpc/shared';
|
2
3
|
import type { Router } from '../router';
|
3
|
-
import type {
|
4
|
-
export type FetchHandlerOptions<
|
4
|
+
import type { Context, WithSignal } from '../types';
|
5
|
+
export type FetchHandlerOptions<T extends Context> = {
|
5
6
|
/**
|
6
7
|
* The `router` used for handling the request and routing,
|
7
8
|
*
|
8
9
|
*/
|
9
|
-
router:
|
10
|
+
router: Router<T, any>;
|
10
11
|
/**
|
11
12
|
* The request need to be handled.
|
12
13
|
*/
|
@@ -17,12 +18,11 @@ export type FetchHandlerOptions<TRouter extends Router<any>> = {
|
|
17
18
|
* @example /orpc
|
18
19
|
* @example /api
|
19
20
|
*/
|
20
|
-
prefix?:
|
21
|
-
} &
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
export type FetchHandler = <TRouter extends Router<any>>(options: FetchHandlerOptions<TRouter>) => Promise<Response | undefined>;
|
21
|
+
prefix?: HTTPPath;
|
22
|
+
} & NoInfer<(undefined extends T ? {
|
23
|
+
context?: Value<T>;
|
24
|
+
} : {
|
25
|
+
context: Value<T>;
|
26
|
+
})> & WithSignal & Hooks<Request, Response, T, WithSignal>;
|
27
|
+
export type FetchHandler = <T extends Context>(options: FetchHandlerOptions<T>) => Promise<Response | undefined>;
|
28
28
|
//# sourceMappingURL=types.d.ts.map
|
@@ -0,0 +1,6 @@
|
|
1
|
+
import type { ContractRouter, HTTPPath } from '@orpc/contract';
|
2
|
+
export declare function setRouterContract<T extends object>(obj: T, contract: ContractRouter): T;
|
3
|
+
export declare function getRouterContract(obj: object): ContractRouter | undefined;
|
4
|
+
export declare function deepSetLazyRouterPrefix<T extends object>(router: T, prefix: HTTPPath): T;
|
5
|
+
export declare function getLazyRouterPrefix(obj: object): HTTPPath | undefined;
|
6
|
+
//# sourceMappingURL=hidden.d.ts.map
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import type { Middleware } from './middleware';
|
2
|
+
import type { Context, MergeContext, WELL_CONTEXT } from './types';
|
3
|
+
import { type ContractProcedure, type ContractRouter } from '@orpc/contract';
|
4
|
+
import { ProcedureImplementer } from './procedure-implementer';
|
5
|
+
import { RouterImplementer } from './router-implementer';
|
6
|
+
export type ChainableImplementer<TContext extends Context, TExtraContext extends Context, TContract extends ContractRouter> = TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema> ? ProcedureImplementer<TContext, TExtraContext, UInputSchema, UOutputSchema> : {
|
7
|
+
[K in keyof TContract]: TContract[K] extends ContractRouter ? ChainableImplementer<TContext, TExtraContext, TContract[K]> : never;
|
8
|
+
} & Omit<RouterImplementer<TContext, TExtraContext, TContract>, '~type' | '~orpc'>;
|
9
|
+
export declare function createChainableImplementer<TContext extends Context = WELL_CONTEXT, TExtraContext extends Context = undefined, TContract extends ContractRouter = any>(contract: TContract, middlewares?: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, unknown, any>[]): ChainableImplementer<TContext, TExtraContext, TContract>;
|
10
|
+
//# sourceMappingURL=implementer-chainable.d.ts.map
|
package/dist/src/index.d.ts
CHANGED
@@ -1,17 +1,23 @@
|
|
1
|
+
import type { WELL_CONTEXT } from './types';
|
1
2
|
import { Builder } from './builder';
|
2
3
|
export * from './builder';
|
4
|
+
export * from './hidden';
|
5
|
+
export * from './implementer-chainable';
|
3
6
|
export * from './lazy';
|
7
|
+
export * from './lazy-decorated';
|
4
8
|
export * from './middleware';
|
9
|
+
export * from './middleware-decorated';
|
5
10
|
export * from './procedure';
|
6
11
|
export * from './procedure-builder';
|
7
|
-
export * from './procedure-
|
12
|
+
export * from './procedure-client';
|
13
|
+
export * from './procedure-decorated';
|
8
14
|
export * from './procedure-implementer';
|
9
15
|
export * from './router';
|
10
16
|
export * from './router-builder';
|
11
|
-
export * from './router-
|
17
|
+
export * from './router-client';
|
12
18
|
export * from './router-implementer';
|
13
19
|
export * from './types';
|
14
20
|
export * from './utils';
|
15
21
|
export * from '@orpc/shared/error';
|
16
|
-
export declare const os: Builder<
|
22
|
+
export declare const os: Builder<WELL_CONTEXT, undefined>;
|
17
23
|
//# sourceMappingURL=index.d.ts.map
|
@@ -0,0 +1,10 @@
|
|
1
|
+
import type { SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
+
import type { Lazy } from './lazy';
|
3
|
+
import type { Procedure } from './procedure';
|
4
|
+
import type { ProcedureClient } from './procedure-client';
|
5
|
+
import { type ANY_ROUTER } from './router';
|
6
|
+
export type DecoratedLazy<T> = T extends Lazy<infer U> ? DecoratedLazy<U> : Lazy<T> & (T extends Procedure<infer UContext, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput> ? undefined extends UContext ? ProcedureClient<SchemaInput<UInputSchema>, SchemaOutput<UOutputSchema, UFuncOutput>> : unknown : {
|
7
|
+
[K in keyof T]: T[K] extends object ? DecoratedLazy<T[K]> : never;
|
8
|
+
});
|
9
|
+
export declare function decorateLazy<T extends Lazy<ANY_ROUTER | undefined>>(lazied: T): DecoratedLazy<T>;
|
10
|
+
//# sourceMappingURL=lazy-decorated.d.ts.map
|
package/dist/src/lazy.d.ts
CHANGED
@@ -1,23 +1,18 @@
|
|
1
|
-
import type { Procedure } from './procedure';
|
2
|
-
import type { ProcedureCaller } from './procedure-caller';
|
3
1
|
export declare const LAZY_LOADER_SYMBOL: unique symbol;
|
4
2
|
export interface Lazy<T> {
|
5
3
|
[LAZY_LOADER_SYMBOL]: () => Promise<{
|
6
4
|
default: T;
|
7
5
|
}>;
|
8
6
|
}
|
7
|
+
export type Lazyable<T> = T | Lazy<T>;
|
9
8
|
export type ANY_LAZY = Lazy<any>;
|
10
|
-
export declare function
|
9
|
+
export declare function lazy<T>(loader: () => Promise<{
|
11
10
|
default: T;
|
12
11
|
}>): Lazy<T>;
|
13
|
-
export declare function loadLazy<T>(lazy: Lazy<T>): Promise<{
|
14
|
-
default: T;
|
15
|
-
}>;
|
16
12
|
export declare function isLazy(item: unknown): item is ANY_LAZY;
|
13
|
+
export declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
|
14
|
+
default: T extends Lazy<infer U> ? U : T;
|
15
|
+
}>;
|
17
16
|
export type FlattenLazy<T> = T extends Lazy<infer U> ? FlattenLazy<U> : Lazy<T>;
|
18
|
-
export declare function
|
19
|
-
export type DecoratedLazy<T> = T extends Lazy<infer U> ? DecoratedLazy<U> : (T extends Procedure<infer UContext, any, any, any, any> ? Lazy<T> & (undefined extends UContext ? ProcedureCaller<T> : unknown) : T extends Record<any, any> ? {
|
20
|
-
[K in keyof T]: DecoratedLazy<T[K]>;
|
21
|
-
} /** Notice: this still a lazy, but type not work when I & Lazy<T>, maybe it's a bug, should improve */ : Lazy<T>);
|
22
|
-
export declare function decorateLazy<T>(lazy: Lazy<T>): DecoratedLazy<T>;
|
17
|
+
export declare function flatLazy<T extends ANY_LAZY>(lazied: T): FlattenLazy<T>;
|
23
18
|
//# sourceMappingURL=lazy.d.ts.map
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import type { MapInputMiddleware, Middleware } from './middleware';
|
2
|
+
import type { Context, MergeContext, WELL_CONTEXT } from './types';
|
3
|
+
export interface DecoratedMiddleware<TContext extends Context, TExtraContext extends Context, TInput, TOutput> extends Middleware<TContext, TExtraContext, TInput, TOutput> {
|
4
|
+
concat: (<UExtraContext extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined, UInput = unknown>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, UInput & TInput, TOutput>) => DecoratedMiddleware<TContext, MergeContext<TExtraContext, UExtraContext>, UInput & TInput, TOutput>) & (<UExtraContext extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined, UInput = TInput, UMappedInput = unknown>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, UMappedInput, TOutput>, mapInput: MapInputMiddleware<UInput & TInput, UMappedInput>) => DecoratedMiddleware<TContext, MergeContext<TExtraContext, UExtraContext>, UInput & TInput, TOutput>);
|
5
|
+
mapInput: <UInput = unknown>(map: MapInputMiddleware<UInput, TInput>) => DecoratedMiddleware<TContext, TExtraContext, UInput, TOutput>;
|
6
|
+
}
|
7
|
+
export declare function decorateMiddleware<TContext extends Context = WELL_CONTEXT, TExtraContext extends Context = undefined, TInput = unknown, TOutput = unknown>(middleware: Middleware<TContext, TExtraContext, TInput, TOutput>): DecoratedMiddleware<TContext, TExtraContext, TInput, TOutput>;
|
8
|
+
//# sourceMappingURL=middleware-decorated.d.ts.map
|
package/dist/src/middleware.d.ts
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
import type { Promisable } from '@orpc/shared';
|
2
|
-
import type { Context,
|
2
|
+
import type { Context, Meta } from './types';
|
3
3
|
export type MiddlewareResult<TExtraContext extends Context, TOutput> = Promisable<{
|
4
4
|
output: TOutput;
|
5
5
|
context: TExtraContext;
|
@@ -15,12 +15,9 @@ export interface MiddlewareMeta<TOutput> extends Meta {
|
|
15
15
|
export interface Middleware<TContext extends Context, TExtraContext extends Context, TInput, TOutput> {
|
16
16
|
(input: TInput, context: TContext, meta: MiddlewareMeta<TOutput>): Promisable<MiddlewareResult<TExtraContext, TOutput>>;
|
17
17
|
}
|
18
|
+
export type ANY_MIDDLEWARE = Middleware<any, any, any, any>;
|
18
19
|
export interface MapInputMiddleware<TInput, TMappedInput> {
|
19
20
|
(input: TInput): TMappedInput;
|
20
21
|
}
|
21
|
-
export
|
22
|
-
concat: (<UExtraContext extends Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>> | undefined = undefined, UInput = TInput>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, UInput & TInput, TOutput>) => DecoratedMiddleware<TContext, MergeContext<TExtraContext, UExtraContext>, TInput & UInput, TOutput>) & (<UExtraContext extends Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>> | undefined = undefined, UInput = TInput, UMappedInput = unknown>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, UMappedInput, TOutput>, mapInput: MapInputMiddleware<UInput, UMappedInput>) => DecoratedMiddleware<TContext, MergeContext<TExtraContext, UExtraContext>, TInput & UInput, TOutput>);
|
23
|
-
mapInput: <UInput = unknown>(map: MapInputMiddleware<UInput, TInput>) => DecoratedMiddleware<TContext, TExtraContext, UInput, TOutput>;
|
24
|
-
}
|
25
|
-
export declare function decorateMiddleware<TContext extends Context, TExtraContext extends Context, TInput, TOutput>(middleware: Middleware<TContext, TExtraContext, TInput, TOutput>): DecoratedMiddleware<TContext, TExtraContext, TInput, TOutput>;
|
22
|
+
export type ANY_MAP_INPUT_MIDDLEWARE = MapInputMiddleware<any, any>;
|
26
23
|
//# sourceMappingURL=middleware.d.ts.map
|
@@ -1,31 +1,22 @@
|
|
1
1
|
import type { MapInputMiddleware, Middleware } from './middleware';
|
2
|
+
import type { DecoratedProcedure } from './procedure-decorated';
|
2
3
|
import type { Context, MergeContext } from './types';
|
3
4
|
import { type ContractProcedure, type RouteOptions, type Schema, type SchemaInput, type SchemaOutput } from '@orpc/contract';
|
4
|
-
import { type
|
5
|
+
import { type ProcedureFunc } from './procedure';
|
5
6
|
import { ProcedureImplementer } from './procedure-implementer';
|
7
|
+
export interface ProcedureBuilderDef<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema> {
|
8
|
+
contract: ContractProcedure<TInputSchema, TOutputSchema>;
|
9
|
+
middlewares?: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, unknown, any>[];
|
10
|
+
}
|
6
11
|
export declare class ProcedureBuilder<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema> {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
* Self chainable
|
17
|
-
*/
|
18
|
-
route(opts: RouteOptions): ProcedureBuilder<TContext, TExtraContext, TInputSchema, TOutputSchema>;
|
19
|
-
input<USchema extends Schema = undefined>(schema: USchema, example?: SchemaInput<USchema>): ProcedureBuilder<TContext, TExtraContext, USchema, TOutputSchema>;
|
20
|
-
output<USchema extends Schema = undefined>(schema: USchema, example?: SchemaOutput<USchema>): ProcedureBuilder<TContext, TExtraContext, TInputSchema, USchema>;
|
21
|
-
/**
|
22
|
-
* Convert to ProcedureBuilder
|
23
|
-
*/
|
24
|
-
use<UExtraContext extends Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>>): ProcedureImplementer<TContext, MergeContext<TExtraContext, UExtraContext>, TInputSchema, TOutputSchema>;
|
25
|
-
use<UExtraContext extends Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>> | undefined = undefined, UMappedInput = unknown>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, UMappedInput, SchemaInput<TOutputSchema>>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UMappedInput>): ProcedureImplementer<TContext, MergeContext<TExtraContext, UExtraContext>, TInputSchema, TOutputSchema>;
|
26
|
-
/**
|
27
|
-
* Convert to Procedure
|
28
|
-
*/
|
29
|
-
func<UFuncOutput extends SchemaOutput<TOutputSchema>>(func: ProcedureFunc<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput>): DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput>;
|
12
|
+
'~type': "ProcedureBuilder";
|
13
|
+
'~orpc': ProcedureBuilderDef<TContext, TExtraContext, TInputSchema, TOutputSchema>;
|
14
|
+
constructor(def: ProcedureBuilderDef<TContext, TExtraContext, TInputSchema, TOutputSchema>);
|
15
|
+
route(route: RouteOptions): ProcedureBuilder<TContext, TExtraContext, TInputSchema, TOutputSchema>;
|
16
|
+
input<U extends Schema = undefined>(schema: U, example?: SchemaInput<U>): ProcedureBuilder<TContext, TExtraContext, U, TOutputSchema>;
|
17
|
+
output<U extends Schema = undefined>(schema: U, example?: SchemaOutput<U>): ProcedureBuilder<TContext, TExtraContext, TInputSchema, U>;
|
18
|
+
use<U extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>>): ProcedureImplementer<TContext, MergeContext<TExtraContext, U>, TInputSchema, TOutputSchema>;
|
19
|
+
use<UExtra extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined, UInput = unknown>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtra, UInput, SchemaInput<TOutputSchema>>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>): ProcedureImplementer<TContext, MergeContext<TExtraContext, UExtra>, TInputSchema, TOutputSchema>;
|
20
|
+
func<UFuncOutput extends SchemaInput<TOutputSchema>>(func: ProcedureFunc<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput>): DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput>;
|
30
21
|
}
|
31
22
|
//# sourceMappingURL=procedure-builder.d.ts.map
|
@@ -0,0 +1,29 @@
|
|
1
|
+
import type { Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
+
import type { Hooks, Value } from '@orpc/shared';
|
3
|
+
import type { Lazyable } from './lazy';
|
4
|
+
import type { Procedure } from './procedure';
|
5
|
+
import type { Context, Meta, WELL_CONTEXT, WithSignal } from './types';
|
6
|
+
export interface ProcedureClient<TInput, TOutput> {
|
7
|
+
(...opts: [input: TInput, options?: WithSignal] | (undefined extends TInput ? [] : never)): Promise<TOutput>;
|
8
|
+
}
|
9
|
+
/**
|
10
|
+
* Options for creating a procedure caller with comprehensive type safety
|
11
|
+
*/
|
12
|
+
export type CreateProcedureClientOptions<TContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TFuncOutput extends SchemaInput<TOutputSchema>> = {
|
13
|
+
procedure: Lazyable<Procedure<TContext, any, TInputSchema, TOutputSchema, TFuncOutput>>;
|
14
|
+
/**
|
15
|
+
* This is helpful for logging and analytics.
|
16
|
+
*
|
17
|
+
* @internal
|
18
|
+
*/
|
19
|
+
path?: string[];
|
20
|
+
} & ({
|
21
|
+
/**
|
22
|
+
* The context used when calling the procedure.
|
23
|
+
*/
|
24
|
+
context: Value<TContext>;
|
25
|
+
} | (undefined extends TContext ? {
|
26
|
+
context?: undefined;
|
27
|
+
} : never)) & Hooks<unknown, SchemaOutput<TOutputSchema, TFuncOutput>, TContext, Meta>;
|
28
|
+
export declare function createProcedureClient<TContext extends Context = WELL_CONTEXT, TInputSchema extends Schema = undefined, TOutputSchema extends Schema = undefined, TFuncOutput extends SchemaInput<TOutputSchema> = SchemaInput<TOutputSchema>>(options: CreateProcedureClientOptions<TContext, TInputSchema, TOutputSchema, TFuncOutput>): ProcedureClient<SchemaInput<TInputSchema>, SchemaOutput<TOutputSchema, TFuncOutput>>;
|
29
|
+
//# sourceMappingURL=procedure-client.d.ts.map
|
@@ -0,0 +1,14 @@
|
|
1
|
+
import type { HTTPPath, RouteOptions, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
+
import type { MapInputMiddleware, Middleware } from './middleware';
|
3
|
+
import type { ProcedureClient } from './procedure-client';
|
4
|
+
import type { Context, MergeContext } from './types';
|
5
|
+
import { Procedure } from './procedure';
|
6
|
+
export type DecoratedProcedure<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TFuncOutput extends SchemaInput<TOutputSchema>> = Procedure<TContext, TExtraContext, TInputSchema, TOutputSchema, TFuncOutput> & {
|
7
|
+
prefix: (prefix: HTTPPath) => DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, TFuncOutput>;
|
8
|
+
route: (route: RouteOptions) => DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, TFuncOutput>;
|
9
|
+
use: (<U extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema, TFuncOutput>>) => DecoratedProcedure<TContext, MergeContext<TExtraContext, U>, TInputSchema, TOutputSchema, TFuncOutput>) & (<UExtra extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined, UInput = unknown>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtra, UInput, SchemaInput<TOutputSchema, TFuncOutput>>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema, TFuncOutput>, UInput>) => DecoratedProcedure<TContext, MergeContext<TExtraContext, UExtra>, TInputSchema, TOutputSchema, TFuncOutput>);
|
10
|
+
unshiftTag: (...tags: string[]) => DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, TFuncOutput>;
|
11
|
+
unshiftMiddleware: <U extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined>(...middlewares: Middleware<TContext, U, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema, TFuncOutput>>[]) => DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, TFuncOutput>;
|
12
|
+
} & (undefined extends TContext ? ProcedureClient<SchemaInput<TInputSchema>, SchemaOutput<TOutputSchema, TFuncOutput>> : unknown);
|
13
|
+
export declare function decorateProcedure<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TFuncOutput extends SchemaInput<TOutputSchema>>(procedure: Procedure<TContext, TExtraContext, TInputSchema, TOutputSchema, TFuncOutput>): DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, TFuncOutput>;
|
14
|
+
//# sourceMappingURL=procedure-decorated.d.ts.map
|
@@ -1,22 +1,18 @@
|
|
1
1
|
import type { ContractProcedure, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
-
import type {
|
3
|
-
import type {
|
2
|
+
import type { MapInputMiddleware, Middleware } from './middleware';
|
3
|
+
import type { ProcedureFunc } from './procedure';
|
4
|
+
import type { DecoratedProcedure } from './procedure-decorated';
|
4
5
|
import type { Context, MergeContext } from './types';
|
5
|
-
|
6
|
+
export type ProcedureImplementerDef<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema> = {
|
7
|
+
contract: ContractProcedure<TInputSchema, TOutputSchema>;
|
8
|
+
middlewares?: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>>[];
|
9
|
+
};
|
6
10
|
export declare class ProcedureImplementer<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema> {
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
middlewares?: Middleware<any, any, any, any>[];
|
14
|
-
});
|
15
|
-
use<UExtraContext extends Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>>): ProcedureImplementer<TContext, MergeContext<TExtraContext, UExtraContext>, TInputSchema, TOutputSchema>;
|
16
|
-
use<UExtraContext extends Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>> | undefined = undefined, UMappedInput = unknown>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, UMappedInput, SchemaInput<TOutputSchema>>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UMappedInput>): ProcedureImplementer<TContext, MergeContext<TExtraContext, UExtraContext>, TInputSchema, TOutputSchema>;
|
17
|
-
func<UFuncOutput extends SchemaOutput<TOutputSchema>>(func: ProcedureFunc<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput>): DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput>;
|
18
|
-
lazy<U extends Procedure<TContext, TExtraContext, TInputSchema, TOutputSchema, SchemaOutput<TOutputSchema>>>(loader: () => Promise<{
|
19
|
-
default: U;
|
20
|
-
}>): DecoratedLazy<U>;
|
11
|
+
'~type': "ProcedureImplementer";
|
12
|
+
'~orpc': ProcedureImplementerDef<TContext, TExtraContext, TInputSchema, TOutputSchema>;
|
13
|
+
constructor(def: ProcedureImplementerDef<TContext, TExtraContext, TInputSchema, TOutputSchema>);
|
14
|
+
use<U extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>>): ProcedureImplementer<TContext, MergeContext<TExtraContext, U>, TInputSchema, TOutputSchema>;
|
15
|
+
use<UExtra extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined, UInput = unknown>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtra, UInput, SchemaInput<TOutputSchema>>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>): ProcedureImplementer<TContext, MergeContext<TExtraContext, UExtra>, TInputSchema, TOutputSchema>;
|
16
|
+
func<UFuncOutput extends SchemaInput<TOutputSchema>>(func: ProcedureFunc<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput>): DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput>;
|
21
17
|
}
|
22
18
|
//# sourceMappingURL=procedure-implementer.d.ts.map
|
package/dist/src/procedure.d.ts
CHANGED
@@ -1,32 +1,23 @@
|
|
1
1
|
import type { Promisable } from '@orpc/shared';
|
2
2
|
import type { Lazy } from './lazy';
|
3
|
-
import type {
|
3
|
+
import type { Middleware } from './middleware';
|
4
4
|
import type { Context, MergeContext, Meta } from './types';
|
5
|
-
import { type ContractProcedure, type
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
5
|
+
import { type ContractProcedure, type Schema, type SchemaInput, type SchemaOutput } from '@orpc/contract';
|
6
|
+
export interface ProcedureFunc<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TFuncOutput extends SchemaInput<TOutputSchema>> {
|
7
|
+
(input: SchemaOutput<TInputSchema>, context: MergeContext<TContext, TExtraContext>, meta: Meta): Promisable<SchemaInput<TOutputSchema, TFuncOutput>>;
|
8
|
+
}
|
9
|
+
export interface ProcedureDef<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TFuncOutput extends SchemaInput<TOutputSchema>> {
|
10
|
+
middlewares?: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, SchemaOutput<TInputSchema>, any>[];
|
11
|
+
contract: ContractProcedure<TInputSchema, TOutputSchema>;
|
12
|
+
func: ProcedureFunc<TContext, TExtraContext, TInputSchema, TOutputSchema, TFuncOutput>;
|
13
|
+
}
|
14
|
+
export declare class Procedure<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TFuncOutput extends SchemaInput<TOutputSchema>> {
|
15
|
+
'~type': "Procedure";
|
16
|
+
'~orpc': ProcedureDef<TContext, TExtraContext, TInputSchema, TOutputSchema, TFuncOutput>;
|
17
|
+
constructor(def: ProcedureDef<TContext, TExtraContext, TInputSchema, TOutputSchema, TFuncOutput>);
|
18
18
|
}
|
19
19
|
export type ANY_PROCEDURE = Procedure<any, any, any, any, any>;
|
20
|
-
export type
|
20
|
+
export type WELL_PROCEDURE = Procedure<Context, Context, Schema, Schema, unknown>;
|
21
21
|
export type ANY_LAZY_PROCEDURE = Lazy<ANY_PROCEDURE>;
|
22
|
-
export type DecoratedProcedure<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TFuncOutput extends SchemaOutput<TOutputSchema>> = Procedure<TContext, TExtraContext, TInputSchema, TOutputSchema, TFuncOutput> & {
|
23
|
-
prefix: (prefix: HTTPPath) => DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, TFuncOutput>;
|
24
|
-
route: (opts: RouteOptions) => DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, TFuncOutput>;
|
25
|
-
use: (<UExtraContext extends Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema, TFuncOutput>>) => DecoratedProcedure<TContext, MergeContext<TExtraContext, UExtraContext>, TInputSchema, TOutputSchema, TFuncOutput>) & (<UExtraContext extends Partial<MergeContext<Context, MergeContext<TContext, TExtraContext>>> | undefined = undefined, UMappedInput = unknown>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, UMappedInput, SchemaInput<TOutputSchema, TFuncOutput>>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema, TFuncOutput>, UMappedInput>) => DecoratedProcedure<TContext, MergeContext<TExtraContext, UExtraContext>, TInputSchema, TOutputSchema, TFuncOutput>);
|
26
|
-
} & (undefined extends TContext ? ProcedureCaller<Procedure<TContext, TExtraContext, TInputSchema, TOutputSchema, TFuncOutput>> : unknown);
|
27
|
-
export interface ProcedureFunc<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TOutput extends SchemaOutput<TOutputSchema>> {
|
28
|
-
(input: SchemaOutput<TInputSchema>, context: MergeContext<TContext, TExtraContext>, meta: Meta): Promisable<SchemaInput<TOutputSchema, TOutput>>;
|
29
|
-
}
|
30
|
-
export declare function decorateProcedure<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TFuncOutput extends SchemaOutput<TOutputSchema>>(procedure: Procedure<TContext, TExtraContext, TInputSchema, TOutputSchema, TFuncOutput>): DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, TFuncOutput>;
|
31
22
|
export declare function isProcedure(item: unknown): item is ANY_PROCEDURE;
|
32
23
|
//# sourceMappingURL=procedure.d.ts.map
|
@@ -1,27 +1,29 @@
|
|
1
|
-
import type {
|
2
|
-
import type {
|
1
|
+
import type { HTTPPath } from '@orpc/contract';
|
2
|
+
import type { FlattenLazy, Lazy } from './lazy';
|
3
|
+
import type { Middleware } from './middleware';
|
4
|
+
import type { Procedure } from './procedure';
|
5
|
+
import type { ANY_ROUTER, Router } from './router';
|
3
6
|
import type { Context, MergeContext } from './types';
|
4
|
-
import { type
|
5
|
-
import { type
|
6
|
-
export
|
7
|
+
import { type DecoratedLazy } from './lazy-decorated';
|
8
|
+
import { type DecoratedProcedure } from './procedure-decorated';
|
9
|
+
export type AdaptedRouter<TContext extends Context, TRouter extends ANY_ROUTER> = TRouter extends Lazy<infer U extends ANY_ROUTER> ? DecoratedLazy<AdaptedRouter<TContext, U>> : TRouter extends Procedure<any, infer UExtraContext, infer UInputSchema, infer UOutputSchema, infer UFuncOutput> ? DecoratedProcedure<TContext, UExtraContext, UInputSchema, UOutputSchema, UFuncOutput> : {
|
10
|
+
[K in keyof TRouter]: TRouter[K] extends ANY_ROUTER ? AdaptedRouter<TContext, TRouter[K]> : never;
|
11
|
+
};
|
12
|
+
export type RouterBuilderDef<TContext extends Context, TExtraContext extends Context> = {
|
13
|
+
prefix?: HTTPPath;
|
14
|
+
tags?: readonly string[];
|
15
|
+
middlewares?: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, unknown, any>[];
|
16
|
+
};
|
7
17
|
export declare class RouterBuilder<TContext extends Context, TExtraContext extends Context> {
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
middlewares?: Middleware<any, any, any, any>[];
|
12
|
-
};
|
13
|
-
constructor(zz$rb: {
|
14
|
-
prefix?: HTTPPath;
|
15
|
-
tags?: string[];
|
16
|
-
middlewares?: Middleware<any, any, any, any>[];
|
17
|
-
});
|
18
|
+
'~type': "RouterBuilder";
|
19
|
+
'~orpc': RouterBuilderDef<TContext, TExtraContext>;
|
20
|
+
constructor(def: RouterBuilderDef<TContext, TExtraContext>);
|
18
21
|
prefix(prefix: HTTPPath): RouterBuilder<TContext, TExtraContext>;
|
19
|
-
|
20
|
-
use<
|
21
|
-
|
22
|
-
|
23
|
-
lazy<U extends Router<TContext>>(loader: () => Promise<{
|
22
|
+
tag(...tags: string[]): RouterBuilder<TContext, TExtraContext>;
|
23
|
+
use<U extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, unknown, unknown>): RouterBuilder<TContext, MergeContext<TExtraContext, U>>;
|
24
|
+
router<U extends Router<MergeContext<TContext, TExtraContext>, any>>(router: U): AdaptedRouter<TContext, U>;
|
25
|
+
lazy<U extends Router<MergeContext<TContext, TExtraContext>, any>>(loader: () => Promise<{
|
24
26
|
default: U;
|
25
|
-
}>):
|
27
|
+
}>): AdaptedRouter<TContext, FlattenLazy<U>>;
|
26
28
|
}
|
27
29
|
//# sourceMappingURL=router-builder.d.ts.map
|
@@ -0,0 +1,25 @@
|
|
1
|
+
import type { ContractProcedure, ContractRouter, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
+
import type { Hooks, Value } from '@orpc/shared';
|
3
|
+
import type { Lazy } from './lazy';
|
4
|
+
import type { Procedure } from './procedure';
|
5
|
+
import type { ProcedureClient } from './procedure-client';
|
6
|
+
import type { Meta } from './types';
|
7
|
+
import { type ANY_ROUTER, type Router } from './router';
|
8
|
+
export type RouterClient<T extends ANY_ROUTER | ContractRouter> = T extends Lazy<infer U extends ANY_ROUTER | ContractRouter> ? RouterClient<U> : T extends ContractProcedure<infer UInputSchema, infer UOutputSchema> | Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput> ? ProcedureClient<SchemaInput<UInputSchema>, SchemaOutput<UOutputSchema, UFuncOutput>> : {
|
9
|
+
[K in keyof T]: T[K] extends ANY_ROUTER | ContractRouter ? RouterClient<T[K]> : never;
|
10
|
+
};
|
11
|
+
export type CreateRouterClientOptions<TRouter extends ANY_ROUTER> = {
|
12
|
+
router: TRouter | Lazy<undefined>;
|
13
|
+
/**
|
14
|
+
* This is helpful for logging and analytics.
|
15
|
+
*
|
16
|
+
* @internal
|
17
|
+
*/
|
18
|
+
path?: string[];
|
19
|
+
} & (TRouter extends Router<infer UContext, any> ? undefined extends UContext ? {
|
20
|
+
context?: Value<UContext>;
|
21
|
+
} : {
|
22
|
+
context: Value<UContext>;
|
23
|
+
} : never) & Hooks<unknown, unknown, TRouter extends Router<infer UContext, any> ? UContext : never, Meta>;
|
24
|
+
export declare function createRouterClient<TRouter extends ANY_ROUTER>(options: CreateRouterClientOptions<TRouter>): RouterClient<TRouter>;
|
25
|
+
//# sourceMappingURL=router-client.d.ts.map
|
@@ -1,24 +1,21 @@
|
|
1
|
-
import type {
|
1
|
+
import type { ContractRouter } from '@orpc/contract';
|
2
|
+
import type { FlattenLazy } from './lazy';
|
2
3
|
import type { Middleware } from './middleware';
|
3
|
-
import type {
|
4
|
-
import type {
|
5
|
-
import {
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
router<U extends
|
16
|
-
lazy<U extends
|
4
|
+
import type { Router } from './router';
|
5
|
+
import type { AdaptedRouter } from './router-builder';
|
6
|
+
import type { Context, MergeContext } from './types';
|
7
|
+
export interface RouterImplementerDef<TContext extends Context, TExtraContext extends Context, TContract extends ContractRouter> {
|
8
|
+
middlewares?: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, unknown, any>[];
|
9
|
+
contract: TContract;
|
10
|
+
}
|
11
|
+
export declare class RouterImplementer<TContext extends Context, TExtraContext extends Context, TContract extends ContractRouter> {
|
12
|
+
'~type': "RouterImplementer";
|
13
|
+
'~orpc': RouterImplementerDef<TContext, TExtraContext, TContract>;
|
14
|
+
constructor(def: RouterImplementerDef<TContext, TExtraContext, TContract>);
|
15
|
+
use<U extends Context & Partial<MergeContext<TContext, TExtraContext>> | undefined = undefined>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, unknown, unknown>): RouterImplementer<TContext, MergeContext<TExtraContext, U>, TContract>;
|
16
|
+
router<U extends Router<MergeContext<TContext, TExtraContext>, TContract>>(router: U): AdaptedRouter<TContext, U>;
|
17
|
+
lazy<U extends Router<MergeContext<TContext, TExtraContext>, TContract>>(loader: () => Promise<{
|
17
18
|
default: U;
|
18
|
-
}>):
|
19
|
+
}>): AdaptedRouter<TContext, FlattenLazy<U>>;
|
19
20
|
}
|
20
|
-
export type ChainedRouterImplementer<TContext extends Context, TContract extends ContractRouter, TExtraContext extends Context> = {
|
21
|
-
[K in keyof TContract]: TContract[K] extends ContractProcedure<infer UInputSchema, infer UOutputSchema> ? ProcedureImplementer<TContext, TExtraContext, UInputSchema, UOutputSchema> : TContract[K] extends ContractRouter ? ChainedRouterImplementer<TContext, TContract[K], TExtraContext> : never;
|
22
|
-
} & RouterImplementer<TContext, TContract>;
|
23
|
-
export declare function chainRouterImplementer<TContext extends Context, TContract extends ContractRouter, TExtraContext extends Context>(contract: TContract, middlewares?: Middleware<any, any, any, any>[]): ChainedRouterImplementer<TContext, TContract, TExtraContext>;
|
24
21
|
//# sourceMappingURL=router-implementer.d.ts.map
|