@temporary-name/server 1.9.3-alpha.6a70825f6d8c3dc99b87e4e5b778aea0fa007417 → 1.9.3-alpha.6a735c9469d995338b7d51335ea70485e18a4dca

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/adapters/aws-lambda/index.d.mts +5 -7
  2. package/dist/adapters/aws-lambda/index.d.ts +5 -7
  3. package/dist/adapters/aws-lambda/index.mjs +4 -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 +16 -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 +14 -122
  10. package/dist/{adapters/standard → handler}/index.d.mts +5 -7
  11. package/dist/{adapters/standard → handler}/index.d.ts +5 -7
  12. package/dist/handler/index.mjs +8 -0
  13. package/dist/helpers/index.mjs +3 -29
  14. package/dist/index.d.mts +368 -202
  15. package/dist/index.d.ts +368 -202
  16. package/dist/index.mjs +462 -176
  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 -369
  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 -31
  32. package/dist/adapters/standard/index.mjs +0 -10
  33. package/dist/plugins/index.d.mts +0 -160
  34. package/dist/plugins/index.d.ts +0 -160
  35. package/dist/plugins/index.mjs +0 -288
  36. package/dist/shared/server.BCcLYvdF.d.mts +0 -56
  37. package/dist/shared/server.CHV9AQHl.mjs +0 -412
  38. package/dist/shared/server.CdeqmULw.d.ts +0 -56
  39. package/dist/shared/server.DHezmW6C.d.mts +0 -23
  40. package/dist/shared/server.DN9mVGfv.mjs +0 -11
  41. package/dist/shared/server.DWwaAM-a.mjs +0 -255
  42. package/dist/shared/server.Da-qLzdU.d.ts +0 -23
  43. package/dist/shared/server.DecvGKtb.d.mts +0 -242
  44. package/dist/shared/server.DecvGKtb.d.ts +0 -242
  45. package/dist/shared/server.JtIZ8YG7.mjs +0 -237
package/dist/index.d.ts CHANGED
@@ -1,45 +1,61 @@
1
- import { Schemas, ErrorMap, Meta, ContractProcedure, MergedErrorMap, AnySchema, AnyShape, MergedSchemas, WrapShape, 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.DecvGKtb.js';
7
- export { U as AccessibleLazyRouter, Z as ContractProcedureCallbackOptions, N as InferRouterCurrentContexts, K as InferRouterInitialContexts, Q as InferRouterInputs, S as InferRouterOutputs, o as LAZY_SYMBOL, p as LazyMeta, _ as LazyTraverseContractProceduresOptions, x as MiddlewareNextFn, w as MiddlewareNextFnOptions, z as MiddlewareOptions, y as MiddlewareOutputFn, v as MiddlewareResult, l as ORPCErrorConstructorMapItem, k as ORPCErrorConstructorMapItemOptions, H as ProcedureClientInterceptorOptions, F as ProcedureDef, D as ProcedureHandlerOptions, Y as TraverseContractProcedureCallbackOptions, X as TraverseContractProceduresOptions, a1 as UnlaziedRouter, V as createAccessibleLazyRouter, n as createORPCErrorConstructorMap, J as createProcedureClient, W as enhanceRouter, t as getLazyMeta, T as getRouter, s as isLazy, G as isProcedure, r as lazy, q as lazyInternal, m as mergeCurrentContext, B as middlewareOutputFn, a0 as resolveContractProcedures, $ as traverseContractProcedures, u as unlazy, a2 as unlazyRouter } from './shared/server.DecvGKtb.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>;
40
- endpoint<U extends AnySchema | AnyShape = core.$ZodType<Record<string, never>, Record<string, never>>>(endpoint: HTTPEndpoint, schema?: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
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, {
41
57
  pathSchema: WrapShape<U>;
42
- }>, TErrorMap, TMeta, TGateName>;
58
+ }>, TMeta, TGateName>;
43
59
  /**
44
60
  * Sets or updates the route definition for the contract.
45
61
  * The provided route is spared-merged with any existing route in the contract.
@@ -48,13 +64,13 @@ declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext
48
64
  * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
49
65
  * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
50
66
  */
51
- endpointOpts(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta, TGateName>;
67
+ endpointOpts(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TMeta, TGateName>;
52
68
  query<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
53
69
  querySchema: WrapShape<U>;
54
- }>, TErrorMap, TMeta, TGateName>;
70
+ }>, TMeta, TGateName>;
55
71
  body<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
56
72
  bodySchema: WrapShape<U>;
57
- }>, TErrorMap, TMeta, TGateName>;
73
+ }>, TMeta, TGateName>;
58
74
  /**
59
75
  * Defines the output validation schema.
60
76
  *
@@ -62,7 +78,7 @@ declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext
62
78
  */
