@temporary-name/server 1.9.3-alpha.65222302f1b71807a849530b3fe0fa0326d3c1a2 → 1.9.3-alpha.6dce39d156e86570d7f905d2e09463c8e1c80db2
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/aws-lambda/index.d.mts +3 -3
- package/dist/adapters/aws-lambda/index.d.ts +3 -3
- package/dist/adapters/aws-lambda/index.mjs +4 -6
- package/dist/adapters/fetch/index.d.mts +3 -3
- package/dist/adapters/fetch/index.d.ts +3 -3
- package/dist/adapters/fetch/index.mjs +4 -6
- package/dist/adapters/node/index.d.mts +3 -3
- package/dist/adapters/node/index.d.ts +3 -3
- package/dist/adapters/node/index.mjs +4 -6
- package/dist/adapters/standard/index.d.mts +20 -31
- package/dist/adapters/standard/index.d.ts +20 -31
- package/dist/adapters/standard/index.mjs +4 -6
- package/dist/index.d.mts +72 -139
- package/dist/index.d.ts +72 -139
- package/dist/index.mjs +106 -294
- package/dist/openapi/index.d.mts +1 -1
- package/dist/openapi/index.d.ts +1 -1
- package/dist/openapi/index.mjs +60 -77
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/index.d.ts +2 -2
- package/dist/shared/{server.CQyYNJ1H.d.ts → server.BSJugGGA.d.mts} +1 -2
- package/dist/shared/{server.SLLuK6_v.d.ts → server.Bs8EZATl.d.ts} +2 -2
- package/dist/shared/server.CHV9AQHl.mjs +412 -0
- package/dist/shared/server.CWWP8ypC.d.mts +239 -0
- package/dist/shared/server.CWWP8ypC.d.ts +239 -0
- package/dist/shared/{server.DLsti1Pv.mjs → server.Cn7WsRHl.mjs} +56 -95
- package/dist/shared/{server.BeuTpcmO.d.mts → server.DrMgIiBr.d.mts} +2 -2
- package/dist/shared/{server.C1fnTLq0.d.mts → server.EKwDe0d2.d.ts} +1 -2
- package/dist/shared/{server.BEHw7Eyx.mjs → server.JtIZ8YG7.mjs} +1 -11
- package/package.json +10 -9
- package/dist/shared/server.BKSOrA6h.d.mts +0 -192
- package/dist/shared/server.BKSOrA6h.d.ts +0 -192
- package/dist/shared/server.BKh8I1Ny.mjs +0 -239
package/dist/index.d.mts
CHANGED
|
@@ -1,119 +1,71 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput,
|
|
3
|
-
import {
|
|
1
|
+
import { Schemas, ErrorMap, Meta, ContractProcedure, MergedErrorMap, AnyShape, MergedSchemas, WrapShape, UnionToIntersection, AnySchema, Route, InferHandlerInputs, InferSchemaInput, ContractRouter, ContractProcedureDef, InitialSchemas, AnyContractRouter, InferContractRouterErrorMap, InferContractRouterMeta, AnyContractProcedure, InferProcedureClientInputs, InferSchemaOutput, ErrorFromErrorMap, Schema } from '@temporary-name/contract';
|
|
2
|
+
export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, MergedErrorMap, Meta, OutputStructure, Route, Schema, ValidationError, eventIterator, validateORPCError } from '@temporary-name/contract';
|
|
3
|
+
import { ClientContext, MaybeOptionalOptions, HTTPEndpoint, IntersectPick, HTTPPath, ClientOptions, ClientPromiseResult } from '@temporary-name/shared';
|
|
4
4
|
export { AsyncIteratorClass, ClientContext, EventPublisher, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, HTTPMethod, HTTPPath, IntersectPick, ORPCError, Registry, ThrowableError, asyncIteratorToStream as eventIteratorToStream, isDefinedError, onError, onFinish, onStart, onSuccess, safe, streamToAsyncIteratorClass as streamToEventIterator } from '@temporary-name/shared';
|
|
5
|
-
import {
|
|
6
|
-
|
|
5
|
+
import { SchemaClass, core } from '@temporary-name/zod';
|
|
6
|
+
import { C as Context, P as Procedure, a as CreateProcedureClientOptions, b as ProcedureClient, M as Middleware, O as ORPCErrorConstructorMap, c as MergedInitialContext, d as MergedCurrentContext, e as ProcedureHandler, E as EnhanceRouterOptions, R as Router, f as EnhancedRouter, g as MapInputMiddleware, A as AnyMiddleware, L as Lazy, h as AnyProcedure, i as Lazyable, j as AnyRouter, I as InferRouterInitialContext } from './shared/server.CWWP8ypC.mjs';
|
|
7
|
+
export { T as AccessibleLazyRouter, Y as ContractProcedureCallbackOptions, K as InferRouterCurrentContexts, J as InferRouterInitialContexts, N as InferRouterInputs, Q as InferRouterOutputs, o as LAZY_SYMBOL, p as LazyMeta, Z as LazyTraverseContractProceduresOptions, w as MiddlewareNextFn, y as MiddlewareOptions, x as MiddlewareOutputFn, v as MiddlewareResult, l as ORPCErrorConstructorMapItem, k as ORPCErrorConstructorMapItemOptions, G as ProcedureClientInterceptorOptions, D as ProcedureDef, B as ProcedureHandlerOptions, X as TraverseContractProcedureCallbackOptions, W as TraverseContractProceduresOptions, a0 as UnlaziedRouter, U as createAccessibleLazyRouter, n as createORPCErrorConstructorMap, H as createProcedureClient, V as enhanceRouter, t as getLazyMeta, S as getRouter, s as isLazy, F as isProcedure, r as lazy, q as lazyInternal, m as mergeCurrentContext, z as middlewareOutputFn, $ as resolveContractProcedures, _ as traverseContractProcedures, u as unlazy, a1 as unlazyRouter } from './shared/server.CWWP8ypC.mjs';
|
|
7
8
|
export { getEventMeta, withEventMeta } from '@temporary-name/standard-server';
|
|
8
9
|
|
|
9
|
-
declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context,
|
|
10
|
+
declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta> {
|
|
10
11
|
/**
|
|
11
|
-
*
|
|
12
|
-
* The provided errors are spared-merged with any existing errors.
|
|
13
|
-
*
|
|
14
|
-
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
15
|
-
*/
|
|
16
|
-
errors<U extends ErrorMap>(errors: U): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
17
|
-
/**
|
|
18
|
-
* Sets or updates the metadata.
|
|
19
|
-
* The provided metadata is spared-merged with any existing metadata.
|
|
20
|
-
*
|
|
21
|
-
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
22
|
-
*/
|
|
23
|
-
meta(meta: TMeta): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
24
|
-
/**
|
|
25
|
-
* Sets or updates the route definition.
|
|
26
|
-
* The provided route is spared-merged with any existing route.
|
|
27
|
-
* This option is typically relevant when integrating with OpenAPI.
|
|
12
|
+
* Make this procedure callable (works like a function while still being a procedure).
|
|
28
13
|
*
|
|
29
|
-
* @see {@link https://orpc.unnoq.com/docs/
|
|
30
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
14
|
+
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
31
15
|
*/
|
|
32
|
-
|
|
16
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TSchemas['outputSchema'], TErrorMap, TMeta, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta> & ProcedureClient<TClientContext, TSchemas, TErrorMap>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> extends ContractProcedure<TSchemas, TErrorMap, TMeta> {
|
|
20
|
+
z: SchemaClass<TGateName>;
|
|
33
21
|
/**
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
37
|
-
* @info Pass second argument to map the input.
|
|
38
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
39
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
22
|
+
* This property holds the defined options.
|
|
40
23
|
*/
|
|
41
|
-
|
|
24
|
+
'~orpc': BuilderDef<TSchemas, TErrorMap, TMeta>;
|
|
25
|
+
constructor(def: BuilderDef<TSchemas, TErrorMap, TMeta>);
|
|
42
26
|
/**
|
|
43
|
-
*
|
|
27
|
+
* Adds type-safe custom errors to the contract.
|
|
28
|
+
* The provided errors are spared-merged with any existing errors in the contract.
|
|
44
29
|
*
|
|
45
|
-
* @
|
|
46
|
-
* @info Pass second argument to map the input.
|
|
47
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
48
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
30
|
+
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
49
31
|
*/
|
|
50
|
-
|
|
32
|
+
errors<U extends ErrorMap>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, MergedErrorMap<TErrorMap, U>, TMeta, TGateName>;
|
|
51
33
|
/**
|
|
52
|
-
*
|
|
34
|
+
* Sets or updates the metadata for the contract.
|
|
35
|
+
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
53
36
|
*
|
|
54
|
-
* @see {@link https://orpc.unnoq.com/docs/
|
|
55
|
-
*/
|
|
56
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
|
|
60
|
-
type AccessibleLazyRouter<T extends Lazyable<AnyRouter | undefined>> = T extends Lazy<infer U extends AnyRouter | undefined | Lazy<AnyRouter | undefined>> ? AccessibleLazyRouter<U> : T extends AnyProcedure | undefined ? Lazy<T> : Lazy<T> & {
|
|
61
|
-
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? AccessibleLazyRouter<T[K]> : never;
|
|
62
|
-
};
|
|
63
|
-
declare function createAccessibleLazyRouter<T extends Lazy<AnyRouter | undefined>>(lazied: T): AccessibleLazyRouter<T>;
|
|
64
|
-
type EnhancedRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap> = T extends Lazy<infer U extends AnyRouter> ? AccessibleLazyRouter<EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>> : T extends (Procedure<infer UInitialContext, infer UCurrentContext, infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta>) ? Procedure<MergedInitialContext<TInitialContext, UInitialContext, TCurrentContext>, UCurrentContext, UInputSchema, UOutputSchema, MergedErrorMap<TErrorMap, UErrorMap>, UMeta> : {
|
|
65
|
-
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? EnhancedRouter<T[K], TInitialContext, TCurrentContext, TErrorMap> : never;
|
|
66
|
-
};
|
|
67
|
-
interface EnhanceRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
|
|
68
|
-
middlewares: readonly AnyMiddleware[];
|
|
69
|
-
errorMap: TErrorMap;
|
|
70
|
-
dedupeLeadingMiddlewares: boolean;
|
|
71
|
-
}
|
|
72
|
-
declare function enhanceRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap>(router: T, options: EnhanceRouterOptions<TErrorMap>): EnhancedRouter<T, TInitialContext, TCurrentContext, TErrorMap>;
|
|
73
|
-
interface TraverseContractProceduresOptions {
|
|
74
|
-
router: AnyContractRouter | AnyRouter;
|
|
75
|
-
path: readonly string[];
|
|
76
|
-
}
|
|
77
|
-
interface TraverseContractProcedureCallbackOptions {
|
|
78
|
-
contract: AnyContractProcedure | AnyProcedure;
|
|
79
|
-
path: readonly string[];
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* @deprecated Use `TraverseContractProcedureCallbackOptions` instead.
|
|
83
|
-
*/
|
|
84
|
-
type ContractProcedureCallbackOptions = TraverseContractProcedureCallbackOptions;
|
|
85
|
-
interface LazyTraverseContractProceduresOptions {
|
|
86
|
-
router: Lazy<AnyRouter>;
|
|
87
|
-
path: readonly string[];
|
|
88
|
-
}
|
|
89
|
-
declare function traverseContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void, lazyOptions?: LazyTraverseContractProceduresOptions[]): LazyTraverseContractProceduresOptions[];
|
|
90
|
-
declare function resolveContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void): Promise<void>;
|
|
91
|
-
type UnlaziedRouter<T extends AnyRouter> = T extends AnyProcedure ? T : {
|
|
92
|
-
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? UnlaziedRouter<U> : never;
|
|
93
|
-
};
|
|
94
|
-
declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedRouter<T>>;
|
|
95
|
-
|
|
96
|
-
declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> extends ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
|
97
|
-
/**
|
|
98
|
-
* This property holds the defined options.
|
|
37
|
+
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
99
38
|
*/
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
39
|
+
meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta, TGateName>;
|
|
40
|
+
endpoint<U extends AnyShape[]>(strings: TemplateStringsArray, ...values: [...U]): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
41
|
+
pathSchema: WrapShape<UnionToIntersection<U>>;
|
|
42
|
+
}>, TErrorMap, TMeta, TGateName>;
|
|
43
|
+
endpoint<U extends AnySchema | AnyShape = core.$ZodType<Record<string, never>, Record<string, never>>>(endpoint: HTTPEndpoint, schema?: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
44
|
+
pathSchema: WrapShape<U>;
|
|
45
|
+
}>, TErrorMap, TMeta, TGateName>;
|
|
105
46
|
/**
|
|
106
|
-
*
|
|
47
|
+
* Sets or updates the route definition for the contract.
|
|
48
|
+
* The provided route is spared-merged with any existing route in the contract.
|
|
49
|
+
* This option is typically relevant when integrating with OpenAPI.
|
|
107
50
|
*
|
|
108
|
-
* @see {@link https://orpc.unnoq.com/docs/
|
|
51
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
52
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
109
53
|
*/
|
|
110
|
-
|
|
54
|
+
endpointOpts(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta, TGateName>;
|
|
55
|
+
query<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
56
|
+
querySchema: WrapShape<U>;
|
|
57
|
+
}>, TErrorMap, TMeta, TGateName>;
|
|
58
|
+
body<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
59
|
+
bodySchema: WrapShape<U>;
|
|
60
|
+
}>, TErrorMap, TMeta, TGateName>;
|
|
111
61
|
/**
|
|
112
62
|
* Defines the output validation schema.
|
|
113
63
|
*
|
|
114
64
|
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
|
|
115
65
|
*/
|
|
116
|
-
output<
|
|
66
|
+
output<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
67
|
+
outputSchema: WrapShape<U>;
|
|
68
|
+
}>, TErrorMap, TMeta, TGateName>;
|
|
117
69
|
/**
|
|
118
70
|
* Uses a middleware to modify the context or improve the pipeline.
|
|
119
71
|
*
|
|
@@ -121,18 +73,18 @@ declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext
|
|
|
121
73
|
* @note The current context must be satisfy middleware dependent-context
|
|
122
74
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
123
75
|
*/
|
|
124
|
-
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureBuilder<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>,
|
|
76
|
+
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureBuilder<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TErrorMap, TMeta, TGateName>;
|
|
125
77
|
useGating<const TInferredGateName extends string>(gates: TInferredGateName[], isGateEnabled: (gate: TInferredGateName, ctx: TCurrentContext) => boolean): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, Context, TCurrentContext>, MergedCurrentContext<TCurrentContext, {
|
|
126
78
|
isGateEnabled: typeof isGateEnabled;
|
|
127
|
-
}>,
|
|
79
|
+
}>, TSchemas, TErrorMap, TMeta, TInferredGateName>;
|
|
128
80
|
/**
|
|
129
81
|
* Defines the handler of the procedure.
|
|
130
82
|
*
|
|
131
83
|
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
132
84
|
*/
|
|
133
|
-
handler
|
|
85
|
+
handler(handler: ProcedureHandler<TCurrentContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta>;
|
|
134
86
|
}
|
|
135
|
-
declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context,
|
|
87
|
+
declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> extends ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta, TGateName> {
|
|
136
88
|
/**
|
|
137
89
|
* Prefixes all procedures in the router.
|
|
138
90
|
* The provided prefix is post-appended to any existing router prefix.
|
|
@@ -141,7 +93,7 @@ declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentCo
|
|
|
141
93
|
*
|
|
142
94
|
* @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
143
95
|
*/
|
|
144
|
-
prefix(prefix: HTTPPath):
|
|
96
|
+
prefix(prefix: HTTPPath): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta, TGateName>;
|
|
145
97
|
/**
|
|
146
98
|
* Adds tags to all procedures in the router.
|
|
147
99
|
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
@@ -155,17 +107,8 @@ declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentCo
|
|
|
155
107
|
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
156
108
|
*/
|
|
157
109
|
router<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>;
|
|
158
|
-
/**
|
|
159
|
-
* Create a lazy router
|
|
160
|
-
* And applies all of the previously defined options to the specified router.
|
|
161
|
-
*
|
|
162
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
163
|
-
*/
|
|
164
|
-
lazyRoute<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(loader: () => Promise<{
|
|
165
|
-
default: U;
|
|
166
|
-
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, TErrorMap>;
|
|
167
110
|
}
|
|
168
|
-
interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> extends Pick<BuilderWithMiddlewares<TInitialContext, TCurrentContext, any,
|
|
111
|
+
interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> extends Pick<BuilderWithMiddlewares<TInitialContext, TCurrentContext, any, TErrorMap, TMeta, any>, 'prefix' | 'tag' | 'router'> {
|
|
169
112
|
/**
|
|
170
113
|
* This property holds the defined options.
|
|
171
114
|
*/
|
|
@@ -194,18 +137,18 @@ interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Co
|
|
|
194
137
|
}
|
|
195
138
|
declare function decorateMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta>(middleware: Middleware<TInContext, TOutContext, TInput, TOutput, TErrorConstructorMap, TMeta>): DecoratedMiddleware<TInContext, TOutContext, TInput, TOutput, TErrorConstructorMap, TMeta>;
|
|
196
139
|
|
|
197
|
-
interface BuilderDef<
|
|
140
|
+
interface BuilderDef<TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TSchemas, TErrorMap, TMeta>, EnhanceRouterOptions<TErrorMap> {
|
|
198
141
|
middlewares: readonly AnyMiddleware[];
|
|
199
142
|
inputValidationIndex: number;
|
|
200
143
|
outputValidationIndex: number;
|
|
201
144
|
}
|
|
202
|
-
declare class Builder<TInitialContext extends Context, TCurrentContext extends Context,
|
|
145
|
+
declare class Builder<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> extends BuilderWithMiddlewares<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta, TGateName> {
|
|
203
146
|
/**
|
|
204
147
|
* Set or override the initial context.
|
|
205
148
|
*
|
|
206
149
|
* @see {@link https://orpc.unnoq.com/docs/context Context Docs}
|
|
207
150
|
*/
|
|
208
|
-
$context<U extends Context>(): Builder<U
|
|
151
|
+
$context<U extends Context>(): Builder<U, U, TSchemas, TErrorMap, TMeta, TGateName>;
|
|
209
152
|
/**
|
|
210
153
|
* Creates a middleware.
|
|
211
154
|
*
|
|
@@ -214,7 +157,7 @@ declare class Builder<TInitialContext extends Context, TCurrentContext extends C
|
|
|
214
157
|
middleware<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
|
215
158
|
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, TMeta>;
|
|
216
159
|
}
|
|
217
|
-
type ApiBuilder<TMeta extends Meta> = Builder<Record<never, never>, Record<never, never>,
|
|
160
|
+
type ApiBuilder<TMeta extends Meta> = Builder<Record<never, never>, Record<never, never>, InitialSchemas, Record<never, never>, TMeta, never>;
|
|
218
161
|
interface ApiBuilderOpts<TMeta extends Meta> {
|
|
219
162
|
meta?: TMeta;
|
|
220
163
|
}
|
|
@@ -224,7 +167,7 @@ declare const os: ApiBuilder<Record<never, never>>;
|
|
|
224
167
|
/**
|
|
225
168
|
* Like `DecoratedProcedure`, but removed all method that can change the contract.
|
|
226
169
|
*/
|
|
227
|
-
interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext extends Context,
|
|
170
|
+
interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta> {
|
|
228
171
|
/**
|
|
229
172
|
* Uses a middleware to modify the context or improve the pipeline.
|
|
230
173
|
*
|
|
@@ -233,7 +176,7 @@ interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext
|
|
|
233
176
|
* @note The current context must be satisfy middleware dependent-context
|
|
234
177
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
235
178
|
*/
|
|
236
|
-
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext,
|
|
179
|
+
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ImplementedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TErrorMap, TMeta>;
|
|
237
180
|
/**
|
|
238
181
|
* Uses a middleware to modify the context or improve the pipeline.
|
|
239
182
|
*
|
|
@@ -242,19 +185,19 @@ interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext
|
|
|
242
185
|
* @note The current context must be satisfy middleware dependent-context
|
|
243
186
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
244
187
|
*/
|
|
245
|
-
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<
|
|
188
|
+
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TSchemas['outputSchema']>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferHandlerInputs<TSchemas>, UInput>): ImplementedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TErrorMap, TMeta>;
|
|
246
189
|
/**
|
|
247
190
|
* Make this procedure callable (works like a function while still being a procedure).
|
|
248
191
|
*
|
|
249
192
|
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
250
193
|
*/
|
|
251
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext,
|
|
194
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TSchemas['outputSchema'], TErrorMap, TMeta, TClientContext>>): ImplementedProcedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta> & ProcedureClient<TClientContext, TSchemas, TErrorMap>;
|
|
252
195
|
}
|
|
253
196
|
/**
|
|
254
197
|
* Like `ProcedureBuilderWithoutHandler`, but removed all method that can change the contract.
|
|
255
198
|
*/
|
|
256
|
-
interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context,
|
|
257
|
-
'~orpc': BuilderDef<
|
|
199
|
+
interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
200
|
+
'~orpc': BuilderDef<TSchemas, TErrorMap, TMeta>;
|
|
258
201
|
/**
|
|
259
202
|
* Uses a middleware to modify the context or improve the pipeline.
|
|
260
203
|
*
|
|
@@ -263,7 +206,7 @@ interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext
|
|
|
263
206
|
* @note The current context must be satisfy middleware dependent-context
|
|
264
207
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
265
208
|
*/
|
|
266
|
-
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext,
|
|
209
|
+
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TErrorMap, TMeta>;
|
|
267
210
|
/**
|
|
268
211
|
* Uses a middleware to modify the context or improve the pipeline.
|
|
269
212
|
*
|
|
@@ -272,13 +215,13 @@ interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext
|
|
|
272
215
|
* @note The current context must be satisfy middleware dependent-context
|
|
273
216
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
274
217
|
*/
|
|
275
|
-
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<
|
|
218
|
+
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TSchemas['outputSchema']>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferHandlerInputs<TSchemas>, UInput>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TErrorMap, TMeta>;
|
|
276
219
|
/**
|
|
277
220
|
* Defines the handler of the procedure.
|
|
278
221
|
*
|
|
279
222
|
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
280
223
|
*/
|
|
281
|
-
'handler'(handler: ProcedureHandler<TCurrentContext,
|
|
224
|
+
'handler'(handler: ProcedureHandler<TCurrentContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta>;
|
|
282
225
|
}
|
|
283
226
|
|
|
284
227
|
interface RouterImplementerWithMiddlewares<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
|
@@ -297,18 +240,8 @@ interface RouterImplementerWithMiddlewares<T extends AnyContractRouter, TInitial
|
|
|
297
240
|
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
298
241
|
*/
|
|
299
242
|
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
300
|
-
/**
|
|
301
|
-
* Create a lazy router
|
|
302
|
-
* And applies all of the previously defined options to the specified router.
|
|
303
|
-
* And enforces the router match the contract.
|
|
304
|
-
*
|
|
305
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
306
|
-
*/
|
|
307
|
-
lazyRoute<U extends Router<T, TInitialContext>>(loader: () => Promise<{
|
|
308
|
-
default: U;
|
|
309
|
-
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
310
243
|
}
|
|
311
|
-
type ImplementerInternalWithMiddlewares<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = TContract extends ContractProcedure<infer
|
|
244
|
+
type ImplementerInternalWithMiddlewares<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = TContract extends ContractProcedure<infer USchemas, infer UErrorMap, infer UMeta> ? ProcedureImplementer<TInitialContext, TCurrentContext, USchemas, UErrorMap, UMeta> : RouterImplementerWithMiddlewares<TContract, TInitialContext, TCurrentContext> & {
|
|
312
245
|
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternalWithMiddlewares<TContract[K], TInitialContext, TCurrentContext> : never;
|
|
313
246
|
};
|
|
314
247
|
|
|
@@ -346,7 +279,7 @@ interface RouterImplementer<T extends AnyContractRouter, TInitialContext extends
|
|
|
346
279
|
default: U;
|
|
347
280
|
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
348
281
|
}
|
|
349
|
-
type ImplementerInternal<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = TContract extends ContractProcedure<infer
|
|
282
|
+
type ImplementerInternal<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = TContract extends ContractProcedure<infer USchemas, infer UErrorMap, infer UMeta> ? ProcedureImplementer<TInitialContext, TCurrentContext, USchemas, UErrorMap, UMeta> : RouterImplementer<TContract, TInitialContext, TCurrentContext> & {
|
|
350
283
|
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternal<TContract[K], TInitialContext, TCurrentContext> : never;
|
|
351
284
|
};
|
|
352
285
|
declare function implementerInternal<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context>(contract: T, middlewares: AnyMiddleware[]): ImplementerInternal<T, TInitialContext, TCurrentContext>;
|
|
@@ -356,7 +289,7 @@ type Implementer<TContract extends AnyContractRouter, TInitialContext extends Co
|
|
|
356
289
|
*
|
|
357
290
|
* @see {@link https://orpc.unnoq.com/docs/context Context Docs}
|
|
358
291
|
*/
|
|
359
|
-
$context<U extends Context>(): Implementer<TContract, U
|
|
292
|
+
$context<U extends Context>(): Implementer<TContract, U, U>;
|
|
360
293
|
} & ImplementerInternal<TContract, TInitialContext, TCurrentContext>;
|
|
361
294
|
declare function implement<T extends AnyContractRouter, TContext extends Context = Record<never, never>>(contract: T): Implementer<T, TContext, TContext>;
|
|
362
295
|
|
|
@@ -381,9 +314,9 @@ declare function createContractedProcedure(procedure: AnyProcedure, contract: An
|
|
|
381
314
|
* ```
|
|
382
315
|
*
|
|
383
316
|
*/
|
|
384
|
-
declare function call<TInitialContext extends Context,
|
|
317
|
+
declare function call<TInitialContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta>(procedure: Lazyable<Procedure<TInitialContext, any, TSchemas, TErrorMap, TMeta>>, input: InferProcedureClientInputs<TSchemas>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TSchemas['outputSchema'], TErrorMap, TMeta, Record<never, never>> & Omit<ClientOptions<Record<never, never>>, 'context'>>): ClientPromiseResult<InferSchemaOutput<TSchemas['outputSchema']>, ErrorFromErrorMap<TErrorMap>>;
|
|
385
318
|
|
|
386
|
-
type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Procedure<any, any, infer
|
|
319
|
+
type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Procedure<any, any, infer USchemas, infer UErrorMap, any> ? ProcedureClient<TClientContext, USchemas, UErrorMap> : {
|
|
387
320
|
[K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
|
|
388
321
|
};
|
|
389
322
|
/**
|
|
@@ -396,5 +329,5 @@ declare function createRouterClient<T extends AnyRouter, TClientContext extends
|
|
|
396
329
|
declare function setHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: AnyContractRouter): T;
|
|
397
330
|
declare function getHiddenRouterContract(router: Lazyable<AnyRouter | AnyContractRouter>): AnyContractRouter | undefined;
|
|
398
331
|
|
|
399
|
-
export { AnyMiddleware, AnyProcedure, AnyRouter, Builder, BuilderWithMiddlewares, Context, CreateProcedureClientOptions, DecoratedProcedure, InferRouterInitialContext, Lazy, Lazyable, MapInputMiddleware, MergedCurrentContext, MergedInitialContext, Middleware, ORPCErrorConstructorMap, Procedure, ProcedureBuilder, ProcedureClient, ProcedureHandler, Router, addMiddleware, call,
|
|
400
|
-
export type {
|
|
332
|
+
export { AnyMiddleware, AnyProcedure, AnyRouter, Builder, BuilderWithMiddlewares, Context, CreateProcedureClientOptions, DecoratedProcedure, EnhanceRouterOptions, EnhancedRouter, InferRouterInitialContext, Lazy, Lazyable, MapInputMiddleware, MergedCurrentContext, MergedInitialContext, Middleware, ORPCErrorConstructorMap, Procedure, ProcedureBuilder, ProcedureClient, ProcedureHandler, Router, addMiddleware, call, createApiBuilder, createAssertedLazyProcedure, createContractedProcedure, createRouterClient, decorateMiddleware, getHiddenRouterContract, implement, implementerInternal, isStartWithMiddlewares, mergeMiddlewares, os, setHiddenRouterContract };
|
|
333
|
+
export type { ApiBuilder, BuilderDef, DecoratedMiddleware, ImplementedProcedure, Implementer, ImplementerInternal, ImplementerInternalWithMiddlewares, ProcedureImplementer, RouterBuilder, RouterClient, RouterImplementer, RouterImplementerWithMiddlewares };
|