@trpc/server 9.4.0 → 9.6.1
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/declarations/src/adapters/node-http/types.d.ts +1 -1
- package/dist/declarations/src/adapters/node-http/types.d.ts.map +1 -1
- package/dist/declarations/src/deprecated/LegacyRouter.d.ts +3 -0
- package/dist/declarations/src/deprecated/LegacyRouter.d.ts.map +1 -0
- package/dist/declarations/src/index.d.ts +1 -1
- package/dist/declarations/src/index.d.ts.map +1 -1
- package/dist/declarations/src/internals/middlewares.d.ts +14 -8
- package/dist/declarations/src/internals/middlewares.d.ts.map +1 -1
- package/dist/declarations/src/internals/procedure.d.ts +11 -10
- package/dist/declarations/src/internals/procedure.d.ts.map +1 -1
- package/dist/declarations/src/router.d.ts +36 -23
- package/dist/declarations/src/router.d.ts.map +1 -1
- package/dist/declarations/src/types.d.ts.map +1 -1
- package/dist/trpc-server.cjs.dev.js +47 -31
- package/dist/trpc-server.cjs.prod.js +47 -31
- package/dist/trpc-server.esm.js +46 -31
- package/package.json +3 -3
- package/src/adapters/node-http/types.ts +1 -1
- package/src/deprecated/LegacyRouter.ts +3 -0
- package/src/index.ts +1 -1
- package/src/internals/middlewares.ts +15 -8
- package/src/internals/procedure.ts +41 -28
- package/src/router.ts +144 -57
- package/src/types.ts +10 -14
|
@@ -10,7 +10,7 @@ export declare type NodeHTTPRequest = http.IncomingMessage & {
|
|
|
10
10
|
body?: unknown;
|
|
11
11
|
};
|
|
12
12
|
export declare type NodeHTTPResponse = http.ServerResponse;
|
|
13
|
-
export declare type NodeHTTPCreateContextOption<TRouter extends AnyRouter, TRequest, TResponse> = inferRouterContext<TRouter>
|
|
13
|
+
export declare type NodeHTTPCreateContextOption<TRouter extends AnyRouter, TRequest, TResponse> = unknown extends inferRouterContext<TRouter> ? {
|
|
14
14
|
/**
|
|
15
15
|
* @link https://trpc.io/docs/context
|
|
16
16
|
**/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"../../../../../src/adapters/node-http","sources":["types.ts"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,oBAAY,eAAe,GAAG,IAAI,CAAC,eAAe,GAAG;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AACF,oBAAY,gBAAgB,GAAG,IAAI,CAAC,cAAc,CAAC;AAEnD,oBAAY,2BAA2B,CACrC,OAAO,SAAS,SAAS,EACzB,QAAQ,EACR,SAAS,IACP,kBAAkB,CAAC,OAAO,CAAC,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"../../../../../src/adapters/node-http","sources":["types.ts"],"names":[],"mappings":";AAAA,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,EAAE,MAAM,IAAI,CAAC;AACpB,OAAO,EAAE,kBAAkB,EAAE,MAAM,OAAO,CAAC;AAC3C,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,oBAAY,eAAe,GAAG,IAAI,CAAC,eAAe,GAAG;IACnD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC;CAChB,CAAC;AACF,oBAAY,gBAAgB,GAAG,IAAI,CAAC,cAAc,CAAC;AAEnD,oBAAY,2BAA2B,CACrC,OAAO,SAAS,SAAS,EACzB,QAAQ,EACR,SAAS,IACP,OAAO,SAAS,kBAAkB,CAAC,OAAO,CAAC,GAC3C;IACE;;QAEI;IACJ,aAAa,CAAC,EAAE,uBAAuB,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;CACvE,GACD;IACE;;QAEI;IACJ,aAAa,EAAE,uBAAuB,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;CACtE,CAAC;AAEN,oBAAY,sBAAsB,CAChC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,eAAe,EAChC,SAAS,SAAS,gBAAgB,IAChC,sBAAsB,CAAC,OAAO,EAAE,QAAQ,CAAC,GAAG;IAC9C,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,2BAA2B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAE9D,oBAAY,8BAA8B,CAAC,QAAQ,EAAE,SAAS,IAAI;IAChE,GAAG,EAAE,QAAQ,CAAC;IACd,GAAG,EAAE,SAAS,CAAC;CAChB,CAAC;AACF,oBAAY,uBAAuB,CACjC,OAAO,SAAS,SAAS,EACzB,QAAQ,EACR,SAAS,IACP,CACF,IAAI,EAAE,8BAA8B,CAAC,QAAQ,EAAE,SAAS,CAAC,KACtD,kBAAkB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LegacyRouter.d.ts","sourceRoot":"../../../../src/deprecated","sources":["LegacyRouter.ts"],"names":[],"mappings":"AAAA,cAAc,WAAW,CAAC;AAE1B,OAAO,EAAE,YAAY,IAAI,MAAM,EAAE,MAAM,WAAW,CAAC"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
export * from './assertNotBrowser';
|
|
2
2
|
export * from './http';
|
|
3
|
-
export * from './router';
|
|
4
3
|
export * from './subscription';
|
|
5
4
|
export * from './transformer';
|
|
6
5
|
export * from './TRPCError';
|
|
7
6
|
export * from './types';
|
|
8
7
|
export * from './deprecated/createHttpServer';
|
|
9
8
|
export * from './deprecated/requestHandler';
|
|
9
|
+
export * from './deprecated/LegacyRouter';
|
|
10
10
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"../../../src","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,QAAQ,CAAC;AACvB,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"../../../src","sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,oBAAoB,CAAC;AACnC,cAAc,QAAQ,CAAC;AACvB,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AAGxB,cAAc,+BAA+B,CAAC;AAC9C,cAAc,6BAA6B,CAAC;AAC5C,cAAc,2BAA2B,CAAC"}
|
|
@@ -1,27 +1,33 @@
|
|
|
1
1
|
import { ProcedureType } from '../router';
|
|
2
2
|
import { TRPCError } from '../TRPCError';
|
|
3
3
|
export declare const middlewareMarker: unique symbol;
|
|
4
|
-
interface MiddlewareResultBase {
|
|
4
|
+
interface MiddlewareResultBase<TContext> {
|
|
5
5
|
/**
|
|
6
6
|
* All middlewares should pass through their `next()`'s output.
|
|
7
7
|
* Requiring this marker makes sure that can't be forgotten at compile-time.
|
|
8
8
|
*/
|
|
9
9
|
readonly marker: typeof middlewareMarker;
|
|
10
|
+
ctx: TContext;
|
|
10
11
|
}
|
|
11
|
-
interface MiddlewareOKResult extends MiddlewareResultBase {
|
|
12
|
+
interface MiddlewareOKResult<TContext> extends MiddlewareResultBase<TContext> {
|
|
12
13
|
ok: true;
|
|
13
14
|
data: unknown;
|
|
14
15
|
}
|
|
15
|
-
interface MiddlewareErrorResult extends MiddlewareResultBase {
|
|
16
|
+
interface MiddlewareErrorResult<TContext> extends MiddlewareResultBase<TContext> {
|
|
16
17
|
ok: false;
|
|
17
18
|
error: TRPCError;
|
|
18
19
|
}
|
|
19
|
-
export declare type MiddlewareResult = MiddlewareOKResult | MiddlewareErrorResult
|
|
20
|
-
export declare type MiddlewareFunction<TContext> = (opts: {
|
|
21
|
-
ctx:
|
|
20
|
+
export declare type MiddlewareResult<TContext> = MiddlewareOKResult<TContext> | MiddlewareErrorResult<TContext>;
|
|
21
|
+
export declare type MiddlewareFunction<TInputContext, TContext> = (opts: {
|
|
22
|
+
ctx: TInputContext;
|
|
22
23
|
type: ProcedureType;
|
|
23
24
|
path: string;
|
|
24
|
-
next:
|
|
25
|
-
|
|
25
|
+
next: {
|
|
26
|
+
(): Promise<MiddlewareResult<TInputContext>>;
|
|
27
|
+
<T>(opts: {
|
|
28
|
+
ctx: T;
|
|
29
|
+
}): Promise<MiddlewareResult<T>>;
|
|
30
|
+
};
|
|
31
|
+
}) => Promise<MiddlewareResult<TContext>>;
|
|
26
32
|
export {};
|
|
27
33
|
//# sourceMappingURL=middlewares.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"middlewares.d.ts","sourceRoot":"../../../../src/internals","sources":["middlewares.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,eAAO,MAAM,gBAAgB,eAA6B,CAAC;AAC3D,UAAU,oBAAoB;
|
|
1
|
+
{"version":3,"file":"middlewares.d.ts","sourceRoot":"../../../../src/internals","sources":["middlewares.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,eAAO,MAAM,gBAAgB,eAA6B,CAAC;AAC3D,UAAU,oBAAoB,CAAC,QAAQ;IACrC;;;OAGG;IACH,QAAQ,CAAC,MAAM,EAAE,OAAO,gBAAgB,CAAC;IACzC,GAAG,EAAE,QAAQ,CAAC;CACf;AAED,UAAU,kBAAkB,CAAC,QAAQ,CAAE,SAAQ,oBAAoB,CAAC,QAAQ,CAAC;IAC3E,EAAE,EAAE,IAAI,CAAC;IACT,IAAI,EAAE,OAAO,CAAC;CAEf;AACD,UAAU,qBAAqB,CAAC,QAAQ,CACtC,SAAQ,oBAAoB,CAAC,QAAQ,CAAC;IACtC,EAAE,EAAE,KAAK,CAAC;IACV,KAAK,EAAE,SAAS,CAAC;CAElB;AAED,oBAAY,gBAAgB,CAAC,QAAQ,IACjC,kBAAkB,CAAC,QAAQ,CAAC,GAC5B,qBAAqB,CAAC,QAAQ,CAAC,CAAC;AAEpC,oBAAY,kBAAkB,CAAC,aAAa,EAAE,QAAQ,IAAI,CAAC,IAAI,EAAE;IAC/D,GAAG,EAAE,aAAa,CAAC;IACnB,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE;QACJ,IAAI,OAAO,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC,CAAC;QAC7C,CAAC,CAAC,EAAE,IAAI,EAAE;YAAE,GAAG,EAAE,CAAC,CAAA;SAAE,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;KACrD,CAAC;CACH,KAAK,OAAO,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC,CAAC"}
|
|
@@ -14,7 +14,7 @@ export declare type ProcedureResolver<TContext = unknown, TInput = unknown, TOut
|
|
|
14
14
|
type: ProcedureType;
|
|
15
15
|
}) => Promise<TOutput> | TOutput;
|
|
16
16
|
interface ProcedureOptions<TContext, TInput, TOutput> {
|
|
17
|
-
middlewares: MiddlewareFunction<
|
|
17
|
+
middlewares: Array<MiddlewareFunction<any, any>>;
|
|
18
18
|
resolver: ProcedureResolver<TContext, TInput, TOutput>;
|
|
19
19
|
inputParser: ProcedureInputParser<TInput>;
|
|
20
20
|
}
|
|
@@ -30,7 +30,8 @@ export interface ProcedureCallOptions<TContext> {
|
|
|
30
30
|
/**
|
|
31
31
|
* @internal
|
|
32
32
|
*/
|
|
33
|
-
export declare abstract class Procedure<
|
|
33
|
+
export declare abstract class Procedure<TInputContext, //
|
|
34
|
+
TContext, TInput, TOutput> {
|
|
34
35
|
private middlewares;
|
|
35
36
|
private resolver;
|
|
36
37
|
private readonly inputParser;
|
|
@@ -41,16 +42,16 @@ export declare abstract class Procedure<TContext = unknown, TInput = unknown, TO
|
|
|
41
42
|
* Trigger middlewares in order, parse raw input & call resolver
|
|
42
43
|
* @internal
|
|
43
44
|
*/
|
|
44
|
-
call(opts: ProcedureCallOptions<
|
|
45
|
+
call(opts: ProcedureCallOptions<TInputContext>): Promise<TOutput>;
|
|
45
46
|
/**
|
|
46
47
|
* Create new procedure with passed middlewares
|
|
47
48
|
* @param middlewares
|
|
48
49
|
*/
|
|
49
|
-
inheritMiddlewares(middlewares: MiddlewareFunction<TContext>[]): this;
|
|
50
|
+
inheritMiddlewares(middlewares: MiddlewareFunction<TInputContext, TContext>[]): this;
|
|
50
51
|
}
|
|
51
|
-
export declare class ProcedureWithoutInput<TContext, TOutput> extends Procedure<TContext, undefined, TOutput> {
|
|
52
|
+
export declare class ProcedureWithoutInput<TInputContext, TContext, TOutput> extends Procedure<TInputContext, TContext, undefined, TOutput> {
|
|
52
53
|
}
|
|
53
|
-
export declare class ProcedureWithInput<TContext, TInput, TOutput> extends Procedure<TContext, TInput, TOutput> {
|
|
54
|
+
export declare class ProcedureWithInput<TInputContext, TContext, TInput, TOutput> extends Procedure<TInputContext, TContext, TInput, TOutput> {
|
|
54
55
|
}
|
|
55
56
|
export declare type CreateProcedureWithInput<TContext, TInput, TOutput> = {
|
|
56
57
|
input: ProcedureInputParser<TInput>;
|
|
@@ -60,9 +61,9 @@ export declare type CreateProcedureWithoutInput<TContext, TOutput> = {
|
|
|
60
61
|
resolve: ProcedureResolver<TContext, undefined, TOutput>;
|
|
61
62
|
};
|
|
62
63
|
export declare type CreateProcedureOptions<TContext = unknown, TInput = unknown, TOutput = unknown> = CreateProcedureWithInput<TContext, TInput, TOutput> | CreateProcedureWithoutInput<TContext, TOutput>;
|
|
63
|
-
export declare function createProcedure<TContext, TInput, TOutput>(opts: CreateProcedureWithInput<TContext, TInput, TOutput>): ProcedureWithInput<TContext, TInput, TOutput>;
|
|
64
|
-
export declare function createProcedure<TContext, TOutput>(opts: CreateProcedureWithoutInput<TContext, TOutput>): ProcedureWithoutInput<TContext, TOutput>;
|
|
65
|
-
export declare function createProcedure<TContext, TInput, TOutput>(opts: CreateProcedureOptions<TContext, TInput, TOutput>): Procedure<TContext, TInput, TOutput>;
|
|
66
|
-
export declare type inferProcedureFromOptions<TOptions extends CreateProcedureOptions<any, any, any>> = TOptions extends CreateProcedureWithInput<infer TContext, infer TInput, infer TOutput> ? ProcedureWithInput<TContext, TInput, TOutput> : TOptions extends CreateProcedureWithoutInput<infer TContext, infer TOutput> ? ProcedureWithoutInput<TContext, TOutput> : Procedure<unknown, unknown>;
|
|
64
|
+
export declare function createProcedure<TInputContext, TContext, TInput, TOutput>(opts: CreateProcedureWithInput<TContext, TInput, TOutput>): ProcedureWithInput<TInputContext, TContext, TInput, TOutput>;
|
|
65
|
+
export declare function createProcedure<TInputContext, TContext, TOutput>(opts: CreateProcedureWithoutInput<TContext, TOutput>): ProcedureWithoutInput<TInputContext, TContext, TOutput>;
|
|
66
|
+
export declare function createProcedure<TInputContext, TContext, TInput, TOutput>(opts: CreateProcedureOptions<TContext, TInput, TOutput>): Procedure<TInputContext, TContext, TInput, TOutput>;
|
|
67
|
+
export declare type inferProcedureFromOptions<TInputContext, TOptions extends CreateProcedureOptions<any, any, any>> = TOptions extends CreateProcedureWithInput<infer TContext, infer TInput, infer TOutput> ? ProcedureWithInput<TInputContext, TContext, TInput, TOutput> : TOptions extends CreateProcedureWithoutInput<infer TContext, infer TOutput> ? ProcedureWithoutInput<TInputContext, TContext, TOutput> : Procedure<unknown, unknown, unknown, unknown>;
|
|
67
68
|
export {};
|
|
68
69
|
//# sourceMappingURL=procedure.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"procedure.d.ts","sourceRoot":"../../../../src/internals","sources":["procedure.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,kBAAkB,EAAoB,MAAM,eAAe,CAAC;AAMrE,oBAAY,4BAA4B,CAAC,MAAM,GAAG,OAAO,IAAI;IAC3D,KAAK,EAAE,CAAC,KAAK,EAAE,GAAG,KAAK,MAAM,CAAC;CAC/B,CAAC;AAEF,oBAAY,wCAAwC,CAAC,MAAM,GAAG,OAAO,IAAI,CACvE,KAAK,EAAE,OAAO,KACX,MAAM,CAAC;AAEZ,oBAAY,4BAA4B,CAAC,MAAM,GAAG,OAAO,IAAI;IAC3D,YAAY,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC;CAC1C,CAAC;AACF,oBAAY,oBAAoB,CAAC,MAAM,GAAG,OAAO,IAC7C,4BAA4B,CAAC,MAAM,CAAC,GACpC,4BAA4B,CAAC,MAAM,CAAC,GACpC,wCAAwC,CAAC,MAAM,CAAC,CAAC;AAErD,oBAAY,iBAAiB,CAC3B,QAAQ,GAAG,OAAO,EAClB,MAAM,GAAG,OAAO,EAChB,OAAO,GAAG,OAAO,IACf,CAAC,IAAI,EAAE;IACT,GAAG,EAAE,QAAQ,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,aAAa,CAAC;CACrB,KAAK,OAAO,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AAEjC,UAAU,gBAAgB,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO;IAClD,WAAW,EAAE,
|
|
1
|
+
{"version":3,"file":"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ACD,qBAAqB,CAAC,aAAa,EAAE,QAAQ,EAAE,OAAO,CAAC,GACvD,SAAS,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,CAAC"}
|
|
@@ -4,7 +4,7 @@ import { TRPCErrorShape, TRPC_ERROR_CODE_KEY, TRPC_ERROR_CODE_NUMBER } from './r
|
|
|
4
4
|
import { Subscription } from './subscription';
|
|
5
5
|
import { CombinedDataTransformer, DataTransformerOptions } from './transformer';
|
|
6
6
|
import { TRPCError } from './TRPCError';
|
|
7
|
-
import { flatten, Prefixer, ThenArg } from './types';
|
|
7
|
+
import { flatten, format, Prefixer, ThenArg } from './types';
|
|
8
8
|
/**
|
|
9
9
|
* @public
|
|
10
10
|
*/
|
|
@@ -12,11 +12,11 @@ export declare type ProcedureType = 'query' | 'mutation' | 'subscription';
|
|
|
12
12
|
/**
|
|
13
13
|
* @internal
|
|
14
14
|
*/
|
|
15
|
-
export declare type ProcedureRecord<TContext = any, TInput = any, TOutput = any> = Record<string, Procedure<TContext, TInput, TOutput>>;
|
|
15
|
+
export declare type ProcedureRecord<TInputContext = any, TContext = any, TInput = any, TOutput = any> = Record<string, Procedure<TInputContext, TContext, TInput, TOutput>>;
|
|
16
16
|
/**
|
|
17
17
|
* @public
|
|
18
18
|
*/
|
|
19
|
-
export declare type inferProcedureInput<TProcedure extends Procedure<any, any, any>> = TProcedure extends ProcedureWithInput<any, infer Input, any> ? Input : undefined;
|
|
19
|
+
export declare type inferProcedureInput<TProcedure extends Procedure<any, any, any, any>> = TProcedure extends ProcedureWithInput<any, any, infer Input, any> ? Input : undefined;
|
|
20
20
|
/**
|
|
21
21
|
* @public
|
|
22
22
|
*/
|
|
@@ -24,7 +24,7 @@ export declare type inferAsyncReturnType<TFunction extends (...args: any) => any
|
|
|
24
24
|
/**
|
|
25
25
|
* @public
|
|
26
26
|
*/
|
|
27
|
-
export declare type inferProcedureOutput<TProcedure extends Procedure
|
|
27
|
+
export declare type inferProcedureOutput<TProcedure extends Procedure<any, any, any, any>> = inferAsyncReturnType<TProcedure['call']>;
|
|
28
28
|
/**
|
|
29
29
|
* @public
|
|
30
30
|
* @beta
|
|
@@ -33,7 +33,7 @@ export declare type inferSubscriptionOutput<TRouter extends AnyRouter, TPath ext
|
|
|
33
33
|
/**
|
|
34
34
|
* @internal
|
|
35
35
|
*/
|
|
36
|
-
export declare type inferHandlerInput<TProcedure extends Procedure
|
|
36
|
+
export declare type inferHandlerInput<TProcedure extends Procedure<any, any, any, any>> = TProcedure extends ProcedureWithInput<any, any, infer TInput, any> ? undefined extends TInput ? unknown extends TInput ? [(null | undefined)?] : [(TInput | null | undefined)?] : [TInput] : [(undefined | null)?];
|
|
37
37
|
declare type inferHandlerFn<TProcedures extends ProcedureRecord> = <TProcedure extends TProcedures[TPath], TPath extends keyof TProcedures & string>(path: TPath, ...args: inferHandlerInput<TProcedure>) => Promise<inferProcedureOutput<TProcedures[TPath]>>;
|
|
38
38
|
/**
|
|
39
39
|
* @internal
|
|
@@ -42,7 +42,7 @@ export declare type inferRouterContext<TRouter extends AnyRouter> = Parameters<T
|
|
|
42
42
|
/**
|
|
43
43
|
* @public
|
|
44
44
|
*/
|
|
45
|
-
export declare type AnyRouter<TContext = any> = Router<TContext, any, any, any, any>;
|
|
45
|
+
export declare type AnyRouter<TContext = any> = Router<any, TContext, any, any, any, any>;
|
|
46
46
|
/**
|
|
47
47
|
* @internal
|
|
48
48
|
*/
|
|
@@ -71,12 +71,19 @@ export interface DefaultErrorShape extends TRPCErrorShape<TRPC_ERROR_CODE_NUMBER
|
|
|
71
71
|
message: string;
|
|
72
72
|
code: TRPC_ERROR_CODE_NUMBER;
|
|
73
73
|
}
|
|
74
|
-
|
|
74
|
+
declare type SwapProcedureContext<TProcedure extends Procedure<any, any, any, any>, TNewContext> = TProcedure extends ProcedureWithInput<infer TInputContext, infer _TOldContext, infer TInput, infer TOutput> ? ProcedureWithInput<TInputContext, TNewContext, TInput, TOutput> : never;
|
|
75
|
+
declare type SwapContext<TObj extends ProcedureRecord<any, any, any, any>, TNewContext> = format<{
|
|
76
|
+
[P in keyof TObj]: SwapProcedureContext<TObj[P], TNewContext>;
|
|
77
|
+
}>;
|
|
78
|
+
/**
|
|
79
|
+
* @internal The type signature of this class may change without warning.
|
|
80
|
+
*/
|
|
81
|
+
export declare class Router<TInputContext, TContext, TQueries extends ProcedureRecord<TInputContext, TContext>, TMutations extends ProcedureRecord<TInputContext, TContext>, TSubscriptions extends ProcedureRecord<TInputContext, TContext, unknown, Subscription<unknown>>, TErrorShape extends TRPCErrorShape<number>> {
|
|
75
82
|
readonly _def: Readonly<{
|
|
76
83
|
queries: Readonly<TQueries>;
|
|
77
84
|
mutations: Readonly<TMutations>;
|
|
78
85
|
subscriptions: Readonly<TSubscriptions>;
|
|
79
|
-
middlewares: MiddlewareFunction<TContext>[];
|
|
86
|
+
middlewares: MiddlewareFunction<TInputContext, TContext>[];
|
|
80
87
|
errorFormatter: ErrorFormatter<TContext, TErrorShape>;
|
|
81
88
|
transformer: CombinedDataTransformer;
|
|
82
89
|
}>;
|
|
@@ -84,54 +91,53 @@ export declare class Router<TContext, TQueries extends ProcedureRecord<TContext>
|
|
|
84
91
|
queries?: TQueries;
|
|
85
92
|
mutations?: TMutations;
|
|
86
93
|
subscriptions?: TSubscriptions;
|
|
87
|
-
middlewares?: MiddlewareFunction<TContext>[];
|
|
94
|
+
middlewares?: MiddlewareFunction<TInputContext, TContext>[];
|
|
88
95
|
errorFormatter?: ErrorFormatter<TContext, TErrorShape>;
|
|
89
96
|
transformer?: CombinedDataTransformer;
|
|
90
97
|
});
|
|
91
98
|
private static prefixProcedures;
|
|
92
|
-
query<TPath extends string, TInput, TOutput>(path: TPath, procedure: CreateProcedureWithInput<TContext, TInput, TOutput>): Router<TContext, flatten<TQueries, Record<TPath, inferProcedureFromOptions<typeof procedure>>>, TMutations, TSubscriptions, TErrorShape>;
|
|
93
|
-
query<TPath extends string, TOutput>(path: TPath, procedure: CreateProcedureWithoutInput<TContext, TOutput>): Router<TContext, flatten<TQueries, Record<TPath, inferProcedureFromOptions<typeof procedure>>>, TMutations, TSubscriptions, TErrorShape>;
|
|
94
|
-
mutation<TPath extends string, TInput, TOutput>(path: TPath, procedure: CreateProcedureWithInput<TContext, TInput, TOutput>): Router<TContext, TQueries, flatten<TMutations, Record<TPath, inferProcedureFromOptions<typeof procedure>>>, TSubscriptions, TErrorShape>;
|
|
95
|
-
mutation<TPath extends string, TOutput>(path: TPath, procedure: CreateProcedureWithoutInput<TContext, TOutput>): Router<TContext, TQueries, flatten<TMutations, Record<TPath, inferProcedureFromOptions<typeof procedure>>>, TSubscriptions, TErrorShape>;
|
|
99
|
+
query<TPath extends string, TInput, TOutput>(path: TPath, procedure: CreateProcedureWithInput<TContext, TInput, TOutput>): Router<TInputContext, TContext, flatten<TQueries, Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>>, TMutations, TSubscriptions, TErrorShape>;
|
|
100
|
+
query<TPath extends string, TOutput>(path: TPath, procedure: CreateProcedureWithoutInput<TContext, TOutput>): Router<TInputContext, TContext, flatten<TQueries, Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>>, TMutations, TSubscriptions, TErrorShape>;
|
|
101
|
+
mutation<TPath extends string, TInput, TOutput>(path: TPath, procedure: CreateProcedureWithInput<TContext, TInput, TOutput>): Router<TInputContext, TContext, TQueries, flatten<TMutations, Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>>, TSubscriptions, TErrorShape>;
|
|
102
|
+
mutation<TPath extends string, TOutput>(path: TPath, procedure: CreateProcedureWithoutInput<TContext, TOutput>): Router<TInputContext, TContext, TQueries, flatten<TMutations, Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>>, TSubscriptions, TErrorShape>;
|
|
96
103
|
/**
|
|
97
104
|
* @beta Might change without a major version bump
|
|
98
105
|
*/
|
|
99
|
-
subscription<TPath extends string, TInput, TOutput extends Subscription<unknown>>(path: TPath, procedure: CreateProcedureWithInput<TContext, TInput, TOutput>): Router<TContext, TQueries, TMutations, TSubscriptions & Record<TPath, inferProcedureFromOptions<typeof procedure>>, TErrorShape>;
|
|
106
|
+
subscription<TPath extends string, TInput, TOutput extends Subscription<unknown>>(path: TPath, procedure: CreateProcedureWithInput<TContext, TInput, TOutput>): Router<TInputContext, TContext, TQueries, TMutations, TSubscriptions & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TErrorShape>;
|
|
100
107
|
/**
|
|
101
108
|
* @beta Might change without a major version bump
|
|
102
109
|
*/
|
|
103
|
-
subscription<TPath extends string, TOutput extends Subscription<unknown>>(path: TPath, procedure: CreateProcedureWithoutInput<TContext, TOutput>): Router<TContext, TQueries, TMutations, TSubscriptions & Record<TPath, inferProcedureFromOptions<typeof procedure>>, TErrorShape>;
|
|
110
|
+
subscription<TPath extends string, TOutput extends Subscription<unknown>>(path: TPath, procedure: CreateProcedureWithoutInput<TContext, TOutput>): Router<TInputContext, TContext, TQueries, TMutations, TSubscriptions & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TErrorShape>;
|
|
104
111
|
/**
|
|
105
112
|
* Merge router with other router
|
|
106
113
|
* @param router
|
|
107
114
|
*/
|
|
108
|
-
merge<TChildRouter extends
|
|
115
|
+
merge<TChildRouter extends Router<TContext, any, any, any, any, any>>(router: TChildRouter): Router<TInputContext, inferRouterContext<TChildRouter>, flatten<TQueries, TChildRouter['_def']['queries']>, flatten<TMutations, TChildRouter['_def']['mutations']>, flatten<TSubscriptions, TChildRouter['_def']['subscriptions']>, TErrorShape>;
|
|
109
116
|
/**
|
|
110
117
|
* Merge router with other router
|
|
111
118
|
* @param prefix Prefix that this router should live under
|
|
112
119
|
* @param router
|
|
113
120
|
*/
|
|
114
|
-
merge<TPath extends string, TChildRouter extends
|
|
121
|
+
merge<TPath extends string, TChildRouter extends Router<TContext, any, any, any, any, any>>(prefix: TPath, router: TChildRouter): Router<TInputContext, inferRouterContext<TChildRouter>, flatten<TQueries, Prefixer<TChildRouter['_def']['queries'], `${TPath}`>>, flatten<TMutations, Prefixer<TChildRouter['_def']['mutations'], `${TPath}`>>, flatten<TSubscriptions, Prefixer<TChildRouter['_def']['subscriptions'], `${TPath}`>>, TErrorShape>;
|
|
115
122
|
/**
|
|
116
123
|
* Invoke procedure. Only for internal use within library.
|
|
117
124
|
*/
|
|
118
125
|
private call;
|
|
119
|
-
createCaller(ctx:
|
|
126
|
+
createCaller(ctx: TInputContext): {
|
|
120
127
|
query: inferHandlerFn<TQueries>;
|
|
121
128
|
mutation: inferHandlerFn<TMutations>;
|
|
122
129
|
subscription: inferHandlerFn<TSubscriptions>;
|
|
123
130
|
};
|
|
124
131
|
/**
|
|
125
132
|
* Function to be called before any procedure is invoked
|
|
126
|
-
* Can be async or sync
|
|
127
133
|
* @link https://trpc.io/docs/middlewares
|
|
128
134
|
*/
|
|
129
|
-
middleware(middleware: MiddlewareFunction<TContext>): Router<
|
|
135
|
+
middleware<TNewContext>(middleware: MiddlewareFunction<TContext, TNewContext>): Router<TInputContext, TNewContext, SwapContext<TQueries, TNewContext>, SwapContext<TMutations, TNewContext>, SwapContext<TSubscriptions, TNewContext>, TErrorShape>;
|
|
130
136
|
/**
|
|
131
137
|
* Format errors
|
|
132
138
|
* @link https://trpc.io/docs/error-formatting
|
|
133
139
|
*/
|
|
134
|
-
formatError<TErrorFormatter extends ErrorFormatter<TContext, TRPCErrorShape<number>>>(errorFormatter: TErrorFormatter): Router<TContext, TQueries, TMutations, TSubscriptions, ReturnType<TErrorFormatter>>;
|
|
140
|
+
formatError<TErrorFormatter extends ErrorFormatter<TContext, TRPCErrorShape<number>>>(errorFormatter: TErrorFormatter): Router<TInputContext, TContext, TQueries, TMutations, TSubscriptions, ReturnType<TErrorFormatter>>;
|
|
135
141
|
getErrorShape(opts: {
|
|
136
142
|
error: TRPCError;
|
|
137
143
|
type: ProcedureType | 'unknown';
|
|
@@ -143,8 +149,15 @@ export declare class Router<TContext, TQueries extends ProcedureRecord<TContext>
|
|
|
143
149
|
* Add data transformer to serialize/deserialize input args + output
|
|
144
150
|
* @link https://trpc.io/docs/data-transformers
|
|
145
151
|
*/
|
|
146
|
-
transformer(_transformer: DataTransformerOptions): Router<TContext, TQueries, TMutations, TSubscriptions, TErrorShape>;
|
|
152
|
+
transformer(_transformer: DataTransformerOptions): Router<TInputContext, TContext, TQueries, TMutations, TSubscriptions, TErrorShape>;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Subclass of `VNextRouter` with `TInputContext` and `TContext` set to the same type, for backcompat.
|
|
156
|
+
*
|
|
157
|
+
* @deprecated
|
|
158
|
+
*/
|
|
159
|
+
export declare class LegacyRouter<TContext, TQueries extends ProcedureRecord<TContext, TContext>, TMutations extends ProcedureRecord<TContext, TContext>, TSubscriptions extends ProcedureRecord<TContext, TContext, unknown, Subscription<unknown>>, TErrorShape extends TRPCErrorShape<number>> extends Router<TContext, TContext, TQueries, TMutations, TSubscriptions, TErrorShape> {
|
|
147
160
|
}
|
|
148
|
-
export declare function router<TContext
|
|
161
|
+
export declare function router<TContext>(): Router<TContext, TContext, {}, {}, {}, DefaultErrorShape>;
|
|
149
162
|
export {};
|
|
150
163
|
//# sourceMappingURL=router.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"../../../src","sources":["router.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAGL,wBAAwB,EACxB,2BAA2B,EAC3B,yBAAyB,EACzB,SAAS,EAET,kBAAkB,EACnB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,cAAc,EAEd,mBAAmB,EACnB,sBAAsB,EACvB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAChF,OAAO,EAAE,SAAS,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GAAG,SAAS,GAAG,IAAI,CAAC;AAE5C;;GAEG;AACH,oBAAY,OAAO,CAAC,CAAC,IAAI,CAAC,SAAS,WAAW,CAAC,MAAM,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AAEzE;;GAEG;AACH,oBAAY,IAAI,CAAC,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC,CAAC"}
|
|
@@ -3,16 +3,39 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var nodeHTTPRequestHandler = require('./nodeHTTPRequestHandler-a20cbe34.cjs.dev.js');
|
|
6
|
-
var transformTRPCResponse = require('./transformTRPCResponse-8248515e.cjs.dev.js');
|
|
7
|
-
var codes = require('./codes-a0cce7aa.cjs.dev.js');
|
|
8
6
|
var subscription = require('./subscription-b8831081.cjs.dev.js');
|
|
7
|
+
var transformTRPCResponse = require('./transformTRPCResponse-8248515e.cjs.dev.js');
|
|
9
8
|
var adapters_standalone_dist_trpcServerAdaptersStandalone = require('../adapters/standalone/dist/trpc-server-adapters-standalone.cjs.dev.js');
|
|
9
|
+
var codes = require('./codes-a0cce7aa.cjs.dev.js');
|
|
10
10
|
require('url');
|
|
11
11
|
require('events');
|
|
12
12
|
require('http');
|
|
13
13
|
|
|
14
14
|
nodeHTTPRequestHandler.assertNotBrowser();
|
|
15
15
|
|
|
16
|
+
// this has been moved to separate package
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated use `createHTTPServer` from `@trpc/server/adapters/standalone`
|
|
20
|
+
*/
|
|
21
|
+
const createHttpServer = adapters_standalone_dist_trpcServerAdaptersStandalone.createHTTPServer;
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated use `createHTTPHandler` from `@trpc/server/adapters/standalone`
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
const createHttpHandler = adapters_standalone_dist_trpcServerAdaptersStandalone.createHTTPHandler;
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated use `CreateHTTPHandlerOptions` from `@trpc/server/adapters/standalone`
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated use `nodeHTTPRequestHandler` from `@trpc/server/adapters/node-http`
|
|
33
|
+
*/
|
|
34
|
+
const requestHandler = nodeHTTPRequestHandler.nodeHTTPRequestHandler;
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated use `NodeHTTPCreateContextFn` from `@trpc/server/adapters/node-http`
|
|
37
|
+
*/
|
|
38
|
+
|
|
16
39
|
const middlewareMarker = /*#__PURE__*/Symbol('middlewareMarker');
|
|
17
40
|
|
|
18
41
|
/**
|
|
@@ -89,21 +112,26 @@ class Procedure {
|
|
|
89
112
|
|
|
90
113
|
async call(opts) {
|
|
91
114
|
// wrap the actual resolver and treat as the last "middleware"
|
|
92
|
-
const middlewaresWithResolver = this.middlewares.concat([async (
|
|
115
|
+
const middlewaresWithResolver = this.middlewares.concat([async ({
|
|
116
|
+
ctx
|
|
117
|
+
}) => {
|
|
93
118
|
const input = this.parseInput(opts.rawInput);
|
|
94
119
|
const data = await this.resolver({ ...opts,
|
|
120
|
+
ctx,
|
|
95
121
|
input
|
|
96
122
|
});
|
|
97
123
|
return {
|
|
98
124
|
marker: middlewareMarker,
|
|
99
125
|
ok: true,
|
|
100
|
-
data
|
|
126
|
+
data,
|
|
127
|
+
ctx
|
|
101
128
|
};
|
|
102
129
|
}]); // create `next()` calls in resolvers
|
|
103
130
|
|
|
104
131
|
const nextFns = middlewaresWithResolver.map((fn, index) => {
|
|
105
|
-
return async
|
|
132
|
+
return async nextOpts => {
|
|
106
133
|
const res = await wrapCallSafe(() => fn({ ...opts,
|
|
134
|
+
...nextOpts,
|
|
107
135
|
next: nextFns[index + 1]
|
|
108
136
|
}));
|
|
109
137
|
|
|
@@ -235,6 +263,10 @@ const defaultTransformer = {
|
|
|
235
263
|
deserialize: obj => obj
|
|
236
264
|
}
|
|
237
265
|
};
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* @internal The type signature of this class may change without warning.
|
|
269
|
+
*/
|
|
238
270
|
class Router {
|
|
239
271
|
constructor(def) {
|
|
240
272
|
var _def$queries, _def$mutations, _def$subscriptions, _def$middlewares, _def$errorFormatter, _def$transformer;
|
|
@@ -396,7 +428,6 @@ class Router {
|
|
|
396
428
|
}
|
|
397
429
|
/**
|
|
398
430
|
* Function to be called before any procedure is invoked
|
|
399
|
-
* Can be async or sync
|
|
400
431
|
* @link https://trpc.io/docs/middlewares
|
|
401
432
|
*/
|
|
402
433
|
|
|
@@ -470,39 +501,24 @@ class Router {
|
|
|
470
501
|
}
|
|
471
502
|
|
|
472
503
|
}
|
|
473
|
-
function router() {
|
|
474
|
-
return new Router();
|
|
475
|
-
}
|
|
476
|
-
|
|
477
|
-
// this has been moved to separate package
|
|
478
|
-
|
|
479
504
|
/**
|
|
480
|
-
*
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
/**
|
|
484
|
-
* @deprecated use `createHTTPHandler` from `@trpc/server/adapters/standalone`
|
|
505
|
+
* Subclass of `VNextRouter` with `TInputContext` and `TContext` set to the same type, for backcompat.
|
|
506
|
+
*
|
|
507
|
+
* @deprecated
|
|
485
508
|
*/
|
|
486
509
|
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
/**
|
|
493
|
-
* @deprecated use `nodeHTTPRequestHandler` from `@trpc/server/adapters/node-http`
|
|
494
|
-
*/
|
|
495
|
-
const requestHandler = nodeHTTPRequestHandler.nodeHTTPRequestHandler;
|
|
496
|
-
/**
|
|
497
|
-
* @deprecated use `NodeHTTPCreateContextFn` from `@trpc/server/adapters/node-http`
|
|
498
|
-
*/
|
|
510
|
+
class LegacyRouter extends Router {}
|
|
511
|
+
function router() {
|
|
512
|
+
return new Router();
|
|
513
|
+
}
|
|
499
514
|
|
|
500
515
|
exports.assertNotBrowser = nodeHTTPRequestHandler.assertNotBrowser;
|
|
501
516
|
exports.resolveHTTPResponse = nodeHTTPRequestHandler.resolveHTTPResponse;
|
|
502
|
-
exports.TRPCError = transformTRPCResponse.TRPCError;
|
|
503
517
|
exports.Subscription = subscription.Subscription;
|
|
504
518
|
exports.subscriptionPullFactory = subscription.subscriptionPullFactory;
|
|
505
|
-
exports.
|
|
519
|
+
exports.TRPCError = transformTRPCResponse.TRPCError;
|
|
520
|
+
exports.LegacyRouter = LegacyRouter;
|
|
521
|
+
exports.Router = LegacyRouter;
|
|
506
522
|
exports.createHttpHandler = createHttpHandler;
|
|
507
523
|
exports.createHttpServer = createHttpServer;
|
|
508
524
|
exports.requestHandler = requestHandler;
|
|
@@ -3,16 +3,39 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
var nodeHTTPRequestHandler = require('./nodeHTTPRequestHandler-d18bd586.cjs.prod.js');
|
|
6
|
-
var transformTRPCResponse = require('./transformTRPCResponse-dcbf66c5.cjs.prod.js');
|
|
7
|
-
var codes = require('./codes-6b99b935.cjs.prod.js');
|
|
8
6
|
var subscription = require('./subscription-c2e0bfbc.cjs.prod.js');
|
|
7
|
+
var transformTRPCResponse = require('./transformTRPCResponse-dcbf66c5.cjs.prod.js');
|
|
9
8
|
var adapters_standalone_dist_trpcServerAdaptersStandalone = require('../adapters/standalone/dist/trpc-server-adapters-standalone.cjs.prod.js');
|
|
9
|
+
var codes = require('./codes-6b99b935.cjs.prod.js');
|
|
10
10
|
require('url');
|
|
11
11
|
require('events');
|
|
12
12
|
require('http');
|
|
13
13
|
|
|
14
14
|
nodeHTTPRequestHandler.assertNotBrowser();
|
|
15
15
|
|
|
16
|
+
// this has been moved to separate package
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* @deprecated use `createHTTPServer` from `@trpc/server/adapters/standalone`
|
|
20
|
+
*/
|
|
21
|
+
const createHttpServer = adapters_standalone_dist_trpcServerAdaptersStandalone.createHTTPServer;
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated use `createHTTPHandler` from `@trpc/server/adapters/standalone`
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
const createHttpHandler = adapters_standalone_dist_trpcServerAdaptersStandalone.createHTTPHandler;
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated use `CreateHTTPHandlerOptions` from `@trpc/server/adapters/standalone`
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* @deprecated use `nodeHTTPRequestHandler` from `@trpc/server/adapters/node-http`
|
|
33
|
+
*/
|
|
34
|
+
const requestHandler = nodeHTTPRequestHandler.nodeHTTPRequestHandler;
|
|
35
|
+
/**
|
|
36
|
+
* @deprecated use `NodeHTTPCreateContextFn` from `@trpc/server/adapters/node-http`
|
|
37
|
+
*/
|
|
38
|
+
|
|
16
39
|
const middlewareMarker = /*#__PURE__*/Symbol('middlewareMarker');
|
|
17
40
|
|
|
18
41
|
/**
|
|
@@ -89,21 +112,26 @@ class Procedure {
|
|
|
89
112
|
|
|
90
113
|
async call(opts) {
|
|
91
114
|
// wrap the actual resolver and treat as the last "middleware"
|
|
92
|
-
const middlewaresWithResolver = this.middlewares.concat([async (
|
|
115
|
+
const middlewaresWithResolver = this.middlewares.concat([async ({
|
|
116
|
+
ctx
|
|
117
|
+
}) => {
|
|
93
118
|
const input = this.parseInput(opts.rawInput);
|
|
94
119
|
const data = await this.resolver({ ...opts,
|
|
120
|
+
ctx,
|
|
95
121
|
input
|
|
96
122
|
});
|
|
97
123
|
return {
|
|
98
124
|
marker: middlewareMarker,
|
|
99
125
|
ok: true,
|
|
100
|
-
data
|
|
126
|
+
data,
|
|
127
|
+
ctx
|
|
101
128
|
};
|
|
102
129
|
}]); // create `next()` calls in resolvers
|
|
103
130
|
|
|
104
131
|
const nextFns = middlewaresWithResolver.map((fn, index) => {
|
|
105
|
-
return async
|
|
132
|
+
return async nextOpts => {
|
|
106
133
|
const res = await wrapCallSafe(() => fn({ ...opts,
|
|
134
|
+
...nextOpts,
|
|
107
135
|
next: nextFns[index + 1]
|
|
108
136
|
}));
|
|
109
137
|
|
|
@@ -235,6 +263,10 @@ const defaultTransformer = {
|
|
|
235
263
|
deserialize: obj => obj
|
|
236
264
|
}
|
|
237
265
|
};
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* @internal The type signature of this class may change without warning.
|
|
269
|
+
*/
|
|
238
270
|
class Router {
|
|
239
271
|
constructor(def) {
|
|
240
272
|
var _def$queries, _def$mutations, _def$subscriptions, _def$middlewares, _def$errorFormatter, _def$transformer;
|
|
@@ -396,7 +428,6 @@ class Router {
|
|
|
396
428
|
}
|
|
397
429
|
/**
|
|
398
430
|
* Function to be called before any procedure is invoked
|
|
399
|
-
* Can be async or sync
|
|
400
431
|
* @link https://trpc.io/docs/middlewares
|
|
401
432
|
*/
|
|
402
433
|
|
|
@@ -466,39 +497,24 @@ class Router {
|
|
|
466
497
|
}
|
|
467
498
|
|
|
468
499
|
}
|
|
469
|
-
function router() {
|
|
470
|
-
return new Router();
|
|
471
|
-
}
|
|
472
|
-
|
|
473
|
-
// this has been moved to separate package
|
|
474
|
-
|
|
475
500
|
/**
|
|
476
|
-
*
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
/**
|
|
480
|
-
* @deprecated use `createHTTPHandler` from `@trpc/server/adapters/standalone`
|
|
501
|
+
* Subclass of `VNextRouter` with `TInputContext` and `TContext` set to the same type, for backcompat.
|
|
502
|
+
*
|
|
503
|
+
* @deprecated
|
|
481
504
|
*/
|
|
482
505
|
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
/**
|
|
489
|
-
* @deprecated use `nodeHTTPRequestHandler` from `@trpc/server/adapters/node-http`
|
|
490
|
-
*/
|
|
491
|
-
const requestHandler = nodeHTTPRequestHandler.nodeHTTPRequestHandler;
|
|
492
|
-
/**
|
|
493
|
-
* @deprecated use `NodeHTTPCreateContextFn` from `@trpc/server/adapters/node-http`
|
|
494
|
-
*/
|
|
506
|
+
class LegacyRouter extends Router {}
|
|
507
|
+
function router() {
|
|
508
|
+
return new Router();
|
|
509
|
+
}
|
|
495
510
|
|
|
496
511
|
exports.assertNotBrowser = nodeHTTPRequestHandler.assertNotBrowser;
|
|
497
512
|
exports.resolveHTTPResponse = nodeHTTPRequestHandler.resolveHTTPResponse;
|
|
498
|
-
exports.TRPCError = transformTRPCResponse.TRPCError;
|
|
499
513
|
exports.Subscription = subscription.Subscription;
|
|
500
514
|
exports.subscriptionPullFactory = subscription.subscriptionPullFactory;
|
|
501
|
-
exports.
|
|
515
|
+
exports.TRPCError = transformTRPCResponse.TRPCError;
|
|
516
|
+
exports.LegacyRouter = LegacyRouter;
|
|
517
|
+
exports.Router = LegacyRouter;
|
|
502
518
|
exports.createHttpHandler = createHttpHandler;
|
|
503
519
|
exports.createHttpServer = createHttpServer;
|
|
504
520
|
exports.requestHandler = requestHandler;
|