@temporary-name/server 1.9.3-alpha.4275e976ddda4d8be107c2cfde9899bdea9a337d → 1.9.3-alpha.4c6c68e5af7355d5a6dff1179055586e1093ac2d
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 +12 -8
- package/dist/adapters/aws-lambda/index.d.ts +12 -8
- package/dist/adapters/aws-lambda/index.mjs +12 -4
- package/dist/adapters/fetch/index.d.mts +15 -87
- package/dist/adapters/fetch/index.d.ts +15 -87
- package/dist/adapters/fetch/index.mjs +23 -161
- package/dist/adapters/node/index.d.mts +15 -64
- package/dist/adapters/node/index.d.ts +15 -64
- package/dist/adapters/node/index.mjs +21 -126
- package/dist/adapters/standard/index.d.mts +27 -14
- package/dist/adapters/standard/index.d.ts +27 -14
- package/dist/adapters/standard/index.mjs +9 -101
- package/dist/helpers/index.mjs +3 -29
- package/dist/index.d.mts +120 -583
- package/dist/index.d.ts +120 -583
- package/dist/index.mjs +213 -449
- package/dist/openapi/index.d.mts +204 -0
- package/dist/openapi/index.d.ts +204 -0
- package/dist/openapi/index.mjs +692 -0
- package/dist/shared/server.BbUmcWIW.d.mts +41 -0
- package/dist/shared/server.BfraJHay.d.mts +373 -0
- package/dist/shared/server.BfraJHay.d.ts +373 -0
- package/dist/shared/server.C1RJffw4.mjs +30 -0
- package/dist/shared/server.CHugaZ_Y.d.ts +41 -0
- package/dist/shared/server.CQIFwyhc.mjs +40 -0
- package/dist/shared/server.CYa9puL2.mjs +403 -0
- package/dist/shared/server.ChOv1yG3.mjs +319 -0
- package/dist/shared/server.Cza0RB3u.mjs +160 -0
- package/dist/shared/server.YUvuxHty.mjs +48 -0
- package/package.json +18 -30
- package/dist/plugins/index.d.mts +0 -160
- package/dist/plugins/index.d.ts +0 -160
- package/dist/plugins/index.mjs +0 -288
- package/dist/shared/server.BEQrAa3A.mjs +0 -207
- package/dist/shared/server.Bo94xDTv.d.mts +0 -73
- package/dist/shared/server.Btxrgkj5.d.ts +0 -73
- package/dist/shared/server.C1YnHvvf.d.mts +0 -192
- package/dist/shared/server.C1YnHvvf.d.ts +0 -192
- package/dist/shared/server.D6K9uoPI.mjs +0 -35
- package/dist/shared/server.DZ5BIITo.mjs +0 -9
- package/dist/shared/server.X0YaZxSJ.mjs +0 -13
package/dist/index.d.mts
CHANGED
|
@@ -1,361 +1,97 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export { H as InferRouterCurrentContexts, G as InferRouterInitialContexts, J as InferRouterInputs, K as InferRouterOutputs, o as LAZY_SYMBOL, p as LazyMeta, w as MiddlewareNextFn, v as MiddlewareNextFnOptions, y as MiddlewareOptions, x as MiddlewareOutputFn, t as MiddlewareResult, l as ORPCErrorConstructorMapItem, k as ORPCErrorConstructorMapItemOptions, P as ProcedureClientInterceptorOptions, D as ProcedureDef, B as ProcedureHandlerOptions, n as createORPCErrorConstructorMap, F as createProcedureClient, s as getLazyMeta, r as isLazy, E as isProcedure, q as lazy, m as mergeCurrentContext, z as middlewareOutputFn, u as unlazy } from './shared/server.C1YnHvvf.mjs';
|
|
1
|
+
import { ClientContext, Value, Promisable, Client, MaybeOptionalOptions, HTTPEndpoint as HTTPEndpoint$1, IntersectPick, OptionalIfEmpty, HTTPPath, AsyncIteratorClass, ClientOptions, HTTPMethod } from '@temporary-name/shared';
|
|
2
|
+
export { AsyncIteratorClass, ClientContext, EventPublisher, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, HTTPMethod, HTTPPath, IntersectPick, ORPCError, asyncIteratorToStream as eventIteratorToStream, isDefinedError, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@temporary-name/shared';
|
|
3
|
+
import { SchemaClass, core } from '@temporary-name/zod';
|
|
4
|
+
import { C as Context, S as Schemas, I as InferProcedureClientInputs, a as InferSchemaOutput, M as Meta, L as Lazyable, P as Procedure, b as Contract, A as AnyShape, c as MergedSchemas, W as WrapShape, U as UnionToIntersection, d as AnySchema, R as Route, e as Middleware, f as MergedCurrentContext, g as MergedInitialContext, h as AuthType, V as ValidatedAuthContext, i as AuthConfig, B as BuildContextWithAuth, j as ProcedureHandler, k as InferHandlerInputs, l as InferSchemaInput, E as EnhanceRouterOptions, m as Router, n as EnhancedRouter, o as MapInputMiddleware, p as ContractDef, q as InitialSchemas, r as SchemaIssue, s as Schema, t as AnyMiddleware, u as Lazy, v as AnyProcedure, w as AnyRouter, x as InferRouterInitialContext } from './shared/server.BfraJHay.mjs';
|
|
5
|
+
export { a8 as AccessibleLazyRouter, $ as AnyContractDef, ad as ContractProcedureCallbackOptions, a2 as ContractRouter, Z as DefaultProcedureHandlerOptions, a4 as InferRouterCurrentContexts, a3 as InferRouterInitialContexts, a5 as InferRouterInputs, a6 as InferRouterOutputs, z as LAZY_SYMBOL, D as LazyMeta, ae as LazyTraverseContractProceduresOptions, Q as MiddlewareNextFn, X as MiddlewareOptions, T as MiddlewareOutputFn, O as MiddlewareResult, a0 as ProcedureDef, _ as ProcedureHandlerOptions, ac as TraverseContractProcedureCallbackOptions, ab as TraverseContractProceduresOptions, aj as TypeRest, ah as UnlaziedRouter, a9 as createAccessibleLazyRouter, aa as enhanceRouter, J as getLazyMeta, a7 as getRouter, ak as initialSchemas, H as isLazy, a1 as isProcedure, G as lazy, F as lazyInternal, y as mergeCurrentContext, N as mergeMeta, Y as middlewareOutputFn, ag as resolveContractProcedures, af as traverseContractProcedures, K as unlazy, ai as unlazyRouter } from './shared/server.BfraJHay.mjs';
|
|
7
6
|
export { getEventMeta, withEventMeta } from '@temporary-name/standard-server';
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
type ProcedureClient<TClientContext extends ClientContext, TSchemas extends Schemas> = Client<TClientContext, InferProcedureClientInputs<TSchemas>, InferSchemaOutput<TSchemas['outputSchema']>>;
|
|
9
|
+
type CreateProcedureClientOptions<TInitialContext extends Context, TClientContext extends ClientContext> = {
|
|
10
10
|
/**
|
|
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.
|
|
28
|
-
*
|
|
29
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
30
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
31
|
-
*/
|
|
32
|
-
route(route: Route): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
33
|
-
/**
|
|
34
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
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}
|
|
40
|
-
*/
|
|
41
|
-
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>;
|
|
42
|
-
/**
|
|
43
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
44
|
-
*
|
|
45
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
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}
|
|
49
|
-
*/
|
|
50
|
-
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>;
|
|
51
|
-
/**
|
|
52
|
-
* Make this procedure callable (works like a function while still being a procedure).
|
|
53
|
-
*
|
|
54
|
-
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
11
|
+
* This is helpful for logging and analytics.
|
|
55
12
|
*/
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
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
|
-
}
|
|
13
|
+
path?: readonly string[];
|
|
14
|
+
} & (object extends TInitialContext ? {
|
|
15
|
+
context?: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
16
|
+
} : {
|
|
17
|
+
context: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
18
|
+
});
|
|
81
19
|
/**
|
|
82
|
-
*
|
|
20
|
+
* Create Server-side client from a procedure.
|
|
21
|
+
*
|
|
22
|
+
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
83
23
|
*/
|
|
84
|
-
|
|
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>>;
|
|
24
|
+
declare function createProcedureClient<TInitialContext extends Context, TSchemas extends Schemas, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TSchemas, TMeta>>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TClientContext>>): ProcedureClient<TClientContext, TSchemas>;
|
|
95
25
|
|
|
96
|
-
|
|
97
|
-
/**
|
|
98
|
-
* This property holds the defined options.
|
|
99
|
-
*/
|
|
100
|
-
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
101
|
-
/**
|
|
102
|
-
* Adds type-safe custom errors.
|
|
103
|
-
* The provided errors are spared-merged with any existing errors.
|
|
104
|
-
*
|
|
105
|
-
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
106
|
-
*/
|
|
107
|
-
'errors'<U extends ErrorMap>(errors: U): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta, TGateName>;
|
|
108
|
-
/**
|
|
109
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
110
|
-
*
|
|
111
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
112
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
113
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
114
|
-
*/
|
|
115
|
-
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
116
|
-
/**
|
|
117
|
-
* Sets or updates the metadata.
|
|
118
|
-
* The provided metadata is spared-merged with any existing metadata.
|
|
119
|
-
*
|
|
120
|
-
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
121
|
-
*/
|
|
122
|
-
'meta'(meta: TMeta): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
123
|
-
/**
|
|
124
|
-
* Sets or updates the route definition.
|
|
125
|
-
* The provided route is spared-merged with any existing route.
|
|
126
|
-
* This option is typically relevant when integrating with OpenAPI.
|
|
127
|
-
*
|
|
128
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
129
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
130
|
-
*/
|
|
131
|
-
'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
132
|
-
/**
|
|
133
|
-
* Defines the input validation schema.
|
|
134
|
-
*
|
|
135
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
|
|
136
|
-
*/
|
|
137
|
-
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
138
|
-
/**
|
|
139
|
-
* Defines the output validation schema.
|
|
140
|
-
*
|
|
141
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
|
|
142
|
-
*/
|
|
143
|
-
'output'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta, TGateName>;
|
|
144
|
-
/**
|
|
145
|
-
* Defines the handler of the procedure.
|
|
146
|
-
*
|
|
147
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
148
|
-
*/
|
|
149
|
-
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
|
150
|
-
/**
|
|
151
|
-
* Prefixes all procedures in the router.
|
|
152
|
-
* The provided prefix is post-appended to any existing router prefix.
|
|
153
|
-
*
|
|
154
|
-
* @note This option does not affect procedures that do not define a path in their route definition.
|
|
155
|
-
*
|
|
156
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
157
|
-
*/
|
|
158
|
-
'prefix'(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
|
159
|
-
/**
|
|
160
|
-
* Adds tags to all procedures in the router.
|
|
161
|
-
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
162
|
-
*
|
|
163
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
164
|
-
*/
|
|
165
|
-
'tag'(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
|
26
|
+
declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TSchemas, TMeta> {
|
|
166
27
|
/**
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
170
|
-
*/
|
|
171
|
-
'router'<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>;
|
|
172
|
-
/**
|
|
173
|
-
* Create a lazy router
|
|
174
|
-
* And applies all of the previously defined options to the specified router.
|
|
28
|
+
* Make this procedure callable (works like a function while still being a procedure).
|
|
175
29
|
*
|
|
176
|
-
* @see {@link https://orpc.unnoq.com/docs/
|
|
30
|
+
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
177
31
|
*/
|
|
178
|
-
|
|
179
|
-
default: U;
|
|
180
|
-
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, TErrorMap>;
|
|
32
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TSchemas, TMeta> & ProcedureClient<TClientContext, TSchemas>;
|
|
181
33
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
187
|
-
/**
|
|
188
|
-
* Adds type-safe custom errors.
|
|
189
|
-
* The provided errors are spared-merged with any existing errors.
|
|
190
|
-
*
|
|
191
|
-
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
192
|
-
*/
|
|
193
|
-
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta, TGateName>;
|
|
194
|
-
/**
|
|
195
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
196
|
-
*
|
|
197
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
198
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
199
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
200
|
-
*/
|
|
201
|
-
'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>, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
34
|
+
|
|
35
|
+
declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TMeta extends Meta, TGateName extends string> extends Contract<BuilderDef<TSchemas, TMeta>> {
|
|
36
|
+
z: SchemaClass<TGateName>;
|
|
37
|
+
constructor(def: BuilderDef<TSchemas, TMeta>);
|
|
202
38
|
/**
|
|
203
|
-
* Sets or updates the metadata.
|
|
204
|
-
* The provided metadata is spared-merged with any existing metadata.
|
|
39
|
+
* Sets or updates the metadata for the contract.
|
|
40
|
+
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
205
41
|
*
|
|
206
42
|
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
207
43
|
*/
|
|
208
|
-
|
|
44
|
+
meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TMeta, TGateName>;
|
|
45
|
+
endpoint<U extends AnyShape[]>(strings: TemplateStringsArray, ...values: [...U]): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
46
|
+
pathSchema: WrapShape<UnionToIntersection<U>>;
|
|
47
|
+
}>, TMeta, TGateName>;
|
|
48
|
+
endpoint<U extends AnySchema | AnyShape = core.$ZodType<Record<string, never>, Record<string, never>>>(endpoint: HTTPEndpoint$1, schema?: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
49
|
+
pathSchema: WrapShape<U>;
|
|
50
|
+
}>, TMeta, TGateName>;
|
|
209
51
|
/**
|
|
210
|
-
* Sets or updates the route definition.
|
|
211
|
-
* The provided route is spared-merged with any existing route.
|
|
52
|
+
* Sets or updates the route definition for the contract.
|
|
53
|
+
* The provided route is spared-merged with any existing route in the contract.
|
|
212
54
|
* This option is typically relevant when integrating with OpenAPI.
|
|
213
55
|
*
|
|
214
56
|
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
215
57
|
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
216
58
|
*/
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
59
|
+
endpointOpts(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TMeta, TGateName>;
|
|
60
|
+
query<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
61
|
+
querySchema: WrapShape<U>;
|
|
62
|
+
}>, TMeta, TGateName>;
|
|
63
|
+
body<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
64
|
+
bodySchema: WrapShape<U>;
|
|
65
|
+
}>, TMeta, TGateName>;
|
|
224
66
|
/**
|
|
225
67
|
* Defines the output validation schema.
|
|
226
68
|
*
|
|
227
69
|
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
|
|
228
70
|
*/
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
*
|
|
233
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
234
|
-
*/
|
|
235
|
-
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
|
236
|
-
}
|
|
237
|
-
interface ProcedureBuilderWithOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> {
|
|
238
|
-
/**
|
|
239
|
-
* This property holds the defined options.
|
|
240
|
-
*/
|
|
241
|
-
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
242
|
-
/**
|
|
243
|
-
* Adds type-safe custom errors.
|
|
244
|
-
* The provided errors are spared-merged with any existing errors.
|
|
245
|
-
*
|
|
246
|
-
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
247
|
-
*/
|
|
248
|
-
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta, TGateName>;
|
|
249
|
-
/**
|
|
250
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
251
|
-
*
|
|
252
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
253
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
254
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
255
|
-
*/
|
|
256
|
-
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureBuilderWithOutput<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
257
|
-
/**
|
|
258
|
-
* Sets or updates the metadata.
|
|
259
|
-
* The provided metadata is spared-merged with any existing metadata.
|
|
260
|
-
*
|
|
261
|
-
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
262
|
-
*/
|
|
263
|
-
'meta'(meta: TMeta): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
264
|
-
/**
|
|
265
|
-
* Sets or updates the route definition.
|
|
266
|
-
* The provided route is spared-merged with any existing route.
|
|
267
|
-
* This option is typically relevant when integrating with OpenAPI.
|
|
268
|
-
*
|
|
269
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
270
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
271
|
-
*/
|
|
272
|
-
'route'(route: Route): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
273
|
-
/**
|
|
274
|
-
* Defines the input validation schema.
|
|
275
|
-
*
|
|
276
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
|
|
277
|
-
*/
|
|
278
|
-
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
279
|
-
/**
|
|
280
|
-
* Defines the handler of the procedure.
|
|
281
|
-
*
|
|
282
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
283
|
-
*/
|
|
284
|
-
'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
285
|
-
}
|
|
286
|
-
interface ProcedureBuilderWithInputOutput<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> {
|
|
287
|
-
/**
|
|
288
|
-
* This property holds the defined options.
|
|
289
|
-
*/
|
|
290
|
-
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
291
|
-
/**
|
|
292
|
-
* Adds type-safe custom errors.
|
|
293
|
-
* The provided errors are spared-merged with any existing errors.
|
|
294
|
-
*
|
|
295
|
-
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
296
|
-
*/
|
|
297
|
-
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta, TGateName>;
|
|
71
|
+
output<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
72
|
+
outputSchema: WrapShape<U>;
|
|
73
|
+
}>, TMeta, TGateName>;
|
|
298
74
|
/**
|
|
299
75
|
* Uses a middleware to modify the context or improve the pipeline.
|
|
300
76
|
*
|
|
301
77
|
* @info Supports both normal middleware and inline middleware implementations.
|
|
302
|
-
* @info Pass second argument to map the input.
|
|
303
78
|
* @note The current context must be satisfy middleware dependent-context
|
|
304
79
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
305
80
|
*/
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
313
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
314
|
-
*/
|
|
315
|
-
'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>): ProcedureBuilderWithInputOutput<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
316
|
-
/**
|
|
317
|
-
* Sets or updates the metadata.
|
|
318
|
-
* The provided metadata is spared-merged with any existing metadata.
|
|
319
|
-
*
|
|
320
|
-
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
321
|
-
*/
|
|
322
|
-
'meta'(meta: TMeta): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
323
|
-
/**
|
|
324
|
-
* Sets or updates the route definition.
|
|
325
|
-
* The provided route is spared-merged with any existing route.
|
|
326
|
-
* This option is typically relevant when integrating with OpenAPI.
|
|
327
|
-
*
|
|
328
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
329
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
330
|
-
*/
|
|
331
|
-
'route'(route: Route): ProcedureBuilderWithInputOutput<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
81
|
+
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>>(middleware: Middleware<TCurrentContext, UOutContext, unknown, unknown, TMeta>): ProcedureBuilder<TInitialContext, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TMeta, TGateName>;
|
|
82
|
+
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, unknown, unknown, TMeta>): ProcedureBuilder<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TMeta, TGateName>;
|
|
83
|
+
useAuth<const TAuthType extends AuthType & {}, TAuthContext extends ValidatedAuthContext = false>(type: TAuthType, ...rest: OptionalIfEmpty<AuthConfig<TAuthType, TAuthContext>>): ProcedureBuilder<TInitialContext, BuildContextWithAuth<TCurrentContext, TAuthContext>, TSchemas, TMeta, TGateName>;
|
|
84
|
+
useGating<const TInferredGateName extends string>(gates: TInferredGateName[], isGateEnabled: (gate: TInferredGateName, ctx: TCurrentContext) => boolean): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, Context, TCurrentContext>, MergedCurrentContext<TCurrentContext, {
|
|
85
|
+
isGateEnabled: typeof isGateEnabled;
|
|
86
|
+
}>, TSchemas, TMeta, TInferredGateName>;
|
|
332
87
|
/**
|
|
333
88
|
* Defines the handler of the procedure.
|
|
334
89
|
*
|
|
335
90
|
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
336
91
|
*/
|
|
337
|
-
|
|
92
|
+
handler(handler: ProcedureHandler<TCurrentContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TSchemas, TMeta>;
|
|
338
93
|
}
|
|
339
|
-
|
|
340
|
-
/**
|
|
341
|
-
* This property holds the defined options.
|
|
342
|
-
*/
|
|
343
|
-
'~orpc': EnhanceRouterOptions<TErrorMap>;
|
|
344
|
-
/**
|
|
345
|
-
* Adds type-safe custom errors.
|
|
346
|
-
* The provided errors are spared-merged with any existing errors.
|
|
347
|
-
*
|
|
348
|
-
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
349
|
-
*/
|
|
350
|
-
'errors'<U extends ErrorMap>(errors: U): RouterBuilder<TInitialContext, TCurrentContext, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
351
|
-
/**
|
|
352
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
353
|
-
*
|
|
354
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
355
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
356
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
357
|
-
*/
|
|
358
|
-
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): RouterBuilder<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TErrorMap, TMeta>;
|
|
94
|
+
declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TMeta extends Meta, TGateName extends string> extends ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TMeta, TGateName> {
|
|
359
95
|
/**
|
|
360
96
|
* Prefixes all procedures in the router.
|
|
361
97
|
* The provided prefix is post-appended to any existing router prefix.
|
|
@@ -364,306 +100,90 @@ interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends
|
|
|
364
100
|
*
|
|
365
101
|
* @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
366
102
|
*/
|
|
367
|
-
|
|
103
|
+
prefix(prefix: HTTPPath): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TSchemas, TMeta, TGateName>;
|
|
368
104
|
/**
|
|
369
105
|
* Adds tags to all procedures in the router.
|
|
370
106
|
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
371
107
|
*
|
|
372
108
|
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
373
109
|
*/
|
|
374
|
-
|
|
110
|
+
tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TMeta>;
|
|
375
111
|
/**
|
|
376
112
|
* Applies all of the previously defined options to the specified router.
|
|
377
113
|
*
|
|
378
114
|
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
379
115
|
*/
|
|
380
|
-
|
|
116
|
+
router<U extends Router<TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext>;
|
|
117
|
+
}
|
|
118
|
+
interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TMeta extends Meta> extends Pick<BuilderWithMiddlewares<TInitialContext, TCurrentContext, any, TMeta, any>, 'prefix' | 'tag' | 'router'> {
|
|
381
119
|
/**
|
|
382
|
-
*
|
|
383
|
-
* And applies all of the previously defined options to the specified router.
|
|
384
|
-
*
|
|
385
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
120
|
+
* This property holds the defined options.
|
|
386
121
|
*/
|
|
387
|
-
'
|
|
388
|
-
default: U;
|
|
389
|
-
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, TErrorMap>;
|
|
122
|
+
'~orpc': EnhanceRouterOptions;
|
|
390
123
|
}
|
|
391
124
|
|
|
392
|
-
interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput,
|
|
125
|
+
interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TMeta extends Meta> extends Middleware<TInContext, TOutContext, TInput, TOutput, TMeta> {
|
|
393
126
|
/**
|
|
394
127
|
* Change the expected input type by providing a map function.
|
|
395
128
|
*/
|
|
396
|
-
mapInput<UInput>(map: MapInputMiddleware<UInput, TInput>): DecoratedMiddleware<TInContext, TOutContext, UInput, TOutput,
|
|
397
|
-
/**
|
|
398
|
-
* Concatenates two middlewares.
|
|
399
|
-
*
|
|
400
|
-
* @info Pass second argument to map the input.
|
|
401
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware#concatenation Middleware Concatenation Docs}
|
|
402
|
-
*/
|
|
403
|
-
concat<UOutContext extends IntersectPick<MergedCurrentContext<TInContext, TOutContext>, UOutContext>, UInput extends TInput, UInContext extends Context = MergedCurrentContext<TInContext, TOutContext>>(middleware: Middleware<UInContext | MergedCurrentContext<TInContext, TOutContext>, UOutContext, UInput, TOutput, TErrorConstructorMap, TMeta>): DecoratedMiddleware<MergedInitialContext<TInContext, UInContext, MergedCurrentContext<TInContext, TOutContext>>, MergedCurrentContext<TOutContext, UOutContext>, UInput, TOutput, TErrorConstructorMap, TMeta>;
|
|
404
|
-
/**
|
|
405
|
-
* Concatenates two middlewares.
|
|
406
|
-
*
|
|
407
|
-
* @info Pass second argument to map the input.
|
|
408
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware#concatenation Middleware Concatenation Docs}
|
|
409
|
-
*/
|
|
410
|
-
concat<UOutContext extends IntersectPick<MergedCurrentContext<TInContext, TOutContext>, UOutContext>, UInput extends TInput, UMappedInput, UInContext extends Context = MergedCurrentContext<TInContext, TOutContext>>(middleware: Middleware<UInContext | MergedCurrentContext<TInContext, TOutContext>, UOutContext, UMappedInput, TOutput, TErrorConstructorMap, TMeta>, mapInput: MapInputMiddleware<UInput, UMappedInput>): DecoratedMiddleware<MergedInitialContext<TInContext, UInContext, MergedCurrentContext<TInContext, TOutContext>>, MergedCurrentContext<TOutContext, UOutContext>, UInput, TOutput, TErrorConstructorMap, TMeta>;
|
|
129
|
+
mapInput<UInput>(map: MapInputMiddleware<UInput, TInput>): DecoratedMiddleware<TInContext, TOutContext, UInput, TOutput, TMeta>;
|
|
411
130
|
}
|
|
412
|
-
declare function decorateMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput,
|
|
131
|
+
declare function decorateMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TMeta extends Meta>(middleware: Middleware<TInContext, TOutContext, TInput, TOutput, TMeta>): DecoratedMiddleware<TInContext, TOutContext, TInput, TOutput, TMeta>;
|
|
413
132
|
|
|
414
|
-
interface BuilderDef<
|
|
415
|
-
middlewares: readonly AnyMiddleware[];
|
|
416
|
-
inputValidationIndex: number;
|
|
417
|
-
outputValidationIndex: number;
|
|
133
|
+
interface BuilderDef<TSchemas extends Schemas, TMeta extends Meta> extends ContractDef<TSchemas, TMeta>, EnhanceRouterOptions {
|
|
418
134
|
}
|
|
419
|
-
declare class Builder<TInitialContext extends Context, TCurrentContext extends Context,
|
|
420
|
-
/**
|
|
421
|
-
* This property holds the defined options.
|
|
422
|
-
*/
|
|
423
|
-
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
424
|
-
constructor(def: BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>);
|
|
135
|
+
declare class Builder<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TMeta extends Meta, TGateName extends string> extends BuilderWithMiddlewares<TInitialContext, TCurrentContext, TSchemas, TMeta, TGateName> {
|
|
425
136
|
/**
|
|
426
137
|
* Set or override the initial context.
|
|
427
138
|
*
|
|
428
139
|
* @see {@link https://orpc.unnoq.com/docs/context Context Docs}
|
|
429
140
|
*/
|
|
430
|
-
$context<U extends Context>(): Builder<U
|
|
141
|
+
$context<U extends Context>(): Builder<U, U, TSchemas, TMeta, TGateName>;
|
|
431
142
|
/**
|
|
432
143
|
* Creates a middleware.
|
|
433
144
|
*
|
|
434
145
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
435
146
|
*/
|
|
436
147
|
middleware<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
|
437
|
-
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput,
|
|
438
|
-
/**
|
|
439
|
-
* Adds type-safe custom errors.
|
|
440
|
-
* The provided errors are spared-merged with any existing errors.
|
|
441
|
-
*
|
|
442
|
-
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
443
|
-
*/
|
|
444
|
-
errors<U extends ErrorMap>(errors: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta, TGateName>;
|
|
445
|
-
/**
|
|
446
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
447
|
-
*
|
|
448
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
449
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
450
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
451
|
-
*/
|
|
452
|
-
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
453
|
-
useGating<const TInferredGateName extends string>(gates: TInferredGateName[], isGateEnabled: (gate: TInferredGateName, ctx: TCurrentContext) => boolean): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, Context, TCurrentContext>, MergedCurrentContext<TCurrentContext, {
|
|
454
|
-
isGateEnabled: typeof isGateEnabled;
|
|
455
|
-
}>, TInputSchema, TOutputSchema, TErrorMap, TMeta, TInferredGateName>;
|
|
456
|
-
/**
|
|
457
|
-
* Sets or updates the metadata.
|
|
458
|
-
* The provided metadata is spared-merged with any existing metadata.
|
|
459
|
-
*
|
|
460
|
-
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
461
|
-
*/
|
|
462
|
-
meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
463
|
-
/**
|
|
464
|
-
* Sets or updates the route definition.
|
|
465
|
-
* The provided route is spared-merged with any existing route.
|
|
466
|
-
* This option is typically relevant when integrating with OpenAPI.
|
|
467
|
-
*
|
|
468
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
469
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
470
|
-
*/
|
|
471
|
-
route(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
472
|
-
/**
|
|
473
|
-
* Defines the input validation schema.
|
|
474
|
-
*
|
|
475
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
|
|
476
|
-
*/
|
|
477
|
-
input<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
478
|
-
/**
|
|
479
|
-
* Defines the output validation schema.
|
|
480
|
-
*
|
|
481
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
|
|
482
|
-
*/
|
|
483
|
-
output<USchema extends AnySchema>(schema: USchema): ProcedureBuilderWithOutput<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta, TGateName>;
|
|
484
|
-
/**
|
|
485
|
-
* Defines the handler of the procedure.
|
|
486
|
-
*
|
|
487
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
488
|
-
*/
|
|
489
|
-
handler<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
|
490
|
-
/**
|
|
491
|
-
* Prefixes all procedures in the router.
|
|
492
|
-
* The provided prefix is post-appended to any existing router prefix.
|
|
493
|
-
*
|
|
494
|
-
* @note This option does not affect procedures that do not define a path in their route definition.
|
|
495
|
-
*
|
|
496
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
497
|
-
*/
|
|
498
|
-
prefix(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
|
499
|
-
/**
|
|
500
|
-
* Adds tags to all procedures in the router.
|
|
501
|
-
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
502
|
-
*
|
|
503
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
504
|
-
*/
|
|
505
|
-
tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
|
506
|
-
/**
|
|
507
|
-
* Applies all of the previously defined options to the specified router.
|
|
508
|
-
*
|
|
509
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
510
|
-
*/
|
|
511
|
-
router<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>;
|
|
512
|
-
/**
|
|
513
|
-
* Create a lazy router
|
|
514
|
-
* And applies all of the previously defined options to the specified router.
|
|
515
|
-
*
|
|
516
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
517
|
-
*/
|
|
518
|
-
lazyRoute<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(loader: () => Promise<{
|
|
519
|
-
default: U;
|
|
520
|
-
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, TErrorMap>;
|
|
148
|
+
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, TMeta>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, TMeta>;
|
|
521
149
|
}
|
|
522
|
-
type ApiBuilder<TMeta extends Meta> = Builder<
|
|
150
|
+
type ApiBuilder<TMeta extends Meta> = Builder<{}, {}, InitialSchemas, TMeta, never>;
|
|
523
151
|
interface ApiBuilderOpts<TMeta extends Meta> {
|
|
524
152
|
meta?: TMeta;
|
|
525
153
|
}
|
|
526
154
|
declare function createApiBuilder<TMeta extends Meta = Record<never, never>>(opts?: ApiBuilderOpts<TMeta>): ApiBuilder<TMeta>;
|
|
527
155
|
declare const os: ApiBuilder<Record<never, never>>;
|
|
528
156
|
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
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> {
|
|
157
|
+
interface ValidationErrorOptions extends ErrorOptions {
|
|
158
|
+
message: string;
|
|
159
|
+
issues: readonly SchemaIssue[];
|
|
533
160
|
/**
|
|
534
|
-
*
|
|
535
|
-
*
|
|
536
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
537
|
-
* @info Pass second argument to map the input.
|
|
538
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
539
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
161
|
+
* @todo require this field in v2
|
|
540
162
|
*/
|
|
541
|
-
|
|
542
|
-
/**
|
|
543
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
544
|
-
*
|
|
545
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
546
|
-
* @info Pass second argument to map the input.
|
|
547
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
548
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
549
|
-
*/
|
|
550
|
-
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>): ImplementedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
551
|
-
/**
|
|
552
|
-
* Make this procedure callable (works like a function while still being a procedure).
|
|
553
|
-
*
|
|
554
|
-
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
555
|
-
*/
|
|
556
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
163
|
+
data?: unknown;
|
|
557
164
|
}
|
|
558
165
|
/**
|
|
559
|
-
*
|
|
166
|
+
* This errors usually used for ORPCError.cause when the error is a validation error.
|
|
167
|
+
*
|
|
168
|
+
* @see {@link https://orpc.unnoq.com/docs/advanced/validation-errors Validation Errors Docs}
|
|
560
169
|
*/
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
*
|
|
566
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
567
|
-
* @info Pass second argument to map the input.
|
|
568
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
569
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
570
|
-
*/
|
|
571
|
-
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
572
|
-
/**
|
|
573
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
574
|
-
*
|
|
575
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
576
|
-
* @info Pass second argument to map the input.
|
|
577
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
578
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
579
|
-
*/
|
|
580
|
-
'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>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
581
|
-
/**
|
|
582
|
-
* Defines the handler of the procedure.
|
|
583
|
-
*
|
|
584
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
585
|
-
*/
|
|
586
|
-
'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
587
|
-
}
|
|
588
|
-
|
|
589
|
-
interface RouterImplementerWithMiddlewares<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
|
590
|
-
/**
|
|
591
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
592
|
-
*
|
|
593
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
594
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
595
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
596
|
-
*/
|
|
597
|
-
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): ImplementerInternalWithMiddlewares<T, MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>>;
|
|
598
|
-
/**
|
|
599
|
-
* Applies all of the previously defined options to the specified router.
|
|
600
|
-
* And enforces the router match the contract.
|
|
601
|
-
*
|
|
602
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
603
|
-
*/
|
|
604
|
-
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
605
|
-
/**
|
|
606
|
-
* Create a lazy router
|
|
607
|
-
* And applies all of the previously defined options to the specified router.
|
|
608
|
-
* And enforces the router match the contract.
|
|
609
|
-
*
|
|
610
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
611
|
-
*/
|
|
612
|
-
lazyRoute<U extends Router<T, TInitialContext>>(loader: () => Promise<{
|
|
613
|
-
default: U;
|
|
614
|
-
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
170
|
+
declare class ValidationError extends Error {
|
|
171
|
+
readonly issues: readonly SchemaIssue[];
|
|
172
|
+
readonly data: unknown;
|
|
173
|
+
constructor(options: ValidationErrorOptions);
|
|
615
174
|
}
|
|
616
|
-
type ImplementerInternalWithMiddlewares<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? ProcedureImplementer<TInitialContext, TCurrentContext, UInputSchema, UOutputSchema, UErrorMap, UMeta> : RouterImplementerWithMiddlewares<TContract, TInitialContext, TCurrentContext> & {
|
|
617
|
-
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternalWithMiddlewares<TContract[K], TInitialContext, TCurrentContext> : never;
|
|
618
|
-
};
|
|
619
175
|
|
|
620
|
-
interface
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
*
|
|
624
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
625
|
-
*/
|
|
626
|
-
middleware<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
|
627
|
-
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, InferContractRouterMeta<T>>;
|
|
628
|
-
/**
|
|
629
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
630
|
-
*
|
|
631
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
632
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
633
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
634
|
-
*/
|
|
635
|
-
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): ImplementerInternalWithMiddlewares<T, MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>>;
|
|
636
|
-
/**
|
|
637
|
-
* Applies all of the previously defined options to the specified router.
|
|
638
|
-
* And enforces the router match the contract.
|
|
639
|
-
*
|
|
640
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
641
|
-
*/
|
|
642
|
-
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
643
|
-
/**
|
|
644
|
-
* Create a lazy router
|
|
645
|
-
* And applies all of the previously defined options to the specified router.
|
|
646
|
-
* And enforces the router match the contract.
|
|
647
|
-
*
|
|
648
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
649
|
-
*/
|
|
650
|
-
lazyRoute<U extends Router<T, TCurrentContext>>(loader: () => Promise<{
|
|
651
|
-
default: U;
|
|
652
|
-
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
176
|
+
interface EventIteratorSchemaDetails {
|
|
177
|
+
yields: AnySchema;
|
|
178
|
+
returns?: AnySchema;
|
|
653
179
|
}
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
*
|
|
662
|
-
* @see {@link https://orpc.unnoq.com/docs/context Context Docs}
|
|
663
|
-
*/
|
|
664
|
-
$context<U extends Context>(): Implementer<TContract, U & Record<never, never>, U>;
|
|
665
|
-
} & ImplementerInternal<TContract, TInitialContext, TCurrentContext>;
|
|
666
|
-
declare function implement<T extends AnyContractRouter, TContext extends Context = Record<never, never>>(contract: T): Implementer<T, TContext, TContext>;
|
|
180
|
+
/**
|
|
181
|
+
* Define schema for an event iterator.
|
|
182
|
+
*
|
|
183
|
+
* @see {@link https://orpc.unnoq.com/docs/event-iterator#validate-event-iterator Validate Event Iterator Docs}
|
|
184
|
+
*/
|
|
185
|
+
declare function eventIterator<TYieldIn, TYieldOut, TReturnIn = unknown, TReturnOut = unknown>(yields: Schema<TYieldIn, TYieldOut>, returns?: Schema<TReturnIn, TReturnOut>): Schema<AsyncIteratorObject<TYieldIn, TReturnIn, void>, AsyncIteratorClass<TYieldOut, TReturnOut, void>>;
|
|
186
|
+
declare function getEventIteratorSchemaDetails(schema: AnySchema | undefined): undefined | EventIteratorSchemaDetails;
|
|
667
187
|
|
|
668
188
|
declare function isStartWithMiddlewares(middlewares: readonly AnyMiddleware[], compare: readonly AnyMiddleware[]): boolean;
|
|
669
189
|
declare function mergeMiddlewares(first: readonly AnyMiddleware[], second: readonly AnyMiddleware[], options: {
|
|
@@ -672,10 +192,6 @@ declare function mergeMiddlewares(first: readonly AnyMiddleware[], second: reado
|
|
|
672
192
|
declare function addMiddleware(middlewares: readonly AnyMiddleware[], addition: AnyMiddleware): AnyMiddleware[];
|
|
673
193
|
|
|
674
194
|
declare function createAssertedLazyProcedure(lazied: Lazy<any>): Lazy<AnyProcedure>;
|
|
675
|
-
/**
|
|
676
|
-
* Create a new procedure that ensure the contract is applied to the procedure.
|
|
677
|
-
*/
|
|
678
|
-
declare function createContractedProcedure(procedure: AnyProcedure, contract: AnyContractProcedure): AnyProcedure;
|
|
679
195
|
/**
|
|
680
196
|
* Directly call a procedure without creating a client.
|
|
681
197
|
*
|
|
@@ -686,9 +202,9 @@ declare function createContractedProcedure(procedure: AnyProcedure, contract: An
|
|
|
686
202
|
* ```
|
|
687
203
|
*
|
|
688
204
|
*/
|
|
689
|
-
declare function call<TInitialContext extends Context,
|
|
205
|
+
declare function call<TInitialContext extends Context, TSchemas extends Schemas, TMeta extends Meta>(procedure: Lazyable<Procedure<TInitialContext, any, TSchemas, TMeta>>, input: InferProcedureClientInputs<TSchemas>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, {}> & Omit<ClientOptions<{}>, 'context'>>): Promise<InferSchemaOutput<TSchemas['outputSchema']>>;
|
|
690
206
|
|
|
691
|
-
type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext =
|
|
207
|
+
type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = {}> = TRouter extends Procedure<any, any, infer USchemas, any> ? ProcedureClient<TClientContext, USchemas> : {
|
|
692
208
|
[K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
|
|
693
209
|
};
|
|
694
210
|
/**
|
|
@@ -696,10 +212,31 @@ type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContex
|
|
|
696
212
|
*
|
|
697
213
|
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
698
214
|
*/
|
|
699
|
-
declare function createRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>,
|
|
215
|
+
declare function createRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>, TClientContext>>): RouterClient<T, TClientContext>;
|
|
700
216
|
|
|
701
|
-
declare function
|
|
702
|
-
|
|
217
|
+
declare function isSchemaIssue(issue: unknown): issue is SchemaIssue;
|
|
218
|
+
|
|
219
|
+
type HTTPEndpoint = `${HTTPMethod} ${HTTPPath}`;
|
|
220
|
+
declare const endpointRegex: RegExp;
|
|
221
|
+
/**
|
|
222
|
+
* @internal
|
|
223
|
+
*/
|
|
224
|
+
declare function standardizeHTTPPath(path: HTTPPath): HTTPPath;
|
|
225
|
+
/**
|
|
226
|
+
* @internal
|
|
227
|
+
*/
|
|
228
|
+
declare function getDynamicParams(path: HTTPPath | undefined): {
|
|
229
|
+
raw: string;
|
|
230
|
+
name: string;
|
|
231
|
+
}[] | undefined;
|
|
232
|
+
/**
|
|
233
|
+
* @internal
|
|
234
|
+
*/
|
|
235
|
+
declare function parseEndpointDefinition(stringsOrEndpoint: TemplateStringsArray | HTTPEndpoint, values: AnyShape[] | [AnySchema | AnyShape] | []): {
|
|
236
|
+
method: HTTPMethod;
|
|
237
|
+
path: HTTPPath;
|
|
238
|
+
pathSchema: AnySchema;
|
|
239
|
+
};
|
|
703
240
|
|
|
704
|
-
export { AnyMiddleware, AnyProcedure, AnyRouter, Builder, Context,
|
|
705
|
-
export type {
|
|
241
|
+
export { AnyMiddleware, AnyProcedure, AnyRouter, AnySchema, AnyShape, BuildContextWithAuth, Builder, BuilderWithMiddlewares, Context, Contract, ContractDef, DecoratedProcedure, EnhanceRouterOptions, EnhancedRouter, InferHandlerInputs, InferProcedureClientInputs, InferRouterInitialContext, InferSchemaInput, InferSchemaOutput, InitialSchemas, Lazy, Lazyable, MapInputMiddleware, MergedCurrentContext, MergedInitialContext, MergedSchemas, Meta, Middleware, Procedure, ProcedureBuilder, ProcedureHandler, Router, Schema, SchemaIssue, Schemas, UnionToIntersection, ValidationError, WrapShape, addMiddleware, call, createApiBuilder, createAssertedLazyProcedure, createProcedureClient, createRouterClient, decorateMiddleware, endpointRegex, eventIterator, getDynamicParams, getEventIteratorSchemaDetails, isSchemaIssue, isStartWithMiddlewares, mergeMiddlewares, os, parseEndpointDefinition, standardizeHTTPPath };
|
|
242
|
+
export type { ApiBuilder, BuilderDef, CreateProcedureClientOptions, DecoratedMiddleware, EventIteratorSchemaDetails, HTTPEndpoint, ProcedureClient, RouterBuilder, RouterClient, ValidationErrorOptions };
|