@orpc/server 0.30.0 → 0.32.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/{chunk-SA7HGGVY.js → chunk-GK2Z6B6W.js} +22 -34
- package/dist/{chunk-2HRHHZJD.js → chunk-SXUFCJBY.js} +2 -2
- package/dist/fetch.js +2 -2
- package/dist/hono.js +2 -2
- package/dist/index.js +555 -103
- package/dist/next.js +2 -2
- package/dist/node.js +2 -2
- package/dist/src/builder-with-errors-middlewares.d.ts +51 -0
- package/dist/src/builder-with-errors.d.ts +52 -0
- package/dist/src/builder-with-middlewares.d.ts +48 -0
- package/dist/src/builder.d.ts +34 -23
- package/dist/src/config.d.ts +6 -0
- package/dist/src/context.d.ts +11 -0
- package/dist/src/implementer-chainable.d.ts +5 -1
- package/dist/src/index.d.ts +3 -2
- package/dist/src/middleware-decorated.d.ts +2 -1
- package/dist/src/procedure-builder-with-input.d.ts +34 -0
- package/dist/src/procedure-builder-with-output.d.ts +33 -0
- package/dist/src/procedure-builder.d.ts +18 -15
- package/dist/src/procedure-decorated.d.ts +5 -6
- package/dist/src/procedure-implementer.d.ts +6 -4
- package/dist/src/procedure.d.ts +4 -3
- package/dist/src/router-builder.d.ts +4 -2
- package/dist/src/router-implementer.d.ts +2 -1
- package/package.json +3 -3
package/dist/next.js
CHANGED
@@ -4,8 +4,8 @@ import {
|
|
4
4
|
ORPCProcedureMatcher,
|
5
5
|
RPCHandler,
|
6
6
|
super_json_exports
|
7
|
-
} from "./chunk-
|
8
|
-
import "./chunk-
|
7
|
+
} from "./chunk-SXUFCJBY.js";
|
8
|
+
import "./chunk-GK2Z6B6W.js";
|
9
9
|
|
10
10
|
// src/adapters/next/serve.ts
|
11
11
|
import { value } from "@orpc/shared";
|
package/dist/node.js
CHANGED
@@ -0,0 +1,51 @@
|
|
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
|
@@ -0,0 +1,52 @@
|
|
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
|
@@ -0,0 +1,48 @@
|
|
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/builder.d.ts
CHANGED
@@ -1,38 +1,49 @@
|
|
1
|
-
import type { ContractRouter, ErrorMap,
|
2
|
-
import type {
|
1
|
+
import type { ContractBuilderConfig, ContractRouter, ErrorMap, ErrorMapSuggestions, HTTPPath, RouteOptions, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
+
import type { ContextGuard } from './context';
|
3
3
|
import type { FlattenLazy } from './lazy';
|
4
4
|
import type { Middleware } from './middleware';
|
5
5
|
import type { DecoratedMiddleware } from './middleware-decorated';
|
6
6
|
import type { ProcedureHandler } from './procedure';
|
7
7
|
import type { Router } from './router';
|
8
8
|
import type { AdaptedRouter } from './router-builder';
|
9
|
-
import type { Context, MergeContext
|
9
|
+
import type { Context, MergeContext } from './types';
|
10
|
+
import { BuilderWithErrors } from './builder-with-errors';
|
11
|
+
import { BuilderWithMiddlewares } from './builder-with-middlewares';
|
10
12
|
import { type ChainableImplementer } from './implementer-chainable';
|
11
13
|
import { ProcedureBuilder } from './procedure-builder';
|
14
|
+
import { ProcedureBuilderWithInput } from './procedure-builder-with-input';
|
15
|
+
import { ProcedureBuilderWithOutput } from './procedure-builder-with-output';
|
12
16
|
import { DecoratedProcedure } from './procedure-decorated';
|
13
17
|
import { RouterBuilder } from './router-builder';
|
14
|
-
export interface
|
15
|
-
|
16
|
-
|
18
|
+
export interface BuilderConfig extends ContractBuilderConfig {
|
19
|
+
initialInputValidationIndex?: number;
|
20
|
+
initialOutputValidationIndex?: number;
|
17
21
|
}
|
18
|
-
export
|
22
|
+
export interface BuilderDef<TContext extends Context> {
|
23
|
+
types?: {
|
24
|
+
context: TContext;
|
25
|
+
};
|
26
|
+
config: BuilderConfig;
|
27
|
+
}
|
28
|
+
export declare class Builder<TContext extends Context> {
|
19
29
|
'~type': "Builder";
|
20
|
-
'~orpc': BuilderDef<TContext
|
21
|
-
constructor(def: BuilderDef<TContext
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
30
|
+
'~orpc': BuilderDef<TContext>;
|
31
|
+
constructor(def: BuilderDef<TContext>);
|
32
|
+
config(config: ContractBuilderConfig): Builder<TContext>;
|
33
|
+
context<UContext extends Context = TContext>(): Builder<UContext>;
|
34
|
+
middleware<UExtraContext extends Context & ContextGuard<TContext>, TInput, TOutput = any>(middleware: Middleware<TContext, UExtraContext, TInput, TOutput, Record<never, never>>): DecoratedMiddleware<TContext, UExtraContext, TInput, TOutput, Record<never, never>>;
|
35
|
+
errors<U extends ErrorMap & ErrorMapSuggestions>(errors: U): BuilderWithErrors<TContext, U>;
|
36
|
+
use<U extends Context & ContextGuard<TContext>>(middleware: Middleware<TContext, U, unknown, unknown, Record<never, never>>): BuilderWithMiddlewares<TContext, U>;
|
37
|
+
route(route: RouteOptions): ProcedureBuilder<TContext, undefined, Record<never, never>>;
|
38
|
+
input<USchema extends Schema>(schema: USchema, example?: SchemaInput<USchema>): ProcedureBuilderWithInput<TContext, undefined, USchema, Record<never, never>>;
|
39
|
+
output<USchema extends Schema>(schema: USchema, example?: SchemaOutput<USchema>): ProcedureBuilderWithOutput<TContext, undefined, USchema, Record<never, never>>;
|
40
|
+
handler<UFuncOutput>(handler: ProcedureHandler<TContext, undefined, undefined, undefined, UFuncOutput, Record<never, never>>): DecoratedProcedure<TContext, undefined, undefined, undefined, UFuncOutput, Record<never, never>>;
|
41
|
+
prefix(prefix: HTTPPath): RouterBuilder<TContext, undefined, Record<never, never>>;
|
42
|
+
tag(...tags: string[]): RouterBuilder<TContext, undefined, Record<never, never>>;
|
43
|
+
router<U extends Router<MergeContext<TContext, undefined>, any>>(router: U): AdaptedRouter<TContext, U, Record<never, never>>;
|
44
|
+
lazy<U extends Router<MergeContext<TContext, undefined>, any>>(loader: () => Promise<{
|
34
45
|
default: U;
|
35
|
-
}>): AdaptedRouter<TContext, FlattenLazy<U>,
|
36
|
-
contract<U extends ContractRouter<any>>(contract: U): ChainableImplementer<TContext,
|
46
|
+
}>): AdaptedRouter<TContext, FlattenLazy<U>, Record<never, never>>;
|
47
|
+
contract<U extends ContractRouter<any>>(contract: U): ChainableImplementer<TContext, undefined, U>;
|
37
48
|
}
|
38
49
|
//# sourceMappingURL=builder.d.ts.map
|
@@ -0,0 +1,11 @@
|
|
1
|
+
import type { Context } from './types';
|
2
|
+
/**
|
3
|
+
* U extends Context & ContextGuard<TContext>
|
4
|
+
*
|
5
|
+
* Purpose:
|
6
|
+
* - Ensures that any extension `U` of `Context` must conform to the current `TContext`.
|
7
|
+
* - This is useful when redefining `TContext` to maintain type compatibility with the existing context.
|
8
|
+
*
|
9
|
+
*/
|
10
|
+
export type ContextGuard<T extends Context> = Partial<T> | undefined;
|
11
|
+
//# sourceMappingURL=context.d.ts.map
|
@@ -6,5 +6,9 @@ import { RouterImplementer } from './router-implementer';
|
|
6
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
7
|
[K in keyof TContract]: TContract[K] extends ContractRouter<any> ? ChainableImplementer<TContext, TExtraContext, TContract[K]> : never;
|
8
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,
|
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>;
|
10
14
|
//# sourceMappingURL=implementer-chainable.d.ts.map
|
package/dist/src/index.d.ts
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
import type { WELL_CONTEXT } from './types';
|
2
2
|
import { Builder } from './builder';
|
3
3
|
export * from './builder';
|
4
|
+
export * from './config';
|
4
5
|
export * from './error';
|
5
6
|
export * from './hidden';
|
6
7
|
export * from './implementer-chainable';
|
@@ -20,6 +21,6 @@ export * from './router-client';
|
|
20
21
|
export * from './router-implementer';
|
21
22
|
export * from './types';
|
22
23
|
export * from './utils';
|
23
|
-
export {
|
24
|
-
export declare const os: Builder<WELL_CONTEXT
|
24
|
+
export { isDefinedError, ORPCError, safe, type } from '@orpc/contract';
|
25
|
+
export declare const os: Builder<WELL_CONTEXT>;
|
25
26
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1,8 +1,9 @@
|
|
1
|
+
import type { ContextGuard } from './context';
|
1
2
|
import type { ORPCErrorConstructorMap } from './error';
|
2
3
|
import type { MapInputMiddleware, Middleware } from './middleware';
|
3
4
|
import type { Context, MergeContext } from './types';
|
4
5
|
export interface DecoratedMiddleware<TContext extends Context, TExtraContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>> extends Middleware<TContext, TExtraContext, TInput, TOutput, TErrorConstructorMap> {
|
5
|
-
concat: (<UExtraContext extends Context &
|
6
|
+
concat: (<UExtraContext extends Context & ContextGuard<MergeContext<TContext, TExtraContext>>, UInput>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, UInput & TInput, TOutput, TErrorConstructorMap>) => DecoratedMiddleware<TContext, MergeContext<TExtraContext, UExtraContext>, UInput & TInput, TOutput, TErrorConstructorMap>) & (<UExtraContext extends Context & ContextGuard<MergeContext<TContext, TExtraContext>>, UInput = TInput, UMappedInput = unknown>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtraContext, UMappedInput, TOutput, TErrorConstructorMap>, mapInput: MapInputMiddleware<UInput & TInput, UMappedInput>) => DecoratedMiddleware<TContext, MergeContext<TExtraContext, UExtraContext>, UInput & TInput, TOutput, TErrorConstructorMap>);
|
6
7
|
mapInput: <UInput = unknown>(map: MapInputMiddleware<UInput, TInput>) => DecoratedMiddleware<TContext, TExtraContext, UInput, TOutput, TErrorConstructorMap>;
|
7
8
|
}
|
8
9
|
export declare function decorateMiddleware<TContext extends Context, TExtraContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>>(middleware: Middleware<TContext, TExtraContext, TInput, TOutput, TErrorConstructorMap>): DecoratedMiddleware<TContext, TExtraContext, TInput, TOutput, TErrorConstructorMap>;
|
@@ -0,0 +1,34 @@
|
|
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
|
@@ -0,0 +1,33 @@
|
|
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
|
@@ -1,24 +1,27 @@
|
|
1
1
|
import type { ContractProcedure, ErrorMap, ErrorMapGuard, ErrorMapSuggestions, RouteOptions, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
+
import type { ContextGuard } from './context';
|
2
3
|
import type { ORPCErrorConstructorMap } from './error';
|
3
|
-
import type {
|
4
|
+
import type { Middleware } from './middleware';
|
4
5
|
import type { ProcedureHandler } from './procedure';
|
5
6
|
import type { Context, MergeContext } from './types';
|
7
|
+
import { ProcedureBuilderWithInput } from './procedure-builder-with-input';
|
8
|
+
import { ProcedureBuilderWithOutput } from './procedure-builder-with-output';
|
6
9
|
import { DecoratedProcedure } from './procedure-decorated';
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
10
|
+
export interface ProcedureBuilderDef<TContext extends Context, TExtraContext extends Context, TErrorMap extends ErrorMap> {
|
11
|
+
contract: ContractProcedure<undefined, undefined, TErrorMap>;
|
12
|
+
middlewares: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, unknown, any, ORPCErrorConstructorMap<TErrorMap>>[];
|
13
|
+
inputValidationIndex: number;
|
14
|
+
outputValidationIndex: number;
|
11
15
|
}
|
12
|
-
export declare class ProcedureBuilder<TContext extends Context, TExtraContext extends Context,
|
16
|
+
export declare class ProcedureBuilder<TContext extends Context, TExtraContext extends Context, TErrorMap extends ErrorMap> {
|
13
17
|
'~type': "ProcedureBuilder";
|
14
|
-
'~orpc': ProcedureBuilderDef<TContext, TExtraContext,
|
15
|
-
constructor(def: ProcedureBuilderDef<TContext, TExtraContext,
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
handler<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap>): DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap>;
|
18
|
+
'~orpc': ProcedureBuilderDef<TContext, TExtraContext, TErrorMap>;
|
19
|
+
constructor(def: ProcedureBuilderDef<TContext, TExtraContext, TErrorMap>);
|
20
|
+
errors<U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions>(errors: U): ProcedureBuilder<TContext, TExtraContext, TErrorMap & U>;
|
21
|
+
route(route: RouteOptions): ProcedureBuilder<TContext, TExtraContext, TErrorMap>;
|
22
|
+
use<U extends Context & ContextGuard<MergeContext<TContext, TExtraContext>>>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>>): ProcedureBuilder<TContext, MergeContext<TExtraContext, U>, TErrorMap>;
|
23
|
+
input<U extends Schema>(schema: U, example?: SchemaInput<U>): ProcedureBuilderWithInput<TContext, TExtraContext, U, TErrorMap>;
|
24
|
+
output<U extends Schema>(schema: U, example?: SchemaOutput<U>): ProcedureBuilderWithOutput<TContext, TExtraContext, U, TErrorMap>;
|
25
|
+
handler<UFuncOutput>(handler: ProcedureHandler<TContext, TExtraContext, undefined, undefined, UFuncOutput, TErrorMap>): DecoratedProcedure<TContext, TExtraContext, undefined, undefined, UFuncOutput, TErrorMap>;
|
23
26
|
}
|
24
27
|
//# sourceMappingURL=procedure-builder.d.ts.map
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import type { ClientRest, ErrorMap, ErrorMapGuard, ErrorMapSuggestions, HTTPPath, RouteOptions, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
+
import type { ContextGuard } from './context';
|
2
3
|
import type { ORPCErrorConstructorMap } from './error';
|
3
4
|
import type { MapInputMiddleware, Middleware } from './middleware';
|
4
5
|
import type { CreateProcedureClientRest, ProcedureClient } from './procedure-client';
|
@@ -9,19 +10,17 @@ export declare class DecoratedProcedure<TContext extends Context, TExtraContext
|
|
9
10
|
prefix(prefix: HTTPPath): DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
10
11
|
route(route: RouteOptions): DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
11
12
|
errors<U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions>(errors: U): DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap & U>;
|
12
|
-
use<U extends Context &
|
13
|
-
use<UExtra extends Context &
|
13
|
+
use<U extends Context & ContextGuard<MergeContext<TContext, TExtraContext>>>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, SchemaOutput<TInputSchema>, THandlerOutput, ORPCErrorConstructorMap<TErrorMap>>): DecoratedProcedure<TContext, MergeContext<TExtraContext, U>, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
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>;
|
14
15
|
unshiftTag(...tags: string[]): DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
15
16
|
unshiftMiddleware(...middlewares: Middleware<TContext, Context & Partial<MergeContext<TContext, TExtraContext>> | undefined, unknown, SchemaOutput<TOutputSchema, THandlerOutput>, ORPCErrorConstructorMap<TErrorMap>>[]): DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
16
17
|
/**
|
17
18
|
* Make this procedure callable (works like a function while still being a procedure).
|
18
|
-
* **Note**: this only takes effect when this method is called at the end of the chain.
|
19
19
|
*/
|
20
|
-
callable<TClientContext>(...rest: CreateProcedureClientRest<TContext, TOutputSchema, THandlerOutput, TClientContext>):
|
20
|
+
callable<TClientContext>(...rest: CreateProcedureClientRest<TContext, TOutputSchema, THandlerOutput, TClientContext>): Procedure<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
21
21
|
/**
|
22
22
|
* Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
|
23
|
-
* **Note**: this only takes effect when this method is called at the end of the chain.
|
24
23
|
*/
|
25
|
-
actionable<TClientContext>(...rest: CreateProcedureClientRest<TContext, TOutputSchema, THandlerOutput, TClientContext>):
|
24
|
+
actionable<TClientContext>(...rest: CreateProcedureClientRest<TContext, TOutputSchema, THandlerOutput, TClientContext>): Procedure<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap> & ((...rest: ClientRest<TClientContext, SchemaInput<TInputSchema>>) => Promise<SchemaOutput<TOutputSchema, THandlerOutput>>);
|
26
25
|
}
|
27
26
|
//# sourceMappingURL=procedure-decorated.d.ts.map
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import type { ContractProcedure, ErrorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
+
import type { ContextGuard } from './context';
|
2
3
|
import type { ORPCErrorConstructorMap } from './error';
|
3
4
|
import type { MapInputMiddleware, Middleware } from './middleware';
|
4
5
|
import type { ProcedureHandler } from './procedure';
|
@@ -6,15 +7,16 @@ import type { Context, MergeContext } from './types';
|
|
6
7
|
import { DecoratedProcedure } from './procedure-decorated';
|
7
8
|
export type ProcedureImplementerDef<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap> = {
|
8
9
|
contract: ContractProcedure<TInputSchema, TOutputSchema, TErrorMap>;
|
9
|
-
|
10
|
-
|
10
|
+
middlewares: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, unknown, unknown, any>[];
|
11
|
+
inputValidationIndex: number;
|
12
|
+
outputValidationIndex: number;
|
11
13
|
};
|
12
14
|
export declare class ProcedureImplementer<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap> {
|
13
15
|
'~type': "ProcedureImplementer";
|
14
16
|
'~orpc': ProcedureImplementerDef<TContext, TExtraContext, TInputSchema, TOutputSchema, TErrorMap>;
|
15
17
|
constructor(def: ProcedureImplementerDef<TContext, TExtraContext, TInputSchema, TOutputSchema, TErrorMap>);
|
16
|
-
use<U extends Context &
|
17
|
-
use<UExtra extends Context &
|
18
|
+
use<U extends Context & ContextGuard<MergeContext<TContext, TExtraContext>>>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>>): ProcedureImplementer<TContext, MergeContext<TExtraContext, U>, TInputSchema, TOutputSchema, TErrorMap>;
|
19
|
+
use<UExtra extends Context & ContextGuard<MergeContext<TContext, TExtraContext>>, UInput>(middleware: Middleware<MergeContext<TContext, TExtraContext>, UExtra, UInput, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>): ProcedureImplementer<TContext, MergeContext<TExtraContext, UExtra>, TInputSchema, TOutputSchema, TErrorMap>;
|
18
20
|
handler<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap>): DecoratedProcedure<TContext, TExtraContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap>;
|
19
21
|
}
|
20
22
|
//# sourceMappingURL=procedure-implementer.d.ts.map
|
package/dist/src/procedure.d.ts
CHANGED
@@ -16,7 +16,7 @@ export interface ProcedureHandler<TContext extends Context, TExtraContext extend
|
|
16
16
|
(opt: ProcedureHandlerOptions<TContext, TExtraContext, SchemaOutput<TInputSchema>, ORPCErrorConstructorMap<TErrorMap>>): Promisable<SchemaInput<TOutputSchema, THandlerOutput>>;
|
17
17
|
}
|
18
18
|
/**
|
19
|
-
* Why is `ErrorConstructorMap` passed to `
|
19
|
+
* Why is `ErrorConstructorMap` passed to `middlewares` as `any`?
|
20
20
|
* Why is `ErrorMap` passed to `ProcedureHandler` as `any`?
|
21
21
|
*
|
22
22
|
* Passing `ErrorMap/ErrorConstructorMap` directly to `Middleware/ProcedureHandler`
|
@@ -27,8 +27,9 @@ export interface ProcedureHandler<TContext extends Context, TExtraContext extend
|
|
27
27
|
* The only downside is that direct access to them requires careful type checking to ensure safety.
|
28
28
|
*/
|
29
29
|
export interface ProcedureDef<TContext extends Context, TExtraContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TErrorMap extends ErrorMap> {
|
30
|
-
|
31
|
-
|
30
|
+
middlewares: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, unknown, unknown, any>[];
|
31
|
+
inputValidationIndex: number;
|
32
|
+
outputValidationIndex: number;
|
32
33
|
contract: ContractProcedure<TInputSchema, TOutputSchema, TErrorMap>;
|
33
34
|
handler: ProcedureHandler<TContext, TExtraContext, TInputSchema, TOutputSchema, THandlerOutput, any>;
|
34
35
|
}
|
@@ -1,4 +1,6 @@
|
|
1
1
|
import type { ContractRouter, ErrorMap, ErrorMapGuard, ErrorMapSuggestions, HTTPPath, StrictErrorMap } from '@orpc/contract';
|
2
|
+
import type { ContextGuard } from './context';
|
3
|
+
import type { ORPCErrorConstructorMap } from './error';
|
2
4
|
import type { FlattenLazy, Lazy } from './lazy';
|
3
5
|
import type { Middleware } from './middleware';
|
4
6
|
import type { Procedure } from './procedure';
|
@@ -12,7 +14,7 @@ export type AdaptedRouter<TContext extends Context, TRouter extends ANY_ROUTER,
|
|
12
14
|
export type RouterBuilderDef<TContext extends Context, TExtraContext extends Context, TErrorMap extends ErrorMap> = {
|
13
15
|
prefix?: HTTPPath;
|
14
16
|
tags?: readonly string[];
|
15
|
-
middlewares: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, unknown, any,
|
17
|
+
middlewares: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, unknown, any, ORPCErrorConstructorMap<TErrorMap>>[];
|
16
18
|
errorMap: TErrorMap;
|
17
19
|
};
|
18
20
|
export declare class RouterBuilder<TContext extends Context, TExtraContext extends Context, TErrorMap extends ErrorMap> {
|
@@ -22,7 +24,7 @@ export declare class RouterBuilder<TContext extends Context, TExtraContext exten
|
|
22
24
|
prefix(prefix: HTTPPath): RouterBuilder<TContext, TExtraContext, TErrorMap>;
|
23
25
|
tag(...tags: string[]): RouterBuilder<TContext, TExtraContext, TErrorMap>;
|
24
26
|
errors<U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions>(errors: U): RouterBuilder<TContext, TExtraContext, TErrorMap & U>;
|
25
|
-
use<U extends Context &
|
27
|
+
use<U extends Context & ContextGuard<MergeContext<TContext, TExtraContext>>>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, unknown, unknown, Record<never, never>>): RouterBuilder<TContext, MergeContext<TExtraContext, U>, TErrorMap>;
|
26
28
|
router<U extends Router<MergeContext<TContext, TExtraContext>, ContractRouter<ErrorMap & Partial<StrictErrorMap<TErrorMap>>>>>(router: U): AdaptedRouter<TContext, U, TErrorMap>;
|
27
29
|
lazy<U extends Router<MergeContext<TContext, TExtraContext>, ContractRouter<ErrorMap & Partial<StrictErrorMap<TErrorMap>>>>>(loader: () => Promise<{
|
28
30
|
default: U;
|
@@ -1,4 +1,5 @@
|
|
1
1
|
import type { ContractRouter } from '@orpc/contract';
|
2
|
+
import type { ContextGuard } from './context';
|
2
3
|
import type { FlattenLazy } from './lazy';
|
3
4
|
import type { Middleware } from './middleware';
|
4
5
|
import type { Router } from './router';
|
@@ -12,7 +13,7 @@ export declare class RouterImplementer<TContext extends Context, TExtraContext e
|
|
12
13
|
'~type': "RouterImplementer";
|
13
14
|
'~orpc': RouterImplementerDef<TContext, TExtraContext, TContract>;
|
14
15
|
constructor(def: RouterImplementerDef<TContext, TExtraContext, TContract>);
|
15
|
-
use<U extends Context &
|
16
|
+
use<U extends Context & ContextGuard<MergeContext<TContext, TExtraContext>>>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, unknown, unknown, Record<never, never>>): RouterImplementer<TContext, MergeContext<TExtraContext, U>, TContract>;
|
16
17
|
router<U extends Router<MergeContext<TContext, TExtraContext>, TContract>>(router: U): AdaptedRouter<TContext, U, Record<never, never>>;
|
17
18
|
lazy<U extends Router<MergeContext<TContext, TExtraContext>, TContract>>(loader: () => Promise<{
|
18
19
|
default: U;
|
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.32.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.32.0",
|
57
|
+
"@orpc/shared": "0.32.0"
|
58
58
|
},
|
59
59
|
"scripts": {
|
60
60
|
"build": "tsup --onSuccess='tsc -b --noCheck'",
|