@orpc/server 0.0.0-next.4220427 → 0.0.0-next.44bdf93
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-DNG2IB3R.js → chunk-GK2Z6B6W.js} +38 -35
- package/dist/{chunk-V3I7RIRY.js → chunk-SXUFCJBY.js} +5 -6
- package/dist/fetch.js +4 -4
- package/dist/hono.js +4 -4
- package/dist/index.js +614 -172
- package/dist/next.js +4 -4
- package/dist/node.js +6 -6
- package/dist/src/adapters/fetch/orpc-handler.d.ts +3 -3
- package/dist/src/adapters/node/orpc-handler.d.ts +3 -3
- package/dist/src/builder-with-errors-middlewares.d.ts +50 -0
- package/dist/src/builder-with-errors.d.ts +49 -0
- package/dist/src/builder-with-middlewares.d.ts +47 -0
- package/dist/src/builder.d.ts +30 -23
- package/dist/src/context.d.ts +11 -0
- package/dist/src/error.d.ts +1 -1
- package/dist/src/hidden.d.ts +2 -2
- package/dist/src/implementer-chainable.d.ts +7 -3
- package/dist/src/index.d.ts +3 -2
- package/dist/src/lazy-decorated.d.ts +3 -6
- package/dist/src/middleware-decorated.d.ts +2 -1
- package/dist/src/middleware.d.ts +1 -0
- 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 +21 -18
- package/dist/src/procedure-client.d.ts +7 -19
- package/dist/src/procedure-decorated.d.ts +21 -10
- package/dist/src/procedure-implementer.d.ts +7 -4
- package/dist/src/procedure-utils.d.ts +17 -0
- package/dist/src/procedure.d.ts +4 -2
- package/dist/src/router-builder.d.ts +19 -15
- package/dist/src/router-client.d.ts +7 -6
- package/dist/src/router-implementer.d.ts +7 -6
- package/dist/src/router.d.ts +3 -3
- package/package.json +3 -3
package/dist/next.js
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
import "./chunk-WUOGVGWG.js";
|
2
2
|
import {
|
3
|
-
ORPCHandler,
|
4
3
|
ORPCPayloadCodec,
|
5
4
|
ORPCProcedureMatcher,
|
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";
|
@@ -27,9 +27,9 @@ function serve(handler, ...[options]) {
|
|
27
27
|
};
|
28
28
|
}
|
29
29
|
export {
|
30
|
-
ORPCHandler,
|
31
30
|
ORPCPayloadCodec,
|
32
31
|
ORPCProcedureMatcher,
|
32
|
+
RPCHandler,
|
33
33
|
super_json_exports as SuperJSON,
|
34
34
|
serve
|
35
35
|
};
|
package/dist/node.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import {
|
2
|
-
|
3
|
-
} from "./chunk-
|
4
|
-
import "./chunk-
|
2
|
+
RPCHandler
|
3
|
+
} from "./chunk-SXUFCJBY.js";
|
4
|
+
import "./chunk-GK2Z6B6W.js";
|
5
5
|
|
6
6
|
// src/adapters/node/request-listener.ts
|
7
7
|
function createRequest(req, res) {
|
@@ -61,10 +61,10 @@ async function sendResponse(res, response) {
|
|
61
61
|
}
|
62
62
|
|
63
63
|
// src/adapters/node/orpc-handler.ts
|
64
|
-
var
|
64
|
+
var RPCHandler2 = class {
|
65
65
|
orpcFetchHandler;
|
66
66
|
constructor(router, options) {
|
67
|
-
this.orpcFetchHandler = new
|
67
|
+
this.orpcFetchHandler = new RPCHandler(router, options);
|
68
68
|
}
|
69
69
|
async handle(req, res, ...[options]) {
|
70
70
|
const request = createRequest(req, res);
|
@@ -79,7 +79,7 @@ var ORPCHandler2 = class {
|
|
79
79
|
}
|
80
80
|
};
|
81
81
|
export {
|
82
|
-
|
82
|
+
RPCHandler2 as RPCHandler,
|
83
83
|
createHeaders,
|
84
84
|
createRequest,
|
85
85
|
sendResponse
|
@@ -4,17 +4,17 @@ import type { Context } from '../../types';
|
|
4
4
|
import type { FetchHandler, FetchHandleRest, FetchHandleResult } from './types';
|
5
5
|
import { type PublicORPCPayloadCodec } from './orpc-payload-codec';
|
6
6
|
import { type PublicORPCProcedureMatcher } from './orpc-procedure-matcher';
|
7
|
-
export type
|
7
|
+
export type RPCHandlerOptions<T extends Context> = Hooks<Request, FetchHandleResult, T, {
|
8
8
|
signal?: AbortSignal;
|
9
9
|
}> & {
|
10
10
|
procedureMatcher?: PublicORPCProcedureMatcher;
|
11
11
|
payloadCodec?: PublicORPCPayloadCodec;
|
12
12
|
};
|
13
|
-
export declare class
|
13
|
+
export declare class RPCHandler<T extends Context> implements FetchHandler<T> {
|
14
14
|
private readonly options?;
|
15
15
|
private readonly procedureMatcher;
|
16
16
|
private readonly payloadCodec;
|
17
|
-
constructor(router: Router<T, any>, options?: NoInfer<
|
17
|
+
constructor(router: Router<T, any>, options?: NoInfer<RPCHandlerOptions<T>> | undefined);
|
18
18
|
handle(request: Request, ...[options]: FetchHandleRest<T>): Promise<FetchHandleResult>;
|
19
19
|
}
|
20
20
|
//# sourceMappingURL=orpc-handler.d.ts.map
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import type { ServerResponse } from 'node:http';
|
2
2
|
import type { Router } from '../../router';
|
3
3
|
import type { Context } from '../../types';
|
4
|
-
import type {
|
4
|
+
import type { RPCHandlerOptions } from '../fetch/orpc-handler';
|
5
5
|
import type { RequestHandler, RequestHandleRest, RequestHandleResult } from './types';
|
6
6
|
import { type ExpressableIncomingMessage } from './request-listener';
|
7
|
-
export declare class
|
7
|
+
export declare class RPCHandler<T extends Context> implements RequestHandler<T> {
|
8
8
|
private readonly orpcFetchHandler;
|
9
|
-
constructor(router: Router<T, any>, options?: NoInfer<
|
9
|
+
constructor(router: Router<T, any>, options?: NoInfer<RPCHandlerOptions<T>>);
|
10
10
|
handle(req: ExpressableIncomingMessage, res: ServerResponse, ...[options]: RequestHandleRest<T>): Promise<RequestHandleResult>;
|
11
11
|
}
|
12
12
|
//# sourceMappingURL=orpc-handler.d.ts.map
|
@@ -0,0 +1,50 @@
|
|
1
|
+
import type { 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
|
+
}
|
24
|
+
/**
|
25
|
+
* `BuilderWithErrorsMiddlewares` is a combination of `BuilderWithErrorsMiddlewares` and `BuilderWithErrors`.
|
26
|
+
*
|
27
|
+
* Why?
|
28
|
+
* - prevents .middleware after .use (can mislead the behavior)
|
29
|
+
* - prevents .contract after .errors (add error map to existing contract can make the contract invalid)
|
30
|
+
* - prevents .context after .use (middlewares required current context, so it tricky when change the current context)
|
31
|
+
*
|
32
|
+
*/
|
33
|
+
export declare class BuilderWithErrorsMiddlewares<TContext extends Context, TExtraContext extends Context, TErrorMap extends ErrorMap> {
|
34
|
+
'~type': "BuilderWithErrorsMiddlewares";
|
35
|
+
'~orpc': BuilderWithErrorsMiddlewaresDef<TContext, TExtraContext, TErrorMap>;
|
36
|
+
constructor(def: BuilderWithErrorsMiddlewaresDef<TContext, TExtraContext, TErrorMap>);
|
37
|
+
errors<U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions>(errors: U): BuilderWithErrorsMiddlewares<TContext, TExtraContext, TErrorMap & U>;
|
38
|
+
use<U extends Context & ContextGuard<MergeContext<TContext, TExtraContext>>>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>>): BuilderWithErrorsMiddlewares<TContext, MergeContext<TExtraContext, U>, TErrorMap>;
|
39
|
+
route(route: RouteOptions): ProcedureBuilder<TContext, TExtraContext, TErrorMap>;
|
40
|
+
input<USchema extends Schema>(schema: USchema, example?: SchemaInput<USchema>): ProcedureBuilderWithInput<TContext, TExtraContext, USchema, TErrorMap>;
|
41
|
+
output<USchema extends Schema>(schema: USchema, example?: SchemaOutput<USchema>): ProcedureBuilderWithOutput<TContext, TExtraContext, USchema, TErrorMap>;
|
42
|
+
handler<UFuncOutput>(handler: ProcedureHandler<TContext, TExtraContext, undefined, undefined, UFuncOutput, TErrorMap>): DecoratedProcedure<TContext, TExtraContext, undefined, undefined, UFuncOutput, TErrorMap>;
|
43
|
+
prefix(prefix: HTTPPath): RouterBuilder<TContext, TExtraContext, TErrorMap>;
|
44
|
+
tag(...tags: string[]): RouterBuilder<TContext, TExtraContext, TErrorMap>;
|
45
|
+
router<U extends Router<MergeContext<TContext, TExtraContext>, ContractRouter<ErrorMap & Partial<StrictErrorMap<TErrorMap>>>>>(router: U): AdaptedRouter<TContext, U, TErrorMap>;
|
46
|
+
lazy<U extends Router<MergeContext<TContext, TExtraContext>, ContractRouter<ErrorMap & Partial<StrictErrorMap<TErrorMap>>>>>(loader: () => Promise<{
|
47
|
+
default: U;
|
48
|
+
}>): AdaptedRouter<TContext, FlattenLazy<U>, TErrorMap>;
|
49
|
+
}
|
50
|
+
//# sourceMappingURL=builder-with-errors-middlewares.d.ts.map
|
@@ -0,0 +1,49 @@
|
|
1
|
+
import type { 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 { DecoratedMiddleware } from './middleware-decorated';
|
7
|
+
import type { ProcedureHandler } from './procedure';
|
8
|
+
import type { Router } from './router';
|
9
|
+
import type { AdaptedRouter } from './router-builder';
|
10
|
+
import type { Context, MergeContext } from './types';
|
11
|
+
import { BuilderWithErrorsMiddlewares } from './builder-with-errors-middlewares';
|
12
|
+
import { ProcedureBuilder } from './procedure-builder';
|
13
|
+
import { ProcedureBuilderWithInput } from './procedure-builder-with-input';
|
14
|
+
import { ProcedureBuilderWithOutput } from './procedure-builder-with-output';
|
15
|
+
import { DecoratedProcedure } from './procedure-decorated';
|
16
|
+
import { RouterBuilder } from './router-builder';
|
17
|
+
export interface BuilderWithErrorsDef<TContext extends Context, TErrorMap extends ErrorMap> {
|
18
|
+
types?: {
|
19
|
+
context: TContext;
|
20
|
+
};
|
21
|
+
errorMap: TErrorMap;
|
22
|
+
}
|
23
|
+
/**
|
24
|
+
* `BuilderWithErrors` is a branch of `Builder` which it has error map.
|
25
|
+
*
|
26
|
+
* Why?
|
27
|
+
* - prevents .contract after .errors (add error map to existing contract can make the contract invalid)
|
28
|
+
*
|
29
|
+
*/
|
30
|
+
export declare class BuilderWithErrors<TContext extends Context, TErrorMap extends ErrorMap> {
|
31
|
+
'~type': "BuilderWithErrors";
|
32
|
+
'~orpc': BuilderWithErrorsDef<TContext, TErrorMap>;
|
33
|
+
constructor(def: BuilderWithErrorsDef<TContext, TErrorMap>);
|
34
|
+
context<UContext extends Context = TContext>(): BuilderWithErrors<UContext, TErrorMap>;
|
35
|
+
errors<U extends ErrorMap & ErrorMapGuard<TErrorMap> & ErrorMapSuggestions>(errors: U): BuilderWithErrors<TContext, TErrorMap & U>;
|
36
|
+
middleware<UExtraContext extends Context & ContextGuard<TContext>, TInput, TOutput = any>(middleware: Middleware<TContext, UExtraContext, TInput, TOutput, ORPCErrorConstructorMap<TErrorMap>>): DecoratedMiddleware<TContext, UExtraContext, TInput, TOutput, ORPCErrorConstructorMap<TErrorMap>>;
|
37
|
+
use<U extends Context & ContextGuard<TContext>>(middleware: Middleware<TContext, U, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>>): BuilderWithErrorsMiddlewares<TContext, U, TErrorMap>;
|
38
|
+
route(route: RouteOptions): ProcedureBuilder<TContext, undefined, TErrorMap>;
|
39
|
+
input<USchema extends Schema>(schema: USchema, example?: SchemaInput<USchema>): ProcedureBuilderWithInput<TContext, undefined, USchema, TErrorMap>;
|
40
|
+
output<USchema extends Schema>(schema: USchema, example?: SchemaOutput<USchema>): ProcedureBuilderWithOutput<TContext, undefined, USchema, TErrorMap>;
|
41
|
+
handler<UFuncOutput>(handler: ProcedureHandler<TContext, undefined, undefined, undefined, UFuncOutput, TErrorMap>): DecoratedProcedure<TContext, undefined, undefined, undefined, UFuncOutput, TErrorMap>;
|
42
|
+
prefix(prefix: HTTPPath): RouterBuilder<TContext, undefined, TErrorMap>;
|
43
|
+
tag(...tags: string[]): RouterBuilder<TContext, undefined, TErrorMap>;
|
44
|
+
router<U extends Router<MergeContext<TContext, undefined>, ContractRouter<ErrorMap & Partial<StrictErrorMap<TErrorMap>>>>>(router: U): AdaptedRouter<TContext, U, TErrorMap>;
|
45
|
+
lazy<U extends Router<MergeContext<TContext, undefined>, ContractRouter<ErrorMap & Partial<StrictErrorMap<TErrorMap>>>>>(loader: () => Promise<{
|
46
|
+
default: U;
|
47
|
+
}>): AdaptedRouter<TContext, FlattenLazy<U>, TErrorMap>;
|
48
|
+
}
|
49
|
+
//# sourceMappingURL=builder-with-errors.d.ts.map
|
@@ -0,0 +1,47 @@
|
|
1
|
+
import type { 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
|
+
middlewares: Middleware<MergeContext<TContext, TExtraContext>, Partial<TExtraContext> | undefined, unknown, any, Record<never, never>>[];
|
26
|
+
inputValidationIndex: number;
|
27
|
+
outputValidationIndex: number;
|
28
|
+
}
|
29
|
+
export declare class BuilderWithMiddlewares<TContext extends Context, TExtraContext extends Context> {
|
30
|
+
'~type': "BuilderHasMiddlewares";
|
31
|
+
'~orpc': BuilderWithMiddlewaresDef<TContext, TExtraContext>;
|
32
|
+
constructor(def: BuilderWithMiddlewaresDef<TContext, TExtraContext>);
|
33
|
+
use<U extends Context & ContextGuard<MergeContext<TContext, TExtraContext>>>(middleware: Middleware<MergeContext<TContext, TExtraContext>, U, unknown, unknown, Record<never, never>>): BuilderWithMiddlewares<TContext, MergeContext<TExtraContext, U>>;
|
34
|
+
errors<U extends ErrorMap & ErrorMapSuggestions>(errors: U): BuilderWithErrorsMiddlewares<TContext, TExtraContext, U>;
|
35
|
+
route(route: RouteOptions): ProcedureBuilder<TContext, TExtraContext, Record<never, never>>;
|
36
|
+
input<USchema extends Schema>(schema: USchema, example?: SchemaInput<USchema>): ProcedureBuilderWithInput<TContext, TExtraContext, USchema, Record<never, never>>;
|
37
|
+
output<USchema extends Schema>(schema: USchema, example?: SchemaOutput<USchema>): ProcedureBuilderWithOutput<TContext, TExtraContext, USchema, Record<never, never>>;
|
38
|
+
handler<UFuncOutput>(handler: ProcedureHandler<TContext, TExtraContext, undefined, undefined, UFuncOutput, Record<never, never>>): DecoratedProcedure<TContext, TExtraContext, undefined, undefined, UFuncOutput, Record<never, never>>;
|
39
|
+
prefix(prefix: HTTPPath): RouterBuilder<TContext, TExtraContext, Record<never, never>>;
|
40
|
+
tag(...tags: string[]): RouterBuilder<TContext, TExtraContext, Record<never, never>>;
|
41
|
+
router<U extends Router<MergeContext<TContext, TExtraContext>, any>>(router: U): AdaptedRouter<TContext, U, Record<never, never>>;
|
42
|
+
lazy<U extends Router<MergeContext<TContext, TExtraContext>, any>>(loader: () => Promise<{
|
43
|
+
default: U;
|
44
|
+
}>): AdaptedRouter<TContext, FlattenLazy<U>, Record<never, never>>;
|
45
|
+
contract<U extends ContractRouter<any>>(contract: U): ChainableImplementer<TContext, TExtraContext, U>;
|
46
|
+
}
|
47
|
+
//# sourceMappingURL=builder-with-middlewares.d.ts.map
|
package/dist/src/builder.d.ts
CHANGED
@@ -1,36 +1,43 @@
|
|
1
|
-
import type {
|
1
|
+
import type { ContractRouter, ErrorMap, ErrorMapSuggestions, HTTPPath, RouteOptions, Schema, SchemaInput, SchemaOutput } 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 { DecoratedMiddleware } from './middleware-decorated';
|
6
|
+
import type { ProcedureHandler } from './procedure';
|
5
7
|
import type { Router } from './router';
|
6
8
|
import type { AdaptedRouter } from './router-builder';
|
7
|
-
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';
|
8
12
|
import { type ChainableImplementer } from './implementer-chainable';
|
9
|
-
import { type ProcedureHandler } from './procedure';
|
10
13
|
import { ProcedureBuilder } from './procedure-builder';
|
11
|
-
import {
|
14
|
+
import { ProcedureBuilderWithInput } from './procedure-builder-with-input';
|
15
|
+
import { ProcedureBuilderWithOutput } from './procedure-builder-with-output';
|
16
|
+
import { DecoratedProcedure } from './procedure-decorated';
|
12
17
|
import { RouterBuilder } from './router-builder';
|
13
|
-
export interface BuilderDef<TContext extends Context
|
14
|
-
|
18
|
+
export interface BuilderDef<TContext extends Context> {
|
19
|
+
types?: {
|
20
|
+
context: TContext;
|
21
|
+
};
|
15
22
|
}
|
16
|
-
export declare class Builder<TContext extends Context
|
23
|
+
export declare class Builder<TContext extends Context> {
|
17
24
|
'~type': "Builder";
|
18
|
-
'~orpc': BuilderDef<TContext
|
19
|
-
constructor(def: BuilderDef<TContext
|
20
|
-
context<UContext extends Context =
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
handler<UFuncOutput
|
28
|
-
prefix(prefix: HTTPPath): RouterBuilder<TContext,
|
29
|
-
tag(...tags: string[]): RouterBuilder<TContext,
|
30
|
-
router<U extends Router<MergeContext<TContext,
|
31
|
-
lazy<U extends Router<MergeContext<TContext,
|
25
|
+
'~orpc': BuilderDef<TContext>;
|
26
|
+
constructor(def: BuilderDef<TContext>);
|
27
|
+
context<UContext extends Context = TContext>(): Builder<UContext>;
|
28
|
+
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>>;
|
29
|
+
errors<U extends ErrorMap & ErrorMapSuggestions>(errors: U): BuilderWithErrors<TContext, U>;
|
30
|
+
use<U extends Context & ContextGuard<TContext>>(middleware: Middleware<TContext, U, unknown, unknown, Record<never, never>>): BuilderWithMiddlewares<TContext, U>;
|
31
|
+
route(route: RouteOptions): ProcedureBuilder<TContext, undefined, Record<never, never>>;
|
32
|
+
input<USchema extends Schema>(schema: USchema, example?: SchemaInput<USchema>): ProcedureBuilderWithInput<TContext, undefined, USchema, Record<never, never>>;
|
33
|
+
output<USchema extends Schema>(schema: USchema, example?: SchemaOutput<USchema>): ProcedureBuilderWithOutput<TContext, undefined, USchema, Record<never, never>>;
|
34
|
+
handler<UFuncOutput>(handler: ProcedureHandler<TContext, undefined, undefined, undefined, UFuncOutput, Record<never, never>>): DecoratedProcedure<TContext, undefined, undefined, undefined, UFuncOutput, Record<never, never>>;
|
35
|
+
prefix(prefix: HTTPPath): RouterBuilder<TContext, undefined, Record<never, never>>;
|
36
|
+
tag(...tags: string[]): RouterBuilder<TContext, undefined, Record<never, never>>;
|
37
|
+
router<U extends Router<MergeContext<TContext, undefined>, any>>(router: U): AdaptedRouter<TContext, U, Record<never, never>>;
|
38
|
+
lazy<U extends Router<MergeContext<TContext, undefined>, any>>(loader: () => Promise<{
|
32
39
|
default: U;
|
33
|
-
}>): AdaptedRouter<TContext, FlattenLazy<U>>;
|
34
|
-
contract<U extends
|
40
|
+
}>): AdaptedRouter<TContext, FlattenLazy<U>, Record<never, never>>;
|
41
|
+
contract<U extends ContractRouter<any>>(contract: U): ChainableImplementer<TContext, undefined, U>;
|
35
42
|
}
|
36
43
|
//# 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
|
package/dist/src/error.d.ts
CHANGED
@@ -3,7 +3,7 @@ import { ORPCError } from '@orpc/contract';
|
|
3
3
|
export type ORPCErrorConstructorMapItemOptions<TData> = Omit<ORPCErrorOptions<any, TData>, 'defined' | 'code' | 'status'>;
|
4
4
|
export type ORPCErrorConstructorMapItemRest<TData> = [options: ORPCErrorConstructorMapItemOptions<TData>] | (undefined extends TData ? [] : never);
|
5
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> =
|
6
|
+
export type ORPCErrorConstructorMap<T extends ErrorMap> = {
|
7
7
|
[K in keyof T]: K extends string ? T[K] extends ErrorMapItem<infer UInputSchema> ? ORPCErrorConstructorMapItem<K, UInputSchema> : never : never;
|
8
8
|
};
|
9
9
|
export declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
|
package/dist/src/hidden.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { ContractRouter, HTTPPath } from '@orpc/contract';
|
2
|
-
export declare function setRouterContract<T extends object>(obj: T, contract: ContractRouter): T;
|
3
|
-
export declare function getRouterContract(obj: object): ContractRouter | undefined;
|
2
|
+
export declare function setRouterContract<T extends object>(obj: T, contract: ContractRouter<any>): T;
|
3
|
+
export declare function getRouterContract(obj: object): ContractRouter<any> | undefined;
|
4
4
|
export declare function deepSetLazyRouterPrefix<T extends object>(router: T, prefix: HTTPPath): T;
|
5
5
|
export declare function getLazyRouterPrefix(obj: object): HTTPPath | undefined;
|
6
6
|
//# sourceMappingURL=hidden.d.ts.map
|
@@ -3,8 +3,12 @@ import type { Context, MergeContext, WELL_CONTEXT } from './types';
|
|
3
3
|
import { type ContractProcedure, type ContractRouter } from '@orpc/contract';
|
4
4
|
import { ProcedureImplementer } from './procedure-implementer';
|
5
5
|
import { RouterImplementer } from './router-implementer';
|
6
|
-
export type ChainableImplementer<TContext extends Context, TExtraContext extends Context, TContract extends ContractRouter
|
7
|
-
[K in keyof TContract]: TContract[K] extends ContractRouter ? ChainableImplementer<TContext, TExtraContext, TContract[K]> : never;
|
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
8
|
} & Omit<RouterImplementer<TContext, TExtraContext, TContract>, '~type' | '~orpc'>;
|
9
|
-
export declare function createChainableImplementer<TContext extends Context = WELL_CONTEXT, TExtraContext extends Context = undefined, TContract extends ContractRouter = any>(contract: TContract,
|
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
@@ -13,12 +13,13 @@ export * from './procedure-builder';
|
|
13
13
|
export * from './procedure-client';
|
14
14
|
export * from './procedure-decorated';
|
15
15
|
export * from './procedure-implementer';
|
16
|
+
export * from './procedure-utils';
|
16
17
|
export * from './router';
|
17
18
|
export * from './router-builder';
|
18
19
|
export * from './router-client';
|
19
20
|
export * from './router-implementer';
|
20
21
|
export * from './types';
|
21
22
|
export * from './utils';
|
22
|
-
export { configGlobal, fallbackToGlobalConfig, isDefinedError, ORPCError, safe } from '@orpc/contract';
|
23
|
-
export declare const os: Builder<WELL_CONTEXT
|
23
|
+
export { configGlobal, fallbackToGlobalConfig, isDefinedError, ORPCError, safe, type } from '@orpc/contract';
|
24
|
+
export declare const os: Builder<WELL_CONTEXT>;
|
24
25
|
//# sourceMappingURL=index.d.ts.map
|
@@ -1,10 +1,7 @@
|
|
1
|
-
import type { ErrorFromErrorMap, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
1
|
import type { Lazy } from './lazy';
|
3
|
-
import type { Procedure } from './procedure';
|
4
|
-
import type { ProcedureClient } from './procedure-client';
|
5
2
|
import { type ANY_ROUTER } from './router';
|
6
|
-
export type DecoratedLazy<T> = T extends Lazy<infer U> ? DecoratedLazy<U> : Lazy<T> & (T extends
|
7
|
-
[K in keyof T]:
|
8
|
-
});
|
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);
|
9
6
|
export declare function decorateLazy<T extends Lazy<ANY_ROUTER | undefined>>(lazied: T): DecoratedLazy<T>;
|
10
7
|
//# sourceMappingURL=lazy-decorated.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>;
|
package/dist/src/middleware.d.ts
CHANGED
@@ -32,4 +32,5 @@ export interface MapInputMiddleware<TInput, TMappedInput> {
|
|
32
32
|
(input: TInput): TMappedInput;
|
33
33
|
}
|
34
34
|
export type ANY_MAP_INPUT_MIDDLEWARE = MapInputMiddleware<any, any>;
|
35
|
+
export declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<undefined, TOutput>;
|
35
36
|
//# sourceMappingURL=middleware.d.ts.map
|
@@ -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
|
-
import type { ContractProcedure, ErrorMap, RouteOptions, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
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 {
|
4
|
+
import type { Middleware } from './middleware';
|
5
|
+
import type { ProcedureHandler } from './procedure';
|
5
6
|
import type { Context, MergeContext } from './types';
|
6
|
-
import {
|
7
|
-
import {
|
8
|
-
|
9
|
-
|
10
|
-
|
7
|
+
import { ProcedureBuilderWithInput } from './procedure-builder-with-input';
|
8
|
+
import { ProcedureBuilderWithOutput } from './procedure-builder-with-output';
|
9
|
+
import { DecoratedProcedure } from './procedure-decorated';
|
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
|
@@ -2,33 +2,21 @@ import type { Client, ErrorFromErrorMap, ErrorMap, Schema, SchemaInput, SchemaOu
|
|
2
2
|
import type { Hooks, Value } from '@orpc/shared';
|
3
3
|
import type { Lazyable } from './lazy';
|
4
4
|
import type { Procedure } from './procedure';
|
5
|
-
import type {
|
6
|
-
export type
|
7
|
-
signal?: AbortSignal;
|
8
|
-
} & (undefined extends TClientContext ? {
|
9
|
-
context?: TClientContext;
|
10
|
-
} : {
|
11
|
-
context: TClientContext;
|
12
|
-
});
|
13
|
-
export type ProcedureClient<TClientContext, TInput, TOutput, TError extends Error> = Client<TClientContext, TInput, TOutput, TError>;
|
5
|
+
import type { Context, Meta } from './types';
|
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>>;
|
14
7
|
/**
|
15
8
|
* Options for creating a procedure caller with comprehensive type safety
|
16
9
|
*/
|
17
|
-
export type CreateProcedureClientOptions<TContext extends Context,
|
18
|
-
procedure: Lazyable<Procedure<TContext, any, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>>;
|
10
|
+
export type CreateProcedureClientOptions<TContext extends Context, TOutputSchema extends Schema, THandlerOutput extends SchemaInput<TOutputSchema>, TClientContext> = {
|
19
11
|
/**
|
20
12
|
* This is helpful for logging and analytics.
|
21
|
-
*
|
22
|
-
* @internal
|
23
13
|
*/
|
24
14
|
path?: string[];
|
25
15
|
} & ({
|
26
|
-
|
27
|
-
* The context used when calling the procedure.
|
28
|
-
*/
|
29
|
-
context: Value<TContext>;
|
16
|
+
context: Value<TContext, [clientContext: TClientContext]>;
|
30
17
|
} | (undefined extends TContext ? {
|
31
|
-
context?:
|
18
|
+
context?: Value<TContext, [clientContext: TClientContext]>;
|
32
19
|
} : never)) & Hooks<unknown, SchemaOutput<TOutputSchema, THandlerOutput>, TContext, Meta>;
|
33
|
-
export
|
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>;
|
34
22
|
//# sourceMappingURL=procedure-client.d.ts.map
|