63
79
  output<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
64
80
  outputSchema: WrapShape<U>;
65
- }>, TErrorMap, TMeta, TGateName>;
81
+ }>, TMeta, TGateName>;
66
82
  /**
67
83
  * Uses a middleware to modify the context or improve the pipeline.
68
84
  *
@@ -70,18 +86,20 @@ declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext
70
86
  * @note The current context must be satisfy middleware dependent-context
71
87
  * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
72
88
  */
73
- 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>;
74
92
  useGating<const TInferredGateName extends string>(gates: TInferredGateName[], isGateEnabled: (gate: TInferredGateName, ctx: TCurrentContext) => boolean): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, Context, TCurrentContext>, MergedCurrentContext<TCurrentContext, {
75
93
  isGateEnabled: typeof isGateEnabled;
76
- }>, TSchemas, TErrorMap, TMeta, TInferredGateName>;
94
+ }>, TSchemas, TMeta, TInferredGateName>;
77
95
  /**
78
96
  * Defines the handler of the procedure.
79
97
  *
80
98
  * @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
81
99
  */
82
- 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>;
83
101
  }
84
- 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> {
85
103
  /**
86
104
  * Prefixes all procedures in the router.
87
105
  * The provided prefix is post-appended to any existing router prefix.
@@ -90,205 +108,346 @@ declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentCo
90
108
  *
91
109
  * @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
92
110
  */
93
- prefix(prefix: HTTPPath): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta, TGateName>;
111
+ prefix(prefix: HTTPPath): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TSchemas, TMeta, TGateName>;
94
112
  /**
95
113
  * Adds tags to all procedures in the router.
96
114
  * This helpful when you want to group procedures together in the OpenAPI specification.
97
115
  *
98
116
  * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
99
117
  */
100
- tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
118
+ tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TMeta>;
101
119
  /**
102
120
  * Applies all of the previously defined options to the specified router.
103
121
  *
104
122
  * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
105
123
  */
106
- 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>;
107
125
  }
108
- 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'> {
109
127
  /**
110
128
  * This property holds the defined options.
111
129
  */
112
- '~orpc': EnhanceRouterOptions<TErrorMap>;
130
+ '~orpc': EnhanceRouterOptions;
113
131
  }
114
132
 
115
- 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> {
116
134
  /**
117
135
  * Change the expected input type by providing a map function.
118
136
  */
119
- mapInput<UInput>(map: MapInputMiddleware<UInput, TInput>): DecoratedMiddleware<TInContext, TOutContext, UInput, TOutput, TErrorConstructorMap, TMeta>;
120
- /**
121
- * Concatenates two middlewares.
122
- *
123
- * @info Pass second argument to map the input.
124
- * @see {@link https://orpc.unnoq.com/docs/middleware#concatenation Middleware Concatenation Docs}
125
- */
126
- 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>;
127
- /**
128
- * Concatenates two middlewares.
129
- *
130
- * @info Pass second argument to map the input.
131
- * @see {@link https://orpc.unnoq.com/docs/middleware#concatenation Middleware Concatenation Docs}
132
- */
133
- 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>;
134
138
  }
