@orpc/server 0.31.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 +191 -787
- 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 +50 -36
- package/dist/src/config.d.ts +6 -0
- 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 +9 -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 -50
- package/dist/src/builder-with-errors.d.ts +0 -49
- package/dist/src/builder-with-middlewares.d.ts +0 -47
- 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/next.js
CHANGED
@@ -4,14 +4,14 @@ import {
|
|
4
4
|
ORPCProcedureMatcher,
|
5
5
|
RPCHandler,
|
6
6
|
super_json_exports
|
7
|
-
} from "./chunk-
|
8
|
-
import "./chunk-
|
7
|
+
} from "./chunk-ESTRJAOX.js";
|
8
|
+
import "./chunk-KK4SDLC7.js";
|
9
9
|
|
10
10
|
// src/adapters/next/serve.ts
|
11
11
|
import { value } from "@orpc/shared";
|
12
12
|
function serve(handler, ...[options]) {
|
13
13
|
const main = async (req) => {
|
14
|
-
const context = await value(options?.context, req);
|
14
|
+
const context = await value(options?.context ?? {}, req);
|
15
15
|
const { matched, response } = await handler.handle(req, { ...options, context });
|
16
16
|
if (matched) {
|
17
17
|
return response;
|
package/dist/node.js
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
import {
|
2
2
|
RPCHandler
|
3
|
-
} from "./chunk-
|
4
|
-
import "./chunk-
|
3
|
+
} from "./chunk-ESTRJAOX.js";
|
4
|
+
import "./chunk-KK4SDLC7.js";
|
5
5
|
|
6
6
|
// src/adapters/node/request-listener.ts
|
7
7
|
function createRequest(req, res) {
|
@@ -66,14 +66,14 @@ var RPCHandler2 = class {
|
|
66
66
|
constructor(router, options) {
|
67
67
|
this.orpcFetchHandler = new RPCHandler(router, options);
|
68
68
|
}
|
69
|
-
async handle(req, res, ...
|
69
|
+
async handle(req, res, ...rest) {
|
70
70
|
const request = createRequest(req, res);
|
71
|
-
const
|
72
|
-
const result = await this.orpcFetchHandler.handle(request, castedOptions);
|
71
|
+
const result = await this.orpcFetchHandler.handle(request, ...rest);
|
73
72
|
if (result.matched === false) {
|
74
73
|
return { matched: false };
|
75
74
|
}
|
76
|
-
|
75
|
+
const context = rest[0]?.context ?? {};
|
76
|
+
await rest[0]?.beforeSend?.(result.response, context);
|
77
77
|
await sendResponse(res, result.response);
|
78
78
|
return { matched: true };
|
79
79
|
}
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import type { Hooks } from '@orpc/shared';
|
2
|
+
import type { Context } from '../../context';
|
2
3
|
import type { Router } from '../../router';
|
3
|
-
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';
|
@@ -1,11 +1,11 @@
|
|
1
|
-
import type {
|
2
|
-
import {
|
1
|
+
import type { AnyProcedure } from '../../procedure';
|
2
|
+
import type { AnyRouter } from '../../router';
|
3
3
|
export declare class ORPCProcedureMatcher {
|
4
4
|
private readonly router;
|
5
|
-
constructor(router:
|
5
|
+
constructor(router: AnyRouter);
|
6
6
|
match(pathname: string): Promise<{
|
7
7
|
path: string[];
|
8
|
-
procedure:
|
8
|
+
procedure: AnyProcedure;
|
9
9
|
} | undefined>;
|
10
10
|
}
|
11
11
|
export type PublicORPCProcedureMatcher = Pick<ORPCProcedureMatcher, keyof ORPCProcedureMatcher>;
|
@@ -1,13 +1,13 @@
|
|
1
1
|
import type { HTTPPath } from '@orpc/contract';
|
2
|
-
import type { Context } from '../../
|
2
|
+
import type { Context } from '../../context';
|
3
3
|
export type FetchHandleOptions<T extends Context> = {
|
4
4
|
prefix?: HTTPPath;
|
5
|
-
} & (
|
5
|
+
} & (Record<never, never> extends T ? {
|
6
6
|
context?: T;
|
7
7
|
} : {
|
8
8
|
context: T;
|
9
9
|
});
|
10
|
-
export type FetchHandleRest<T extends Context> = [options: FetchHandleOptions<T>] | (
|
10
|
+
export type FetchHandleRest<T extends Context> = [options: FetchHandleOptions<T>] | (Record<never, never> extends T ? [] : never);
|
11
11
|
export type FetchHandleResult = {
|
12
12
|
matched: true;
|
13
13
|
response: Response;
|
@@ -16,6 +16,6 @@ export type FetchHandleResult = {
|
|
16
16
|
response: undefined;
|
17
17
|
};
|
18
18
|
export interface FetchHandler<T extends Context> {
|
19
|
-
handle
|
19
|
+
handle(request: Request, ...rest: FetchHandleRest<T>): Promise<FetchHandleResult>;
|
20
20
|
}
|
21
21
|
//# sourceMappingURL=types.d.ts.map
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import type { Context as HonoContext, MiddlewareHandler } from 'hono';
|
2
|
-
import type { Context } from '../../
|
2
|
+
import type { Context } from '../../context';
|
3
3
|
import type { FetchHandleOptions, FetchHandler } from '../fetch';
|
4
4
|
import { type Value } from '@orpc/shared';
|
5
|
-
export type CreateMiddlewareOptions<T extends Context> = Omit<FetchHandleOptions<T>, 'context'> & (
|
5
|
+
export type CreateMiddlewareOptions<T extends Context> = Omit<FetchHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
6
6
|
context?: Value<T, [HonoContext]>;
|
7
7
|
} : {
|
8
8
|
context: Value<T, [HonoContext]>;
|
9
9
|
});
|
10
|
-
export type CreateMiddlewareRest<T extends Context> = [options: CreateMiddlewareOptions<T>] | (
|
10
|
+
export type CreateMiddlewareRest<T extends Context> = [options: CreateMiddlewareOptions<T>] | (Record<never, never> extends T ? [] : never);
|
11
11
|
export declare function createMiddleware<T extends Context>(handler: FetchHandler<T>, ...[options]: CreateMiddlewareRest<T>): MiddlewareHandler;
|
12
12
|
//# sourceMappingURL=middleware.d.ts.map
|
@@ -1,19 +1,19 @@
|
|
1
1
|
import type { NextRequest } from 'next/server';
|
2
|
-
import type { Context } from '../../
|
2
|
+
import type { Context } from '../../context';
|
3
3
|
import type { FetchHandleOptions, FetchHandler } from '../fetch';
|
4
4
|
import { type Value } from '@orpc/shared';
|
5
|
-
export type ServeOptions<T extends Context> = Omit<FetchHandleOptions<T>, 'context'> & (
|
5
|
+
export type ServeOptions<T extends Context> = Omit<FetchHandleOptions<T>, 'context'> & (Record<never, never> extends T ? {
|
6
6
|
context?: Value<T, [NextRequest]>;
|
7
7
|
} : {
|
8
8
|
context: Value<T, [NextRequest]>;
|
9
9
|
});
|
10
|
-
export type ServeRest<T extends Context> = [options: ServeOptions<T>] | (
|
10
|
+
export type ServeRest<T extends Context> = [options: ServeOptions<T>] | (Record<never, never> extends T ? [] : never);
|
11
11
|
export interface ServeResult {
|
12
|
-
GET
|
13
|
-
POST
|
14
|
-
PUT
|
15
|
-
PATCH
|
16
|
-
DELETE
|
12
|
+
GET(req: NextRequest): Promise<Response>;
|
13
|
+
POST(req: NextRequest): Promise<Response>;
|
14
|
+
PUT(req: NextRequest): Promise<Response>;
|
15
|
+
PATCH(req: NextRequest): Promise<Response>;
|
16
|
+
DELETE(req: NextRequest): Promise<Response>;
|
17
17
|
}
|
18
18
|
export declare function serve<T extends Context>(handler: FetchHandler<T>, ...[options]: ServeRest<T>): ServeResult;
|
19
19
|
//# sourceMappingURL=serve.d.ts.map
|
@@ -1,12 +1,12 @@
|
|
1
1
|
import type { ServerResponse } from 'node:http';
|
2
|
+
import type { Context } from '../../context';
|
2
3
|
import type { Router } from '../../router';
|
3
|
-
import type { Context } from '../../types';
|
4
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
7
|
export declare class RPCHandler<T extends Context> implements RequestHandler<T> {
|
8
8
|
private readonly orpcFetchHandler;
|
9
9
|
constructor(router: Router<T, any>, options?: NoInfer<RPCHandlerOptions<T>>);
|
10
|
-
handle(req: ExpressableIncomingMessage, res: ServerResponse, ...
|
10
|
+
handle(req: ExpressableIncomingMessage, res: ServerResponse, ...rest: RequestHandleRest<T>): Promise<RequestHandleResult>;
|
11
11
|
}
|
12
12
|
//# sourceMappingURL=orpc-handler.d.ts.map
|
@@ -1,22 +1,22 @@
|
|
1
1
|
import type { HTTPPath } from '@orpc/contract';
|
2
2
|
import type { Promisable } from '@orpc/shared';
|
3
3
|
import type { IncomingMessage, ServerResponse } from 'node:http';
|
4
|
-
import type { Context } from '../../
|
4
|
+
import type { Context } from '../../context';
|
5
5
|
export type RequestHandleOptions<T extends Context> = {
|
6
6
|
prefix?: HTTPPath;
|
7
|
-
beforeSend
|
8
|
-
} & (
|
7
|
+
beforeSend?(response: Response, context: T): Promisable<void>;
|
8
|
+
} & (Record<never, never> extends T ? {
|
9
9
|
context?: T;
|
10
10
|
} : {
|
11
11
|
context: T;
|
12
12
|
});
|
13
|
-
export type RequestHandleRest<T extends Context> = [options: RequestHandleOptions<T>] | (
|
13
|
+
export type RequestHandleRest<T extends Context> = [options: RequestHandleOptions<T>] | (Record<never, never> extends T ? [] : never);
|
14
14
|
export type RequestHandleResult = {
|
15
15
|
matched: true;
|
16
16
|
} | {
|
17
17
|
matched: false;
|
18
18
|
};
|
19
19
|
export interface RequestHandler<T extends Context> {
|
20
|
-
handle
|
20
|
+
handle(req: IncomingMessage, res: ServerResponse, ...rest: RequestHandleRest<T>): Promise<RequestHandleResult>;
|
21
21
|
}
|
22
22
|
//# sourceMappingURL=types.d.ts.map
|
@@ -0,0 +1,74 @@
|
|
1
|
+
import type { ContractRouter, ErrorMap, HTTPPath, MergedErrorMap, Meta, ORPCErrorConstructorMap, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
+
import type { BuilderDef } from './builder';
|
3
|
+
import type { ConflictContextGuard, Context, MergedContext } from './context';
|
4
|
+
import type { FlattenLazy } from './lazy-utils';
|
5
|
+
import type { MapInputMiddleware, Middleware } from './middleware';
|
6
|
+
import type { ProcedureHandler } from './procedure';
|
7
|
+
import type { DecoratedProcedure } from './procedure-decorated';
|
8
|
+
import type { AdaptedRouter, AdaptRouterOptions, Router } from './router';
|
9
|
+
export interface BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
10
|
+
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
11
|
+
'errors'<U extends ErrorMap>(errors: U): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
12
|
+
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & BuilderWithMiddlewares<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
13
|
+
'meta'(meta: TMeta): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
14
|
+
'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
15
|
+
'input'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
16
|
+
'output'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
17
|
+
'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
|
18
|
+
'prefix'(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
19
|
+
'tag'(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
20
|
+
'router'<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(router: U): AdaptedRouter<U, TInitialContext, TErrorMap>;
|
21
|
+
'lazy'<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(loader: () => Promise<{
|
22
|
+
default: U;
|
23
|
+
}>): AdaptedRouter<FlattenLazy<U>, TInitialContext, TErrorMap>;
|
24
|
+
}
|
25
|
+
export interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
26
|
+
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
27
|
+
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
28
|
+
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilder<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
29
|
+
'meta'(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
30
|
+
'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
31
|
+
'input'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
32
|
+
'output'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
33
|
+
'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
|
34
|
+
}
|
35
|
+
export interface ProcedureBuilderWithInput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
36
|
+
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
37
|
+
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
38
|
+
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
39
|
+
'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
40
|
+
'meta'(meta: TMeta): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
41
|
+
'route'(route: Route): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
42
|
+
'output'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
43
|
+
'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
|
44
|
+
}
|
45
|
+
export interface ProcedureBuilderWithOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
46
|
+
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
47
|
+
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
48
|
+
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithOutput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
49
|
+
'meta'(meta: TMeta): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
50
|
+
'route'(route: Route): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
51
|
+
'input'<USchema extends Schema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
52
|
+
'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
|
53
|
+
}
|
54
|
+
export interface ProcedureBuilderWithInputOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
55
|
+
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
56
|
+
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
57
|
+
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInputOutput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
58
|
+
'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInputOutput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
59
|
+
'meta'(meta: TMeta): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
60
|
+
'route'(route: Route): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
61
|
+
'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
|
62
|
+
}
|
63
|
+
export interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
64
|
+
'~orpc': AdaptRouterOptions<TErrorMap>;
|
65
|
+
'errors'<U extends ErrorMap>(errors: U): RouterBuilder<TInitialContext, TCurrentContext, MergedErrorMap<TErrorMap, U>, TMeta>;
|
66
|
+
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & RouterBuilder<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TErrorMap, TMeta>;
|
67
|
+
'prefix'(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
68
|
+
'tag'(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
69
|
+
'router'<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(router: U): AdaptedRouter<U, TInitialContext, TErrorMap>;
|
70
|
+
'lazy'<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(loader: () => Promise<{
|
71
|
+
default: U;
|
72
|
+
}>): AdaptedRouter<FlattenLazy<U>, TInitialContext, TErrorMap>;
|
73
|
+
}
|
74
|
+
//# sourceMappingURL=builder-variants.d.ts.map
|
package/dist/src/builder.d.ts
CHANGED
@@ -1,43 +1,57 @@
|
|
1
|
-
import type { ContractRouter, ErrorMap,
|
2
|
-
import type {
|
3
|
-
import type {
|
4
|
-
import type {
|
1
|
+
import type { ContractProcedureDef, ContractRouter, ErrorMap, HTTPPath, MergedErrorMap, Meta, ORPCErrorConstructorMap, Route, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
+
import type { BuilderWithMiddlewares, ProcedureBuilder, ProcedureBuilderWithInput, ProcedureBuilderWithOutput, RouterBuilder } from './builder-variants';
|
3
|
+
import type { ConflictContextGuard, Context, MergedContext } from './context';
|
4
|
+
import type { FlattenLazy } from './lazy-utils';
|
5
|
+
import type { AnyMiddleware, MapInputMiddleware, Middleware } from './middleware';
|
5
6
|
import type { DecoratedMiddleware } from './middleware-decorated';
|
6
7
|
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 { BuilderWithErrors } from './builder-with-errors';
|
11
|
-
import { BuilderWithMiddlewares } from './builder-with-middlewares';
|
12
|
-
import { type ChainableImplementer } from './implementer-chainable';
|
13
|
-
import { ProcedureBuilder } from './procedure-builder';
|
14
|
-
import { ProcedureBuilderWithInput } from './procedure-builder-with-input';
|
15
|
-
import { ProcedureBuilderWithOutput } from './procedure-builder-with-output';
|
8
|
+
import type { AdaptedRouter, AdaptRouterOptions, Router } from './router';
|
16
9
|
import { DecoratedProcedure } from './procedure-decorated';
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
context: TContext;
|
21
|
-
};
|
10
|
+
export interface BuilderConfig {
|
11
|
+
initialInputValidationIndex?: number;
|
12
|
+
initialOutputValidationIndex?: number;
|
22
13
|
}
|
23
|
-
export
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
14
|
+
export interface BuilderDef<TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>, AdaptRouterOptions<TErrorMap> {
|
15
|
+
middlewares: AnyMiddleware[];
|
16
|
+
inputValidationIndex: number;
|
17
|
+
outputValidationIndex: number;
|
18
|
+
config: BuilderConfig;
|
19
|
+
}
|
20
|
+
export declare class Builder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
21
|
+
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
22
|
+
constructor(def: BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>);
|
23
|
+
/**
|
24
|
+
* Reset config
|
25
|
+
*/
|
26
|
+
$config(config: BuilderConfig): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
27
|
+
/**
|
28
|
+
* Reset initial context
|
29
|
+
*/
|
30
|
+
$context<U extends Context>(): Builder<U, U, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
31
|
+
/**
|
32
|
+
* Reset initial meta
|
33
|
+
*/
|
34
|
+
$meta<U extends Meta>(initialMeta: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, U>;
|
35
|
+
/**
|
36
|
+
* Reset initial route
|
37
|
+
*/
|
38
|
+
$route(initialRoute: Route): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
39
|
+
middleware<UOutContext extends Context, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
40
|
+
middleware: Middleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): DecoratedMiddleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<any>, TMeta>;
|
41
|
+
errors<U extends ErrorMap>(errors: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
42
|
+
use<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & BuilderWithMiddlewares<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
43
|
+
use<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & BuilderWithMiddlewares<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
44
|
+
meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
45
|
+
route(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
46
|
+
input<USchema extends Schema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
47
|
+
output<USchema extends Schema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
48
|
+
handler<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
|
49
|
+
prefix(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
50
|
+
tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
51
|
+
router<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(router: U): AdaptedRouter<U, TInitialContext, TErrorMap>;
|
52
|
+
lazy<U extends Router<TCurrentContext, ContractRouter<TMeta>>>(loader: () => Promise<{
|
39
53
|
default: U;
|
40
|
-
}>): AdaptedRouter<
|
41
|
-
contract<U extends ContractRouter<any>>(contract: U): ChainableImplementer<TContext, undefined, U>;
|
54
|
+
}>): AdaptedRouter<FlattenLazy<U>, TInitialContext, TErrorMap>;
|
42
55
|
}
|
56
|
+
export declare const os: Builder<Context, Context, undefined, undefined, {}, {}>;
|
43
57
|
//# sourceMappingURL=builder.d.ts.map
|
package/dist/src/context.d.ts
CHANGED
@@ -1,11 +1,9 @@
|
|
1
|
-
import type {
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
*/
|
10
|
-
export type ContextGuard<T extends Context> = Partial<T> | undefined;
|
1
|
+
import type { IsNever } from '@orpc/shared';
|
2
|
+
export type Context = Record<string, any>;
|
3
|
+
export type TypeInitialContext<T extends Context> = (type: T) => unknown;
|
4
|
+
export type MergedContext<T extends Context, U extends Context> = T & U;
|
5
|
+
export declare function mergeContext<T extends Context, U extends Context>(context: T, other: U): MergedContext<T, U>;
|
6
|
+
export type ConflictContextGuard<T extends Context> = true extends IsNever<T> | {
|
7
|
+
[K in keyof T]: IsNever<T[K]>;
|
8
|
+
}[keyof T] ? never : unknown;
|
11
9
|
//# sourceMappingURL=context.d.ts.map
|
package/dist/src/hidden.d.ts
CHANGED
@@ -1,6 +1,8 @@
|
|
1
|
-
import type { ContractRouter, HTTPPath } from '@orpc/contract';
|
2
|
-
|
1
|
+
import type { AnyContractRouter, ContractRouter, HTTPPath } from '@orpc/contract';
|
2
|
+
import type { Lazy } from './lazy';
|
3
|
+
import type { AnyRouter } from './router';
|
4
|
+
export declare function setRouterContract<T extends AnyRouter>(obj: T, contract: AnyContractRouter): T;
|
3
5
|
export declare function getRouterContract(obj: object): ContractRouter<any> | undefined;
|
4
|
-
export declare function deepSetLazyRouterPrefix<T extends
|
6
|
+
export declare function deepSetLazyRouterPrefix<T extends Lazy<any>>(router: T, prefix: HTTPPath): T;
|
5
7
|
export declare function getLazyRouterPrefix(obj: object): HTTPPath | undefined;
|
6
8
|
//# sourceMappingURL=hidden.d.ts.map
|
@@ -0,0 +1,30 @@
|
|
1
|
+
import type { ClientRest, ErrorMap, Meta, ORPCErrorConstructorMap, Schema, SchemaInput, SchemaOutput } from '@orpc/contract';
|
2
|
+
import type { BuilderDef } from './builder';
|
3
|
+
import type { ConflictContextGuard, Context, MergedContext } from './context';
|
4
|
+
import type { MapInputMiddleware, Middleware } from './middleware';
|
5
|
+
import type { Procedure, ProcedureHandler } from './procedure';
|
6
|
+
import type { CreateProcedureClientRest, ProcedureClient } from './procedure-client';
|
7
|
+
import type { DecoratedProcedure } from './procedure-decorated';
|
8
|
+
/**
|
9
|
+
* Like `DecoratedProcedure`, but removed all method that can change the contract.
|
10
|
+
*/
|
11
|
+
export interface ImplementedProcedure<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> {
|
12
|
+
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>) & (<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>);
|
13
|
+
/**
|
14
|
+
* Make this procedure callable (works like a function while still being a procedure).
|
15
|
+
*/
|
16
|
+
callable<TClientContext>(...rest: CreateProcedureClientRest<TInitialContext, TOutputSchema, THandlerOutput, TClientContext>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, THandlerOutput, TErrorMap>;
|
17
|
+
/**
|
18
|
+
* Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
|
19
|
+
*/
|
20
|
+
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>>);
|
21
|
+
}
|
22
|
+
/**
|
23
|
+
* Like `ProcedureBuilderWithoutHandler`, but removed all method that can change the contract.
|
24
|
+
*/
|
25
|
+
export interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends Schema, TOutputSchema extends Schema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
26
|
+
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
27
|
+
'use': (<U extends Context>(middleware: Middleware<TCurrentContext, U, SchemaOutput<TInputSchema>, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>) => ConflictContextGuard<MergedContext<TCurrentContext, U>> & ProcedureImplementer<TInitialContext, MergedContext<TCurrentContext, U>, TInputSchema, TOutputSchema, TErrorMap, TMeta>) & (<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, SchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<SchemaOutput<TInputSchema>, UInput>) => ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureImplementer<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>);
|
28
|
+
'handler'<UFuncOutput extends SchemaInput<TOutputSchema>>(handler: ProcedureHandler<TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, UFuncOutput, TErrorMap, TMeta>;
|
29
|
+
}
|
30
|
+
//# sourceMappingURL=implementer-procedure.d.ts.map
|
@@ -0,0 +1,16 @@
|
|
1
|
+
import type { AnyContractRouter, ContractProcedure, ContractRouter, ContractRouterToErrorMap, ORPCErrorConstructorMap } from '@orpc/contract';
|
2
|
+
import type { ConflictContextGuard, Context, MergedContext } from './context';
|
3
|
+
import type { ProcedureImplementer } from './implementer-procedure';
|
4
|
+
import type { FlattenLazy } from './lazy-utils';
|
5
|
+
import type { Middleware } from './middleware';
|
6
|
+
import type { AdaptedRouter, Router } from './router';
|
7
|
+
export type ImplementerInternalWithMiddlewares<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = (TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? ProcedureImplementer<TInitialContext, TCurrentContext, UInputSchema, UOutputSchema, UErrorMap, UMeta> : TContract extends ContractRouter<infer UMeta> ? {
|
8
|
+
use<U extends Context>(middleware: Middleware<TCurrentContext, U, unknown, unknown, ORPCErrorConstructorMap<ContractRouterToErrorMap<TContract>>, UMeta>): ConflictContextGuard<MergedContext<TCurrentContext, U>> & ImplementerInternalWithMiddlewares<TContract, TInitialContext, MergedContext<TCurrentContext, U>>;
|
9
|
+
router<U extends Router<TCurrentContext, TContract>>(router: U): AdaptedRouter<U, TInitialContext, Record<never, never>>;
|
10
|
+
lazy<U extends Router<TInitialContext, TContract>>(loader: () => Promise<{
|
11
|
+
default: U;
|
12
|
+
}>): AdaptedRouter<FlattenLazy<U>, TInitialContext, Record<never, never>>;
|
13
|
+
} & {
|
14
|
+
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternalWithMiddlewares<TContract[K], TInitialContext, TCurrentContext> : never;
|
15
|
+
} : never);
|
16
|
+
//# sourceMappingURL=implementer-variants.d.ts.map
|
@@ -0,0 +1,27 @@
|
|
1
|
+
import type { AnyContractRouter, ContractProcedure, ContractRouter, ContractRouterToErrorMap, ContractRouterToMeta, ORPCErrorConstructorMap } from '@orpc/contract';
|
2
|
+
import type { ConflictContextGuard, Context, MergedContext } from './context';
|
3
|
+
import type { ProcedureImplementer } from './implementer-procedure';
|
4
|
+
import type { ImplementerInternalWithMiddlewares } from './implementer-variants';
|
5
|
+
import type { AnyMiddleware, Middleware } from './middleware';
|
6
|
+
import { type BuilderConfig } from './builder';
|
7
|
+
import { type FlattenLazy } from './lazy-utils';
|
8
|
+
import { type DecoratedMiddleware } from './middleware-decorated';
|
9
|
+
import { type AdaptedRouter, type Router } from './router';
|
10
|
+
export type ImplementerInternal<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = (TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? ProcedureImplementer<TInitialContext, TCurrentContext, UInputSchema, UOutputSchema, UErrorMap, UMeta> : TContract extends ContractRouter<infer UMeta> ? {
|
11
|
+
middleware<UOutContext extends Context, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
12
|
+
middleware: Middleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<ContractRouterToErrorMap<TContract>>, ContractRouterToMeta<TContract>>): DecoratedMiddleware<TCurrentContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<any>, UMeta>;
|
13
|
+
use<U extends Context>(middleware: Middleware<TCurrentContext, U, unknown, unknown, ORPCErrorConstructorMap<ContractRouterToErrorMap<TContract>>, UMeta>): ConflictContextGuard<MergedContext<TCurrentContext, U>> & ImplementerInternalWithMiddlewares<TContract, TInitialContext, MergedContext<TCurrentContext, U>>;
|
14
|
+
router<U extends Router<TCurrentContext, TContract>>(router: U): AdaptedRouter<U, TInitialContext, Record<never, never>>;
|
15
|
+
lazy<U extends Router<TCurrentContext, TContract>>(loader: () => Promise<{
|
16
|
+
default: U;
|
17
|
+
}>): AdaptedRouter<FlattenLazy<U>, TInitialContext, Record<never, never>>;
|
18
|
+
} & {
|
19
|
+
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternal<TContract[K], TInitialContext, TCurrentContext> : never;
|
20
|
+
} : never);
|
21
|
+
export declare function implementerInternal<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context>(contract: TContract, config: BuilderConfig, middlewares: AnyMiddleware[]): ImplementerInternal<TContract, TInitialContext, TCurrentContext>;
|
22
|
+
export type Implementer<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = {
|
23
|
+
$context<U extends Context>(): Implementer<TContract, U, U>;
|
24
|
+
$config(config: BuilderConfig): Implementer<TContract, TInitialContext, TCurrentContext>;
|
25
|
+
} & ImplementerInternal<TContract, TInitialContext, TCurrentContext>;
|
26
|
+
export declare function implement<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context>(contract: TContract, config?: BuilderConfig): Implementer<TContract, TInitialContext, TCurrentContext>;
|
27
|
+
//# sourceMappingURL=implementer.d.ts.map
|
package/dist/src/index.d.ts
CHANGED
@@ -1,25 +1,21 @@
|
|
1
|
-
import type { WELL_CONTEXT } from './types';
|
2
|
-
import { Builder } from './builder';
|
3
1
|
export * from './builder';
|
4
|
-
export * from './
|
2
|
+
export * from './builder-variants';
|
3
|
+
export * from './config';
|
4
|
+
export * from './context';
|
5
5
|
export * from './hidden';
|
6
|
-
export * from './implementer
|
6
|
+
export * from './implementer';
|
7
|
+
export * from './implementer-procedure';
|
8
|
+
export * from './implementer-variants';
|
7
9
|
export * from './lazy';
|
8
|
-
export * from './lazy-
|
10
|
+
export * from './lazy-utils';
|
9
11
|
export * from './middleware';
|
10
12
|
export * from './middleware-decorated';
|
11
13
|
export * from './procedure';
|
12
|
-
export * from './procedure-builder';
|
13
14
|
export * from './procedure-client';
|
14
15
|
export * from './procedure-decorated';
|
15
|
-
export * from './procedure-implementer';
|
16
16
|
export * from './procedure-utils';
|
17
17
|
export * from './router';
|
18
|
-
export * from './router-
|
18
|
+
export * from './router-accessible-lazy';
|
19
19
|
export * from './router-client';
|
20
|
-
export
|
21
|
-
export * from './types';
|
22
|
-
export * from './utils';
|
23
|
-
export { configGlobal, fallbackToGlobalConfig, isDefinedError, ORPCError, safe, type } from '@orpc/contract';
|
24
|
-
export declare const os: Builder<WELL_CONTEXT>;
|
20
|
+
export { isDefinedError, ORPCError, safe, type, ValidationError } from '@orpc/contract';
|
25
21
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/src/lazy-utils.d.ts
CHANGED
@@ -1,4 +1,6 @@
|
|
1
1
|
import type { Lazy } from './lazy';
|
2
|
-
import { type
|
3
|
-
export
|
2
|
+
import { type AnyProcedure } from './procedure';
|
3
|
+
export type FlattenLazy<T> = T extends Lazy<infer U> ? FlattenLazy<U> : Lazy<T>;
|
4
|
+
export declare function flatLazy<T extends Lazy<any>>(lazied: T): FlattenLazy<T>;
|
5
|
+
export declare function createLazyProcedureFormAnyLazy(lazied: Lazy<any>): Lazy<AnyProcedure>;
|
4
6
|
//# sourceMappingURL=lazy-utils.d.ts.map
|
package/dist/src/lazy.d.ts
CHANGED
@@ -1,18 +1,22 @@
|
|
1
|
+
import type { HTTPPath } from '@orpc/contract';
|
1
2
|
export declare const LAZY_LOADER_SYMBOL: unique symbol;
|
3
|
+
export interface LazyMeta {
|
4
|
+
prefix?: HTTPPath;
|
5
|
+
}
|
2
6
|
export interface Lazy<T> {
|
3
|
-
[LAZY_LOADER_SYMBOL]
|
7
|
+
[LAZY_LOADER_SYMBOL](): Promise<{
|
4
8
|
default: T;
|
5
9
|
}>;
|
6
10
|
}
|
7
11
|
export type Lazyable<T> = T | Lazy<T>;
|
8
|
-
export
|
12
|
+
export interface LazyOptions {
|
13
|
+
prefix?: HTTPPath;
|
14
|
+
}
|
9
15
|
export declare function lazy<T>(loader: () => Promise<{
|
10
16
|
default: T;
|
11
17
|
}>): Lazy<T>;
|
12
|
-
export declare function isLazy(item: unknown): item is
|
18
|
+
export declare function isLazy(item: unknown): item is Lazy<any>;
|
13
19
|
export declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
|
14
20
|
default: T extends Lazy<infer U> ? U : T;
|
15
21
|
}>;
|
16
|
-
export type FlattenLazy<T> = T extends Lazy<infer U> ? FlattenLazy<U> : Lazy<T>;
|
17
|
-
export declare function flatLazy<T extends ANY_LAZY>(lazied: T): FlattenLazy<T>;
|
18
22
|
//# sourceMappingURL=lazy.d.ts.map
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import type {
|
2
|
-
import type {
|
1
|
+
import type { Meta, ORPCErrorConstructorMap } from '@orpc/contract';
|
2
|
+
import type { Context, MergedContext } from './context';
|
3
3
|
import type { MapInputMiddleware, Middleware } from './middleware';
|
4
|
-
|
5
|
-
|
6
|
-
concat
|
7
|
-
mapInput
|
4
|
+
export interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> extends Middleware<TInContext, TOutContext, TInput, TOutput, TErrorConstructorMap, TMeta> {
|
5
|
+
concat<UOutContext extends Context, UInput>(middleware: Middleware<TInContext & TOutContext, UOutContext, UInput & TInput, TOutput, TErrorConstructorMap, TMeta>): DecoratedMiddleware<TInContext, MergedContext<TOutContext, UOutContext>, UInput & TInput, TOutput, TErrorConstructorMap, TMeta>;
|
6
|
+
concat<UOutContext extends Context, UInput, UMappedInput>(middleware: Middleware<TInContext & TOutContext, UOutContext, UMappedInput, TOutput, TErrorConstructorMap, TMeta>, mapInput: MapInputMiddleware<UInput & TInput, UMappedInput>): DecoratedMiddleware<TInContext, TOutContext & UOutContext, UInput & TInput, TOutput, TErrorConstructorMap, TMeta>;
|
7
|
+
mapInput<UInput = unknown>(map: MapInputMiddleware<UInput, TInput>): DecoratedMiddleware<TInContext, TOutContext, UInput, TOutput, TErrorConstructorMap, TMeta>;
|
8
8
|
}
|
9
|
-
export declare function decorateMiddleware<
|
9
|
+
export declare function decorateMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta>(middleware: Middleware<TInContext, TOutContext, TInput, TOutput, TErrorConstructorMap, TMeta>): DecoratedMiddleware<TInContext, TOutContext, TInput, TOutput, TErrorConstructorMap, TMeta>;
|
10
10
|
//# sourceMappingURL=middleware-decorated.d.ts.map
|