@temporary-name/server 1.9.3-alpha.4275e976ddda4d8be107c2cfde9899bdea9a337d → 1.9.3-alpha.65222302f1b71807a849530b3fe0fa0326d3c1a2
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 -6
- package/dist/adapters/aws-lambda/index.d.ts +12 -6
- package/dist/adapters/aws-lambda/index.mjs +14 -4
- package/dist/adapters/fetch/index.d.mts +12 -6
- package/dist/adapters/fetch/index.d.ts +12 -6
- package/dist/adapters/fetch/index.mjs +11 -8
- package/dist/adapters/node/index.d.mts +12 -6
- package/dist/adapters/node/index.d.ts +12 -6
- package/dist/adapters/node/index.mjs +11 -8
- package/dist/adapters/standard/index.d.mts +39 -13
- package/dist/adapters/standard/index.d.ts +39 -13
- package/dist/adapters/standard/index.mjs +7 -97
- package/dist/index.d.mts +29 -334
- package/dist/index.d.ts +29 -334
- package/dist/index.mjs +69 -107
- package/dist/openapi/index.d.mts +220 -0
- package/dist/openapi/index.d.ts +220 -0
- package/dist/openapi/index.mjs +776 -0
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/index.d.ts +2 -2
- package/dist/shared/server.BEHw7Eyx.mjs +247 -0
- package/dist/shared/{server.C1YnHvvf.d.ts → server.BKSOrA6h.d.mts} +2 -2
- package/dist/shared/{server.C1YnHvvf.d.mts → server.BKSOrA6h.d.ts} +2 -2
- package/dist/shared/{server.BEQrAa3A.mjs → server.BKh8I1Ny.mjs} +34 -2
- package/dist/shared/server.BeuTpcmO.d.mts +23 -0
- package/dist/shared/{server.Btxrgkj5.d.ts → server.C1fnTLq0.d.mts} +8 -24
- package/dist/shared/{server.Bo94xDTv.d.mts → server.CQyYNJ1H.d.ts} +8 -24
- package/dist/shared/server.DLsti1Pv.mjs +293 -0
- package/dist/shared/server.SLLuK6_v.d.ts +23 -0
- package/package.json +17 -12
- 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,9 +1,9 @@
|
|
|
1
|
-
import { AnySchema, ErrorMap, Meta, MergedErrorMap, Route, InferSchemaOutput, InferSchemaInput, EnhanceRouteOptions, AnyContractRouter, AnyContractProcedure, Schema, ContractRouter, ContractProcedureDef, ContractProcedure, InferContractRouterErrorMap, InferContractRouterMeta, ErrorFromErrorMap } from '@temporary-name/contract';
|
|
1
|
+
import { AnySchema, ErrorMap, Meta, MergedErrorMap, Route, InferSchemaOutput, InferSchemaInput, EnhanceRouteOptions, AnyContractRouter, AnyContractProcedure, ContractProcedureBuilder, Schema, ContractRouter, ContractProcedureDef, ContractProcedure, InferContractRouterErrorMap, InferContractRouterMeta, ErrorFromErrorMap } from '@temporary-name/contract';
|
|
2
2
|
export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, InputStructure, MergedErrorMap, Meta, OutputStructure, Route, Schema, ValidationError, eventIterator, type, validateORPCError } from '@temporary-name/contract';
|
|
3
3
|
import { IntersectPick, ClientContext, MaybeOptionalOptions, 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 { C as Context,
|
|
6
|
-
export { H as InferRouterCurrentContexts, G as InferRouterInitialContexts, J as InferRouterInputs, K as InferRouterOutputs,
|
|
5
|
+
import { C as Context, P as Procedure, M as Middleware, O as ORPCErrorConstructorMap, a as MergedInitialContext, b as MergedCurrentContext, c as MapInputMiddleware, d as CreateProcedureClientOptions, e as ProcedureClient, A as AnyMiddleware, L as Lazyable, f as AnyRouter, g as Lazy, h as AnyProcedure, i as ProcedureHandler, R as Router, I as InferRouterInitialContext } from './shared/server.BKSOrA6h.mjs';
|
|
6
|
+
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.BKSOrA6h.mjs';
|
|
7
7
|
export { getEventMeta, withEventMeta } from '@temporary-name/standard-server';
|
|
8
8
|
|
|
9
9
|
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> {
|
|
@@ -93,159 +93,27 @@ type UnlaziedRouter<T extends AnyRouter> = T extends AnyProcedure ? T : {
|
|
|
93
93
|
};
|
|
94
94
|
declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedRouter<T>>;
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> extends ContractProcedureBuilder<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
|
97
97
|
/**
|
|
98
98
|
* This property holds the defined options.
|
|
99
99
|
*/
|
|
100
100
|
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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>;
|
|
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>;
|
|
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>;
|
|
202
|
-
/**
|
|
203
|
-
* Sets or updates the metadata.
|
|
204
|
-
* The provided metadata is spared-merged with any existing metadata.
|
|
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>;
|
|
101
|
+
constructor(def: BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>);
|
|
102
|
+
errors: <U extends ErrorMap>(errors: U) => ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta, TGateName>;
|
|
103
|
+
meta: (meta: TMeta) => ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
104
|
+
route: (route: Route) => ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
218
105
|
/**
|
|
219
106
|
* Defines the input validation schema.
|
|
220
107
|
*
|
|
221
108
|
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
|
|
222
109
|
*/
|
|
223
|
-
|
|
110
|
+
input<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
224
111
|
/**
|
|
225
112
|
* Defines the output validation schema.
|
|
226
113
|
*
|
|
227
114
|
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
|
|
228
115
|
*/
|
|
229
|
-
|
|
230
|
-
/**
|
|
231
|
-
* Defines the handler of the procedure.
|
|
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>;
|
|
116
|
+
output<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta, TGateName>;
|
|
249
117
|
/**
|
|
250
118
|
* Uses a middleware to modify the context or improve the pipeline.
|
|
251
119
|
*
|
|
@@ -253,109 +121,18 @@ interface ProcedureBuilderWithOutput<TInitialContext extends Context, TCurrentCo
|
|
|
253
121
|
* @note The current context must be satisfy middleware dependent-context
|
|
254
122
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
255
123
|
*/
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
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>;
|
|
298
|
-
/**
|
|
299
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
300
|
-
*
|
|
301
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
302
|
-
* @info Pass second argument to map the input.
|
|
303
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
304
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
305
|
-
*/
|
|
306
|
-
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureBuilderWithInputOutput<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
307
|
-
/**
|
|
308
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
309
|
-
*
|
|
310
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
311
|
-
* @info Pass second argument to map the input.
|
|
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>;
|
|
124
|
+
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureBuilder<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
125
|
+
useGating<const TInferredGateName extends string>(gates: TInferredGateName[], isGateEnabled: (gate: TInferredGateName, ctx: TCurrentContext) => boolean): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, Context, TCurrentContext>, MergedCurrentContext<TCurrentContext, {
|
|
126
|
+
isGateEnabled: typeof isGateEnabled;
|
|
127
|
+
}>, TInputSchema, TOutputSchema, TErrorMap, TMeta, TInferredGateName>;
|
|
332
128
|
/**
|
|
333
129
|
* Defines the handler of the procedure.
|
|
334
130
|
*
|
|
335
131
|
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
336
132
|
*/
|
|
337
|
-
|
|
133
|
+
handler<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
|
338
134
|
}
|
|
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>;
|
|
135
|
+
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> {
|
|
359
136
|
/**
|
|
360
137
|
* Prefixes all procedures in the router.
|
|
361
138
|
* The provided prefix is post-appended to any existing router prefix.
|
|
@@ -364,30 +141,36 @@ interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends
|
|
|
364
141
|
*
|
|
365
142
|
* @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
366
143
|
*/
|
|
367
|
-
|
|
144
|
+
prefix(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
|
368
145
|
/**
|
|
369
146
|
* Adds tags to all procedures in the router.
|
|
370
147
|
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
371
148
|
*
|
|
372
149
|
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
373
150
|
*/
|
|
374
|
-
|
|
151
|
+
tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
|
375
152
|
/**
|
|
376
153
|
* Applies all of the previously defined options to the specified router.
|
|
377
154
|
*
|
|
378
155
|
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
379
156
|
*/
|
|
380
|
-
|
|
157
|
+
router<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>;
|
|
381
158
|
/**
|
|
382
159
|
* Create a lazy router
|
|
383
160
|
* And applies all of the previously defined options to the specified router.
|
|
384
161
|
*
|
|
385
162
|
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
386
163
|
*/
|
|
387
|
-
|
|
164
|
+
lazyRoute<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(loader: () => Promise<{
|
|
388
165
|
default: U;
|
|
389
166
|
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, TErrorMap>;
|
|
390
167
|
}
|
|
168
|
+
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'> {
|
|
169
|
+
/**
|
|
170
|
+
* This property holds the defined options.
|
|
171
|
+
*/
|
|
172
|
+
'~orpc': EnhanceRouterOptions<TErrorMap>;
|
|
173
|
+
}
|
|
391
174
|
|
|
392
175
|
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> {
|
|
393
176
|
/**
|
|
@@ -416,12 +199,7 @@ interface BuilderDef<TInputSchema extends AnySchema, TOutputSchema extends AnySc
|
|
|
416
199
|
inputValidationIndex: number;
|
|
417
200
|
outputValidationIndex: number;
|
|
418
201
|
}
|
|
419
|
-
declare class Builder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> {
|
|
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>);
|
|
202
|
+
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> {
|
|
425
203
|
/**
|
|
426
204
|
* Set or override the initial context.
|
|
427
205
|
*
|
|
@@ -435,89 +213,6 @@ declare class Builder<TInitialContext extends Context, TCurrentContext extends C
|
|
|
435
213
|
*/
|
|
436
214
|
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
215
|
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, TMeta>;
|
|
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>;
|
|
521
216
|
}
|
|
522
217
|
type ApiBuilder<TMeta extends Meta> = Builder<Record<never, never>, Record<never, never>, Schema<unknown, unknown>, Schema<unknown, unknown>, Record<never, never>, TMeta, never>;
|
|
523
218
|
interface ApiBuilderOpts<TMeta extends Meta> {
|
|
@@ -701,5 +396,5 @@ declare function createRouterClient<T extends AnyRouter, TClientContext extends
|
|
|
701
396
|
declare function setHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: AnyContractRouter): T;
|
|
702
397
|
declare function getHiddenRouterContract(router: Lazyable<AnyRouter | AnyContractRouter>): AnyContractRouter | undefined;
|
|
703
398
|
|
|
704
|
-
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 };
|
|
705
|
-
export type { AccessibleLazyRouter, ApiBuilder, BuilderDef,
|
|
399
|
+
export { AnyMiddleware, AnyProcedure, AnyRouter, Builder, BuilderWithMiddlewares, Context, CreateProcedureClientOptions, DecoratedProcedure, InferRouterInitialContext, Lazy, Lazyable, MapInputMiddleware, MergedCurrentContext, MergedInitialContext, Middleware, ORPCErrorConstructorMap, Procedure, ProcedureBuilder, ProcedureClient, ProcedureHandler, Router, addMiddleware, call, createAccessibleLazyRouter, createApiBuilder, createAssertedLazyProcedure, createContractedProcedure, createRouterClient, decorateMiddleware, enhanceRouter, getHiddenRouterContract, getRouter, implement, implementerInternal, isStartWithMiddlewares, mergeMiddlewares, os, resolveContractProcedures, setHiddenRouterContract, traverseContractProcedures, unlazyRouter };
|
|
400
|
+
export type { AccessibleLazyRouter, ApiBuilder, BuilderDef, ContractProcedureCallbackOptions, DecoratedMiddleware, EnhanceRouterOptions, EnhancedRouter, ImplementedProcedure, Implementer, ImplementerInternal, ImplementerInternalWithMiddlewares, LazyTraverseContractProceduresOptions, ProcedureImplementer, RouterBuilder, RouterClient, RouterImplementer, RouterImplementerWithMiddlewares, TraverseContractProcedureCallbackOptions, TraverseContractProceduresOptions, UnlaziedRouter };
|