@orpc/server 0.0.0-next.3afb521 → 0.0.0-next.3b1dac3
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/adapters/fetch/index.d.mts +2 -2
- package/dist/adapters/fetch/index.d.ts +2 -2
- package/dist/adapters/hono/index.d.mts +2 -2
- package/dist/adapters/hono/index.d.ts +2 -2
- package/dist/adapters/next/index.d.mts +2 -2
- package/dist/adapters/next/index.d.ts +2 -2
- package/dist/adapters/node/index.d.mts +2 -2
- package/dist/adapters/node/index.d.ts +2 -2
- package/dist/adapters/standard/index.d.mts +3 -3
- package/dist/adapters/standard/index.d.ts +3 -3
- package/dist/index.d.mts +52 -52
- package/dist/index.d.ts +52 -52
- package/dist/index.mjs +0 -2
- package/dist/plugins/index.d.mts +3 -3
- package/dist/plugins/index.d.ts +3 -3
- package/dist/shared/{server.SegZfF38.d.ts → server.BZRSVRDu.d.ts} +3 -3
- package/dist/shared/{server.C99bm-AA.d.mts → server.CPteJIPP.d.mts} +22 -22
- package/dist/shared/{server.C99bm-AA.d.ts → server.CPteJIPP.d.ts} +22 -22
- package/dist/shared/{server.rcYTv2pz.d.mts → server.iM8li30u.d.mts} +3 -3
- package/package.json +7 -7
@@ -1,7 +1,7 @@
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
2
2
|
import { ToFetchResponseOptions } from '@orpc/standard-server-fetch';
|
3
|
-
import { C as Context, R as Router } from '../../shared/server.
|
4
|
-
import { S as StandardHandleOptions, b as StandardHandlerOptions } from '../../shared/server.
|
3
|
+
import { C as Context, R as Router } from '../../shared/server.CPteJIPP.mjs';
|
4
|
+
import { S as StandardHandleOptions, b as StandardHandlerOptions } from '../../shared/server.iM8li30u.mjs';
|
5
5
|
import '@orpc/client';
|
6
6
|
import '@orpc/contract';
|
7
7
|
import '@orpc/standard-server';
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
2
2
|
import { ToFetchResponseOptions } from '@orpc/standard-server-fetch';
|
3
|
-
import { C as Context, R as Router } from '../../shared/server.
|
4
|
-
import { S as StandardHandleOptions, b as StandardHandlerOptions } from '../../shared/server.
|
3
|
+
import { C as Context, R as Router } from '../../shared/server.CPteJIPP.js';
|
4
|
+
import { S as StandardHandleOptions, b as StandardHandlerOptions } from '../../shared/server.BZRSVRDu.js';
|
5
5
|
import '@orpc/client';
|
6
6
|
import '@orpc/contract';
|
7
7
|
import '@orpc/standard-server';
|
@@ -2,8 +2,8 @@ import { FetchHandler } from '../fetch/index.mjs';
|
|
2
2
|
export { FetchHandleResult, RPCHandler } from '../fetch/index.mjs';
|
3
3
|
import { Value, MaybeOptionalOptions } from '@orpc/shared';
|
4
4
|
import { Context as Context$1, MiddlewareHandler } from 'hono';
|
5
|
-
import { C as Context } from '../../shared/server.
|
6
|
-
import { S as StandardHandleOptions } from '../../shared/server.
|
5
|
+
import { C as Context } from '../../shared/server.CPteJIPP.mjs';
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.iM8li30u.mjs';
|
7
7
|
import '@orpc/standard-server-fetch';
|
8
8
|
import '@orpc/client';
|
9
9
|
import '@orpc/contract';
|
@@ -2,8 +2,8 @@ import { FetchHandler } from '../fetch/index.js';
|
|
2
2
|
export { FetchHandleResult, RPCHandler } from '../fetch/index.js';
|
3
3
|
import { Value, MaybeOptionalOptions } from '@orpc/shared';
|
4
4
|
import { Context as Context$1, MiddlewareHandler } from 'hono';
|
5
|
-
import { C as Context } from '../../shared/server.
|
6
|
-
import { S as StandardHandleOptions } from '../../shared/server.
|
5
|
+
import { C as Context } from '../../shared/server.CPteJIPP.js';
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.BZRSVRDu.js';
|
7
7
|
import '@orpc/standard-server-fetch';
|
8
8
|
import '@orpc/client';
|
9
9
|
import '@orpc/contract';
|
@@ -2,8 +2,8 @@ import { FetchHandler } from '../fetch/index.mjs';
|
|
2
2
|
export { FetchHandleResult, RPCHandler } from '../fetch/index.mjs';
|
3
3
|
import { Value, MaybeOptionalOptions } from '@orpc/shared';
|
4
4
|
import { NextRequest } from 'next/server';
|
5
|
-
import { C as Context } from '../../shared/server.
|
6
|
-
import { S as StandardHandleOptions } from '../../shared/server.
|
5
|
+
import { C as Context } from '../../shared/server.CPteJIPP.mjs';
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.iM8li30u.mjs';
|
7
7
|
import '@orpc/standard-server-fetch';
|
8
8
|
import '@orpc/client';
|
9
9
|
import '@orpc/contract';
|
@@ -2,8 +2,8 @@ import { FetchHandler } from '../fetch/index.js';
|
|
2
2
|
export { FetchHandleResult, RPCHandler } from '../fetch/index.js';
|
3
3
|
import { Value, MaybeOptionalOptions } from '@orpc/shared';
|
4
4
|
import { NextRequest } from 'next/server';
|
5
|
-
import { C as Context } from '../../shared/server.
|
6
|
-
import { S as StandardHandleOptions } from '../../shared/server.
|
5
|
+
import { C as Context } from '../../shared/server.CPteJIPP.js';
|
6
|
+
import { S as StandardHandleOptions } from '../../shared/server.BZRSVRDu.js';
|
7
7
|
import '@orpc/standard-server-fetch';
|
8
8
|
import '@orpc/client';
|
9
9
|
import '@orpc/contract';
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
2
2
|
import { SendStandardResponseOptions } from '@orpc/standard-server-node';
|
3
|
-
import { C as Context, R as Router } from '../../shared/server.
|
4
|
-
import { S as StandardHandleOptions, b as StandardHandlerOptions } from '../../shared/server.
|
3
|
+
import { C as Context, R as Router } from '../../shared/server.CPteJIPP.mjs';
|
4
|
+
import { S as StandardHandleOptions, b as StandardHandlerOptions } from '../../shared/server.iM8li30u.mjs';
|
5
5
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
6
6
|
import { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
|
7
7
|
import '@orpc/client';
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
2
2
|
import { SendStandardResponseOptions } from '@orpc/standard-server-node';
|
3
|
-
import { C as Context, R as Router } from '../../shared/server.
|
4
|
-
import { S as StandardHandleOptions, b as StandardHandlerOptions } from '../../shared/server.
|
3
|
+
import { C as Context, R as Router } from '../../shared/server.CPteJIPP.js';
|
4
|
+
import { S as StandardHandleOptions, b as StandardHandlerOptions } from '../../shared/server.BZRSVRDu.js';
|
5
5
|
import { IncomingMessage, ServerResponse } from 'node:http';
|
6
6
|
import { Http2ServerRequest, Http2ServerResponse } from 'node:http2';
|
7
7
|
import '@orpc/client';
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import { c as StandardCodec, d as StandardParams, e as StandardMatcher, f as StandardMatchResult } from '../../shared/server.
|
2
|
-
export { S as StandardHandleOptions, g as StandardHandleResult, h as StandardHandler, a as StandardHandlerInterceptorOptions, b as StandardHandlerOptions, W as WellStandardHandleOptions } from '../../shared/server.
|
1
|
+
import { c as StandardCodec, d as StandardParams, e as StandardMatcher, f as StandardMatchResult } from '../../shared/server.iM8li30u.mjs';
|
2
|
+
export { S as StandardHandleOptions, g as StandardHandleResult, h as StandardHandler, a as StandardHandlerInterceptorOptions, b as StandardHandlerOptions, W as WellStandardHandleOptions } from '../../shared/server.iM8li30u.mjs';
|
3
3
|
import { ORPCError } from '@orpc/client';
|
4
4
|
import { RPCSerializer } from '@orpc/client/standard';
|
5
5
|
import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
|
6
|
-
import { A as AnyProcedure, a as AnyRouter } from '../../shared/server.
|
6
|
+
import { A as AnyProcedure, a as AnyRouter } from '../../shared/server.CPteJIPP.mjs';
|
7
7
|
import { HTTPPath } from '@orpc/contract';
|
8
8
|
import '@orpc/shared';
|
9
9
|
|
@@ -1,9 +1,9 @@
|
|
1
|
-
import { c as StandardCodec, d as StandardParams, e as StandardMatcher, f as StandardMatchResult } from '../../shared/server.
|
2
|
-
export { S as StandardHandleOptions, g as StandardHandleResult, h as StandardHandler, a as StandardHandlerInterceptorOptions, b as StandardHandlerOptions, W as WellStandardHandleOptions } from '../../shared/server.
|
1
|
+
import { c as StandardCodec, d as StandardParams, e as StandardMatcher, f as StandardMatchResult } from '../../shared/server.BZRSVRDu.js';
|
2
|
+
export { S as StandardHandleOptions, g as StandardHandleResult, h as StandardHandler, a as StandardHandlerInterceptorOptions, b as StandardHandlerOptions, W as WellStandardHandleOptions } from '../../shared/server.BZRSVRDu.js';
|
3
3
|
import { ORPCError } from '@orpc/client';
|
4
4
|
import { RPCSerializer } from '@orpc/client/standard';
|
5
5
|
import { StandardLazyRequest, StandardResponse } from '@orpc/standard-server';
|
6
|
-
import { A as AnyProcedure, a as AnyRouter } from '../../shared/server.
|
6
|
+
import { A as AnyProcedure, a as AnyRouter } from '../../shared/server.CPteJIPP.js';
|
7
7
|
import { HTTPPath } from '@orpc/contract';
|
8
8
|
import '@orpc/shared';
|
9
9
|
|
package/dist/index.d.mts
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
import {
|
2
|
-
export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, HTTPMethod, HTTPPath, InputStructure, Meta, ORPCErrorFromErrorMap, OutputStructure, Route, Schema,
|
3
|
-
import { C as Context, b as Procedure, M as Middleware, O as ORPCErrorConstructorMap, c as ConflictContextGuard, d as MergedContext, e as MapInputMiddleware, f as CreateProcedureClientOptions, g as ProcedureClient, h as AnyMiddleware, L as Lazyable, a as AnyRouter, i as Lazy, A as AnyProcedure, j as ProcedureHandler, R as Router, I as InferRouterInitialContext } from './shared/server.
|
4
|
-
export { E as InferRouterCurrentContexts, D as InferRouterInitialContexts, F as InferRouterInputs, G as InferRouterOutputs, k as LAZY_SYMBOL, l as LazyMeta, s as MiddlewareNextFn, r as MiddlewareNextFnOptions, v as MiddlewareOptions, t as MiddlewareOutputFn, q as MiddlewareResult, P as ProcedureClientInterceptorOptions, y as ProcedureDef, x as ProcedureHandlerOptions, B as createProcedureClient, p as getLazyMeta, o as isLazy, z as isProcedure, n as lazy, m as mergeContext, w as middlewareOutputFn, u as unlazy } from './shared/server.
|
1
|
+
import { AnySchema, ErrorMap, Meta, MergedErrorMap, Route, InferSchemaOutput, InferSchemaInput, EnhanceRouteOptions, AnyContractRouter, AnyContractProcedure, Schema, HTTPPath, ContractRouter, ContractProcedureDef, ContractProcedure, InferContractRouterErrorMap, InferContractRouterMeta, ErrorFromErrorMap } from '@orpc/contract';
|
2
|
+
export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, HTTPMethod, HTTPPath, InferSchemaInput, InferSchemaOutput, InputStructure, Meta, ORPCErrorFromErrorMap, OutputStructure, Route, Schema, ValidationError, eventIterator, type } from '@orpc/contract';
|
3
|
+
import { C as Context, b as Procedure, M as Middleware, O as ORPCErrorConstructorMap, c as ConflictContextGuard, d as MergedContext, e as MapInputMiddleware, f as CreateProcedureClientOptions, g as ProcedureClient, h as AnyMiddleware, L as Lazyable, a as AnyRouter, i as Lazy, A as AnyProcedure, j as ProcedureHandler, R as Router, I as InferRouterInitialContext } from './shared/server.CPteJIPP.mjs';
|
4
|
+
export { E as InferRouterCurrentContexts, D as InferRouterInitialContexts, F as InferRouterInputs, G as InferRouterOutputs, k as LAZY_SYMBOL, l as LazyMeta, s as MiddlewareNextFn, r as MiddlewareNextFnOptions, v as MiddlewareOptions, t as MiddlewareOutputFn, q as MiddlewareResult, P as ProcedureClientInterceptorOptions, y as ProcedureDef, x as ProcedureHandlerOptions, B as createProcedureClient, p as getLazyMeta, o as isLazy, z as isProcedure, n as lazy, m as mergeContext, w as middlewareOutputFn, u as unlazy } from './shared/server.CPteJIPP.mjs';
|
5
5
|
import { ClientContext, ClientRest, ClientPromiseResult } from '@orpc/client';
|
6
6
|
export { ORPCError, isDefinedError, safe } from '@orpc/client';
|
7
7
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
8
8
|
export { onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
9
9
|
export { getEventMeta, withEventMeta } from '@orpc/standard-server';
|
10
10
|
|
11
|
-
declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
12
|
-
errors<U extends ErrorMap>(errors: U): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema,
|
13
|
-
meta(meta: TMeta): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema,
|
14
|
-
route(route: Route): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema,
|
15
|
-
use<U extends Context>(middleware: Middleware<TCurrentContext, U,
|
16
|
-
use<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput,
|
11
|
+
declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
12
|
+
errors<U extends ErrorMap>(errors: U): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
13
|
+
meta(meta: TMeta): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
14
|
+
route(route: Route): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
15
|
+
use<U extends Context>(middleware: Middleware<TCurrentContext, U, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, U>> & DecoratedProcedure<TInitialContext, MergedContext<TCurrentContext, U>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
16
|
+
use<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & DecoratedProcedure<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
17
17
|
/**
|
18
18
|
* Make this procedure callable (works like a function while still being a procedure).
|
19
19
|
*/
|
20
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema,
|
20
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, 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
23
|
*/
|
24
|
-
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema,
|
24
|
+
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, InferSchemaInput<TInputSchema>>) => Promise<InferSchemaOutput<TOutputSchema>>);
|
25
25
|
}
|
26
26
|
|
27
27
|
declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
|
@@ -29,7 +29,7 @@ type AccessibleLazyRouter<T extends Lazyable<AnyRouter | undefined>> = T extends
|
|
29
29
|
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? AccessibleLazyRouter<T[K]> : never;
|
30
30
|
};
|
31
31
|
declare function createAccessibleLazyRouter<T extends Lazy<AnyRouter | undefined>>(lazied: T): AccessibleLazyRouter<T>;
|
32
|
-
type EnhancedRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TErrorMap extends ErrorMap> = T extends Lazy<infer U extends AnyRouter> ? AccessibleLazyRouter<EnhancedRouter<U, TInitialContext, TErrorMap>> : T extends Procedure<any, infer UCurrentContext, infer UInputSchema, infer UOutputSchema, infer
|
32
|
+
type EnhancedRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TErrorMap extends ErrorMap> = T extends Lazy<infer U extends AnyRouter> ? AccessibleLazyRouter<EnhancedRouter<U, TInitialContext, TErrorMap>> : T extends Procedure<any, infer UCurrentContext, infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, UCurrentContext, UInputSchema, UOutputSchema, MergedErrorMap<TErrorMap, UErrorMap>, UMeta> : {
|
33
33
|
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? EnhancedRouter<T[K], TInitialContext, TErrorMap> : never;
|
34
34
|
};
|
35
35
|
interface EnhanceRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
|
@@ -52,15 +52,15 @@ interface LazyTraverseContractProceduresOptions {
|
|
52
52
|
declare function traverseContractProcedures(options: TraverseContractProceduresOptions, callback: (options: ContractProcedureCallbackOptions) => void, lazyOptions?: LazyTraverseContractProceduresOptions[]): LazyTraverseContractProceduresOptions[];
|
53
53
|
declare function resolveContractProcedures(options: TraverseContractProceduresOptions, callback: (options: ContractProcedureCallbackOptions) => void): Promise<void>;
|
54
54
|
|
55
|
-
interface BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
55
|
+
interface BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
56
56
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
57
57
|
'errors'<U extends ErrorMap>(errors: U): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
58
58
|
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & BuilderWithMiddlewares<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
59
59
|
'meta'(meta: TMeta): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
60
60
|
'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
61
|
-
'input'<USchema extends
|
62
|
-
'output'<USchema extends
|
63
|
-
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, unknown, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema,
|
61
|
+
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
62
|
+
'output'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
63
|
+
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, unknown, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
64
64
|
'prefix'(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
65
65
|
'tag'(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
66
66
|
'router'<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TErrorMap>;
|
@@ -68,43 +68,43 @@ interface BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContex
|
|
68
68
|
default: U;
|
69
69
|
}>): EnhancedRouter<Lazy<U>, TInitialContext, TErrorMap>;
|
70
70
|
}
|
71
|
-
interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
71
|
+
interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
72
72
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
73
73
|
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
74
74
|
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilder<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
75
75
|
'meta'(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
76
76
|
'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
77
|
-
'input'<USchema extends
|
78
|
-
'output'<USchema extends
|
79
|
-
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, unknown, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema,
|
77
|
+
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
78
|
+
'output'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
79
|
+
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, unknown, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
80
80
|
}
|
81
|
-
interface ProcedureBuilderWithInput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
81
|
+
interface ProcedureBuilderWithInput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
82
82
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
83
83
|
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
84
|
-
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext,
|
85
|
-
'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<
|
84
|
+
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
85
|
+
'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
86
86
|
'meta'(meta: TMeta): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
87
87
|
'route'(route: Route): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
88
|
-
'output'<USchema extends
|
89
|
-
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext,
|
88
|
+
'output'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
89
|
+
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
90
90
|
}
|
91
|
-
interface ProcedureBuilderWithOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
91
|
+
interface ProcedureBuilderWithOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
92
92
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
93
93
|
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
94
|
-
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, unknown,
|
94
|
+
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, unknown, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithOutput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
95
95
|
'meta'(meta: TMeta): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
96
96
|
'route'(route: Route): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
97
|
-
'input'<USchema extends
|
98
|
-
'handler'(handler: ProcedureHandler<TCurrentContext, unknown,
|
97
|
+
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
98
|
+
'handler'(handler: ProcedureHandler<TCurrentContext, unknown, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
99
99
|
}
|
100
|
-
interface ProcedureBuilderWithInputOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
100
|
+
interface ProcedureBuilderWithInputOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
101
101
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
102
102
|
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
103
|
-
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext,
|
104
|
-
'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput,
|
103
|
+
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInputOutput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
104
|
+
'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInputOutput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
105
105
|
'meta'(meta: TMeta): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
106
106
|
'route'(route: Route): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
107
|
-
'handler'(handler: ProcedureHandler<TCurrentContext,
|
107
|
+
'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
108
108
|
}
|
109
109
|
interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
110
110
|
'~orpc': EnhanceRouterOptions<TErrorMap>;
|
@@ -129,13 +129,13 @@ interface BuilderConfig {
|
|
129
129
|
initialInputValidationIndex?: number;
|
130
130
|
initialOutputValidationIndex?: number;
|
131
131
|
}
|
132
|
-
interface BuilderDef<TInputSchema extends
|
132
|
+
interface BuilderDef<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>, EnhanceRouterOptions<TErrorMap> {
|
133
133
|
middlewares: AnyMiddleware[];
|
134
134
|
inputValidationIndex: number;
|
135
135
|
outputValidationIndex: number;
|
136
136
|
config: BuilderConfig;
|
137
137
|
}
|
138
|
-
declare class Builder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
138
|
+
declare class Builder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
139
139
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
140
140
|
constructor(def: BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>);
|
141
141
|
/**
|
@@ -161,9 +161,9 @@ declare class Builder<TInitialContext extends Context, TCurrentContext extends C
|
|
161
161
|
use<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<unknown, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & BuilderWithMiddlewares<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
162
162
|
meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
163
163
|
route(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
164
|
-
input<USchema extends
|
165
|
-
output<USchema extends
|
166
|
-
handler<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, unknown, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema,
|
164
|
+
input<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
165
|
+
output<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
166
|
+
handler<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, unknown, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
167
167
|
prefix(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
168
168
|
tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
169
169
|
router<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TErrorMap>;
|
@@ -171,7 +171,7 @@ declare class Builder<TInitialContext extends Context, TCurrentContext extends C
|
|
171
171
|
default: U;
|
172
172
|
}>): EnhancedRouter<Lazy<U>, TInitialContext, TErrorMap>;
|
173
173
|
}
|
174
|
-
declare const os: Builder<
|
174
|
+
declare const os: Builder<Record<never, never>, Record<never, never>, Schema<unknown, unknown>, Schema<unknown, unknown>, Record<never, never>, Record<never, never>>;
|
175
175
|
|
176
176
|
interface Config {
|
177
177
|
initialInputValidationIndex: number;
|
@@ -182,26 +182,26 @@ declare function fallbackConfig<T extends keyof Config>(key: T, value?: Config[T
|
|
182
182
|
/**
|
183
183
|
* Like `DecoratedProcedure`, but removed all method that can change the contract.
|
184
184
|
*/
|
185
|
-
interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
186
|
-
use<U extends Context>(middleware: Middleware<TCurrentContext, U,
|
187
|
-
use<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput,
|
185
|
+
interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
186
|
+
use<U extends Context>(middleware: Middleware<TCurrentContext, U, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, U>> & DecoratedProcedure<TInitialContext, MergedContext<TCurrentContext, U>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
187
|
+
use<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & DecoratedProcedure<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
188
188
|
/**
|
189
189
|
* Make this procedure callable (works like a function while still being a procedure).
|
190
190
|
*/
|
191
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema,
|
191
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
192
192
|
/**
|
193
193
|
* Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
|
194
194
|
*/
|
195
|
-
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema,
|
195
|
+
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, InferSchemaInput<TInputSchema>>) => Promise<InferSchemaOutput<TOutputSchema>>);
|
196
196
|
}
|
197
197
|
/**
|
198
198
|
* Like `ProcedureBuilderWithoutHandler`, but removed all method that can change the contract.
|
199
199
|
*/
|
200
|
-
interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
200
|
+
interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
201
201
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
202
|
-
'use'<U extends Context>(middleware: Middleware<TCurrentContext, U,
|
203
|
-
'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput,
|
204
|
-
'handler'(handler: ProcedureHandler<TCurrentContext,
|
202
|
+
'use'<U extends Context>(middleware: Middleware<TCurrentContext, U, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, U>> & ProcedureImplementer<TInitialContext, MergedContext<TCurrentContext, U>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
203
|
+
'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureImplementer<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
204
|
+
'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
205
205
|
}
|
206
206
|
|
207
207
|
interface RouterImplementerWithMiddlewares<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
@@ -249,12 +249,12 @@ declare function createContractedProcedure(procedure: AnyProcedure, contract: An
|
|
249
249
|
* ```
|
250
250
|
*
|
251
251
|
*/
|
252
|
-
declare function call<TInitialContext extends Context, TInputSchema extends
|
252
|
+
declare function call<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta>(procedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, input: InferSchemaInput<TInputSchema>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, Record<never, never>>>): ClientPromiseResult<InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
|
253
253
|
|
254
|
-
type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer
|
254
|
+
type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UErrorMap, any> ? ProcedureClient<TClientContext, UInputSchema, UOutputSchema, UErrorMap> : {
|
255
255
|
[K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
|
256
256
|
};
|
257
|
-
declare function createRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>,
|
257
|
+
declare function createRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>, Schema<unknown, unknown>, Schema<unknown, unknown>, ErrorMap, Meta, TClientContext>>): RouterClient<T, TClientContext>;
|
258
258
|
|
259
259
|
declare function setHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: AnyContractRouter): T;
|
260
260
|
declare function getHiddenRouterContract(router: Lazyable<AnyRouter | AnyContractRouter>): AnyContractRouter | undefined;
|
package/dist/index.d.ts
CHANGED
@@ -1,27 +1,27 @@
|
|
1
|
-
import {
|
2
|
-
export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, HTTPMethod, HTTPPath, InputStructure, Meta, ORPCErrorFromErrorMap, OutputStructure, Route, Schema,
|
3
|
-
import { C as Context, b as Procedure, M as Middleware, O as ORPCErrorConstructorMap, c as ConflictContextGuard, d as MergedContext, e as MapInputMiddleware, f as CreateProcedureClientOptions, g as ProcedureClient, h as AnyMiddleware, L as Lazyable, a as AnyRouter, i as Lazy, A as AnyProcedure, j as ProcedureHandler, R as Router, I as InferRouterInitialContext } from './shared/server.
|
4
|
-
export { E as InferRouterCurrentContexts, D as InferRouterInitialContexts, F as InferRouterInputs, G as InferRouterOutputs, k as LAZY_SYMBOL, l as LazyMeta, s as MiddlewareNextFn, r as MiddlewareNextFnOptions, v as MiddlewareOptions, t as MiddlewareOutputFn, q as MiddlewareResult, P as ProcedureClientInterceptorOptions, y as ProcedureDef, x as ProcedureHandlerOptions, B as createProcedureClient, p as getLazyMeta, o as isLazy, z as isProcedure, n as lazy, m as mergeContext, w as middlewareOutputFn, u as unlazy } from './shared/server.
|
1
|
+
import { AnySchema, ErrorMap, Meta, MergedErrorMap, Route, InferSchemaOutput, InferSchemaInput, EnhanceRouteOptions, AnyContractRouter, AnyContractProcedure, Schema, HTTPPath, ContractRouter, ContractProcedureDef, ContractProcedure, InferContractRouterErrorMap, InferContractRouterMeta, ErrorFromErrorMap } from '@orpc/contract';
|
2
|
+
export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, HTTPMethod, HTTPPath, InferSchemaInput, InferSchemaOutput, InputStructure, Meta, ORPCErrorFromErrorMap, OutputStructure, Route, Schema, ValidationError, eventIterator, type } from '@orpc/contract';
|
3
|
+
import { C as Context, b as Procedure, M as Middleware, O as ORPCErrorConstructorMap, c as ConflictContextGuard, d as MergedContext, e as MapInputMiddleware, f as CreateProcedureClientOptions, g as ProcedureClient, h as AnyMiddleware, L as Lazyable, a as AnyRouter, i as Lazy, A as AnyProcedure, j as ProcedureHandler, R as Router, I as InferRouterInitialContext } from './shared/server.CPteJIPP.js';
|
4
|
+
export { E as InferRouterCurrentContexts, D as InferRouterInitialContexts, F as InferRouterInputs, G as InferRouterOutputs, k as LAZY_SYMBOL, l as LazyMeta, s as MiddlewareNextFn, r as MiddlewareNextFnOptions, v as MiddlewareOptions, t as MiddlewareOutputFn, q as MiddlewareResult, P as ProcedureClientInterceptorOptions, y as ProcedureDef, x as ProcedureHandlerOptions, B as createProcedureClient, p as getLazyMeta, o as isLazy, z as isProcedure, n as lazy, m as mergeContext, w as middlewareOutputFn, u as unlazy } from './shared/server.CPteJIPP.js';
|
5
5
|
import { ClientContext, ClientRest, ClientPromiseResult } from '@orpc/client';
|
6
6
|
export { ORPCError, isDefinedError, safe } from '@orpc/client';
|
7
7
|
import { MaybeOptionalOptions } from '@orpc/shared';
|
8
8
|
export { onError, onFinish, onStart, onSuccess } from '@orpc/shared';
|
9
9
|
export { getEventMeta, withEventMeta } from '@orpc/standard-server';
|
10
10
|
|
11
|
-
declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
12
|
-
errors<U extends ErrorMap>(errors: U): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema,
|
13
|
-
meta(meta: TMeta): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema,
|
14
|
-
route(route: Route): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema,
|
15
|
-
use<U extends Context>(middleware: Middleware<TCurrentContext, U,
|
16
|
-
use<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput,
|
11
|
+
declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
12
|
+
errors<U extends ErrorMap>(errors: U): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
13
|
+
meta(meta: TMeta): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
14
|
+
route(route: Route): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
15
|
+
use<U extends Context>(middleware: Middleware<TCurrentContext, U, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, U>> & DecoratedProcedure<TInitialContext, MergedContext<TCurrentContext, U>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
16
|
+
use<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & DecoratedProcedure<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
17
17
|
/**
|
18
18
|
* Make this procedure callable (works like a function while still being a procedure).
|
19
19
|
*/
|
20
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema,
|
20
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, 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
23
|
*/
|
24
|
-
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema,
|
24
|
+
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, InferSchemaInput<TInputSchema>>) => Promise<InferSchemaOutput<TOutputSchema>>);
|
25
25
|
}
|
26
26
|
|
27
27
|
declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
|
@@ -29,7 +29,7 @@ type AccessibleLazyRouter<T extends Lazyable<AnyRouter | undefined>> = T extends
|
|
29
29
|
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? AccessibleLazyRouter<T[K]> : never;
|
30
30
|
};
|
31
31
|
declare function createAccessibleLazyRouter<T extends Lazy<AnyRouter | undefined>>(lazied: T): AccessibleLazyRouter<T>;
|
32
|
-
type EnhancedRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TErrorMap extends ErrorMap> = T extends Lazy<infer U extends AnyRouter> ? AccessibleLazyRouter<EnhancedRouter<U, TInitialContext, TErrorMap>> : T extends Procedure<any, infer UCurrentContext, infer UInputSchema, infer UOutputSchema, infer
|
32
|
+
type EnhancedRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TErrorMap extends ErrorMap> = T extends Lazy<infer U extends AnyRouter> ? AccessibleLazyRouter<EnhancedRouter<U, TInitialContext, TErrorMap>> : T extends Procedure<any, infer UCurrentContext, infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, UCurrentContext, UInputSchema, UOutputSchema, MergedErrorMap<TErrorMap, UErrorMap>, UMeta> : {
|
33
33
|
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? EnhancedRouter<T[K], TInitialContext, TErrorMap> : never;
|
34
34
|
};
|
35
35
|
interface EnhanceRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
|
@@ -52,15 +52,15 @@ interface LazyTraverseContractProceduresOptions {
|
|
52
52
|
declare function traverseContractProcedures(options: TraverseContractProceduresOptions, callback: (options: ContractProcedureCallbackOptions) => void, lazyOptions?: LazyTraverseContractProceduresOptions[]): LazyTraverseContractProceduresOptions[];
|
53
53
|
declare function resolveContractProcedures(options: TraverseContractProceduresOptions, callback: (options: ContractProcedureCallbackOptions) => void): Promise<void>;
|
54
54
|
|
55
|
-
interface BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
55
|
+
interface BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
56
56
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
57
57
|
'errors'<U extends ErrorMap>(errors: U): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
58
58
|
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & BuilderWithMiddlewares<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
59
59
|
'meta'(meta: TMeta): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
60
60
|
'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
61
|
-
'input'<USchema extends
|
62
|
-
'output'<USchema extends
|
63
|
-
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, unknown, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema,
|
61
|
+
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
62
|
+
'output'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
63
|
+
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, unknown, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
64
64
|
'prefix'(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
65
65
|
'tag'(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
66
66
|
'router'<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TErrorMap>;
|
@@ -68,43 +68,43 @@ interface BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContex
|
|
68
68
|
default: U;
|
69
69
|
}>): EnhancedRouter<Lazy<U>, TInitialContext, TErrorMap>;
|
70
70
|
}
|
71
|
-
interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
71
|
+
interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
72
72
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
73
73
|
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
74
74
|
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilder<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
75
75
|
'meta'(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
76
76
|
'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
77
|
-
'input'<USchema extends
|
78
|
-
'output'<USchema extends
|
79
|
-
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, unknown, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema,
|
77
|
+
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
78
|
+
'output'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
79
|
+
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, unknown, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
80
80
|
}
|
81
|
-
interface ProcedureBuilderWithInput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
81
|
+
interface ProcedureBuilderWithInput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
82
82
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
83
83
|
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
84
|
-
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext,
|
85
|
-
'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<
|
84
|
+
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
85
|
+
'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
86
86
|
'meta'(meta: TMeta): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
87
87
|
'route'(route: Route): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
88
|
-
'output'<USchema extends
|
89
|
-
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext,
|
88
|
+
'output'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
89
|
+
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
90
90
|
}
|
91
|
-
interface ProcedureBuilderWithOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
91
|
+
interface ProcedureBuilderWithOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
92
92
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
93
93
|
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
94
|
-
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, unknown,
|
94
|
+
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, unknown, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithOutput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
95
95
|
'meta'(meta: TMeta): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
96
96
|
'route'(route: Route): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
97
|
-
'input'<USchema extends
|
98
|
-
'handler'(handler: ProcedureHandler<TCurrentContext, unknown,
|
97
|
+
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
98
|
+
'handler'(handler: ProcedureHandler<TCurrentContext, unknown, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
99
99
|
}
|
100
|
-
interface ProcedureBuilderWithInputOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
100
|
+
interface ProcedureBuilderWithInputOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
101
101
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
102
102
|
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
103
|
-
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext,
|
104
|
-
'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput,
|
103
|
+
'use'<UOutContext extends Context>(middleware: Middleware<TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInputOutput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
104
|
+
'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureBuilderWithInputOutput<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
105
105
|
'meta'(meta: TMeta): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
106
106
|
'route'(route: Route): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
107
|
-
'handler'(handler: ProcedureHandler<TCurrentContext,
|
107
|
+
'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
108
108
|
}
|
109
109
|
interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
110
110
|
'~orpc': EnhanceRouterOptions<TErrorMap>;
|
@@ -129,13 +129,13 @@ interface BuilderConfig {
|
|
129
129
|
initialInputValidationIndex?: number;
|
130
130
|
initialOutputValidationIndex?: number;
|
131
131
|
}
|
132
|
-
interface BuilderDef<TInputSchema extends
|
132
|
+
interface BuilderDef<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>, EnhanceRouterOptions<TErrorMap> {
|
133
133
|
middlewares: AnyMiddleware[];
|
134
134
|
inputValidationIndex: number;
|
135
135
|
outputValidationIndex: number;
|
136
136
|
config: BuilderConfig;
|
137
137
|
}
|
138
|
-
declare class Builder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
138
|
+
declare class Builder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
139
139
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
140
140
|
constructor(def: BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>);
|
141
141
|
/**
|
@@ -161,9 +161,9 @@ declare class Builder<TInitialContext extends Context, TCurrentContext extends C
|
|
161
161
|
use<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<unknown, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & BuilderWithMiddlewares<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
162
162
|
meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
163
163
|
route(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
164
|
-
input<USchema extends
|
165
|
-
output<USchema extends
|
166
|
-
handler<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, unknown, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema,
|
164
|
+
input<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta>;
|
165
|
+
output<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta>;
|
166
|
+
handler<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, unknown, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
167
167
|
prefix(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
168
168
|
tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
169
169
|
router<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TErrorMap>;
|
@@ -171,7 +171,7 @@ declare class Builder<TInitialContext extends Context, TCurrentContext extends C
|
|
171
171
|
default: U;
|
172
172
|
}>): EnhancedRouter<Lazy<U>, TInitialContext, TErrorMap>;
|
173
173
|
}
|
174
|
-
declare const os: Builder<
|
174
|
+
declare const os: Builder<Record<never, never>, Record<never, never>, Schema<unknown, unknown>, Schema<unknown, unknown>, Record<never, never>, Record<never, never>>;
|
175
175
|
|
176
176
|
interface Config {
|
177
177
|
initialInputValidationIndex: number;
|
@@ -182,26 +182,26 @@ declare function fallbackConfig<T extends keyof Config>(key: T, value?: Config[T
|
|
182
182
|
/**
|
183
183
|
* Like `DecoratedProcedure`, but removed all method that can change the contract.
|
184
184
|
*/
|
185
|
-
interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
186
|
-
use<U extends Context>(middleware: Middleware<TCurrentContext, U,
|
187
|
-
use<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput,
|
185
|
+
interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
186
|
+
use<U extends Context>(middleware: Middleware<TCurrentContext, U, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, U>> & DecoratedProcedure<TInitialContext, MergedContext<TCurrentContext, U>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
187
|
+
use<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & DecoratedProcedure<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
188
188
|
/**
|
189
189
|
* Make this procedure callable (works like a function while still being a procedure).
|
190
190
|
*/
|
191
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema,
|
191
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
192
192
|
/**
|
193
193
|
* Make this procedure compatible with server action (the same as .callable, but the type is compatible with server action).
|
194
194
|
*/
|
195
|
-
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema,
|
195
|
+
actionable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ((...rest: ClientRest<TClientContext, InferSchemaInput<TInputSchema>>) => Promise<InferSchemaOutput<TOutputSchema>>);
|
196
196
|
}
|
197
197
|
/**
|
198
198
|
* Like `ProcedureBuilderWithoutHandler`, but removed all method that can change the contract.
|
199
199
|
*/
|
200
|
-
interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
200
|
+
interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
201
201
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
202
|
-
'use'<U extends Context>(middleware: Middleware<TCurrentContext, U,
|
203
|
-
'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput,
|
204
|
-
'handler'(handler: ProcedureHandler<TCurrentContext,
|
202
|
+
'use'<U extends Context>(middleware: Middleware<TCurrentContext, U, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ConflictContextGuard<MergedContext<TCurrentContext, U>> & ProcedureImplementer<TInitialContext, MergedContext<TCurrentContext, U>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
203
|
+
'use'<UOutContext extends Context, UInput>(middleware: Middleware<TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ConflictContextGuard<MergedContext<TCurrentContext, UOutContext>> & ProcedureImplementer<TInitialContext, MergedContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
204
|
+
'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
205
205
|
}
|
206
206
|
|
207
207
|
interface RouterImplementerWithMiddlewares<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
@@ -249,12 +249,12 @@ declare function createContractedProcedure(procedure: AnyProcedure, contract: An
|
|
249
249
|
* ```
|
250
250
|
*
|
251
251
|
*/
|
252
|
-
declare function call<TInitialContext extends Context, TInputSchema extends
|
252
|
+
declare function call<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta>(procedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, input: InferSchemaInput<TInputSchema>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, Record<never, never>>>): ClientPromiseResult<InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
|
253
253
|
|
254
|
-
type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer
|
254
|
+
type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UErrorMap, any> ? ProcedureClient<TClientContext, UInputSchema, UOutputSchema, UErrorMap> : {
|
255
255
|
[K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
|
256
256
|
};
|
257
|
-
declare function createRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>,
|
257
|
+
declare function createRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>, Schema<unknown, unknown>, Schema<unknown, unknown>, ErrorMap, Meta, TClientContext>>): RouterClient<T, TClientContext>;
|
258
258
|
|
259
259
|
declare function setHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: AnyContractRouter): T;
|
260
260
|
declare function getHiddenRouterContract(router: Lazyable<AnyRouter | AnyContractRouter>): AnyContractRouter | undefined;
|
package/dist/index.mjs
CHANGED
@@ -205,8 +205,6 @@ const os = new Builder({
|
|
205
205
|
route: {},
|
206
206
|
meta: {},
|
207
207
|
errorMap: {},
|
208
|
-
inputSchema: void 0,
|
209
|
-
outputSchema: void 0,
|
210
208
|
inputValidationIndex: fallbackConfig("initialInputValidationIndex"),
|
211
209
|
outputValidationIndex: fallbackConfig("initialOutputValidationIndex"),
|
212
210
|
middlewares: []
|
package/dist/plugins/index.d.mts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
import { a as StandardHandlerInterceptorOptions, H as HandlerPlugin, b as StandardHandlerOptions } from '../shared/server.
|
2
|
-
export { C as CompositePlugin } from '../shared/server.
|
1
|
+
import { a as StandardHandlerInterceptorOptions, H as HandlerPlugin, b as StandardHandlerOptions } from '../shared/server.iM8li30u.mjs';
|
2
|
+
export { C as CompositePlugin } from '../shared/server.iM8li30u.mjs';
|
3
3
|
import { Value } from '@orpc/shared';
|
4
|
-
import { C as Context } from '../shared/server.
|
4
|
+
import { C as Context } from '../shared/server.CPteJIPP.mjs';
|
5
5
|
import '@orpc/contract';
|
6
6
|
import '@orpc/standard-server';
|
7
7
|
import '@orpc/client';
|
package/dist/plugins/index.d.ts
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
-
import { a as StandardHandlerInterceptorOptions, H as HandlerPlugin, b as StandardHandlerOptions } from '../shared/server.
|
2
|
-
export { C as CompositePlugin } from '../shared/server.
|
1
|
+
import { a as StandardHandlerInterceptorOptions, H as HandlerPlugin, b as StandardHandlerOptions } from '../shared/server.BZRSVRDu.js';
|
2
|
+
export { C as CompositePlugin } from '../shared/server.BZRSVRDu.js';
|
3
3
|
import { Value } from '@orpc/shared';
|
4
|
-
import { C as Context } from '../shared/server.
|
4
|
+
import { C as Context } from '../shared/server.CPteJIPP.js';
|
5
5
|
import '@orpc/contract';
|
6
6
|
import '@orpc/standard-server';
|
7
7
|
import '@orpc/client';
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import { HTTPPath,
|
1
|
+
import { HTTPPath, AnySchema, Meta, InferSchemaOutput, ErrorFromErrorMap } from '@orpc/contract';
|
2
2
|
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
3
3
|
import { StandardResponse, StandardLazyRequest } from '@orpc/standard-server';
|
4
|
-
import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.
|
4
|
+
import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.CPteJIPP.js';
|
5
5
|
import { ORPCError } from '@orpc/client';
|
6
6
|
|
7
7
|
type StandardParams = Record<string, string>;
|
@@ -54,7 +54,7 @@ interface StandardHandlerOptions<TContext extends Context> {
|
|
54
54
|
*
|
55
55
|
* Interceptors for procedure client.
|
56
56
|
*/
|
57
|
-
clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext,
|
57
|
+
clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, AnySchema, Record<never, never>, Meta>, InferSchemaOutput<AnySchema>, ErrorFromErrorMap<Record<never, never>>>[];
|
58
58
|
}
|
59
59
|
declare class StandardHandler<T extends Context> {
|
60
60
|
private readonly matcher;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { ORPCErrorCode, ORPCErrorOptions, ORPCError, ClientContext, Client } from '@orpc/client';
|
2
2
|
import { IsNever, MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
|
3
|
-
import { ErrorMap, ErrorMapItem,
|
3
|
+
import { ErrorMap, ErrorMapItem, InferSchemaInput, HTTPPath, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@orpc/contract';
|
4
4
|
|
5
5
|
type Context = Record<string, any>;
|
6
6
|
type MergedContext<T extends Context, U extends Context> = T & U;
|
@@ -12,7 +12,7 @@ type ConflictContextGuard<T extends Context> = true extends IsNever<T> | {
|
|
12
12
|
type ORPCErrorConstructorMapItemOptions<TData> = Omit<ORPCErrorOptions<TData>, 'defined' | 'status'>;
|
13
13
|
type ORPCErrorConstructorMapItem<TCode extends ORPCErrorCode, TInData> = (...rest: MaybeOptionalOptions<ORPCErrorConstructorMapItemOptions<TInData>>) => ORPCError<TCode, TInData>;
|
14
14
|
type ORPCErrorConstructorMap<T extends ErrorMap> = {
|
15
|
-
[K in keyof T]: K extends ORPCErrorCode ? T[K] extends ErrorMapItem<infer UInputSchema> ? ORPCErrorConstructorMapItem<K,
|
15
|
+
[K in keyof T]: K extends ORPCErrorCode ? T[K] extends ErrorMapItem<infer UInputSchema> ? ORPCErrorConstructorMapItem<K, InferSchemaInput<UInputSchema>> : never : never;
|
16
16
|
};
|
17
17
|
|
18
18
|
declare const LAZY_SYMBOL: unique symbol;
|
@@ -41,7 +41,7 @@ interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErro
|
|
41
41
|
context: TCurrentContext;
|
42
42
|
input: TInput;
|
43
43
|
path: readonly string[];
|
44
|
-
procedure: Procedure<Context, Context,
|
44
|
+
procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
|
45
45
|
signal?: AbortSignal;
|
46
46
|
lastEventId: string | undefined;
|
47
47
|
errors: TErrorConstructorMap;
|
@@ -49,18 +49,18 @@ interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErro
|
|
49
49
|
interface ProcedureHandler<TCurrentContext extends Context, TInput, THandlerOutput, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
50
50
|
(opt: ProcedureHandlerOptions<TCurrentContext, TInput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): Promisable<THandlerOutput>;
|
51
51
|
}
|
52
|
-
interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
52
|
+
interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
53
53
|
__initialContext?: (type: TInitialContext) => unknown;
|
54
54
|
middlewares: AnyMiddleware[];
|
55
55
|
inputValidationIndex: number;
|
56
56
|
outputValidationIndex: number;
|
57
|
-
handler: ProcedureHandler<TCurrentContext, any,
|
57
|
+
handler: ProcedureHandler<TCurrentContext, any, any, any, any>;
|
58
58
|
}
|
59
|
-
declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
60
|
-
'~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema,
|
61
|
-
constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema,
|
59
|
+
declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
60
|
+
'~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
61
|
+
constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>);
|
62
62
|
}
|
63
|
-
type AnyProcedure = Procedure<any, any, any, any, any, any
|
63
|
+
type AnyProcedure = Procedure<any, any, any, any, any, any>;
|
64
64
|
declare function isProcedure(item: unknown): item is AnyProcedure;
|
65
65
|
|
66
66
|
type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
|
@@ -81,7 +81,7 @@ interface MiddlewareOutputFn<TOutput> {
|
|
81
81
|
interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
82
82
|
context: TInContext;
|
83
83
|
path: readonly string[];
|
84
|
-
procedure: Procedure<Context, Context,
|
84
|
+
procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
|
85
85
|
signal?: AbortSignal;
|
86
86
|
lastEventId: string | undefined;
|
87
87
|
next: MiddlewareNextFn<TInContext, TOutput>;
|
@@ -96,47 +96,47 @@ interface MapInputMiddleware<TInput, TMappedInput> {
|
|
96
96
|
}
|
97
97
|
declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
|
98
98
|
|
99
|
-
type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends
|
100
|
-
interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TInputSchema extends
|
99
|
+
type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
|
100
|
+
interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TInputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
101
101
|
context: TInitialContext;
|
102
|
-
input:
|
102
|
+
input: InferSchemaInput<TInputSchema>;
|
103
103
|
errors: ORPCErrorConstructorMap<TErrorMap>;
|
104
104
|
path: readonly string[];
|
105
|
-
procedure: Procedure<Context, Context,
|
105
|
+
procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
|
106
106
|
signal?: AbortSignal;
|
107
107
|
lastEventId: string | undefined;
|
108
108
|
}
|
109
109
|
/**
|
110
110
|
* Options for creating a procedure caller with comprehensive type safety
|
111
111
|
*/
|
112
|
-
type CreateProcedureClientOptions<TInitialContext extends Context, TInputSchema extends
|
112
|
+
type CreateProcedureClientOptions<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
|
113
113
|
/**
|
114
114
|
* This is helpful for logging and analytics.
|
115
115
|
*/
|
116
116
|
path?: readonly string[];
|
117
|
-
interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TInputSchema, TErrorMap, TMeta>,
|
117
|
+
interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TInputSchema, TErrorMap, TMeta>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>[];
|
118
118
|
} & (Record<never, never> extends TInitialContext ? {
|
119
119
|
context?: Value<TInitialContext, [clientContext: TClientContext]>;
|
120
120
|
} : {
|
121
121
|
context: Value<TInitialContext, [clientContext: TClientContext]>;
|
122
122
|
});
|
123
|
-
declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends
|
123
|
+
declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
124
124
|
|
125
|
-
type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, UInputSchema, UOutputSchema,
|
125
|
+
type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, UInputSchema, UOutputSchema, UErrorMap, UMeta> : {
|
126
126
|
[K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
|
127
127
|
};
|
128
128
|
type AnyRouter = Router<any, any>;
|
129
129
|
type InferRouterInitialContext<T extends AnyRouter> = T extends Router<any, infer UInitialContext> ? UInitialContext : never;
|
130
|
-
type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any, any
|
130
|
+
type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any, any> ? UInitialContext : {
|
131
131
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInitialContexts<U> : never;
|
132
132
|
};
|
133
|
-
type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any, any
|
133
|
+
type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any, any> ? UCurrentContext : {
|
134
134
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterCurrentContexts<U> : never;
|
135
135
|
};
|
136
|
-
type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer UInputSchema, any, any, any
|
136
|
+
type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer UInputSchema, any, any, any> ? InferSchemaInput<UInputSchema> : {
|
137
137
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInputs<U> : never;
|
138
138
|
};
|
139
|
-
type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any, infer UOutputSchema,
|
139
|
+
type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any, infer UOutputSchema, any, any> ? InferSchemaOutput<UOutputSchema> : {
|
140
140
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
|
141
141
|
};
|
142
142
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
import { ORPCErrorCode, ORPCErrorOptions, ORPCError, ClientContext, Client } from '@orpc/client';
|
2
2
|
import { IsNever, MaybeOptionalOptions, Promisable, Interceptor, Value } from '@orpc/shared';
|
3
|
-
import { ErrorMap, ErrorMapItem,
|
3
|
+
import { ErrorMap, ErrorMapItem, InferSchemaInput, HTTPPath, AnySchema, Meta, ContractProcedureDef, InferSchemaOutput, ErrorFromErrorMap, AnyContractRouter, ContractProcedure } from '@orpc/contract';
|
4
4
|
|
5
5
|
type Context = Record<string, any>;
|
6
6
|
type MergedContext<T extends Context, U extends Context> = T & U;
|
@@ -12,7 +12,7 @@ type ConflictContextGuard<T extends Context> = true extends IsNever<T> | {
|
|
12
12
|
type ORPCErrorConstructorMapItemOptions<TData> = Omit<ORPCErrorOptions<TData>, 'defined' | 'status'>;
|
13
13
|
type ORPCErrorConstructorMapItem<TCode extends ORPCErrorCode, TInData> = (...rest: MaybeOptionalOptions<ORPCErrorConstructorMapItemOptions<TInData>>) => ORPCError<TCode, TInData>;
|
14
14
|
type ORPCErrorConstructorMap<T extends ErrorMap> = {
|
15
|
-
[K in keyof T]: K extends ORPCErrorCode ? T[K] extends ErrorMapItem<infer UInputSchema> ? ORPCErrorConstructorMapItem<K,
|
15
|
+
[K in keyof T]: K extends ORPCErrorCode ? T[K] extends ErrorMapItem<infer UInputSchema> ? ORPCErrorConstructorMapItem<K, InferSchemaInput<UInputSchema>> : never : never;
|
16
16
|
};
|
17
17
|
|
18
18
|
declare const LAZY_SYMBOL: unique symbol;
|
@@ -41,7 +41,7 @@ interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErro
|
|
41
41
|
context: TCurrentContext;
|
42
42
|
input: TInput;
|
43
43
|
path: readonly string[];
|
44
|
-
procedure: Procedure<Context, Context,
|
44
|
+
procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
|
45
45
|
signal?: AbortSignal;
|
46
46
|
lastEventId: string | undefined;
|
47
47
|
errors: TErrorConstructorMap;
|
@@ -49,18 +49,18 @@ interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErro
|
|
49
49
|
interface ProcedureHandler<TCurrentContext extends Context, TInput, THandlerOutput, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
50
50
|
(opt: ProcedureHandlerOptions<TCurrentContext, TInput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): Promisable<THandlerOutput>;
|
51
51
|
}
|
52
|
-
interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
52
|
+
interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
53
53
|
__initialContext?: (type: TInitialContext) => unknown;
|
54
54
|
middlewares: AnyMiddleware[];
|
55
55
|
inputValidationIndex: number;
|
56
56
|
outputValidationIndex: number;
|
57
|
-
handler: ProcedureHandler<TCurrentContext, any,
|
57
|
+
handler: ProcedureHandler<TCurrentContext, any, any, any, any>;
|
58
58
|
}
|
59
|
-
declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends
|
60
|
-
'~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema,
|
61
|
-
constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema,
|
59
|
+
declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
60
|
+
'~orpc': ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
61
|
+
constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>);
|
62
62
|
}
|
63
|
-
type AnyProcedure = Procedure<any, any, any, any, any, any
|
63
|
+
type AnyProcedure = Procedure<any, any, any, any, any, any>;
|
64
64
|
declare function isProcedure(item: unknown): item is AnyProcedure;
|
65
65
|
|
66
66
|
type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
|
@@ -81,7 +81,7 @@ interface MiddlewareOutputFn<TOutput> {
|
|
81
81
|
interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
82
82
|
context: TInContext;
|
83
83
|
path: readonly string[];
|
84
|
-
procedure: Procedure<Context, Context,
|
84
|
+
procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
|
85
85
|
signal?: AbortSignal;
|
86
86
|
lastEventId: string | undefined;
|
87
87
|
next: MiddlewareNextFn<TInContext, TOutput>;
|
@@ -96,47 +96,47 @@ interface MapInputMiddleware<TInput, TMappedInput> {
|
|
96
96
|
}
|
97
97
|
declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
|
98
98
|
|
99
|
-
type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends
|
100
|
-
interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TInputSchema extends
|
99
|
+
type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
|
100
|
+
interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TInputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
101
101
|
context: TInitialContext;
|
102
|
-
input:
|
102
|
+
input: InferSchemaInput<TInputSchema>;
|
103
103
|
errors: ORPCErrorConstructorMap<TErrorMap>;
|
104
104
|
path: readonly string[];
|
105
|
-
procedure: Procedure<Context, Context,
|
105
|
+
procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
|
106
106
|
signal?: AbortSignal;
|
107
107
|
lastEventId: string | undefined;
|
108
108
|
}
|
109
109
|
/**
|
110
110
|
* Options for creating a procedure caller with comprehensive type safety
|
111
111
|
*/
|
112
|
-
type CreateProcedureClientOptions<TInitialContext extends Context, TInputSchema extends
|
112
|
+
type CreateProcedureClientOptions<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
|
113
113
|
/**
|
114
114
|
* This is helpful for logging and analytics.
|
115
115
|
*/
|
116
116
|
path?: readonly string[];
|
117
|
-
interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TInputSchema, TErrorMap, TMeta>,
|
117
|
+
interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TInputSchema, TErrorMap, TMeta>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>[];
|
118
118
|
} & (Record<never, never> extends TInitialContext ? {
|
119
119
|
context?: Value<TInitialContext, [clientContext: TClientContext]>;
|
120
120
|
} : {
|
121
121
|
context: Value<TInitialContext, [clientContext: TClientContext]>;
|
122
122
|
});
|
123
|
-
declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends
|
123
|
+
declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...[options]: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
124
124
|
|
125
|
-
type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, UInputSchema, UOutputSchema,
|
125
|
+
type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, UInputSchema, UOutputSchema, UErrorMap, UMeta> : {
|
126
126
|
[K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
|
127
127
|
};
|
128
128
|
type AnyRouter = Router<any, any>;
|
129
129
|
type InferRouterInitialContext<T extends AnyRouter> = T extends Router<any, infer UInitialContext> ? UInitialContext : never;
|
130
|
-
type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any, any
|
130
|
+
type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any, any> ? UInitialContext : {
|
131
131
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInitialContexts<U> : never;
|
132
132
|
};
|
133
|
-
type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any, any
|
133
|
+
type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any, any> ? UCurrentContext : {
|
134
134
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterCurrentContexts<U> : never;
|
135
135
|
};
|
136
|
-
type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer UInputSchema, any, any, any
|
136
|
+
type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer UInputSchema, any, any, any> ? InferSchemaInput<UInputSchema> : {
|
137
137
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInputs<U> : never;
|
138
138
|
};
|
139
|
-
type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any, infer UOutputSchema,
|
139
|
+
type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, any, infer UOutputSchema, any, any> ? InferSchemaOutput<UOutputSchema> : {
|
140
140
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
|
141
141
|
};
|
142
142
|
|
@@ -1,7 +1,7 @@
|
|
1
|
-
import { HTTPPath,
|
1
|
+
import { HTTPPath, AnySchema, Meta, InferSchemaOutput, ErrorFromErrorMap } from '@orpc/contract';
|
2
2
|
import { Interceptor, MaybeOptionalOptions } from '@orpc/shared';
|
3
3
|
import { StandardResponse, StandardLazyRequest } from '@orpc/standard-server';
|
4
|
-
import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.
|
4
|
+
import { a as AnyRouter, A as AnyProcedure, C as Context, P as ProcedureClientInterceptorOptions, R as Router } from './server.CPteJIPP.mjs';
|
5
5
|
import { ORPCError } from '@orpc/client';
|
6
6
|
|
7
7
|
type StandardParams = Record<string, string>;
|
@@ -54,7 +54,7 @@ interface StandardHandlerOptions<TContext extends Context> {
|
|
54
54
|
*
|
55
55
|
* Interceptors for procedure client.
|
56
56
|
*/
|
57
|
-
clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext,
|
57
|
+
clientInterceptors?: Interceptor<ProcedureClientInterceptorOptions<TContext, AnySchema, Record<never, never>, Meta>, InferSchemaOutput<AnySchema>, ErrorFromErrorMap<Record<never, never>>>[];
|
58
58
|
}
|
59
59
|
declare class StandardHandler<T extends Context> {
|
60
60
|
private readonly matcher;
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@orpc/server",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.0.0-next.
|
4
|
+
"version": "0.0.0-next.3b1dac3",
|
5
5
|
"license": "MIT",
|
6
6
|
"homepage": "https://orpc.unnoq.com",
|
7
7
|
"repository": {
|
@@ -58,12 +58,12 @@
|
|
58
58
|
"next": ">=14.0.0"
|
59
59
|
},
|
60
60
|
"dependencies": {
|
61
|
-
"@orpc/client": "0.0.0-next.
|
62
|
-
"@orpc/
|
63
|
-
"@orpc/
|
64
|
-
"@orpc/standard-server
|
65
|
-
"@orpc/standard-server-fetch": "0.0.0-next.
|
66
|
-
"@orpc/
|
61
|
+
"@orpc/client": "0.0.0-next.3b1dac3",
|
62
|
+
"@orpc/contract": "0.0.0-next.3b1dac3",
|
63
|
+
"@orpc/shared": "0.0.0-next.3b1dac3",
|
64
|
+
"@orpc/standard-server": "0.0.0-next.3b1dac3",
|
65
|
+
"@orpc/standard-server-fetch": "0.0.0-next.3b1dac3",
|
66
|
+
"@orpc/standard-server-node": "0.0.0-next.3b1dac3"
|
67
67
|
},
|
68
68
|
"devDependencies": {
|
69
69
|
"light-my-request": "^6.5.1"
|