@temporary-name/server 1.9.3-alpha.6a70825f6d8c3dc99b87e4e5b778aea0fa007417 → 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 +4 -5
- 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 -156
- 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 -121
- package/dist/adapters/standard/index.d.mts +5 -7
- package/dist/adapters/standard/index.d.ts +5 -7
- package/dist/adapters/standard/index.mjs +4 -5
- package/dist/helpers/index.mjs +3 -29
- package/dist/index.d.mts +106 -181
- package/dist/index.d.ts +106 -181
- package/dist/index.mjs +130 -117
- package/dist/openapi/index.d.mts +11 -27
- package/dist/openapi/index.d.ts +11 -27
- package/dist/openapi/index.mjs +8 -76
- 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 -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.BCcLYvdF.d.mts +0 -56
- package/dist/shared/server.CHV9AQHl.mjs +0 -412
- package/dist/shared/server.CdeqmULw.d.ts +0 -56
- package/dist/shared/server.DHezmW6C.d.mts +0 -23
- package/dist/shared/server.DN9mVGfv.mjs +0 -11
- package/dist/shared/server.DWwaAM-a.mjs +0 -255
- package/dist/shared/server.Da-qLzdU.d.ts +0 -23
- package/dist/shared/server.DecvGKtb.d.mts +0 -242
- package/dist/shared/server.DecvGKtb.d.ts +0 -242
- package/dist/shared/server.JtIZ8YG7.mjs +0 -237
package/dist/index.d.mts
CHANGED
|
@@ -1,45 +1,53 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import { ClientContext, MaybeOptionalOptions, HTTPEndpoint, IntersectPick, HTTPPath, ClientOptions, ClientPromiseResult } from '@temporary-name/shared';
|
|
4
|
-
export { AsyncIteratorClass, ClientContext, EventPublisher, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, HTTPMethod, HTTPPath, IntersectPick, ORPCError, Registry, ThrowableError, asyncIteratorToStream as eventIteratorToStream, isDefinedError, onError, onFinish, onStart, onSuccess, safe, streamToAsyncIteratorClass as streamToEventIterator } from '@temporary-name/shared';
|
|
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';
|
|
5
3
|
import { SchemaClass, core } from '@temporary-name/zod';
|
|
6
|
-
import { C as Context,
|
|
7
|
-
export {
|
|
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> = {
|
|
10
|
+
/**
|
|
11
|
+
* This is helpful for logging and analytics.
|
|
12
|
+
*/
|
|
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> {
|
|
11
27
|
/**
|
|
12
28
|
* Make this procedure callable (works like a function while still being a procedure).
|
|
13
29
|
*
|
|
14
30
|
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
15
31
|
*/
|
|
16
|
-
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>;
|
|
17
33
|
}
|
|
18
34
|
|
|
19
|
-
declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas,
|
|
35
|
+
declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TMeta extends Meta, TGateName extends string> extends Contract<BuilderDef<TSchemas, TMeta>> {
|
|
20
36
|
z: SchemaClass<TGateName>;
|
|
21
|
-
|
|
22
|
-
* This property holds the defined options.
|
|
23
|
-
*/
|
|
24
|
-
'~orpc': BuilderDef<TSchemas, TErrorMap, TMeta>;
|
|
25
|
-
constructor(def: BuilderDef<TSchemas, TErrorMap, TMeta>);
|
|
26
|
-
/**
|
|
27
|
-
* Adds type-safe custom errors to the contract.
|
|
28
|
-
* The provided errors are spared-merged with any existing errors in the contract.
|
|
29
|
-
*
|
|
30
|
-
* @see {@link https://orpc.unnoq.com/docs/error-handling#type%E2%80%90safe-error-handling Type-Safe Error Handling Docs}
|
|
31
|
-
*/
|
|
32
|
-
errors<U extends ErrorMap>(errors: U): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, MergedErrorMap<TErrorMap, U>, TMeta, TGateName>;
|
|
37
|
+
constructor(def: BuilderDef<TSchemas, TMeta>);
|
|
33
38
|
/**
|
|
34
39
|
* Sets or updates the metadata for the contract.
|
|
35
40
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
36
41
|
*
|
|
37
42
|
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
38
43
|
*/
|
|
39
|
-
meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas,
|
|
40
|
-
endpoint<U extends
|
|
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, {
|
|
41
49
|
pathSchema: WrapShape<U>;
|
|
42
|
-
}>,
|
|
50
|
+
}>, TMeta, TGateName>;
|
|
43
51
|
/**
|
|
44
52
|
* Sets or updates the route definition for the contract.
|
|
45
53
|
* The provided route is spared-merged with any existing route in the contract.
|
|
@@ -48,13 +56,13 @@ declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext
|
|
|
48
56
|
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
49
57
|
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
50
58
|
*/
|
|
51
|
-
endpointOpts(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas,
|
|
59
|
+
endpointOpts(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TMeta, TGateName>;
|
|
52
60
|
query<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
53
61
|
querySchema: WrapShape<U>;
|
|
54
|
-
}>,
|
|
62
|
+
}>, TMeta, TGateName>;
|
|
55
63
|
body<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
56
64
|
bodySchema: WrapShape<U>;
|
|
57
|
-
}>,
|
|
65
|
+
}>, TMeta, TGateName>;
|
|
58
66
|
/**
|
|
59
67
|
* Defines the output validation schema.
|
|
60
68
|
*
|
|
@@ -62,7 +70,7 @@ declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext
|
|
|
62
70
|
*/
|
|
63
71
|
output<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
64
72
|
outputSchema: WrapShape<U>;
|
|
65
|
-
}>,
|
|
73
|
+
}>, TMeta, TGateName>;
|
|
66
74
|
/**
|
|
67
75
|
* Uses a middleware to modify the context or improve the pipeline.
|
|
68
76
|
*
|
|
@@ -70,18 +78,19 @@ declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext
|
|
|
70
78
|
* @note The current context must be satisfy middleware dependent-context
|
|
71
79
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
72
80
|
*/
|
|
73
|
-
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>;
|
|
74
83
|
useGating<const TInferredGateName extends string>(gates: TInferredGateName[], isGateEnabled: (gate: TInferredGateName, ctx: TCurrentContext) => boolean): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, Context, TCurrentContext>, MergedCurrentContext<TCurrentContext, {
|
|
75
84
|
isGateEnabled: typeof isGateEnabled;
|
|
76
|
-
}>, TSchemas,
|
|
85
|
+
}>, TSchemas, TMeta, TInferredGateName>;
|
|
77
86
|
/**
|
|
78
87
|
* Defines the handler of the procedure.
|
|
79
88
|
*
|
|
80
89
|
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
81
90
|
*/
|
|
82
|
-
handler(handler: ProcedureHandler<TCurrentContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>,
|
|
91
|
+
handler(handler: ProcedureHandler<TCurrentContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TSchemas, TMeta>;
|
|
83
92
|
}
|
|
84
|
-
declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas,
|
|
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> {
|
|
85
94
|
/**
|
|
86
95
|
* Prefixes all procedures in the router.
|
|
87
96
|
* The provided prefix is post-appended to any existing router prefix.
|
|
@@ -90,205 +99,104 @@ declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentCo
|
|
|
90
99
|
*
|
|
91
100
|
* @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
92
101
|
*/
|
|
93
|
-
prefix(prefix: HTTPPath): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TSchemas,
|
|
102
|
+
prefix(prefix: HTTPPath): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TSchemas, TMeta, TGateName>;
|
|
94
103
|
/**
|
|
95
104
|
* Adds tags to all procedures in the router.
|
|
96
105
|
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
97
106
|
*
|
|
98
107
|
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
99
108
|
*/
|
|
100
|
-
tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext,
|
|
109
|
+
tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TMeta>;
|
|
101
110
|
/**
|
|
102
111
|
* Applies all of the previously defined options to the specified router.
|
|
103
112
|
*
|
|
104
113
|
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
105
114
|
*/
|
|
106
|
-
router<U extends Router<
|
|
115
|
+
router<U extends Router<TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext>;
|
|
107
116
|
}
|
|
108
|
-
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'> {
|
|
109
118
|
/**
|
|
110
119
|
* This property holds the defined options.
|
|
111
120
|
*/
|
|
112
|
-
'~orpc': EnhanceRouterOptions
|
|
121
|
+
'~orpc': EnhanceRouterOptions;
|
|
113
122
|
}
|
|
114
123
|
|
|
115
|
-
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> {
|
|
116
125
|
/**
|
|
117
126
|
* Change the expected input type by providing a map function.
|
|
118
127
|
*/
|
|
119
|
-
mapInput<UInput>(map: MapInputMiddleware<UInput, TInput>): DecoratedMiddleware<TInContext, TOutContext, UInput, TOutput,
|
|
128
|
+
mapInput<UInput>(map: MapInputMiddleware<UInput, TInput>): DecoratedMiddleware<TInContext, TOutContext, UInput, TOutput, TMeta>;
|
|
120
129
|
/**
|
|
121
130
|
* Concatenates two middlewares.
|
|
122
131
|
*
|
|
123
132
|
* @info Pass second argument to map the input.
|
|
124
133
|
* @see {@link https://orpc.unnoq.com/docs/middleware#concatenation Middleware Concatenation Docs}
|
|
125
134
|
*/
|
|
126
|
-
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>;
|
|
127
136
|
/**
|
|
128
137
|
* Concatenates two middlewares.
|
|
129
138
|
*
|
|
130
139
|
* @info Pass second argument to map the input.
|
|
131
140
|
* @see {@link https://orpc.unnoq.com/docs/middleware#concatenation Middleware Concatenation Docs}
|
|
132
141
|
*/
|
|
133
|
-
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>;
|
|
134
143
|
}
|
|
135
|
-
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>;
|
|
136
145
|
|
|
137
|
-
interface BuilderDef<TSchemas extends Schemas,
|
|
138
|
-
middlewares: readonly AnyMiddleware[];
|
|
139
|
-
inputValidationIndex: number;
|
|
140
|
-
outputValidationIndex: number;
|
|
146
|
+
interface BuilderDef<TSchemas extends Schemas, TMeta extends Meta> extends ContractDef<TSchemas, TMeta>, EnhanceRouterOptions {
|
|
141
147
|
}
|
|
142
|
-
declare class Builder<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas,
|
|
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> {
|
|
143
149
|
/**
|
|
144
150
|
* Set or override the initial context.
|
|
145
151
|
*
|
|
146
152
|
* @see {@link https://orpc.unnoq.com/docs/context Context Docs}
|
|
147
153
|
*/
|
|
148
|
-
$context<U extends Context>(): Builder<U, U, TSchemas,
|
|
154
|
+
$context<U extends Context>(): Builder<U, U, TSchemas, TMeta, TGateName>;
|
|
149
155
|
/**
|
|
150
156
|
* Creates a middleware.
|
|
151
157
|
*
|
|
152
158
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
153
159
|
*/
|
|
154
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
|
|
155
|
-
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput,
|
|
161
|
+
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, TMeta>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, TMeta>;
|
|
156
162
|
}
|
|
157
|
-
type ApiBuilder<TMeta extends Meta> = Builder<Record<never, never>, Record<never, never>, InitialSchemas,
|
|
163
|
+
type ApiBuilder<TMeta extends Meta> = Builder<Record<never, never>, Record<never, never>, InitialSchemas, TMeta, never>;
|
|
158
164
|
interface ApiBuilderOpts<TMeta extends Meta> {
|
|
159
165
|
meta?: TMeta;
|
|
160
166
|
}
|
|
161
167
|
declare function createApiBuilder<TMeta extends Meta = Record<never, never>>(opts?: ApiBuilderOpts<TMeta>): ApiBuilder<TMeta>;
|
|
162
168
|
declare const os: ApiBuilder<Record<never, never>>;
|
|
163
169
|
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
interface ImplementedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta> {
|
|
168
|
-
/**
|
|
169
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
170
|
-
*
|
|
171
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
172
|
-
* @info Pass second argument to map the input.
|
|
173
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
174
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
175
|
-
*/
|
|
176
|
-
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ImplementedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TErrorMap, TMeta>;
|
|
177
|
-
/**
|
|
178
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
179
|
-
*
|
|
180
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
181
|
-
* @info Pass second argument to map the input.
|
|
182
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
183
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
184
|
-
*/
|
|
185
|
-
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TSchemas['outputSchema']>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferHandlerInputs<TSchemas>, UInput>): ImplementedProcedure<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TErrorMap, TMeta>;
|
|
170
|
+
interface ValidationErrorOptions extends ErrorOptions {
|
|
171
|
+
message: string;
|
|
172
|
+
issues: readonly SchemaIssue[];
|
|
186
173
|
/**
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
174
|
+
* @todo require this field in v2
|
|
190
175
|
*/
|
|
191
|
-
|
|
176
|
+
data?: unknown;
|
|
192
177
|
}
|
|
193
178
|
/**
|
|
194
|
-
*
|
|
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}
|
|
195
182
|
*/
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
*
|
|
201
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
202
|
-
* @info Pass second argument to map the input.
|
|
203
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
204
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
205
|
-
*/
|
|
206
|
-
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>, ORPCErrorConstructorMap<TErrorMap>, TMeta>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TErrorMap, TMeta>;
|
|
207
|
-
/**
|
|
208
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
209
|
-
*
|
|
210
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
211
|
-
* @info Pass second argument to map the input.
|
|
212
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
213
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
214
|
-
*/
|
|
215
|
-
'use'<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInput, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, UInput, InferSchemaInput<TSchemas['outputSchema']>, ORPCErrorConstructorMap<TErrorMap>, TMeta>, mapInput: MapInputMiddleware<InferHandlerInputs<TSchemas>, UInput>): ProcedureImplementer<MergedInitialContext<TInitialContext, UInContext, TCurrentContext>, MergedCurrentContext<TCurrentContext, UOutContext>, TSchemas, TErrorMap, TMeta>;
|
|
216
|
-
/**
|
|
217
|
-
* Defines the handler of the procedure.
|
|
218
|
-
*
|
|
219
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
220
|
-
*/
|
|
221
|
-
'handler'(handler: ProcedureHandler<TCurrentContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta>;
|
|
183
|
+
declare class ValidationError extends Error {
|
|
184
|
+
readonly issues: readonly SchemaIssue[];
|
|
185
|
+
readonly data: unknown;
|
|
186
|
+
constructor(options: ValidationErrorOptions);
|
|
222
187
|
}
|
|
223
188
|
|
|
224
|
-
interface
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
*
|
|
228
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
229
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
230
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
231
|
-
*/
|
|
232
|
-
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>>;
|
|
233
|
-
/**
|
|
234
|
-
* Applies all of the previously defined options to the specified router.
|
|
235
|
-
* And enforces the router match the contract.
|
|
236
|
-
*
|
|
237
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
238
|
-
*/
|
|
239
|
-
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
240
|
-
}
|
|
241
|
-
type ImplementerInternalWithMiddlewares<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = TContract extends ContractProcedure<infer USchemas, infer UErrorMap, infer UMeta> ? ProcedureImplementer<TInitialContext, TCurrentContext, USchemas, UErrorMap, UMeta> : RouterImplementerWithMiddlewares<TContract, TInitialContext, TCurrentContext> & {
|
|
242
|
-
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternalWithMiddlewares<TContract[K], TInitialContext, TCurrentContext> : never;
|
|
243
|
-
};
|
|
244
|
-
|
|
245
|
-
interface RouterImplementer<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
|
246
|
-
/**
|
|
247
|
-
* Creates a middleware.
|
|
248
|
-
*
|
|
249
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
250
|
-
*/
|
|
251
|
-
middleware<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
|
252
|
-
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, InferContractRouterMeta<T>>;
|
|
253
|
-
/**
|
|
254
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
255
|
-
*
|
|
256
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
257
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
258
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
259
|
-
*/
|
|
260
|
-
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>>;
|
|
261
|
-
/**
|
|
262
|
-
* Applies all of the previously defined options to the specified router.
|
|
263
|
-
* And enforces the router match the contract.
|
|
264
|
-
*
|
|
265
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
266
|
-
*/
|
|
267
|
-
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
268
|
-
/**
|
|
269
|
-
* Create a lazy router
|
|
270
|
-
* And applies all of the previously defined options to the specified router.
|
|
271
|
-
* And enforces the router match the contract.
|
|
272
|
-
*
|
|
273
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
274
|
-
*/
|
|
275
|
-
lazyRoute<U extends Router<T, TCurrentContext>>(loader: () => Promise<{
|
|
276
|
-
default: U;
|
|
277
|
-
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
189
|
+
interface EventIteratorSchemaDetails {
|
|
190
|
+
yields: AnySchema;
|
|
191
|
+
returns?: AnySchema;
|
|
278
192
|
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
*
|
|
287
|
-
* @see {@link https://orpc.unnoq.com/docs/context Context Docs}
|
|
288
|
-
*/
|
|
289
|
-
$context<U extends Context>(): Implementer<TContract, U, U>;
|
|
290
|
-
} & ImplementerInternal<TContract, TInitialContext, TCurrentContext>;
|
|
291
|
-
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;
|
|
292
200
|
|
|
293
201
|
declare function isStartWithMiddlewares(middlewares: readonly AnyMiddleware[], compare: readonly AnyMiddleware[]): boolean;
|
|
294
202
|
declare function mergeMiddlewares(first: readonly AnyMiddleware[], second: readonly AnyMiddleware[], options: {
|
|
@@ -297,10 +205,6 @@ declare function mergeMiddlewares(first: readonly AnyMiddleware[], second: reado
|
|
|
297
205
|
declare function addMiddleware(middlewares: readonly AnyMiddleware[], addition: AnyMiddleware): AnyMiddleware[];
|
|
298
206
|
|
|
299
207
|
declare function createAssertedLazyProcedure(lazied: Lazy<any>): Lazy<AnyProcedure>;
|
|
300
|
-
/**
|
|
301
|
-
* Create a new procedure that ensure the contract is applied to the procedure.
|
|
302
|
-
*/
|
|
303
|
-
declare function createContractedProcedure(procedure: AnyProcedure, contract: AnyContractProcedure): AnyProcedure;
|
|
304
208
|
/**
|
|
305
209
|
* Directly call a procedure without creating a client.
|
|
306
210
|
*
|
|
@@ -311,9 +215,9 @@ declare function createContractedProcedure(procedure: AnyProcedure, contract: An
|
|
|
311
215
|
* ```
|
|
312
216
|
*
|
|
313
217
|
*/
|
|
314
|
-
declare function call<TInitialContext extends Context, TSchemas extends Schemas,
|
|
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']>>;
|
|
315
219
|
|
|
316
|
-
type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Procedure<any, any, infer USchemas,
|
|
220
|
+
type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Procedure<any, any, infer USchemas, any> ? ProcedureClient<TClientContext, USchemas> : {
|
|
317
221
|
[K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
|
|
318
222
|
};
|
|
319
223
|
/**
|
|
@@ -321,10 +225,31 @@ type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContex
|
|
|
321
225
|
*
|
|
322
226
|
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
323
227
|
*/
|
|
324
|
-
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;
|
|
325
231
|
|
|
326
|
-
|
|
327
|
-
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
|
+
};
|
|
328
253
|
|
|
329
|
-
export { AnyMiddleware, AnyProcedure, AnyRouter, Builder, BuilderWithMiddlewares, Context,
|
|
330
|
-
export type { ApiBuilder, BuilderDef,
|
|
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 };
|