@temporary-name/server 1.9.3-alpha.16e8a4f82a5b0af6e22263774a4af4e6f9afd8bc → 1.9.3-alpha.21b0289906d115f2f3db137ea407a6d8d50b5ad6

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.
Files changed (33) hide show
  1. package/dist/adapters/aws-lambda/index.d.mts +3 -4
  2. package/dist/adapters/aws-lambda/index.d.ts +3 -4
  3. package/dist/adapters/aws-lambda/index.mjs +4 -6
  4. package/dist/adapters/fetch/index.d.mts +3 -4
  5. package/dist/adapters/fetch/index.d.ts +3 -4
  6. package/dist/adapters/fetch/index.mjs +4 -6
  7. package/dist/adapters/node/index.d.mts +3 -4
  8. package/dist/adapters/node/index.d.ts +3 -4
  9. package/dist/adapters/node/index.mjs +4 -6
  10. package/dist/adapters/standard/index.d.mts +20 -32
  11. package/dist/adapters/standard/index.d.ts +20 -32
  12. package/dist/adapters/standard/index.mjs +4 -6
  13. package/dist/index.d.mts +69 -339
  14. package/dist/index.d.ts +69 -339
  15. package/dist/index.mjs +132 -357
  16. package/dist/openapi/index.d.mts +1 -1
  17. package/dist/openapi/index.d.ts +1 -1
  18. package/dist/openapi/index.mjs +60 -77
  19. package/dist/plugins/index.d.mts +3 -4
  20. package/dist/plugins/index.d.ts +3 -4
  21. package/dist/shared/{server.BeuTpcmO.d.mts → server.7aL9gcoU.d.mts} +2 -2
  22. package/dist/shared/server.BL2R5jcp.d.mts +228 -0
  23. package/dist/shared/server.BL2R5jcp.d.ts +228 -0
  24. package/dist/shared/{server.DLsti1Pv.mjs → server.CttFCjkj.mjs} +57 -95
  25. package/dist/shared/{server.CQyYNJ1H.d.ts → server.D6Qs_UcF.d.mts} +2 -4
  26. package/dist/shared/{server.SLLuK6_v.d.ts → server.DFptr1Nz.d.ts} +2 -2
  27. package/dist/shared/server.DmGicgbG.mjs +413 -0
  28. package/dist/shared/{server.C1fnTLq0.d.mts → server.DpoO_ER_.d.ts} +2 -4
  29. package/dist/shared/{server.BEHw7Eyx.mjs → server.JtIZ8YG7.mjs} +1 -11
  30. package/package.json +10 -9
  31. package/dist/shared/server.BKSOrA6h.d.mts +0 -192
  32. package/dist/shared/server.BKSOrA6h.d.ts +0 -192
  33. package/dist/shared/server.BKh8I1Ny.mjs +0 -239
