@temporary-name/server 1.9.3-alpha.62445d8d52a6787e7750865cd468fca8cccd3e28 → 1.9.3-alpha.62d88f5cf3908d4411b5278f1824b69334da8072

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