@temporary-name/server 1.9.3-alpha.592ae1e02e18c5274906b132313b083116248636 → 1.9.3-alpha.5bb5db108c105334106e6177e3043b9c45fbe69c
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 +6 -9
- package/dist/adapters/fetch/index.d.mts +8 -86
- package/dist/adapters/fetch/index.d.ts +8 -86
- package/dist/adapters/fetch/index.mjs +18 -160
- package/dist/adapters/node/index.d.mts +9 -64
- package/dist/adapters/node/index.d.ts +9 -64
- package/dist/adapters/node/index.mjs +16 -125
- 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 +372 -493
- package/dist/index.d.ts +372 -493
- package/dist/index.mjs +546 -469
- 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 -30
- 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 -11
- 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.BEHw7Eyx.mjs +0 -247
- package/dist/shared/server.BKSOrA6h.d.mts +0 -192
- package/dist/shared/server.BKSOrA6h.d.ts +0 -192
- package/dist/shared/server.BKh8I1Ny.mjs +0 -239
- package/dist/shared/server.BeuTpcmO.d.mts +0 -23
- package/dist/shared/server.C1fnTLq0.d.mts +0 -57
- package/dist/shared/server.CQyYNJ1H.d.ts +0 -57
- package/dist/shared/server.DLsti1Pv.mjs +0 -293
- package/dist/shared/server.SLLuK6_v.d.ts +0 -23
package/dist/index.d.ts
CHANGED
|
@@ -1,196 +1,84 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
import {
|
|
6
|
-
export {
|
|
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.js';
|
|
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.js';
|
|
9
|
+
import * as Draft07 from '@temporary-name/interop/json-schema-typed/draft-07';
|
|
10
|
+
import * as Draft2019 from '@temporary-name/interop/json-schema-typed/draft-2019-09';
|
|
11
|
+
import * as Draft2020 from '@temporary-name/interop/json-schema-typed/draft-2020-12';
|
|
12
|
+
export { a as ZodToJsonSchemaConverter, Z as ZodToJsonSchemaConverterOptions } from './shared/server.CjPiuQYH.js';
|
|
13
|
+
import { JSONSchema } from '@temporary-name/server/openapi';
|
|
7
14
|
export { getEventMeta, withEventMeta } from '@temporary-name/standard-server';
|
|
8
15
|
|
|
9
|
-
|
|
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> = {
|
|
10
18
|
/**
|
|
11
|
-
*
|
|
12
|
-
* The provided errors are spared-merged with any existing errors.
|
|
13
|
-
*
|
|
14
|
-
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
15
|
-
*/
|
|
16
|
-
errors<U extends ErrorMap>(errors: U): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
17
|
-
/**
|
|
18
|
-
* Sets or updates the metadata.
|
|
19
|
-
* The provided metadata is spared-merged with any existing metadata.
|
|
20
|
-
*
|
|
21
|
-
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
22
|
-
*/
|
|
23
|
-
meta(meta: TMeta): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
24
|
-
/**
|
|
25
|
-
* Sets or updates the route definition.
|
|
26
|
-
* The provided route is spared-merged with any existing route.
|
|
27
|
-
* This option is typically relevant when integrating with OpenAPI.
|
|
28
|
-
*
|
|
29
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
30
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
19
|
+
* This is helpful for logging and analytics.
|
|
31
20
|
*/
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
* @info Pass second argument to map the input.
|
|
47
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
48
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
49
|
-
*/
|
|
50
|
-
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>): DecoratedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
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> {
|
|
51
35
|
/**
|
|
52
36
|
* Make this procedure callable (works like a function while still being a procedure).
|
|
53
37
|
*
|
|
54
38
|
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
55
39
|
*/
|
|
56
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext,
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
|
|
60
|
-
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> & {
|
|
61
|
-
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? AccessibleLazyRouter<T[K]> : never;
|
|
62
|
-
};
|
|
63
|
-
declare function createAccessibleLazyRouter<T extends Lazy<AnyRouter | undefined>>(lazied: T): AccessibleLazyRouter<T>;
|
|
64
|
-
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> : {
|
|
65
|
-
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? EnhancedRouter<T[K], TInitialContext, TCurrentContext, TErrorMap> : never;
|
|
66
|
-
};
|
|
67
|
-
interface EnhanceRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
|
|
68
|
-
middlewares: readonly AnyMiddleware[];
|
|
69
|
-
errorMap: TErrorMap;
|
|
70
|
-
dedupeLeadingMiddlewares: boolean;
|
|
71
|
-
}
|
|
72
|
-
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>;
|
|
73
|
-
interface TraverseContractProceduresOptions {
|
|
74
|
-
router: AnyContractRouter | AnyRouter;
|
|
75
|
-
path: readonly string[];
|
|
76
|
-
}
|
|
77
|
-
interface TraverseContractProcedureCallbackOptions {
|
|
78
|
-
contract: AnyContractProcedure | AnyProcedure;
|
|
79
|
-
path: readonly string[];
|
|
40
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TSchemas, TMeta> & ProcedureClient<TClientContext, TSchemas>;
|
|
80
41
|
}
|
|
81
|
-
/**
|
|
82
|
-
* @deprecated Use `TraverseContractProcedureCallbackOptions` instead.
|
|
83
|
-
*/
|
|
84
|
-
type ContractProcedureCallbackOptions = TraverseContractProcedureCallbackOptions;
|
|
85
|
-
interface LazyTraverseContractProceduresOptions {
|
|
86
|
-
router: Lazy<AnyRouter>;
|
|
87
|
-
path: readonly string[];
|
|
88
|
-
}
|
|
89
|
-
declare function traverseContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void, lazyOptions?: LazyTraverseContractProceduresOptions[]): LazyTraverseContractProceduresOptions[];
|
|
90
|
-
declare function resolveContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void): Promise<void>;
|
|
91
|
-
type UnlaziedRouter<T extends AnyRouter> = T extends AnyProcedure ? T : {
|
|
92
|
-
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? UnlaziedRouter<U> : never;
|
|
93
|
-
};
|
|
94
|
-
declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedRouter<T>>;
|
|
95
42
|
|
|
96
|
-
|
|
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>);
|
|
97
46
|
/**
|
|
98
|
-
*
|
|
99
|
-
|
|
100
|
-
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
101
|
-
/**
|
|
102
|
-
* Adds type-safe custom errors.
|
|
103
|
-
* The provided errors are spared-merged with any existing errors.
|
|
104
|
-
*
|
|
105
|
-
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
106
|
-
*/
|
|
107
|
-
'errors'<U extends ErrorMap>(errors: U): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta, TGateName>;
|
|
108
|
-
/**
|
|
109
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
110
|
-
*
|
|
111
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
112
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
113
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
114
|
-
*/
|
|
115
|
-
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
116
|
-
/**
|
|
117
|
-
* Sets or updates the metadata.
|
|
118
|
-
* The provided metadata is spared-merged with any existing metadata.
|
|
47
|
+
* Sets or updates the metadata for the contract.
|
|
48
|
+
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
119
49
|
*
|
|
120
50
|
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
121
51
|
*/
|
|
122
|
-
|
|
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>;
|
|
123
59
|
/**
|
|
124
|
-
* Sets or updates the route definition.
|
|
125
|
-
* The provided route is spared-merged with any existing route.
|
|
60
|
+
* Sets or updates the route definition for the contract.
|
|
61
|
+
* The provided route is spared-merged with any existing route in the contract.
|
|
126
62
|
* This option is typically relevant when integrating with OpenAPI.
|
|
127
63
|
*
|
|
128
64
|
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
129
65
|
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
130
66
|
*/
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
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>;
|
|
138
74
|
/**
|
|
139
75
|
* Defines the output validation schema.
|
|
140
76
|
*
|
|
141
77
|
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
|
|
142
78
|
*/
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
*
|
|
147
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
148
|
-
*/
|
|
149
|
-
'handler'<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
|
150
|
-
/**
|
|
151
|
-
* Prefixes all procedures in the router.
|
|
152
|
-
* The provided prefix is post-appended to any existing router prefix.
|
|
153
|
-
*
|
|
154
|
-
* @note This option does not affect procedures that do not define a path in their route definition.
|
|
155
|
-
*
|
|
156
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
157
|
-
*/
|
|
158
|
-
'prefix'(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
|
159
|
-
/**
|
|
160
|
-
* Adds tags to all procedures in the router.
|
|
161
|
-
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
162
|
-
*
|
|
163
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
164
|
-
*/
|
|
165
|
-
'tag'(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
|
166
|
-
/**
|
|
167
|
-
* Applies all of the previously defined options to the specified router.
|
|
168
|
-
*
|
|
169
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
170
|
-
*/
|
|
171
|
-
'router'<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>;
|
|
172
|
-
/**
|
|
173
|
-
* Create a lazy router
|
|
174
|
-
* And applies all of the previously defined options to the specified router.
|
|
175
|
-
*
|
|
176
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
177
|
-
*/
|
|
178
|
-
'lazyRoute'<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(loader: () => Promise<{
|
|
179
|
-
default: U;
|
|
180
|
-
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, TErrorMap>;
|
|
181
|
-
}
|
|
182
|
-
interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> {
|
|
183
|
-
/**
|
|
184
|
-
* This property holds the defined options.
|
|
185
|
-
*/
|
|
186
|
-
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
187
|
-
/**
|
|
188
|
-
* Adds type-safe custom errors.
|
|
189
|
-
* The provided errors are spared-merged with any existing errors.
|
|
190
|
-
*
|
|
191
|
-
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
192
|
-
*/
|
|
193
|
-
'errors'<U extends ErrorMap>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta, TGateName>;
|
|
79
|
+
output<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
80
|
+
outputSchema: WrapShape<U>;
|
|
81
|
+
}>, TMeta, TGateName>;
|
|
194
82
|
/**
|
|
195
83
|
* Uses a middleware to modify the context or improve the pipeline.
|
|
196
84
|
*
|
|
@@ -198,62 +86,21 @@ interface ProcedureBuilder<TInitialContext extends Context, TCurrentContext exte
|
|
|
198
86
|
* @note The current context must be satisfy middleware dependent-context
|
|
199
87
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
200
88
|
*/
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
'meta'(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
209
|
-
/**
|
|
210
|
-
* Sets or updates the route definition.
|
|
211
|
-
* The provided route is spared-merged with any existing route.
|
|
212
|
-
* This option is typically relevant when integrating with OpenAPI.
|
|
213
|
-
*
|
|
214
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
215
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
216
|
-
*/
|
|
217
|
-
'route'(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
218
|
-
/**
|
|
219
|
-
* Defines the input validation schema.
|
|
220
|
-
*
|
|
221
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
|
|
222
|
-
*/
|
|
223
|
-
'input'<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
224
|
-
/**
|
|
225
|
-
* Defines the output validation schema.
|
|
226
|
-
*
|
|
227
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
|
|
228
|
-
*/
|
|
229
|
-
'output'<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta, TGateName>;
|
|
89
|
+
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>>(middleware: Middleware<TCurrentContext, UOutContext, unknown, unknown, TMeta>): ProcedureBuilder<TInitialContext, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TMeta, TGateName>;
|
|
90
|
+
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext, UOutContext, unknown, unknown, TMeta>): ProcedureBuilder<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TMeta, TGateName>;
|
|
91
|
+
useErrors(errorMap: ErrorMap): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TMeta, TGateName>;
|
|
92
|
+
useAuth<TAuthContext extends ValidatedAuthContext = false>(config: AuthConfig<TAuthContext, TCurrentContext, TMeta>): ProcedureBuilder<TInitialContext, BuildContextWithAuth<TCurrentContext, TAuthContext>, TSchemas, TMeta, TGateName>;
|
|
93
|
+
useGating<const TInferredGateName extends string>(gates: TInferredGateName[], isGateEnabled: (gate: TInferredGateName, ctx: TCurrentContext) => boolean): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, Context, TCurrentContext>, MergedCurrentContext<TCurrentContext, {
|
|
94
|
+
isGateEnabled: typeof isGateEnabled;
|
|
95
|
+
}>, TSchemas, TMeta, TInferredGateName>;
|
|
230
96
|
/**
|
|
231
97
|
* Defines the handler of the procedure.
|
|
232
98
|
*
|
|
233
99
|
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
234
100
|
*/
|
|
235
|
-
|
|
101
|
+
handler(handler: ProcedureHandler<TCurrentContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TSchemas, TMeta>;
|
|
236
102
|
}
|
|
237
|
-
|
|
238
|
-
/**
|
|
239
|
-
* This property holds the defined options.
|
|
240
|
-
*/
|
|
241
|
-
'~orpc': EnhanceRouterOptions<TErrorMap>;
|
|
242
|
-
/**
|
|
243
|
-
* Adds type-safe custom errors.
|
|
244
|
-
* The provided errors are spared-merged with any existing errors.
|
|
245
|
-
*
|
|
246
|
-
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
247
|
-
*/
|
|
248
|
-
'errors'<U extends ErrorMap>(errors: U): RouterBuilder<TInitialContext, TCurrentContext, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
249
|
-
/**
|
|
250
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
251
|
-
*
|
|
252
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
253
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
254
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
255
|
-
*/
|
|
256
|
-
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): RouterBuilder<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TErrorMap, TMeta>;
|
|
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> {
|
|
257
104
|
/**
|
|
258
105
|
* Prefixes all procedures in the router.
|
|
259
106
|
* The provided prefix is post-appended to any existing router prefix.
|
|
@@ -262,306 +109,327 @@ interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends
|
|
|
262
109
|
*
|
|
263
110
|
* @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
264
111
|
*/
|
|
265
|
-
|
|
112
|
+
prefix(prefix: HTTPPath): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TSchemas, TMeta, TGateName>;
|
|
266
113
|
/**
|
|
267
114
|
* Adds tags to all procedures in the router.
|
|
268
115
|
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
269
116
|
*
|
|
270
117
|
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
271
118
|
*/
|
|
272
|
-
|
|
119
|
+
tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TMeta>;
|
|
273
120
|
/**
|
|
274
121
|
* Applies all of the previously defined options to the specified router.
|
|
275
122
|
*
|
|
276
123
|
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
277
124
|
*/
|
|
278
|
-
|
|
125
|
+
router<U extends Router<TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext>;
|
|
126
|
+
}
|
|
127
|
+
interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TMeta extends Meta> extends Pick<BuilderWithMiddlewares<TInitialContext, TCurrentContext, any, TMeta, any>, 'prefix' | 'tag' | 'router'> {
|
|
279
128
|
/**
|
|
280
|
-
*
|
|
281
|
-
* And applies all of the previously defined options to the specified router.
|
|
282
|
-
*
|
|
283
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
129
|
+
* This property holds the defined options.
|
|
284
130
|
*/
|
|
285
|
-
'
|
|
286
|
-
default: U;
|
|
287
|
-
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, TErrorMap>;
|
|
131
|
+
'~orpc': EnhanceRouterOptions;
|
|
288
132
|
}
|
|
289
133
|
|
|
290
|
-
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> {
|
|
291
135
|
/**
|
|
292
136
|
* Change the expected input type by providing a map function.
|
|
293
137
|
*/
|
|
294
|
-
mapInput<UInput>(map: MapInputMiddleware<UInput, TInput>): DecoratedMiddleware<TInContext, TOutContext, UInput, TOutput,
|
|
295
|
-
/**
|
|
296
|
-
* Concatenates two middlewares.
|
|
297
|
-
*
|
|
298
|
-
* @info Pass second argument to map the input.
|
|
299
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware#concatenation Middleware Concatenation Docs}
|
|
300
|
-
*/
|
|
301
|
-
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>;
|
|
302
|
-
/**
|
|
303
|
-
* Concatenates two middlewares.
|
|
304
|
-
*
|
|
305
|
-
* @info Pass second argument to map the input.
|
|
306
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware#concatenation Middleware Concatenation Docs}
|
|
307
|
-
*/
|
|
308
|
-
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>;
|
|
309
139
|
}
|
|
310
|
-
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>;
|
|
311
141
|
|
|
312
|
-
interface BuilderDef<
|
|
313
|
-
middlewares: readonly AnyMiddleware[];
|
|
314
|
-
inputValidationIndex: number;
|
|
315
|
-
outputValidationIndex: number;
|
|
142
|
+
interface BuilderDef<TSchemas extends Schemas, TMeta extends Meta> extends ContractDef<TSchemas, TMeta>, EnhanceRouterOptions {
|
|
316
143
|
}
|
|
317
|
-
declare class Builder<TInitialContext extends Context, TCurrentContext extends Context,
|
|
318
|
-
/**
|
|
319
|
-
* This property holds the defined options.
|
|
320
|
-
*/
|
|
321
|
-
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
322
|
-
constructor(def: BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>);
|
|
144
|
+
declare class Builder<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TMeta extends Meta, TGateName extends string> extends BuilderWithMiddlewares<TInitialContext, TCurrentContext, TSchemas, TMeta, TGateName> {
|
|
323
145
|
/**
|
|
324
146
|
* Set or override the initial context.
|
|
325
147
|
*
|
|
326
148
|
* @see {@link https://orpc.unnoq.com/docs/context Context Docs}
|
|
327
149
|
*/
|
|
328
|
-
$context<U extends Context>(): Builder<U
|
|
150
|
+
$context<U extends Context>(): Builder<U, U, TSchemas, TMeta, TGateName>;
|
|
329
151
|
/**
|
|
330
152
|
* Creates a middleware.
|
|
331
153
|
*
|
|
332
154
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
333
155
|
*/
|
|
334
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
|
|
335
|
-
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput,
|
|
336
|
-
/**
|
|
337
|
-
* Adds type-safe custom errors.
|
|
338
|
-
* The provided errors are spared-merged with any existing errors.
|
|
339
|
-
*
|
|
340
|
-
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
341
|
-
*/
|
|
342
|
-
errors<U extends ErrorMap>(errors: U): Builder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta, TGateName>;
|
|
343
|
-
/**
|
|
344
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
345
|
-
*
|
|
346
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
347
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
348
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
349
|
-
*/
|
|
350
|
-
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<TErrorMap>, TMeta>): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
351
|
-
useGating<const TInferredGateName extends string>(gates: TInferredGateName[], isGateEnabled: (gate: TInferredGateName, ctx: TCurrentContext) => boolean): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, Context, TCurrentContext>, MergedCurrentContext<TCurrentContext, {
|
|
352
|
-
isGateEnabled: typeof isGateEnabled;
|
|
353
|
-
}>, TInputSchema, TOutputSchema, TErrorMap, TMeta, TInferredGateName>;
|
|
354
|
-
/**
|
|
355
|
-
* Sets or updates the metadata.
|
|
356
|
-
* The provided metadata is spared-merged with any existing metadata.
|
|
357
|
-
*
|
|
358
|
-
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
359
|
-
*/
|
|
360
|
-
meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
361
|
-
/**
|
|
362
|
-
* Sets or updates the route definition.
|
|
363
|
-
* The provided route is spared-merged with any existing route.
|
|
364
|
-
* This option is typically relevant when integrating with OpenAPI.
|
|
365
|
-
*
|
|
366
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
367
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
368
|
-
*/
|
|
369
|
-
route(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
370
|
-
/**
|
|
371
|
-
* Defines the input validation schema.
|
|
372
|
-
*
|
|
373
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Input Validation Docs}
|
|
374
|
-
*/
|
|
375
|
-
input<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext, USchema, TOutputSchema, TErrorMap, TMeta, TGateName>;
|
|
376
|
-
/**
|
|
377
|
-
* Defines the output validation schema.
|
|
378
|
-
*
|
|
379
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
|
|
380
|
-
*/
|
|
381
|
-
output<USchema extends AnySchema>(schema: USchema): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, USchema, TErrorMap, TMeta, TGateName>;
|
|
382
|
-
/**
|
|
383
|
-
* Defines the handler of the procedure.
|
|
384
|
-
*
|
|
385
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
386
|
-
*/
|
|
387
|
-
handler<UFuncOutput>(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, UFuncOutput, TErrorMap, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, Schema<UFuncOutput, UFuncOutput>, TErrorMap, TMeta>;
|
|
388
|
-
/**
|
|
389
|
-
* Prefixes all procedures in the router.
|
|
390
|
-
* The provided prefix is post-appended to any existing router prefix.
|
|
391
|
-
*
|
|
392
|
-
* @note This option does not affect procedures that do not define a path in their route definition.
|
|
393
|
-
*
|
|
394
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
395
|
-
*/
|
|
396
|
-
prefix(prefix: HTTPPath): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
|
397
|
-
/**
|
|
398
|
-
* Adds tags to all procedures in the router.
|
|
399
|
-
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
400
|
-
*
|
|
401
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
402
|
-
*/
|
|
403
|
-
tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TErrorMap, TMeta>;
|
|
404
|
-
/**
|
|
405
|
-
* Applies all of the previously defined options to the specified router.
|
|
406
|
-
*
|
|
407
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
408
|
-
*/
|
|
409
|
-
router<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>;
|
|
410
|
-
/**
|
|
411
|
-
* Create a lazy router
|
|
412
|
-
* And applies all of the previously defined options to the specified router.
|
|
413
|
-
*
|
|
414
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
415
|
-
*/
|
|
416
|
-
lazyRoute<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(loader: () => Promise<{
|
|
417
|
-
default: U;
|
|
418
|
-
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, TErrorMap>;
|
|
419
|
-
}
|
|
420
|
-
type ApiBuilder<TMeta extends Meta> = Builder<Record<never, never>, Record<never, never>, Schema<unknown, unknown>, Schema<unknown, unknown>, Record<never, never>, TMeta, never>;
|
|
421
|
-
interface ApiBuilderOpts<TMeta extends Meta> {
|
|
422
|
-
meta?: TMeta;
|
|
157
|
+
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, TMeta>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, TMeta>;
|
|
423
158
|
}
|
|
424
|
-
declare
|
|
425
|
-
|
|
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>;
|
|
426
165
|
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
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> {
|
|
431
|
-
/**
|
|
432
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
433
|
-
*
|
|
434
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
435
|
-
* @info Pass second argument to map the input.
|
|
436
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
437
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
438
|
-
*/
|
|
439
|
-
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>;
|
|
440
|
-
/**
|
|
441
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
442
|
-
*
|
|
443
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
444
|
-
* @info Pass second argument to map the input.
|
|
445
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
446
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
447
|
-
*/
|
|
448
|
-
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>;
|
|
449
|
-
/**
|
|
450
|
-
* Make this procedure callable (works like a function while still being a procedure).
|
|
451
|
-
*
|
|
452
|
-
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
453
|
-
*/
|
|
454
|
-
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;
|
|
455
169
|
}
|
|
456
170
|
/**
|
|
457
|
-
*
|
|
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}
|
|
458
174
|
*/
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
/**
|
|
462
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
463
|
-
*
|
|
464
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
465
|
-
* @info Pass second argument to map the input.
|
|
466
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
467
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
468
|
-
*/
|
|
469
|
-
'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>;
|
|
470
|
-
/**
|
|
471
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
472
|
-
*
|
|
473
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
474
|
-
* @info Pass second argument to map the input.
|
|
475
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
476
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
477
|
-
*/
|
|
478
|
-
'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>;
|
|
479
|
-
/**
|
|
480
|
-
* Defines the handler of the procedure.
|
|
481
|
-
*
|
|
482
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
483
|
-
*/
|
|
484
|
-
'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
485
|
-
}
|
|
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;
|
|
486
177
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
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>>;
|
|
496
|
-
/**
|
|
497
|
-
* Applies all of the previously defined options to the specified router.
|
|
498
|
-
* And enforces the router match the contract.
|
|
499
|
-
*
|
|
500
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
501
|
-
*/
|
|
502
|
-
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
503
|
-
/**
|
|
504
|
-
* Create a lazy router
|
|
505
|
-
* And applies all of the previously defined options to the specified router.
|
|
506
|
-
* And enforces the router match the contract.
|
|
507
|
-
*
|
|
508
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
509
|
-
*/
|
|
510
|
-
lazyRoute<U extends Router<T, TInitialContext>>(loader: () => Promise<{
|
|
511
|
-
default: U;
|
|
512
|
-
}>): 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"
|
|
513
186
|
}
|
|
514
|
-
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> & {
|
|
515
|
-
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternalWithMiddlewares<TContract[K], TInitialContext, TCurrentContext> : never;
|
|
516
|
-
};
|
|
517
187
|
|
|
518
|
-
interface
|
|
519
|
-
|
|
520
|
-
* Creates a middleware.
|
|
521
|
-
*
|
|
522
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
523
|
-
*/
|
|
524
|
-
middleware<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
|
525
|
-
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, InferContractRouterMeta<T>>;
|
|
526
|
-
/**
|
|
527
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
528
|
-
*
|
|
529
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
530
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
531
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
532
|
-
*/
|
|
533
|
-
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>>;
|
|
534
|
-
/**
|
|
535
|
-
* Applies all of the previously defined options to the specified router.
|
|
536
|
-
* And enforces the router match the contract.
|
|
537
|
-
*
|
|
538
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
539
|
-
*/
|
|
540
|
-
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
541
|
-
/**
|
|
542
|
-
* Create a lazy router
|
|
543
|
-
* And applies all of the previously defined options to the specified router.
|
|
544
|
-
* And enforces the router match the contract.
|
|
545
|
-
*
|
|
546
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
547
|
-
*/
|
|
548
|
-
lazyRoute<U extends Router<T, TCurrentContext>>(loader: () => Promise<{
|
|
549
|
-
default: U;
|
|
550
|
-
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
188
|
+
interface experimental_JsonSchemaCoerceOptions {
|
|
189
|
+
components?: Record<string, JsonSchema>;
|
|
551
190
|
}
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
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>>>;
|
|
565
433
|
|
|
566
434
|
declare function isStartWithMiddlewares(middlewares: readonly AnyMiddleware[], compare: readonly AnyMiddleware[]): boolean;
|
|
567
435
|
declare function mergeMiddlewares(first: readonly AnyMiddleware[], second: readonly AnyMiddleware[], options: {
|
|
@@ -570,10 +438,6 @@ declare function mergeMiddlewares(first: readonly AnyMiddleware[], second: reado
|
|
|
570
438
|
declare function addMiddleware(middlewares: readonly AnyMiddleware[], addition: AnyMiddleware): AnyMiddleware[];
|
|
571
439
|
|
|
572
440
|
declare function createAssertedLazyProcedure(lazied: Lazy<any>): Lazy<AnyProcedure>;
|
|
573
|
-
/**
|
|
574
|
-
* Create a new procedure that ensure the contract is applied to the procedure.
|
|
575
|
-
*/
|
|
576
|
-
declare function createContractedProcedure(procedure: AnyProcedure, contract: AnyContractProcedure): AnyProcedure;
|
|
577
441
|
/**
|
|
578
442
|
* Directly call a procedure without creating a client.
|
|
579
443
|
*
|
|
@@ -584,20 +448,35 @@ declare function createContractedProcedure(procedure: AnyProcedure, contract: An
|
|
|
584
448
|
* ```
|
|
585
449
|
*
|
|
586
450
|
*/
|
|
587
|
-
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']>>;
|
|
588
452
|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
}
|
|
453
|
+
declare function isSchemaIssue(issue: unknown): issue is SchemaIssue;
|
|
454
|
+
|
|
455
|
+
type HTTPEndpoint = `${HTTPMethod} ${HTTPPath}`;
|
|
456
|
+
declare const endpointRegex: RegExp;
|
|
592
457
|
/**
|
|
593
|
-
*
|
|
594
|
-
*
|
|
595
|
-
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
458
|
+
* @internal
|
|
596
459
|
*/
|
|
597
|
-
declare function
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
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
|
+
};
|
|
601
480
|
|
|
602
|
-
export { AnyMiddleware, AnyProcedure,
|
|
603
|
-
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 };
|