@temporary-name/server 1.9.3-alpha.e2d8d164da72fb570c2b14a4fa956c80f9e33cdc → 1.9.3-alpha.edd373b82156a10608d43b19a44b75ae72e72de7

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 +4 -6
  2. package/dist/adapters/aws-lambda/index.d.ts +4 -6
  3. package/dist/adapters/aws-lambda/index.mjs +4 -4
  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 -155
  7. package/dist/adapters/node/index.d.mts +8 -63
  8. package/dist/adapters/node/index.d.ts +8 -63
  9. package/dist/adapters/node/index.mjs +14 -120
  10. package/dist/adapters/standard/index.d.mts +10 -7
  11. package/dist/adapters/standard/index.d.ts +10 -7
  12. package/dist/adapters/standard/index.mjs +4 -4
  13. package/dist/helpers/index.mjs +3 -29
  14. package/dist/index.d.mts +376 -242
  15. package/dist/index.d.ts +376 -242
  16. package/dist/index.mjs +482 -359
  17. package/dist/openapi/index.d.mts +18 -53
  18. package/dist/openapi/index.d.ts +18 -53
  19. package/dist/openapi/index.mjs +337 -347
  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.CQIFwyhc.mjs +40 -0
  25. package/dist/shared/server.CjPiuQYH.d.mts +51 -0
  26. package/dist/shared/server.CjPiuQYH.d.ts +51 -0
  27. package/dist/shared/server.Cq7SBLD5.mjs +403 -0
  28. package/dist/shared/server.DGH2Bq4t.d.mts +41 -0
  29. package/dist/shared/server.nQoUObAJ.d.ts +41 -0
  30. package/dist/shared/server.zsKBRxsz.d.mts +388 -0
  31. package/dist/shared/server.zsKBRxsz.d.ts +388 -0
  32. package/package.json +10 -28
  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.B93y_8tj.d.mts +0 -23
  37. package/dist/shared/server.BYYf0Wn6.mjs +0 -202
  38. package/dist/shared/server.C3RuMHWl.d.mts +0 -192
  39. package/dist/shared/server.C3RuMHWl.d.ts +0 -192
  40. package/dist/shared/server.CT1xhSmE.d.mts +0 -56
  41. package/dist/shared/server.CqTex_jI.mjs +0 -265
  42. package/dist/shared/server.D_fags8X.d.ts +0 -23
  43. package/dist/shared/server.Kxw442A9.mjs +0 -247
  44. package/dist/shared/server.cjcgLdr1.d.ts +0 -56
