@temporary-name/server 1.9.3-alpha.37dfe6603933b8e445661fe453c4fbdb30ccb524 → 1.9.3-alpha.50b729ba628b987e14f5bd1004e5a04590fd4b4e
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/adapters/aws-lambda/index.d.mts +3 -3
- package/dist/adapters/aws-lambda/index.d.ts +3 -3
- package/dist/adapters/aws-lambda/index.mjs +3 -5
- package/dist/adapters/fetch/index.d.mts +3 -3
- package/dist/adapters/fetch/index.d.ts +3 -3
- package/dist/adapters/fetch/index.mjs +3 -5
- package/dist/adapters/node/index.d.mts +3 -3
- package/dist/adapters/node/index.d.ts +3 -3
- package/dist/adapters/node/index.mjs +3 -5
- package/dist/adapters/standard/index.d.mts +14 -30
- package/dist/adapters/standard/index.d.ts +14 -30
- package/dist/adapters/standard/index.mjs +3 -5
- package/dist/index.d.mts +44 -266
- package/dist/index.d.ts +44 -266
- package/dist/index.mjs +108 -151
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/index.d.ts +2 -2
- package/dist/shared/{server.DLsti1Pv.mjs → server.BVxcyR6X.mjs} +76 -82
- package/dist/shared/{server.CQyYNJ1H.d.ts → server.Bk5r0-2R.d.ts} +1 -2
- package/dist/shared/{server.BeuTpcmO.d.mts → server.Bs6ka_UE.d.mts} +2 -2
- package/dist/shared/{server.BKSOrA6h.d.mts → server.CZNLCQBm.d.mts} +2 -2
- package/dist/shared/{server.BKSOrA6h.d.ts → server.CZNLCQBm.d.ts} +2 -2
- package/dist/shared/{server.C1fnTLq0.d.mts → server.CbLTWfgn.d.mts} +1 -2
- package/dist/shared/{server.SLLuK6_v.d.ts → server.D2UFMrxf.d.ts} +2 -2
- package/dist/shared/{server.BKh8I1Ny.mjs → server.DcfsPloY.mjs} +17 -54
- package/package.json +10 -9
package/dist/index.d.ts
CHANGED
|
@@ -1,53 +1,13 @@
|
|
|
1
|
-
import { AnySchema, ErrorMap, Meta,
|
|
2
|
-
export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, InputStructure, MergedErrorMap, Meta, OutputStructure, Route, Schema, ValidationError, eventIterator,
|
|
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, InputStructure, 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.CZNLCQBm.js';
|
|
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.CZNLCQBm.js';
|
|
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,30 +122,36 @@ 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>;
|
|
279
139
|
/**
|
|
280
140
|
* Create a lazy router
|
|
281
141
|
* And applies all of the previously defined options to the specified router.
|
|
282
142
|
*
|
|
283
143
|
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
284
144
|
*/
|
|
285
|
-
|
|
145
|
+
lazyRoute<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(loader: () => Promise<{
|
|
286
146
|
default: U;
|
|
287
147
|
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, TErrorMap>;
|
|
288
148
|
}
|
|
149
|
+
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' | 'lazyRoute'> {
|
|
150
|
+
/**
|
|
151
|
+
* This property holds the defined options.
|
|
152
|
+
*/
|
|
153
|
+
'~orpc': EnhanceRouterOptions<TErrorMap>;
|
|
154
|
+
}
|
|
289
155
|
|
|
290
156
|
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> {
|
|
291
157
|
/**
|
|
@@ -309,23 +175,18 @@ interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Co
|
|
|
309
175
|
}
|
|
310
176
|
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
177
|
|
|
312
|
-
interface BuilderDef<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta
|
|
178
|
+
interface BuilderDef<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>, EnhanceRouterOptions<TErrorMap> {
|
|
313
179
|
middlewares: readonly AnyMiddleware[];
|
|
314
180
|
inputValidationIndex: number;
|
|
315
181
|
outputValidationIndex: number;
|
|
316
182
|
}
|
|
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>);
|
|
183
|
+
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
184
|
/**
|
|
324
185
|
* Set or override the initial context.
|
|
325
186
|
*
|
|
326
187
|
* @see {@link https://orpc.unnoq.com/docs/context Context Docs}
|
|
327
188
|
*/
|
|
328
|
-
$context<U extends Context>(): Builder<U
|
|
189
|
+
$context<U extends Context>(): Builder<U, U, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
329
190
|
/**
|
|
330
191
|
* Creates a middleware.
|
|
331
192
|
*
|
|
@@ -333,89 +194,6 @@ declare class Builder<TInitialContext extends Context, TCurrentContext extends C
|
|
|
333
194
|
*/
|
|
334
195
|
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
196
|
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
197
|
}
|
|
420
198
|
type ApiBuilder<TMeta extends Meta> = Builder<Record<never, never>, Record<never, never>, Schema<unknown, unknown>, Schema<unknown, unknown>, Record<never, never>, TMeta, never>;
|
|
421
199
|
interface ApiBuilderOpts<TMeta extends Meta> {
|
|
@@ -457,7 +235,7 @@ interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext
|
|
|
457
235
|
* Like `ProcedureBuilderWithoutHandler`, but removed all method that can change the contract.
|
|
458
236
|
*/
|
|
459
237
|
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
|
|
238
|
+
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
461
239
|
/**
|
|
462
240
|
* Uses a middleware to modify the context or improve the pipeline.
|
|
463
241
|
*
|
|
@@ -559,7 +337,7 @@ type Implementer<TContract extends AnyContractRouter, TInitialContext extends Co
|
|
|
559
337
|
*
|
|
560
338
|
* @see {@link https://orpc.unnoq.com/docs/context Context Docs}
|
|
561
339
|
*/
|
|
562
|
-
$context<U extends Context>(): Implementer<TContract, U
|
|
340
|
+
$context<U extends Context>(): Implementer<TContract, U, U>;
|
|
563
341
|
} & ImplementerInternal<TContract, TInitialContext, TCurrentContext>;
|
|
564
342
|
declare function implement<T extends AnyContractRouter, TContext extends Context = Record<never, never>>(contract: T): Implementer<T, TContext, TContext>;
|
|
565
343
|
|
|
@@ -599,5 +377,5 @@ declare function createRouterClient<T extends AnyRouter, TClientContext extends
|
|
|
599
377
|
declare function setHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: AnyContractRouter): T;
|
|
600
378
|
declare function getHiddenRouterContract(router: Lazyable<AnyRouter | AnyContractRouter>): AnyContractRouter | undefined;
|
|
601
379
|
|
|
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,
|
|
380
|
+
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 };
|
|
381
|
+
export type { AccessibleLazyRouter, ApiBuilder, BuilderDef, ContractProcedureCallbackOptions, DecoratedMiddleware, EnhanceRouterOptions, EnhancedRouter, ImplementedProcedure, Implementer, ImplementerInternal, ImplementerInternalWithMiddlewares, LazyTraverseContractProceduresOptions, ProcedureImplementer, RouterBuilder, RouterClient, RouterImplementer, RouterImplementerWithMiddlewares, TraverseContractProcedureCallbackOptions, TraverseContractProceduresOptions, UnlaziedRouter };
|