package/dist/index.d.ts CHANGED
@@ -1,196 +1,71 @@
1
- import { AnySchema, ErrorMap, Meta, MergedErrorMap, Route, InferSchemaOutput, InferSchemaInput, EnhanceRouteOptions, AnyContractRouter, AnyContractProcedure, Schema, ContractRouter, ContractProcedureDef, ContractProcedure, InferContractRouterErrorMap, InferContractRouterMeta, ErrorFromErrorMap } from '@temporary-name/contract';
2
- export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, InputStructure, MergedErrorMap, Meta, OutputStructure, Route, Schema, ValidationError, eventIterator, type, validateORPCError } from '@temporary-name/contract';
3
- import { IntersectPick, ClientContext, MaybeOptionalOptions, HTTPPath, ClientOptions, ClientPromiseResult } from '@temporary-name/shared';
1
+ import { Schemas, ErrorMap, Meta, ContractProcedure, MergedErrorMap, AnyShape, MergedSchemas, WrapShape, UnionToIntersection, AnySchema, Route, InferHandlerInputs, InferSchemaInput, ContractRouter, ContractProcedureDef, InitialSchemas, AnyContractRouter, InferContractRouterErrorMap, InferContractRouterMeta, AnyContractProcedure, InferProcedureClientInputs, InferSchemaOutput, ErrorFromErrorMap, Schema } from '@temporary-name/contract';
2
+ export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, MergedErrorMap, Meta, OutputStructure, Route, Schema, ValidationError, eventIterator, validateORPCError } from '@temporary-name/contract';
3
+ import { ClientContext, MaybeOptionalOptions, HTTPEndpoint, 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 { 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.js';
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.js';
5
+ import { SchemaClass, core } from '@temporary-name/zod';
6
+ import { C as Context, P as Procedure, a as CreateProcedureClientOptions, b as ProcedureClient, M as Middleware, O as ORPCErrorConstructorMap, c as MergedInitialContext, d as MergedCurrentContext, e as ProcedureHandler, E as EnhanceRouterOptions, R as Router, f as EnhancedRouter, g as MapInputMiddleware, A as AnyMiddleware, L as Lazy, h as AnyProcedure, i as Lazyable, j as AnyRouter, I as InferRouterInitialContext } from './shared/server.BL2R5jcp.js';
7
+ export { T as AccessibleLazyRouter, Y as ContractProcedureCallbackOptions, K as InferRouterCurrentContexts, J as InferRouterInitialContexts, N as InferRouterInputs, Q as InferRouterOutputs, o as LAZY_SYMBOL, p as LazyMeta, Z as LazyTraverseContractProceduresOptions, w as MiddlewareNextFn, y as MiddlewareOptions, x as MiddlewareOutputFn, v as MiddlewareResult, l as ORPCErrorConstructorMapItem, k as ORPCErrorConstructorMapItemOptions, G as ProcedureClientInterceptorOptions, D as ProcedureDef, B as ProcedureHandlerOptions, X as TraverseContractProcedureCallbackOptions, W as TraverseContractProceduresOptions, a0 as UnlaziedRouter, U as createAccessibleLazyRouter, n as createORPCErrorConstructorMap, H as createProcedureClient, V as enhanceRouter, t as getLazyMeta, S as getRouter, s as isLazy, F as isProcedure, r as lazy, q as lazyInternal, m as mergeCurrentContext, z as middlewareOutputFn, $ as resolveContractProcedures, _ as traverseContractProcedures, u as unlazy, a1 as unlazyRouter } from './shared/server.BL2R5jcp.js';
7
8
  export { getEventMeta, withEventMeta } from '@temporary-name/standard-server';
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> {
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>;
10
+ declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta> {
51
11
  /**
52
12
  * Make this procedure callable (works like a function while still being a procedure).
53
13
  *
54
14
  * @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
55
15
  */
56
- callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
57
- }
58
-
59
- declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
60
- type AccessibleLazyRouter<T extends Lazyable<AnyRouter | undefined>> = T extends Lazy<infer U extends AnyRouter | undefined | Lazy<AnyRouter | undefined>> ? AccessibleLazyRouter<U> : T extends AnyProcedure | undefined ? Lazy<T> : Lazy<T> & {
61
- [K in keyof T]: T[K] extends Lazyable<AnyRouter> ? AccessibleLazyRouter<T[K]> : never;
62
- };
63
- declare function createAccessibleLazyRouter<T extends Lazy<AnyRouter | undefined>>(lazied: T): AccessibleLazyRouter<T>;
64
- type EnhancedRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap> = T extends Lazy<infer U extends AnyRouter> ? AccessibleLazyRouter<EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>> : T extends (Procedure<infer UInitialContext, infer UCurrentContext, infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta>) ? Procedure<MergedInitialContext<TInitialContext, UInitialContext, TCurrentContext>, UCurrentContext, UInputSchema, UOutputSchema, MergedErrorMap<TErrorMap, UErrorMap>, UMeta> : {
65
- [K in keyof T]: T[K] extends Lazyable<AnyRouter> ? EnhancedRouter<T[K], TInitialContext, TCurrentContext, TErrorMap> : never;
66
- };
67
- interface EnhanceRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
68
- middlewares: readonly AnyMiddleware[];
69
- errorMap: TErrorMap;
70
- dedupeLeadingMiddlewares: boolean;
71
- }
72
- declare function enhanceRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap>(router: T, options: EnhanceRouterOptions<TErrorMap>): EnhancedRouter<T, TInitialContext, TCurrentContext, TErrorMap>;
73
- interface TraverseContractProceduresOptions {
74
- router: AnyContractRouter | AnyRouter;
75
- path: readonly string[];
76
- }
77
- interface TraverseContractProcedureCallbackOptions {
78
- contract: AnyContractProcedure | AnyProcedure;
79
- path: readonly string[];
80
- }
81
- /**
82
- * @deprecated Use `TraverseContractProcedureCallbackOptions` instead.
83
- */
84
- type ContractProcedureCallbackOptions = TraverseContractProcedureCallbackOptions;
85
- interface LazyTraverseContractProceduresOptions {
86
- router: Lazy<AnyRouter>;
87
- path: readonly string[];
16
+ callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TSchemas['outputSchema'], TErrorMap, TMeta, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta> & ProcedureClient<TClientContext, TSchemas, TErrorMap>;
88
17
  }
89
- declare function traverseContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void, lazyOptions?: LazyTraverseContractProceduresOptions[]): LazyTraverseContractProceduresOptions[];
90
- declare function resolveContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void): Promise<void>;
91
- type UnlaziedRouter<T extends AnyRouter> = T extends AnyProcedure ? T : {
92
- [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? UnlaziedRouter<U> : never;
93
- };
94
- declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedRouter<T>>;
95
18
 
96
- interface BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> {
19
+ declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> extends ContractProcedure<TSchemas, TErrorMap, TMeta> {
20
+ z: SchemaClass<TGateName>;
97
21
  /**
98
22
  * This property holds the defined options.
99
23
  */
100
- '~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
24
+ '~orpc': BuilderDef<TSchemas, TErrorMap, TMeta>;
25
+ constructor(def: BuilderDef<TSchemas, TErrorMap, TMeta>);
101
26
  /**
102
- * Adds type-safe custom errors.
103
- * The provided errors are spared-merged with any existing errors.
27
+ * Adds type-safe custom errors to the contract.
28
+ * The provided errors are spared-merged with any existing errors in the contract.
104
29
  *
105
30
  * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
106
31
  */
107
- 'errors'<U extends ErrorMap>(errors: U): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta, TGateName>;
32
+ errors<U extends ErrorMap>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, MergedErrorMap<TErrorMap, U>, TMeta, TGateName>;
108
33
  /**
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.
34
+ * Sets or updates the metadata for the contract.
35
+ * The provided metadata is spared-merged with any existing metadata in the contract.
119
36
  *
120
37
  * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
121
38
  */
122
- 'meta'(meta: TMeta): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
39
+ meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta, TGateName>;
40
+ endpoint<U extends AnyShape[]>(strings: TemplateStringsArray, ...values: [...U]): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
41
+ pathSchema: WrapShape<UnionToIntersection<U>>;
42
+ }>, TErrorMap, TMeta, TGateName>;
43
+ endpoint<U extends AnySchema | AnyShape = core.$ZodType<Record<string, never>, Record<string, never>>>(endpoint: HTTPEndpoint, schema?: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
44
+ pathSchema: WrapShape<U>;
45
+ }>, TErrorMap, TMeta, TGateName>;
123
46
  /**
124
- * Sets or updates the route definition.
125
- * The provided route is spared-merged with any existing route.
47
+ * Sets or updates the route definition for the contract.
48
+ * The provided route is spared-merged with any existing route in the contract.
126
49
  * This option is typically relevant when integrating with OpenAPI.
127
50
  *
128
51
  * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
129
52
  * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
130
53
  */
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>;
54
+ endpointOpts(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta, TGateName>;
55
+ query<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
56
+ querySchema: WrapShape<U>;
57
+ }>, TErrorMap, TMeta, TGateName>;
58
+ body<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
59
+ bodySchema: WrapShape<U>;
60
+ }>, TErrorMap, TMeta, TGateName>;
138
61
  /**
139
62
  * Defines the output validation schema.
140
63
  *
141
64
  * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
142
65
  */
143
- 'output'<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<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>;
66
+ output<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
67
+ outputSchema: WrapShape<U>;
68
+ }>, TErrorMap, TMeta, TGateName>;
194
69
  /**
195
70
  * Uses a middleware to modify the context or improve the pipeline.
196
71
  *
@@ -198,62 +73,18 @@ interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext exte
198
73
  * @note The current context must be satisfy middleware dependent-context
199
74
  * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
200
75
  */
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>;
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>;
76
+ use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureBuilder<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TErrorMap, TMeta, TGateName>;
77
+ useGating<const TInferredGateName extends string>(gates: TInferredGateName[], isGateEnabled: (gate: TInferredGateName, ctx: TCurrentContext) => boolean): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, Context, TCurrentContext>, MergedCurrentContext<TCurrentContext, {
78
+ isGateEnabled: typeof isGateEnabled;
79
+ }>, TSchemas, TErrorMap, TMeta, TInferredGateName>;
230
80
  /**
231
81
  * Defines the handler of the procedure.
232
82
  *
233
83
  * @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
234
84
  */