package/dist/index.d.mts CHANGED
@@ -1,79 +1,61 @@
1
- import { AnySchema, ErrorMap, Meta, EnhanceRouteOptions, MergedErrorMap, AnyContractRouter, AnyContractProcedure, ContractProcedure, Route, InferSchemaOutput, InferSchemaInput, ContractRouter, ContractProcedureDef, Schema, InferContractRouterErrorMap, InferContractRouterMeta, ErrorFromErrorMap } from '@temporary-name/contract';
2
- export { ContractProcedure, ContractProcedureDef, ContractRouter, ErrorMap, ErrorMapItem, InferSchemaInput, InferSchemaOutput, MergedErrorMap, Meta, OutputStructure, Route, Schema, ValidationError, eventIterator, validateORPCError } from '@temporary-name/contract';
3
- import { ClientContext, MaybeOptionalOptions, IntersectPick, HTTPPath, ClientOptions, ClientPromiseResult } from '@temporary-name/shared';
4
- export { AsyncIteratorClass, ClientContext, EventPublisher, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, HTTPMethod, HTTPPath, IntersectPick, ORPCError, Registry, ThrowableError, asyncIteratorToStream as eventIteratorToStream, isDefinedError, onError, onFinish, onStart, onSuccess, safe, streamToAsyncIteratorClass as streamToEventIterator } from '@temporary-name/shared';
5
- import { SchemaClass } from '@temporary-name/zod';
6
- import { C as Context, P as Procedure, a as CreateProcedureClientOptions, b as ProcedureClient, A as AnyMiddleware, L as Lazyable, c as AnyRouter, d as Lazy, e as AnyProcedure, M as MergedInitialContext, f as Middleware, O as ORPCErrorConstructorMap, g as MergedCurrentContext, h as ProcedureHandler, R as Router, i as MapInputMiddleware, I as InferRouterInitialContext } from './shared/server.C3RuMHWl.mjs';
7
- export { H as InferRouterCurrentContexts, G as InferRouterInitialContexts, J as InferRouterInputs, K as InferRouterOutputs, n as LAZY_SYMBOL, o as LazyMeta, v as MiddlewareNextFn, t as MiddlewareNextFnOptions, x as MiddlewareOptions, w as MiddlewareOutputFn, s as MiddlewareResult, k as ORPCErrorConstructorMapItem, j as ORPCErrorConstructorMapItemOptions, E as ProcedureClientInterceptorOptions, B as ProcedureDef, z as ProcedureHandlerOptions, l as createORPCErrorConstructorMap, F as createProcedureClient, r as getLazyMeta, q as isLazy, D as isProcedure, p as lazy, m as mergeCurrentContext, y as middlewareOutputFn, u as unlazy } from './shared/server.C3RuMHWl.mjs';
1
+ import * as z from '@temporary-name/zod';
2
+ import { SchemaClass, core } from '@temporary-name/zod';
3
+ import * as zod_v4_core from 'zod/v4/core';
4
+ import { $input, $output } from 'zod/v4/core';
5
+ import { ClientContext, Value, Promisable, Client, MaybeOptionalOptions, HTTPEndpoint as HTTPEndpoint$1, IntersectPick, HTTPPath, AsyncIteratorClass, ClientOptions, HTTPMethod } from '@temporary-name/shared';
6
+ export { AsyncIteratorClass, ClientContext, EventPublisher, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, HTTPMethod, HTTPPath, IntersectPick, 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.mjs';
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.mjs';
9
+ import * as Draft07 from '@temporary-name/interop/json-schema-typed/draft-07';
10
+ import * as Draft2019 from '@temporary-name/interop/json-schema-typed/draft-2019-09';
11
+ import * as Draft2020 from '@temporary-name/interop/json-schema-typed/draft-2020-12';
12
+ export { a as ZodToJsonSchemaConverter, Z as ZodToJsonSchemaConverterOptions } from './shared/server.CjPiuQYH.mjs';
13
+ import { JSONSchema } from '@temporary-name/server/openapi';
8
14
  export { getEventMeta, withEventMeta } from '@temporary-name/standard-server';
9
15
 
10
- declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> {
16
+ type ProcedureClient<TClientContext extends ClientContext, TSchemas extends Schemas> = Client<TClientContext, InferProcedureClientInputs<TSchemas>, InferSchemaOutput<TSchemas['outputSchema']>>;
17
+ type CreateProcedureClientOptions<TInitialContext extends Context, TClientContext extends ClientContext> = {
11
18
  /**
12
- * Make this procedure callable (works like a function while still being a procedure).
13
- *
14
- * @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
19
+ * This is helpful for logging and analytics.
15
20
  */
16
- callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
17
- }
18
-
19
- declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
20
- type AccessibleLazyRouter<T extends Lazyable<AnyRouter | undefined>> = T extends Lazy<infer U extends AnyRouter | undefined | Lazy<AnyRouter | undefined>> ? AccessibleLazyRouter<U> : T extends AnyProcedure | undefined ? Lazy<T> : Lazy<T> & {
21
- [K in keyof T]: T[K] extends Lazyable<AnyRouter> ? AccessibleLazyRouter<T[K]> : never;
22
- };
23
- declare function createAccessibleLazyRouter<T extends Lazy<AnyRouter | undefined>>(lazied: T): AccessibleLazyRouter<T>;
24
- type EnhancedRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap> = T extends Lazy<infer U extends AnyRouter> ? AccessibleLazyRouter<EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>> : T extends (Procedure<infer UInitialContext, infer UCurrentContext, infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta>) ? Procedure<MergedInitialContext<TInitialContext, UInitialContext, TCurrentContext>, UCurrentContext, UInputSchema, UOutputSchema, MergedErrorMap<TErrorMap, UErrorMap>, UMeta> : {
25
- [K in keyof T]: T[K] extends Lazyable<AnyRouter> ? EnhancedRouter<T[K], TInitialContext, TCurrentContext, TErrorMap> : never;
26
- };
27
- interface EnhanceRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
28
- middlewares: readonly AnyMiddleware[];
29
- errorMap: TErrorMap;
30
- dedupeLeadingMiddlewares: boolean;
31
- }
32
- declare function enhanceRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap>(router: T, options: EnhanceRouterOptions<TErrorMap>): EnhancedRouter<T, TInitialContext, TCurrentContext, TErrorMap>;
33
- interface TraverseContractProceduresOptions {
34
- router: AnyContractRouter | AnyRouter;
35
- path: readonly string[];
36
- }
37
- interface TraverseContractProcedureCallbackOptions {
38
- contract: AnyContractProcedure | AnyProcedure;
39
- path: readonly string[];
40
- }
21
+ path?: readonly string[];
22
+ } & (object extends TInitialContext ? {
23
+ context?: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
24
+ } : {
25
+ context: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
26
+ });
41
27
  /**
42
- * @deprecated Use `TraverseContractProcedureCallbackOptions` instead.
28
+ * Create Server-side client from a procedure.
29
+ *
30
+ * @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
43
31
  */
