@temporary-name/server 1.9.3-alpha.26612c2cf6a7177d2b500d984d282309d8320ca3 → 1.9.3-alpha.32780b2c7ad58cf8dcbc93a40f13494185223e6e
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 +2 -2
- package/dist/adapters/fetch/index.d.mts +3 -3
- package/dist/adapters/fetch/index.d.ts +3 -3
- package/dist/adapters/fetch/index.mjs +2 -2
- package/dist/adapters/node/index.d.mts +3 -3
- package/dist/adapters/node/index.d.ts +3 -3
- package/dist/adapters/node/index.mjs +2 -2
- package/dist/adapters/standard/index.d.mts +10 -5
- package/dist/adapters/standard/index.d.ts +10 -5
- package/dist/adapters/standard/index.mjs +2 -2
- package/dist/index.d.mts +47 -42
- package/dist/index.d.ts +47 -42
- package/dist/index.mjs +34 -12
- package/dist/openapi/index.d.mts +1 -1
- package/dist/openapi/index.d.ts +1 -1
- package/dist/openapi/index.mjs +50 -33
- package/dist/plugins/index.d.mts +2 -2
- package/dist/plugins/index.d.ts +2 -2
- package/dist/shared/{server.BlJrjUA9.d.mts → server.BRCH88Sb.d.mts} +1 -1
- package/dist/shared/{server.JI4dqTgD.d.ts → server.Bb9Wxubg.d.ts} +2 -2
- package/dist/shared/{server.BYnDyuDL.d.mts → server.BbfNcgas.d.mts} +2 -2
- package/dist/shared/{server.C-tNYmY_.d.ts → server.D24uJlXJ.d.ts} +1 -1
- package/dist/shared/{server.CjkiSCui.mjs → server.DlRH_uit.mjs} +24 -11
- package/dist/shared/{server.WsFQIubj.d.mts → server.XpnxYU3D.d.mts} +32 -20
- package/dist/shared/{server.WsFQIubj.d.ts → server.XpnxYU3D.d.ts} +32 -20
- package/dist/shared/{server.DdHBdcen.mjs → server.u-02Z0mj.mjs} +12 -20
- package/package.json +10 -10
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ErrorMap, ErrorMapItem, InferSchemaInput,
|
|
1
|
+
import { ErrorMap, ErrorMapItem, InferSchemaInput, Schemas, Meta, ContractProcedureDef, AnyContractRouter, ContractProcedure, InferProcedureClientInputs, InferSchemaOutput, EnhanceRouteOptions, MergedErrorMap, AnyContractProcedure, ContractRouter, AnySchema, ErrorFromErrorMap } from '@temporary-name/contract';
|
|
2
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>;
|
|
@@ -13,19 +13,27 @@ type ORPCErrorConstructorMap<T extends ErrorMap> = {
|
|
|
13
13
|
};
|
|
14
14
|
declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
|
|
15
15
|
|
|
16
|
-
interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput
|
|
16
|
+
interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput extends {
|
|
17
|
+
path: any;
|
|
18
|
+
query: any;
|
|
19
|
+
body: any;
|
|
20
|
+
}, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
|
17
21
|
context: TCurrentContext;
|
|
18
22
|
input: TInput;
|
|
19
23
|
path: readonly string[];
|
|
20
|
-
procedure: Procedure<Context, Context,
|
|
24
|
+
procedure: Procedure<Context, Context, Schemas, ErrorMap, TMeta>;
|
|
21
25
|
signal?: AbortSignal;
|
|
22
26
|
lastEventId: string | undefined;
|
|
23
27
|
errors: TErrorConstructorMap;
|
|
24
28
|
}
|
|
25
|
-
interface ProcedureHandler<TCurrentContext extends Context, TInput
|
|
29
|
+
interface ProcedureHandler<TCurrentContext extends Context, TInput extends {
|
|
30
|
+
path: any;
|
|
31
|
+
query: any;
|
|
32
|
+
body: any;
|
|
33
|
+
}, THandlerOutput, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
26
34
|
(opt: ProcedureHandlerOptions<TCurrentContext, TInput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): Promisable<THandlerOutput>;
|
|
27
35
|
}
|
|
28
|
-
interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context,
|
|
36
|
+
interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TSchemas, TErrorMap, TMeta> {
|
|
29
37
|
__initialContext?: (type: TInitialContext) => unknown;
|
|
30
38
|
middlewares: readonly AnyMiddleware[];
|
|
31
39
|
inputValidationIndex: number;
|
|
@@ -37,14 +45,14 @@ interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends
|
|
|
37
45
|
*
|
|
38
46
|
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
39
47
|
*/
|
|
40
|
-
declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context,
|
|
48
|
+
declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
41
49
|
/**
|
|
42
50
|
* This property holds the defined options.
|
|
43
51
|
*/
|
|
44
|
-
'~orpc': ProcedureDef<TInitialContext, TCurrentContext,
|
|
45
|
-
constructor(def: ProcedureDef<TInitialContext, TCurrentContext,
|
|
52
|
+
'~orpc': ProcedureDef<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta>;
|
|
53
|
+
constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta>);
|
|
46
54
|
}
|
|
47
|
-
type AnyProcedure = Procedure<any, any,
|
|
55
|
+
type AnyProcedure = Procedure<any, any, Schemas, any, any>;
|
|
48
56
|
declare function isProcedure(item: unknown): item is AnyProcedure;
|
|
49
57
|
|
|
50
58
|
type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
|
|
@@ -65,7 +73,7 @@ interface MiddlewareOutputFn<TOutput> {
|
|
|
65
73
|
interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
|
66
74
|
context: TInContext;
|
|
67
75
|
path: readonly string[];
|
|
68
|
-
procedure: Procedure<Context, Context,
|
|
76
|
+
procedure: Procedure<Context, Context, Schemas, ErrorMap, TMeta>;
|
|
69
77
|
signal?: AbortSignal;
|
|
70
78
|
lastEventId: string | undefined;
|
|
71
79
|
next: MiddlewareNextFn<TOutput>;
|
|
@@ -91,7 +99,7 @@ declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<
|
|
|
91
99
|
* @info A procedure is a router too.
|
|
92
100
|
* @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#contract-router Contract Router Docs}
|
|
93
101
|
*/
|
|
94
|
-
type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer
|
|
102
|
+
type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer USchemas, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, USchemas, UErrorMap, UMeta> : {
|
|
95
103
|
[K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
|
|
96
104
|
};
|
|
97
105
|
type AnyRouter = Router<any, any>;
|
|
@@ -102,7 +110,7 @@ type InferRouterInitialContext<T extends AnyRouter> = T extends Router<any, infe
|
|
|
102
110
|
* @info A procedure is a router too.
|
|
103
111
|
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
104
112
|
*/
|
|
105
|
-
type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any
|
|
113
|
+
type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any> ? UInitialContext : {
|
|
106
114
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInitialContexts<U> : never;
|
|
107
115
|
};
|
|
108
116
|
/**
|
|
@@ -111,7 +119,7 @@ type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer
|
|
|
111
119
|
* @info A procedure is a router too.
|
|
112
120
|
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
113
121
|
*/
|
|
114
|
-
type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any
|
|
122
|
+
type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any> ? UCurrentContext : {
|
|
115
123
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterCurrentContexts<U> : never;
|
|
116
124
|
};
|
|
117
125
|
/**
|
|
@@ -120,7 +128,7 @@ type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any,
|
|
|
120
128
|
* @info A procedure is a router too.
|
|
121
129
|
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
122
130
|
*/
|
|
123
|
-
type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer
|
|
131
|
+
type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer USchemas, any, any> ? InferProcedureClientInputs<USchemas> : {
|
|
124
132
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInputs<U> : never;
|
|
125
133
|
};
|
|
126
134
|
/**
|
|
@@ -129,7 +137,7 @@ type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infe
|
|
|
129
137
|
* @info A procedure is a router too.
|
|
130
138
|
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
131
139
|
*/
|
|
132
|
-
type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any,
|
|
140
|
+
type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, infer USchemas, any, any> ? InferSchemaOutput<USchemas['outputSchema']> : {
|
|
133
141
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
|
|
134
142
|
};
|
|
135
143
|
|
|
@@ -138,7 +146,7 @@ type AccessibleLazyRouter<T extends Lazyable<AnyRouter | undefined>> = T extends
|
|
|
138
146
|
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? AccessibleLazyRouter<T[K]> : never;
|
|
139
147
|
};
|
|
140
148
|
declare function createAccessibleLazyRouter<T extends Lazy<AnyRouter | undefined>>(lazied: T): AccessibleLazyRouter<T>;
|
|
141
|
-
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
|
|
149
|
+
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> : {
|
|
142
150
|
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? EnhancedRouter<T[K], TInitialContext, TCurrentContext, TErrorMap> : never;
|
|
143
151
|
};
|
|
144
152
|
interface EnhanceRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
|
|
@@ -203,13 +211,17 @@ declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
|
|
|
203
211
|
default: T extends Lazy<infer U> ? U : T;
|
|
204
212
|
}>;
|
|
205
213
|
|
|
206
|
-
type ProcedureClient<TClientContext extends ClientContext,
|
|
214
|
+
type ProcedureClient<TClientContext extends ClientContext, TSchemas extends Schemas, TErrorMap extends ErrorMap> = Client<TClientContext, InferProcedureClientInputs<TSchemas>, InferSchemaOutput<TSchemas['outputSchema']>, ErrorFromErrorMap<TErrorMap>>;
|
|
207
215
|
interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
208
216
|
context: TInitialContext;
|
|
209
|
-
input:
|
|
217
|
+
input: {
|
|
218
|
+
path: unknown;
|
|
219
|
+
query: unknown;
|
|
220
|
+
body: unknown;
|
|
221
|
+
};
|
|
210
222
|
errors: ORPCErrorConstructorMap<TErrorMap>;
|
|
211
223
|
path: readonly string[];
|
|
212
|
-
procedure: Procedure<Context, Context,
|
|
224
|
+
procedure: Procedure<Context, Context, Schemas, ErrorMap, TMeta>;
|
|
213
225
|
signal?: AbortSignal;
|
|
214
226
|
lastEventId: string | undefined;
|
|
215
227
|
}
|
|
@@ -229,7 +241,7 @@ type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema
|
|
|
229
241
|
*
|
|
230
242
|
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
231
243
|
*/
|
|
232
|
-
declare function createProcedureClient<TInitialContext extends Context,
|
|
244
|
+
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>;
|
|
233
245
|
|
|
234
246
|
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 };
|
|
235
247
|
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,4 +1,4 @@
|
|
|
1
|
-
import { ErrorMap, ErrorMapItem, InferSchemaInput,
|
|
1
|
+
import { ErrorMap, ErrorMapItem, InferSchemaInput, Schemas, Meta, ContractProcedureDef, AnyContractRouter, ContractProcedure, InferProcedureClientInputs, InferSchemaOutput, EnhanceRouteOptions, MergedErrorMap, AnyContractProcedure, ContractRouter, AnySchema, ErrorFromErrorMap } from '@temporary-name/contract';
|
|
2
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>;
|
|
@@ -13,19 +13,27 @@ type ORPCErrorConstructorMap<T extends ErrorMap> = {
|
|
|
13
13
|
};
|
|
14
14
|
declare function createORPCErrorConstructorMap<T extends ErrorMap>(errors: T): ORPCErrorConstructorMap<T>;
|
|
15
15
|
|
|
16
|
-
interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput
|
|
16
|
+
interface ProcedureHandlerOptions<TCurrentContext extends Context, TInput extends {
|
|
17
|
+
path: any;
|
|
18
|
+
query: any;
|
|
19
|
+
body: any;
|
|
20
|
+
}, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
|
17
21
|
context: TCurrentContext;
|
|
18
22
|
input: TInput;
|
|
19
23
|
path: readonly string[];
|
|
20
|
-
procedure: Procedure<Context, Context,
|
|
24
|
+
procedure: Procedure<Context, Context, Schemas, ErrorMap, TMeta>;
|
|
21
25
|
signal?: AbortSignal;
|
|
22
26
|
lastEventId: string | undefined;
|
|
23
27
|
errors: TErrorConstructorMap;
|
|
24
28
|
}
|
|
25
|
-
interface ProcedureHandler<TCurrentContext extends Context, TInput
|
|
29
|
+
interface ProcedureHandler<TCurrentContext extends Context, TInput extends {
|
|
30
|
+
path: any;
|
|
31
|
+
query: any;
|
|
32
|
+
body: any;
|
|
33
|
+
}, THandlerOutput, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
26
34
|
(opt: ProcedureHandlerOptions<TCurrentContext, TInput, ORPCErrorConstructorMap<TErrorMap>, TMeta>): Promisable<THandlerOutput>;
|
|
27
35
|
}
|
|
28
|
-
interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context,
|
|
36
|
+
interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> extends ContractProcedureDef<TSchemas, TErrorMap, TMeta> {
|
|
29
37
|
__initialContext?: (type: TInitialContext) => unknown;
|
|
30
38
|
middlewares: readonly AnyMiddleware[];
|
|
31
39
|
inputValidationIndex: number;
|
|
@@ -37,14 +45,14 @@ interface ProcedureDef<TInitialContext extends Context, TCurrentContext extends
|
|
|
37
45
|
*
|
|
38
46
|
* @see {@link https://orpc.unnoq.com/docs/procedure Procedure Docs}
|
|
39
47
|
*/
|
|
40
|
-
declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context,
|
|
48
|
+
declare class Procedure<TInitialContext extends Context, TCurrentContext extends Context, TSchemas extends Schemas, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
41
49
|
/**
|
|
42
50
|
* This property holds the defined options.
|
|
43
51
|
*/
|
|
44
|
-
'~orpc': ProcedureDef<TInitialContext, TCurrentContext,
|
|
45
|
-
constructor(def: ProcedureDef<TInitialContext, TCurrentContext,
|
|
52
|
+
'~orpc': ProcedureDef<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta>;
|
|
53
|
+
constructor(def: ProcedureDef<TInitialContext, TCurrentContext, TSchemas, TErrorMap, TMeta>);
|
|
46
54
|
}
|
|
47
|
-
type AnyProcedure = Procedure<any, any,
|
|
55
|
+
type AnyProcedure = Procedure<any, any, Schemas, any, any>;
|
|
48
56
|
declare function isProcedure(item: unknown): item is AnyProcedure;
|
|
49
57
|
|
|
50
58
|
type MiddlewareResult<TOutContext extends Context, TOutput> = Promisable<{
|
|
@@ -65,7 +73,7 @@ interface MiddlewareOutputFn<TOutput> {
|
|
|
65
73
|
interface MiddlewareOptions<TInContext extends Context, TOutput, TErrorConstructorMap extends ORPCErrorConstructorMap<any>, TMeta extends Meta> {
|
|
66
74
|
context: TInContext;
|
|
67
75
|
path: readonly string[];
|
|
68
|
-
procedure: Procedure<Context, Context,
|
|
76
|
+
procedure: Procedure<Context, Context, Schemas, ErrorMap, TMeta>;
|
|
69
77
|
signal?: AbortSignal;
|
|
70
78
|
lastEventId: string | undefined;
|
|
71
79
|
next: MiddlewareNextFn<TOutput>;
|
|
@@ -91,7 +99,7 @@ declare function middlewareOutputFn<TOutput>(output: TOutput): MiddlewareResult<
|
|
|
91
99
|
* @info A procedure is a router too.
|
|
92
100
|
* @see {@link https://orpc.unnoq.com/docs/contract-first/define-contract#contract-router Contract Router Docs}
|
|
93
101
|
*/
|
|
94
|
-
type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer
|
|
102
|
+
type Router<T extends AnyContractRouter, TInitialContext extends Context> = T extends ContractProcedure<infer USchemas, infer UErrorMap, infer UMeta> ? Procedure<TInitialContext, any, USchemas, UErrorMap, UMeta> : {
|
|
95
103
|
[K in keyof T]: T[K] extends AnyContractRouter ? Lazyable<Router<T[K], TInitialContext>> : never;
|
|
96
104
|
};
|
|
97
105
|
type AnyRouter = Router<any, any>;
|
|
@@ -102,7 +110,7 @@ type InferRouterInitialContext<T extends AnyRouter> = T extends Router<any, infe
|
|
|
102
110
|
* @info A procedure is a router too.
|
|
103
111
|
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
104
112
|
*/
|
|
105
|
-
type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any
|
|
113
|
+
type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer UInitialContext, any, any, any, any> ? UInitialContext : {
|
|
106
114
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInitialContexts<U> : never;
|
|
107
115
|
};
|
|
108
116
|
/**
|
|
@@ -111,7 +119,7 @@ type InferRouterInitialContexts<T extends AnyRouter> = T extends Procedure<infer
|
|
|
111
119
|
* @info A procedure is a router too.
|
|
112
120
|
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
113
121
|
*/
|
|
114
|
-
type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any
|
|
122
|
+
type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any, infer UCurrentContext, any, any, any> ? UCurrentContext : {
|
|
115
123
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterCurrentContexts<U> : never;
|
|
116
124
|
};
|
|
117
125
|
/**
|
|
@@ -120,7 +128,7 @@ type InferRouterCurrentContexts<T extends AnyRouter> = T extends Procedure<any,
|
|
|
120
128
|
* @info A procedure is a router too.
|
|
121
129
|
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
122
130
|
*/
|
|
123
|
-
type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer
|
|
131
|
+
type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infer USchemas, any, any> ? InferProcedureClientInputs<USchemas> : {
|
|
124
132
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterInputs<U> : never;
|
|
125
133
|
};
|
|
126
134
|
/**
|
|
@@ -129,7 +137,7 @@ type InferRouterInputs<T extends AnyRouter> = T extends Procedure<any, any, infe
|
|
|
129
137
|
* @info A procedure is a router too.
|
|
130
138
|
* @see {@link https://orpc.unnoq.com/docs/router#utilities Router Utilities Docs}
|
|
131
139
|
*/
|
|
132
|
-
type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any,
|
|
140
|
+
type InferRouterOutputs<T extends AnyRouter> = T extends Procedure<any, any, infer USchemas, any, any> ? InferSchemaOutput<USchemas['outputSchema']> : {
|
|
133
141
|
[K in keyof T]: T[K] extends Lazyable<infer U extends AnyRouter> ? InferRouterOutputs<U> : never;
|
|
134
142
|
};
|
|
135
143
|
|
|
@@ -138,7 +146,7 @@ type AccessibleLazyRouter<T extends Lazyable<AnyRouter | undefined>> = T extends
|
|
|
138
146
|
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? AccessibleLazyRouter<T[K]> : never;
|
|
139
147
|
};
|
|
140
148
|
declare function createAccessibleLazyRouter<T extends Lazy<AnyRouter | undefined>>(lazied: T): AccessibleLazyRouter<T>;
|
|
141
|
-
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
|
|
149
|
+
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> : {
|
|
142
150
|
[K in keyof T]: T[K] extends Lazyable<AnyRouter> ? EnhancedRouter<T[K], TInitialContext, TCurrentContext, TErrorMap> : never;
|
|
143
151
|
};
|
|
144
152
|
interface EnhanceRouterOptions<TErrorMap extends ErrorMap> extends EnhanceRouteOptions {
|
|
@@ -203,13 +211,17 @@ declare function unlazy<T extends Lazyable<any>>(lazied: T): Promise<{
|
|
|
203
211
|
default: T extends Lazy<infer U> ? U : T;
|
|
204
212
|
}>;
|
|
205
213
|
|
|
206
|
-
type ProcedureClient<TClientContext extends ClientContext,
|
|
214
|
+
type ProcedureClient<TClientContext extends ClientContext, TSchemas extends Schemas, TErrorMap extends ErrorMap> = Client<TClientContext, InferProcedureClientInputs<TSchemas>, InferSchemaOutput<TSchemas['outputSchema']>, ErrorFromErrorMap<TErrorMap>>;
|
|
207
215
|
interface ProcedureClientInterceptorOptions<TInitialContext extends Context, TErrorMap extends ErrorMap, TMeta extends Meta> {
|
|
208
216
|
context: TInitialContext;
|
|
209
|
-
input:
|
|
217
|
+
input: {
|
|
218
|
+
path: unknown;
|
|
219
|
+
query: unknown;
|
|
220
|
+
body: unknown;
|
|
221
|
+
};
|
|
210
222
|
errors: ORPCErrorConstructorMap<TErrorMap>;
|
|
211
223
|
path: readonly string[];
|
|
212
|
-
procedure: Procedure<Context, Context,
|
|
224
|
+
procedure: Procedure<Context, Context, Schemas, ErrorMap, TMeta>;
|
|
213
225
|
signal?: AbortSignal;
|
|
214
226
|
lastEventId: string | undefined;
|
|
215
227
|
}
|
|
@@ -229,7 +241,7 @@ type CreateProcedureClientOptions<TInitialContext extends Context, TOutputSchema
|
|
|
229
241
|
*
|
|
230
242
|
* @see {@link https://orpc.unnoq.com/docs/client/server-side Server-side Client Docs}
|
|
231
243
|
*/
|
|
232
|
-
declare function createProcedureClient<TInitialContext extends Context,
|
|
244
|
+
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>;
|
|
233
245
|
|
|
234
246
|
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 };
|
|
235
247
|
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,26 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { stringifyJSON, isObject, isORPCErrorStatus, tryDecodeURIComponent, toHttpPath, toArray, intercept, runWithSpan, ORPC_NAME, isAsyncIteratorObject, asyncIteratorWithSpan, setSpanError, ORPCError, toORPCError } from '@temporary-name/shared';
|
|
2
2
|
import { flattenHeader } from '@temporary-name/standard-server';
|
|
3
|
-
import { c as createProcedureClient } from './server.
|
|
3
|
+
import { c as createProcedureClient } from './server.DlRH_uit.mjs';
|
|
4
4
|
import { fallbackContractConfig } from '@temporary-name/contract';
|
|
5
|
-
import { d as deserialize,
|
|
5
|
+
import { d as deserialize, b as bracketNotationDeserialize, s as serialize, a as standardizeHTTPPath } from './server.Kxw442A9.mjs';
|
|
6
6
|
import { traverseContractProcedures, isProcedure, getLazyMeta, unlazy, getRouter, createContractedProcedure } from '@temporary-name/server';
|
|
7
7
|
import { createRouter, addRoute, findRoute } from 'rou3';
|
|
8
8
|
|
|
9
9
|
async function decode(request, pathParams) {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
return {
|
|
11
|
+
path: pathParams ?? {},
|
|
12
|
+
query: bracketNotationDeserialize(Array.from(request.url.searchParams.entries())),
|
|
13
|
+
headers: request.headers,
|
|
14
|
+
body: deserialize(await request.body()) ?? {}
|
|
12
15
|
};
|
|
13
|
-
const data = request.method === "GET" ? deserializeSearchParams() : deserialize(await request.body());
|
|
14
|
-
if (data === void 0) {
|
|
15
|
-
return pathParams;
|
|
16
|
-
}
|
|
17
|
-
if (isObject(data)) {
|
|
18
|
-
return {
|
|
19
|
-
...pathParams,
|
|
20
|
-
...data
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
return data;
|
|
24
16
|
}
|
|
25
17
|
function encode(output, procedure) {
|
|
26
18
|
const successStatus = fallbackContractConfig(
|
|
@@ -214,12 +206,12 @@ class StandardHandler {
|
|
|
214
206
|
span?.setAttribute("rpc.system", ORPC_NAME);
|
|
215
207
|
span?.setAttribute("rpc.method", match.path.join("."));
|
|
216
208
|
step = "decode_input";
|
|
217
|
-
|
|
209
|
+
const input = await runWithSpan({ name: "decode_input" }, () => decode(request2, match.params));
|
|
218
210
|
step = void 0;
|
|
219
|
-
if (isAsyncIteratorObject(input)) {
|
|
220
|
-
input = asyncIteratorWithSpan(
|
|
211
|
+
if (isAsyncIteratorObject(input.body)) {
|
|
212
|
+
input.body = asyncIteratorWithSpan(
|
|
221
213
|
{ name: "consume_event_iterator_input", signal: request2.signal },
|
|
222
|
-
input
|
|
214
|
+
input.body
|
|
223
215
|
);
|
|
224
216
|
}
|
|
225
217
|
const client = createProcedureClient(match.procedure, {
|
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.32780b2c7ad58cf8dcbc93a40f13494185223e6e",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://www.stainless.com/",
|
|
7
7
|
"repository": {
|
|
@@ -73,15 +73,15 @@
|
|
|
73
73
|
"cookie": "^1.0.2",
|
|
74
74
|
"rou3": "^0.7.7",
|
|
75
75
|
"zod": "^4.1.12",
|
|
76
|
-
"@temporary-name/
|
|
77
|
-
"@temporary-name/
|
|
78
|
-
"@temporary-name/
|
|
79
|
-
"@temporary-name/standard-server": "1.9.3-alpha.
|
|
80
|
-
"@temporary-name/standard-server-
|
|
81
|
-
"@temporary-name/
|
|
82
|
-
"@temporary-name/
|
|
83
|
-
"@temporary-name/
|
|
84
|
-
"@temporary-name/standard-server-
|
|
76
|
+
"@temporary-name/interop": "1.9.3-alpha.32780b2c7ad58cf8dcbc93a40f13494185223e6e",
|
|
77
|
+
"@temporary-name/contract": "1.9.3-alpha.32780b2c7ad58cf8dcbc93a40f13494185223e6e",
|
|
78
|
+
"@temporary-name/standard-server": "1.9.3-alpha.32780b2c7ad58cf8dcbc93a40f13494185223e6e",
|
|
79
|
+
"@temporary-name/standard-server-fetch": "1.9.3-alpha.32780b2c7ad58cf8dcbc93a40f13494185223e6e",
|
|
80
|
+
"@temporary-name/standard-server-node": "1.9.3-alpha.32780b2c7ad58cf8dcbc93a40f13494185223e6e",
|
|
81
|
+
"@temporary-name/zod": "1.9.3-alpha.32780b2c7ad58cf8dcbc93a40f13494185223e6e",
|
|
82
|
+
"@temporary-name/shared": "1.9.3-alpha.32780b2c7ad58cf8dcbc93a40f13494185223e6e",
|
|
83
|
+
"@temporary-name/json-schema": "1.9.3-alpha.32780b2c7ad58cf8dcbc93a40f13494185223e6e",
|
|
84
|
+
"@temporary-name/standard-server-aws-lambda": "1.9.3-alpha.32780b2c7ad58cf8dcbc93a40f13494185223e6e"
|
|
85
85
|
},
|
|
86
86
|
"devDependencies": {
|
|
87
87
|
"@types/supertest": "^6.0.3",
|