@orpc/server 0.32.0 → 0.33.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{chunk-SXUFCJBY.js → chunk-ESTRJAOX.js} +5 -7
- package/dist/{chunk-GK2Z6B6W.js → chunk-KK4SDLC7.js} +158 -68
- package/dist/fetch.js +2 -2
- package/dist/hono.js +3 -3
- package/dist/index.js +189 -841
- package/dist/next.js +3 -3
- package/dist/node.js +6 -6
- package/dist/src/adapters/fetch/orpc-handler.d.ts +1 -1
- package/dist/src/adapters/fetch/orpc-procedure-matcher.d.ts +4 -4
- package/dist/src/adapters/fetch/types.d.ts +4 -4
- package/dist/src/adapters/hono/middleware.d.ts +3 -3
- package/dist/src/adapters/next/serve.d.ts +8 -8
- package/dist/src/adapters/node/orpc-handler.d.ts +2 -2
- package/dist/src/adapters/node/types.d.ts +5 -5
- package/dist/src/builder-variants.d.ts +74 -0
- package/dist/src/builder.d.ts +46 -38
- package/dist/src/context.d.ts +8 -10
- package/dist/src/hidden.d.ts +5 -3
- package/dist/src/implementer-procedure.d.ts +30 -0
- package/dist/src/implementer-variants.d.ts +16 -0
- package/dist/src/implementer.d.ts +27 -0
- package/dist/src/index.d.ts +8 -13
- package/dist/src/lazy-utils.d.ts +4 -2
- package/dist/src/lazy.d.ts +9 -5
- package/dist/src/middleware-decorated.d.ts +7 -7
- package/dist/src/middleware-utils.d.ts +5 -0
- package/dist/src/middleware.d.ts +22 -21
- package/dist/src/procedure-client.d.ts +6 -8
- package/dist/src/procedure-decorated.d.ts +10 -15
- package/dist/src/procedure-utils.d.ts +2 -2
- package/dist/src/procedure.d.ts +17 -33
- package/dist/src/router-accessible-lazy.d.ts +8 -0
- package/dist/src/router-client.d.ts +6 -10
- package/dist/src/router.d.ts +25 -12
- package/package.json +3 -3
- package/dist/src/builder-with-errors-middlewares.d.ts +0 -51
- package/dist/src/builder-with-errors.d.ts +0 -52
- package/dist/src/builder-with-middlewares.d.ts +0 -48
- package/dist/src/error.d.ts +0 -10
- package/dist/src/implementer-chainable.d.ts +0 -14
- package/dist/src/lazy-decorated.d.ts +0 -7
- package/dist/src/procedure-builder-with-input.d.ts +0 -34
- package/dist/src/procedure-builder-with-output.d.ts +0 -33
- package/dist/src/procedure-builder.d.ts +0 -27
- package/dist/src/procedure-implementer.d.ts +0 -22
- package/dist/src/router-builder.d.ts +0 -33
- package/dist/src/router-implementer.d.ts +0 -22
- package/dist/src/types.d.ts +0 -14
- package/dist/src/utils.d.ts +0 -3
package/dist/src/middleware.d.ts
CHANGED
@@ -1,36 +1,37 @@
|
|
1
|
+
import type { AbortSignal, ErrorMap, Meta, ORPCErrorConstructorMap, Schema } from '@orpc/contract';
|
1
2
|
import type { Promisable } from '@orpc/shared';
|
2
|
-
import type {
|
3
|
-
import type {
|
4
|
-
|
5
|
-
export type MiddlewareResult<TExtraContext extends Context, TOutput> = Promisable<{
|
3
|
+
import type { Context } from './context';
|
4
|
+
import type { Procedure } from './procedure';
|
5
|
+
export type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
|
6
6
|
output: TOutput;
|
7
|
-
context:
|
7
|
+
context: TOutContext;
|
8
8
|
}>;
|
9
|
-
export
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
9
|
+
export type MiddlewareNextFnOptions<TOutContext extends Context> = Record<never, never> extends TOutContext ? {
|
10
|
+
context?: TOutContext;
|
11
|
+
} : {
|
12
|
+
context: TOutContext;
|
13
|
+
};
|
14
|
+
export type MiddlewareNextFnRest<TOutContext extends Context> = [options: MiddlewareNextFnOptions<TOutContext>] | (Record<never, never> extends TOutContext ? [] : never);
|
15
|
+
export interface MiddlewareNextFn<TInContext extends Context, TOutput> {
|
16
|
+
<U extends Context & Partial<TInContext> = Record<never, never>>(...rest: MiddlewareNextFnRest<U>): MiddlewareResult<U, TOutput>;
|
15
17
|
}
|
16
18
|
export interface MiddlewareOutputFn<TOutput> {
|
17
|
-
(output: TOutput): MiddlewareResult<
|
19
|
+
(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
|
18
20
|
}
|
19
|
-
export interface MiddlewareOptions<
|
20
|
-
context:
|
21
|
+
export interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
22
|
+
context: TInContext;
|
21
23
|
path: string[];
|
22
|
-
procedure:
|
24
|
+
procedure: Procedure<Context, Context, Schema, Schema, unknown, ErrorMap, TMeta>;
|
23
25
|
signal?: AbortSignal;
|
24
|
-
next: MiddlewareNextFn<TOutput>;
|
26
|
+
next: MiddlewareNextFn<TInContext, TOutput>;
|
25
27
|
errors: TErrorConstructorMap;
|
26
28
|
}
|
27
|
-
export interface Middleware<
|
28
|
-
(options: MiddlewareOptions<
|
29
|
+
export interface Middleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
30
|
+
(options: MiddlewareOptions<TInContext, TOutput, TErrorConstructorMap, TMeta>, input: TInput, output: MiddlewareOutputFn<TOutput>): Promisable<MiddlewareResult<TOutContext, TOutput>>;
|
29
31
|
}
|
30
|
-
export type
|
32
|
+
export type AnyMiddleware = Middleware<any, any, any, any, any, any>;
|
31
33
|
export interface MapInputMiddleware<TInput, TMappedInput> {
|
32
34
|
(input: TInput): TMappedInput;
|
33
35
|
}
|
34
|
-
export
|
35
|
-
export declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<undefined, TOutput>;
|
36
|
+
export declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
|
36
37
|
//# sourceMappingURL=middleware.d.ts.map
|
@@ -1,22 +1,20 @@
|
|
1
1
|
import type { Client, ErrorFromErrorMap, ErrorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
2
|
import type { Hooks, Value } from '@orpc/shared';
|
3
|
+
import type { Context } from './context';
|
3
4
|
import type { Lazyable } from './lazy';
|
4
5
|
import type { Procedure } from './procedure';
|
5
|
-
import type { Context, Meta } from './types';
|
6
6
|
export type ProcedureClient<TClientContext, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap> = Client<TClientContext, SchemaInput<TInputSchema>, SchemaOutput<TOutputSchema, THandlerOutput>, ErrorFromErrorMap<TErrorMap>>;
|
7
7
|
/**
|
8
8
|
* Options for creating a procedure caller with comprehensive type safety
|
9
9
|
*/
|
10
|
-
export type CreateProcedureClientOptions<
|
10
|
+
export type CreateProcedureClientOptions<TInitialContext extends Context, TCurrentContext extends Schema, THandlerOutput extends SchemaInput<TCurrentContext>, TClientContext> = {
|
11
11
|
/**
|
12
12
|
* This is helpful for logging and analytics.
|
13
13
|
*/
|
14
14
|
path?: string[];
|
15
15
|
} & ({
|
16
|
-
context: Value<
|
17
|
-
} | (
|
18
|
-
|
19
|
-
|
20
|
-
export type CreateProcedureClientRest<TContext extends Context, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TClientContext> = [options: CreateProcedureClientOptions<TContext, TOutputSchema, THandlerOutput, TClientContext>] | (undefined extends TContext ? [] : never);
|
21
|
-
export declare function createProcedureClient<TContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TClientContext>(lazyableProcedure: Lazyable<Procedure<TContext, any, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>>, ...[options]: CreateProcedureClientRest<TContext, TOutputSchema, THandlerOutput, TClientContext>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
16
|
+
context: Value<TInitialContext, [clientContext: TClientContext]>;
|
17
|
+
} | (Record<never, never> extends TInitialContext ? Record<never, never> : never)) & Hooks<unknown, SchemaOutput<TCurrentContext, THandlerOutput>, TInitialContext, any>;
|
18
|
+
export type CreateProcedureClientRest<TInitialContext extends Context, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TClientContext> = [options: CreateProcedureClientOptions<TInitialContext, TOutputSchema, THandlerOutput, TClientContext>] | (Record<never, never> extends TInitialContext ? [] : never);
|
19
|
+
export declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, any>>, ...[options]: CreateProcedureClientRest<TInitialContext, TOutputSchema, THandlerOutput, TClientContext>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
22
20
|
//# sourceMappingURL=procedure-client.d.ts.map
|
@@ -1,26 +1,21 @@
|
|
1
|
-
import type { ClientRest, ErrorMap,
|
2
|
-
import type {
|
3
|
-
import type { ORPCErrorConstructorMap } from './error';
|
1
|
+
import type { ClientRest, ErrorMap, MergedErrorMap, Meta, ORPCErrorConstructorMap, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
+
import type { ConflictContextGuard, Context, MergedContext } from './context';
|
4
3
|
import type { MapInputMiddleware, Middleware } from './middleware';
|
5
4
|
import type { CreateProcedureClientRest, ProcedureClient } from './procedure-client';
|
6
|
-
import type { Context, MergeContext } from './types';
|
7
5
|
import { Procedure } from './procedure';
|
8
|
-
export declare class DecoratedProcedure<
|
9
|
-
|
10
|
-
|
11
|
-
route(route:
|
12
|
-
|
13
|
-
use<
|
14
|
-
use<UExtra extends Context & ContextGuard<MergeContext<TContext, TExtraContext>>, UInput = unknown>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtra, UInput, THandlerOutput, ORPCErrorConstructorMap<TErrorMap>>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema, THandlerOutput>, UInput>): DecoratedProcedure<TContext, MergeContext<TExtraContext, UExtra>, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
15
|
-
unshiftTag(...tags: string[]): DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
16
|
-
unshiftMiddleware(...middlewares: Middleware<TContext, Context & Partial<MergeContext<TContext, TExtraContext>> | undefined, unknown, SchemaOutput<TOutputSchema, THandlerOutput>, ORPCErrorConstructorMap<TErrorMap>>[]): DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
6
|
+
export declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> {
|
7
|
+
errors<U extends ErrorMap>(errors: U): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, MergedErrorMap<TErrorMap, U>, TMeta>;
|
8
|
+
meta(meta: TMeta): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>;
|
9
|
+
route(route: Route): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>;
|
10
|
+
use<U extends Context>(middleware: Middleware<TCurrentContext, U, SchemaOutput<TInputSchema>, THandlerOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, U>> & DecoratedProcedure<TInitialContext, MergedContext<TCurrentContext, U>, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>;
|
11
|
+
use<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, THandlerOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema, THandlerOutput>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & DecoratedProcedure<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>;
|
17
12
|
/**
|
18
13
|
* Make this procedure callable (works like a function while still being a procedure).
|
19
14
|
*/
|
20
|
-
callable<TClientContext>(...rest: CreateProcedureClientRest<
|
15
|
+
callable<TClientContext>(...rest: CreateProcedureClientRest<TInitialContext, TOutputSchema, THandlerOutput, TClientContext>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
21
16
|
/**
|
22
17
|
* Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
|
23
18
|
*/
|
24
|
-
actionable<TClientContext>(...rest: CreateProcedureClientRest<
|
19
|
+
actionable<TClientContext>(...rest: CreateProcedureClientRest<TInitialContext, TOutputSchema, THandlerOutput, TClientContext>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, SchemaInput<TInputSchema>>) => Promise<SchemaOutput<TOutputSchema, THandlerOutput>>);
|
25
20
|
}
|
26
21
|
//# sourceMappingURL=procedure-decorated.d.ts.map
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import type { ClientPromiseResult, ErrorFromErrorMap, ErrorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
+
import type { Context } from './context';
|
2
3
|
import type { Lazyable } from './lazy';
|
3
4
|
import type { Procedure } from './procedure';
|
4
|
-
import type { Context } from './types';
|
5
5
|
import { type CreateProcedureClientRest } from './procedure-client';
|
6
6
|
/**
|
7
7
|
* Directly call a procedure without creating a client.
|
@@ -13,5 +13,5 @@ import { type CreateProcedureClientRest } from './procedure-client';
|
|
13
13
|
* ```
|
14
14
|
*
|
15
15
|
*/
|
16
|
-
export declare function call<
|
16
|
+
export declare function call<TInitialContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap>(procedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, any>>, input: SchemaInput<TInputSchema>, ...rest: CreateProcedureClientRest<TInitialContext, TOutputSchema, THandlerOutput, unknown>): ClientPromiseResult<SchemaOutput<TOutputSchema, THandlerOutput>, ErrorFromErrorMap<TErrorMap>>;
|
17
17
|
//# sourceMappingURL=procedure-utils.d.ts.map
|
package/dist/src/procedure.d.ts
CHANGED
@@ -1,45 +1,29 @@
|
|
1
|
-
import type {
|
1
|
+
import type { AbortSignal, ContractProcedureDef, ErrorMap, Meta, ORPCErrorConstructorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
2
|
import type { Promisable } from '@orpc/shared';
|
3
|
-
import type {
|
4
|
-
import type {
|
5
|
-
|
6
|
-
|
7
|
-
export interface ProcedureHandlerOptions<TContext extends Context, TExtraContext extends Context, TInput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>> {
|
8
|
-
context: MergeContext<TContext, TExtraContext>;
|
3
|
+
import type { Context, TypeInitialContext } from './context';
|
4
|
+
import type { AnyMiddleware } from './middleware';
|
5
|
+
export interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
6
|
+
context: TCurrentContext;
|
9
7
|
input: TInput;
|
10
8
|
path: string[];
|
11
|
-
procedure:
|
9
|
+
procedure: Procedure<Context, Context, Schema, Schema, unknown, ErrorMap, TMeta>;
|
12
10
|
signal?: AbortSignal;
|
13
11
|
errors: TErrorConstructorMap;
|
14
12
|
}
|
15
|
-
export interface ProcedureHandler<
|
16
|
-
(opt: ProcedureHandlerOptions<
|
13
|
+
export interface ProcedureHandler<TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
14
|
+
(opt: ProcedureHandlerOptions<TCurrentContext, SchemaOutput<TInputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): Promisable<SchemaInput<TOutputSchema, THandlerOutput>>;
|
17
15
|
}
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
*
|
22
|
-
* Passing `ErrorMap/ErrorConstructorMap` directly to `Middleware/ProcedureHandler`
|
23
|
-
* causes unexpected errors in the router (the root cause is unclear, but it occurs consistently).
|
24
|
-
* To avoid these issues, `any` is used as a workaround.
|
25
|
-
*
|
26
|
-
* This approach is still functional because `ProcedureDef` can infer the `ErrorMap` from `ContractProcedure`.
|
27
|
-
* The only downside is that direct access to them requires careful type checking to ensure safety.
|
28
|
-
*/
|
29
|
-
export interface ProcedureDef<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap> {
|
30
|
-
middlewares: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, unknown, unknown, any>[];
|
16
|
+
export interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
17
|
+
__initialContext?: TypeInitialContext<TInitialContext>;
|
18
|
+
middlewares: AnyMiddleware[];
|
31
19
|
inputValidationIndex: number;
|
32
20
|
outputValidationIndex: number;
|
33
|
-
|
34
|
-
handler: ProcedureHandler<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput, any>;
|
21
|
+
handler: ProcedureHandler<TCurrentContext, any, any, THandlerOutput, any, any>;
|
35
22
|
}
|
36
|
-
export declare class Procedure<
|
37
|
-
'~
|
38
|
-
|
39
|
-
constructor(def: ProcedureDef<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>);
|
23
|
+
export declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
24
|
+
'~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>;
|
25
|
+
constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta>);
|
40
26
|
}
|
41
|
-
export type
|
42
|
-
export
|
43
|
-
export type ANY_LAZY_PROCEDURE = Lazy<ANY_PROCEDURE>;
|
44
|
-
export declare function isProcedure(item: unknown): item is ANY_PROCEDURE;
|
27
|
+
export type AnyProcedure = Procedure<any, any, any, any, any, any, any>;
|
28
|
+
export declare function isProcedure(item: unknown): item is AnyProcedure;
|
45
29
|
//# sourceMappingURL=procedure.d.ts.map
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import type { Lazy } from './lazy';
|
2
|
+
import type { AnyProcedure } from './procedure';
|
3
|
+
import type { AnyRouter } from './router';
|
4
|
+
export type AccessibleLazyRouter<T extends AnyRouter | undefined | Lazy<AnyRouter | undefined>> = T extends Lazy<infer U extends AnyRouter | undefined | Lazy<AnyRouter | undefined>> ? AccessibleLazyRouter<U> : Lazy<T> & (T extends AnyProcedure | undefined ? unknown : {
|
5
|
+
[K in keyof T]: T[K] extends AnyRouter ? AccessibleLazyRouter<T[K]> : never;
|
6
|
+
});
|
7
|
+
export declare function createAccessibleLazyRouter<T extends Lazy<AnyRouter | undefined>>(lazied: T): AccessibleLazyRouter<T>;
|
8
|
+
//# sourceMappingURL=router-accessible-lazy.d.ts.map
|
@@ -2,15 +2,11 @@ import type { Hooks, Value } from '@orpc/shared';
|
|
2
2
|
import type { Lazy } from './lazy';
|
3
3
|
import type { Procedure } from './procedure';
|
4
4
|
import type { CreateProcedureClientRest, ProcedureClient } from './procedure-client';
|
5
|
-
import type {
|
6
|
-
|
7
|
-
|
8
|
-
* FIXME: separate RouterClient and ContractRouterClient, don't mix them
|
9
|
-
*/
|
10
|
-
export type RouterClient<TRouter extends ANY_ROUTER, TClientContext> = TRouter extends Lazy<infer U extends ANY_ROUTER> ? RouterClient<U, TClientContext> : TRouter extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput, infer UErrorMap> ? ProcedureClient<TClientContext, UInputSchema, UOutputSchema, UFuncOutput, UErrorMap> : {
|
11
|
-
[K in keyof TRouter]: TRouter[K] extends ANY_ROUTER ? RouterClient<TRouter[K], TClientContext> : never;
|
5
|
+
import type { AnyRouter, Router } from './router';
|
6
|
+
export type RouterClient<TRouter extends AnyRouter, TClientContext> = TRouter extends Lazy<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : TRouter extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UFuncOutput, infer UErrorMap, any> ? ProcedureClient<TClientContext, UInputSchema, UOutputSchema, UFuncOutput, UErrorMap> : {
|
7
|
+
[K in keyof TRouter]: TRouter[K] extends AnyRouter ? RouterClient<TRouter[K], TClientContext> : never;
|
12
8
|
};
|
13
|
-
export type CreateRouterClientOptions<TRouter extends
|
9
|
+
export type CreateRouterClientOptions<TRouter extends AnyRouter> = {
|
14
10
|
/**
|
15
11
|
* This is helpful for logging and analytics.
|
16
12
|
*
|
@@ -21,6 +17,6 @@ export type CreateRouterClientOptions<TRouter extends ANY_ROUTER> = {
|
|
21
17
|
context?: Value<UContext>;
|
22
18
|
} : {
|
23
19
|
context: Value<UContext>;
|
24
|
-
} : never) & Hooks<unknown, unknown, TRouter extends Router<infer UContext, any> ? UContext : never,
|
25
|
-
export declare function createRouterClient<TRouter extends
|
20
|
+
} : never) & Hooks<unknown, unknown, TRouter extends Router<infer UContext, any> ? UContext : never, any>;
|
21
|
+
export declare function createRouterClient<TRouter extends AnyRouter, TClientContext>(router: TRouter | Lazy<undefined>, ...rest: CreateProcedureClientRest<TRouter extends Router<infer UContext, any> ? UContext : never, undefined, unknown, TClientContext>): RouterClient<TRouter, TClientContext>;
|
26
22
|
//# sourceMappingURL=router-client.d.ts.map
|
package/dist/src/router.d.ts
CHANGED
@@ -1,16 +1,29 @@
|
|
1
|
-
import type { ContractProcedure,
|
2
|
-
import type {
|
3
|
-
import type {
|
4
|
-
import type {
|
5
|
-
|
6
|
-
|
1
|
+
import type { AnyContractRouter, ContractProcedure, ErrorMap, HTTPPath, MergedErrorMap, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
+
import type { Context } from './context';
|
3
|
+
import type { Lazy, Lazyable } from './lazy';
|
4
|
+
import type { AnyMiddleware } from './middleware';
|
5
|
+
import type { AnyProcedure } from './procedure';
|
6
|
+
import { Procedure } from './procedure';
|
7
|
+
import { type AccessibleLazyRouter } from './router-accessible-lazy';
|
8
|
+
export type Router<TInitialContext extends Context, TContract extends AnyContractRouter> = Lazyable<TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, UInputSchema, UOutputSchema, any, UErrorMap, UMeta> : {
|
9
|
+
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? Router<TInitialContext, TContract[K]> : never;
|
7
10
|
}>;
|
8
|
-
export type
|
9
|
-
export type InferRouterInputs<T extends
|
10
|
-
[K in keyof T]: T[K] extends
|
11
|
+
export type AnyRouter = Router<any, any>;
|
12
|
+
export type InferRouterInputs<T extends AnyRouter> = T extends Lazy<infer U extends AnyRouter> ? InferRouterInputs<U> : T extends Procedure<any, any, infer UInputSchema, any, any, any, any> ? SchemaInput<UInputSchema> : {
|
13
|
+
[K in keyof T]: T[K] extends AnyRouter ? InferRouterInputs<T[K]> : never;
|
11
14
|
};
|
12
|
-
export type InferRouterOutputs<T extends
|
13
|
-
[K in keyof T]: T[K] extends
|
15
|
+
export type InferRouterOutputs<T extends AnyRouter> = T extends Lazy<infer U extends AnyRouter> ? InferRouterOutputs<U> : T extends Procedure<any, any, any, infer UOutputSchema, infer UFuncOutput, any, any> ? SchemaOutput<UOutputSchema, UFuncOutput> : {
|
16
|
+
[K in keyof T]: T[K] extends AnyRouter ? InferRouterOutputs<T[K]> : never;
|
14
17
|
};
|
15
|
-
export
|
18
|
+
export type AdaptedRouter<TRouter extends AnyRouter, TInitialContext extends Context, TErrorMap extends ErrorMap> = TRouter extends Lazy<infer U extends AnyRouter> ? AccessibleLazyRouter<AdaptedRouter<U, TInitialContext, TErrorMap>> : TRouter extends Procedure<any, infer UCurrentContext, infer UInputSchema, infer UOutputSchema, infer UFuncOutput, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, UCurrentContext, UInputSchema, UOutputSchema, UFuncOutput, MergedErrorMap<TErrorMap, UErrorMap>, UMeta> : {
|
19
|
+
[K in keyof TRouter]: TRouter[K] extends AnyRouter ? AdaptedRouter<TRouter[K], TInitialContext, TErrorMap> : never;
|
20
|
+
};
|
21
|
+
export interface AdaptRouterOptions<TErrorMap extends ErrorMap> {
|
22
|
+
middlewares: AnyMiddleware[];
|
23
|
+
tags?: readonly string[];
|
24
|
+
prefix?: HTTPPath;
|
25
|
+
errorMap: TErrorMap;
|
26
|
+
}
|
27
|
+
export declare function adaptRouter<TRouter extends AnyRouter, TInitialContext extends Context, TErrorMap extends ErrorMap>(router: TRouter, options: AdaptRouterOptions<TErrorMap>): AdaptedRouter<TRouter, TInitialContext, TErrorMap>;
|
28
|
+
export declare function getRouterChild<T extends AnyRouter | Lazy<undefined>>(router: T, ...path: string[]): T extends Lazy<any> ? Lazy<AnyProcedure> | Lazy<Record<string, AnyRouter>> | Lazy<undefined> : AnyRouter | Lazy<undefined> | undefined;
|
16
29
|
//# sourceMappingURL=router.d.ts.map
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/server",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.33.0",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -53,8 +53,8 @@
|
|
53
53
|
"next": ">=14.0.0"
|
54
54
|
},
|
55
55
|
"dependencies": {
|
56
|
-
"@orpc/contract": "0.
|
57
|
-
"@orpc/shared": "0.
|
56
|
+
"@orpc/contract": "0.33.0",
|
57
|
+
"@orpc/shared": "0.33.0"
|
58
58
|
},
|
59
59
|
"scripts": {
|
60
60
|
"build": "tsup --onSuccess='tsc -b --noCheck'",
|
@@ -1,51 +0,0 @@
|
|
1
|
-
import type { ContractBuilderConfig, ContractRouter, ErrorMap, ErrorMapGuard, ErrorMapSuggestions, HTTPPath, RouteOptions, Schema, SchemaInput, SchemaOutput, StrictErrorMap } from '@orpc/contract';
|
2
|
-
import type { ContextGuard } from './context';
|
3
|
-
import type { ORPCErrorConstructorMap } from './error';
|
4
|
-
import type { FlattenLazy } from './lazy';
|
5
|
-
import type { Middleware } from './middleware';
|
6
|
-
import type { ProcedureHandler } from './procedure';
|
7
|
-
import type { Router } from './router';
|
8
|
-
import type { AdaptedRouter } from './router-builder';
|
9
|
-
import type { Context, MergeContext } from './types';
|
10
|
-
import { ProcedureBuilder } from './procedure-builder';
|
11
|
-
import { ProcedureBuilderWithInput } from './procedure-builder-with-input';
|
12
|
-
import { ProcedureBuilderWithOutput } from './procedure-builder-with-output';
|
13
|
-
import { DecoratedProcedure } from './procedure-decorated';
|
14
|
-
import { RouterBuilder } from './router-builder';
|
15
|
-
export interface BuilderWithErrorsMiddlewaresDef<TContext extends Context, TExtraContext extends Context, TErrorMap extends ErrorMap> {
|
16
|
-
types?: {
|
17
|
-
context: TContext;
|
18
|
-
};
|
19
|
-
errorMap: TErrorMap;
|
20
|
-
middlewares: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, unknown, any, ORPCErrorConstructorMap<TErrorMap>>[];
|
21
|
-
inputValidationIndex: number;
|
22
|
-
outputValidationIndex: number;
|
23
|
-
config: ContractBuilderConfig;
|
24
|
-
}
|
25
|
-
/**
|
26
|
-
* `BuilderWithErrorsMiddlewares` is a combination of `BuilderWithErrorsMiddlewares` and `BuilderWithErrors`.
|
27
|
-
*
|
28
|
-
* Why?
|
29
|
-
* - prevents .middleware after .use (can mislead the behavior)
|
30
|
-
* - prevents .contract after .errors (add error map to existing contract can make the contract invalid)
|
31
|
-
* - prevents .context after .use (middlewares required current context, so it tricky when change the current context)
|
32
|
-
*
|
33
|
-
*/
|
34
|
-
export declare class BuilderWithErrorsMiddlewares<TContext extends Context, TExtraContext extends Context, TErrorMap extends ErrorMap> {
|
35
|
-
'~type': "BuilderWithErrorsMiddlewares";
|
36
|
-
'~orpc': BuilderWithErrorsMiddlewaresDef<TContext, TExtraContext, TErrorMap>;
|
37
|
-
constructor(def: BuilderWithErrorsMiddlewaresDef<TContext, TExtraContext, TErrorMap>);
|
38
|
-
errors<U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions>(errors: U): BuilderWithErrorsMiddlewares<TContext, TExtraContext, TErrorMap & U>;
|
39
|
-
use<U extends Context & ContextGuard<MergeContext<TContext, TExtraContext>>>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>>): BuilderWithErrorsMiddlewares<TContext, MergeContext<TExtraContext, U>, TErrorMap>;
|
40
|
-
route(route: RouteOptions): ProcedureBuilder<TContext, TExtraContext, TErrorMap>;
|
41
|
-
input<USchema extends Schema>(schema: USchema, example?: SchemaInput<USchema>): ProcedureBuilderWithInput<TContext, TExtraContext, USchema, TErrorMap>;
|
42
|
-
output<USchema extends Schema>(schema: USchema, example?: SchemaOutput<USchema>): ProcedureBuilderWithOutput<TContext, TExtraContext, USchema, TErrorMap>;
|
43
|
-
handler<UFuncOutput>(handler: ProcedureHandler<TContext, TExtraContext, undefined, undefined, UFuncOutput, TErrorMap>): DecoratedProcedure<TContext, TExtraContext, undefined, undefined, UFuncOutput, TErrorMap>;
|
44
|
-
prefix(prefix: HTTPPath): RouterBuilder<TContext, TExtraContext, TErrorMap>;
|
45
|
-
tag(...tags: string[]): RouterBuilder<TContext, TExtraContext, TErrorMap>;
|
46
|
-
router<U extends Router<MergeContext<TContext, TExtraContext>, ContractRouter<ErrorMap & Partial<StrictErrorMap<TErrorMap>>>>>(router: U): AdaptedRouter<TContext, U, TErrorMap>;
|
47
|
-
lazy<U extends Router<MergeContext<TContext, TExtraContext>, ContractRouter<ErrorMap & Partial<StrictErrorMap<TErrorMap>>>>>(loader: () => Promise<{
|
48
|
-
default: U;
|
49
|
-
}>): AdaptedRouter<TContext, FlattenLazy<U>, TErrorMap>;
|
50
|
-
}
|
51
|
-
//# sourceMappingURL=builder-with-errors-middlewares.d.ts.map
|
@@ -1,52 +0,0 @@
|
|
1
|
-
import type { ContractBuilderConfig, ContractRouter, ErrorMap, ErrorMapGuard, ErrorMapSuggestions, HTTPPath, RouteOptions, Schema, SchemaInput, SchemaOutput, StrictErrorMap } from '@orpc/contract';
|
2
|
-
import type { BuilderConfig } from './builder';
|
3
|
-
import type { ContextGuard } from './context';
|
4
|
-
import type { ORPCErrorConstructorMap } from './error';
|
5
|
-
import type { FlattenLazy } from './lazy';
|
6
|
-
import type { Middleware } from './middleware';
|
7
|
-
import type { DecoratedMiddleware } from './middleware-decorated';
|
8
|
-
import type { ProcedureHandler } from './procedure';
|
9
|
-
import type { Router } from './router';
|
10
|
-
import type { AdaptedRouter } from './router-builder';
|
11
|
-
import type { Context, MergeContext } from './types';
|
12
|
-
import { BuilderWithErrorsMiddlewares } from './builder-with-errors-middlewares';
|
13
|
-
import { ProcedureBuilder } from './procedure-builder';
|
14
|
-
import { ProcedureBuilderWithInput } from './procedure-builder-with-input';
|
15
|
-
import { ProcedureBuilderWithOutput } from './procedure-builder-with-output';
|
16
|
-
import { DecoratedProcedure } from './procedure-decorated';
|
17
|
-
import { RouterBuilder } from './router-builder';
|
18
|
-
export interface BuilderWithErrorsDef<TContext extends Context, TErrorMap extends ErrorMap> {
|
19
|
-
types?: {
|
20
|
-
context: TContext;
|
21
|
-
};
|
22
|
-
errorMap: TErrorMap;
|
23
|
-
config: BuilderConfig;
|
24
|
-
}
|
25
|
-
/**
|
26
|
-
* `BuilderWithErrors` is a branch of `Builder` which it has error map.
|
27
|
-
*
|
28
|
-
* Why?
|
29
|
-
* - prevents .contract after .errors (add error map to existing contract can make the contract invalid)
|
30
|
-
*
|
31
|
-
*/
|
32
|
-
export declare class BuilderWithErrors<TContext extends Context, TErrorMap extends ErrorMap> {
|
33
|
-
'~type': "BuilderWithErrors";
|
34
|
-
'~orpc': BuilderWithErrorsDef<TContext, TErrorMap>;
|
35
|
-
constructor(def: BuilderWithErrorsDef<TContext, TErrorMap>);
|
36
|
-
config(config: ContractBuilderConfig): BuilderWithErrors<TContext, TErrorMap>;
|
37
|
-
context<UContext extends Context = TContext>(): BuilderWithErrors<UContext, TErrorMap>;
|
38
|
-
errors<U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions>(errors: U): BuilderWithErrors<TContext, TErrorMap & U>;
|
39
|
-
middleware<UExtraContext extends Context & ContextGuard<TContext>, TInput, TOutput = any>(middleware: Middleware<TContext, UExtraContext, TInput, TOutput, ORPCErrorConstructorMap<TErrorMap>>): DecoratedMiddleware<TContext, UExtraContext, TInput, TOutput, ORPCErrorConstructorMap<TErrorMap>>;
|
40
|
-
use<U extends Context & ContextGuard<TContext>>(middleware: Middleware<TContext, U, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>>): BuilderWithErrorsMiddlewares<TContext, U, TErrorMap>;
|
41
|
-
route(route: RouteOptions): ProcedureBuilder<TContext, undefined, TErrorMap>;
|
42
|
-
input<USchema extends Schema>(schema: USchema, example?: SchemaInput<USchema>): ProcedureBuilderWithInput<TContext, undefined, USchema, TErrorMap>;
|
43
|
-
output<USchema extends Schema>(schema: USchema, example?: SchemaOutput<USchema>): ProcedureBuilderWithOutput<TContext, undefined, USchema, TErrorMap>;
|
44
|
-
handler<UFuncOutput>(handler: ProcedureHandler<TContext, undefined, undefined, undefined, UFuncOutput, TErrorMap>): DecoratedProcedure<TContext, undefined, undefined, undefined, UFuncOutput, TErrorMap>;
|
45
|
-
prefix(prefix: HTTPPath): RouterBuilder<TContext, undefined, TErrorMap>;
|
46
|
-
tag(...tags: string[]): RouterBuilder<TContext, undefined, TErrorMap>;
|
47
|
-
router<U extends Router<MergeContext<TContext, undefined>, ContractRouter<ErrorMap & Partial<StrictErrorMap<TErrorMap>>>>>(router: U): AdaptedRouter<TContext, U, TErrorMap>;
|
48
|
-
lazy<U extends Router<MergeContext<TContext, undefined>, ContractRouter<ErrorMap & Partial<StrictErrorMap<TErrorMap>>>>>(loader: () => Promise<{
|
49
|
-
default: U;
|
50
|
-
}>): AdaptedRouter<TContext, FlattenLazy<U>, TErrorMap>;
|
51
|
-
}
|
52
|
-
//# sourceMappingURL=builder-with-errors.d.ts.map
|
@@ -1,48 +0,0 @@
|
|
1
|
-
import type { ContractBuilderConfig, ContractRouter, ErrorMap, ErrorMapSuggestions, HTTPPath, RouteOptions, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
-
import type { ContextGuard } from './context';
|
3
|
-
import type { FlattenLazy } from './lazy';
|
4
|
-
import type { Middleware } from './middleware';
|
5
|
-
import type { ProcedureHandler } from './procedure';
|
6
|
-
import type { Router } from './router';
|
7
|
-
import type { AdaptedRouter } from './router-builder';
|
8
|
-
import type { Context, MergeContext } from './types';
|
9
|
-
import { BuilderWithErrorsMiddlewares } from './builder-with-errors-middlewares';
|
10
|
-
import { type ChainableImplementer } from './implementer-chainable';
|
11
|
-
import { ProcedureBuilder } from './procedure-builder';
|
12
|
-
import { ProcedureBuilderWithInput } from './procedure-builder-with-input';
|
13
|
-
import { ProcedureBuilderWithOutput } from './procedure-builder-with-output';
|
14
|
-
import { DecoratedProcedure } from './procedure-decorated';
|
15
|
-
import { RouterBuilder } from './router-builder';
|
16
|
-
/**
|
17
|
-
* `BuilderWithMiddlewares` is a branch of `Builder` which it has middlewares.
|
18
|
-
*
|
19
|
-
* Why?
|
20
|
-
* - prevents .middleware after .use (can mislead the behavior)
|
21
|
-
* - prevents .context after .use (middlewares required current context, so it tricky when change the current context)
|
22
|
-
*
|
23
|
-
*/
|
24
|
-
export interface BuilderWithMiddlewaresDef<TContext extends Context, TExtraContext extends Context> {
|
25
|
-
config: ContractBuilderConfig;
|
26
|
-
middlewares: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, unknown, any, Record<never, never>>[];
|
27
|
-
inputValidationIndex: number;
|
28
|
-
outputValidationIndex: number;
|
29
|
-
}
|
30
|
-
export declare class BuilderWithMiddlewares<TContext extends Context, TExtraContext extends Context> {
|
31
|
-
'~type': "BuilderHasMiddlewares";
|
32
|
-
'~orpc': BuilderWithMiddlewaresDef<TContext, TExtraContext>;
|
33
|
-
constructor(def: BuilderWithMiddlewaresDef<TContext, TExtraContext>);
|
34
|
-
use<U extends Context & ContextGuard<MergeContext<TContext, TExtraContext>>>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, unknown, unknown, Record<never, never>>): BuilderWithMiddlewares<TContext, MergeContext<TExtraContext, U>>;
|
35
|
-
errors<U extends ErrorMap & ErrorMapSuggestions>(errors: U): BuilderWithErrorsMiddlewares<TContext, TExtraContext, U>;
|
36
|
-
route(route: RouteOptions): ProcedureBuilder<TContext, TExtraContext, Record<never, never>>;
|
37
|
-
input<USchema extends Schema>(schema: USchema, example?: SchemaInput<USchema>): ProcedureBuilderWithInput<TContext, TExtraContext, USchema, Record<never, never>>;
|
38
|
-
output<USchema extends Schema>(schema: USchema, example?: SchemaOutput<USchema>): ProcedureBuilderWithOutput<TContext, TExtraContext, USchema, Record<never, never>>;
|
39
|
-
handler<UFuncOutput>(handler: ProcedureHandler<TContext, TExtraContext, undefined, undefined, UFuncOutput, Record<never, never>>): DecoratedProcedure<TContext, TExtraContext, undefined, undefined, UFuncOutput, Record<never, never>>;
|
40
|
-
prefix(prefix: HTTPPath): RouterBuilder<TContext, TExtraContext, Record<never, never>>;
|
41
|
-
tag(...tags: string[]): RouterBuilder<TContext, TExtraContext, Record<never, never>>;
|
42
|
-
router<U extends Router<MergeContext<TContext, TExtraContext>, any>>(router: U): AdaptedRouter<TContext, U, Record<never, never>>;
|
43
|
-
lazy<U extends Router<MergeContext<TContext, TExtraContext>, any>>(loader: () => Promise<{
|
44
|
-
default: U;
|
45
|
-
}>): AdaptedRouter<TContext, FlattenLazy<U>, Record<never, never>>;
|
46
|
-
contract<U extends ContractRouter<any>>(contract: U): ChainableImplementer<TContext, TExtraContext, U>;
|
47
|
-
}
|
48
|
-
//# sourceMappingURL=builder-with-middlewares.d.ts.map
|
package/dist/src/error.d.ts
DELETED
@@ -1,10 +0,0 @@
|
|
1
|
-
import type { ErrorMap, ErrorMapItem, ORPCErrorOptions, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
-
import { ORPCError } from '@orpc/contract';
|
3
|
-
export type ORPCErrorConstructorMapItemOptions<TData> = Omit<ORPCErrorOptions<any, TData>, 'defined' | 'code' | 'status'>;
|
4
|
-
export type ORPCErrorConstructorMapItemRest<TData> = [options: ORPCErrorConstructorMapItemOptions<TData>] | (undefined extends TData ? [] : never);
|
5
|
-
export type ORPCErrorConstructorMapItem<TCode extends string, TDataSchema extends Schema> = (...rest: ORPCErrorConstructorMapItemRest<SchemaInput<TDataSchema>>) => ORPCError<TCode, SchemaOutput<TDataSchema>>;
|
6
|
-
export type ORPCErrorConstructorMap<T extends ErrorMap> = {
|
7
|
-
[K in keyof T]: K extends string ? T[K] extends ErrorMapItem<infer UInputSchema> ? ORPCErrorConstructorMapItem<K, UInputSchema> : never : never;
|
8
|
-
};
|
9
|
-
export declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
|
10
|
-
//# sourceMappingURL=error.d.ts.map
|
@@ -1,14 +0,0 @@
|
|
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<any>> = TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap> ? ProcedureImplementer<TContext, TExtraContext, UInputSchema, UOutputSchema, UErrorMap> : {
|
7
|
-
[K in keyof TContract]: TContract[K] extends ContractRouter<any> ? 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> = any>(contract: TContract, options: {
|
10
|
-
middlewares: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, unknown, any, any>[];
|
11
|
-
inputValidationIndex: number;
|
12
|
-
outputValidationIndex: number;
|
13
|
-
}): ChainableImplementer<TContext, TExtraContext, TContract>;
|
14
|
-
//# sourceMappingURL=implementer-chainable.d.ts.map
|
@@ -1,7 +0,0 @@
|
|
1
|
-
import type { Lazy } from './lazy';
|
2
|
-
import { type ANY_ROUTER } from './router';
|
3
|
-
export type DecoratedLazy<T> = T extends Lazy<infer U> ? DecoratedLazy<U> : Lazy<T> & (T extends ANY_ROUTER ? {
|
4
|
-
[K in keyof T]: DecoratedLazy<T[K]>;
|
5
|
-
} : unknown);
|
6
|
-
export declare function decorateLazy<T extends Lazy<ANY_ROUTER | undefined>>(lazied: T): DecoratedLazy<T>;
|
7
|
-
//# sourceMappingURL=lazy-decorated.d.ts.map
|
@@ -1,34 +0,0 @@
|
|
1
|
-
import type { ContractProcedure, ErrorMap, ErrorMapGuard, ErrorMapSuggestions, RouteOptions, Schema, SchemaOutput } from '@orpc/contract';
|
2
|
-
import type { ContextGuard } from './context';
|
3
|
-
import type { ORPCErrorConstructorMap } from './error';
|
4
|
-
import type { MapInputMiddleware, Middleware } from './middleware';
|
5
|
-
import type { ProcedureHandler } from './procedure';
|
6
|
-
import type { Context, MergeContext } from './types';
|
7
|
-
import { DecoratedProcedure } from './procedure-decorated';
|
8
|
-
import { ProcedureImplementer } from './procedure-implementer';
|
9
|
-
export interface ProcedureBuilderWithInputDef<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TErrorMap extends ErrorMap> {
|
10
|
-
contract: ContractProcedure<TInputSchema, undefined, TErrorMap>;
|
11
|
-
middlewares: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>>[];
|
12
|
-
inputValidationIndex: number;
|
13
|
-
outputValidationIndex: number;
|
14
|
-
}
|
15
|
-
/**
|
16
|
-
* `ProcedureBuilderWithInput` is a branch of `ProcedureBuilder` which it has input schema.
|
17
|
-
*
|
18
|
-
* Why?
|
19
|
-
* - prevents override input schema after .input
|
20
|
-
* - allows .use between .input and .output
|
21
|
-
*
|
22
|
-
*/
|
23
|
-
export declare class ProcedureBuilderWithInput<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TErrorMap extends ErrorMap> {
|
24
|
-
'~type': "ProcedureBuilderWithInput";
|
25
|
-
'~orpc': ProcedureBuilderWithInputDef<TContext, TExtraContext, TInputSchema, TErrorMap>;
|
26
|
-
constructor(def: ProcedureBuilderWithInputDef<TContext, TExtraContext, TInputSchema, TErrorMap>);
|
27
|
-
errors<U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions>(errors: U): ProcedureBuilderWithInput<TContext, TExtraContext, TInputSchema, TErrorMap & U>;
|
28
|
-
route(route: RouteOptions): ProcedureBuilderWithInput<TContext, TExtraContext, TInputSchema, TErrorMap>;
|
29
|
-
use<U extends Context & ContextGuard<MergeContext<TContext, TExtraContext>>>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, SchemaOutput<TInputSchema>, unknown, ORPCErrorConstructorMap<TErrorMap>>): ProcedureBuilderWithInput<TContext, MergeContext<TExtraContext, U>, TInputSchema, TErrorMap>;
|
30
|
-
use<UExtra extends Context & ContextGuard<MergeContext<TContext, TExtraContext>>, UInput>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtra, UInput, unknown, ORPCErrorConstructorMap<TErrorMap>>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>): ProcedureBuilderWithInput<TContext, MergeContext<TExtraContext, UExtra>, TInputSchema, TErrorMap>;
|
31
|
-
output<U extends Schema>(schema: U, example?: SchemaOutput<U>): ProcedureImplementer<TContext, TExtraContext, TInputSchema, U, TErrorMap>;
|
32
|
-
handler<UFuncOutput>(handler: ProcedureHandler<TContext, TExtraContext, TInputSchema, undefined, UFuncOutput, TErrorMap>): DecoratedProcedure<TContext, TExtraContext, TInputSchema, undefined, UFuncOutput, TErrorMap>;
|
33
|
-
}
|
34
|
-
//# sourceMappingURL=procedure-builder-with-input.d.ts.map
|
@@ -1,33 +0,0 @@
|
|
1
|
-
import type { ContractProcedure, ErrorMap, ErrorMapGuard, ErrorMapSuggestions, RouteOptions, Schema, SchemaInput } from '@orpc/contract';
|
2
|
-
import type { ContextGuard } from './context';
|
3
|
-
import type { ORPCErrorConstructorMap } from './error';
|
4
|
-
import type { Middleware } from './middleware';
|
5
|
-
import type { ProcedureHandler } from './procedure';
|
6
|
-
import type { Context, MergeContext } from './types';
|
7
|
-
import { DecoratedProcedure } from './procedure-decorated';
|
8
|
-
import { ProcedureImplementer } from './procedure-implementer';
|
9
|
-
export interface ProcedureBuilderWithOutputDef<TContext extends Context, TExtraContext extends Context, TOutputSchema extends Schema, TErrorMap extends ErrorMap> {
|
10
|
-
contract: ContractProcedure<undefined, TOutputSchema, TErrorMap>;
|
11
|
-
middlewares: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, unknown, any, ORPCErrorConstructorMap<TErrorMap>>[];
|
12
|
-
inputValidationIndex: number;
|
13
|
-
outputValidationIndex: number;
|
14
|
-
}
|
15
|
-
/**
|
16
|
-
* `ProcedureBuilderWithOutput` is a branch of `ProcedureBuilder` which it has output schema.
|
17
|
-
*
|
18
|
-
* Why?
|
19
|
-
* - prevents override output schema after .output
|
20
|
-
* - allows .use between .input and .output
|
21
|
-
*
|
22
|
-
*/
|
23
|
-
export declare class ProcedureBuilderWithOutput<TContext extends Context, TExtraContext extends Context, TOutputSchema extends Schema, TErrorMap extends ErrorMap> {
|
24
|
-
'~type': "ProcedureBuilderWithOutput";
|
25
|
-
'~orpc': ProcedureBuilderWithOutputDef<TContext, TExtraContext, TOutputSchema, TErrorMap>;
|
26
|
-
constructor(def: ProcedureBuilderWithOutputDef<TContext, TExtraContext, TOutputSchema, TErrorMap>);
|
27
|
-
errors<U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions>(errors: U): ProcedureBuilderWithOutput<TContext, TExtraContext, TOutputSchema, TErrorMap & U>;
|
28
|
-
route(route: RouteOptions): ProcedureBuilderWithOutput<TContext, TExtraContext, TOutputSchema, TErrorMap>;
|
29
|
-
use<U extends Context & ContextGuard<MergeContext<TContext, TExtraContext>>>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, unknown, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>>): ProcedureBuilderWithOutput<TContext, MergeContext<TExtraContext, U>, TOutputSchema, TErrorMap>;
|
30
|
-
input<U extends Schema>(schema: U, example?: SchemaInput<U>): ProcedureImplementer<TContext, TExtraContext, U, TOutputSchema, TErrorMap>;
|
31
|
-
handler<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TContext, TExtraContext, undefined, TOutputSchema, UFuncOutput, TErrorMap>): DecoratedProcedure<TContext, TExtraContext, undefined, TOutputSchema, UFuncOutput, TErrorMap>;
|
32
|
-
}
|
33
|
-
//# sourceMappingURL=procedure-builder-with-output.d.ts.map
|