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