@temporary-name/server 1.9.3-alpha.6f8b694b2a090fe0182bfd5f16d29ca20f259307 → 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 (46) hide show
  1. package/dist/adapters/aws-lambda/index.d.mts +5 -7
  2. package/dist/adapters/aws-lambda/index.d.ts +5 -7
  3. package/dist/adapters/aws-lambda/index.mjs +6 -9
  4. package/dist/adapters/fetch/index.d.mts +8 -86
  5. package/dist/adapters/fetch/index.d.ts +8 -86
  6. package/dist/adapters/fetch/index.mjs +18 -160
  7. package/dist/adapters/node/index.d.mts +9 -64
  8. package/dist/adapters/node/index.d.ts +9 -64
  9. package/dist/adapters/node/index.mjs +16 -125
  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 -493
  15. package/dist/index.d.ts +373 -493
  16. package/dist/index.mjs +547 -469
  17. package/dist/openapi/index.d.mts +18 -53
  18. package/dist/openapi/index.d.ts +18 -53
  19. package/dist/openapi/index.mjs +384 -378
  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 +13 -30
  32. package/dist/adapters/standard/index.d.mts +0 -42
  33. package/dist/adapters/standard/index.d.ts +0 -42
  34. package/dist/adapters/standard/index.mjs +0 -11
  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.BEHw7Eyx.mjs +0 -247
  39. package/dist/shared/server.BKSOrA6h.d.mts +0 -192
  40. package/dist/shared/server.BKSOrA6h.d.ts +0 -192
  41. package/dist/shared/server.BKh8I1Ny.mjs +0 -239
  42. package/dist/shared/server.BeuTpcmO.d.mts +0 -23
  43. package/dist/shared/server.C1fnTLq0.d.mts +0 -57
  44. package/dist/shared/server.CQyYNJ1H.d.ts +0 -57
  45. package/dist/shared/server.DLsti1Pv.mjs +0 -293
  46. package/dist/shared/server.SLLuK6_v.d.ts +0 -23
package/dist/index.d.ts CHANGED
@@ -1,196 +1,85 @@
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, 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';
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.js';
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.js';
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.js';
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>;
22
+ path?: readonly string[];
23
+ } & (object extends TInitialContext ? {
24
+ context?: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
25
+ } : {
26
+ context: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
27
+ });
28
+ /**
29
+ * Create Server-side client from a procedure.
30
+ *
31
+ * @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
32
+ */
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>;
34
+
35
+ declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TSchemas, TMeta> {
51
36
  /**
52
37
  * Make this procedure callable (works like a function while still being a procedure).
53
38
  *
54
39
  * @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
55
40
  */
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[];
41
+ callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TSchemas, TMeta> & ProcedureClient<TClientContext, TSchemas>;
80
42
  }
81
- /**
82
- * @deprecated Use `TraverseContractProcedureCallbackOptions` instead.
83
- */
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>>;
95
43
 
96
- interface BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> {
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>);
97
47
  /**
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.
48
+ * Sets or updates the metadata for the contract.
49
+ * The provided metadata is spared-merged with any existing metadata in the contract.
119
50
  *
120
51
  * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
121
52
  */
122
- 'meta'(meta: TMeta): BuilderWithMiddlewares<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>;
123
60
  /**
124
- * Sets or updates the route definition.
125
- * 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.
126
63
  * This option is typically relevant when integrating with OpenAPI.
127
64
  *
128
65
  * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
129
66
  * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
130
67
  */
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>;
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>;
138
75
  /**
139
76
  * Defines the output validation schema.
140
77
  *
141
78
  * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
142
79
  */
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>;
80
+ output<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
81
+ outputSchema: WrapShape<U>;
82
+ }>, TMeta, TGateName>;
194
83
  /**
195
84
  * Uses a middleware to modify the context or improve the pipeline.
196
85
  *
@@ -198,62 +87,21 @@ interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext exte
198
87
  * @note The current context must be satisfy middleware dependent-context
199
88
  * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
200
89
  */
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>;
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>;
230
97
  /**
231
98
  * Defines the handler of the procedure.
232
99
  *
233
100
  * @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
234
101
  */
