@temporary-name/server 1.9.3-alpha.65222302f1b71807a849530b3fe0fa0326d3c1a2 → 1.9.3-alpha.6d3c10e7b535aec2de4b812161c8001a916134b9
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 +4 -6
- package/dist/adapters/aws-lambda/index.d.ts +4 -6
- package/dist/adapters/aws-lambda/index.mjs +5 -7
- 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 -158
- package/dist/adapters/node/index.d.mts +8 -63
- package/dist/adapters/node/index.d.ts +8 -63
- package/dist/adapters/node/index.mjs +15 -123
- package/dist/adapters/standard/index.d.mts +20 -33
- package/dist/adapters/standard/index.d.ts +20 -33
- package/dist/adapters/standard/index.mjs +5 -7
- package/dist/helpers/index.mjs +3 -29
- package/dist/index.d.mts +122 -267
- package/dist/index.d.ts +122 -267
- package/dist/index.mjs +214 -380
- package/dist/openapi/index.d.mts +12 -28
- package/dist/openapi/index.d.ts +12 -28
- package/dist/openapi/index.mjs +66 -150
- package/dist/shared/server.BYV-qTJt.d.ts +41 -0
- package/dist/shared/server.C1RJffw4.mjs +30 -0
- package/dist/shared/server.CQIFwyhc.mjs +40 -0
- package/dist/shared/server.CWb33y9B.d.mts +41 -0
- package/dist/shared/server.ChOv1yG3.mjs +319 -0
- package/dist/shared/server.DXzEGRE2.mjs +403 -0
- package/dist/shared/server.DgzAlPjF.mjs +160 -0
- package/dist/shared/server.DimTvmOQ.d.mts +373 -0
- package/dist/shared/server.DimTvmOQ.d.ts +373 -0
- package/dist/shared/server.YUvuxHty.mjs +48 -0
- package/package.json +10 -26
- 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,119 +1,76 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export { H as InferRouterCurrentContexts, G as InferRouterInitialContexts, J as InferRouterInputs, K as InferRouterOutputs, n as LAZY_SYMBOL, o as LazyMeta, v as MiddlewareNextFn, t as MiddlewareNextFnOptions, x as MiddlewareOptions, w as MiddlewareOutputFn, s as MiddlewareResult, k as ORPCErrorConstructorMapItem, j as ORPCErrorConstructorMapItemOptions, E as ProcedureClientInterceptorOptions, B as ProcedureDef, z as ProcedureHandlerOptions, l as createORPCErrorConstructorMap, F as createProcedureClient, r as getLazyMeta, q as isLazy, D as isProcedure, p as lazy, m as mergeCurrentContext, y as middlewareOutputFn, u as unlazy } from './shared/server.BKSOrA6h.js';
|
|
1
|
+
import { ClientContext, Value, Promisable, Client, MaybeOptionalOptions, HTTPEndpoint as HTTPEndpoint$1, IntersectPick, OptionalIfEmpty, HTTPPath, AsyncIteratorClass, ClientOptions, HTTPMethod } from '@temporary-name/shared';
|
|
2
|
+
export { AsyncIteratorClass, ClientContext, EventPublisher, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, HTTPMethod, HTTPPath, IntersectPick, ORPCError, asyncIteratorToStream as eventIteratorToStream, isDefinedError, onError, onFinish, onStart, onSuccess, streamToAsyncIteratorClass as streamToEventIterator } from '@temporary-name/shared';
|
|
3
|
+
import { SchemaClass, core } from '@temporary-name/zod';
|
|
4
|
+
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 MergedInitialContext, g as MergedCurrentContext, h as AuthType, V as ValidatedAuthContext, i as AuthConfig, B as BuildContextWithAuth, j as ProcedureHandler, k as InferHandlerInputs, l as InferSchemaInput, E as EnhanceRouterOptions, m as Router, n as EnhancedRouter, o as MapInputMiddleware, p as ContractDef, q as InitialSchemas, r as SchemaIssue, s as Schema, t as AnyMiddleware, u as Lazy, v as AnyProcedure, w as AnyRouter, x as InferRouterInitialContext } from './shared/server.DimTvmOQ.js';
|
|
5
|
+
export { a8 as AccessibleLazyRouter, $ as AnyContractDef, ad as ContractProcedureCallbackOptions, a2 as ContractRouter, Z as DefaultProcedureHandlerOptions, a4 as InferRouterCurrentContexts, a3 as InferRouterInitialContexts, a5 as InferRouterInputs, a6 as InferRouterOutputs, z as LAZY_SYMBOL, D as LazyMeta, ae as LazyTraverseContractProceduresOptions, Q as MiddlewareNextFn, X as MiddlewareOptions, T as MiddlewareOutputFn, O as MiddlewareResult, a0 as ProcedureDef, _ as ProcedureHandlerOptions, ac as TraverseContractProcedureCallbackOptions, ab as TraverseContractProceduresOptions, aj as TypeRest, ah as UnlaziedRouter, a9 as createAccessibleLazyRouter, aa as enhanceRouter, J as getLazyMeta, a7 as getRouter, ak as initialSchemas, H as isLazy, a1 as isProcedure, G as lazy, F as lazyInternal, y as mergeCurrentContext, N as mergeMeta, Y as middlewareOutputFn, ag as resolveContractProcedures, af as traverseContractProcedures, K as unlazy, ai as unlazyRouter } from './shared/server.DimTvmOQ.js';
|
|
7
6
|
export { getEventMeta, withEventMeta } from '@temporary-name/standard-server';
|
|
8
7
|
|
|
9
|
-
|
|
8
|
+
type ProcedureClient<TClientContext extends ClientContext, TSchemas extends Schemas> = Client<TClientContext, InferProcedureClientInputs<TSchemas>, InferSchemaOutput<TSchemas['outputSchema']>>;
|
|
9
|
+
type CreateProcedureClientOptions<TInitialContext extends Context, TClientContext extends ClientContext> = {
|
|
10
10
|
/**
|
|
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}
|
|
31
|
-
*/
|
|
32
|
-
route(route: Route): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
33
|
-
/**
|
|
34
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
35
|
-
*
|
|
36
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
37
|
-
* @info Pass second argument to map the input.
|
|
38
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
39
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
11
|
+
* This is helpful for logging and analytics.
|
|
40
12
|
*/
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
13
|
+
path?: readonly string[];
|
|
14
|
+
} & (Record<never, never> extends TInitialContext ? {
|
|
15
|
+
context?: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
16
|
+
} : {
|
|
17
|
+
context: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
18
|
+
});
|
|
19
|
+
/**
|
|
20
|
+
* Create Server-side client from a procedure.
|
|
21
|
+
*
|
|
22
|
+
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
23
|
+
*/
|
|
24
|
+
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>;
|
|
25
|
+
|
|
26
|
+
declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TSchemas, TMeta> {
|
|
51
27
|
/**
|
|
52
28
|
* Make this procedure callable (works like a function while still being a procedure).
|
|
53
29
|
*
|
|
54
30
|
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
55
31
|
*/
|
|
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[];
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* @deprecated Use `TraverseContractProcedureCallbackOptions` instead.
|
|
83
|
-
*/
|
|
84
|
-
type ContractProcedureCallbackOptions = TraverseContractProcedureCallbackOptions;
|
|
85
|
-
interface LazyTraverseContractProceduresOptions {
|
|
86
|
-
router: Lazy<AnyRouter>;
|
|
87
|
-
path: readonly string[];
|
|
32
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TSchemas, TMeta> & ProcedureClient<TClientContext, TSchemas>;
|
|
88
33
|
}
|
|
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
34
|
|
|
96
|
-
declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context,
|
|
35
|
+
declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TMeta extends Meta, TGateName extends string> extends Contract<BuilderDef<TSchemas, TMeta>> {
|
|
36
|
+
z: SchemaClass<TGateName>;
|
|
37
|
+
constructor(def: BuilderDef<TSchemas, TMeta>);
|
|
97
38
|
/**
|
|
98
|
-
*
|
|
39
|
+
* Sets or updates the metadata for the contract.
|
|
40
|
+
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
41
|
+
*
|
|
42
|
+
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
99
43
|
*/
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
44
|
+
meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TMeta, TGateName>;
|
|
45
|
+
endpoint<U extends AnyShape[]>(strings: TemplateStringsArray, ...values: [...U]): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
46
|
+
pathSchema: WrapShape<UnionToIntersection<U>>;
|
|
47
|
+
}>, TMeta, TGateName>;
|
|
48
|
+
endpoint<U extends AnySchema | AnyShape = core.$ZodType<Record<string, never>, Record<string, never>>>(endpoint: HTTPEndpoint$1, schema?: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
49
|
+
pathSchema: WrapShape<U>;
|
|
50
|
+
}>, TMeta, TGateName>;
|
|
105
51
|
/**
|
|
106
|
-
*
|
|
52
|
+
* Sets or updates the route definition for the contract.
|
|
53
|
+
* The provided route is spared-merged with any existing route in the contract.
|
|
54
|
+
* This option is typically relevant when integrating with OpenAPI.
|
|
107
55
|
*
|
|
108
|
-
* @see {@link https://orpc.unnoq.com/docs/
|
|
56
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
57
|
+
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
109
58
|
*/
|
|
110
|
-
|
|
59
|
+
endpointOpts(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TMeta, TGateName>;
|
|
60
|
+
query<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
61
|
+
querySchema: WrapShape<U>;
|
|
62
|
+
}>, TMeta, TGateName>;
|
|
63
|
+
body<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
64
|
+
bodySchema: WrapShape<U>;
|
|
65
|
+
}>, TMeta, TGateName>;
|
|
111
66
|
/**
|
|
112
67
|
* Defines the output validation schema.
|
|
113
68
|
*
|
|
114
69
|
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
|
|
115
70
|
*/
|
|
116
|
-
output<
|
|
71
|
+
output<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
72
|
+
outputSchema: WrapShape<U>;
|
|
73
|
+
}>, TMeta, TGateName>;
|
|
117
74
|
/**
|
|
118
75
|
* Uses a middleware to modify the context or improve the pipeline.
|
|
119
76
|
*
|
|
@@ -121,18 +78,19 @@ declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext
|
|
|
121
78
|
* @note The current context must be satisfy middleware dependent-context
|
|
122
79
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
123
80
|
*/
|
|
124
|
-
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown,
|
|
81
|
+
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, TMeta>): ProcedureBuilder<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TMeta, TGateName>;
|
|
82
|
+
useAuth<const TAuthType extends AuthType & {}, TAuthContext extends ValidatedAuthContext = false>(type: TAuthType, ...rest: OptionalIfEmpty<AuthConfig<TAuthType, TAuthContext>>): ProcedureBuilder<TInitialContext, BuildContextWithAuth<TCurrentContext, TAuthContext>, TSchemas, TMeta, TGateName>;
|
|
125
83
|
useGating<const TInferredGateName extends string>(gates: TInferredGateName[], isGateEnabled: (gate: TInferredGateName, ctx: TCurrentContext) => boolean): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, Context, TCurrentContext>, MergedCurrentContext<TCurrentContext, {
|
|
126
84
|
isGateEnabled: typeof isGateEnabled;
|
|
127
|
-
}>,
|
|
85
|
+
}>, TSchemas, TMeta, TInferredGateName>;
|
|
128
86
|
/**
|
|
129
87
|
* Defines the handler of the procedure.
|
|
130
88
|
*
|
|
131
89
|
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
132
90
|
*/
|
|
133
|
-
handler
|
|
91
|
+
handler(handler: ProcedureHandler<TCurrentContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TSchemas, TMeta>;
|
|
134
92
|
}
|
|
135
|
-
declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context,
|
|
93
|
+
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> {
|
|
136
94
|
/**
|
|
137
95
|
* Prefixes all procedures in the router.
|
|
138
96
|
* The provided prefix is post-appended to any existing router prefix.
|
|
@@ -141,224 +99,104 @@ declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentCo
|
|
|
141
99
|
*
|
|
142
100
|
* @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
143
101
|
*/
|
|
144
|
-
prefix(prefix: HTTPPath):
|
|
102
|
+
prefix(prefix: HTTPPath): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TSchemas, TMeta, TGateName>;
|
|
145
103
|
/**
|
|
146
104
|
* Adds tags to all procedures in the router.
|
|
147
105
|
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
148
106
|
*
|
|
149
107
|
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
150
108
|
*/
|
|
151
|
-
tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext,
|
|
109
|
+
tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TMeta>;
|
|
152
110
|
/**
|
|
153
111
|
* Applies all of the previously defined options to the specified router.
|
|
154
112
|
*
|
|
155
113
|
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
156
114
|
*/
|
|
157
|
-
router<U extends Router<
|
|
158
|
-
/**
|
|
159
|
-
* Create a lazy router
|
|
160
|
-
* And applies all of the previously defined options to the specified router.
|
|
161
|
-
*
|
|
162
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
163
|
-
*/
|
|
164
|
-
lazyRoute<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(loader: () => Promise<{
|
|
165
|
-
default: U;
|
|
166
|
-
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, TErrorMap>;
|
|
115
|
+
router<U extends Router<TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext>;
|
|
167
116
|
}
|
|
168
|
-
interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context,
|
|
117
|
+
interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TMeta extends Meta> extends Pick<BuilderWithMiddlewares<TInitialContext, TCurrentContext, any, TMeta, any>, 'prefix' | 'tag' | 'router'> {
|
|
169
118
|
/**
|
|
170
119
|
* This property holds the defined options.
|
|
171
120
|
*/
|
|
172
|
-
'~orpc': EnhanceRouterOptions
|
|
121
|
+
'~orpc': EnhanceRouterOptions;
|
|
173
122
|
}
|
|
174
123
|
|
|
175
|
-
interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput,
|
|
124
|
+
interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TMeta extends Meta> extends Middleware<TInContext, TOutContext, TInput, TOutput, TMeta> {
|
|
176
125
|
/**
|
|
177
126
|
* Change the expected input type by providing a map function.
|
|
178
127
|
*/
|
|
179
|
-
mapInput<UInput>(map: MapInputMiddleware<UInput, TInput>): DecoratedMiddleware<TInContext, TOutContext, UInput, TOutput,
|
|
128
|
+
mapInput<UInput>(map: MapInputMiddleware<UInput, TInput>): DecoratedMiddleware<TInContext, TOutContext, UInput, TOutput, TMeta>;
|
|
180
129
|
/**
|
|
181
130
|
* Concatenates two middlewares.
|
|
182
131
|
*
|
|
183
132
|
* @info Pass second argument to map the input.
|
|
184
133
|
* @see {@link https://orpc.unnoq.com/docs/middleware#concatenation Middleware Concatenation Docs}
|
|
185
134
|
*/
|
|
186
|
-
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,
|
|
135
|
+
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, TMeta>): DecoratedMiddleware<MergedInitialContext<TInContext, UInContext, MergedCurrentContext<TInContext, TOutContext>>, MergedCurrentContext<TOutContext, UOutContext>, UInput, TOutput, TMeta>;
|
|
187
136
|
/**
|
|
188
137
|
* Concatenates two middlewares.
|
|
189
138
|
*
|
|
190
139
|
* @info Pass second argument to map the input.
|
|
191
140
|
* @see {@link https://orpc.unnoq.com/docs/middleware#concatenation Middleware Concatenation Docs}
|
|
192
141
|
*/
|
|
193
|
-
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,
|
|
142
|
+
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, TMeta>, mapInput: MapInputMiddleware<UInput, UMappedInput>): DecoratedMiddleware<MergedInitialContext<TInContext, UInContext, MergedCurrentContext<TInContext, TOutContext>>, MergedCurrentContext<TOutContext, UOutContext>, UInput, TOutput, TMeta>;
|
|
194
143
|
}
|
|
195
|
-
declare function decorateMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput,
|
|
144
|
+
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>;
|
|
196
145
|
|
|
197
|
-
interface BuilderDef<
|
|
198
|
-
middlewares: readonly AnyMiddleware[];
|
|
199
|
-
inputValidationIndex: number;
|
|
200
|
-
outputValidationIndex: number;
|
|
146
|
+
interface BuilderDef<TSchemas extends Schemas, TMeta extends Meta> extends ContractDef<TSchemas, TMeta>, EnhanceRouterOptions {
|
|
201
147
|
}
|
|
202
|
-
declare class Builder<TInitialContext extends Context, TCurrentContext extends Context,
|
|
148
|
+
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> {
|
|
203
149
|
/**
|
|
204
150
|
* Set or override the initial context.
|
|
205
151
|
*
|
|
206
152
|
* @see {@link https://orpc.unnoq.com/docs/context Context Docs}
|
|
207
153
|
*/
|
|
208
|
-
$context<U extends Context>(): Builder<U
|
|
154
|
+
$context<U extends Context>(): Builder<U, U, TSchemas, TMeta, TGateName>;
|
|
209
155
|
/**
|
|
210
156
|
* Creates a middleware.
|
|
211
157
|
*
|
|
212
158
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
213
159
|
*/
|
|
214
160
|
middleware<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
|
215
|
-
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput,
|
|
161
|
+
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, TMeta>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, TMeta>;
|
|
216
162
|
}
|
|
217
|
-
type ApiBuilder<TMeta extends Meta> = Builder<Record<never, never>, Record<never, never>,
|
|
163
|
+
type ApiBuilder<TMeta extends Meta> = Builder<Record<never, never>, Record<never, never>, InitialSchemas, TMeta, never>;
|
|
218
164
|
interface ApiBuilderOpts<TMeta extends Meta> {
|
|
219
165
|
meta?: TMeta;
|
|
220
166
|
}
|
|
221
167
|
declare function createApiBuilder<TMeta extends Meta = Record<never, never>>(opts?: ApiBuilderOpts<TMeta>): ApiBuilder<TMeta>;
|
|
222
168
|
declare const os: ApiBuilder<Record<never, never>>;
|
|
223
169
|
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
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> {
|
|
170
|
+
interface ValidationErrorOptions extends ErrorOptions {
|
|
171
|
+
message: string;
|
|
172
|
+
issues: readonly SchemaIssue[];
|
|
228
173
|
/**
|
|
229
|
-
*
|
|
230
|
-
*
|
|
231
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
232
|
-
* @info Pass second argument to map the input.
|
|
233
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
234
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
235
|
-
*/
|
|
236
|
-
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>;
|
|
237
|
-
/**
|
|
238
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
239
|
-
*
|
|
240
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
241
|
-
* @info Pass second argument to map the input.
|
|
242
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
243
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
174
|
+
* @todo require this field in v2
|
|
244
175
|
*/
|
|
245
|
-
|
|
246
|
-
/**
|
|
247
|
-
* Make this procedure callable (works like a function while still being a procedure).
|
|
248
|
-
*
|
|
249
|
-
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
250
|
-
*/
|
|
251
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
176
|
+
data?: unknown;
|
|
252
177
|
}
|
|
253
178
|
/**
|
|
254
|
-
*
|
|
179
|
+
* This errors usually used for ORPCError.cause when the error is a validation error.
|
|
180
|
+
*
|
|
181
|
+
* @see {@link https://orpc.unnoq.com/docs/advanced/validation-errors Validation Errors Docs}
|
|
255
182
|
*/
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
*
|
|
261
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
262
|
-
* @info Pass second argument to map the input.
|
|
263
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
264
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
265
|
-
*/
|
|
266
|
-
'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>;
|
|
267
|
-
/**
|
|
268
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
269
|
-
*
|
|
270
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
271
|
-
* @info Pass second argument to map the input.
|
|
272
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
273
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
274
|
-
*/
|
|
275
|
-
'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>;
|
|
276
|
-
/**
|
|
277
|
-
* Defines the handler of the procedure.
|
|
278
|
-
*
|
|
279
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
280
|
-
*/
|
|
281
|
-
'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
183
|
+
declare class ValidationError extends Error {
|
|
184
|
+
readonly issues: readonly SchemaIssue[];
|
|
185
|
+
readonly data: unknown;
|
|
186
|
+
constructor(options: ValidationErrorOptions);
|
|
282
187
|
}
|
|
283
188
|
|
|
284
|
-
interface
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
*
|
|
288
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
289
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
290
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
291
|
-
*/
|
|
292
|
-
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): ImplementerInternalWithMiddlewares<T, MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>>;
|
|
293
|
-
/**
|
|
294
|
-
* Applies all of the previously defined options to the specified router.
|
|
295
|
-
* And enforces the router match the contract.
|
|
296
|
-
*
|
|
297
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
298
|
-
*/
|
|
299
|
-
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
300
|
-
/**
|
|
301
|
-
* Create a lazy router
|
|
302
|
-
* And applies all of the previously defined options to the specified router.
|
|
303
|
-
* And enforces the router match the contract.
|
|
304
|
-
*
|
|
305
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
306
|
-
*/
|
|
307
|
-
lazyRoute<U extends Router<T, TInitialContext>>(loader: () => Promise<{
|
|
308
|
-
default: U;
|
|
309
|
-
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
189
|
+
interface EventIteratorSchemaDetails {
|
|
190
|
+
yields: AnySchema;
|
|
191
|
+
returns?: AnySchema;
|
|
310
192
|
}
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
*
|
|
319
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
320
|
-
*/
|
|
321
|
-
middleware<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
|
322
|
-
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, InferContractRouterMeta<T>>;
|
|
323
|
-
/**
|
|
324
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
325
|
-
*
|
|
326
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
327
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
328
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
329
|
-
*/
|
|
330
|
-
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>>;
|
|
331
|
-
/**
|
|
332
|
-
* Applies all of the previously defined options to the specified router.
|
|
333
|
-
* And enforces the router match the contract.
|
|
334
|
-
*
|
|
335
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
336
|
-
*/
|
|
337
|
-
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
338
|
-
/**
|
|
339
|
-
* Create a lazy router
|
|
340
|
-
* And applies all of the previously defined options to the specified router.
|
|
341
|
-
* And enforces the router match the contract.
|
|
342
|
-
*
|
|
343
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
344
|
-
*/
|
|
345
|
-
lazyRoute<U extends Router<T, TCurrentContext>>(loader: () => Promise<{
|
|
346
|
-
default: U;
|
|
347
|
-
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
348
|
-
}
|
|
349
|
-
type ImplementerInternal<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? ProcedureImplementer<TInitialContext, TCurrentContext, UInputSchema, UOutputSchema, UErrorMap, UMeta> : RouterImplementer<TContract, TInitialContext, TCurrentContext> & {
|
|
350
|
-
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternal<TContract[K], TInitialContext, TCurrentContext> : never;
|
|
351
|
-
};
|
|
352
|
-
declare function implementerInternal<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context>(contract: T, middlewares: AnyMiddleware[]): ImplementerInternal<T, TInitialContext, TCurrentContext>;
|
|
353
|
-
type Implementer<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = {
|
|
354
|
-
/**
|
|
355
|
-
* Set or override the initial context.
|
|
356
|
-
*
|
|
357
|
-
* @see {@link https://orpc.unnoq.com/docs/context Context Docs}
|
|
358
|
-
*/
|
|
359
|
-
$context<U extends Context>(): Implementer<TContract, U & Record<never, never>, U>;
|
|
360
|
-
} & ImplementerInternal<TContract, TInitialContext, TCurrentContext>;
|
|
361
|
-
declare function implement<T extends AnyContractRouter, TContext extends Context = Record<never, never>>(contract: T): Implementer<T, TContext, TContext>;
|
|
193
|
+
/**
|
|
194
|
+
* Define schema for an event iterator.
|
|
195
|
+
*
|
|
196
|
+
* @see {@link https://orpc.unnoq.com/docs/event-iterator#validate-event-iterator Validate Event Iterator Docs}
|
|
197
|
+
*/
|
|
198
|
+
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>>;
|
|
199
|
+
declare function getEventIteratorSchemaDetails(schema: AnySchema | undefined): undefined | EventIteratorSchemaDetails;
|
|
362
200
|
|
|
363
201
|
declare function isStartWithMiddlewares(middlewares: readonly AnyMiddleware[], compare: readonly AnyMiddleware[]): boolean;
|
|
364
202
|
declare function mergeMiddlewares(first: readonly AnyMiddleware[], second: readonly AnyMiddleware[], options: {
|
|
@@ -367,10 +205,6 @@ declare function mergeMiddlewares(first: readonly AnyMiddleware[], second: reado
|
|
|
367
205
|
declare function addMiddleware(middlewares: readonly AnyMiddleware[], addition: AnyMiddleware): AnyMiddleware[];
|
|
368
206
|
|
|
369
207
|
declare function createAssertedLazyProcedure(lazied: Lazy<any>): Lazy<AnyProcedure>;
|
|
370
|
-
/**
|
|
371
|
-
* Create a new procedure that ensure the contract is applied to the procedure.
|
|
372
|
-
*/
|
|
373
|
-
declare function createContractedProcedure(procedure: AnyProcedure, contract: AnyContractProcedure): AnyProcedure;
|
|
374
208
|
/**
|
|
375
209
|
* Directly call a procedure without creating a client.
|
|
376
210
|
*
|
|
@@ -381,9 +215,9 @@ declare function createContractedProcedure(procedure: AnyProcedure, contract: An
|
|
|
381
215
|
* ```
|
|
382
216
|
*
|
|
383
217
|
*/
|
|
384
|
-
declare function call<TInitialContext extends Context,
|
|
218
|
+
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, Record<never, never>> & Omit<ClientOptions<Record<never, never>>, 'context'>>): Promise<InferSchemaOutput<TSchemas['outputSchema']>>;
|
|
385
219
|
|
|
386
|
-
type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Procedure<any, any, infer
|
|
220
|
+
type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Procedure<any, any, infer USchemas, any> ? ProcedureClient<TClientContext, USchemas> : {
|
|
387
221
|
[K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
|
|
388
222
|
};
|
|
389
223
|
/**
|
|
@@ -391,10 +225,31 @@ type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContex
|
|
|
391
225
|
*
|
|
392
226
|
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
393
227
|
*/
|
|
394
|
-
declare function createRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>,
|
|
228
|
+
declare function createRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>, TClientContext>>): RouterClient<T, TClientContext>;
|
|
229
|
+
|
|
230
|
+
declare function isSchemaIssue(issue: unknown): issue is SchemaIssue;
|
|
395
231
|
|
|
396
|
-
|
|
397
|
-
declare
|
|
232
|
+
type HTTPEndpoint = `${HTTPMethod} ${HTTPPath}`;
|
|
233
|
+
declare const endpointRegex: RegExp;
|
|
234
|
+
/**
|
|
235
|
+
* @internal
|
|
236
|
+
*/
|
|
237
|
+
declare function standardizeHTTPPath(path: HTTPPath): HTTPPath;
|
|
238
|
+
/**
|
|
239
|
+
* @internal
|
|
240
|
+
*/
|
|
241
|
+
declare function getDynamicParams(path: HTTPPath | undefined): {
|
|
242
|
+
raw: string;
|
|
243
|
+
name: string;
|
|
244
|
+
}[] | undefined;
|
|
245
|
+
/**
|
|
246
|
+
* @internal
|
|
247
|
+
*/
|
|
248
|
+
declare function parseEndpointDefinition(stringsOrEndpoint: TemplateStringsArray | HTTPEndpoint, values: AnyShape[] | [AnySchema | AnyShape] | []): {
|
|
249
|
+
method: HTTPMethod;
|
|
250
|
+
path: HTTPPath;
|
|
251
|
+
pathSchema: AnySchema;
|
|
252
|
+
};
|
|
398
253
|
|
|
399
|
-
export { AnyMiddleware, AnyProcedure, AnyRouter, Builder, BuilderWithMiddlewares, Context,
|
|
400
|
-
export type {
|
|
254
|
+
export { AnyMiddleware, AnyProcedure, AnyRouter, AnySchema, AnyShape, BuildContextWithAuth, Builder, BuilderWithMiddlewares, Context, Contract, ContractDef, DecoratedProcedure, EnhanceRouterOptions, EnhancedRouter, InferHandlerInputs, InferProcedureClientInputs, InferRouterInitialContext, InferSchemaInput, InferSchemaOutput, InitialSchemas, Lazy, Lazyable, MapInputMiddleware, MergedCurrentContext, MergedInitialContext, MergedSchemas, Meta, Middleware, Procedure, ProcedureBuilder, ProcedureHandler, Router, Schema, SchemaIssue, Schemas, UnionToIntersection, ValidationError, WrapShape, addMiddleware, call, createApiBuilder, createAssertedLazyProcedure, createProcedureClient, createRouterClient, decorateMiddleware, endpointRegex, eventIterator, getDynamicParams, getEventIteratorSchemaDetails, isSchemaIssue, isStartWithMiddlewares, mergeMiddlewares, os, parseEndpointDefinition, standardizeHTTPPath };
|
|
255
|
+
export type { ApiBuilder, BuilderDef, CreateProcedureClientOptions, DecoratedMiddleware, EventIteratorSchemaDetails, HTTPEndpoint, ProcedureClient, RouterBuilder, RouterClient, ValidationErrorOptions };
|