@temporary-name/server 1.9.3-alpha.121f1a14eceb7f2aa23c6993c2adce0ccca377db → 1.9.3-alpha.1a5ff4923d25c9d83e80d717687ebc859f5312f2
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 -3
- package/dist/adapters/aws-lambda/index.d.ts +3 -3
- package/dist/adapters/aws-lambda/index.mjs +4 -3
- package/dist/adapters/fetch/index.d.mts +3 -3
- package/dist/adapters/fetch/index.d.ts +3 -3
- package/dist/adapters/fetch/index.mjs +4 -3
- package/dist/adapters/node/index.d.mts +3 -3
- package/dist/adapters/node/index.d.ts +3 -3
- package/dist/adapters/node/index.mjs +4 -3
- package/dist/adapters/standard/index.d.mts +20 -31
- package/dist/adapters/standard/index.d.ts +20 -31
- package/dist/adapters/standard/index.mjs +4 -3
- package/dist/index.d.mts +53 -1047
- package/dist/index.d.ts +53 -1047
- package/dist/index.mjs +77 -1886
- package/dist/openapi/index.d.mts +1 -1
- package/dist/openapi/index.d.ts +1 -1
- package/dist/openapi/index.mjs +59 -76
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/index.d.ts +2 -2
- package/dist/shared/{server.CMTfy2UB.mjs → server.B--sAUhn.mjs} +55 -94
- package/dist/shared/{server.CQyYNJ1H.d.ts → server.BCcLYvdF.d.mts} +1 -2
- package/dist/shared/server.CHV9AQHl.mjs +412 -0
- package/dist/shared/{server.C1fnTLq0.d.mts → server.CdeqmULw.d.ts} +1 -2
- package/dist/shared/{server.BeuTpcmO.d.mts → server.DHezmW6C.d.mts} +2 -2
- package/dist/shared/{server.SLLuK6_v.d.ts → server.Da-qLzdU.d.ts} +2 -2
- package/dist/shared/{server.BKSOrA6h.d.mts → server.DecvGKtb.d.mts} +125 -75
- package/dist/shared/{server.BKSOrA6h.d.ts → server.DecvGKtb.d.ts} +125 -75
- package/dist/shared/{server.BEHw7Eyx.mjs → server.Kxw442A9.mjs} +1 -1
- package/package.json +10 -9
- package/dist/shared/server.BZtKt8i8.mjs +0 -201
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ErrorMap, ErrorMapItem, InferSchemaInput,
|
|
2
|
-
import { ORPCErrorCode, MaybeOptionalOptions, ORPCErrorOptions, ORPCError,
|
|
1
|
+
import { ErrorMap, ErrorMapItem, InferSchemaInput, Schemas, Meta, ContractProcedureDef, AnyContractRouter, ContractProcedure, InferProcedureClientInputs, InferSchemaOutput, EnhanceRouteOptions, MergedErrorMap, AnyContractProcedure, ContractRouter, AnySchema, ErrorFromErrorMap } from '@temporary-name/contract';
|
|
2
|
+
import { ORPCErrorCode, MaybeOptionalOptions, ORPCErrorOptions, ORPCError, Promisable, HTTPPath, ClientContext, Interceptor, PromiseWithError, Value, Client } from '@temporary-name/shared';
|
|
3
3
|
|
|
4
4
|
type Context = Record<PropertyKey, any>;
|
|
5
5
|
type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
|
|
@@ -13,46 +13,22 @@ type ORPCErrorConstructorMap<T extends ErrorMap> = {
|
|
|
13
13
|
};
|
|
14
14
|
declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
interface LazyMeta {
|
|
18
|
-
prefix?: HTTPPath;
|
|
19
|
-
}
|
|
20
|
-
interface Lazy<T> {
|
|
21
|
-
[LAZY_SYMBOL]: {
|
|
22
|
-
loader: () => Promise<{
|
|
23
|
-
default: T;
|
|
24
|
-
}>;
|
|
25
|
-
meta: LazyMeta;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
type Lazyable<T> = T | Lazy<T>;
|
|
29
|
-
/**
|
|
30
|
-
* Creates a lazy-loaded item.
|
|
31
|
-
*
|
|
32
|
-
* @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazyRoute(...)` instead.
|
|
33
|
-
*/
|
|
34
|
-
declare function lazy<T>(loader: () => Promise<{
|
|
35
|
-
default: T;
|
|
36
|
-
}>, meta?: LazyMeta): Lazy<T>;
|
|
37
|
-
declare function isLazy(item: unknown): item is Lazy<any>;
|
|
38
|
-
declare function getLazyMeta(lazied: Lazy<any>): LazyMeta;
|
|
39
|
-
declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
|
|
40
|
-
default: T extends Lazy<infer U> ? U : T;
|
|
41
|
-
}>;
|
|
42
|
-
|
|
43
|
-
interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
|
16
|
+
interface ProcedureHandlerOptions<TCurrentContext extends Context, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
|
44
17
|
context: TCurrentContext;
|
|
45
|
-
input: TInput;
|
|
46
18
|
path: readonly string[];
|
|
47
|
-
procedure: Procedure<Context, Context,
|
|
19
|
+
procedure: Procedure<Context, Context, Schemas, ErrorMap, TMeta>;
|
|
48
20
|
signal?: AbortSignal;
|
|
49
21
|
lastEventId: string | undefined;
|
|
50
22
|
errors: TErrorConstructorMap;
|
|
51
23
|
}
|
|
52
|
-
interface ProcedureHandler<TCurrentContext extends Context, TInput
|
|
53
|
-
|
|
24
|
+
interface ProcedureHandler<TCurrentContext extends Context, TInput extends {
|
|
25
|
+
path: any;
|
|
26
|
+
query: any;
|
|
27
|
+
body: any;
|
|
28
|
+
}, THandlerOutput, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
29
|
+
(input: TInput, opt: ProcedureHandlerOptions<TCurrentContext, ORPCErrorConstructorMap<TErrorMap>, TMeta>): Promisable<THandlerOutput>;
|
|
54
30
|
}
|
|
55
|
-
interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context,
|
|
31
|
+
interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TSchemas, TErrorMap, TMeta> {
|
|
56
32
|
__initialContext?: (type: TInitialContext) => unknown;
|
|
57
33
|
middlewares: readonly AnyMiddleware[];
|
|
58
34
|
inputValidationIndex: number;
|
|
@@ -64,14 +40,14 @@ interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends
|
|
|
64
40
|
*
|
|
65
41
|
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
66
42
|
*/
|
|
67
|
-
declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context,
|
|
43
|
+
declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
68
44
|
/**
|
|
69
45
|
* This property holds the defined options.
|
|
70
46
|
*/
|
|
71
|
-
'~orpc': ProcedureDef<TInitialContext, TCurrentContext,
|
|
72
|
-
constructor(def: ProcedureDef<TInitialContext, TCurrentContext,
|
|
47
|
+
'~orpc': ProcedureDef<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta>;
|
|
48
|
+
constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta>);
|
|
73
49
|
}
|
|
74
|
-
type AnyProcedure = Procedure<any, any,
|
|
50
|
+
type AnyProcedure = Procedure<any, any, Schemas, any, any>;
|
|
75
51
|
declare function isProcedure(item: unknown): item is AnyProcedure;
|
|
76
52
|
|
|
77
53
|
type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
|
|
@@ -92,7 +68,7 @@ interface MiddlewareOutputFn<TOutput> {
|
|
|
92
68
|
interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
|
93
69
|
context: TInContext;
|
|
94
70
|
path: readonly string[];
|
|
95
|
-
procedure: Procedure<Context, Context,
|
|
71
|
+
procedure: Procedure<Context, Context, Schemas, ErrorMap, TMeta>;
|
|
96
72
|
signal?: AbortSignal;
|
|
97
73
|
lastEventId: string | undefined;
|
|
98
74
|
next: MiddlewareNextFn<TOutput>;
|
|
@@ -112,41 +88,13 @@ interface MapInputMiddleware<TInput, TMappedInput> {
|
|
|
112
88
|
}
|
|
113
89
|
declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
|
|
114
90
|
|
|
115
|
-
type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
|
|
116
|
-
interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
117
|
-
context: TInitialContext;
|
|
118
|
-
input: unknown;
|
|
119
|
-
errors: ORPCErrorConstructorMap<TErrorMap>;
|
|
120
|
-
path: readonly string[];
|
|
121
|
-
procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
|
|
122
|
-
signal?: AbortSignal;
|
|
123
|
-
lastEventId: string | undefined;
|
|
124
|
-
}
|
|
125
|
-
type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
|
|
126
|
-
/**
|
|
127
|
-
* This is helpful for logging and analytics.
|
|
128
|
-
*/
|
|
129
|
-
path?: readonly string[];
|
|
130
|
-
interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TErrorMap, TMeta>, PromiseWithError<InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>>[];
|
|
131
|
-
} & (Record<never, never> extends TInitialContext ? {
|
|
132
|
-
context?: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
133
|
-
} : {
|
|
134
|
-
context: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
135
|
-
});
|
|
136
|
-
/**
|
|
137
|
-
* Create Server-side client from a procedure.
|
|
138
|
-
*
|
|
139
|
-
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
140
|
-
*/
|
|
141
|
-
declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
142
|
-
|
|
143
91
|
/**
|
|
144
92
|
* Represents a router, which defines a hierarchical structure of procedures.
|
|
145
93
|
*
|
|
146
94
|
* @info A procedure is a router too.
|
|
147
95
|
* @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#contract-router Contract Router Docs}
|
|
148
96
|
*/
|
|
149
|
-
type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer
|
|
97
|
+
type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer USchemas, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, USchemas, UErrorMap, UMeta> : {
|
|
150
98
|
[K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
|
|
151
99
|
};
|
|
152
100
|
type AnyRouter = Router<any, any>;
|
|
@@ -157,7 +105,7 @@ type InferRouterInitialContext<T extends AnyRouter> = T extends Router<any, infe
|
|
|
157
105
|
* @info A procedure is a router too.
|
|
158
106
|
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
159
107
|
*/
|
|
160
|
-
type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any
|
|
108
|
+
type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any> ? UInitialContext : {
|
|
161
109
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInitialContexts<U> : never;
|
|
162
110
|
};
|
|
163
111
|
/**
|
|
@@ -166,7 +114,7 @@ type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer
|
|
|
166
114
|
* @info A procedure is a router too.
|
|
167
115
|
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
168
116
|
*/
|
|
169
|
-
type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any
|
|
117
|
+
type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any> ? UCurrentContext : {
|
|
170
118
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterCurrentContexts<U> : never;
|
|
171
119
|
};
|
|
172
120
|
/**
|
|
@@ -175,7 +123,7 @@ type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any,
|
|
|
175
123
|
* @info A procedure is a router too.
|
|
176
124
|
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
177
125
|
*/
|
|
178
|
-
type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer
|
|
126
|
+
type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer USchemas, any, any> ? InferProcedureClientInputs<USchemas> : {
|
|
179
127
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInputs<U> : never;
|
|
180
128
|
};
|
|
181
129
|
/**
|
|
@@ -184,9 +132,111 @@ type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infe
|
|
|
184
132
|
* @info A procedure is a router too.
|
|
185
133
|
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
186
134
|
*/
|
|
187
|
-
type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any,
|
|
135
|
+
type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, infer USchemas, any, any> ? InferSchemaOutput<USchemas['outputSchema']> : {
|
|
188
136
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
|
|
189
137
|
};
|
|
190
138
|
|
|
191
|
-
|
|
192
|
-
|
|
139
|
+
declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
|
|
140
|
+
type AccessibleLazyRouter<T extends Lazyable<AnyRouter | undefined>> = T extends Lazy<infer U extends AnyRouter | undefined | Lazy<AnyRouter | undefined>> ? AccessibleLazyRouter<U> : T extends AnyProcedure | undefined ? Lazy<T> : Lazy<T> & {
|
|
141
|
+
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? AccessibleLazyRouter<T[K]> : never;
|
|
142
|
+
};
|
|
143
|
+
declare function createAccessibleLazyRouter<T extends Lazy<AnyRouter | undefined>>(lazied: T): AccessibleLazyRouter<T>;
|
|
144
|
+
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 USchemas, infer UErrorMap, infer UMeta>) ? Procedure<MergedInitialContext<TInitialContext, UInitialContext, TCurrentContext>, UCurrentContext, USchemas, MergedErrorMap<TErrorMap, UErrorMap>, UMeta> : {
|
|
145
|
+
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? EnhancedRouter<T[K], TInitialContext, TCurrentContext, TErrorMap> : never;
|
|
146
|
+
};
|
|
147
|
+
interface EnhanceRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
|
|
148
|
+
middlewares: readonly AnyMiddleware[];
|
|
149
|
+
errorMap: TErrorMap;
|
|
150
|
+
dedupeLeadingMiddlewares: boolean;
|
|
151
|
+
}
|
|
152
|
+
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>;
|
|
153
|
+
interface TraverseContractProceduresOptions {
|
|
154
|
+
router: AnyContractRouter | AnyRouter;
|
|
155
|
+
path: readonly string[];
|
|
156
|
+
}
|
|
157
|
+
interface TraverseContractProcedureCallbackOptions {
|
|
158
|
+
contract: AnyContractProcedure | AnyProcedure;
|
|
159
|
+
path: readonly string[];
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* @deprecated Use `TraverseContractProcedureCallbackOptions` instead.
|
|
163
|
+
*/
|
|
164
|
+
type ContractProcedureCallbackOptions = TraverseContractProcedureCallbackOptions;
|
|
165
|
+
interface LazyTraverseContractProceduresOptions {
|
|
166
|
+
router: Lazy<AnyRouter>;
|
|
167
|
+
path: readonly string[];
|
|
168
|
+
}
|
|
169
|
+
declare function traverseContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void, lazyOptions?: LazyTraverseContractProceduresOptions[]): LazyTraverseContractProceduresOptions[];
|
|
170
|
+
declare function resolveContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void): Promise<void>;
|
|
171
|
+
type UnlaziedRouter<T extends AnyRouter> = T extends AnyProcedure ? T : {
|
|
172
|
+
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? UnlaziedRouter<U> : never;
|
|
173
|
+
};
|
|
174
|
+
declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedRouter<T>>;
|
|
175
|
+
|
|
176
|
+
declare const LAZY_SYMBOL: unique symbol;
|
|
177
|
+
interface LazyMeta {
|
|
178
|
+
prefix?: HTTPPath;
|
|
179
|
+
}
|
|
180
|
+
interface Lazy<T> {
|
|
181
|
+
[LAZY_SYMBOL]: {
|
|
182
|
+
loader: () => Promise<{
|
|
183
|
+
default: T;
|
|
184
|
+
}>;
|
|
185
|
+
meta: LazyMeta;
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
type Lazyable<T> = T | Lazy<T>;
|
|
189
|
+
/**
|
|
190
|
+
* @internal
|
|
191
|
+
*/
|
|
192
|
+
declare function lazyInternal<T>(loader: () => Promise<{
|
|
193
|
+
default: T;
|
|
194
|
+
}>, meta?: LazyMeta): Lazy<T>;
|
|
195
|
+
/**
|
|
196
|
+
* Creates a lazy-loaded item.
|
|
197
|
+
*
|
|
198
|
+
* @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazyRoute(...)` instead.
|
|
199
|
+
*/
|
|
200
|
+
declare function lazy<T extends Router<ContractRouter<{}>, any>>(prefix: HTTPPath, loader: () => Promise<{
|
|
201
|
+
default: T;
|
|
202
|
+
}>): EnhancedRouter<Lazy<T>, {}, {}, {}>;
|
|
203
|
+
declare function isLazy(item: unknown): item is Lazy<any>;
|
|
204
|
+
declare function getLazyMeta(lazied: Lazy<any>): LazyMeta;
|
|
205
|
+
declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
|
|
206
|
+
default: T extends Lazy<infer U> ? U : T;
|
|
207
|
+
}>;
|
|
208
|
+
|
|
209
|
+
type ProcedureClient<TClientContext extends ClientContext, TSchemas extends Schemas, TErrorMap extends ErrorMap> = Client<TClientContext, InferProcedureClientInputs<TSchemas>, InferSchemaOutput<TSchemas['outputSchema']>, ErrorFromErrorMap<TErrorMap>>;
|
|
210
|
+
interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
211
|
+
context: TInitialContext;
|
|
212
|
+
input: {
|
|
213
|
+
path: unknown;
|
|
214
|
+
query: unknown;
|
|
215
|
+
body: unknown;
|
|
216
|
+
};
|
|
217
|
+
errors: ORPCErrorConstructorMap<TErrorMap>;
|
|
218
|
+
path: readonly string[];
|
|
219
|
+
procedure: Procedure<Context, Context, Schemas, ErrorMap, TMeta>;
|
|
220
|
+
signal?: AbortSignal;
|
|
221
|
+
lastEventId: string | undefined;
|
|
222
|
+
}
|
|
223
|
+
type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
|
|
224
|
+
/**
|
|
225
|
+
* This is helpful for logging and analytics.
|
|
226
|
+
*/
|
|
227
|
+
path?: readonly string[];
|
|
228
|
+
interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TErrorMap, TMeta>, PromiseWithError<InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>>[];
|
|
229
|
+
} & (Record<never, never> extends TInitialContext ? {
|
|
230
|
+
context?: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
231
|
+
} : {
|
|
232
|
+
context: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
233
|
+
});
|
|
234
|
+
/**
|
|
235
|
+
* Create Server-side client from a procedure.
|
|
236
|
+
*
|
|
237
|
+
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
238
|
+
*/
|
|
239
|
+
declare function createProcedureClient<TInitialContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TSchemas, TErrorMap, TMeta>>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TSchemas['outputSchema'], TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TSchemas, TErrorMap>;
|
|
240
|
+
|
|
241
|
+
export { traverseContractProcedures as $, middlewareOutputFn as B, isProcedure as G, createProcedureClient as J, Procedure as P, getRouter as T, createAccessibleLazyRouter as V, enhanceRouter as W, resolveContractProcedures as a0, unlazyRouter as a2, mergeCurrentContext as m, createORPCErrorConstructorMap as n, LAZY_SYMBOL as o, lazyInternal as q, lazy as r, isLazy as s, getLazyMeta as t, unlazy as u };
|
|
242
|
+
export type { AnyMiddleware as A, Context as C, ProcedureHandlerOptions as D, EnhanceRouterOptions as E, ProcedureDef as F, ProcedureClientInterceptorOptions as H, InferRouterInitialContext as I, InferRouterInitialContexts as K, Lazy as L, Middleware as M, InferRouterCurrentContexts as N, ORPCErrorConstructorMap as O, InferRouterInputs as Q, Router as R, InferRouterOutputs as S, AccessibleLazyRouter as U, TraverseContractProceduresOptions as X, TraverseContractProcedureCallbackOptions as Y, ContractProcedureCallbackOptions as Z, LazyTraverseContractProceduresOptions as _, CreateProcedureClientOptions as a, UnlaziedRouter as a1, ProcedureClient as b, MergedInitialContext as c, MergedCurrentContext as d, ProcedureHandler as e, EnhancedRouter as f, MapInputMiddleware as g, AnyProcedure as h, Lazyable as i, AnyRouter as j, ORPCErrorConstructorMapItemOptions as k, ORPCErrorConstructorMapItem as l, LazyMeta as p, MiddlewareResult as v, MiddlewareNextFnOptions as w, MiddlewareNextFn as x, MiddlewareOutputFn as y, MiddlewareOptions as z };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ErrorMap, ErrorMapItem, InferSchemaInput,
|
|
2
|
-
import { ORPCErrorCode, MaybeOptionalOptions, ORPCErrorOptions, ORPCError,
|
|
1
|
+
import { ErrorMap, ErrorMapItem, InferSchemaInput, Schemas, Meta, ContractProcedureDef, AnyContractRouter, ContractProcedure, InferProcedureClientInputs, InferSchemaOutput, EnhanceRouteOptions, MergedErrorMap, AnyContractProcedure, ContractRouter, AnySchema, ErrorFromErrorMap } from '@temporary-name/contract';
|
|
2
|
+
import { ORPCErrorCode, MaybeOptionalOptions, ORPCErrorOptions, ORPCError, Promisable, HTTPPath, ClientContext, Interceptor, PromiseWithError, Value, Client } from '@temporary-name/shared';
|
|
3
3
|
|
|
4
4
|
type Context = Record<PropertyKey, any>;
|
|
5
5
|
type MergedInitialContext<TInitial extends Context, TAdditional extends Context, TCurrent extends Context> = TInitial & Omit<TAdditional, keyof TCurrent>;
|
|
@@ -13,46 +13,22 @@ type ORPCErrorConstructorMap<T extends ErrorMap> = {
|
|
|
13
13
|
};
|
|
14
14
|
declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
interface LazyMeta {
|
|
18
|
-
prefix?: HTTPPath;
|
|
19
|
-
}
|
|
20
|
-
interface Lazy<T> {
|
|
21
|
-
[LAZY_SYMBOL]: {
|
|
22
|
-
loader: () => Promise<{
|
|
23
|
-
default: T;
|
|
24
|
-
}>;
|
|
25
|
-
meta: LazyMeta;
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
type Lazyable<T> = T | Lazy<T>;
|
|
29
|
-
/**
|
|
30
|
-
* Creates a lazy-loaded item.
|
|
31
|
-
*
|
|
32
|
-
* @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazyRoute(...)` instead.
|
|
33
|
-
*/
|
|
34
|
-
declare function lazy<T>(loader: () => Promise<{
|
|
35
|
-
default: T;
|
|
36
|
-
}>, meta?: LazyMeta): Lazy<T>;
|
|
37
|
-
declare function isLazy(item: unknown): item is Lazy<any>;
|
|
38
|
-
declare function getLazyMeta(lazied: Lazy<any>): LazyMeta;
|
|
39
|
-
declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
|
|
40
|
-
default: T extends Lazy<infer U> ? U : T;
|
|
41
|
-
}>;
|
|
42
|
-
|
|
43
|
-
interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
|
16
|
+
interface ProcedureHandlerOptions<TCurrentContext extends Context, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
|
44
17
|
context: TCurrentContext;
|
|
45
|
-
input: TInput;
|
|
46
18
|
path: readonly string[];
|
|
47
|
-
procedure: Procedure<Context, Context,
|
|
19
|
+
procedure: Procedure<Context, Context, Schemas, ErrorMap, TMeta>;
|
|
48
20
|
signal?: AbortSignal;
|
|
49
21
|
lastEventId: string | undefined;
|
|
50
22
|
errors: TErrorConstructorMap;
|
|
51
23
|
}
|
|
52
|
-
interface ProcedureHandler<TCurrentContext extends Context, TInput
|
|
53
|
-
|
|
24
|
+
interface ProcedureHandler<TCurrentContext extends Context, TInput extends {
|
|
25
|
+
path: any;
|
|
26
|
+
query: any;
|
|
27
|
+
body: any;
|
|
28
|
+
}, THandlerOutput, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
29
|
+
(input: TInput, opt: ProcedureHandlerOptions<TCurrentContext, ORPCErrorConstructorMap<TErrorMap>, TMeta>): Promisable<THandlerOutput>;
|
|
54
30
|
}
|
|
55
|
-
interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context,
|
|
31
|
+
interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TSchemas, TErrorMap, TMeta> {
|
|
56
32
|
__initialContext?: (type: TInitialContext) => unknown;
|
|
57
33
|
middlewares: readonly AnyMiddleware[];
|
|
58
34
|
inputValidationIndex: number;
|
|
@@ -64,14 +40,14 @@ interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends
|
|
|
64
40
|
*
|
|
65
41
|
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
66
42
|
*/
|
|
67
|
-
declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context,
|
|
43
|
+
declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
68
44
|
/**
|
|
69
45
|
* This property holds the defined options.
|
|
70
46
|
*/
|
|
71
|
-
'~orpc': ProcedureDef<TInitialContext, TCurrentContext,
|
|
72
|
-
constructor(def: ProcedureDef<TInitialContext, TCurrentContext,
|
|
47
|
+
'~orpc': ProcedureDef<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta>;
|
|
48
|
+
constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta>);
|
|
73
49
|
}
|
|
74
|
-
type AnyProcedure = Procedure<any, any,
|
|
50
|
+
type AnyProcedure = Procedure<any, any, Schemas, any, any>;
|
|
75
51
|
declare function isProcedure(item: unknown): item is AnyProcedure;
|
|
76
52
|
|
|
77
53
|
type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
|
|
@@ -92,7 +68,7 @@ interface MiddlewareOutputFn<TOutput> {
|
|
|
92
68
|
interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
|
93
69
|
context: TInContext;
|
|
94
70
|
path: readonly string[];
|
|
95
|
-
procedure: Procedure<Context, Context,
|
|
71
|
+
procedure: Procedure<Context, Context, Schemas, ErrorMap, TMeta>;
|
|
96
72
|
signal?: AbortSignal;
|
|
97
73
|
lastEventId: string | undefined;
|
|
98
74
|
next: MiddlewareNextFn<TOutput>;
|
|
@@ -112,41 +88,13 @@ interface MapInputMiddleware<TInput, TMappedInput> {
|
|
|
112
88
|
}
|
|
113
89
|
declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<Record<never, never>, TOutput>;
|
|
114
90
|
|
|
115
|
-
type ProcedureClient<TClientContext extends ClientContext, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap> = Client<TClientContext, InferSchemaInput<TInputSchema>, InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>;
|
|
116
|
-
interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
117
|
-
context: TInitialContext;
|
|
118
|
-
input: unknown;
|
|
119
|
-
errors: ORPCErrorConstructorMap<TErrorMap>;
|
|
120
|
-
path: readonly string[];
|
|
121
|
-
procedure: Procedure<Context, Context, AnySchema, AnySchema, ErrorMap, TMeta>;
|
|
122
|
-
signal?: AbortSignal;
|
|
123
|
-
lastEventId: string | undefined;
|
|
124
|
-
}
|
|
125
|
-
type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
|
|
126
|
-
/**
|
|
127
|
-
* This is helpful for logging and analytics.
|
|
128
|
-
*/
|
|
129
|
-
path?: readonly string[];
|
|
130
|
-
interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TErrorMap, TMeta>, PromiseWithError<InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>>[];
|
|
131
|
-
} & (Record<never, never> extends TInitialContext ? {
|
|
132
|
-
context?: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
133
|
-
} : {
|
|
134
|
-
context: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
135
|
-
});
|
|
136
|
-
/**
|
|
137
|
-
* Create Server-side client from a procedure.
|
|
138
|
-
*
|
|
139
|
-
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
140
|
-
*/
|
|
141
|
-
declare function createProcedureClient<TInitialContext extends Context, TInputSchema extends AnySchema, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TInputSchema, TOutputSchema, TErrorMap, TMeta>>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TOutputSchema, TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TInputSchema, TOutputSchema, TErrorMap>;
|
|
142
|
-
|
|
143
91
|
/**
|
|
144
92
|
* Represents a router, which defines a hierarchical structure of procedures.
|
|
145
93
|
*
|
|
146
94
|
* @info A procedure is a router too.
|
|
147
95
|
* @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#contract-router Contract Router Docs}
|
|
148
96
|
*/
|
|
149
|
-
type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer
|
|
97
|
+
type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer USchemas, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, USchemas, UErrorMap, UMeta> : {
|
|
150
98
|
[K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
|
|
151
99
|
};
|
|
152
100
|
type AnyRouter = Router<any, any>;
|
|
@@ -157,7 +105,7 @@ type InferRouterInitialContext<T extends AnyRouter> = T extends Router<any, infe
|
|
|
157
105
|
* @info A procedure is a router too.
|
|
158
106
|
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
159
107
|
*/
|
|
160
|
-
type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any
|
|
108
|
+
type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any> ? UInitialContext : {
|
|
161
109
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInitialContexts<U> : never;
|
|
162
110
|
};
|
|
163
111
|
/**
|
|
@@ -166,7 +114,7 @@ type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer
|
|
|
166
114
|
* @info A procedure is a router too.
|
|
167
115
|
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
168
116
|
*/
|
|
169
|
-
type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any
|
|
117
|
+
type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any> ? UCurrentContext : {
|
|
170
118
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterCurrentContexts<U> : never;
|
|
171
119
|
};
|
|
172
120
|
/**
|
|
@@ -175,7 +123,7 @@ type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any,
|
|
|
175
123
|
* @info A procedure is a router too.
|
|
176
124
|
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
177
125
|
*/
|
|
178
|
-
type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer
|
|
126
|
+
type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer USchemas, any, any> ? InferProcedureClientInputs<USchemas> : {
|
|
179
127
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInputs<U> : never;
|
|
180
128
|
};
|
|
181
129
|
/**
|
|
@@ -184,9 +132,111 @@ type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infe
|
|
|
184
132
|
* @info A procedure is a router too.
|
|
185
133
|
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
186
134
|
*/
|
|
187
|
-
type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any,
|
|
135
|
+
type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, infer USchemas, any, any> ? InferSchemaOutput<USchemas['outputSchema']> : {
|
|
188
136
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
|
|
189
137
|
};
|
|
190
138
|
|
|
191
|
-
|
|
192
|
-
|
|
139
|
+
declare function getRouter<T extends Lazyable<AnyRouter | undefined>>(router: T, path: readonly string[]): T extends Lazy<any> ? Lazy<AnyRouter | undefined> : Lazyable<AnyRouter | undefined>;
|
|
140
|
+
type AccessibleLazyRouter<T extends Lazyable<AnyRouter | undefined>> = T extends Lazy<infer U extends AnyRouter | undefined | Lazy<AnyRouter | undefined>> ? AccessibleLazyRouter<U> : T extends AnyProcedure | undefined ? Lazy<T> : Lazy<T> & {
|
|
141
|
+
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? AccessibleLazyRouter<T[K]> : never;
|
|
142
|
+
};
|
|
143
|
+
declare function createAccessibleLazyRouter<T extends Lazy<AnyRouter | undefined>>(lazied: T): AccessibleLazyRouter<T>;
|
|
144
|
+
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 USchemas, infer UErrorMap, infer UMeta>) ? Procedure<MergedInitialContext<TInitialContext, UInitialContext, TCurrentContext>, UCurrentContext, USchemas, MergedErrorMap<TErrorMap, UErrorMap>, UMeta> : {
|
|
145
|
+
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? EnhancedRouter<T[K], TInitialContext, TCurrentContext, TErrorMap> : never;
|
|
146
|
+
};
|
|
147
|
+
interface EnhanceRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
|
|
148
|
+
middlewares: readonly AnyMiddleware[];
|
|
149
|
+
errorMap: TErrorMap;
|
|
150
|
+
dedupeLeadingMiddlewares: boolean;
|
|
151
|
+
}
|
|
152
|
+
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>;
|
|
153
|
+
interface TraverseContractProceduresOptions {
|
|
154
|
+
router: AnyContractRouter | AnyRouter;
|
|
155
|
+
path: readonly string[];
|
|
156
|
+
}
|
|
157
|
+
interface TraverseContractProcedureCallbackOptions {
|
|
158
|
+
contract: AnyContractProcedure | AnyProcedure;
|
|
159
|
+
path: readonly string[];
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* @deprecated Use `TraverseContractProcedureCallbackOptions` instead.
|
|
163
|
+
*/
|
|
164
|
+
type ContractProcedureCallbackOptions = TraverseContractProcedureCallbackOptions;
|
|
165
|
+
interface LazyTraverseContractProceduresOptions {
|
|
166
|
+
router: Lazy<AnyRouter>;
|
|
167
|
+
path: readonly string[];
|
|
168
|
+
}
|
|
169
|
+
declare function traverseContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void, lazyOptions?: LazyTraverseContractProceduresOptions[]): LazyTraverseContractProceduresOptions[];
|
|
170
|
+
declare function resolveContractProcedures(options: TraverseContractProceduresOptions, callback: (options: TraverseContractProcedureCallbackOptions) => void): Promise<void>;
|
|
171
|
+
type UnlaziedRouter<T extends AnyRouter> = T extends AnyProcedure ? T : {
|
|
172
|
+
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? UnlaziedRouter<U> : never;
|
|
173
|
+
};
|
|
174
|
+
declare function unlazyRouter<T extends AnyRouter>(router: T): Promise<UnlaziedRouter<T>>;
|
|
175
|
+
|
|
176
|
+
declare const LAZY_SYMBOL: unique symbol;
|
|
177
|
+
interface LazyMeta {
|
|
178
|
+
prefix?: HTTPPath;
|
|
179
|
+
}
|
|
180
|
+
interface Lazy<T> {
|
|
181
|
+
[LAZY_SYMBOL]: {
|
|
182
|
+
loader: () => Promise<{
|
|
183
|
+
default: T;
|
|
184
|
+
}>;
|
|
185
|
+
meta: LazyMeta;
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
type Lazyable<T> = T | Lazy<T>;
|
|
189
|
+
/**
|
|
190
|
+
* @internal
|
|
191
|
+
*/
|
|
192
|
+
declare function lazyInternal<T>(loader: () => Promise<{
|
|
193
|
+
default: T;
|
|
194
|
+
}>, meta?: LazyMeta): Lazy<T>;
|
|
195
|
+
/**
|
|
196
|
+
* Creates a lazy-loaded item.
|
|
197
|
+
*
|
|
198
|
+
* @warning The `prefix` in `meta` only holds metadata and does not apply the prefix to the lazy router, use `os.prefix(...).lazyRoute(...)` instead.
|
|
199
|
+
*/
|
|
200
|
+
declare function lazy<T extends Router<ContractRouter<{}>, any>>(prefix: HTTPPath, loader: () => Promise<{
|
|
201
|
+
default: T;
|
|
202
|
+
}>): EnhancedRouter<Lazy<T>, {}, {}, {}>;
|
|
203
|
+
declare function isLazy(item: unknown): item is Lazy<any>;
|
|
204
|
+
declare function getLazyMeta(lazied: Lazy<any>): LazyMeta;
|
|
205
|
+
declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
|
|
206
|
+
default: T extends Lazy<infer U> ? U : T;
|
|
207
|
+
}>;
|
|
208
|
+
|
|
209
|
+
type ProcedureClient<TClientContext extends ClientContext, TSchemas extends Schemas, TErrorMap extends ErrorMap> = Client<TClientContext, InferProcedureClientInputs<TSchemas>, InferSchemaOutput<TSchemas['outputSchema']>, ErrorFromErrorMap<TErrorMap>>;
|
|
210
|
+
interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
211
|
+
context: TInitialContext;
|
|
212
|
+
input: {
|
|
213
|
+
path: unknown;
|
|
214
|
+
query: unknown;
|
|
215
|
+
body: unknown;
|
|
216
|
+
};
|
|
217
|
+
errors: ORPCErrorConstructorMap<TErrorMap>;
|
|
218
|
+
path: readonly string[];
|
|
219
|
+
procedure: Procedure<Context, Context, Schemas, ErrorMap, TMeta>;
|
|
220
|
+
signal?: AbortSignal;
|
|
221
|
+
lastEventId: string | undefined;
|
|
222
|
+
}
|
|
223
|
+
type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema extends AnySchema, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext> = {
|
|
224
|
+
/**
|
|
225
|
+
* This is helpful for logging and analytics.
|
|
226
|
+
*/
|
|
227
|
+
path?: readonly string[];
|
|
228
|
+
interceptors?: Interceptor<ProcedureClientInterceptorOptions<TInitialContext, TErrorMap, TMeta>, PromiseWithError<InferSchemaOutput<TOutputSchema>, ErrorFromErrorMap<TErrorMap>>>[];
|
|
229
|
+
} & (Record<never, never> extends TInitialContext ? {
|
|
230
|
+
context?: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
231
|
+
} : {
|
|
232
|
+
context: Value<Promisable<TInitialContext>, [clientContext: TClientContext]>;
|
|
233
|
+
});
|
|
234
|
+
/**
|
|
235
|
+
* Create Server-side client from a procedure.
|
|
236
|
+
*
|
|
237
|
+
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
238
|
+
*/
|
|
239
|
+
declare function createProcedureClient<TInitialContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta, TClientContext extends ClientContext>(lazyableProcedure: Lazyable<Procedure<TInitialContext, any, TSchemas, TErrorMap, TMeta>>, ...rest: MaybeOptionalOptions<CreateProcedureClientOptions<TInitialContext, TSchemas['outputSchema'], TErrorMap, TMeta, TClientContext>>): ProcedureClient<TClientContext, TSchemas, TErrorMap>;
|
|
240
|
+
|
|
241
|
+
export { traverseContractProcedures as $, middlewareOutputFn as B, isProcedure as G, createProcedureClient as J, Procedure as P, getRouter as T, createAccessibleLazyRouter as V, enhanceRouter as W, resolveContractProcedures as a0, unlazyRouter as a2, mergeCurrentContext as m, createORPCErrorConstructorMap as n, LAZY_SYMBOL as o, lazyInternal as q, lazy as r, isLazy as s, getLazyMeta as t, unlazy as u };
|
|
242
|
+
export type { AnyMiddleware as A, Context as C, ProcedureHandlerOptions as D, EnhanceRouterOptions as E, ProcedureDef as F, ProcedureClientInterceptorOptions as H, InferRouterInitialContext as I, InferRouterInitialContexts as K, Lazy as L, Middleware as M, InferRouterCurrentContexts as N, ORPCErrorConstructorMap as O, InferRouterInputs as Q, Router as R, InferRouterOutputs as S, AccessibleLazyRouter as U, TraverseContractProceduresOptions as X, TraverseContractProcedureCallbackOptions as Y, ContractProcedureCallbackOptions as Z, LazyTraverseContractProceduresOptions as _, CreateProcedureClientOptions as a, UnlaziedRouter as a1, ProcedureClient as b, MergedInitialContext as c, MergedCurrentContext as d, ProcedureHandler as e, EnhancedRouter as f, MapInputMiddleware as g, AnyProcedure as h, Lazyable as i, AnyRouter as j, ORPCErrorConstructorMapItemOptions as k, ORPCErrorConstructorMapItem as l, LazyMeta as p, MiddlewareResult as v, MiddlewareNextFnOptions as w, MiddlewareNextFn as x, MiddlewareOutputFn as y, MiddlewareOptions as z };
|
|
@@ -244,4 +244,4 @@ function getDynamicParams(path) {
|
|
|
244
244
|
})) : void 0;
|
|
245
245
|
}
|
|
246
246
|
|
|
247
|
-
export { standardizeHTTPPath as a, deserialize as d, getDynamicParams as g, jsonSerialize as j, serialize as s };
|
|
247
|
+
export { standardizeHTTPPath as a, bracketNotationDeserialize as b, deserialize as d, getDynamicParams as g, jsonSerialize as j, serialize as s };
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@temporary-name/server",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.9.3-alpha.
|
|
4
|
+
"version": "1.9.3-alpha.1a5ff4923d25c9d83e80d717687ebc859f5312f2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://www.stainless.com/",
|
|
7
7
|
"repository": {
|
|
@@ -71,16 +71,17 @@
|
|
|
71
71
|
},
|
|
72
72
|
"dependencies": {
|
|
73
73
|
"cookie": "^1.0.2",
|
|
74
|
-
"@standard-schema/spec": "^1.0.0",
|
|
75
74
|
"rou3": "^0.7.7",
|
|
76
75
|
"zod": "^4.1.12",
|
|
77
|
-
"@temporary-name/contract": "1.9.3-alpha.
|
|
78
|
-
"@temporary-name/interop": "1.9.3-alpha.
|
|
79
|
-
"@temporary-name/
|
|
80
|
-
"@temporary-name/
|
|
81
|
-
"@temporary-name/standard-server
|
|
82
|
-
"@temporary-name/standard-server-
|
|
83
|
-
"@temporary-name/standard-server-
|
|
76
|
+
"@temporary-name/contract": "1.9.3-alpha.1a5ff4923d25c9d83e80d717687ebc859f5312f2",
|
|
77
|
+
"@temporary-name/interop": "1.9.3-alpha.1a5ff4923d25c9d83e80d717687ebc859f5312f2",
|
|
78
|
+
"@temporary-name/json-schema": "1.9.3-alpha.1a5ff4923d25c9d83e80d717687ebc859f5312f2",
|
|
79
|
+
"@temporary-name/shared": "1.9.3-alpha.1a5ff4923d25c9d83e80d717687ebc859f5312f2",
|
|
80
|
+
"@temporary-name/standard-server": "1.9.3-alpha.1a5ff4923d25c9d83e80d717687ebc859f5312f2",
|
|
81
|
+
"@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.1a5ff4923d25c9d83e80d717687ebc859f5312f2",
|
|
82
|
+
"@temporary-name/standard-server-fetch": "1.9.3-alpha.1a5ff4923d25c9d83e80d717687ebc859f5312f2",
|
|
83
|
+
"@temporary-name/standard-server-node": "1.9.3-alpha.1a5ff4923d25c9d83e80d717687ebc859f5312f2",
|
|
84
|
+
"@temporary-name/zod": "1.9.3-alpha.1a5ff4923d25c9d83e80d717687ebc859f5312f2"
|
|
84
85
|
},
|
|
85
86
|
"devDependencies": {
|
|
86
87
|
"@types/supertest": "^6.0.3",
|