235
- 'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
102
+ handler(handler: ProcedureHandler<TCurrentContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TSchemas, TMeta>;
236
103
  }
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>;
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> {
257
105
  /**
258
106
  * Prefixes all procedures in the router.
259
107
  * The provided prefix is post-appended to any existing router prefix.
@@ -262,306 +110,327 @@ interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends
262
110
  *
263
111
  * @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
264
112
  */
265
- 'prefix'(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
113
+ prefix(prefix: HTTPPath): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TSchemas, TMeta, TGateName>;
266
114
  /**
267
115
  * Adds tags to all procedures in the router.
268
116
  * This helpful when you want to group procedures together in the OpenAPI specification.
269
117
  *
270
118
  * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
271
119
  */
272
- 'tag'(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
120
+ tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TMeta>;
273
121
  /**
274
122
  * Applies all of the previously defined options to the specified router.
275
123
  *
276
124
  * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
277
125
  */
278
- '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'> {
279
129
  /**
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}
130
+ * This property holds the defined options.
284
131
  */
285
- 'lazyRoute'<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(loader: () => Promise<{
286
- default: U;
287
- }>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, TErrorMap>;
132
+ '~orpc': EnhanceRouterOptions;
288
133
  }
289
134
 
290
- 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> {
291
136
  /**
292
137
  * Change the expected input type by providing a map function.
293
138
  */
294
- mapInput<UInput>(map: MapInputMiddleware<UInput, TInput>): DecoratedMiddleware<TInContext, TOutContext, UInput, TOutput, TErrorConstructorMap, TMeta>;
295
- /**
296
- * Concatenates two middlewares.
297
- *
298
- * @info Pass second argument to map the input.
299
- * @see {@link https://orpc.unnoq.com/docs/middleware#concatenation Middleware Concatenation Docs}
300
- */
301
- 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>;
302
- /**
303
- * Concatenates two middlewares.
304
- *
305
- * @info Pass second argument to map the input.
306
- * @see {@link https://orpc.unnoq.com/docs/middleware#concatenation Middleware Concatenation Docs}
307
- */
308
- 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>;
309
140
  }
310
- 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>;
311
142
 
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> {
313
- middlewares: readonly AnyMiddleware[];
314
- inputValidationIndex: number;
315
- outputValidationIndex: number;
143
+ interface BuilderDef<TSchemas extends Schemas, TMeta extends Meta> extends ContractDef<TSchemas, TMeta>, EnhanceRouterOptions {
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, TMeta extends Meta, TGateName extends string> extends BuilderWithMiddlewares<TInitialContext, TCurrentContext, TSchemas, 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, TMeta, TGateName>;
329
152
  /**
330
153
  * Creates a middleware.
331
154
  *
332
155
  * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
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
- 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
- }
420
- type ApiBuilder<TMeta extends Meta> = Builder<Record<never, never>, Record<never, never>, Schema<unknown, unknown>, Schema<unknown, unknown>, Record<never, never>, TMeta, never>;
421
- interface ApiBuilderOpts<TMeta extends Meta> {
422
- meta?: TMeta;
158
+ middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, TMeta>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, TMeta>;
423
159
  }
424
- declare function createApiBuilder<TMeta extends Meta = Record<never, never>>(opts?: ApiBuilderOpts<TMeta>): ApiBuilder<TMeta>;
425
- 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>;
426
166
 
427
- /**
428
- * Like `DecoratedProcedure`, but removed all method that can change the contract.
429
- */
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> {
431
- /**
432
- * Uses a middleware to modify the context or improve the pipeline.
433
- *
434
- * @info Supports both normal middleware and inline middleware implementations.
435
- * @info Pass second argument to map the input.
436
- * @note The current context must be satisfy middleware dependent-context
437
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
438
- */
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>;
440
- /**
441
- * Uses a middleware to modify the context or improve the pipeline.
442
- *
443
- * @info Supports both normal middleware and inline middleware implementations.
444
- * @info Pass second argument to map the input.
445
- * @note The current context must be satisfy middleware dependent-context
446
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
447
- */
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>;
449
- /**
450
- * Make this procedure callable (works like a function while still being a procedure).
451
- *
452
- * @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
453
- */
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>;
167
+ interface EventIteratorSchemaDetails {
168
+ yields: AnySchema;
169
+ returns?: AnySchema;
455
170
  }
456
171
  /**
457
- * 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}
458
175
  */
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>;
461
- /**
462
- * Uses a middleware to modify the context or improve the pipeline.
463
- *
464
- * @info Supports both normal middleware and inline middleware implementations.
465
- * @info Pass second argument to map the input.
466
- * @note The current context must be satisfy middleware dependent-context
467
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
468
- */
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>;
470
- /**
471
- * Uses a middleware to modify the context or improve the pipeline.
472
- *
473
- * @info Supports both normal middleware and inline middleware implementations.
474
- * @info Pass second argument to map the input.
475
- * @note The current context must be satisfy middleware dependent-context
476
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
477
- */
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>;
479
- /**
480
- * Defines the handler of the procedure.
481
- *
482
- * @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
483
- */
484
- 'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
485
- }
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;
486
178
 
487
- interface RouterImplementerWithMiddlewares<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
488
- /**
489
- * Uses a middleware to modify the context or improve the pipeline.
490
- *
491
- * @info Supports both normal middleware and inline middleware implementations.
492
- * @note The current context must be satisfy middleware dependent-context
493
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
494
- */
495
- 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>>;
496
- /**
497
- * Applies all of the previously defined options to the specified router.
498
- * And enforces the router match the contract.
499
- *
500
- * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
501
- */
502
- 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>>;
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"
513
187
  }
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> & {
515
- [K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternalWithMiddlewares<TContract[K], TInitialContext, TCurrentContext> : never;
516
- };
517
188
 
518
- interface RouterImplementer<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
519
- /**
520
- * Creates a middleware.
521
- *
522
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
523
- */
524
- middleware<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
525
- middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, InferContractRouterMeta<T>>;
526
- /**
527
- * Uses a middleware to modify the context or improve the pipeline.
528
- *
529
- * @info Supports both normal middleware and inline middleware implementations.
530
- * @note The current context must be satisfy middleware dependent-context
531
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
532
- */
533
- 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>>;
534
- /**
535
- * Applies all of the previously defined options to the specified router.
536
- * And enforces the router match the contract.
537
- *
538
- * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
539
- */
540
- router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
541
- /**
542
- * Create a lazy router
543
- * And applies all of the previously defined options to the specified router.
544
- * And enforces the router match the contract.
545
- *
546
- * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
547
- */
548
- lazyRoute<U extends Router<T, TCurrentContext>>(loader: () => Promise<{
549
- default: U;
550
- }>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, Record<never, never>>;
189
+ interface experimental_JsonSchemaCoerceOptions {
190
+ components?: Record<string, JsonSchema>;
551
191
  }
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> & {
553
- [K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternal<TContract[K], TInitialContext, TCurrentContext> : never;
554
- };
555
- declare function implementerInternal<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context>(contract: T, middlewares: AnyMiddleware[]): ImplementerInternal<T, TInitialContext, TCurrentContext>;
556
- type Implementer<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = {
557
- /**
558
- * Set or override the initial context.
559
- *
560
- * @see {@link https://orpc.unnoq.com/docs/context Context Docs}
561
- */
562
- $context<U extends Context>(): Implementer<TContract, U & Record<never, never>, U>;
563
- } & ImplementerInternal<TContract, TInitialContext, TCurrentContext>;
564
- 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>>>;
565
434
 
566
435
  declare function isStartWithMiddlewares(middlewares: readonly AnyMiddleware[], compare: readonly AnyMiddleware[]): boolean;
567
436
  declare function mergeMiddlewares(first: readonly AnyMiddleware[], second: readonly AnyMiddleware[], options: {
@@ -570,10 +439,6 @@ declare function mergeMiddlewares(first: readonly AnyMiddleware[], second: reado
570
439
  declare function addMiddleware(middlewares: readonly AnyMiddleware[], addition: AnyMiddleware): AnyMiddleware[];
571
440
 
572
441
  declare function createAssertedLazyProcedure(lazied: Lazy<any>): Lazy<AnyProcedure>;
573
- /**
574
- * Create a new procedure that ensure the contract is applied to the procedure.
575
- */
576
- declare function createContractedProcedure(procedure: AnyProcedure, contract: AnyContractProcedure): AnyProcedure;
577
442
  /**
578
443
  * Directly call a procedure without creating a client.
579
444
  *
@@ -584,20 +449,35 @@ declare function createContractedProcedure(procedure: AnyProcedure, contract: An
584
449
  * ```
585
450
  *
586
451
  */
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>>;
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']>>;
588
453
 
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> : {
590
- [K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
591
- };
454
+ declare function isSchemaIssue(issue: unknown): issue is SchemaIssue;
455
+
456
+ type HTTPEndpoint = `${HTTPMethod} ${HTTPPath}`;
457
+ declare const endpointRegex: RegExp;
592
458
  /**
593
- * Create Server-side client from a router.
594
- *
595
- * @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
459
+ * @internal
596
460
  */
597
- 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>;
598
-
599
- declare function setHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: AnyContractRouter): T;
600
- 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
+ };
601
481
 
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 };
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 };