44
- type ContractProcedureCallbackOptions = TraverseContractProcedureCallbackOptions;
45
- interface LazyTraverseContractProceduresOptions {
46
- router: Lazy<AnyRouter>;
47
- path: readonly string[];
48
- }
49
- declare function traverseContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void, lazyOptions?: LazyTraverseContractProceduresOptions[]): LazyTraverseContractProceduresOptions[];
50
- declare function resolveContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void): Promise<void>;
51
- type UnlaziedRouter<T extends AnyRouter> = T extends AnyProcedure ? T : {
52
- [K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? UnlaziedRouter<U> : never;
53
- };
54
- declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedRouter<T>>;
32
+ declare function createProcedureClient<TInitialContext extends Context, TSchemas extends Schemas, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TSchemas, TMeta>>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TClientContext>>): ProcedureClient<TClientContext, TSchemas>;
55
33
 
56
- declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
57
- z: SchemaClass;
58
- /**
59
- * This property holds the defined options.
60
- */
61
- '~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
62
- constructor(def: BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>);
34
+ declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TSchemas, TMeta> {
63
35
  /**
64
- * Adds type-safe custom errors to the contract.
65
- * The provided errors are spared-merged with any existing errors in the contract.
36
+ * Make this procedure callable (works like a function while still being a procedure).
66
37
  *
67
- * @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
38
+ * @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
68
39
  */
69
- errors<U extends ErrorMap>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta, TGateName>;
40
+ callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TSchemas, TMeta> & ProcedureClient<TClientContext, TSchemas>;
41
+ }
42
+
43
+ declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TMeta extends Meta, TGateName extends string> extends Contract<BuilderDef<TSchemas, TMeta>> {
44
+ z: SchemaClass<TGateName>;
45
+ constructor(def: BuilderDef<TSchemas, TMeta>);
70
46
  /**
71
47
  * Sets or updates the metadata for the contract.
72
48
  * The provided metadata is spared-merged with any existing metadata in the contract.
73
49
  *
74
50
  * @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
75
51
  */
76
- meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
52
+ meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TMeta, TGateName>;
53
+ endpoint<U extends AnyShape[]>(strings: TemplateStringsArray, ...values: [...U]): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
54
+ pathSchema: WrapShape<UnionToIntersection<U>>;
55
+ }>, TMeta, TGateName>;
56
+ endpoint<U extends AnySchema | AnyShape = core.$ZodType<Record<string, never>, Record<string, never>>>(endpoint: HTTPEndpoint$1, schema?: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
57
+ pathSchema: WrapShape<U>;
58
+ }>, TMeta, TGateName>;
77
59
  /**
78
60
  * Sets or updates the route definition for the contract.
79
61
  * The provided route is spared-merged with any existing route in the contract.
@@ -82,19 +64,21 @@ declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext
82
64
  * @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
83
65
  * @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
84
66
  */
85
- route(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
86
- /**
87
- * Defines the input validation schema.
88
- *
89
- * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
90
- */
91
- input<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
67
+ endpointOpts(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TMeta, TGateName>;
68
+ query<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
69
+ querySchema: WrapShape<U>;
70
+ }>, TMeta, TGateName>;
71
+ body<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
72
+ bodySchema: WrapShape<U>;
73
+ }>, TMeta, TGateName>;
92
74
  /**
93
75
  * Defines the output validation schema.
94
76
  *
95
77
  * @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
96
78
  */
