@temporary-name/server 1.9.3-alpha.6ef4729e23affbe6454d37025d1dfc4d998b0649 → 1.9.3-alpha.70ac9623e5fa2a8af7954e34ef97cee968e5cad9

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