@temporary-name/server 1.9.3-alpha.26612c2cf6a7177d2b500d984d282309d8320ca3 → 1.9.3-alpha.2957dbc009ec31fa21575f028b83c96651cba827
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 +3 -5
- package/dist/adapters/aws-lambda/index.d.ts +3 -5
- package/dist/adapters/aws-lambda/index.mjs +3 -3
- package/dist/adapters/fetch/index.d.mts +7 -85
- package/dist/adapters/fetch/index.d.ts +7 -85
- package/dist/adapters/fetch/index.mjs +15 -154
- package/dist/adapters/node/index.d.mts +7 -62
- package/dist/adapters/node/index.d.ts +7 -62
- package/dist/adapters/node/index.mjs +13 -119
- package/dist/adapters/standard/index.d.mts +9 -6
- package/dist/adapters/standard/index.d.ts +9 -6
- package/dist/adapters/standard/index.mjs +4 -4
- package/dist/helpers/index.mjs +3 -29
- package/dist/index.d.mts +72 -195
- package/dist/index.d.ts +72 -195
- package/dist/index.mjs +131 -114
- package/dist/openapi/index.d.mts +10 -27
- package/dist/openapi/index.d.ts +10 -27
- package/dist/openapi/index.mjs +57 -108
- package/dist/shared/{server.CjkiSCui.mjs → server.B7tjiDal.mjs} +73 -115
- package/dist/shared/server.C1RJffw4.mjs +30 -0
- package/dist/shared/server.CQIFwyhc.mjs +40 -0
- package/dist/shared/server.CpS0m3at.mjs +403 -0
- package/dist/shared/server.DPD7R7h_.d.mts +226 -0
- package/dist/shared/server.DPD7R7h_.d.ts +226 -0
- package/dist/shared/server.DfUs5c4R.d.ts +41 -0
- package/dist/shared/server.L8lRAYBR.d.mts +41 -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.BYnDyuDL.d.mts +0 -23
- package/dist/shared/server.BlJrjUA9.d.mts +0 -56
- package/dist/shared/server.C-tNYmY_.d.ts +0 -56
- package/dist/shared/server.DdHBdcen.mjs +0 -262
- package/dist/shared/server.JI4dqTgD.d.ts +0 -23
- package/dist/shared/server.Kxw442A9.mjs +0 -247
- package/dist/shared/server.WsFQIubj.d.mts +0 -235
- package/dist/shared/server.WsFQIubj.d.ts +0 -235
package/dist/index.d.mts
CHANGED
|
@@ -1,42 +1,55 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
3
|
-
import { ClientContext, MaybeOptionalOptions, IntersectPick, HTTPPath, ClientOptions
|
|
4
|
-
export { AsyncIteratorClass, ClientContext, EventPublisher, EventPublisherOptions, EventPublisherSubscribeIteratorOptions, HTTPMethod, HTTPPath, IntersectPick, ORPCError,
|
|
5
|
-
import { SchemaClass } from '@temporary-name/zod';
|
|
6
|
-
import { C as Context, P as Procedure, a as
|
|
7
|
-
export {
|
|
1
|
+
import { Schemas, InferProcedureClientInputs, InferSchemaOutput, Meta, AnyShape, MergedSchemas, WrapShape, UnionToIntersection, AnySchema, Route, InferHandlerInputs, InferSchemaInput, InitialSchemas } from '@temporary-name/contract';
|
|
2
|
+
export { InferSchemaInput, InferSchemaOutput, Meta, OutputStructure, Route, Schema, ValidationError, eventIterator } from '@temporary-name/contract';
|
|
3
|
+
import { ClientContext, Value, Promisable, Client, MaybeOptionalOptions, HTTPEndpoint, IntersectPick, OptionalIfEmpty, HTTPPath, ClientOptions } from '@temporary-name/shared';
|
|
4
|
+
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
|
+
import { SchemaClass, core } from '@temporary-name/zod';
|
|
6
|
+
import { C as Context, L as Lazyable, P as Procedure, a as Contract, M as Middleware, b as MergedInitialContext, c as MergedCurrentContext, A as AuthType, V as ValidatedAuthContext, d as AuthConfig, B as BuildContextWithAuth, e as ProcedureHandler, E as EnhanceRouterOptions, R as Router, f as EnhancedRouter, g as MapInputMiddleware, h as ContractDef, i as AnyMiddleware, j as Lazy, k as AnyProcedure, l as AnyRouter, I as InferRouterInitialContext } from './shared/server.DPD7R7h_.mjs';
|
|
7
|
+
export { T as AccessibleLazyRouter, F as AnyContractDef, Z as ContractProcedureCallbackOptions, J as ContractRouter, D as DefaultProcedureHandlerOptions, N as InferRouterCurrentContexts, K as InferRouterInitialContexts, O as InferRouterInputs, Q as InferRouterOutputs, n as LAZY_SYMBOL, o as LazyMeta, _ as LazyTraverseContractProceduresOptions, v as MiddlewareNextFn, x as MiddlewareOptions, w as MiddlewareOutputFn, t as MiddlewareResult, G as ProcedureDef, z as ProcedureHandlerOptions, Y as TraverseContractProcedureCallbackOptions, X as TraverseContractProceduresOptions, a1 as UnlaziedRouter, U as createAccessibleLazyRouter, W as enhanceRouter, s as getLazyMeta, S as getRouter, r as isLazy, H as isProcedure, q as lazy, p as lazyInternal, m as mergeCurrentContext, y as middlewareOutputFn, a0 as resolveContractProcedures, $ as traverseContractProcedures, u as unlazy, a2 as unlazyRouter } from './shared/server.DPD7R7h_.mjs';
|
|
8
8
|
export { getEventMeta, withEventMeta } from '@temporary-name/standard-server';
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
type ProcedureClient<TClientContext extends ClientContext, TSchemas extends Schemas> = Client<TClientContext, InferProcedureClientInputs<TSchemas>, InferSchemaOutput<TSchemas['outputSchema']>>;
|
|
11
|
+
type CreateProcedureClientOptions<TInitialContext extends Context, TClientContext extends ClientContext> = {
|
|
12
|
+
/**
|
|
13
|
+
* This is helpful for logging and analytics.
|
|
14
|
+
*/
|
|
15
|
+
path?: readonly string[];
|
|
16
|
+
} & (Record<never, never> extends TInitialContext ? {
|
|
17
|
+
context?: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
18
|
+
} : {
|
|
19
|
+
context: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* Create Server-side client from a procedure.
|
|
23
|
+
*
|
|
24
|
+
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
25
|
+
*/
|
|
26
|
+
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>;
|
|
27
|
+
|
|
28
|
+
declare class DecoratedProcedure<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TMeta extends Meta> extends Procedure<TInitialContext, TCurrentContext, TSchemas, TMeta> {
|
|
11
29
|
/**
|
|
12
30
|
* Make this procedure callable (works like a function while still being a procedure).
|
|
13
31
|
*
|
|
14
32
|
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
15
33
|
*/
|
|
16
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext,
|
|
34
|
+
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TClientContext>>): DecoratedProcedure<TInitialContext, TCurrentContext, TSchemas, TMeta> & ProcedureClient<TClientContext, TSchemas>;
|
|
17
35
|
}
|
|
18
36
|
|
|
19
|
-
declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context,
|
|
20
|
-
z: SchemaClass
|
|
21
|
-
|
|
22
|
-
* This property holds the defined options.
|
|
23
|
-
*/
|
|
24
|
-
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
25
|
-
constructor(def: BuilderDef<TInputSchema, TOutputSchema, 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, TInputSchema, TOutputSchema, MergedErrorMap<TErrorMap, U>, TMeta, TGateName>;
|
|
37
|
+
declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TMeta extends Meta, TGateName extends string> extends Contract<BuilderDef<TSchemas, TMeta>> {
|
|
38
|
+
z: SchemaClass<TGateName>;
|
|
39
|
+
constructor(def: BuilderDef<TSchemas, TMeta>);
|
|
33
40
|
/**
|
|
34
41
|
* Sets or updates the metadata for the contract.
|
|
35
42
|
* The provided metadata is spared-merged with any existing metadata in the contract.
|
|
36
43
|
*
|
|
37
44
|
* @see {@link https://orpc.unnoq.com/docs/metadata Metadata Docs}
|
|
38
45
|
*/
|
|
39
|
-
meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext,
|
|
46
|
+
meta(meta: TMeta): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TMeta, TGateName>;
|
|
47
|
+
endpoint<U extends AnyShape[]>(strings: TemplateStringsArray, ...values: [...U]): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
48
|
+
pathSchema: WrapShape<UnionToIntersection<U>>;
|
|
49
|
+
}>, TMeta, TGateName>;
|
|
50
|
+
endpoint<U extends AnySchema | AnyShape = core.$ZodType<Record<string, never>, Record<string, never>>>(endpoint: HTTPEndpoint, schema?: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
51
|
+
pathSchema: WrapShape<U>;
|
|
52
|
+
}>, TMeta, TGateName>;
|
|
40
53
|
/**
|
|
41
54
|
* Sets or updates the route definition for the contract.
|
|
42
55
|
* The provided route is spared-merged with any existing route in the contract.
|
|
@@ -45,19 +58,21 @@ declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext
|
|
|
45
58
|
* @see {@link https://orpc.unnoq.com/docs/openapi/routing OpenAPI Routing Docs}
|
|
46
59
|
* @see {@link https://orpc.unnoq.com/docs/openapi/input-output-structure OpenAPI Input/Output Structure Docs}
|
|
47
60
|
*/
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
61
|
+
endpointOpts(route: Route): ProcedureBuilder<TInitialContext, TCurrentContext, TSchemas, TMeta, TGateName>;
|
|
62
|
+
query<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
63
|
+
querySchema: WrapShape<U>;
|
|
64
|
+
}>, TMeta, TGateName>;
|
|
65
|
+
body<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
66
|
+
bodySchema: WrapShape<U>;
|
|
67
|
+
}>, TMeta, TGateName>;
|
|
55
68
|
/**
|
|
56
69
|
* Defines the output validation schema.
|
|
57
70
|
*
|
|
58
71
|
* @see {@link https://orpc.unnoq.com/docs/procedure#input-output-validation Output Validation Docs}
|
|
59
72
|
*/
|
|
60
|
-
output<
|
|
73
|
+
output<U extends AnySchema | AnyShape>(schema: U): ProcedureBuilder<TInitialContext, TCurrentContext, MergedSchemas<TSchemas, {
|
|
74
|
+
outputSchema: WrapShape<U>;
|
|
75
|
+
}>, TMeta, TGateName>;
|
|
61
76
|
/**
|
|
62
77
|
* Uses a middleware to modify the context or improve the pipeline.
|
|
63
78
|
*
|
|
@@ -65,18 +80,19 @@ declare class ProcedureBuilder<TInitialContext extends Context, TCurrentContext
|
|
|
65
80
|
* @note The current context must be satisfy middleware dependent-context
|
|
66
81
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
67
82
|
*/
|
|
68
|
-
use<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, UInContext extends Context = TCurrentContext>(middleware: Middleware<UInContext | TCurrentContext, UOutContext, unknown, unknown,
|
|
83
|
+
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>;
|
|
84
|
+
useAuth<const TAuthType extends AuthType & {}, TAuthContext extends ValidatedAuthContext = false>(type: TAuthType, ...rest: OptionalIfEmpty<AuthConfig<TAuthType, TAuthContext>>): ProcedureBuilder<TInitialContext, BuildContextWithAuth<TCurrentContext, TAuthContext>, TSchemas, TMeta, TGateName>;
|
|
69
85
|
useGating<const TInferredGateName extends string>(gates: TInferredGateName[], isGateEnabled: (gate: TInferredGateName, ctx: TCurrentContext) => boolean): BuilderWithMiddlewares<MergedInitialContext<TInitialContext, Context, TCurrentContext>, MergedCurrentContext<TCurrentContext, {
|
|
70
86
|
isGateEnabled: typeof isGateEnabled;
|
|
71
|
-
}>,
|
|
87
|
+
}>, TSchemas, TMeta, TInferredGateName>;
|
|
72
88
|
/**
|
|
73
89
|
* Defines the handler of the procedure.
|
|
74
90
|
*
|
|
75
91
|
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
76
92
|
*/
|
|
77
|
-
handler(handler: ProcedureHandler<TCurrentContext,
|
|
93
|
+
handler(handler: ProcedureHandler<TCurrentContext, InferHandlerInputs<TSchemas>, InferSchemaInput<TSchemas['outputSchema']>, TMeta>): DecoratedProcedure<TInitialContext, TCurrentContext, TSchemas, TMeta>;
|
|
78
94
|
}
|
|
79
|
-
declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentContext extends Context,
|
|
95
|
+
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> {
|
|
80
96
|
/**
|
|
81
97
|
* Prefixes all procedures in the router.
|
|
82
98
|
* The provided prefix is post-appended to any existing router prefix.
|
|
@@ -85,206 +101,74 @@ declare class BuilderWithMiddlewares<TInitialContext extends Context, TCurrentCo
|
|
|
85
101
|
*
|
|
86
102
|
* @see {@link https://orpc.unnoq.com/docs/openapi/routing#route-prefixes OpenAPI Route Prefixes Docs}
|
|
87
103
|
*/
|
|
88
|
-
prefix(prefix: HTTPPath): BuilderWithMiddlewares<TInitialContext, TCurrentContext,
|
|
104
|
+
prefix(prefix: HTTPPath): BuilderWithMiddlewares<TInitialContext, TCurrentContext, TSchemas, TMeta, TGateName>;
|
|
89
105
|
/**
|
|
90
106
|
* Adds tags to all procedures in the router.
|
|
91
107
|
* This helpful when you want to group procedures together in the OpenAPI specification.
|
|
92
108
|
*
|
|
93
109
|
* @see {@link https://orpc.unnoq.com/docs/openapi/openapi-specification#operation-metadata OpenAPI Operation Metadata Docs}
|
|
94
110
|
*/
|
|
95
|
-
tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext,
|
|
111
|
+
tag(...tags: string[]): RouterBuilder<TInitialContext, TCurrentContext, TMeta>;
|
|
96
112
|
/**
|
|
97
113
|
* Applies all of the previously defined options to the specified router.
|
|
98
114
|
*
|
|
99
115
|
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
100
116
|
*/
|
|
101
|
-
router<U extends Router<
|
|
117
|
+
router<U extends Router<TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext>;
|
|
102
118
|
}
|
|
103
|
-
interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context,
|
|
119
|
+
interface RouterBuilder<TInitialContext extends Context, TCurrentContext extends Context, TMeta extends Meta> extends Pick<BuilderWithMiddlewares<TInitialContext, TCurrentContext, any, TMeta, any>, 'prefix' | 'tag' | 'router'> {
|
|
104
120
|
/**
|
|
105
121
|
* This property holds the defined options.
|
|
106
122
|
*/
|
|
107
|
-
'~orpc': EnhanceRouterOptions
|
|
123
|
+
'~orpc': EnhanceRouterOptions;
|
|
108
124
|
}
|
|
109
125
|
|
|
110
|
-
interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput,
|
|
126
|
+
interface DecoratedMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput, TMeta extends Meta> extends Middleware<TInContext, TOutContext, TInput, TOutput, TMeta> {
|
|
111
127
|
/**
|
|
112
128
|
* Change the expected input type by providing a map function.
|
|
113
129
|
*/
|
|
114
|
-
mapInput<UInput>(map: MapInputMiddleware<UInput, TInput>): DecoratedMiddleware<TInContext, TOutContext, UInput, TOutput,
|
|
130
|
+
mapInput<UInput>(map: MapInputMiddleware<UInput, TInput>): DecoratedMiddleware<TInContext, TOutContext, UInput, TOutput, TMeta>;
|
|
115
131
|
/**
|
|
116
132
|
* Concatenates two middlewares.
|
|
117
133
|
*
|
|
118
134
|
* @info Pass second argument to map the input.
|
|
119
135
|
* @see {@link https://orpc.unnoq.com/docs/middleware#concatenation Middleware Concatenation Docs}
|
|
120
136
|
*/
|
|
121
|
-
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,
|
|
137
|
+
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>;
|
|
122
138
|
/**
|
|
123
139
|
* Concatenates two middlewares.
|
|
124
140
|
*
|
|
125
141
|
* @info Pass second argument to map the input.
|
|
126
142
|
* @see {@link https://orpc.unnoq.com/docs/middleware#concatenation Middleware Concatenation Docs}
|
|
127
143
|
*/
|
|
128
|
-
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,
|
|
144
|
+
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>;
|
|
129
145
|
}
|
|
130
|
-
declare function decorateMiddleware<TInContext extends Context, TOutContext extends Context, TInput, TOutput,
|
|
146
|
+
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>;
|
|
131
147
|
|
|
132
|
-
interface BuilderDef<
|
|
133
|
-
middlewares: readonly AnyMiddleware[];
|
|
134
|
-
inputValidationIndex: number;
|
|
135
|
-
outputValidationIndex: number;
|
|
148
|
+
interface BuilderDef<TSchemas extends Schemas, TMeta extends Meta> extends ContractDef<any, TSchemas, TMeta>, EnhanceRouterOptions {
|
|
136
149
|
}
|
|
137
|
-
declare class Builder<TInitialContext extends Context, TCurrentContext extends Context,
|
|
150
|
+
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> {
|
|
138
151
|
/**
|
|
139
152
|
* Set or override the initial context.
|
|
140
153
|
*
|
|
141
154
|
* @see {@link https://orpc.unnoq.com/docs/context Context Docs}
|
|
142
155
|
*/
|
|
143
|
-
$context<U extends Context>(): Builder<U, U,
|
|
156
|
+
$context<U extends Context>(): Builder<U, U, TSchemas, TMeta, TGateName>;
|
|
144
157
|
/**
|
|
145
158
|
* Creates a middleware.
|
|
146
159
|
*
|
|
147
160
|
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
148
161
|
*/
|
|
149
162
|
middleware<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
|
150
|
-
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput,
|
|
163
|
+
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, TMeta>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, TMeta>;
|
|
151
164
|
}
|
|
152
|
-
type ApiBuilder<TMeta extends Meta> = Builder<Record<never, never>, Record<never, never>,
|
|
165
|
+
type ApiBuilder<TMeta extends Meta> = Builder<Record<never, never>, Record<never, never>, InitialSchemas, TMeta, never>;
|
|
153
166
|
interface ApiBuilderOpts<TMeta extends Meta> {
|
|
154
167
|
meta?: TMeta;
|
|
155
168
|
}
|
|
156
169
|
declare function createApiBuilder<TMeta extends Meta = Record<never, never>>(opts?: ApiBuilderOpts<TMeta>): ApiBuilder<TMeta>;
|
|
157
170
|
declare const os: ApiBuilder<Record<never, never>>;
|
|
158
171
|
|
|
159
|
-
/**
|
|
160
|
-
* Like `DecoratedProcedure`, but removed all method that can change the contract.
|
|
161
|
-
*/
|
|
162
|
-
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> {
|
|
163
|
-
/**
|
|
164
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
165
|
-
*
|
|
166
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
167
|
-
* @info Pass second argument to map the input.
|
|
168
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
169
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
170
|
-
*/
|
|
171
|
-
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>;
|
|
172
|
-
/**
|
|
173
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
174
|
-
*
|
|
175
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
176
|
-
* @info Pass second argument to map the input.
|
|
177
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
178
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
179
|
-
*/
|
|
180
|
-
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>;
|
|
181
|
-
/**
|
|
182
|
-
* Make this procedure callable (works like a function while still being a procedure).
|
|
183
|
-
*
|
|
184
|
-
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
185
|
-
*/
|
|
186
|
-
callable<TClientContext extends ClientContext>(...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta> & ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
187
|
-
}
|
|
188
|
-
/**
|
|
189
|
-
* Like `ProcedureBuilderWithoutHandler`, but removed all method that can change the contract.
|
|
190
|
-
*/
|
|
191
|
-
interface ProcedureImplementer<TInitialContext extends Context, TCurrentContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
192
|
-
'~orpc': BuilderDef<TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
193
|
-
/**
|
|
194
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
195
|
-
*
|
|
196
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
197
|
-
* @info Pass second argument to map the input.
|
|
198
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
199
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
200
|
-
*/
|
|
201
|
-
'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>;
|
|
202
|
-
/**
|
|
203
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
204
|
-
*
|
|
205
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
206
|
-
* @info Pass second argument to map the input.
|
|
207
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
208
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
209
|
-
*/
|
|
210
|
-
'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>;
|
|
211
|
-
/**
|
|
212
|
-
* Defines the handler of the procedure.
|
|
213
|
-
*
|
|
214
|
-
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
215
|
-
*/
|
|
216
|
-
'handler'(handler: ProcedureHandler<TCurrentContext, InferSchemaOutput<TInputSchema>, InferSchemaInput<TOutputSchema>, TErrorMap, TMeta>): ImplementedProcedure<TInitialContext, TCurrentContext, TInputSchema, TOutputSchema, TErrorMap, TMeta>;
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
interface RouterImplementerWithMiddlewares<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
|
220
|
-
/**
|
|
221
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
222
|
-
*
|
|
223
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
224
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
225
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
226
|
-
*/
|
|
227
|
-
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>>;
|
|
228
|
-
/**
|
|
229
|
-
* Applies all of the previously defined options to the specified router.
|
|
230
|
-
* And enforces the router match the contract.
|
|
231
|
-
*
|
|
232
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
233
|
-
*/
|
|
234
|
-
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
235
|
-
}
|
|
236
|
-
type ImplementerInternalWithMiddlewares<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = TContract extends ContractProcedure<infer UInputSchema, infer UOutputSchema, infer UErrorMap, infer UMeta> ? ProcedureImplementer<TInitialContext, TCurrentContext, UInputSchema, UOutputSchema, UErrorMap, UMeta> : RouterImplementerWithMiddlewares<TContract, TInitialContext, TCurrentContext> & {
|
|
237
|
-
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternalWithMiddlewares<TContract[K], TInitialContext, TCurrentContext> : never;
|
|
238
|
-
};
|
|
239
|
-
|
|
240
|
-
interface RouterImplementer<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> {
|
|
241
|
-
/**
|
|
242
|
-
* Creates a middleware.
|
|
243
|
-
*
|
|
244
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
245
|
-
*/
|
|
246
|
-
middleware<UOutContext extends IntersectPick<TCurrentContext, UOutContext>, TInput, TOutput = any>(// = any here is important to make middleware can be used in any output by default
|
|
247
|
-
middleware: Middleware<TInitialContext, UOutContext, TInput, TOutput, ORPCErrorConstructorMap<InferContractRouterErrorMap<T>>, InferContractRouterMeta<T>>): DecoratedMiddleware<TInitialContext, UOutContext, TInput, TOutput, any, InferContractRouterMeta<T>>;
|
|
248
|
-
/**
|
|
249
|
-
* Uses a middleware to modify the context or improve the pipeline.
|
|
250
|
-
*
|
|
251
|
-
* @info Supports both normal middleware and inline middleware implementations.
|
|
252
|
-
* @note The current context must be satisfy middleware dependent-context
|
|
253
|
-
* @see {@link https://orpc.unnoq.com/docs/middleware Middleware Docs}
|
|
254
|
-
*/
|
|
255
|
-
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>>;
|
|
256
|
-
/**
|
|
257
|
-
* Applies all of the previously defined options to the specified router.
|
|
258
|
-
* And enforces the router match the contract.
|
|
259
|
-
*
|
|
260
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
261
|
-
*/
|
|
262
|
-
router<U extends Router<T, TCurrentContext>>(router: U): EnhancedRouter<U, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
263
|
-
/**
|
|
264
|
-
* Create a lazy router
|
|
265
|
-
* And applies all of the previously defined options to the specified router.
|
|
266
|
-
* And enforces the router match the contract.
|
|
267
|
-
*
|
|
268
|
-
* @see {@link https://orpc.unnoq.com/docs/router#extending-router Extending Router Docs}
|
|
269
|
-
*/
|
|
270
|
-
lazyRoute<U extends Router<T, TCurrentContext>>(loader: () => Promise<{
|
|
271
|
-
default: U;
|
|
272
|
-
}>): EnhancedRouter<Lazy<U>, TInitialContext, TCurrentContext, Record<never, never>>;
|
|
273
|
-
}
|
|
274
|
-
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> & {
|
|
275
|
-
[K in keyof TContract]: TContract[K] extends AnyContractRouter ? ImplementerInternal<TContract[K], TInitialContext, TCurrentContext> : never;
|
|
276
|
-
};
|
|
277
|
-
declare function implementerInternal<T extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context>(contract: T, middlewares: AnyMiddleware[]): ImplementerInternal<T, TInitialContext, TCurrentContext>;
|
|
278
|
-
type Implementer<TContract extends AnyContractRouter, TInitialContext extends Context, TCurrentContext extends Context> = {
|
|
279
|
-
/**
|
|
280
|
-
* Set or override the initial context.
|
|
281
|
-
*
|
|
282
|
-
* @see {@link https://orpc.unnoq.com/docs/context Context Docs}
|
|
283
|
-
*/
|
|
284
|
-
$context<U extends Context>(): Implementer<TContract, U, U>;
|
|
285
|
-
} & ImplementerInternal<TContract, TInitialContext, TCurrentContext>;
|
|
286
|
-
declare function implement<T extends AnyContractRouter, TContext extends Context = Record<never, never>>(contract: T): Implementer<T, TContext, TContext>;
|
|
287
|
-
|
|
288
172
|
declare function isStartWithMiddlewares(middlewares: readonly AnyMiddleware[], compare: readonly AnyMiddleware[]): boolean;
|
|
289
173
|
declare function mergeMiddlewares(first: readonly AnyMiddleware[], second: readonly AnyMiddleware[], options: {
|
|
290
174
|
dedupeLeading: boolean;
|
|
@@ -292,10 +176,6 @@ declare function mergeMiddlewares(first: readonly AnyMiddleware[], second: reado
|
|
|
292
176
|
declare function addMiddleware(middlewares: readonly AnyMiddleware[], addition: AnyMiddleware): AnyMiddleware[];
|
|
293
177
|
|
|
294
178
|
declare function createAssertedLazyProcedure(lazied: Lazy<any>): Lazy<AnyProcedure>;
|
|
295
|
-
/**
|
|
296
|
-
* Create a new procedure that ensure the contract is applied to the procedure.
|
|
297
|
-
*/
|
|
298
|
-
declare function createContractedProcedure(procedure: AnyProcedure, contract: AnyContractProcedure): AnyProcedure;
|
|
299
179
|
/**
|
|
300
180
|
* Directly call a procedure without creating a client.
|
|
301
181
|
*
|
|
@@ -306,9 +186,9 @@ declare function createContractedProcedure(procedure: AnyProcedure, contract: An
|
|
|
306
186
|
* ```
|
|
307
187
|
*
|
|
308
188
|
*/
|
|
309
|
-
declare function call<TInitialContext extends Context,
|
|
189
|
+
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']>>;
|
|
310
190
|
|
|
311
|
-
type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Procedure<any, any, infer
|
|
191
|
+
type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContext = Record<never, never>> = TRouter extends Procedure<any, any, infer USchemas, any> ? ProcedureClient<TClientContext, USchemas> : {
|
|
312
192
|
[K in keyof TRouter]: TRouter[K] extends Lazyable<infer U extends AnyRouter> ? RouterClient<U, TClientContext> : never;
|
|
313
193
|
};
|
|
314
194
|
/**
|
|
@@ -316,10 +196,7 @@ type RouterClient<TRouter extends AnyRouter, TClientContext extends ClientContex
|
|
|
316
196
|
*
|
|
317
197
|
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
318
198
|
*/
|
|
319
|
-
declare function createRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>,
|
|
320
|
-
|
|
321
|
-
declare function setHiddenRouterContract<T extends Lazyable<AnyRouter>>(router: T, contract: AnyContractRouter): T;
|
|
322
|
-
declare function getHiddenRouterContract(router: Lazyable<AnyRouter | AnyContractRouter>): AnyContractRouter | undefined;
|
|
199
|
+
declare function createRouterClient<T extends AnyRouter, TClientContext extends ClientContext>(router: Lazyable<T | undefined>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<InferRouterInitialContext<T>, TClientContext>>): RouterClient<T, TClientContext>;
|
|
323
200
|
|
|
324
|
-
export { AnyMiddleware, AnyProcedure, AnyRouter, Builder, BuilderWithMiddlewares, Context,
|
|
325
|
-
export type { ApiBuilder, BuilderDef,
|
|
201
|
+
export { AnyMiddleware, AnyProcedure, AnyRouter, BuildContextWithAuth, Builder, BuilderWithMiddlewares, Context, Contract, ContractDef, DecoratedProcedure, EnhanceRouterOptions, EnhancedRouter, InferRouterInitialContext, Lazy, Lazyable, MapInputMiddleware, MergedCurrentContext, MergedInitialContext, Middleware, Procedure, ProcedureBuilder, ProcedureHandler, Router, addMiddleware, call, createApiBuilder, createAssertedLazyProcedure, createProcedureClient, createRouterClient, decorateMiddleware, isStartWithMiddlewares, mergeMiddlewares, os };
|
|
202
|
+
export type { ApiBuilder, BuilderDef, CreateProcedureClientOptions, DecoratedMiddleware, ProcedureClient, RouterBuilder, RouterClient };
|