97
- output<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta, TGateName>;
79
+ output<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
80
+ outputSchema: WrapShape<U>;
81
+ }>, TMeta, TGateName>;
98
82
  /**
99
83
  * Uses a middleware to modify the context or improve the pipeline.
100
84
  *
@@ -102,18 +86,20 @@ declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext
102
86
  * @note The current context must be satisfy middleware dependent-context
103
87
  * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
104
88
  */
105
- use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureBuilder<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
89
+ use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>>(middleware: Middleware<TCurrentContext, UOutContext, unknown, unknown, TMeta>): ProcedureBuilder<TInitialContext, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TMeta, TGateName>;
90
+ use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, unknown, unknown, TMeta>): ProcedureBuilder<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TMeta, TGateName>;
91
+ useAuth<TAuthContext extends ValidatedAuthContext = false>(config: AuthConfig<TAuthContext, TCurrentContext, TMeta>): ProcedureBuilder<TInitialContext, BuildContextWithAuth<TCurrentContext, TAuthContext>, TSchemas, TMeta, TGateName>;
106
92
  useGating<const TInferredGateName extends string>(gates: TInferredGateName[], isGateEnabled: (gate: TInferredGateName, ctx: TCurrentContext) => boolean): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, Context, TCurrentContext>, MergedCurrentContext<TCurrentContext, {
107
93
  isGateEnabled: typeof isGateEnabled;
108
- }>, TInputSchema, TOutputSchema, TErrorMap, TMeta, TInferredGateName>;
94
+ }>, TSchemas, TMeta, TInferredGateName>;
109
95
  /**
110
96
  * Defines the handler of the procedure.
111
97
  *
112
98
  * @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
113
99
  */