135
- 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>;
136
140
 
137
- interface BuilderDef<TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TSchemas, TErrorMap, TMeta>, EnhanceRouterOptions<TErrorMap> {
138
- middlewares: readonly AnyMiddleware[];
139
- inputValidationIndex: number;
140
- outputValidationIndex: number;
141
+ interface BuilderDef<TSchemas extends Schemas, TMeta extends Meta> extends ContractDef<TSchemas, TMeta>, EnhanceRouterOptions {
141
142
  }
142
- 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> {
143
144
  /**
144
145
  * Set or override the initial context.
145
146
  *
146
147
  * @see {@link https://orpc.unnoq.com/docs/context Context Docs}
147
148
  */
148
- $context<U extends Context>(): Builder<U, U, TSchemas, TErrorMap, TMeta, TGateName>;
149
+ $context<U extends Context>(): Builder<U, U, TSchemas, TMeta, TGateName>;
149
150
  /**
150
151
  * Creates a middleware.
151
152
  *
152
153
  * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
153
154
  */
154
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
155
- middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, TMeta>;
156
- }
157
- type ApiBuilder<TMeta extends Meta> = Builder<Record<never, never>, Record<never, never>, InitialSchemas, Record<never, never>, TMeta, never>;
158
- interface ApiBuilderOpts<TMeta extends Meta> {
159
- meta?: TMeta;
156
+ middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, TMeta>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, TMeta>;
160
157
  }
161
- declare function createApiBuilder<TMeta extends Meta = Record<never, never>>(opts?: ApiBuilderOpts<TMeta>): ApiBuilder<TMeta>;
162
- 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>;
163
164
 
164
- /**
165
- * Like `DecoratedProcedure`, but removed all method that can change the contract.
166
- */
167
- interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta> {
168
- /**
169
- * Uses a middleware to modify the context or improve the pipeline.
170
- *
171
- * @info Supports both normal middleware and inline middleware implementations.
172
- * @info Pass second argument to map the input.
173
- * @note The current context must be satisfy middleware dependent-context
174
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
175
- */
176
- 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>;
177
- /**
178
- * Uses a middleware to modify the context or improve the pipeline.
179
- *
180
- * @info Supports both normal middleware and inline middleware implementations.
181
- * @info Pass second argument to map the input.
182
- * @note The current context must be satisfy middleware dependent-context
183
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
184
- */
185
- 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[];
186
168
  /**
187
- * Make this procedure callable (works like a function while still being a procedure).
188
- *
189
- * @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
169
+ * @todo require this field in v2
190
170
  */
191
- 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;
192
172
  }
193
173
  /**
194
- * 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}
195
177
  */
196
- interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> {
197
- '~orpc': BuilderDef<TSchemas, TErrorMap, TMeta>;
198
- /**
199
- * Uses a middleware to modify the context or improve the pipeline.
200
- *
201
- * @info Supports both normal middleware and inline middleware implementations.
202
- * @info Pass second argument to map the input.
203
- * @note The current context must be satisfy middleware dependent-context
204
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
205
- */
206
- '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>;
207
- /**
208
- * Uses a middleware to modify the context or improve the pipeline.
209
- *
210
- * @info Supports both normal middleware and inline middleware implementations.
211
- * @info Pass second argument to map the input.
212
- * @note The current context must be satisfy middleware dependent-context
213
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
214
- */
215
- '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>;
216
- /**
217
- * Defines the handler of the procedure.
218
- *
219
- * @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
220
- */
221
- '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);
222
182
  }
223
183
 
224
- interface RouterImplementerWithMiddlewares<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
225
- /**
226
- * Uses a middleware to modify the context or improve the pipeline.
227
- *
228
- * @info Supports both normal middleware and inline middleware implementations.
229
- * @note The current context must be satisfy middleware dependent-context
230
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
231
- */
232
- 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>>;
233
- /**
234
- * Applies all of the previously defined options to the specified router.
235
- * And enforces the router match the contract.
236
- *
237
- * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
238
- */
239
- router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
184
+ interface EventIteratorSchemaDetails {
185
+ yields: AnySchema;
186
+ returns?: AnySchema;
240
187
  }
241
- 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> & {
242
- [K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternalWithMiddlewares<TContract[K], TInitialContext, TCurrentContext> : never;
243
- };
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;
244
195
 
245
- interface RouterImplementer<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
246
- /**
247
- * Creates a middleware.
248
- *
249
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
250
- */
251
- middleware<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
252
- middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, InferContractRouterMeta<T>>;
253
- /**
254
- * Uses a middleware to modify the context or improve the pipeline.
255
- *
256
- * @info Supports both normal middleware and inline middleware implementations.
257
- * @note The current context must be satisfy middleware dependent-context
258
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
259
- */
260
- 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>>;
261
- /**
262
- * Applies all of the previously defined options to the specified router.
263
- * And enforces the router match the contract.
264
- *
265
- * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
266
- */
267
- router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
268
- /**
269
- * Create a lazy router
270
- * And applies all of the previously defined options to the specified router.
271
- * And enforces the router match the contract.
272
- *
273
- * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
274
- */
275
- lazyRoute<U extends Router<T, TCurrentContext>>(loader: () => Promise<{
276
- default: U;
277
- }>): 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"
278
204
  }
279
- 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> & {
280
- [K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternal<TContract[K], TInitialContext, TCurrentContext> : never;
281
- };
282
- declare function implementerInternal<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context>(contract: T, middlewares: AnyMiddleware[]): ImplementerInternal<T, TInitialContext, TCurrentContext>;
283
- type Implementer<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = {
284
- /**
285
- * Set or override the initial context.
286
- *
287
- * @see {@link https://orpc.unnoq.com/docs/context Context Docs}
288
- */
289
- $context<U extends Context>(): Implementer<TContract, U, U>;
290
- } & ImplementerInternal<TContract, TInitialContext, TCurrentContext>;
291
- 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>>>;
292
451
 
293
452
  declare function isStartWithMiddlewares(middlewares: readonly AnyMiddleware[], compare: readonly AnyMiddleware[]): boolean;
294
453
  declare function mergeMiddlewares(first: readonly AnyMiddleware[], second: readonly AnyMiddleware[], options: {
@@ -297,10 +456,6 @@ declare function mergeMiddlewares(first: readonly AnyMiddleware[], second: reado
297
456
  declare function addMiddleware(middlewares: readonly AnyMiddleware[], addition: AnyMiddleware): AnyMiddleware[];
298
457
 
299
458
  declare function createAssertedLazyProcedure(lazied: Lazy<any>): Lazy<AnyProcedure>;
300
- /**
301
- * Create a new procedure that ensure the contract is applied to the procedure.
302
- */
303
- declare function createContractedProcedure(procedure: AnyProcedure, contract: AnyContractProcedure): AnyProcedure;
304
459
  /**
305
460
  * Directly call a procedure without creating a client.
306
461
  *
@@ -311,20 +466,31 @@ declare function createContractedProcedure(procedure: AnyProcedure, contract: An
311
466
  * ```
312
467
  *
313
468
  */
314
- 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']>>;
315
470
 
316
- 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> : {
317
- [K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
318
- };
471
+ declare function isSchemaIssue(issue: unknown): issue is SchemaIssue;
472
+
473
+ type HTTPEndpoint = `${HTTPMethod} ${HTTPPath}`;
474
+ declare const endpointRegex: RegExp;
319
475
  /**
320
- * Create Server-side client from a router.
321
- *
322
- * @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
476
+ * @internal
323
477
  */
324
- 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>;
325
-
326
- declare function setHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: AnyContractRouter): T;
327
- 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
+ };
328
494
 
329
- 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 };
330
- 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 };