@temporary-name/server 1.9.3-alpha.cf2fe368e72e6a6ab0ce041b812dbf8134f70b0b → 1.9.3-alpha.d0c8ba895f81e5ee5f2f893da0804bd96a5aa41c
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 +4 -4
- package/dist/adapters/fetch/index.d.mts +8 -86
- package/dist/adapters/fetch/index.d.ts +8 -86
- package/dist/adapters/fetch/index.mjs +16 -155
- package/dist/adapters/node/index.d.mts +8 -63
- package/dist/adapters/node/index.d.ts +8 -63
- package/dist/adapters/node/index.mjs +14 -120
- package/dist/adapters/standard/index.d.mts +20 -33
- package/dist/adapters/standard/index.d.ts +20 -33
- package/dist/adapters/standard/index.mjs +4 -4
- package/dist/helpers/index.mjs +3 -29
- package/dist/index.d.mts +113 -280
- package/dist/index.d.ts +113 -280
- package/dist/index.mjs +189 -393
- 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 +9 -27
- 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.B9i6p26R.d.ts +0 -57
- package/dist/shared/server.BEHw7Eyx.mjs +0 -247
- package/dist/shared/server.Bzrdopnd.d.mts +0 -192
- package/dist/shared/server.Bzrdopnd.d.ts +0 -192
- package/dist/shared/server.C-j2WKJz.d.mts +0 -57
- package/dist/shared/server.CYRDznXq.d.ts +0 -23
- package/dist/shared/server.Cp__uvkw.d.mts +0 -23
- package/dist/shared/server.CvI-wPHM.mjs +0 -293
- package/dist/shared/server.NLSomL7m.mjs +0 -202
package/dist/index.d.mts
CHANGED
|
@@ -1,120 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { C as Context, P as Procedure, M as Middleware, O as ORPCErrorConstructorMap, a as MergedInitialContext, b as MergedCurrentContext, c as MapInputMiddleware, d as CreateProcedureClientOptions, e as ProcedureClient, A as AnyMiddleware, L as Lazyable, f as AnyRouter, g as Lazy, h as AnyProcedure, i as ProcedureHandler, R as Router, I as InferRouterInitialContext } from './shared/server.Bzrdopnd.mjs';
|
|
7
|
-
export { H as InferRouterCurrentContexts, G as InferRouterInitialContexts, J as InferRouterInputs, K as InferRouterOutputs, n as LAZY_SYMBOL, o as LazyMeta, v as MiddlewareNextFn, t as MiddlewareNextFnOptions, x as MiddlewareOptions, w as MiddlewareOutputFn, s as MiddlewareResult, k as ORPCErrorConstructorMapItem, j as ORPCErrorConstructorMapItemOptions, E as ProcedureClientInterceptorOptions, B as ProcedureDef, z as ProcedureHandlerOptions, l as createORPCErrorConstructorMap, F as createProcedureClient, r as getLazyMeta, q as isLazy, D as isProcedure, p as lazy, m as mergeCurrentContext, y as middlewareOutputFn, u as unlazy } from './shared/server.Bzrdopnd.mjs';
|
|
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.mjs';
|
|
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.mjs';
|
|
8
6
|
export { getEventMeta, withEventMeta } from '@temporary-name/standard-server';
|
|
9
7
|
|
|
10
|
-
|
|
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> = {
|
|
11
10
|
/**
|
|
12
|
-
*
|
|
13
|
-
* The provided errors are spared-merged with any existing errors.
|
|
14
|
-
*
|
|
15
|
-
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
16
|
-
*/
|
|
17
|
-
errors<U extends ErrorMap>(errors: U): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta>;
|
|
18
|
-
/**
|
|
19
|
-
* Sets or updates the metadata.
|
|
20
|
-
* The provided metadata is spared-merged with any existing metadata.
|
|
21
|
-
*
|
|
22
|
-
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
23
|
-
*/
|
|
24
|
-
meta(meta: TMeta): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
25
|
-
/**
|
|
26
|
-
* Sets or updates the route definition.
|
|
27
|
-
* The provided route is spared-merged with any existing route.
|
|
28
|
-
* This option is typically relevant when integrating with OpenAPI.
|
|
29
|
-
*
|
|
30
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
31
|
-
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
32
|
-
*/
|
|
33
|
-
route(route: Route): DecoratedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
34
|
-
/**
|
|
35
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
36
|
-
*
|
|
37
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
38
|
-
* @info Pass second argument to map the input.
|
|
39
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
40
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
41
|
-
*/
|
|
42
|
-
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): DecoratedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
43
|
-
/**
|
|
44
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
45
|
-
*
|
|
46
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
47
|
-
* @info Pass second argument to map the input.
|
|
48
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
49
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
11
|
+
* This is helpful for logging and analytics.
|
|
50
12
|
*/
|
|
51
|
-
|
|
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> {
|
|
52
27
|
/**
|
|
53
28
|
* Make this procedure callable (works like a function while still being a procedure).
|
|
54
29
|
*
|
|
55
30
|
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
56
31
|
*/
|
|
57
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext,
|
|
32
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TSchemas, TMeta> & ProcedureClient<TClientContext, TSchemas>;
|
|
58
33
|
}
|
|
59
34
|
|
|
60
|
-
declare
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
};
|
|
64
|
-
declare function createAccessibleLazyRouter<T extends Lazy<AnyRouter | undefined>>(lazied: T): AccessibleLazyRouter<T>;
|
|
65
|
-
type EnhancedRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap> = T extends Lazy<infer U extends AnyRouter> ? AccessibleLazyRouter<EnhancedRouter<U, TInitialContext, TCurrentContext, TErrorMap>> : T extends (Procedure<infer UInitialContext, infer UCurrentContext, infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta>) ? Procedure<MergedInitialContext<TInitialContext, UInitialContext, TCurrentContext>, UCurrentContext, UInputSchema, UOutputSchema, MergedErrorMap<TErrorMap, UErrorMap>, UMeta> : {
|
|
66
|
-
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? EnhancedRouter<T[K], TInitialContext, TCurrentContext, TErrorMap> : never;
|
|
67
|
-
};
|
|
68
|
-
interface EnhanceRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
|
|
69
|
-
middlewares: readonly AnyMiddleware[];
|
|
70
|
-
errorMap: TErrorMap;
|
|
71
|
-
dedupeLeadingMiddlewares: boolean;
|
|
72
|
-
}
|
|
73
|
-
declare function enhanceRouter<T extends Lazyable<AnyRouter>, TInitialContext extends Context, TCurrentContext extends Context, TErrorMap extends ErrorMap>(router: T, options: EnhanceRouterOptions<TErrorMap>): EnhancedRouter<T, TInitialContext, TCurrentContext, TErrorMap>;
|
|
74
|
-
interface TraverseContractProceduresOptions {
|
|
75
|
-
router: AnyContractRouter | AnyRouter;
|
|
76
|
-
path: readonly string[];
|
|
77
|
-
}
|
|
78
|
-
interface TraverseContractProcedureCallbackOptions {
|
|
79
|
-
contract: AnyContractProcedure | AnyProcedure;
|
|
80
|
-
path: readonly string[];
|
|
81
|
-
}
|
|
82
|
-
/**
|
|
83
|
-
* @deprecated Use `TraverseContractProcedureCallbackOptions` instead.
|
|
84
|
-
*/
|
|
85
|
-
type ContractProcedureCallbackOptions = TraverseContractProcedureCallbackOptions;
|
|
86
|
-
interface LazyTraverseContractProceduresOptions {
|
|
87
|
-
router: Lazy<AnyRouter>;
|
|
88
|
-
path: readonly string[];
|
|
89
|
-
}
|
|
90
|
-
declare function traverseContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void, lazyOptions?: LazyTraverseContractProceduresOptions[]): LazyTraverseContractProceduresOptions[];
|
|
91
|
-
declare function resolveContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void): Promise<void>;
|
|
92
|
-
type UnlaziedRouter<T extends AnyRouter> = T extends AnyProcedure ? T : {
|
|
93
|
-
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? UnlaziedRouter<U> : never;
|
|
94
|
-
};
|
|
95
|
-
declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedRouter<T>>;
|
|
96
|
-
|
|
97
|
-
declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TGateName extends string> extends ContractProcedure<TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
|
98
|
-
z: SchemaClass;
|
|
99
|
-
/**
|
|
100
|
-
* This property holds the defined options.
|
|
101
|
-
*/
|
|
102
|
-
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
103
|
-
constructor(def: BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>);
|
|
104
|
-
/**
|
|
105
|
-
* Adds type-safe custom errors to the contract.
|
|
106
|
-
* The provided errors are spared-merged with any existing errors in the contract.
|
|
107
|
-
*
|
|
108
|
-
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
109
|
-
*/
|
|
110
|
-
errors<U extends ErrorMap>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta, TGateName>;
|
|
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>);
|
|
111
38
|
/**
|
|
112
39
|
* Sets or updates the metadata for the contract.
|
|
113
40
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
114
41
|
*
|
|
115
42
|
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
116
43
|
*/
|
|
117
|
-
meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext,
|
|
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>;
|
|
118
51
|
/**
|
|
119
52
|
* Sets or updates the route definition for the contract.
|
|
120
53
|
* The provided route is spared-merged with any existing route in the contract.
|
|
@@ -123,19 +56,21 @@ declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext
|
|
|
123
56
|
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
124
57
|
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
125
58
|
*/
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
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>;
|
|
133
66
|
/**
|
|
134
67
|
* Defines the output validation schema.
|
|
135
68
|
*
|
|
136
69
|
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
|
|
137
70
|
*/
|
|
138
|
-
output<
|
|
71
|
+
output<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
72
|
+
outputSchema: WrapShape<U>;
|
|
73
|
+
}>, TMeta, TGateName>;
|
|
139
74
|
/**
|
|
140
75
|
* Uses a middleware to modify the context or improve the pipeline.
|
|
141
76
|
*
|
|
@@ -143,18 +78,19 @@ declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext
|
|
|
143
78
|
* @note The current context must be satisfy middleware dependent-context
|
|
144
79
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
145
80
|
*/
|
|
146
|
-
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>;
|
|
147
83
|
useGating<const TInferredGateName extends string>(gates: TInferredGateName[], isGateEnabled: (gate: TInferredGateName, ctx: TCurrentContext) => boolean): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, Context, TCurrentContext>, MergedCurrentContext<TCurrentContext, {
|
|
148
84
|
isGateEnabled: typeof isGateEnabled;
|
|
149
|
-
}>,
|
|
85
|
+
}>, TSchemas, TMeta, TInferredGateName>;
|
|
150
86
|
/**
|
|
151
87
|
* Defines the handler of the procedure.
|
|
152
88
|
*
|
|
153
89
|
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
154
90
|
*/
|
|
155
|
-
handler
|
|
91
|
+
handler(handler: ProcedureHandler<TCurrentContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TSchemas, TMeta>;
|
|
156
92
|
}
|
|
157
|
-
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> {
|
|
158
94
|
/**
|
|
159
95
|
* Prefixes all procedures in the router.
|
|
160
96
|
* The provided prefix is post-appended to any existing router prefix.
|
|
@@ -163,224 +99,104 @@ declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentCo
|
|
|
163
99
|
*
|
|
164
100
|
* @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
165
101
|
*/
|
|
166
|
-
prefix(prefix: HTTPPath): BuilderWithMiddlewares<TInitialContext, TCurrentContext,
|
|
102
|
+
prefix(prefix: HTTPPath): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TSchemas, TMeta, TGateName>;
|
|
167
103
|
/**
|
|
168
104
|
* Adds tags to all procedures in the router.
|
|
169
105
|
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
170
106
|
*
|
|
171
107
|
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
172
108
|
*/
|
|
173
|
-
tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext,
|
|
109
|
+
tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TMeta>;
|
|
174
110
|
/**
|
|
175
111
|
* Applies all of the previously defined options to the specified router.
|
|
176
112
|
*
|
|
177
113
|
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
178
114
|
*/
|
|
179
|
-
router<U extends Router<
|
|
180
|
-
/**
|
|
181
|
-
* Create a lazy router
|
|
182
|
-
* And applies all of the previously defined options to the specified router.
|
|
183
|
-
*
|
|
184
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
185
|
-
*/
|
|
186
|
-
lazyRoute<U extends Router<ContractRouter<TMeta>, TCurrentContext>>(loader: () => Promise<{
|
|
187
|
-
default: U;
|
|
188
|
-
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, TErrorMap>;
|
|
115
|
+
router<U extends Router<TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext>;
|
|
189
116
|
}
|
|
190
|
-
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'> {
|
|
191
118
|
/**
|
|
192
119
|
* This property holds the defined options.
|
|
193
120
|
*/
|
|
194
|
-
'~orpc': EnhanceRouterOptions
|
|
121
|
+
'~orpc': EnhanceRouterOptions;
|
|
195
122
|
}
|
|
196
123
|
|
|
197
|
-
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> {
|
|
198
125
|
/**
|
|
199
126
|
* Change the expected input type by providing a map function.
|
|
200
127
|
*/
|
|
201
|
-
mapInput<UInput>(map: MapInputMiddleware<UInput, TInput>): DecoratedMiddleware<TInContext, TOutContext, UInput, TOutput,
|
|
128
|
+
mapInput<UInput>(map: MapInputMiddleware<UInput, TInput>): DecoratedMiddleware<TInContext, TOutContext, UInput, TOutput, TMeta>;
|
|
202
129
|
/**
|
|
203
130
|
* Concatenates two middlewares.
|
|
204
131
|
*
|
|
205
132
|
* @info Pass second argument to map the input.
|
|
206
133
|
* @see {@link https://orpc.unnoq.com/docs/middleware#concatenation Middleware Concatenation Docs}
|
|
207
134
|
*/
|
|
208
|
-
concat<UOutContext extends IntersectPick<MergedCurrentContext<TInContext, TOutContext>, UOutContext>, UInput extends TInput, UInContext extends Context = MergedCurrentContext<TInContext, TOutContext>>(middleware: Middleware<UInContext | MergedCurrentContext<TInContext, TOutContext>, UOutContext, UInput, TOutput,
|
|
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>;
|
|
209
136
|
/**
|
|
210
137
|
* Concatenates two middlewares.
|
|
211
138
|
*
|
|
212
139
|
* @info Pass second argument to map the input.
|
|
213
140
|
* @see {@link https://orpc.unnoq.com/docs/middleware#concatenation Middleware Concatenation Docs}
|
|
214
141
|
*/
|
|
215
|
-
concat<UOutContext extends IntersectPick<MergedCurrentContext<TInContext, TOutContext>, UOutContext>, UInput extends TInput, UMappedInput, UInContext extends Context = MergedCurrentContext<TInContext, TOutContext>>(middleware: Middleware<UInContext | MergedCurrentContext<TInContext, TOutContext>, UOutContext, UMappedInput, TOutput,
|
|
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>;
|
|
216
143
|
}
|
|
217
|
-
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>;
|
|
218
145
|
|
|
219
|
-
interface BuilderDef<
|
|
220
|
-
middlewares: readonly AnyMiddleware[];
|
|
221
|
-
inputValidationIndex: number;
|
|
222
|
-
outputValidationIndex: number;
|
|
146
|
+
interface BuilderDef<TSchemas extends Schemas, TMeta extends Meta> extends ContractDef<TSchemas, TMeta>, EnhanceRouterOptions {
|
|
223
147
|
}
|
|
224
|
-
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> {
|
|
225
149
|
/**
|
|
226
150
|
* Set or override the initial context.
|
|
227
151
|
*
|
|
228
152
|
* @see {@link https://orpc.unnoq.com/docs/context Context Docs}
|
|
229
153
|
*/
|
|
230
|
-
$context<U extends Context>(): Builder<U
|
|
154
|
+
$context<U extends Context>(): Builder<U, U, TSchemas, TMeta, TGateName>;
|
|
231
155
|
/**
|
|
232
156
|
* Creates a middleware.
|
|
233
157
|
*
|
|
234
158
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
235
159
|
*/
|
|
236
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
|
|
237
|
-
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput,
|
|
161
|
+
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, TMeta>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, TMeta>;
|
|
238
162
|
}
|
|
239
|
-
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>;
|
|
240
164
|
interface ApiBuilderOpts<TMeta extends Meta> {
|
|
241
165
|
meta?: TMeta;
|
|
242
166
|
}
|
|
243
167
|
declare function createApiBuilder<TMeta extends Meta = Record<never, never>>(opts?: ApiBuilderOpts<TMeta>): ApiBuilder<TMeta>;
|
|
244
168
|
declare const os: ApiBuilder<Record<never, never>>;
|
|
245
169
|
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> {
|
|
170
|
+
interface ValidationErrorOptions extends ErrorOptions {
|
|
171
|
+
message: string;
|
|
172
|
+
issues: readonly SchemaIssue[];
|
|
250
173
|
/**
|
|
251
|
-
*
|
|
252
|
-
*
|
|
253
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
254
|
-
* @info Pass second argument to map the input.
|
|
255
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
256
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
174
|
+
* @todo require this field in v2
|
|
257
175
|
*/
|
|
258
|
-
|
|
259
|
-
/**
|
|
260
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
261
|
-
*
|
|
262
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
263
|
-
* @info Pass second argument to map the input.
|
|
264
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
265
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
266
|
-
*/
|
|
267
|
-
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ImplementedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
268
|
-
/**
|
|
269
|
-
* Make this procedure callable (works like a function while still being a procedure).
|
|
270
|
-
*
|
|
271
|
-
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
272
|
-
*/
|
|
273
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
176
|
+
data?: unknown;
|
|
274
177
|
}
|
|
275
178
|
/**
|
|
276
|
-
*
|
|
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}
|
|
277
182
|
*/
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
*
|
|
283
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
284
|
-
* @info Pass second argument to map the input.
|
|
285
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
286
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
287
|
-
*/
|
|
288
|
-
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
289
|
-
/**
|
|
290
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
291
|
-
*
|
|
292
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
293
|
-
* @info Pass second argument to map the input.
|
|
294
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
295
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
296
|
-
*/
|
|
297
|
-
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TOutputSchema>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferSchemaOutput<TInputSchema>, UInput>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
298
|
-
/**
|
|
299
|
-
* Defines the handler of the procedure.
|
|
300
|
-
*
|
|
301
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
302
|
-
*/
|
|
303
|
-
'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
183
|
+
declare class ValidationError extends Error {
|
|
184
|
+
readonly issues: readonly SchemaIssue[];
|
|
185
|
+
readonly data: unknown;
|
|
186
|
+
constructor(options: ValidationErrorOptions);
|
|
304
187
|
}
|
|
305
188
|
|
|
306
|
-
interface
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
*
|
|
310
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
311
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
312
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
313
|
-
*/
|
|
314
|
-
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): ImplementerInternalWithMiddlewares<T, MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>>;
|
|
315
|
-
/**
|
|
316
|
-
* Applies all of the previously defined options to the specified router.
|
|
317
|
-
* And enforces the router match the contract.
|
|
318
|
-
*
|
|
319
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
320
|
-
*/
|
|
321
|
-
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
322
|
-
/**
|
|
323
|
-
* Create a lazy router
|
|
324
|
-
* And applies all of the previously defined options to the specified router.
|
|
325
|
-
* And enforces the router match the contract.
|
|
326
|
-
*
|
|
327
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
328
|
-
*/
|
|
329
|
-
lazyRoute<U extends Router<T, TInitialContext>>(loader: () => Promise<{
|
|
330
|
-
default: U;
|
|
331
|
-
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
189
|
+
interface EventIteratorSchemaDetails {
|
|
190
|
+
yields: AnySchema;
|
|
191
|
+
returns?: AnySchema;
|
|
332
192
|
}
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
*
|
|
341
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
342
|
-
*/
|
|
343
|
-
middleware<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
|
344
|
-
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, InferContractRouterMeta<T>>;
|
|
345
|
-
/**
|
|
346
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
347
|
-
*
|
|
348
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
349
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
350
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
351
|
-
*/
|
|
352
|
-
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): ImplementerInternalWithMiddlewares<T, MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>>;
|
|
353
|
-
/**
|
|
354
|
-
* Applies all of the previously defined options to the specified router.
|
|
355
|
-
* And enforces the router match the contract.
|
|
356
|
-
*
|
|
357
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
358
|
-
*/
|
|
359
|
-
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
360
|
-
/**
|
|
361
|
-
* Create a lazy router
|
|
362
|
-
* And applies all of the previously defined options to the specified router.
|
|
363
|
-
* And enforces the router match the contract.
|
|
364
|
-
*
|
|
365
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
366
|
-
*/
|
|
367
|
-
lazyRoute<U extends Router<T, TCurrentContext>>(loader: () => Promise<{
|
|
368
|
-
default: U;
|
|
369
|
-
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
370
|
-
}
|
|
371
|
-
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> & {
|
|
372
|
-
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternal<TContract[K], TInitialContext, TCurrentContext> : never;
|
|
373
|
-
};
|
|
374
|
-
declare function implementerInternal<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context>(contract: T, middlewares: AnyMiddleware[]): ImplementerInternal<T, TInitialContext, TCurrentContext>;
|
|
375
|
-
type Implementer<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = {
|
|
376
|
-
/**
|
|
377
|
-
* Set or override the initial context.
|
|
378
|
-
*
|
|
379
|
-
* @see {@link https://orpc.unnoq.com/docs/context Context Docs}
|
|
380
|
-
*/
|
|
381
|
-
$context<U extends Context>(): Implementer<TContract, U & Record<never, never>, U>;
|
|
382
|
-
} & ImplementerInternal<TContract, TInitialContext, TCurrentContext>;
|
|
383
|
-
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;
|
|
384
200
|
|
|
385
201
|
declare function isStartWithMiddlewares(middlewares: readonly AnyMiddleware[], compare: readonly AnyMiddleware[]): boolean;
|
|
386
202
|
declare function mergeMiddlewares(first: readonly AnyMiddleware[], second: readonly AnyMiddleware[], options: {
|
|
@@ -389,10 +205,6 @@ declare function mergeMiddlewares(first: readonly AnyMiddleware[], second: reado
|
|
|
389
205
|
declare function addMiddleware(middlewares: readonly AnyMiddleware[], addition: AnyMiddleware): AnyMiddleware[];
|
|
390
206
|
|
|
391
207
|
declare function createAssertedLazyProcedure(lazied: Lazy<any>): Lazy<AnyProcedure>;
|
|
392
|
-
/**
|
|
393
|
-
* Create a new procedure that ensure the contract is applied to the procedure.
|
|
394
|
-
*/
|
|
395
|
-
declare function createContractedProcedure(procedure: AnyProcedure, contract: AnyContractProcedure): AnyProcedure;
|
|
396
208
|
/**
|
|
397
209
|
* Directly call a procedure without creating a client.
|
|
398
210
|
*
|
|
@@ -403,9 +215,9 @@ declare function createContractedProcedure(procedure: AnyProcedure, contract: An
|
|
|
403
215
|
* ```
|
|
404
216
|
*
|
|
405
217
|
*/
|
|
406
|
-
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']>>;
|
|
407
219
|
|
|
408
|
-
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> : {
|
|
409
221
|
[K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
|
|
410
222
|
};
|
|
411
223
|
/**
|
|
@@ -413,10 +225,31 @@ type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContex
|
|
|
413
225
|
*
|
|
414
226
|
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
415
227
|
*/
|
|
416
|
-
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;
|
|
417
231
|
|
|
418
|
-
|
|
419
|
-
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
|
+
};
|
|
420
253
|
|
|
421
|
-
export { AnyMiddleware, AnyProcedure, AnyRouter, Builder, BuilderWithMiddlewares, Context,
|
|
422
|
-
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 };
|