@temporary-name/server 1.9.3-alpha.c13915862ce0feb161cb37a7c0da5ab7d57bd1bf → 1.9.3-alpha.cd9bac3545348e08cfaddb66f59c70d314145115

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