@trpc/server 10.0.0-alpha.2 → 10.0.0-alpha.20
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/adapters/express/dist/trpc-server-adapters-express.cjs.dev.js +5 -4
- package/adapters/express/dist/trpc-server-adapters-express.cjs.prod.js +5 -4
- package/adapters/express/dist/trpc-server-adapters-express.esm.js +5 -4
- package/adapters/express/index.d.ts +1 -0
- package/adapters/express/index.js +1 -0
- package/adapters/fastify/dist/trpc-server-adapters-fastify.cjs.d.ts +1 -0
- package/adapters/fastify/dist/trpc-server-adapters-fastify.cjs.dev.js +109 -0
- package/adapters/fastify/dist/trpc-server-adapters-fastify.cjs.js +7 -0
- package/adapters/fastify/dist/trpc-server-adapters-fastify.cjs.prod.js +109 -0
- package/adapters/fastify/dist/trpc-server-adapters-fastify.esm.js +104 -0
- package/adapters/fastify/index.d.ts +1 -0
- package/adapters/fastify/index.js +1 -0
- package/adapters/next/dist/trpc-server-adapters-next.cjs.dev.js +2 -1
- package/adapters/next/dist/trpc-server-adapters-next.cjs.prod.js +2 -1
- package/adapters/next/dist/trpc-server-adapters-next.esm.js +2 -1
- package/adapters/next/index.d.ts +1 -0
- package/adapters/next/index.js +1 -0
- package/adapters/node-http/dist/trpc-server-adapters-node-http.cjs.dev.js +2 -1
- package/adapters/node-http/dist/trpc-server-adapters-node-http.cjs.prod.js +2 -1
- package/adapters/node-http/dist/trpc-server-adapters-node-http.esm.js +2 -1
- package/adapters/node-http/index.d.ts +1 -0
- package/adapters/node-http/index.js +1 -0
- package/adapters/standalone/dist/trpc-server-adapters-standalone.cjs.dev.js +3 -2
- package/adapters/standalone/dist/trpc-server-adapters-standalone.cjs.prod.js +3 -2
- package/adapters/standalone/dist/trpc-server-adapters-standalone.esm.js +3 -2
- package/adapters/standalone/index.d.ts +1 -0
- package/adapters/standalone/index.js +1 -0
- package/adapters/ws/dist/trpc-server-adapters-ws.cjs.dev.js +5 -4
- package/adapters/ws/dist/trpc-server-adapters-ws.cjs.prod.js +5 -4
- package/adapters/ws/dist/trpc-server-adapters-ws.esm.js +5 -4
- package/adapters/ws/index.d.ts +1 -0
- package/adapters/ws/index.js +1 -0
- package/dist/{declarations/src/TRPCError.d.ts → TRPCError.d.ts} +10 -18
- package/dist/TRPCError.d.ts.map +1 -0
- package/dist/{declarations/src/adapters → adapters}/express.d.ts +5 -5
- package/dist/adapters/express.d.ts.map +1 -0
- package/dist/adapters/express.js +23 -0
- package/dist/adapters/express.mjs +19 -0
- package/dist/adapters/express.ts.js +1 -0
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts +13 -0
- package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +1 -0
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +12 -0
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -0
- package/dist/adapters/fastify/index.d.ts +3 -0
- package/dist/adapters/fastify/index.d.ts.map +1 -0
- package/dist/adapters/fastify/index.js +109 -0
- package/dist/adapters/fastify/index.mjs +104 -0
- package/dist/adapters/fastify/index.ts.js +1 -0
- package/dist/{declarations/src/adapters → adapters}/next.d.ts +5 -5
- package/dist/adapters/next.d.ts.map +1 -0
- package/dist/adapters/next.js +56 -0
- package/dist/adapters/next.mjs +52 -0
- package/dist/adapters/next.ts.js +1 -0
- package/dist/{declarations/src/adapters → adapters}/node-http/index.d.ts +2 -2
- package/dist/adapters/node-http/index.d.ts.map +1 -0
- package/dist/adapters/node-http/index.js +13 -0
- package/dist/adapters/node-http/index.mjs +5 -0
- package/dist/adapters/node-http/index.ts.js +1 -0
- package/dist/{declarations/src/adapters → adapters}/node-http/internals/getPostBody.d.ts +12 -12
- package/dist/adapters/node-http/internals/getPostBody.d.ts.map +1 -0
- package/dist/{declarations/src/adapters → adapters}/node-http/nodeHTTPRequestHandler.d.ts +9 -9
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -0
- package/dist/{declarations/src/adapters → adapters}/node-http/types.d.ts +32 -32
- package/dist/adapters/node-http/types.d.ts.map +1 -0
- package/dist/{declarations/src/adapters → adapters}/standalone.d.ts +13 -13
- package/dist/adapters/standalone.d.ts.map +1 -0
- package/dist/adapters/standalone.js +46 -0
- package/dist/adapters/standalone.mjs +36 -0
- package/dist/adapters/standalone.ts.js +1 -0
- package/dist/{declarations/src/adapters → adapters}/ws.d.ts +16 -16
- package/dist/adapters/ws.d.ts.map +1 -0
- package/dist/adapters/ws.js +347 -0
- package/dist/adapters/ws.mjs +343 -0
- package/dist/adapters/ws.ts.js +1 -0
- package/dist/{declarations/src/assertNotBrowser.d.ts → assertNotBrowser.d.ts} +1 -1
- package/dist/assertNotBrowser.d.ts.map +1 -0
- package/dist/{codes-fe07bf82.esm.js → codes-7a3d4f65.mjs} +0 -0
- package/dist/{codes-33cef953.cjs.dev.js → codes-7f46544e.js} +0 -0
- package/dist/{declarations/src/http → http}/ResponseMeta.d.ts +4 -4
- package/dist/http/ResponseMeta.d.ts.map +1 -0
- package/dist/{declarations/src/http → http}/index.d.ts +2 -2
- package/dist/http/index.d.ts.map +1 -0
- package/dist/{declarations/src/http → http}/internals/getHTTPStatusCode.d.ts +20 -20
- package/dist/http/internals/getHTTPStatusCode.d.ts.map +1 -0
- package/dist/{declarations/src/http → http}/internals/types.d.ts +39 -39
- package/dist/http/internals/types.d.ts.map +1 -0
- package/dist/{declarations/src/http → http}/resolveHTTPResponse.d.ts +12 -12
- package/dist/http/resolveHTTPResponse.d.ts.map +1 -0
- package/dist/{declarations/src/index.d.ts → index.d.ts} +7 -9
- package/dist/index.d.ts.map +1 -0
- package/dist/{trpc-server.cjs.dev.js → index.js} +45 -62
- package/dist/{trpc-server.esm.js → index.mjs} +41 -54
- package/dist/index.ts.js +1 -0
- package/dist/{declarations/src/internals → internals}/BaseHandlerOptions.d.ts +12 -12
- package/dist/internals/BaseHandlerOptions.d.ts.map +1 -0
- package/dist/{declarations/src/internals → internals}/OnErrorFunction.d.ts +10 -10
- package/dist/internals/OnErrorFunction.d.ts.map +1 -0
- package/dist/{declarations/src/internals → internals}/callProcedure.d.ts +9 -9
- package/dist/internals/callProcedure.d.ts.map +1 -0
- package/dist/{declarations/src/internals → internals}/errors.d.ts +3 -3
- package/dist/internals/errors.d.ts.map +1 -0
- package/dist/{declarations/src/internals → internals}/invert.d.ts +8 -8
- package/dist/internals/invert.d.ts.map +1 -0
- package/dist/{declarations/src/internals → internals}/middlewares.d.ts +33 -33
- package/dist/internals/middlewares.d.ts.map +1 -0
- package/dist/internals/procedure.d.ts +81 -0
- package/dist/internals/procedure.d.ts.map +1 -0
- package/dist/{declarations/src/internals → internals}/transformTRPCResponse.d.ts +6 -6
- package/dist/internals/transformTRPCResponse.d.ts.map +1 -0
- package/dist/{declarations/src/internals → internals}/wrapCallSafe.d.ts +15 -15
- package/dist/internals/wrapCallSafe.d.ts.map +1 -0
- package/dist/nodeHTTPRequestHandler-5fccb3bb.mjs +106 -0
- package/dist/nodeHTTPRequestHandler-7d71ac09.js +108 -0
- package/dist/{nodeHTTPRequestHandler-2e6cc2d7.esm.js → resolveHTTPResponse-3292a84a.mjs} +3 -105
- package/dist/{nodeHTTPRequestHandler-b7ff366e.cjs.dev.js → resolveHTTPResponse-c3777a47.js} +2 -105
- package/dist/{declarations/src/router.d.ts → router.d.ts} +168 -175
- package/dist/router.d.ts.map +1 -0
- package/dist/{declarations/src/rpc → rpc}/codes.d.ts +46 -46
- package/dist/rpc/codes.d.ts.map +1 -0
- package/dist/{declarations/src/rpc → rpc}/envelopes.d.ts +71 -71
- package/dist/rpc/envelopes.d.ts.map +1 -0
- package/dist/{declarations/src/rpc → rpc}/index.d.ts +2 -2
- package/dist/rpc/index.d.ts.map +1 -0
- package/dist/rpc/index.js +10 -0
- package/dist/rpc/index.mjs +1 -0
- package/dist/rpc/index.ts.js +1 -0
- package/dist/{subscription-fbda2888.esm.js → subscription-0d8a48ec.mjs} +2 -2
- package/dist/{subscription-c2e0bfbc.cjs.prod.js → subscription-41611bc2.js} +2 -2
- package/dist/{declarations/src/subscription.d.ts → subscription.d.ts} +57 -57
- package/dist/subscription.d.ts.map +1 -0
- package/dist/{transformTRPCResponse-8248515e.cjs.dev.js → transformTRPCResponse-43a869de.js} +41 -45
- package/dist/{transformTRPCResponse-f73dc4a2.esm.js → transformTRPCResponse-ff424ff4.mjs} +41 -45
- package/dist/{declarations/src/transformer.d.ts → transformer.d.ts} +29 -29
- package/dist/transformer.d.ts.map +1 -0
- package/dist/{declarations/src/types.d.ts → types.d.ts} +32 -40
- package/dist/types.d.ts.map +1 -0
- package/package.json +55 -20
- package/rpc/index.d.ts +1 -0
- package/rpc/index.js +1 -0
- package/src/TRPCError.ts +3 -11
- package/src/adapters/express.ts +3 -3
- package/src/adapters/fastify/fastifyRequestHandler.ts +78 -0
- package/src/adapters/fastify/fastifyTRPCPlugin.ts +56 -0
- package/src/adapters/fastify/index.ts +2 -0
- package/src/adapters/next.ts +6 -2
- package/src/adapters/node-http/internals/getPostBody.test.ts +2 -1
- package/src/adapters/node-http/nodeHTTPRequestHandler.ts +5 -5
- package/src/adapters/standalone.ts +2 -1
- package/src/adapters/ws.ts +8 -5
- package/src/http/internals/getHTTPStatusCode.ts +1 -1
- package/src/http/internals/types.ts +2 -2
- package/src/http/resolveHTTPResponse.ts +3 -3
- package/src/index.ts +1 -5
- package/src/internals/BaseHandlerOptions.ts +1 -1
- package/src/internals/OnErrorFunction.ts +1 -1
- package/src/internals/middlewares.ts +1 -1
- package/src/internals/procedure.ts +123 -63
- package/src/router.ts +93 -63
- package/src/subscription.ts +1 -1
- package/src/types.ts +0 -9
- package/ws/dist/trpc-server-ws.cjs.dev.js +1 -1
- package/ws/dist/trpc-server-ws.cjs.prod.js +1 -1
- package/ws/dist/trpc-server-ws.esm.js +1 -1
- package/ws/index.d.ts +1 -0
- package/ws/index.js +1 -0
- package/adapters/express/package.json +0 -4
- package/adapters/next/package.json +0 -4
- package/adapters/node-http/package.json +0 -4
- package/adapters/standalone/package.json +0 -4
- package/adapters/ws/package.json +0 -4
- package/dist/codes-e0df67c4.cjs.prod.js +0 -60
- package/dist/declarations/src/TRPCError.d.ts.map +0 -1
- package/dist/declarations/src/adapters/express.d.ts.map +0 -1
- package/dist/declarations/src/adapters/next.d.ts.map +0 -1
- package/dist/declarations/src/adapters/node-http/index.d.ts.map +0 -1
- package/dist/declarations/src/adapters/node-http/internals/getPostBody.d.ts.map +0 -1
- package/dist/declarations/src/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +0 -1
- package/dist/declarations/src/adapters/node-http/types.d.ts.map +0 -1
- package/dist/declarations/src/adapters/standalone.d.ts.map +0 -1
- package/dist/declarations/src/adapters/ws.d.ts.map +0 -1
- package/dist/declarations/src/assertNotBrowser.d.ts.map +0 -1
- package/dist/declarations/src/deprecated/LegacyRouter.d.ts +0 -3
- package/dist/declarations/src/deprecated/LegacyRouter.d.ts.map +0 -1
- package/dist/declarations/src/deprecated/createHttpServer.d.ts +0 -19
- package/dist/declarations/src/deprecated/createHttpServer.d.ts.map +0 -1
- package/dist/declarations/src/deprecated/requestHandler.d.ts +0 -15
- package/dist/declarations/src/deprecated/requestHandler.d.ts.map +0 -1
- package/dist/declarations/src/http/ResponseMeta.d.ts.map +0 -1
- package/dist/declarations/src/http/index.d.ts.map +0 -1
- package/dist/declarations/src/http/internals/getHTTPStatusCode.d.ts.map +0 -1
- package/dist/declarations/src/http/internals/types.d.ts.map +0 -1
- package/dist/declarations/src/http/resolveHTTPResponse.d.ts.map +0 -1
- package/dist/declarations/src/index.d.ts.map +0 -1
- package/dist/declarations/src/internals/BaseHandlerOptions.d.ts.map +0 -1
- package/dist/declarations/src/internals/OnErrorFunction.d.ts.map +0 -1
- package/dist/declarations/src/internals/callProcedure.d.ts.map +0 -1
- package/dist/declarations/src/internals/errors.d.ts.map +0 -1
- package/dist/declarations/src/internals/invert.d.ts.map +0 -1
- package/dist/declarations/src/internals/middlewares.d.ts.map +0 -1
- package/dist/declarations/src/internals/procedure.d.ts +0 -74
- package/dist/declarations/src/internals/procedure.d.ts.map +0 -1
- package/dist/declarations/src/internals/transformTRPCResponse.d.ts.map +0 -1
- package/dist/declarations/src/internals/wrapCallSafe.d.ts.map +0 -1
- package/dist/declarations/src/router.d.ts.map +0 -1
- package/dist/declarations/src/rpc/codes.d.ts.map +0 -1
- package/dist/declarations/src/rpc/envelopes.d.ts.map +0 -1
- package/dist/declarations/src/rpc/index.d.ts.map +0 -1
- package/dist/declarations/src/subscription.d.ts.map +0 -1
- package/dist/declarations/src/transformer.d.ts.map +0 -1
- package/dist/declarations/src/types.d.ts.map +0 -1
- package/dist/declarations/src/ws/index.d.ts +0 -7
- package/dist/declarations/src/ws/index.d.ts.map +0 -1
- package/dist/nodeHTTPRequestHandler-7325b53f.cjs.prod.js +0 -399
- package/dist/subscription-b8831081.cjs.dev.js +0 -136
- package/dist/transformTRPCResponse-dcbf66c5.cjs.prod.js +0 -114
- package/dist/trpc-server.cjs.d.ts +0 -1
- package/dist/trpc-server.cjs.js +0 -7
- package/dist/trpc-server.cjs.prod.js +0 -528
- package/rpc/package.json +0 -4
- package/src/deprecated/LegacyRouter.ts +0 -3
- package/src/deprecated/createHttpServer.ts +0 -29
- package/src/deprecated/requestHandler.ts +0 -26
- package/src/ws/index.ts +0 -8
- package/ws/package.json +0 -4
|
@@ -1,176 +1,169 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
/**
|
|
9
|
-
* @public
|
|
10
|
-
*/
|
|
11
|
-
export declare type ProcedureType = 'query' | 'mutation' | 'subscription';
|
|
12
|
-
/**
|
|
13
|
-
* @internal
|
|
14
|
-
*/
|
|
15
|
-
export declare type ProcedureRecord<TInputContext = any, TContext = any, TInput = any, TParsedInput = any, TOutput = any> = Record<string, Procedure<TInputContext, TContext, TInput, TParsedInput, TOutput>>;
|
|
16
|
-
/**
|
|
17
|
-
* @public
|
|
18
|
-
*/
|
|
19
|
-
export declare type inferProcedureInput<TProcedure extends Procedure<any, any, any, any, any>> = TProcedure extends Procedure<any, any, infer Input, any, any> ? undefined extends Input ? Input | null | void : Input : undefined;
|
|
20
|
-
/**
|
|
21
|
-
* @public
|
|
22
|
-
*/
|
|
23
|
-
export declare type inferAsyncReturnType<TFunction extends (...args: any) => any> = ThenArg<ReturnType<TFunction>>;
|
|
24
|
-
/**
|
|
25
|
-
* @public
|
|
26
|
-
*/
|
|
27
|
-
export declare type inferProcedureOutput<TProcedure extends Procedure<any, any, any, any, any>> = inferAsyncReturnType<TProcedure['call']>;
|
|
28
|
-
/**
|
|
29
|
-
* @public
|
|
30
|
-
* @beta
|
|
31
|
-
*/
|
|
32
|
-
export declare type inferSubscriptionOutput<TRouter extends AnyRouter, TPath extends keyof TRouter['_def']['subscriptions']> = ReturnType<inferAsyncReturnType<TRouter['_def']['subscriptions'][TPath]['call']>['output']>;
|
|
33
|
-
/**
|
|
34
|
-
* @internal
|
|
35
|
-
*/
|
|
36
|
-
export declare type inferHandlerInput<TProcedure extends Procedure<any, any, any, any, any>> = TProcedure extends Procedure<any, any, infer TInput, any, any> ? undefined extends TInput ? unknown extends TInput ? [(null | undefined)?] : [(TInput | null | undefined)?] : [TInput] : [(undefined | null)?];
|
|
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
|
-
/**
|
|
39
|
-
* @internal
|
|
40
|
-
*/
|
|
41
|
-
export declare type inferRouterContext<TRouter extends AnyRouter> = Parameters<TRouter['createCaller']>[0];
|
|
42
|
-
/**
|
|
43
|
-
* @public
|
|
44
|
-
*/
|
|
45
|
-
export declare type AnyRouter<TContext = any> = Router<any, TContext, any, any, any, any>;
|
|
46
|
-
/**
|
|
47
|
-
* @internal
|
|
48
|
-
*/
|
|
49
|
-
export declare type inferRouterError<TRouter extends AnyRouter> = ReturnType<TRouter['getErrorShape']>;
|
|
50
|
-
/**
|
|
51
|
-
* @internal
|
|
52
|
-
*/
|
|
53
|
-
export declare type ErrorFormatter<TContext, TShape extends TRPCErrorShape<number>> = ({ error, }: {
|
|
54
|
-
error: TRPCError;
|
|
55
|
-
type: ProcedureType | 'unknown';
|
|
56
|
-
path: string | undefined;
|
|
57
|
-
input: unknown;
|
|
58
|
-
ctx: undefined | TContext;
|
|
59
|
-
shape: DefaultErrorShape;
|
|
60
|
-
}) => TShape;
|
|
61
|
-
declare type DefaultErrorData = {
|
|
62
|
-
code: TRPC_ERROR_CODE_KEY;
|
|
63
|
-
httpStatus: number;
|
|
64
|
-
path?: string;
|
|
65
|
-
stack?: string;
|
|
66
|
-
};
|
|
67
|
-
/**
|
|
68
|
-
* @internal
|
|
69
|
-
*/
|
|
70
|
-
export interface DefaultErrorShape extends TRPCErrorShape<TRPC_ERROR_CODE_NUMBER, DefaultErrorData> {
|
|
71
|
-
message: string;
|
|
72
|
-
code: TRPC_ERROR_CODE_NUMBER;
|
|
73
|
-
}
|
|
74
|
-
declare type SwapProcedureContext<TProcedure extends Procedure<any, any, any, any, any>, TNewContext> = TProcedure extends Procedure<infer TInputContext, infer _TOldContext, infer TInput, infer TParsedInput, infer TOutput> ? Procedure<TInputContext, TNewContext, TInput, TParsedInput, TOutput> : never;
|
|
75
|
-
declare type SwapContext<TObj extends ProcedureRecord<any, any, any, any>, TNewContext> = {
|
|
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
|
|
82
|
-
readonly _def: {
|
|
83
|
-
queries: TQueries;
|
|
84
|
-
mutations: TMutations;
|
|
85
|
-
subscriptions: TSubscriptions;
|
|
86
|
-
middlewares: MiddlewareFunction<TInputContext, TContext>[];
|
|
87
|
-
errorFormatter: ErrorFormatter<TContext, TErrorShape>;
|
|
88
|
-
transformer: CombinedDataTransformer;
|
|
89
|
-
};
|
|
90
|
-
constructor(def?: {
|
|
91
|
-
queries?: TQueries;
|
|
92
|
-
mutations?: TMutations;
|
|
93
|
-
subscriptions?: TSubscriptions;
|
|
94
|
-
middlewares?: MiddlewareFunction<TInputContext, TContext>[];
|
|
95
|
-
errorFormatter?: ErrorFormatter<TContext, TErrorShape>;
|
|
96
|
-
transformer?: CombinedDataTransformer;
|
|
97
|
-
});
|
|
98
|
-
private static prefixProcedures;
|
|
99
|
-
query<TPath extends string, TInput, TParsedInput, TOutput>(path: TPath, procedure: CreateProcedureWithInputOutputParser<TContext, TInput, TParsedInput, TOutput>): Router<TInputContext, TContext, TQueries & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TMutations, TSubscriptions, TErrorShape>;
|
|
100
|
-
query<TPath extends string, TInput, TOutput>(path: TPath, procedure: CreateProcedureWithInput<TContext, TInput,
|
|
101
|
-
query<TPath extends string, TOutput>(path: TPath, procedure: CreateProcedureWithoutInput<TContext, TOutput>): Router<TInputContext, TContext, TQueries & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TMutations, TSubscriptions, TErrorShape>;
|
|
102
|
-
mutation<TPath extends string, TInput, TParsedInput, TOutput>(path: TPath, procedure: CreateProcedureWithInputOutputParser<TContext, TInput, TParsedInput, TOutput>): Router<TInputContext, TContext, TQueries, TMutations & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TSubscriptions, TErrorShape>;
|
|
103
|
-
mutation<TPath extends string, TInput, TOutput>(path: TPath, procedure: CreateProcedureWithInput<TContext, TInput,
|
|
104
|
-
mutation<TPath extends string, TOutput>(path: TPath, procedure: CreateProcedureWithoutInput<TContext, TOutput>): Router<TInputContext, TContext, TQueries, TMutations & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TSubscriptions, TErrorShape>;
|
|
105
|
-
/**
|
|
106
|
-
* @beta Might change without a major version bump
|
|
107
|
-
*/
|
|
108
|
-
subscription<TPath extends string, TInput, TParsedInput, TOutput extends Subscription<unknown>>(path: TPath, procedure: CreateProcedureWithInputOutputParser<TContext, TInput, TParsedInput, TOutput>): Router<TInputContext, TContext, TQueries, TMutations, TSubscriptions & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TErrorShape>;
|
|
109
|
-
/**
|
|
110
|
-
* @beta Might change without a major version bump
|
|
111
|
-
*/
|
|
112
|
-
subscription<TPath extends string, TInput, TOutput extends Subscription<unknown>>(path: TPath, procedure: CreateProcedureWithInput<TContext, TInput,
|
|
113
|
-
/**
|
|
114
|
-
* @beta Might change without a major version bump
|
|
115
|
-
*/
|
|
116
|
-
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>;
|
|
117
|
-
/**
|
|
118
|
-
* Merge router with other router
|
|
119
|
-
* @param router
|
|
120
|
-
*/
|
|
121
|
-
merge<TChildRouter extends Router<TContext, any, any, any, any, any>>(router: TChildRouter): Router<TInputContext, inferRouterContext<TChildRouter>, TQueries & TChildRouter['_def']['queries'], TMutations & TChildRouter['_def']['mutations'], TSubscriptions & TChildRouter['_def']['subscriptions'], TErrorShape>;
|
|
122
|
-
/**
|
|
123
|
-
* Merge router with other router
|
|
124
|
-
* @param prefix Prefix that this router should live under
|
|
125
|
-
* @param router
|
|
126
|
-
*/
|
|
127
|
-
merge<TPath extends string, TChildRouter extends Router<TContext, any, any, any, any, any>>(prefix: TPath, router: TChildRouter): Router<TInputContext, inferRouterContext<TChildRouter>, TQueries & Prefixer<TChildRouter['_def']['queries'], `${TPath}`>, TMutations & Prefixer<TChildRouter['_def']['mutations'], `${TPath}`>, TSubscriptions & Prefixer<TChildRouter['_def']['subscriptions'], `${TPath}`>, TErrorShape>;
|
|
128
|
-
/**
|
|
129
|
-
* Invoke procedure. Only for internal use within library.
|
|
130
|
-
*/
|
|
131
|
-
private call;
|
|
132
|
-
createCaller(ctx: TInputContext): {
|
|
133
|
-
query: inferHandlerFn<TQueries>;
|
|
134
|
-
mutation: inferHandlerFn<TMutations>;
|
|
135
|
-
subscription: inferHandlerFn<TSubscriptions>;
|
|
136
|
-
};
|
|
137
|
-
/**
|
|
138
|
-
* Function to be called before any procedure is invoked
|
|
139
|
-
* @link https://trpc.io/docs/middlewares
|
|
140
|
-
*/
|
|
141
|
-
middleware<TNewContext>(middleware: MiddlewareFunction<TContext, TNewContext>): Router<TInputContext, TNewContext, SwapContext<TQueries, TNewContext>, SwapContext<TMutations, TNewContext>, SwapContext<TSubscriptions, TNewContext>, TErrorShape>;
|
|
142
|
-
/**
|
|
143
|
-
* Format errors
|
|
144
|
-
* @link https://trpc.io/docs/error-formatting
|
|
145
|
-
*/
|
|
146
|
-
formatError<TErrorFormatter extends ErrorFormatter<TContext, TRPCErrorShape<number>>>(errorFormatter: TErrorFormatter): Router<TInputContext, TContext, TQueries, TMutations, TSubscriptions, ReturnType<TErrorFormatter>>;
|
|
147
|
-
getErrorShape(opts: {
|
|
148
|
-
error: TRPCError;
|
|
149
|
-
type: ProcedureType | 'unknown';
|
|
150
|
-
path: string | undefined;
|
|
151
|
-
input: unknown;
|
|
152
|
-
ctx: undefined | TContext;
|
|
153
|
-
}): TErrorShape;
|
|
154
|
-
/**
|
|
155
|
-
* Add data transformer to serialize/deserialize input args + output
|
|
156
|
-
* @link https://trpc.io/docs/data-transformers
|
|
157
|
-
*/
|
|
158
|
-
transformer(_transformer: DataTransformerOptions): Router<TInputContext, TContext, TQueries, TMutations, TSubscriptions, TErrorShape>;
|
|
159
|
-
/**
|
|
160
|
-
* Flattens the generics of TQueries/TMutations/TSubscriptions.
|
|
161
|
-
* ⚠️ Experimental - might disappear. ⚠️
|
|
162
|
-
*
|
|
163
|
-
* @alpha
|
|
164
|
-
*/
|
|
165
|
-
flat(): Router<TInputContext, TContext, flatten<{}, TQueries>, flatten<{}, TMutations>, flatten<{}, TSubscriptions>, TErrorShape>;
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
*
|
|
170
|
-
* @deprecated
|
|
171
|
-
*/
|
|
172
|
-
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> {
|
|
173
|
-
}
|
|
174
|
-
export declare function router<TContext>(): Router<TContext, TContext, {}, {}, {}, DefaultErrorShape>;
|
|
175
|
-
export {};
|
|
1
|
+
import { TRPCError } from './TRPCError';
|
|
2
|
+
import { MiddlewareFunction } from './internals/middlewares';
|
|
3
|
+
import { CreateProcedureWithInput, CreateProcedureWithInputOutputParser, CreateProcedureWithoutInput, Procedure, inferProcedureFromOptions } from './internals/procedure';
|
|
4
|
+
import { TRPCErrorShape, TRPC_ERROR_CODE_KEY, TRPC_ERROR_CODE_NUMBER } from './rpc';
|
|
5
|
+
import { Subscription } from './subscription';
|
|
6
|
+
import { CombinedDataTransformer, DataTransformerOptions } from './transformer';
|
|
7
|
+
import { Prefixer, ThenArg, flatten } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* @public
|
|
10
|
+
*/
|
|
11
|
+
export declare type ProcedureType = 'query' | 'mutation' | 'subscription';
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export declare type ProcedureRecord<TInputContext = any, TContext = any, TInput = any, TParsedInput = any, TOutput = any, TParsedOutput = any> = Record<string, Procedure<TInputContext, TContext, TInput, TParsedInput, TOutput, TParsedOutput>>;
|
|
16
|
+
/**
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export declare type inferProcedureInput<TProcedure extends Procedure<any, any, any, any, any, any>> = TProcedure extends Procedure<any, any, infer Input, any, any, any> ? undefined extends Input ? Input | null | void : Input : undefined;
|
|
20
|
+
/**
|
|
21
|
+
* @public
|
|
22
|
+
*/
|
|
23
|
+
export declare type inferAsyncReturnType<TFunction extends (...args: any) => any> = ThenArg<ReturnType<TFunction>>;
|
|
24
|
+
/**
|
|
25
|
+
* @public
|
|
26
|
+
*/
|
|
27
|
+
export declare type inferProcedureOutput<TProcedure extends Procedure<any, any, any, any, any, any>> = inferAsyncReturnType<TProcedure['call']>;
|
|
28
|
+
/**
|
|
29
|
+
* @public
|
|
30
|
+
* @beta
|
|
31
|
+
*/
|
|
32
|
+
export declare type inferSubscriptionOutput<TRouter extends AnyRouter, TPath extends keyof TRouter['_def']['subscriptions']> = ReturnType<inferAsyncReturnType<TRouter['_def']['subscriptions'][TPath]['call']>['output']>;
|
|
33
|
+
/**
|
|
34
|
+
* @internal
|
|
35
|
+
*/
|
|
36
|
+
export declare type inferHandlerInput<TProcedure extends Procedure<any, any, any, any, any, any>> = TProcedure extends Procedure<any, any, infer TInput, any, any, any> ? undefined extends TInput ? unknown extends TInput ? [(null | undefined)?] : [(TInput | null | undefined)?] : [TInput] : [(undefined | null)?];
|
|
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
|
+
/**
|
|
39
|
+
* @internal
|
|
40
|
+
*/
|
|
41
|
+
export declare type inferRouterContext<TRouter extends AnyRouter> = Parameters<TRouter['createCaller']>[0];
|
|
42
|
+
/**
|
|
43
|
+
* @public
|
|
44
|
+
*/
|
|
45
|
+
export declare type AnyRouter<TContext = any> = Router<any, TContext, any, any, any, any>;
|
|
46
|
+
/**
|
|
47
|
+
* @internal
|
|
48
|
+
*/
|
|
49
|
+
export declare type inferRouterError<TRouter extends AnyRouter> = ReturnType<TRouter['getErrorShape']>;
|
|
50
|
+
/**
|
|
51
|
+
* @internal
|
|
52
|
+
*/
|
|
53
|
+
export declare type ErrorFormatter<TContext, TShape extends TRPCErrorShape<number>> = ({ error, }: {
|
|
54
|
+
error: TRPCError;
|
|
55
|
+
type: ProcedureType | 'unknown';
|
|
56
|
+
path: string | undefined;
|
|
57
|
+
input: unknown;
|
|
58
|
+
ctx: undefined | TContext;
|
|
59
|
+
shape: DefaultErrorShape;
|
|
60
|
+
}) => TShape;
|
|
61
|
+
declare type DefaultErrorData = {
|
|
62
|
+
code: TRPC_ERROR_CODE_KEY;
|
|
63
|
+
httpStatus: number;
|
|
64
|
+
path?: string;
|
|
65
|
+
stack?: string;
|
|
66
|
+
};
|
|
67
|
+
/**
|
|
68
|
+
* @internal
|
|
69
|
+
*/
|
|
70
|
+
export interface DefaultErrorShape extends TRPCErrorShape<TRPC_ERROR_CODE_NUMBER, DefaultErrorData> {
|
|
71
|
+
message: string;
|
|
72
|
+
code: TRPC_ERROR_CODE_NUMBER;
|
|
73
|
+
}
|
|
74
|
+
declare type SwapProcedureContext<TProcedure extends Procedure<any, any, any, any, any, any>, TNewContext> = TProcedure extends Procedure<infer TInputContext, infer _TOldContext, infer TInput, infer TParsedInput, infer TOutput, infer TParsedOutput> ? Procedure<TInputContext, TNewContext, TInput, TParsedInput, TOutput, TParsedOutput> : never;
|
|
75
|
+
declare type SwapContext<TObj extends ProcedureRecord<any, any, any, any, any, any>, TNewContext> = {
|
|
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, any, any, any, any>, TMutations extends ProcedureRecord<TInputContext, TContext, any, any, any, any>, TSubscriptions extends ProcedureRecord<TInputContext, TContext, unknown, unknown, Subscription<unknown>, unknown>, TErrorShape extends TRPCErrorShape<number>> {
|
|
82
|
+
readonly _def: {
|
|
83
|
+
queries: TQueries;
|
|
84
|
+
mutations: TMutations;
|
|
85
|
+
subscriptions: TSubscriptions;
|
|
86
|
+
middlewares: MiddlewareFunction<TInputContext, TContext>[];
|
|
87
|
+
errorFormatter: ErrorFormatter<TContext, TErrorShape>;
|
|
88
|
+
transformer: CombinedDataTransformer;
|
|
89
|
+
};
|
|
90
|
+
constructor(def?: {
|
|
91
|
+
queries?: TQueries;
|
|
92
|
+
mutations?: TMutations;
|
|
93
|
+
subscriptions?: TSubscriptions;
|
|
94
|
+
middlewares?: MiddlewareFunction<TInputContext, TContext>[];
|
|
95
|
+
errorFormatter?: ErrorFormatter<TContext, TErrorShape>;
|
|
96
|
+
transformer?: CombinedDataTransformer;
|
|
97
|
+
});
|
|
98
|
+
private static prefixProcedures;
|
|
99
|
+
query<TPath extends string, TInput, TParsedInput, TOutput, TParsedOutput>(path: TPath, procedure: CreateProcedureWithInputOutputParser<TContext, TInput, TParsedInput, TOutput, TParsedOutput>): Router<TInputContext, TContext, TQueries & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TMutations, TSubscriptions, TErrorShape>;
|
|
100
|
+
query<TPath extends string, TInput, TOutput>(path: TPath, procedure: CreateProcedureWithInput<TContext, TInput, TOutput>): Router<TInputContext, TContext, TQueries & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TMutations, TSubscriptions, TErrorShape>;
|
|
101
|
+
query<TPath extends string, TOutput, TParsedOutput>(path: TPath, procedure: CreateProcedureWithoutInput<TContext, TOutput, TParsedOutput>): Router<TInputContext, TContext, TQueries & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TMutations, TSubscriptions, TErrorShape>;
|
|
102
|
+
mutation<TPath extends string, TInput, TParsedInput, TOutput, TParsedOutput>(path: TPath, procedure: CreateProcedureWithInputOutputParser<TContext, TInput, TParsedInput, TOutput, TParsedOutput>): Router<TInputContext, TContext, TQueries, TMutations & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TSubscriptions, TErrorShape>;
|
|
103
|
+
mutation<TPath extends string, TInput, TOutput>(path: TPath, procedure: CreateProcedureWithInput<TContext, TInput, TOutput>): Router<TInputContext, TContext, TQueries, TMutations & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TSubscriptions, TErrorShape>;
|
|
104
|
+
mutation<TPath extends string, TOutput, TParsedOutput>(path: TPath, procedure: CreateProcedureWithoutInput<TContext, TOutput, TParsedOutput>): Router<TInputContext, TContext, TQueries, TMutations & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TSubscriptions, TErrorShape>;
|
|
105
|
+
/**
|
|
106
|
+
* @beta Might change without a major version bump
|
|
107
|
+
*/
|
|
108
|
+
subscription<TPath extends string, TInput, TParsedInput, TOutput extends Subscription<unknown>>(path: TPath, procedure: Omit<CreateProcedureWithInputOutputParser<TContext, TInput, TParsedInput, TOutput, unknown>, 'output'>): Router<TInputContext, TContext, TQueries, TMutations, TSubscriptions & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TErrorShape>;
|
|
109
|
+
/**
|
|
110
|
+
* @beta Might change without a major version bump
|
|
111
|
+
*/
|
|
112
|
+
subscription<TPath extends string, TInput, TOutput extends Subscription<unknown>>(path: TPath, procedure: Omit<CreateProcedureWithInput<TContext, TInput, TOutput>, 'output'>): Router<TInputContext, TContext, TQueries, TMutations, TSubscriptions & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TErrorShape>;
|
|
113
|
+
/**
|
|
114
|
+
* @beta Might change without a major version bump
|
|
115
|
+
*/
|
|
116
|
+
subscription<TPath extends string, TOutput extends Subscription<unknown>>(path: TPath, procedure: Omit<CreateProcedureWithoutInput<TContext, TOutput, unknown>, 'output'>): Router<TInputContext, TContext, TQueries, TMutations, TSubscriptions & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TErrorShape>;
|
|
117
|
+
/**
|
|
118
|
+
* Merge router with other router
|
|
119
|
+
* @param router
|
|
120
|
+
*/
|
|
121
|
+
merge<TChildRouter extends Router<TContext, any, any, any, any, any>>(router: TChildRouter): Router<TInputContext, inferRouterContext<TChildRouter>, TQueries & TChildRouter['_def']['queries'], TMutations & TChildRouter['_def']['mutations'], TSubscriptions & TChildRouter['_def']['subscriptions'], TErrorShape>;
|
|
122
|
+
/**
|
|
123
|
+
* Merge router with other router
|
|
124
|
+
* @param prefix Prefix that this router should live under
|
|
125
|
+
* @param router
|
|
126
|
+
*/
|
|
127
|
+
merge<TPath extends string, TChildRouter extends Router<TContext, any, any, any, any, any>>(prefix: TPath, router: TChildRouter): Router<TInputContext, inferRouterContext<TChildRouter>, TQueries & Prefixer<TChildRouter['_def']['queries'], `${TPath}`>, TMutations & Prefixer<TChildRouter['_def']['mutations'], `${TPath}`>, TSubscriptions & Prefixer<TChildRouter['_def']['subscriptions'], `${TPath}`>, TErrorShape>;
|
|
128
|
+
/**
|
|
129
|
+
* Invoke procedure. Only for internal use within library.
|
|
130
|
+
*/
|
|
131
|
+
private call;
|
|
132
|
+
createCaller(ctx: TInputContext): {
|
|
133
|
+
query: inferHandlerFn<TQueries>;
|
|
134
|
+
mutation: inferHandlerFn<TMutations>;
|
|
135
|
+
subscription: inferHandlerFn<TSubscriptions>;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Function to be called before any procedure is invoked
|
|
139
|
+
* @link https://trpc.io/docs/middlewares
|
|
140
|
+
*/
|
|
141
|
+
middleware<TNewContext>(middleware: MiddlewareFunction<TContext, TNewContext>): Router<TInputContext, TNewContext, SwapContext<TQueries, TNewContext>, SwapContext<TMutations, TNewContext>, SwapContext<TSubscriptions, TNewContext>, TErrorShape>;
|
|
142
|
+
/**
|
|
143
|
+
* Format errors
|
|
144
|
+
* @link https://trpc.io/docs/error-formatting
|
|
145
|
+
*/
|
|
146
|
+
formatError<TErrorFormatter extends ErrorFormatter<TContext, TRPCErrorShape<number>>>(errorFormatter: TErrorFormatter): Router<TInputContext, TContext, TQueries, TMutations, TSubscriptions, ReturnType<TErrorFormatter>>;
|
|
147
|
+
getErrorShape(opts: {
|
|
148
|
+
error: TRPCError;
|
|
149
|
+
type: ProcedureType | 'unknown';
|
|
150
|
+
path: string | undefined;
|
|
151
|
+
input: unknown;
|
|
152
|
+
ctx: undefined | TContext;
|
|
153
|
+
}): TErrorShape;
|
|
154
|
+
/**
|
|
155
|
+
* Add data transformer to serialize/deserialize input args + output
|
|
156
|
+
* @link https://trpc.io/docs/data-transformers
|
|
157
|
+
*/
|
|
158
|
+
transformer(_transformer: DataTransformerOptions): Router<TInputContext, TContext, TQueries, TMutations, TSubscriptions, TErrorShape>;
|
|
159
|
+
/**
|
|
160
|
+
* Flattens the generics of TQueries/TMutations/TSubscriptions.
|
|
161
|
+
* ⚠️ Experimental - might disappear. ⚠️
|
|
162
|
+
*
|
|
163
|
+
* @alpha
|
|
164
|
+
*/
|
|
165
|
+
flat(): Router<TInputContext, TContext, flatten<{}, TQueries>, flatten<{}, TMutations>, flatten<{}, TSubscriptions>, TErrorShape>;
|
|
166
|
+
}
|
|
167
|
+
export declare function router<TContext>(): Router<TContext, TContext, {}, {}, {}, DefaultErrorShape>;
|
|
168
|
+
export {};
|
|
176
169
|
//# sourceMappingURL=router.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../src/router.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAEL,wBAAwB,EACxB,oCAAoC,EACpC,2BAA2B,EAC3B,SAAS,EAGT,yBAAyB,EAC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;;;OAGG;IACI,WAAW,CAChB,eAAe,SAAS,cAAc,CAAC,QAAQ,EAAE,cAAc,CAAC,MAAM,CAAC,CAAC,EACxE,cAAc,EAAE,eAAe;IAmB1B,aAAa,CAAC,IAAI,EAAE;QACzB,KAAK,EAAE,SAAS,CAAC;QACjB,IAAI,EAAE,aAAa,GAAG,SAAS,CAAC;QAChC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;QACzB,KAAK,EAAE,OAAO,CAAC;QACf,GAAG,EAAE,SAAS,GAAG,QAAQ,CAAC;KAC3B,GAAG,WAAW;IAuBf;;;OAGG;IACH,WAAW,CAAC,YAAY,EAAE,sBAAsB;IAqBhD;;;;;OAKG;IACI,IAAI,IAAI,MAAM,CACnB,aAAa,EACb,QAAQ,EACR,OAAO,CAAC,EAAE,EAAE,QAAQ,CAAC,EACrB,OAAO,CAAC,EAAE,EAAE,UAAU,CAAC,EACvB,OAAO,CAAC,EAAE,EAAE,cAAc,CAAC,EAC3B,WAAW,CACZ;CAGF;AAED,wBAAgB,MAAM,CAAC,QAAQ,+DAE9B"}
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* JSON-RPC 2.0 Error codes
|
|
3
|
-
*
|
|
4
|
-
* `-32000` to `-32099` are reserved for implementation-defined server-errors.
|
|
5
|
-
* For tRPC we're copying the last digits of HTTP 4XX errors.
|
|
6
|
-
*/
|
|
7
|
-
export declare const TRPC_ERROR_CODES_BY_KEY: {
|
|
8
|
-
/**
|
|
9
|
-
* Invalid JSON was received by the server.
|
|
10
|
-
* An error occurred on the server while parsing the JSON text.
|
|
11
|
-
*/
|
|
12
|
-
readonly PARSE_ERROR: -32700;
|
|
13
|
-
/**
|
|
14
|
-
* The JSON sent is not a valid Request object.
|
|
15
|
-
*/
|
|
16
|
-
readonly BAD_REQUEST: -32600;
|
|
17
|
-
/**
|
|
18
|
-
* Internal JSON-RPC error.
|
|
19
|
-
*/
|
|
20
|
-
readonly INTERNAL_SERVER_ERROR: -32603;
|
|
21
|
-
readonly UNAUTHORIZED: -32001;
|
|
22
|
-
readonly FORBIDDEN: -32003;
|
|
23
|
-
readonly NOT_FOUND: -32004;
|
|
24
|
-
readonly METHOD_NOT_SUPPORTED: -32005;
|
|
25
|
-
readonly TIMEOUT: -32008;
|
|
26
|
-
readonly PRECONDITION_FAILED: -32012;
|
|
27
|
-
readonly PAYLOAD_TOO_LARGE: -32013;
|
|
28
|
-
readonly CLIENT_CLOSED_REQUEST: -32099;
|
|
29
|
-
};
|
|
30
|
-
export declare const TRPC_ERROR_CODES_BY_NUMBER: {
|
|
31
|
-
[-32700]: "PARSE_ERROR";
|
|
32
|
-
[-32600]: "BAD_REQUEST";
|
|
33
|
-
[-32603]: "INTERNAL_SERVER_ERROR";
|
|
34
|
-
[-32001]: "UNAUTHORIZED";
|
|
35
|
-
[-32003]: "FORBIDDEN";
|
|
36
|
-
[-32004]: "NOT_FOUND";
|
|
37
|
-
[-32005]: "METHOD_NOT_SUPPORTED";
|
|
38
|
-
[-32008]: "TIMEOUT";
|
|
39
|
-
[-32012]: "PRECONDITION_FAILED";
|
|
40
|
-
[-32013]: "PAYLOAD_TOO_LARGE";
|
|
41
|
-
[-32099]: "CLIENT_CLOSED_REQUEST";
|
|
42
|
-
};
|
|
43
|
-
declare type ValueOf<T> = T[keyof T];
|
|
44
|
-
export declare type TRPC_ERROR_CODE_NUMBER = ValueOf<typeof TRPC_ERROR_CODES_BY_KEY>;
|
|
45
|
-
export declare type TRPC_ERROR_CODE_KEY = keyof typeof TRPC_ERROR_CODES_BY_KEY;
|
|
46
|
-
export {};
|
|
1
|
+
/**
|
|
2
|
+
* JSON-RPC 2.0 Error codes
|
|
3
|
+
*
|
|
4
|
+
* `-32000` to `-32099` are reserved for implementation-defined server-errors.
|
|
5
|
+
* For tRPC we're copying the last digits of HTTP 4XX errors.
|
|
6
|
+
*/
|
|
7
|
+
export declare const TRPC_ERROR_CODES_BY_KEY: {
|
|
8
|
+
/**
|
|
9
|
+
* Invalid JSON was received by the server.
|
|
10
|
+
* An error occurred on the server while parsing the JSON text.
|
|
11
|
+
*/
|
|
12
|
+
readonly PARSE_ERROR: -32700;
|
|
13
|
+
/**
|
|
14
|
+
* The JSON sent is not a valid Request object.
|
|
15
|
+
*/
|
|
16
|
+
readonly BAD_REQUEST: -32600;
|
|
17
|
+
/**
|
|
18
|
+
* Internal JSON-RPC error.
|
|
19
|
+
*/
|
|
20
|
+
readonly INTERNAL_SERVER_ERROR: -32603;
|
|
21
|
+
readonly UNAUTHORIZED: -32001;
|
|
22
|
+
readonly FORBIDDEN: -32003;
|
|
23
|
+
readonly NOT_FOUND: -32004;
|
|
24
|
+
readonly METHOD_NOT_SUPPORTED: -32005;
|
|
25
|
+
readonly TIMEOUT: -32008;
|
|
26
|
+
readonly PRECONDITION_FAILED: -32012;
|
|
27
|
+
readonly PAYLOAD_TOO_LARGE: -32013;
|
|
28
|
+
readonly CLIENT_CLOSED_REQUEST: -32099;
|
|
29
|
+
};
|
|
30
|
+
export declare const TRPC_ERROR_CODES_BY_NUMBER: {
|
|
31
|
+
[-32700]: "PARSE_ERROR";
|
|
32
|
+
[-32600]: "BAD_REQUEST";
|
|
33
|
+
[-32603]: "INTERNAL_SERVER_ERROR";
|
|
34
|
+
[-32001]: "UNAUTHORIZED";
|
|
35
|
+
[-32003]: "FORBIDDEN";
|
|
36
|
+
[-32004]: "NOT_FOUND";
|
|
37
|
+
[-32005]: "METHOD_NOT_SUPPORTED";
|
|
38
|
+
[-32008]: "TIMEOUT";
|
|
39
|
+
[-32012]: "PRECONDITION_FAILED";
|
|
40
|
+
[-32013]: "PAYLOAD_TOO_LARGE";
|
|
41
|
+
[-32099]: "CLIENT_CLOSED_REQUEST";
|
|
42
|
+
};
|
|
43
|
+
declare type ValueOf<T> = T[keyof T];
|
|
44
|
+
export declare type TRPC_ERROR_CODE_NUMBER = ValueOf<typeof TRPC_ERROR_CODES_BY_KEY>;
|
|
45
|
+
export declare type TRPC_ERROR_CODE_KEY = keyof typeof TRPC_ERROR_CODES_BY_KEY;
|
|
46
|
+
export {};
|
|
47
47
|
//# sourceMappingURL=codes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codes.d.ts","sourceRoot":"","sources":["../../src/rpc/codes.ts"],"names":[],"mappings":"AAIA;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB;IAClC;;;OAGG;;IAEH;;OAEG;;IAEH;;OAEG;;;;;;;;;;CAWK,CAAC;AAEX,eAAO,MAAM,0BAA0B;;;;;;;;;;;;CAAkC,CAAC;AAC1E,aAAK,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;AAE7B,oBAAY,sBAAsB,GAAG,OAAO,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAC7E,oBAAY,mBAAmB,GAAG,MAAM,OAAO,uBAAuB,CAAC"}
|
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
import { ProcedureType } from '../router';
|
|
2
|
-
import { TRPC_ERROR_CODE_NUMBER } from './codes';
|
|
3
|
-
declare type JSONRPC2RequestId = number | string | null;
|
|
4
|
-
/**
|
|
5
|
-
* All requests/responses extends this shape
|
|
6
|
-
*/
|
|
7
|
-
interface JSONRPC2BaseEnvelope {
|
|
8
|
-
id: JSONRPC2RequestId;
|
|
9
|
-
jsonrpc?: '2.0';
|
|
10
|
-
}
|
|
11
|
-
interface JSONRPC2BaseRequest<TMethod extends string = string> extends JSONRPC2BaseEnvelope {
|
|
12
|
-
method: TMethod;
|
|
13
|
-
}
|
|
14
|
-
interface JSONRPC2Request<TMethod extends string = string, TParams = unknown> extends JSONRPC2BaseRequest<TMethod> {
|
|
15
|
-
params: TParams;
|
|
16
|
-
}
|
|
17
|
-
interface JSONRPC2ResultResponse<TResult = unknown> extends JSONRPC2BaseEnvelope {
|
|
18
|
-
result: TResult;
|
|
19
|
-
}
|
|
20
|
-
export interface TRPCErrorShape<TCode extends number = TRPC_ERROR_CODE_NUMBER, TData extends Record<string, unknown> = Record<string, unknown>> {
|
|
21
|
-
code: TCode;
|
|
22
|
-
message: string;
|
|
23
|
-
data: TData;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* The result data wrapped
|
|
27
|
-
*/
|
|
28
|
-
export declare type TRPCResult<TData = unknown> = {
|
|
29
|
-
type: 'data';
|
|
30
|
-
data: TData;
|
|
31
|
-
} | {
|
|
32
|
-
type: 'started';
|
|
33
|
-
} | {
|
|
34
|
-
type: 'stopped';
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* Request envelope
|
|
38
|
-
*/
|
|
39
|
-
export declare type TRPCRequest = JSONRPC2Request<'subscription.stop'> | JSONRPC2Request<ProcedureType, {
|
|
40
|
-
path: string;
|
|
41
|
-
input: unknown;
|
|
42
|
-
}>;
|
|
43
|
-
/**
|
|
44
|
-
* OK response
|
|
45
|
-
*/
|
|
46
|
-
export declare type TRPCResultResponse<TData = unknown> = JSONRPC2ResultResponse<TRPCResult<TData>>;
|
|
47
|
-
/**
|
|
48
|
-
* Generic response wrapper that is either a result or error
|
|
49
|
-
*/
|
|
50
|
-
export declare type TRPCResponse<TData = unknown, TError extends TRPCErrorShape = TRPCErrorShape> = TRPCResultResponse<TData> | TRPCErrorResponse<TError>;
|
|
51
|
-
/**
|
|
52
|
-
* Error response
|
|
53
|
-
*/
|
|
54
|
-
export interface TRPCErrorResponse<TError extends TRPCErrorShape = TRPCErrorShape> extends JSONRPC2BaseEnvelope {
|
|
55
|
-
error: TError;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* The server asked the client to reconnect - useful when restarting/redeploying service
|
|
59
|
-
*/
|
|
60
|
-
export interface TRPCReconnectNotification extends JSONRPC2BaseRequest<'reconnect'> {
|
|
61
|
-
id: null;
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* The client's incoming request types
|
|
65
|
-
*/
|
|
66
|
-
export declare type TRPCClientIncomingRequest = TRPCReconnectNotification;
|
|
67
|
-
/**
|
|
68
|
-
* The client's received messages shape
|
|
69
|
-
*/
|
|
70
|
-
export declare type TRPCClientIncomingMessage = TRPCResponse | TRPCClientIncomingRequest;
|
|
71
|
-
export {};
|
|
1
|
+
import { ProcedureType } from '../router';
|
|
2
|
+
import { TRPC_ERROR_CODE_NUMBER } from './codes';
|
|
3
|
+
declare type JSONRPC2RequestId = number | string | null;
|
|
4
|
+
/**
|
|
5
|
+
* All requests/responses extends this shape
|
|
6
|
+
*/
|
|
7
|
+
interface JSONRPC2BaseEnvelope {
|
|
8
|
+
id: JSONRPC2RequestId;
|
|
9
|
+
jsonrpc?: '2.0';
|
|
10
|
+
}
|
|
11
|
+
interface JSONRPC2BaseRequest<TMethod extends string = string> extends JSONRPC2BaseEnvelope {
|
|
12
|
+
method: TMethod;
|
|
13
|
+
}
|
|
14
|
+
interface JSONRPC2Request<TMethod extends string = string, TParams = unknown> extends JSONRPC2BaseRequest<TMethod> {
|
|
15
|
+
params: TParams;
|
|
16
|
+
}
|
|
17
|
+
interface JSONRPC2ResultResponse<TResult = unknown> extends JSONRPC2BaseEnvelope {
|
|
18
|
+
result: TResult;
|
|
19
|
+
}
|
|
20
|
+
export interface TRPCErrorShape<TCode extends number = TRPC_ERROR_CODE_NUMBER, TData extends Record<string, unknown> = Record<string, unknown>> {
|
|
21
|
+
code: TCode;
|
|
22
|
+
message: string;
|
|
23
|
+
data: TData;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* The result data wrapped
|
|
27
|
+
*/
|
|
28
|
+
export declare type TRPCResult<TData = unknown> = {
|
|
29
|
+
type: 'data';
|
|
30
|
+
data: TData;
|
|
31
|
+
} | {
|
|
32
|
+
type: 'started';
|
|
33
|
+
} | {
|
|
34
|
+
type: 'stopped';
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Request envelope
|
|
38
|
+
*/
|
|
39
|
+
export declare type TRPCRequest = JSONRPC2Request<'subscription.stop'> | JSONRPC2Request<ProcedureType, {
|
|
40
|
+
path: string;
|
|
41
|
+
input: unknown;
|
|
42
|
+
}>;
|
|
43
|
+
/**
|
|
44
|
+
* OK response
|
|
45
|
+
*/
|
|
46
|
+
export declare type TRPCResultResponse<TData = unknown> = JSONRPC2ResultResponse<TRPCResult<TData>>;
|
|
47
|
+
/**
|
|
48
|
+
* Generic response wrapper that is either a result or error
|
|
49
|
+
*/
|
|
50
|
+
export declare type TRPCResponse<TData = unknown, TError extends TRPCErrorShape = TRPCErrorShape> = TRPCResultResponse<TData> | TRPCErrorResponse<TError>;
|
|
51
|
+
/**
|
|
52
|
+
* Error response
|
|
53
|
+
*/
|
|
54
|
+
export interface TRPCErrorResponse<TError extends TRPCErrorShape = TRPCErrorShape> extends JSONRPC2BaseEnvelope {
|
|
55
|
+
error: TError;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* The server asked the client to reconnect - useful when restarting/redeploying service
|
|
59
|
+
*/
|
|
60
|
+
export interface TRPCReconnectNotification extends JSONRPC2BaseRequest<'reconnect'> {
|
|
61
|
+
id: null;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The client's incoming request types
|
|
65
|
+
*/
|
|
66
|
+
export declare type TRPCClientIncomingRequest = TRPCReconnectNotification;
|
|
67
|
+
/**
|
|
68
|
+
* The client's received messages shape
|
|
69
|
+
*/
|
|
70
|
+
export declare type TRPCClientIncomingMessage = TRPCResponse | TRPCClientIncomingRequest;
|
|
71
|
+
export {};
|
|
72
72
|
//# sourceMappingURL=envelopes.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"envelopes.d.ts","sourceRoot":"","sources":["../../src/rpc/envelopes.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEjD,aAAK,iBAAiB,GAAG,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;AAEh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EG;AACH,oBAAY,YAAY,CACtB,KAAK,GAAG,OAAO,EACf,MAAM,SAAS,cAAc,GAAG,cAAc,IAC5C,kBAAkB,CAAC,KAAK,CAAC,GAAG,iBAAiB,CAAC,MAAM,CAAC,CAAC;AAE1D;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAChC,MAAM,SAAS,cAAc,GAAG,cAAc,CAC9C,SAAQ,oBAAoB;IAC5B,KAAK,EAAE,MAAM,CAAC;CACf;AAED;;GAEG;AACH,MAAM,WAAW,yBACf,SAAQ,mBAAmB,CAAC,WAAW,CAAC;IACxC,EAAE,EAAE,IAAI,CAAC;CACV;AAED;;GAEG;AACH,oBAAY,yBAAyB,GACnC,yBAAyB,CAAmC;AAE9D;;GAEG;AACH,oBAAY,yBAAyB,GACjC,YAAY,GACZ,yBAAyB,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './codes';
|
|
2
|
-
export * from './envelopes';
|
|
1
|
+
export * from './codes';
|
|
2
|
+
export * from './envelopes';
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/rpc/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC"}
|