235
- 'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
85
+ handler(handler: ProcedureHandler<TCurrentContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta>;
236
86
  }
237
- interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
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>;
87
+ declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> extends ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta, TGateName> {
257
88
  /**
258
89
  * Prefixes all procedures in the router.
259
90
  * The provided prefix is post-appended to any existing router prefix.
@@ -262,29 +93,26 @@ interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends
262
93
  *
263
94
  * @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
264
95
  */
265
- 'prefix'(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
96
+ prefix(prefix: HTTPPath): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta, TGateName>;
266
97
  /**
267
98
  * Adds tags to all procedures in the router.
268
99
  * This helpful when you want to group procedures together in the OpenAPI specification.
269
100
  *
270
101
  * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
271
102
  */
272
- 'tag'(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
103
+ tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
273
104
  /**
274
105
  * Applies all of the previously defined options to the specified router.
275
106
  *
276
107
  * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
277
108
  */
278
- 'router'<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>;
109
+ router<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>;
110
+ }
111
+ interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> extends Pick<BuilderWithMiddlewares<TInitialContext, TCurrentContext, any, TErrorMap, TMeta, any>, 'prefix' | 'tag' | 'router'> {
279
112
  /**
280
- * Create a lazy router
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}
113
+ * This property holds the defined options.
284
114
  */
285
- 'lazyRoute'<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(loader: () => Promise<{
286
- default: U;
287
- }>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, TErrorMap>;
115
+ '~orpc': EnhanceRouterOptions<TErrorMap>;
288
116
  }
289
117
 
290
118
  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 +137,18 @@ interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Co
309
137
  }
310
138
  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
139
 
312
- interface BuilderDef<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>, EnhanceRouterOptions<TErrorMap> {
140
+ interface BuilderDef<TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TSchemas, TErrorMap, TMeta>, EnhanceRouterOptions<TErrorMap> {
313
141
  middlewares: readonly AnyMiddleware[];
314
142
  inputValidationIndex: number;
315
143
  outputValidationIndex: number;
316
144
  }
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>);
145
+ declare class Builder<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> extends BuilderWithMiddlewares<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta, TGateName> {
323
146
  /**
324
147
  * Set or override the initial context.
325
148
  *
326
149
  * @see {@link https://orpc.unnoq.com/docs/context Context Docs}
327
150
  */
328
- $context<U extends Context>(): Builder<U & Record<never, never>, U, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
151
+ $context<U extends Context>(): Builder<U, U, TSchemas, TErrorMap, TMeta, TGateName>;
329
152
  /**
330
153
  * Creates a middleware.
331
154
  *
@@ -333,91 +156,8 @@ declare class Builder<TInitialContext extends Context, TCurrentContext extends C
333
156
  */
334
157
  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
158
  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
159
  }
420
- type ApiBuilder<TMeta extends Meta> = Builder<Record<never, never>, Record<never, never>, Schema<unknown, unknown>, Schema<unknown, unknown>, Record<never, never>, TMeta, never>;
160
+ type ApiBuilder<TMeta extends Meta> = Builder<Record<never, never>, Record<never, never>, InitialSchemas, Record<never, never>, TMeta, never>;
421
161
  interface ApiBuilderOpts<TMeta extends Meta> {
422
162
  meta?: TMeta;
423
163
  }
@@ -427,7 +167,7 @@ declare const os: ApiBuilder<Record<never, never>>;
427
167
  /**
428
168
  * Like `DecoratedProcedure`, but removed all method that can change the contract.
429
169
  */
430
- interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> {
170
+ interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta> {
431
171
  /**
432
172
  * Uses a middleware to modify the context or improve the pipeline.
433
173
  *
@@ -436,7 +176,7 @@ interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext
436
176
  * @note The current context must be satisfy middleware dependent-context
437
177
  * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
438
178
  */
439
- use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ImplementedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
179
+ use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ImplementedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TErrorMap, TMeta>;
440
180
  /**
441
181
  * Uses a middleware to modify the context or improve the pipeline.
442
182
  *
@@ -445,19 +185,19 @@ interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext
445
185
  * @note The current context must be satisfy middleware dependent-context
446
186
  * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
447
187
  */
448
- use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ImplementedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
188
+ use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TSchemas['outputSchema']>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferHandlerInputs<TSchemas>, UInput>): ImplementedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TErrorMap, TMeta>;
449
189
  /**
450
190
  * Make this procedure callable (works like a function while still being a procedure).
451
191
  *
452
192
  * @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
453
193
  */
454
- callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
194
+ callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TSchemas['outputSchema'], TErrorMap, TMeta, TClientContext>>): ImplementedProcedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta> & ProcedureClient<TClientContext, TSchemas, TErrorMap>;
455
195
  }
456
196
  /**
457
197
  * Like `ProcedureBuilderWithoutHandler`, but removed all method that can change the contract.
458
198
  */
459
- 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, string>;
199
+ interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> {
200
+ '~orpc': BuilderDef<TSchemas, TErrorMap, TMeta>;
461
201
  /**
462
202
  * Uses a middleware to modify the context or improve the pipeline.
463
203
  *
@@ -466,7 +206,7 @@ interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext
466
206
  * @note The current context must be satisfy middleware dependent-context
467
207
  * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
468
208
  */
469
- 'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
209
+ 'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TErrorMap, TMeta>;
470
210
  /**
471
211
  * Uses a middleware to modify the context or improve the pipeline.
472
212
  *
@@ -475,13 +215,13 @@ interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext
475
215
  * @note The current context must be satisfy middleware dependent-context
476
216
  * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
477
217
  */
478
- 'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
218
+ 'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TSchemas['outputSchema']>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferHandlerInputs<TSchemas>, UInput>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TErrorMap, TMeta>;
479
219
  /**
480
220
  * Defines the handler of the procedure.
481
221
  *
482
222
  * @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
483
223
  */
484
- 'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
224
+ 'handler'(handler: ProcedureHandler<TCurrentContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta>;
485
225
  }
486
226
 
487
227
  interface RouterImplementerWithMiddlewares<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
@@ -500,18 +240,8 @@ interface RouterImplementerWithMiddlewares<T extends AnyContractRouter, TInitial
500
240
  * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
501
241
  */
502
242
  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
243
  }
514
- 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> & {
244
+ type ImplementerInternalWithMiddlewares<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = TContract extends ContractProcedure<infer USchemas, infer UErrorMap, infer UMeta> ? ProcedureImplementer<TInitialContext, TCurrentContext, USchemas, UErrorMap, UMeta> : RouterImplementerWithMiddlewares<TContract, TInitialContext, TCurrentContext> & {
515
245
  [K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternalWithMiddlewares<TContract[K], TInitialContext, TCurrentContext> : never;
516
246
  };
517
247
 
@@ -549,7 +279,7 @@ interface RouterImplementer<T extends AnyContractRouter, TInitialContext extends
549
279
  default: U;
550
280
  }>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, Record<never, never>>;
551
281
  }
552
- type ImplementerInternal<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> : RouterImplementer<TContract, TInitialContext, TCurrentContext> & {
282
+ type ImplementerInternal<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = TContract extends ContractProcedure<infer USchemas, infer UErrorMap, infer UMeta> ? ProcedureImplementer<TInitialContext, TCurrentContext, USchemas, UErrorMap, UMeta> : RouterImplementer<TContract, TInitialContext, TCurrentContext> & {
553
283
  [K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternal<TContract[K], TInitialContext, TCurrentContext> : never;
554
284
  };
555
285
  declare function implementerInternal<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context>(contract: T, middlewares: AnyMiddleware[]): ImplementerInternal<T, TInitialContext, TCurrentContext>;
@@ -559,7 +289,7 @@ type Implementer<TContract extends AnyContractRouter, TInitialContext extends Co
559
289
  *
560
290
  * @see {@link https://orpc.unnoq.com/docs/context Context Docs}
561
291
  */
562
- $context<U extends Context>(): Implementer<TContract, U & Record<never, never>, U>;
292
+ $context<U extends Context>(): Implementer<TContract, U, U>;
563
293
  } & ImplementerInternal<TContract, TInitialContext, TCurrentContext>;
564
294
  declare function implement<T extends AnyContractRouter, TContext extends Context = Record<never, never>>(contract: T): Implementer<T, TContext, TContext>;
565
295
 
@@ -584,9 +314,9 @@ declare function createContractedProcedure(procedure: AnyProcedure, contract: An
584
314
  * ```
585
315
  *
586
316
  */
587
- declare function call<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta>(procedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, input: InferSchemaInput<TInputSchema>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, Record<never, never>> & Omit<ClientOptions<Record<never, never>>, 'context'>>): ClientPromiseResult<InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
317
+ declare function call<TInitialContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta>(procedure: Lazyable<Procedure<TInitialContext, any, TSchemas, TErrorMap, TMeta>>, input: InferProcedureClientInputs<TSchemas>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TSchemas['outputSchema'], TErrorMap, TMeta, Record<never, never>> & Omit<ClientOptions<Record<never, never>>, 'context'>>): ClientPromiseResult<InferSchemaOutput<TSchemas['outputSchema']>, ErrorFromErrorMap<TErrorMap>>;
588
318
 
589
- type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UErrorMap, any> ? ProcedureClient<TClientContext, UInputSchema, UOutputSchema, UErrorMap> : {
319
+ type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Procedure<any, any, infer USchemas, infer UErrorMap, any> ? ProcedureClient<TClientContext, USchemas, UErrorMap> : {
590
320
  [K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
591
321
  };
592
322
  /**
@@ -599,5 +329,5 @@ declare function createRouterClient<T extends AnyRouter, TClientContext extends
599
329
  declare function setHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: AnyContractRouter): T;
600
330
  declare function getHiddenRouterContract(router: Lazyable<AnyRouter | AnyContractRouter>): AnyContractRouter | undefined;
601
331
 
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, BuilderWithMiddlewares, ContractProcedureCallbackOptions, DecoratedMiddleware, EnhanceRouterOptions, EnhancedRouter, ImplementedProcedure, Implementer, ImplementerInternal, ImplementerInternalWithMiddlewares, LazyTraverseContractProceduresOptions, ProcedureBuilder, ProcedureImplementer, RouterBuilder, RouterClient, RouterImplementer, RouterImplementerWithMiddlewares, TraverseContractProcedureCallbackOptions, TraverseContractProceduresOptions, UnlaziedRouter };
332
+ export { AnyMiddleware, AnyProcedure, AnyRouter, Builder, BuilderWithMiddlewares, Context, CreateProcedureClientOptions, DecoratedProcedure, EnhanceRouterOptions, EnhancedRouter, InferRouterInitialContext, Lazy, Lazyable, MapInputMiddleware, MergedCurrentContext, MergedInitialContext, Middleware, ORPCErrorConstructorMap, Procedure, ProcedureBuilder, ProcedureClient, ProcedureHandler, Router, addMiddleware, call, createApiBuilder, createAssertedLazyProcedure, createContractedProcedure, createRouterClient, decorateMiddleware, getHiddenRouterContract, implement, implementerInternal, isStartWithMiddlewares, mergeMiddlewares, os, setHiddenRouterContract };
333
+ export type { ApiBuilder, BuilderDef, DecoratedMiddleware, ImplementedProcedure, Implementer, ImplementerInternal, ImplementerInternalWithMiddlewares, ProcedureImplementer, RouterBuilder, RouterClient, RouterImplementer, RouterImplementerWithMiddlewares };