@temporary-name/server 1.9.3-alpha.5537ef74244620c125352bc9356d8c0ae804f10d → 1.9.3-alpha.5c041722542bb790586629fc98d4c72d9f6ee65e
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 +3 -3
- package/dist/adapters/fetch/index.d.mts +3 -3
- package/dist/adapters/fetch/index.d.ts +3 -3
- package/dist/adapters/fetch/index.mjs +3 -3
- package/dist/adapters/node/index.d.mts +3 -3
- package/dist/adapters/node/index.d.ts +3 -3
- package/dist/adapters/node/index.mjs +3 -3
- package/dist/adapters/standard/index.d.mts +14 -30
- package/dist/adapters/standard/index.d.ts +14 -30
- package/dist/adapters/standard/index.mjs +3 -3
- package/dist/index.d.mts +46 -139
- package/dist/index.d.ts +46 -139
- package/dist/index.mjs +51 -295
- package/dist/openapi/index.mjs +30 -64
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/index.d.ts +2 -2
- package/dist/shared/{server.Bzrdopnd.d.ts → server.B5czSQQh.d.mts} +114 -71
- package/dist/shared/{server.Bzrdopnd.d.mts → server.B5czSQQh.d.ts} +114 -71
- package/dist/shared/{server.DcfsPloY.mjs → server.BdGbIyq8.mjs} +211 -17
- package/dist/shared/{server.Cp__uvkw.d.mts → server.Bk8Hmx7Z.d.mts} +2 -2
- package/dist/shared/{server.B9i6p26R.d.ts → server.C4l2ZA3m.d.ts} +1 -2
- package/dist/shared/{server.CYRDznXq.d.ts → server.D7UjcuIv.d.ts} +2 -2
- package/dist/shared/{server.BEHw7Eyx.mjs → server.Kxw442A9.mjs} +1 -1
- package/dist/shared/{server.B9VxPdeK.mjs → server.SmOM3Fae.mjs} +58 -89
- package/dist/shared/{server.C-j2WKJz.d.mts → server.TgmlNh8r.d.mts} +1 -2
- package/package.json +10 -10
package/dist/index.d.ts
CHANGED
|
@@ -1,120 +1,42 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput,
|
|
3
|
-
import {
|
|
1
|
+
import { Schemas, ErrorMap, Meta, ContractProcedure, MergedErrorMap, Route, AnySchema, MergedSchemas, InferSchemaOutput, InferSchemaInput, ContractRouter, ContractProcedureDef, InitialSchemas, AnyContractRouter, InferContractRouterErrorMap, InferContractRouterMeta, AnyContractProcedure, 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, 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
5
|
import { SchemaClass } from '@temporary-name/zod';
|
|
6
|
-
import { C as Context, P as Procedure, M as Middleware, O as ORPCErrorConstructorMap,
|
|
7
|
-
export {
|
|
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.B5czSQQh.js';
|
|
7
|
+
export { U as AccessibleLazyRouter, Z as ContractProcedureCallbackOptions, N as InferRouterCurrentContexts, K as InferRouterInitialContexts, Q as InferRouterInputs, S as InferRouterOutputs, o as LAZY_SYMBOL, p as LazyMeta, _ as LazyTraverseContractProceduresOptions, x as MiddlewareNextFn, w as MiddlewareNextFnOptions, z as MiddlewareOptions, y as MiddlewareOutputFn, v as MiddlewareResult, l as ORPCErrorConstructorMapItem, k as ORPCErrorConstructorMapItemOptions, H as ProcedureClientInterceptorOptions, F as ProcedureDef, D as ProcedureHandlerOptions, Y as TraverseContractProcedureCallbackOptions, X as TraverseContractProceduresOptions, a1 as UnlaziedRouter, V as createAccessibleLazyRouter, n as createORPCErrorConstructorMap, J as createProcedureClient, W as enhanceRouter, t as getLazyMeta, T as getRouter, s as isLazy, G as isProcedure, r as lazy, q as lazyInternal, m as mergeCurrentContext, B as middlewareOutputFn, a0 as resolveContractProcedures, $ as traverseContractProcedures, u as unlazy, a2 as unlazyRouter } from './shared/server.B5czSQQh.js';
|
|
8
8
|
export { getEventMeta, withEventMeta } from '@temporary-name/standard-server';
|
|
9
9
|
|
|
10
|
-
declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context,
|
|
11
|
-
/**
|
|
12
|
-
* Adds type-safe custom errors.
|
|
13
|
-
* The provided errors are spared-merged with any existing errors.
|
|
14
|
-
*
|
|
15
|
-
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
16
|
-
*/
|
|
17
|
-
errors<U extends ErrorMap>(errors: U): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
18
|
-
/**
|
|
19
|
-
* Sets or updates the metadata.
|
|
20
|
-
* The provided metadata is spared-merged with any existing metadata.
|
|
21
|
-
*
|
|
22
|
-
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
23
|
-
*/
|
|
24
|
-
meta(meta: TMeta): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
25
|
-
/**
|
|
26
|
-
* Sets or updates the route definition.
|
|
27
|
-
* The provided route is spared-merged with any existing route.
|
|
28
|
-
* This option is typically relevant when integrating with OpenAPI.
|
|
29
|
-
*
|
|
30
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
31
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
32
|
-
*/
|
|
33
|
-
route(route: Route): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
34
|
-
/**
|
|
35
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
36
|
-
*
|
|
37
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
38
|
-
* @info Pass second argument to map the input.
|
|
39
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
40
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
41
|
-
*/
|
|
42
|
-
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): DecoratedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
43
|
-
/**
|
|
44
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
45
|
-
*
|
|
46
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
47
|
-
* @info Pass second argument to map the input.
|
|
48
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
49
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
50
|
-
*/
|
|
51
|
-
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): DecoratedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
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> {
|
|
52
11
|
/**
|
|
53
12
|
* Make this procedure callable (works like a function while still being a procedure).
|
|
54
13
|
*
|
|
55
14
|
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
56
15
|
*/
|
|
57
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext,
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
|
|
61
|
-
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> & {
|
|
62
|
-
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? AccessibleLazyRouter<T[K]> : never;
|
|
63
|
-
};
|
|
64
|
-
declare function createAccessibleLazyRouter<T extends Lazy<AnyRouter | undefined>>(lazied: T): AccessibleLazyRouter<T>;
|
|
65
|
-
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> : {
|
|
66
|
-
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? EnhancedRouter<T[K], TInitialContext, TCurrentContext, TErrorMap> : never;
|
|
67
|
-
};
|
|
68
|
-
interface EnhanceRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
|
|
69
|
-
middlewares: readonly AnyMiddleware[];
|
|
70
|
-
errorMap: TErrorMap;
|
|
71
|
-
dedupeLeadingMiddlewares: boolean;
|
|
72
|
-
}
|
|
73
|
-
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>;
|
|
74
|
-
interface TraverseContractProceduresOptions {
|
|
75
|
-
router: AnyContractRouter | AnyRouter;
|
|
76
|
-
path: readonly string[];
|
|
16
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TSchemas['outputSchema'], TErrorMap, TMeta, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta> & ProcedureClient<TClientContext, TSchemas, TErrorMap>;
|
|
77
17
|
}
|
|
78
|
-
interface TraverseContractProcedureCallbackOptions {
|
|
79
|
-
contract: AnyContractProcedure | AnyProcedure;
|
|
80
|
-
path: readonly string[];
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* @deprecated Use `TraverseContractProcedureCallbackOptions` instead.
|
|
84
|
-
*/
|
|
85
|
-
type ContractProcedureCallbackOptions = TraverseContractProcedureCallbackOptions;
|
|
86
|
-
interface LazyTraverseContractProceduresOptions {
|
|
87
|
-
router: Lazy<AnyRouter>;
|
|
88
|
-
path: readonly string[];
|
|
89
|
-
}
|
|
90
|
-
declare function traverseContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void, lazyOptions?: LazyTraverseContractProceduresOptions[]): LazyTraverseContractProceduresOptions[];
|
|
91
|
-
declare function resolveContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void): Promise<void>;
|
|
92
|
-
type UnlaziedRouter<T extends AnyRouter> = T extends AnyProcedure ? T : {
|
|
93
|
-
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? UnlaziedRouter<U> : never;
|
|
94
|
-
};
|
|
95
|
-
declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedRouter<T>>;
|
|
96
18
|
|
|
97
|
-
declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context,
|
|
98
|
-
z: SchemaClass
|
|
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>;
|
|
99
21
|
/**
|
|
100
22
|
* This property holds the defined options.
|
|
101
23
|
*/
|
|
102
|
-
'~orpc': BuilderDef<
|
|
103
|
-
constructor(def: BuilderDef<
|
|
24
|
+
'~orpc': BuilderDef<TSchemas, TErrorMap, TMeta>;
|
|
25
|
+
constructor(def: BuilderDef<TSchemas, TErrorMap, TMeta>);
|
|
104
26
|
/**
|
|
105
27
|
* Adds type-safe custom errors to the contract.
|
|
106
28
|
* The provided errors are spared-merged with any existing errors in the contract.
|
|
107
29
|
*
|
|
108
30
|
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
109
31
|
*/
|
|
110
|
-
errors<U extends ErrorMap>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext,
|
|
32
|
+
errors<U extends ErrorMap>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, MergedErrorMap<TErrorMap, U>, TMeta, TGateName>;
|
|
111
33
|
/**
|
|
112
34
|
* Sets or updates the metadata for the contract.
|
|
113
35
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
114
36
|
*
|
|
115
37
|
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
116
38
|
*/
|
|
117
|
-
meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext,
|
|
39
|
+
meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta, TGateName>;
|
|
118
40
|
/**
|
|
119
41
|
* Sets or updates the route definition for the contract.
|
|
120
42
|
* The provided route is spared-merged with any existing route in the contract.
|
|
@@ -123,19 +45,23 @@ declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext
|
|
|
123
45
|
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
124
46
|
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
125
47
|
*/
|
|
126
|
-
route(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext,
|
|
48
|
+
route(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta, TGateName>;
|
|
127
49
|
/**
|
|
128
50
|
* Defines the input validation schema.
|
|
129
51
|
*
|
|
130
52
|
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
|
|
131
53
|
*/
|
|
132
|
-
input<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext,
|
|
54
|
+
input<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
55
|
+
inputSchema: USchema;
|
|
56
|
+
}>, TErrorMap, TMeta, TGateName>;
|
|
133
57
|
/**
|
|
134
58
|
* Defines the output validation schema.
|
|
135
59
|
*
|
|
136
60
|
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
|
|
137
61
|
*/
|
|
138
|
-
output<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext,
|
|
62
|
+
output<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
63
|
+
outputSchema: USchema;
|
|
64
|
+
}>, TErrorMap, TMeta, TGateName>;
|
|
139
65
|
/**
|
|
140
66
|
* Uses a middleware to modify the context or improve the pipeline.
|
|
141
67
|
*
|
|
@@ -143,18 +69,18 @@ declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext
|
|
|
143
69
|
* @note The current context must be satisfy middleware dependent-context
|
|
144
70
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
145
71
|
*/
|
|
146
|
-
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>,
|
|
72
|
+
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>;
|
|
147
73
|
useGating<const TInferredGateName extends string>(gates: TInferredGateName[], isGateEnabled: (gate: TInferredGateName, ctx: TCurrentContext) => boolean): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, Context, TCurrentContext>, MergedCurrentContext<TCurrentContext, {
|
|
148
74
|
isGateEnabled: typeof isGateEnabled;
|
|
149
|
-
}>,
|
|
75
|
+
}>, TSchemas, TErrorMap, TMeta, TInferredGateName>;
|
|
150
76
|
/**
|
|
151
77
|
* Defines the handler of the procedure.
|
|
152
78
|
*
|
|
153
79
|
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
154
80
|
*/
|
|
155
|
-
handler
|
|
81
|
+
handler(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TSchemas['inputSchema']>, InferSchemaInput<TSchemas['outputSchema']>, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta>;
|
|
156
82
|
}
|
|
157
|
-
declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context,
|
|
83
|
+
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> {
|
|
158
84
|
/**
|
|
159
85
|
* Prefixes all procedures in the router.
|
|
160
86
|
* The provided prefix is post-appended to any existing router prefix.
|
|
@@ -163,7 +89,7 @@ declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentCo
|
|
|
163
89
|
*
|
|
164
90
|
* @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
165
91
|
*/
|
|
166
|
-
prefix(prefix: HTTPPath): BuilderWithMiddlewares<TInitialContext, TCurrentContext,
|
|
92
|
+
prefix(prefix: HTTPPath): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta, TGateName>;
|
|
167
93
|
/**
|
|
168
94
|
* Adds tags to all procedures in the router.
|
|
169
95
|
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
@@ -177,17 +103,8 @@ declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentCo
|
|
|
177
103
|
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
178
104
|
*/
|
|
179
105
|
router<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>;
|
|
180
|
-
/**
|
|
181
|
-
* Create a lazy router
|
|
182
|
-
* And applies all of the previously defined options to the specified router.
|
|
183
|
-
*
|
|
184
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
185
|
-
*/
|
|
186
|
-
lazyRoute<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(loader: () => Promise<{
|
|
187
|
-
default: U;
|
|
188
|
-
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, TErrorMap>;
|
|
189
106
|
}
|
|
190
|
-
interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> extends Pick<BuilderWithMiddlewares<TInitialContext, TCurrentContext, any,
|
|
107
|
+
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'> {
|
|
191
108
|
/**
|
|
192
109
|
* This property holds the defined options.
|
|
193
110
|
*/
|
|
@@ -216,18 +133,18 @@ interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Co
|
|
|
216
133
|
}
|
|
217
134
|
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>;
|
|
218
135
|
|
|
219
|
-
interface BuilderDef<
|
|
136
|
+
interface BuilderDef<TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TSchemas, TErrorMap, TMeta>, EnhanceRouterOptions<TErrorMap> {
|
|
220
137
|
middlewares: readonly AnyMiddleware[];
|
|
221
138
|
inputValidationIndex: number;
|
|
222
139
|
outputValidationIndex: number;
|
|
223
140
|
}
|
|
224
|
-
declare class Builder<TInitialContext extends Context, TCurrentContext extends Context,
|
|
141
|
+
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> {
|
|
225
142
|
/**
|
|
226
143
|
* Set or override the initial context.
|
|
227
144
|
*
|
|
228
145
|
* @see {@link https://orpc.unnoq.com/docs/context Context Docs}
|
|
229
146
|
*/
|
|
230
|
-
$context<U extends Context>(): Builder<U
|
|
147
|
+
$context<U extends Context>(): Builder<U, U, TSchemas, TErrorMap, TMeta, TGateName>;
|
|
231
148
|
/**
|
|
232
149
|
* Creates a middleware.
|
|
233
150
|
*
|
|
@@ -236,7 +153,7 @@ declare class Builder<TInitialContext extends Context, TCurrentContext extends C
|
|
|
236
153
|
middleware<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
|
237
154
|
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, TMeta>;
|
|
238
155
|
}
|
|
239
|
-
type ApiBuilder<TMeta extends Meta> = Builder<Record<never, never>, Record<never, never>,
|
|
156
|
+
type ApiBuilder<TMeta extends Meta> = Builder<Record<never, never>, Record<never, never>, InitialSchemas, Record<never, never>, TMeta, never>;
|
|
240
157
|
interface ApiBuilderOpts<TMeta extends Meta> {
|
|
241
158
|
meta?: TMeta;
|
|
242
159
|
}
|
|
@@ -246,7 +163,7 @@ declare const os: ApiBuilder<Record<never, never>>;
|
|
|
246
163
|
/**
|
|
247
164
|
* Like `DecoratedProcedure`, but removed all method that can change the contract.
|
|
248
165
|
*/
|
|
249
|
-
interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext extends Context,
|
|
166
|
+
interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta> {
|
|
250
167
|
/**
|
|
251
168
|
* Uses a middleware to modify the context or improve the pipeline.
|
|
252
169
|
*
|
|
@@ -255,7 +172,7 @@ interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext
|
|
|
255
172
|
* @note The current context must be satisfy middleware dependent-context
|
|
256
173
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
257
174
|
*/
|
|
258
|
-
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<
|
|
175
|
+
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TSchemas['inputSchema']>, InferSchemaInput<TSchemas['outputSchema']>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ImplementedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TErrorMap, TMeta>;
|
|
259
176
|
/**
|
|
260
177
|
* Uses a middleware to modify the context or improve the pipeline.
|
|
261
178
|
*
|
|
@@ -264,19 +181,19 @@ interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext
|
|
|
264
181
|
* @note The current context must be satisfy middleware dependent-context
|
|
265
182
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
266
183
|
*/
|
|
267
|
-
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<
|
|
184
|
+
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<InferSchemaOutput<TSchemas['inputSchema']>, UInput>): ImplementedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TErrorMap, TMeta>;
|
|
268
185
|
/**
|
|
269
186
|
* Make this procedure callable (works like a function while still being a procedure).
|
|
270
187
|
*
|
|
271
188
|
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
272
189
|
*/
|
|
273
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext,
|
|
190
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TSchemas['outputSchema'], TErrorMap, TMeta, TClientContext>>): ImplementedProcedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta> & ProcedureClient<TClientContext, TSchemas, TErrorMap>;
|
|
274
191
|
}
|
|
275
192
|
/**
|
|
276
193
|
* Like `ProcedureBuilderWithoutHandler`, but removed all method that can change the contract.
|
|
277
194
|
*/
|
|
278
|
-
interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context,
|
|
279
|
-
'~orpc': BuilderDef<
|
|
195
|
+
interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
196
|
+
'~orpc': BuilderDef<TSchemas, TErrorMap, TMeta>;
|
|
280
197
|
/**
|
|
281
198
|
* Uses a middleware to modify the context or improve the pipeline.
|
|
282
199
|
*
|
|
@@ -285,7 +202,7 @@ interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext
|
|
|
285
202
|
* @note The current context must be satisfy middleware dependent-context
|
|
286
203
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
287
204
|
*/
|
|
288
|
-
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<
|
|
205
|
+
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TSchemas['inputSchema']>, InferSchemaInput<TSchemas['outputSchema']>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TErrorMap, TMeta>;
|
|
289
206
|
/**
|
|
290
207
|
* Uses a middleware to modify the context or improve the pipeline.
|
|
291
208
|
*
|
|
@@ -294,13 +211,13 @@ interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext
|
|
|
294
211
|
* @note The current context must be satisfy middleware dependent-context
|
|
295
212
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
296
213
|
*/
|
|
297
|
-
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<
|
|
214
|
+
'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<InferSchemaOutput<TSchemas['inputSchema']>, UInput>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TErrorMap, TMeta>;
|
|
298
215
|
/**
|
|
299
216
|
* Defines the handler of the procedure.
|
|
300
217
|
*
|
|
301
218
|
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
302
219
|
*/
|
|
303
|
-
'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<
|
|
220
|
+
'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TSchemas['inputSchema']>, InferSchemaInput<TSchemas['outputSchema']>, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta>;
|
|
304
221
|
}
|
|
305
222
|
|
|
306
223
|
interface RouterImplementerWithMiddlewares<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
|
@@ -319,18 +236,8 @@ interface RouterImplementerWithMiddlewares<T extends AnyContractRouter, TInitial
|
|
|
319
236
|
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
320
237
|
*/
|
|
321
238
|
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
322
|
-
/**
|
|
323
|
-
* Create a lazy router
|
|
324
|
-
* And applies all of the previously defined options to the specified router.
|
|
325
|
-
* And enforces the router match the contract.
|
|
326
|
-
*
|
|
327
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
328
|
-
*/
|
|
329
|
-
lazyRoute<U extends Router<T, TInitialContext>>(loader: () => Promise<{
|
|
330
|
-
default: U;
|
|
331
|
-
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
332
239
|
}
|
|
333
|
-
type ImplementerInternalWithMiddlewares<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = TContract extends ContractProcedure<infer
|
|
240
|
+
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> & {
|
|
334
241
|
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternalWithMiddlewares<TContract[K], TInitialContext, TCurrentContext> : never;
|
|
335
242
|
};
|
|
336
243
|
|
|
@@ -368,7 +275,7 @@ interface RouterImplementer<T extends AnyContractRouter, TInitialContext extends
|
|
|
368
275
|
default: U;
|
|
369
276
|
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
370
277
|
}
|
|
371
|
-
type ImplementerInternal<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = TContract extends ContractProcedure<infer
|
|
278
|
+
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> & {
|
|
372
279
|
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternal<TContract[K], TInitialContext, TCurrentContext> : never;
|
|
373
280
|
};
|
|
374
281
|
declare function implementerInternal<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context>(contract: T, middlewares: AnyMiddleware[]): ImplementerInternal<T, TInitialContext, TCurrentContext>;
|
|
@@ -378,7 +285,7 @@ type Implementer<TContract extends AnyContractRouter, TInitialContext extends Co
|
|
|
378
285
|
*
|
|
379
286
|
* @see {@link https://orpc.unnoq.com/docs/context Context Docs}
|
|
380
287
|
*/
|
|
381
|
-
$context<U extends Context>(): Implementer<TContract, U
|
|
288
|
+
$context<U extends Context>(): Implementer<TContract, U, U>;
|
|
382
289
|
} & ImplementerInternal<TContract, TInitialContext, TCurrentContext>;
|
|
383
290
|
declare function implement<T extends AnyContractRouter, TContext extends Context = Record<never, never>>(contract: T): Implementer<T, TContext, TContext>;
|
|
384
291
|
|
|
@@ -403,9 +310,9 @@ declare function createContractedProcedure(procedure: AnyProcedure, contract: An
|
|
|
403
310
|
* ```
|
|
404
311
|
*
|
|
405
312
|
*/
|
|
406
|
-
declare function call<TInitialContext extends Context,
|
|
313
|
+
declare function call<TInitialContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta>(procedure: Lazyable<Procedure<TInitialContext, any, TSchemas, TErrorMap, TMeta>>, input: InferSchemaInput<TSchemas['inputSchema']>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TSchemas['outputSchema'], TErrorMap, TMeta, Record<never, never>> & Omit<ClientOptions<Record<never, never>>, 'context'>>): ClientPromiseResult<InferSchemaOutput<TSchemas['outputSchema']>, ErrorFromErrorMap<TErrorMap>>;
|
|
407
314
|
|
|
408
|
-
type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Procedure<any, any, infer
|
|
315
|
+
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> : {
|
|
409
316
|
[K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
|
|
410
317
|
};
|
|
411
318
|
/**
|
|
@@ -418,5 +325,5 @@ declare function createRouterClient<T extends AnyRouter, TClientContext extends
|
|
|
418
325
|
declare function setHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: AnyContractRouter): T;
|
|
419
326
|
declare function getHiddenRouterContract(router: Lazyable<AnyRouter | AnyContractRouter>): AnyContractRouter | undefined;
|
|
420
327
|
|
|
421
|
-
export { AnyMiddleware, AnyProcedure, AnyRouter, Builder, BuilderWithMiddlewares, Context, CreateProcedureClientOptions, DecoratedProcedure, InferRouterInitialContext, Lazy, Lazyable, MapInputMiddleware, MergedCurrentContext, MergedInitialContext, Middleware, ORPCErrorConstructorMap, Procedure, ProcedureBuilder, ProcedureClient, ProcedureHandler, Router, addMiddleware, call,
|
|
422
|
-
export type {
|
|
328
|
+
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 };
|
|
329
|
+
export type { ApiBuilder, BuilderDef, DecoratedMiddleware, ImplementedProcedure, Implementer, ImplementerInternal, ImplementerInternalWithMiddlewares, ProcedureImplementer, RouterBuilder, RouterClient, RouterImplementer, RouterImplementerWithMiddlewares };
|