@temporary-name/server 1.9.3-alpha.e09726e1bf5340c7b7052eeabcb4935b3c85ce93 → 1.9.3-alpha.e2d8d164da72fb570c2b14a4fa956c80f9e33cdc
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/aws-lambda/index.d.mts +3 -3
- package/dist/adapters/aws-lambda/index.d.ts +3 -3
- package/dist/adapters/aws-lambda/index.mjs +4 -6
- package/dist/adapters/fetch/index.d.mts +3 -3
- package/dist/adapters/fetch/index.d.ts +3 -3
- package/dist/adapters/fetch/index.mjs +4 -6
- package/dist/adapters/node/index.d.mts +3 -3
- package/dist/adapters/node/index.d.ts +3 -3
- package/dist/adapters/node/index.mjs +4 -6
- package/dist/adapters/standard/index.d.mts +14 -30
- package/dist/adapters/standard/index.d.ts +14 -30
- package/dist/adapters/standard/index.mjs +4 -6
- package/dist/index.d.mts +41 -282
- package/dist/index.d.ts +41 -282
- package/dist/index.mjs +102 -155
- package/dist/openapi/index.mjs +27 -61
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/index.d.ts +2 -2
- package/dist/shared/{server.BeuTpcmO.d.mts → server.B93y_8tj.d.mts} +2 -2
- package/dist/shared/{server.BKh8I1Ny.mjs → server.BYYf0Wn6.mjs} +36 -73
- package/dist/shared/{server.BKSOrA6h.d.mts → server.C3RuMHWl.d.mts} +30 -30
- package/dist/shared/{server.BKSOrA6h.d.ts → server.C3RuMHWl.d.ts} +30 -30
- package/dist/shared/{server.CQyYNJ1H.d.ts → server.CT1xhSmE.d.mts} +1 -2
- package/dist/shared/{server.DLsti1Pv.mjs → server.CqTex_jI.mjs} +57 -85
- package/dist/shared/{server.SLLuK6_v.d.ts → server.D_fags8X.d.ts} +2 -2
- package/dist/shared/{server.BEHw7Eyx.mjs → server.Kxw442A9.mjs} +1 -1
- package/dist/shared/{server.C1fnTLq0.d.mts → server.cjcgLdr1.d.ts} +1 -2
- package/package.json +10 -9
package/dist/index.d.mts
CHANGED
|
@@ -1,53 +1,13 @@
|
|
|
1
|
-
import { AnySchema, ErrorMap, Meta,
|
|
2
|
-
export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput,
|
|
3
|
-
import {
|
|
1
|
+
import { AnySchema, ErrorMap, Meta, EnhanceRouteOptions, MergedErrorMap, AnyContractRouter, AnyContractProcedure, ContractProcedure, Route, InferSchemaOutput, InferSchemaInput, ContractRouter, ContractProcedureDef, Schema, InferContractRouterErrorMap, InferContractRouterMeta, ErrorFromErrorMap } 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
|
-
import {
|
|
6
|
-
|
|
5
|
+
import { SchemaClass } from '@temporary-name/zod';
|
|
6
|
+
import { C as Context, P as Procedure, a as CreateProcedureClientOptions, b as ProcedureClient, A as AnyMiddleware, L as Lazyable, c as AnyRouter, d as Lazy, e as AnyProcedure, M as MergedInitialContext, f as Middleware, O as ORPCErrorConstructorMap, g as MergedCurrentContext, h as ProcedureHandler, R as Router, i as MapInputMiddleware, I as InferRouterInitialContext } from './shared/server.C3RuMHWl.mjs';
|
|
7
|
+
export { H as InferRouterCurrentContexts, G as InferRouterInitialContexts, J as InferRouterInputs, K as InferRouterOutputs, n as LAZY_SYMBOL, o as LazyMeta, v as MiddlewareNextFn, t as MiddlewareNextFnOptions, x as MiddlewareOptions, w as MiddlewareOutputFn, s as MiddlewareResult, k as ORPCErrorConstructorMapItem, j as ORPCErrorConstructorMapItemOptions, E as ProcedureClientInterceptorOptions, B as ProcedureDef, z as ProcedureHandlerOptions, l as createORPCErrorConstructorMap, F as createProcedureClient, r as getLazyMeta, q as isLazy, D as isProcedure, p as lazy, m as mergeCurrentContext, y as middlewareOutputFn, u as unlazy } from './shared/server.C3RuMHWl.mjs';
|
|
7
8
|
export { getEventMeta, withEventMeta } from '@temporary-name/standard-server';
|
|
8
9
|
|
|
9
10
|
declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
|
10
|
-
/**
|
|
11
|
-
* Adds type-safe custom errors.
|
|
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
11
|
/**
|
|
52
12
|
* Make this procedure callable (works like a function while still being a procedure).
|
|
53
13
|
*
|
|
@@ -93,104 +53,48 @@ type UnlaziedRouter<T extends AnyRouter> = T extends AnyProcedure ? T : {
|
|
|
93
53
|
};
|
|
94
54
|
declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedRouter<T>>;
|
|
95
55
|
|
|
96
|
-
|
|
56
|
+
declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
|
57
|
+
z: SchemaClass;
|
|
97
58
|
/**
|
|
98
59
|
* This property holds the defined options.
|
|
99
60
|
*/
|
|
100
|
-
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta
|
|
61
|
+
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
62
|
+
constructor(def: BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>);
|
|
101
63
|
/**
|
|
102
|
-
* Adds type-safe custom errors.
|
|
103
|
-
* The provided errors are spared-merged with any existing errors.
|
|
64
|
+
* Adds type-safe custom errors to the contract.
|
|
65
|
+
* The provided errors are spared-merged with any existing errors in the contract.
|
|
104
66
|
*
|
|
105
67
|
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
106
68
|
*/
|
|
107
|
-
|
|
69
|
+
errors<U extends ErrorMap>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta, TGateName>;
|
|
108
70
|
/**
|
|
109
|
-
*
|
|
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.
|
|
71
|
+
* Sets or updates the metadata for the contract.
|
|
72
|
+
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
119
73
|
*
|
|
120
74
|
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
121
75
|
*/
|
|
122
|
-
|
|
76
|
+
meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
123
77
|
/**
|
|
124
|
-
* Sets or updates the route definition.
|
|
125
|
-
* The provided route is spared-merged with any existing route.
|
|
78
|
+
* Sets or updates the route definition for the contract.
|
|
79
|
+
* The provided route is spared-merged with any existing route in the contract.
|
|
126
80
|
* This option is typically relevant when integrating with OpenAPI.
|
|
127
81
|
*
|
|
128
82
|
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
129
83
|
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
130
84
|
*/
|
|
131
|
-
|
|
85
|
+
route(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
132
86
|
/**
|
|
133
87
|
* Defines the input validation schema.
|
|
134
88
|
*
|
|
135
89
|
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
|
|
136
90
|
*/
|
|
137
|
-
|
|
91
|
+
input<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
138
92
|
/**
|
|
139
93
|
* Defines the output validation schema.
|
|
140
94
|
*
|
|
141
95
|
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
|
|
142
96
|
*/
|
|
143
|
-
|
|
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>;
|
|
166
|
-
/**
|
|
167
|
-
* Applies all of the previously defined options to the specified router.
|
|
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.
|
|
175
|
-
*
|
|
176
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
177
|
-
*/
|
|
178
|
-
'lazyRoute'<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(loader: () => Promise<{
|
|
179
|
-
default: U;
|
|
180
|
-
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, TErrorMap>;
|
|
181
|
-
}
|
|
182
|
-
interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> {
|
|
183
|
-
/**
|
|
184
|
-
* This property holds the defined options.
|
|
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>;
|
|
97
|
+
output<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta, TGateName>;
|
|
194
98
|
/**
|
|
195
99
|
* Uses a middleware to modify the context or improve the pipeline.
|
|
196
100
|
*
|
|
@@ -198,62 +102,18 @@ interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext exte
|
|
|
198
102
|
* @note The current context must be satisfy middleware dependent-context
|
|
199
103
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
200
104
|
*/
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
*
|
|
206
|
-
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
207
|
-
*/
|
|
208
|
-
'meta'(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
209
|
-
/**
|
|
210
|
-
* Sets or updates the route definition.
|
|
211
|
-
* The provided route is spared-merged with any existing route.
|
|
212
|
-
* This option is typically relevant when integrating with OpenAPI.
|
|
213
|
-
*
|
|
214
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
215
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
216
|
-
*/
|
|
217
|
-
'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
218
|
-
/**
|
|
219
|
-
* Defines the input validation schema.
|
|
220
|
-
*
|
|
221
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
|
|
222
|
-
*/
|
|
223
|
-
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
224
|
-
/**
|
|
225
|
-
* Defines the output validation schema.
|
|
226
|
-
*
|
|
227
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
|
|
228
|
-
*/
|
|
229
|
-
'output'<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta, TGateName>;
|
|
105
|
+
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>;
|
|
106
|
+
useGating<const TInferredGateName extends string>(gates: TInferredGateName[], isGateEnabled: (gate: TInferredGateName, ctx: TCurrentContext) => boolean): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, Context, TCurrentContext>, MergedCurrentContext<TCurrentContext, {
|
|
107
|
+
isGateEnabled: typeof isGateEnabled;
|
|
108
|
+
}>, TInputSchema, TOutputSchema, TErrorMap, TMeta, TInferredGateName>;
|
|
230
109
|
/**
|
|
231
110
|
* Defines the handler of the procedure.
|
|
232
111
|
*
|
|
233
112
|
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
234
113
|
*/
|
|
235
|
-
|
|
114
|
+
handler(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
236
115
|
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* This property holds the defined options.
|
|
240
|
-
*/
|
|
241
|
-
'~orpc': EnhanceRouterOptions<TErrorMap>;
|
|
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): RouterBuilder<TInitialContext, TCurrentContext, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
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, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): RouterBuilder<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TErrorMap, TMeta>;
|
|
116
|
+
declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> extends ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName> {
|
|
257
117
|
/**
|
|
258
118
|
* Prefixes all procedures in the router.
|
|
259
119
|
* The provided prefix is post-appended to any existing router prefix.
|
|
@@ -262,29 +122,26 @@ interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends
|
|
|
262
122
|
*
|
|
263
123
|
* @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
264
124
|
*/
|
|
265
|
-
|
|
125
|
+
prefix(prefix: HTTPPath): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
266
126
|
/**
|
|
267
127
|
* Adds tags to all procedures in the router.
|
|
268
128
|
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
269
129
|
*
|
|
270
130
|
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
271
131
|
*/
|
|
272
|
-
|
|
132
|
+
tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
|
273
133
|
/**
|
|
274
134
|
* Applies all of the previously defined options to the specified router.
|
|
275
135
|
*
|
|
276
136
|
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
277
137
|
*/
|
|
278
|
-
|
|
138
|
+
router<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>;
|
|
139
|
+
}
|
|
140
|
+
interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> extends Pick<BuilderWithMiddlewares<TInitialContext, TCurrentContext, any, any, TErrorMap, TMeta, any>, 'prefix' | 'tag' | 'router'> {
|
|
279
141
|
/**
|
|
280
|
-
*
|
|
281
|
-
* And applies all of the previously defined options to the specified router.
|
|
282
|
-
*
|
|
283
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
142
|
+
* This property holds the defined options.
|
|
284
143
|
*/
|
|
285
|
-
'
|
|
286
|
-
default: U;
|
|
287
|
-
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, TErrorMap>;
|
|
144
|
+
'~orpc': EnhanceRouterOptions<TErrorMap>;
|
|
288
145
|
}
|
|
289
146
|
|
|
290
147
|
interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> extends Middleware<TInContext, TOutContext, TInput, TOutput, TErrorConstructorMap, TMeta> {
|
|
@@ -309,23 +166,18 @@ interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Co
|
|
|
309
166
|
}
|
|
310
167
|
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>;
|
|
311
168
|
|
|
312
|
-
interface BuilderDef<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta
|
|
169
|
+
interface BuilderDef<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>, EnhanceRouterOptions<TErrorMap> {
|
|
313
170
|
middlewares: readonly AnyMiddleware[];
|
|
314
171
|
inputValidationIndex: number;
|
|
315
172
|
outputValidationIndex: number;
|
|
316
173
|
}
|
|
317
|
-
declare class Builder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> {
|
|
318
|
-
/**
|
|
319
|
-
* This property holds the defined options.
|
|
320
|
-
*/
|
|
321
|
-
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
322
|
-
constructor(def: BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>);
|
|
174
|
+
declare class Builder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> extends BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName> {
|
|
323
175
|
/**
|
|
324
176
|
* Set or override the initial context.
|
|
325
177
|
*
|
|
326
178
|
* @see {@link https://orpc.unnoq.com/docs/context Context Docs}
|
|
327
179
|
*/
|
|
328
|
-
$context<U extends Context>(): Builder<U
|
|
180
|
+
$context<U extends Context>(): Builder<U, U, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
329
181
|
/**
|
|
330
182
|
* Creates a middleware.
|
|
331
183
|
*
|
|
@@ -333,89 +185,6 @@ declare class Builder<TInitialContext extends Context, TCurrentContext extends C
|
|
|
333
185
|
*/
|
|
334
186
|
middleware<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
|
335
187
|
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, TMeta>;
|
|
336
|
-
/**
|
|
337
|
-
* Adds type-safe custom errors.
|
|
338
|
-
* The provided errors are spared-merged with any existing errors.
|
|
339
|
-
*
|
|
340
|
-
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
341
|
-
*/
|
|
342
|
-
errors<U extends ErrorMap>(errors: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta, TGateName>;
|
|
343
|
-
/**
|
|
344
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
345
|
-
*
|
|
346
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
347
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
348
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
349
|
-
*/
|
|
350
|
-
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>;
|
|
351
|
-
useGating<const TInferredGateName extends string>(gates: TInferredGateName[], isGateEnabled: (gate: TInferredGateName, ctx: TCurrentContext) => boolean): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, Context, TCurrentContext>, MergedCurrentContext<TCurrentContext, {
|
|
352
|
-
isGateEnabled: typeof isGateEnabled;
|
|
353
|
-
}>, TInputSchema, TOutputSchema, TErrorMap, TMeta, TInferredGateName>;
|
|
354
|
-
/**
|
|
355
|
-
* Sets or updates the metadata.
|
|
356
|
-
* The provided metadata is spared-merged with any existing metadata.
|
|
357
|
-
*
|
|
358
|
-
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
359
|
-
*/
|
|
360
|
-
meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
361
|
-
/**
|
|
362
|
-
* Sets or updates the route definition.
|
|
363
|
-
* The provided route is spared-merged with any existing route.
|
|
364
|
-
* This option is typically relevant when integrating with OpenAPI.
|
|
365
|
-
*
|
|
366
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
367
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
368
|
-
*/
|
|
369
|
-
route(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
370
|
-
/**
|
|
371
|
-
* Defines the input validation schema.
|
|
372
|
-
*
|
|
373
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
|
|
374
|
-
*/
|
|
375
|
-
input<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
376
|
-
/**
|
|
377
|
-
* Defines the output validation schema.
|
|
378
|
-
*
|
|
379
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
|
|
380
|
-
*/
|
|
381
|
-
output<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta, TGateName>;
|
|
382
|
-
/**
|
|
383
|
-
* Defines the handler of the procedure.
|
|
384
|
-
*
|
|
385
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
386
|
-
*/
|
|
387
|
-
handler<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
|
388
|
-
/**
|
|
389
|
-
* Prefixes all procedures in the router.
|
|
390
|
-
* The provided prefix is post-appended to any existing router prefix.
|
|
391
|
-
*
|
|
392
|
-
* @note This option does not affect procedures that do not define a path in their route definition.
|
|
393
|
-
*
|
|
394
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
395
|
-
*/
|
|
396
|
-
prefix(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
|
397
|
-
/**
|
|
398
|
-
* Adds tags to all procedures in the router.
|
|
399
|
-
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
400
|
-
*
|
|
401
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
402
|
-
*/
|
|
403
|
-
tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
|
404
|
-
/**
|
|
405
|
-
* Applies all of the previously defined options to the specified router.
|
|
406
|
-
*
|
|
407
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
408
|
-
*/
|
|
409
|
-
router<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>;
|
|
410
|
-
/**
|
|
411
|
-
* Create a lazy router
|
|
412
|
-
* And applies all of the previously defined options to the specified router.
|
|
413
|
-
*
|
|
414
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
415
|
-
*/
|
|
416
|
-
lazyRoute<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(loader: () => Promise<{
|
|
417
|
-
default: U;
|
|
418
|
-
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, TErrorMap>;
|
|
419
188
|
}
|
|
420
189
|
type ApiBuilder<TMeta extends Meta> = Builder<Record<never, never>, Record<never, never>, Schema<unknown, unknown>, Schema<unknown, unknown>, Record<never, never>, TMeta, never>;
|
|
421
190
|
interface ApiBuilderOpts<TMeta extends Meta> {
|
|
@@ -457,7 +226,7 @@ interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext
|
|
|
457
226
|
* Like `ProcedureBuilderWithoutHandler`, but removed all method that can change the contract.
|
|
458
227
|
*/
|
|
459
228
|
interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
460
|
-
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta
|
|
229
|
+
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
461
230
|
/**
|
|
462
231
|
* Uses a middleware to modify the context or improve the pipeline.
|
|
463
232
|
*
|
|
@@ -500,16 +269,6 @@ interface RouterImplementerWithMiddlewares<T extends AnyContractRouter, TInitial
|
|
|
500
269
|
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
501
270
|
*/
|
|
502
271
|
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
503
|
-
/**
|
|
504
|
-
* Create a lazy router
|
|
505
|
-
* And applies all of the previously defined options to the specified router.
|
|
506
|
-
* And enforces the router match the contract.
|
|
507
|
-
*
|
|
508
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
509
|
-
*/
|
|
510
|
-
lazyRoute<U extends Router<T, TInitialContext>>(loader: () => Promise<{
|
|
511
|
-
default: U;
|
|
512
|
-
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
513
272
|
}
|
|
514
273
|
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> & {
|
|
515
274
|
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternalWithMiddlewares<TContract[K], TInitialContext, TCurrentContext> : never;
|
|
@@ -559,7 +318,7 @@ type Implementer<TContract extends AnyContractRouter, TInitialContext extends Co
|
|
|
559
318
|
*
|
|
560
319
|
* @see {@link https://orpc.unnoq.com/docs/context Context Docs}
|
|
561
320
|
*/
|
|
562
|
-
$context<U extends Context>(): Implementer<TContract, U
|
|
321
|
+
$context<U extends Context>(): Implementer<TContract, U, U>;
|
|
563
322
|
} & ImplementerInternal<TContract, TInitialContext, TCurrentContext>;
|
|
564
323
|
declare function implement<T extends AnyContractRouter, TContext extends Context = Record<never, never>>(contract: T): Implementer<T, TContext, TContext>;
|
|
565
324
|
|
|
@@ -599,5 +358,5 @@ declare function createRouterClient<T extends AnyRouter, TClientContext extends
|
|
|
599
358
|
declare function setHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: AnyContractRouter): T;
|
|
600
359
|
declare function getHiddenRouterContract(router: Lazyable<AnyRouter | AnyContractRouter>): AnyContractRouter | undefined;
|
|
601
360
|
|
|
602
|
-
export { AnyMiddleware, AnyProcedure, AnyRouter, Builder, Context, CreateProcedureClientOptions, DecoratedProcedure, InferRouterInitialContext, Lazy, Lazyable, MapInputMiddleware, MergedCurrentContext, MergedInitialContext, Middleware, ORPCErrorConstructorMap, Procedure, ProcedureClient, ProcedureHandler, Router, addMiddleware, call, createAccessibleLazyRouter, createApiBuilder, createAssertedLazyProcedure, createContractedProcedure, createRouterClient, decorateMiddleware, enhanceRouter, getHiddenRouterContract, getRouter, implement, implementerInternal, isStartWithMiddlewares, mergeMiddlewares, os, resolveContractProcedures, setHiddenRouterContract, traverseContractProcedures, unlazyRouter };
|
|
603
|
-
export type { AccessibleLazyRouter, ApiBuilder, BuilderDef,
|
|
361
|
+
export { AnyMiddleware, AnyProcedure, AnyRouter, Builder, BuilderWithMiddlewares, Context, CreateProcedureClientOptions, DecoratedProcedure, InferRouterInitialContext, Lazy, Lazyable, MapInputMiddleware, MergedCurrentContext, MergedInitialContext, Middleware, ORPCErrorConstructorMap, Procedure, ProcedureBuilder, ProcedureClient, ProcedureHandler, Router, addMiddleware, call, createAccessibleLazyRouter, createApiBuilder, createAssertedLazyProcedure, createContractedProcedure, createRouterClient, decorateMiddleware, enhanceRouter, getHiddenRouterContract, getRouter, implement, implementerInternal, isStartWithMiddlewares, mergeMiddlewares, os, resolveContractProcedures, setHiddenRouterContract, traverseContractProcedures, unlazyRouter };
|
|
362
|
+
export type { AccessibleLazyRouter, ApiBuilder, BuilderDef, ContractProcedureCallbackOptions, DecoratedMiddleware, EnhanceRouterOptions, EnhancedRouter, ImplementedProcedure, Implementer, ImplementerInternal, ImplementerInternalWithMiddlewares, LazyTraverseContractProceduresOptions, ProcedureImplementer, RouterBuilder, RouterClient, RouterImplementer, RouterImplementerWithMiddlewares, TraverseContractProcedureCallbackOptions, TraverseContractProceduresOptions, UnlaziedRouter };
|