114
- handler(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
100
+ handler(handler: ProcedureHandler<TCurrentContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TSchemas, TMeta>;
115
101
  }
116
- declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> extends ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName> {
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> {
117
103
  /**
118
104
  * Prefixes all procedures in the router.
119
105
  * The provided prefix is post-appended to any existing router prefix.
@@ -122,205 +108,346 @@ declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentCo
122
108
  *
123
109
  * @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
124
110
  */
125
- prefix(prefix: HTTPPath): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
111
+ prefix(prefix: HTTPPath): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TSchemas, TMeta, TGateName>;
126
112
  /**
127
113
  * Adds tags to all procedures in the router.
128
114
  * This helpful when you want to group procedures together in the OpenAPI specification.
129
115
  *
130
116
  * @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
131
117
  */
132
- tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
118
+ tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TMeta>;
133
119
  /**
134
120
  * Applies all of the previously defined options to the specified router.
135
121
  *
136
122
  * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
137
123
  */
138
- 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>;
139
125
  }
140
- interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> extends Pick<BuilderWithMiddlewares<TInitialContext, TCurrentContext, any, any, TErrorMap, TMeta, any>, 'prefix' | 'tag' | 'router'> {
126
+ interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TMeta extends Meta> extends Pick<BuilderWithMiddlewares<TInitialContext, TCurrentContext, any, TMeta, any>, 'prefix' | 'tag' | 'router'> {
141
127
  /**
142
128
  * This property holds the defined options.
143
129
  */
144
- '~orpc': EnhanceRouterOptions<TErrorMap>;
130
+ '~orpc': EnhanceRouterOptions;
145
131
  }
146
132
 
147
- interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> extends Middleware<TInContext, TOutContext, TInput, TOutput, TErrorConstructorMap, TMeta> {
133
+ interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TMeta extends Meta> extends Middleware<TInContext, TOutContext, TInput, TOutput, TMeta> {
148
134
  /**
149
135
  * Change the expected input type by providing a map function.
150
136
  */
151
- mapInput<UInput>(map: MapInputMiddleware<UInput, TInput>): DecoratedMiddleware<TInContext, TOutContext, UInput, TOutput, TErrorConstructorMap, TMeta>;
152
- /**
153
- * Concatenates two middlewares.
154
- *
155
- * @info Pass second argument to map the input.
156
- * @see {@link https://orpc.unnoq.com/docs/middleware#concatenation Middleware Concatenation Docs}
157
- */
158
- concat<UOutContext extends IntersectPick<MergedCurrentContext<TInContext, TOutContext>, UOutContext>, UInput extends TInput, UInContext extends Context = MergedCurrentContext<TInContext, TOutContext>>(middleware: Middleware<UInContext | MergedCurrentContext<TInContext, TOutContext>, UOutContext, UInput, TOutput, TErrorConstructorMap, TMeta>): DecoratedMiddleware<MergedInitialContext<TInContext, UInContext, MergedCurrentContext<TInContext, TOutContext>>, MergedCurrentContext<TOutContext, UOutContext>, UInput, TOutput, TErrorConstructorMap, TMeta>;
159
- /**
160
- * Concatenates two middlewares.
161
- *
162
- * @info Pass second argument to map the input.
163
- * @see {@link https://orpc.unnoq.com/docs/middleware#concatenation Middleware Concatenation Docs}
164
- */
165
- concat<UOutContext extends IntersectPick<MergedCurrentContext<TInContext, TOutContext>, UOutContext>, UInput extends TInput, UMappedInput, UInContext extends Context = MergedCurrentContext<TInContext, TOutContext>>(middleware: Middleware<UInContext | MergedCurrentContext<TInContext, TOutContext>, UOutContext, UMappedInput, TOutput, TErrorConstructorMap, TMeta>, mapInput: MapInputMiddleware<UInput, UMappedInput>): DecoratedMiddleware<MergedInitialContext<TInContext, UInContext, MergedCurrentContext<TInContext, TOutContext>>, MergedCurrentContext<TOutContext, UOutContext>, UInput, TOutput, TErrorConstructorMap, TMeta>;
137
+ mapInput<UInput>(map: MapInputMiddleware<UInput, TInput>): DecoratedMiddleware<TInContext, TOutContext, UInput, TOutput, TMeta>;
166
138
  }
167
- declare function decorateMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta>(middleware: Middleware<TInContext, TOutContext, TInput, TOutput, TErrorConstructorMap, TMeta>): DecoratedMiddleware<TInContext, TOutContext, TInput, TOutput, TErrorConstructorMap, TMeta>;
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>;
168
140
 
169
- interface BuilderDef<TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>, EnhanceRouterOptions<TErrorMap> {
170
- middlewares: readonly AnyMiddleware[];
171
- inputValidationIndex: number;
172
- outputValidationIndex: number;
141
+ interface BuilderDef<TSchemas extends Schemas, TMeta extends Meta> extends ContractDef<TSchemas, TMeta>, EnhanceRouterOptions {
173
142
  }
174
- declare class Builder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> extends BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName> {
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> {
175
144
  /**
176
145
  * Set or override the initial context.
177
146
  *
178
147
  * @see {@link https://orpc.unnoq.com/docs/context Context Docs}
179
148
  */
180
- $context<U extends Context>(): Builder<U, U, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
149
+ $context<U extends Context>(): Builder<U, U, TSchemas, TMeta, TGateName>;
181
150
  /**
182
151
  * Creates a middleware.
183
152
  *
184
153
  * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
185
154
  */
186
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
187
- middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, TMeta>;
156
+ middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, TMeta>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, TMeta>;
188
157
  }
189
- type ApiBuilder<TMeta extends Meta> = Builder<Record<never, never>, Record<never, never>, Schema<unknown, unknown>, Schema<unknown, unknown>, Record<never, never>, TMeta, never>;
190
- interface ApiBuilderOpts<TMeta extends Meta> {
191
- meta?: TMeta;
192
- }
193
- declare function createApiBuilder<TMeta extends Meta = Record<never, never>>(opts?: ApiBuilderOpts<TMeta>): ApiBuilder<TMeta>;
194
- declare const os: ApiBuilder<Record<never, never>>;
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>;
195
164
 
196
- /**
197
- * Like `DecoratedProcedure`, but removed all method that can change the contract.
198
- */
199
- interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> {
165
+ interface ValidationErrorOptions extends ErrorOptions {
166
+ message: string;
167
+ issues: readonly SchemaIssue[];
200
168
  /**
201
- * Uses a middleware to modify the context or improve the pipeline.
202
- *
203
- * @info Supports both normal middleware and inline middleware implementations.
204
- * @info Pass second argument to map the input.
205
- * @note The current context must be satisfy middleware dependent-context
206
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
169
+ * @todo require this field in v2
207
170
  */
208
- use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ImplementedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
209
- /**
210
- * Uses a middleware to modify the context or improve the pipeline.
211
- *
212
- * @info Supports both normal middleware and inline middleware implementations.
213
- * @info Pass second argument to map the input.
214
- * @note The current context must be satisfy middleware dependent-context
215
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
216
- */
217
- use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ImplementedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
218
- /**
219
- * Make this procedure callable (works like a function while still being a procedure).
220
- *
221
- * @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
222
- */
223
- callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
171
+ data?: unknown;
224
172
  }
225
173
  /**
226
- * 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}
227
177
  */
228
- interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
229
- '~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
230
- /**
231
- * Uses a middleware to modify the context or improve the pipeline.
232
- *
233
- * @info Supports both normal middleware and inline middleware implementations.
234
- * @info Pass second argument to map the input.
235
- * @note The current context must be satisfy middleware dependent-context
236
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
237
- */
238
- 'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
239
- /**
240
- * Uses a middleware to modify the context or improve the pipeline.
241
- *
242
- * @info Supports both normal middleware and inline middleware implementations.
243
- * @info Pass second argument to map the input.
244
- * @note The current context must be satisfy middleware dependent-context
245
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
246
- */
247
- 'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
248
- /**
249
- * Defines the handler of the procedure.
250
- *
251
- * @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
252
- */
253
- 'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
178
+ declare class ValidationError extends Error {
179
+ readonly issues: readonly SchemaIssue[];
180
+ readonly data: unknown;
181
+ constructor(options: ValidationErrorOptions);
254
182
  }
255
183
 
256
- interface RouterImplementerWithMiddlewares<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
257
- /**
258
- * Uses a middleware to modify the context or improve the pipeline.
259
- *
260
- * @info Supports both normal middleware and inline middleware implementations.
261
- * @note The current context must be satisfy middleware dependent-context
262
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
263
- */
264
- use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): ImplementerInternalWithMiddlewares<T, MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>>;
265
- /**
266
- * Applies all of the previously defined options to the specified router.
267
- * And enforces the router match the contract.
268
- *
269
- * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
270
- */
271
- router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
184
+ interface EventIteratorSchemaDetails {
185
+ yields: AnySchema;
186
+ returns?: AnySchema;
272
187
  }
273
- type ImplementerInternalWithMiddlewares<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? ProcedureImplementer<TInitialContext, TCurrentContext, UInputSchema, UOutputSchema, UErrorMap, UMeta> : RouterImplementerWithMiddlewares<TContract, TInitialContext, TCurrentContext> & {
274
- [K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternalWithMiddlewares<TContract[K], TInitialContext, TCurrentContext> : never;
275
- };
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;
276
195
 
277
- interface RouterImplementer<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
278
- /**
279
- * Creates a middleware.
280
- *
281
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
282
- */
283
- middleware<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
284
- middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, InferContractRouterMeta<T>>;
285
- /**
286
- * Uses a middleware to modify the context or improve the pipeline.
287
- *
288
- * @info Supports both normal middleware and inline middleware implementations.
289
- * @note The current context must be satisfy middleware dependent-context
290
- * @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
291
- */
292
- use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): ImplementerInternalWithMiddlewares<T, MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>>;
293
- /**
294
- * Applies all of the previously defined options to the specified router.
295
- * And enforces the router match the contract.
296
- *
297
- * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
298
- */
299
- router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
300
- /**
301
- * Create a lazy router
302
- * And applies all of the previously defined options to the specified router.
303
- * And enforces the router match the contract.
304
- *
305
- * @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
306
- */
307
- lazyRoute<U extends Router<T, TCurrentContext>>(loader: () => Promise<{
308
- default: U;
309
- }>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, Record<never, never>>;
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"
310
204
  }
311
- type ImplementerInternal<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? ProcedureImplementer<TInitialContext, TCurrentContext, UInputSchema, UOutputSchema, UErrorMap, UMeta> : RouterImplementer<TContract, TInitialContext, TCurrentContext> & {
312
- [K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternal<TContract[K], TInitialContext, TCurrentContext> : never;
313
- };
314
- declare function implementerInternal<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context>(contract: T, middlewares: AnyMiddleware[]): ImplementerInternal<T, TInitialContext, TCurrentContext>;
315
- type Implementer<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = {
316
- /**
317
- * Set or override the initial context.
318
- *
319
- * @see {@link https://orpc.unnoq.com/docs/context Context Docs}
320
- */
321
- $context<U extends Context>(): Implementer<TContract, U, U>;
322
- } & ImplementerInternal<TContract, TInitialContext, TCurrentContext>;
323
- declare function implement<T extends AnyContractRouter, TContext extends Context = Record<never, never>>(contract: T): Implementer<T, TContext, TContext>;
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>>>;
324
451
 
325
452
  declare function isStartWithMiddlewares(middlewares: readonly AnyMiddleware[], compare: readonly AnyMiddleware[]): boolean;
326
453
  declare function mergeMiddlewares(first: readonly AnyMiddleware[], second: readonly AnyMiddleware[], options: {
@@ -329,10 +456,6 @@ declare function mergeMiddlewares(first: readonly AnyMiddleware[], second: reado
329
456
  declare function addMiddleware(middlewares: readonly AnyMiddleware[], addition: AnyMiddleware): AnyMiddleware[];
330
457
 
331
458
  declare function createAssertedLazyProcedure(lazied: Lazy<any>): Lazy<AnyProcedure>;
332
- /**
333
- * Create a new procedure that ensure the contract is applied to the procedure.
334
- */
335
- declare function createContractedProcedure(procedure: AnyProcedure, contract: AnyContractProcedure): AnyProcedure;
336
459
  /**
337
460
  * Directly call a procedure without creating a client.
338
461
  *
@@ -343,20 +466,31 @@ declare function createContractedProcedure(procedure: AnyProcedure, contract: An
343
466
  * ```
344
467
  *
345
468
  */
346
- declare function call<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta>(procedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, input: InferSchemaInput<TInputSchema>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, Record<never, never>> & Omit<ClientOptions<Record<never, never>>, 'context'>>): ClientPromiseResult<InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
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']>>;
347
470
 
348
- type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Procedure<any, any, infer UInputSchema, infer UOutputSchema, infer UErrorMap, any> ? ProcedureClient<TClientContext, UInputSchema, UOutputSchema, UErrorMap> : {
349
- [K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
350
- };
471
+ declare function isSchemaIssue(issue: unknown): issue is SchemaIssue;
472
+
473
+ type HTTPEndpoint = `${HTTPMethod} ${HTTPPath}`;
474
+ declare const endpointRegex: RegExp;
351
475
  /**
352
- * Create Server-side client from a router.
353
- *
354
- * @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
476
+ * @internal
355
477
  */
356
- declare function createRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>, Schema<unknown, unknown>, ErrorMap, Meta, TClientContext>>): RouterClient<T, TClientContext>;
357
-
358
- declare function setHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: AnyContractRouter): T;
359
- declare function getHiddenRouterContract(router: Lazyable<AnyRouter | AnyContractRouter>): AnyContractRouter | undefined;
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
+ };
360
494
 
361
- export { AnyMiddleware, AnyProcedure, AnyRouter, Builder, BuilderWithMiddlewares, Context, CreateProcedureClientOptions, DecoratedProcedure, InferRouterInitialContext, Lazy, Lazyable, MapInputMiddleware, MergedCurrentContext, MergedInitialContext, Middleware, ORPCErrorConstructorMap, Procedure, ProcedureBuilder, ProcedureClient, ProcedureHandler, Router, addMiddleware, call, createAccessibleLazyRouter, createApiBuilder, createAssertedLazyProcedure, createContractedProcedure, createRouterClient, decorateMiddleware, enhanceRouter, getHiddenRouterContract, getRouter, implement, implementerInternal, isStartWithMiddlewares, mergeMiddlewares, os, resolveContractProcedures, setHiddenRouterContract, traverseContractProcedures, unlazyRouter };
362
- export type { AccessibleLazyRouter, ApiBuilder, BuilderDef, ContractProcedureCallbackOptions, DecoratedMiddleware, EnhanceRouterOptions, EnhancedRouter, ImplementedProcedure, Implementer, ImplementerInternal, ImplementerInternalWithMiddlewares, LazyTraverseContractProceduresOptions, ProcedureImplementer, RouterBuilder, RouterClient, RouterImplementer, RouterImplementerWithMiddlewares, TraverseContractProcedureCallbackOptions, TraverseContractProceduresOptions, UnlaziedRouter };
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 };