@trpc/server 9.20.1 → 10.0.0-alpha.10

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.
Files changed (203) hide show
  1. package/adapters/express/dist/trpc-server-adapters-express.cjs.dev.js +1 -1
  2. package/adapters/express/dist/trpc-server-adapters-express.cjs.prod.js +1 -1
  3. package/adapters/express/dist/trpc-server-adapters-express.esm.js +1 -1
  4. package/adapters/express/index.d.ts +1 -0
  5. package/adapters/express/index.js +1 -0
  6. package/adapters/fastify/index.d.ts +1 -0
  7. package/adapters/fastify/index.js +1 -0
  8. package/adapters/next/dist/trpc-server-adapters-next.cjs.dev.js +1 -1
  9. package/adapters/next/dist/trpc-server-adapters-next.cjs.prod.js +1 -1
  10. package/adapters/next/dist/trpc-server-adapters-next.esm.js +1 -1
  11. package/adapters/next/index.d.ts +1 -0
  12. package/adapters/next/index.js +1 -0
  13. package/adapters/node-http/dist/trpc-server-adapters-node-http.cjs.dev.js +1 -1
  14. package/adapters/node-http/dist/trpc-server-adapters-node-http.cjs.prod.js +1 -1
  15. package/adapters/node-http/dist/trpc-server-adapters-node-http.esm.js +1 -1
  16. package/adapters/node-http/index.d.ts +1 -0
  17. package/adapters/node-http/index.js +1 -0
  18. package/adapters/standalone/dist/trpc-server-adapters-standalone.cjs.dev.js +1 -1
  19. package/adapters/standalone/dist/trpc-server-adapters-standalone.cjs.prod.js +1 -1
  20. package/adapters/standalone/dist/trpc-server-adapters-standalone.esm.js +1 -1
  21. package/adapters/standalone/index.d.ts +1 -0
  22. package/adapters/standalone/index.js +1 -0
  23. package/adapters/ws/dist/trpc-server-adapters-ws.cjs.dev.js +1 -2
  24. package/adapters/ws/dist/trpc-server-adapters-ws.cjs.prod.js +1 -2
  25. package/adapters/ws/dist/trpc-server-adapters-ws.esm.js +1 -2
  26. package/adapters/ws/index.d.ts +1 -0
  27. package/adapters/ws/index.js +1 -0
  28. package/dist/{declarations/src/TRPCError.d.ts → TRPCError.d.ts} +18 -18
  29. package/dist/TRPCError.d.ts.map +1 -0
  30. package/dist/{declarations/src/adapters → adapters}/express.d.ts +5 -5
  31. package/dist/adapters/express.d.ts.map +1 -0
  32. package/dist/adapters/express.js +23 -0
  33. package/dist/adapters/express.mjs +19 -0
  34. package/dist/adapters/express.ts.js +1 -0
  35. package/dist/{declarations/src/adapters → adapters}/fastify/fastifyRequestHandler.d.ts +12 -12
  36. package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +1 -0
  37. package/dist/{declarations/src/adapters → adapters}/fastify/fastifyTRPCPlugin.d.ts +11 -11
  38. package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -0
  39. package/dist/{declarations/src/adapters → adapters}/fastify/index.d.ts +2 -2
  40. package/dist/adapters/fastify/index.d.ts.map +1 -0
  41. package/dist/adapters/fastify/index.js +102 -0
  42. package/dist/adapters/fastify/index.mjs +97 -0
  43. package/dist/adapters/fastify/index.ts.js +1 -0
  44. package/dist/{declarations/src/adapters → adapters}/next.d.ts +5 -5
  45. package/dist/adapters/next.d.ts.map +1 -0
  46. package/dist/adapters/next.js +56 -0
  47. package/dist/adapters/next.mjs +52 -0
  48. package/dist/adapters/next.ts.js +1 -0
  49. package/dist/{declarations/src/adapters → adapters}/node-http/index.d.ts +2 -2
  50. package/dist/adapters/node-http/index.d.ts.map +1 -0
  51. package/dist/adapters/node-http/index.js +13 -0
  52. package/dist/adapters/node-http/index.mjs +5 -0
  53. package/dist/adapters/node-http/index.ts.js +1 -0
  54. package/dist/{declarations/src/adapters → adapters}/node-http/internals/getPostBody.d.ts +12 -12
  55. package/dist/adapters/node-http/internals/getPostBody.d.ts.map +1 -0
  56. package/dist/{declarations/src/adapters → adapters}/node-http/nodeHTTPRequestHandler.d.ts +9 -9
  57. package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -0
  58. package/dist/{declarations/src/adapters → adapters}/node-http/types.d.ts +32 -32
  59. package/dist/adapters/node-http/types.d.ts.map +1 -0
  60. package/dist/{declarations/src/adapters → adapters}/standalone.d.ts +13 -13
  61. package/dist/adapters/standalone.d.ts.map +1 -0
  62. package/dist/adapters/standalone.js +46 -0
  63. package/dist/adapters/standalone.mjs +36 -0
  64. package/dist/adapters/standalone.ts.js +1 -0
  65. package/dist/{declarations/src/adapters → adapters}/ws.d.ts +16 -16
  66. package/dist/adapters/ws.d.ts.map +1 -0
  67. package/dist/adapters/ws.js +346 -0
  68. package/dist/adapters/ws.mjs +342 -0
  69. package/dist/adapters/ws.ts.js +1 -0
  70. package/dist/{declarations/src/assertNotBrowser.d.ts → assertNotBrowser.d.ts} +1 -1
  71. package/dist/assertNotBrowser.d.ts.map +1 -0
  72. package/dist/{codes-fe07bf82.esm.js → codes-7a3d4f65.mjs} +0 -0
  73. package/dist/{codes-33cef953.cjs.dev.js → codes-7f46544e.js} +0 -0
  74. package/dist/{declarations/src/deprecated → deprecated}/LegacyRouter.d.ts +2 -2
  75. package/dist/deprecated/LegacyRouter.d.ts.map +1 -0
  76. package/dist/{declarations/src/deprecated → deprecated}/createHttpServer.d.ts +18 -18
  77. package/dist/deprecated/createHttpServer.d.ts.map +1 -0
  78. package/dist/{declarations/src/deprecated → deprecated}/requestHandler.d.ts +14 -14
  79. package/dist/deprecated/requestHandler.d.ts.map +1 -0
  80. package/dist/{declarations/src/http → http}/ResponseMeta.d.ts +4 -4
  81. package/dist/http/ResponseMeta.d.ts.map +1 -0
  82. package/dist/{declarations/src/http → http}/index.d.ts +2 -2
  83. package/dist/http/index.d.ts.map +1 -0
  84. package/dist/{declarations/src/http → http}/internals/getHTTPStatusCode.d.ts +20 -20
  85. package/dist/http/internals/getHTTPStatusCode.d.ts.map +1 -0
  86. package/dist/{declarations/src/http → http}/internals/types.d.ts +39 -39
  87. package/dist/http/internals/types.d.ts.map +1 -0
  88. package/dist/{declarations/src/http → http}/resolveHTTPResponse.d.ts +12 -12
  89. package/dist/http/resolveHTTPResponse.d.ts.map +1 -0
  90. package/dist/{declarations/src/index.d.ts → index.d.ts} +9 -9
  91. package/dist/index.d.ts.map +1 -0
  92. package/dist/{trpc-server.cjs.dev.js → index.js} +8 -8
  93. package/dist/{trpc-server.esm.js → index.mjs} +8 -8
  94. package/dist/index.ts.js +1 -0
  95. package/dist/{declarations/src/internals → internals}/BaseHandlerOptions.d.ts +12 -12
  96. package/dist/internals/BaseHandlerOptions.d.ts.map +1 -0
  97. package/dist/{declarations/src/internals → internals}/OnErrorFunction.d.ts +10 -10
  98. package/dist/internals/OnErrorFunction.d.ts.map +1 -0
  99. package/dist/{declarations/src/internals → internals}/callProcedure.d.ts +9 -9
  100. package/dist/internals/callProcedure.d.ts.map +1 -0
  101. package/dist/{declarations/src/internals → internals}/errors.d.ts +3 -3
  102. package/dist/internals/errors.d.ts.map +1 -0
  103. package/dist/{declarations/src/internals → internals}/invert.d.ts +8 -8
  104. package/dist/internals/invert.d.ts.map +1 -0
  105. package/dist/{declarations/src/internals → internals}/middlewares.d.ts +33 -33
  106. package/dist/internals/middlewares.d.ts.map +1 -0
  107. package/dist/{declarations/src/internals → internals}/procedure.d.ts +73 -73
  108. package/dist/internals/procedure.d.ts.map +1 -0
  109. package/dist/{declarations/src/internals → internals}/transformTRPCResponse.d.ts +6 -6
  110. package/dist/internals/transformTRPCResponse.d.ts.map +1 -0
  111. package/dist/{declarations/src/internals → internals}/wrapCallSafe.d.ts +15 -15
  112. package/dist/internals/wrapCallSafe.d.ts.map +1 -0
  113. package/dist/{nodeHTTPRequestHandler-d00c1126.esm.js → nodeHTTPRequestHandler-17a5e0dd.mjs} +2 -2
  114. package/dist/{nodeHTTPRequestHandler-2cc444d8.cjs.dev.js → nodeHTTPRequestHandler-17b64c0e.js} +2 -2
  115. package/dist/{resolveHTTPResponse-3867844c.cjs.dev.js → resolveHTTPResponse-087ce86a.js} +2 -2
  116. package/dist/{resolveHTTPResponse-85f3f5df.esm.js → resolveHTTPResponse-9604d47d.mjs} +2 -2
  117. package/dist/{declarations/src/router.d.ts → router.d.ts} +175 -175
  118. package/dist/router.d.ts.map +1 -0
  119. package/dist/{declarations/src/rpc → rpc}/codes.d.ts +46 -46
  120. package/dist/rpc/codes.d.ts.map +1 -0
  121. package/dist/{declarations/src/rpc → rpc}/envelopes.d.ts +71 -71
  122. package/dist/rpc/envelopes.d.ts.map +1 -0
  123. package/dist/{declarations/src/rpc → rpc}/index.d.ts +2 -2
  124. package/dist/rpc/index.d.ts.map +1 -0
  125. package/dist/rpc/index.js +10 -0
  126. package/dist/rpc/index.mjs +1 -0
  127. package/dist/rpc/index.ts.js +1 -0
  128. package/dist/{subscription-b8831081.cjs.dev.js → subscription-5b7e1eba.js} +1 -1
  129. package/dist/{subscription-fbda2888.esm.js → subscription-e1d42e69.mjs} +1 -1
  130. package/dist/{declarations/src/subscription.d.ts → subscription.d.ts} +57 -57
  131. package/dist/subscription.d.ts.map +1 -0
  132. package/dist/{transformTRPCResponse-f73dc4a2.esm.js → transformTRPCResponse-76e0c91e.mjs} +0 -0
  133. package/dist/{transformTRPCResponse-8248515e.cjs.dev.js → transformTRPCResponse-bd24f548.js} +0 -0
  134. package/dist/{declarations/src/transformer.d.ts → transformer.d.ts} +29 -29
  135. package/dist/transformer.d.ts.map +1 -0
  136. package/dist/{declarations/src/types.d.ts → types.d.ts} +40 -40
  137. package/dist/types.d.ts.map +1 -0
  138. package/dist/{declarations/src/ws → ws}/index.d.ts +6 -6
  139. package/dist/ws/index.d.ts.map +1 -0
  140. package/dist/ws/index.js +15 -0
  141. package/dist/ws/index.mjs +11 -0
  142. package/dist/ws/index.ts.js +1 -0
  143. package/package.json +55 -19
  144. package/rpc/index.d.ts +1 -0
  145. package/rpc/index.js +1 -0
  146. package/src/adapters/ws.ts +1 -4
  147. package/ws/index.d.ts +1 -0
  148. package/ws/index.js +1 -0
  149. package/adapters/express/package.json +0 -4
  150. package/adapters/fastify/package.json +0 -4
  151. package/adapters/next/package.json +0 -4
  152. package/adapters/node-http/package.json +0 -4
  153. package/adapters/standalone/package.json +0 -4
  154. package/adapters/ws/package.json +0 -4
  155. package/dist/codes-e0df67c4.cjs.prod.js +0 -60
  156. package/dist/declarations/src/TRPCError.d.ts.map +0 -1
  157. package/dist/declarations/src/adapters/express.d.ts.map +0 -1
  158. package/dist/declarations/src/adapters/fastify/fastifyRequestHandler.d.ts.map +0 -1
  159. package/dist/declarations/src/adapters/fastify/fastifyTRPCPlugin.d.ts.map +0 -1
  160. package/dist/declarations/src/adapters/fastify/index.d.ts.map +0 -1
  161. package/dist/declarations/src/adapters/next.d.ts.map +0 -1
  162. package/dist/declarations/src/adapters/node-http/index.d.ts.map +0 -1
  163. package/dist/declarations/src/adapters/node-http/internals/getPostBody.d.ts.map +0 -1
  164. package/dist/declarations/src/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +0 -1
  165. package/dist/declarations/src/adapters/node-http/types.d.ts.map +0 -1
  166. package/dist/declarations/src/adapters/standalone.d.ts.map +0 -1
  167. package/dist/declarations/src/adapters/ws.d.ts.map +0 -1
  168. package/dist/declarations/src/assertNotBrowser.d.ts.map +0 -1
  169. package/dist/declarations/src/deprecated/LegacyRouter.d.ts.map +0 -1
  170. package/dist/declarations/src/deprecated/createHttpServer.d.ts.map +0 -1
  171. package/dist/declarations/src/deprecated/requestHandler.d.ts.map +0 -1
  172. package/dist/declarations/src/http/ResponseMeta.d.ts.map +0 -1
  173. package/dist/declarations/src/http/index.d.ts.map +0 -1
  174. package/dist/declarations/src/http/internals/getHTTPStatusCode.d.ts.map +0 -1
  175. package/dist/declarations/src/http/internals/types.d.ts.map +0 -1
  176. package/dist/declarations/src/http/resolveHTTPResponse.d.ts.map +0 -1
  177. package/dist/declarations/src/index.d.ts.map +0 -1
  178. package/dist/declarations/src/internals/BaseHandlerOptions.d.ts.map +0 -1
  179. package/dist/declarations/src/internals/OnErrorFunction.d.ts.map +0 -1
  180. package/dist/declarations/src/internals/callProcedure.d.ts.map +0 -1
  181. package/dist/declarations/src/internals/errors.d.ts.map +0 -1
  182. package/dist/declarations/src/internals/invert.d.ts.map +0 -1
  183. package/dist/declarations/src/internals/middlewares.d.ts.map +0 -1
  184. package/dist/declarations/src/internals/procedure.d.ts.map +0 -1
  185. package/dist/declarations/src/internals/transformTRPCResponse.d.ts.map +0 -1
  186. package/dist/declarations/src/internals/wrapCallSafe.d.ts.map +0 -1
  187. package/dist/declarations/src/router.d.ts.map +0 -1
  188. package/dist/declarations/src/rpc/codes.d.ts.map +0 -1
  189. package/dist/declarations/src/rpc/envelopes.d.ts.map +0 -1
  190. package/dist/declarations/src/rpc/index.d.ts.map +0 -1
  191. package/dist/declarations/src/subscription.d.ts.map +0 -1
  192. package/dist/declarations/src/transformer.d.ts.map +0 -1
  193. package/dist/declarations/src/types.d.ts.map +0 -1
  194. package/dist/declarations/src/ws/index.d.ts.map +0 -1
  195. package/dist/nodeHTTPRequestHandler-8ddacc19.cjs.prod.js +0 -108
  196. package/dist/resolveHTTPResponse-562c3d62.cjs.prod.js +0 -296
  197. package/dist/subscription-c2e0bfbc.cjs.prod.js +0 -136
  198. package/dist/transformTRPCResponse-dcbf66c5.cjs.prod.js +0 -114
  199. package/dist/trpc-server.cjs.d.ts +0 -1
  200. package/dist/trpc-server.cjs.js +0 -7
  201. package/dist/trpc-server.cjs.prod.js +0 -529
  202. package/rpc/package.json +0 -4
  203. package/ws/package.json +0 -4
@@ -1,74 +1,74 @@
1
- import { ProcedureType } from '../router';
2
- import { MiddlewareFunction } from './middlewares';
3
- export declare type ProcedureInputParserZodEsque<TInput, TParsedInput> = {
4
- _input: TInput;
5
- _output: TParsedInput;
6
- };
7
- export declare type ProcedureInputParserMyZodEsque<TInput> = {
8
- parse: (input: any) => TInput;
9
- };
10
- export declare type ProcedureInputParserSuperstructEsque<TInput> = {
11
- create: (input: unknown) => TInput;
12
- };
13
- export declare type ProcedureInputParserCustomValidatorEsque<TInput> = (input: unknown) => TInput | Promise<TInput>;
14
- export declare type ProcedureInputParserYupEsque<TInput> = {
15
- validateSync: (input: unknown) => TInput;
16
- };
17
- export declare type ProcedureInputParser<TInput> = ProcedureInputParserYupEsque<TInput> | ProcedureInputParserSuperstructEsque<TInput> | ProcedureInputParserCustomValidatorEsque<TInput> | ProcedureInputParserMyZodEsque<TInput>;
18
- export declare type ProcedureInputParserWithInputOutput<TInput, TParsedInput> = ProcedureInputParserZodEsque<TInput, TParsedInput>;
19
- export declare type ProcedureResolver<TContext, TParsedInput, TOutput> = (opts: {
20
- ctx: TContext;
21
- input: TParsedInput;
22
- type: ProcedureType;
23
- }) => Promise<TOutput> | TOutput;
24
- interface ProcedureOptions<TContext, TParsedInput, TOutput> {
25
- middlewares: Array<MiddlewareFunction<any, any>>;
26
- resolver: ProcedureResolver<TContext, TParsedInput, TOutput>;
27
- inputParser: ProcedureInputParser<TParsedInput>;
28
- }
29
- /**
30
- * @internal
31
- */
32
- export interface ProcedureCallOptions<TContext> {
33
- ctx: TContext;
34
- rawInput: unknown;
35
- path: string;
36
- type: ProcedureType;
37
- }
38
- /**
39
- * @internal
40
- */
41
- export declare class Procedure<TInputContext, TContext, TInput, TParsedInput, TOutput> {
42
- private middlewares;
43
- private resolver;
44
- private readonly inputParser;
45
- private parse;
46
- constructor(opts: ProcedureOptions<TContext, TParsedInput, TOutput>);
47
- private parseInput;
48
- /**
49
- * Trigger middlewares in order, parse raw input & call resolver
50
- * @internal
51
- */
52
- call(opts: ProcedureCallOptions<TInputContext>): Promise<TOutput>;
53
- /**
54
- * Create new procedure with passed middlewares
55
- * @param middlewares
56
- */
57
- inheritMiddlewares(middlewares: MiddlewareFunction<TInputContext, TContext>[]): this;
58
- }
59
- export declare type CreateProcedureWithInput<TContext, TInput, TParsedInput, TOutput> = {
60
- input: ProcedureInputParser<TInput>;
61
- resolve: ProcedureResolver<TContext, TParsedInput, TOutput>;
62
- };
63
- export declare type CreateProcedureWithInputOutputParser<TContext, TInput, TParsedInput, TOutput> = {
64
- input: ProcedureInputParserWithInputOutput<TInput, TParsedInput>;
65
- resolve: ProcedureResolver<TContext, TParsedInput, TOutput>;
66
- };
67
- export declare type CreateProcedureWithoutInput<TContext, TOutput> = {
68
- resolve: ProcedureResolver<TContext, undefined, TOutput>;
69
- };
70
- export declare type CreateProcedureOptions<TContext, TInput = undefined, TParsedInput = undefined, TOutput = undefined> = CreateProcedureWithInput<TContext, TInput, TParsedInput, TOutput> | CreateProcedureWithInputOutputParser<TContext, TInput, TParsedInput, TOutput> | CreateProcedureWithoutInput<TContext, TOutput>;
71
- export declare function createProcedure<TContext, TInput, TParsedInput, TOutput>(opts: CreateProcedureOptions<TContext, TInput, TParsedInput, TOutput>): Procedure<unknown, TContext, TInput, TParsedInput, TOutput>;
72
- export declare type inferProcedureFromOptions<TInputContext, TOptions extends CreateProcedureOptions<any, any, any, any>> = TOptions extends CreateProcedureOptions<infer TContext, infer TInput, infer TParsedInput, infer TOutput> ? Procedure<TInputContext, TContext, unknown extends TInput ? undefined : TInput, unknown extends TParsedInput ? undefined : TParsedInput, TOutput> : never;
73
- export {};
1
+ import { ProcedureType } from '../router';
2
+ import { MiddlewareFunction } from './middlewares';
3
+ export declare type ProcedureInputParserZodEsque<TInput, TParsedInput> = {
4
+ _input: TInput;
5
+ _output: TParsedInput;
6
+ };
7
+ export declare type ProcedureInputParserMyZodEsque<TInput> = {
8
+ parse: (input: any) => TInput;
9
+ };
10
+ export declare type ProcedureInputParserSuperstructEsque<TInput> = {
11
+ create: (input: unknown) => TInput;
12
+ };
13
+ export declare type ProcedureInputParserCustomValidatorEsque<TInput> = (input: unknown) => TInput | Promise<TInput>;
14
+ export declare type ProcedureInputParserYupEsque<TInput> = {
15
+ validateSync: (input: unknown) => TInput;
16
+ };
17
+ export declare type ProcedureInputParser<TInput> = ProcedureInputParserYupEsque<TInput> | ProcedureInputParserSuperstructEsque<TInput> | ProcedureInputParserCustomValidatorEsque<TInput> | ProcedureInputParserMyZodEsque<TInput>;
18
+ export declare type ProcedureInputParserWithInputOutput<TInput, TParsedInput> = ProcedureInputParserZodEsque<TInput, TParsedInput>;
19
+ export declare type ProcedureResolver<TContext, TParsedInput, TOutput> = (opts: {
20
+ ctx: TContext;
21
+ input: TParsedInput;
22
+ type: ProcedureType;
23
+ }) => Promise<TOutput> | TOutput;
24
+ interface ProcedureOptions<TContext, TParsedInput, TOutput> {
25
+ middlewares: Array<MiddlewareFunction<any, any>>;
26
+ resolver: ProcedureResolver<TContext, TParsedInput, TOutput>;
27
+ inputParser: ProcedureInputParser<TParsedInput>;
28
+ }
29
+ /**
30
+ * @internal
31
+ */
32
+ export interface ProcedureCallOptions<TContext> {
33
+ ctx: TContext;
34
+ rawInput: unknown;
35
+ path: string;
36
+ type: ProcedureType;
37
+ }
38
+ /**
39
+ * @internal
40
+ */
41
+ export declare class Procedure<TInputContext, TContext, TInput, TParsedInput, TOutput> {
42
+ private middlewares;
43
+ private resolver;
44
+ private readonly inputParser;
45
+ private parse;
46
+ constructor(opts: ProcedureOptions<TContext, TParsedInput, TOutput>);
47
+ private parseInput;
48
+ /**
49
+ * Trigger middlewares in order, parse raw input & call resolver
50
+ * @internal
51
+ */
52
+ call(opts: ProcedureCallOptions<TInputContext>): Promise<TOutput>;
53
+ /**
54
+ * Create new procedure with passed middlewares
55
+ * @param middlewares
56
+ */
57
+ inheritMiddlewares(middlewares: MiddlewareFunction<TInputContext, TContext>[]): this;
58
+ }
59
+ export declare type CreateProcedureWithInput<TContext, TInput, TParsedInput, TOutput> = {
60
+ input: ProcedureInputParser<TInput>;
61
+ resolve: ProcedureResolver<TContext, TParsedInput, TOutput>;
62
+ };
63
+ export declare type CreateProcedureWithInputOutputParser<TContext, TInput, TParsedInput, TOutput> = {
64
+ input: ProcedureInputParserWithInputOutput<TInput, TParsedInput>;
65
+ resolve: ProcedureResolver<TContext, TParsedInput, TOutput>;
66
+ };
67
+ export declare type CreateProcedureWithoutInput<TContext, TOutput> = {
68
+ resolve: ProcedureResolver<TContext, undefined, TOutput>;
69
+ };
70
+ export declare type CreateProcedureOptions<TContext, TInput = undefined, TParsedInput = undefined, TOutput = undefined> = CreateProcedureWithInput<TContext, TInput, TParsedInput, TOutput> | CreateProcedureWithInputOutputParser<TContext, TInput, TParsedInput, TOutput> | CreateProcedureWithoutInput<TContext, TOutput>;
71
+ export declare function createProcedure<TContext, TInput, TParsedInput, TOutput>(opts: CreateProcedureOptions<TContext, TInput, TParsedInput, TOutput>): Procedure<unknown, TContext, TInput, TParsedInput, TOutput>;
72
+ export declare type inferProcedureFromOptions<TInputContext, TOptions extends CreateProcedureOptions<any, any, any, any>> = TOptions extends CreateProcedureOptions<infer TContext, infer TInput, infer TParsedInput, infer TOutput> ? Procedure<TInputContext, TContext, unknown extends TInput ? undefined : TInput, unknown extends TParsedInput ? undefined : TParsedInput, TOutput> : never;
73
+ export {};
74
74
  //# sourceMappingURL=procedure.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"procedure.d.ts","sourceRoot":"","sources":["../../src/internals/procedure.ts"],"names":[],"mappings":"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"}
@@ -1,7 +1,7 @@
1
- import { AnyRouter } from '../router';
2
- import { TRPCResponse } from '../rpc';
3
- /**
4
- * Takes a unserialized `TRPCResponse` and serializes it with the router's transformers
5
- **/
6
- export declare function transformTRPCResponse<TResponse extends TRPCResponse | TRPCResponse[]>(router: AnyRouter, itemOrItems: TResponse): TRPCResponse<unknown, import("../rpc").TRPCErrorShape<import("../rpc").TRPC_ERROR_CODE_NUMBER, Record<string, unknown>>> | TRPCResponse<unknown, import("../rpc").TRPCErrorShape<import("../rpc").TRPC_ERROR_CODE_NUMBER, Record<string, unknown>>>[];
1
+ import { AnyRouter } from '../router';
2
+ import { TRPCResponse } from '../rpc';
3
+ /**
4
+ * Takes a unserialized `TRPCResponse` and serializes it with the router's transformers
5
+ **/
6
+ export declare function transformTRPCResponse<TResponse extends TRPCResponse | TRPCResponse[]>(router: AnyRouter, itemOrItems: TResponse): TRPCResponse<unknown, import("../rpc").TRPCErrorShape<import("../rpc").TRPC_ERROR_CODE_NUMBER, Record<string, unknown>>> | TRPCResponse<unknown, import("../rpc").TRPCErrorShape<import("../rpc").TRPC_ERROR_CODE_NUMBER, Record<string, unknown>>>[];
7
7
  //# sourceMappingURL=transformTRPCResponse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transformTRPCResponse.d.ts","sourceRoot":"","sources":["../../src/internals/transformTRPCResponse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AACtC,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAwBtC;;IAEI;AACJ,wBAAgB,qBAAqB,CACnC,SAAS,SAAS,YAAY,GAAG,YAAY,EAAE,EAC/C,MAAM,EAAE,SAAS,EAAE,WAAW,EAAE,SAAS,yPAI1C"}
@@ -1,16 +1,16 @@
1
- declare type AsyncFn<T> = () => Promise<T> | T;
2
- /**
3
- * Wrap a function in a safe wrapper that never throws
4
- * Returns a discriminated union
5
- */
6
- export declare function wrapCallSafe<T>(fn: AsyncFn<T>): Promise<{
7
- ok: true;
8
- data: T;
9
- error?: undefined;
10
- } | {
11
- ok: false;
12
- error: unknown;
13
- data?: undefined;
14
- }>;
15
- export {};
1
+ declare type AsyncFn<T> = () => Promise<T> | T;
2
+ /**
3
+ * Wrap a function in a safe wrapper that never throws
4
+ * Returns a discriminated union
5
+ */
6
+ export declare function wrapCallSafe<T>(fn: AsyncFn<T>): Promise<{
7
+ ok: true;
8
+ data: T;
9
+ error?: undefined;
10
+ } | {
11
+ ok: false;
12
+ error: unknown;
13
+ data?: undefined;
14
+ }>;
15
+ export {};
16
16
  //# sourceMappingURL=wrapCallSafe.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapCallSafe.d.ts","sourceRoot":"","sources":["../../src/internals/wrapCallSafe.ts"],"names":[],"mappings":"AAAA,aAAK,OAAO,CAAC,CAAC,IAAI,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC;AACvC;;;GAGG;AACH,wBAAsB,YAAY,CAAC,CAAC,EAAE,EAAE,EAAE,OAAO,CAAC,CAAC,CAAC;;;;;;;;GAanD"}
@@ -1,6 +1,6 @@
1
1
  import { URLSearchParams } from 'url';
2
- import { a as assertNotBrowser, r as resolveHTTPResponse } from './resolveHTTPResponse-85f3f5df.esm.js';
3
- import { T as TRPCError } from './transformTRPCResponse-f73dc4a2.esm.js';
2
+ import { a as assertNotBrowser, r as resolveHTTPResponse } from './resolveHTTPResponse-9604d47d.mjs';
3
+ import { T as TRPCError } from './transformTRPCResponse-76e0c91e.mjs';
4
4
 
5
5
  async function getPostBody({
6
6
  req,
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var url = require('url');
4
- var resolveHTTPResponse = require('./resolveHTTPResponse-3867844c.cjs.dev.js');
5
- var transformTRPCResponse = require('./transformTRPCResponse-8248515e.cjs.dev.js');
4
+ var resolveHTTPResponse = require('./resolveHTTPResponse-087ce86a.js');
5
+ var transformTRPCResponse = require('./transformTRPCResponse-bd24f548.js');
6
6
 
7
7
  async function getPostBody({
8
8
  req,
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var transformTRPCResponse = require('./transformTRPCResponse-8248515e.cjs.dev.js');
4
- var codes = require('./codes-33cef953.cjs.dev.js');
3
+ var transformTRPCResponse = require('./transformTRPCResponse-bd24f548.js');
4
+ var codes = require('./codes-7f46544e.js');
5
5
 
6
6
  /* istanbul ignore file */
7
7
  function assertNotBrowser() {
@@ -1,5 +1,5 @@
1
- import { T as TRPCError, c as callProcedure, g as getErrorFromUnknown, t as transformTRPCResponse } from './transformTRPCResponse-f73dc4a2.esm.js';
2
- import { i as invert, T as TRPC_ERROR_CODES_BY_KEY } from './codes-fe07bf82.esm.js';
1
+ import { T as TRPCError, c as callProcedure, g as getErrorFromUnknown, t as transformTRPCResponse } from './transformTRPCResponse-76e0c91e.mjs';
2
+ import { i as invert, T as TRPC_ERROR_CODES_BY_KEY } from './codes-7a3d4f65.mjs';
3
3
 
4
4
  /* istanbul ignore file */
5
5
  function assertNotBrowser() {
@@ -1,176 +1,176 @@
1
- import { MiddlewareFunction } from './internals/middlewares';
2
- import { CreateProcedureWithInput, CreateProcedureWithInputOutputParser, CreateProcedureWithoutInput, inferProcedureFromOptions, Procedure } from './internals/procedure';
3
- import { TRPCErrorShape, TRPC_ERROR_CODE_KEY, TRPC_ERROR_CODE_NUMBER } from './rpc';
4
- import { Subscription } from './subscription';
5
- import { CombinedDataTransformer, DataTransformerOptions } from './transformer';
6
- import { TRPCError } from './TRPCError';
7
- import { flatten, Prefixer, ThenArg } 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> = 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>>, 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>(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, TInput, TOutput>): Router<TInputContext, TContext, TQueries & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TMutations, TSubscriptions, TErrorShape>;
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, TInput, TOutput>): Router<TInputContext, TContext, TQueries, TMutations & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TSubscriptions, TErrorShape>;
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, TInput, TOutput>): 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: 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
- * Subclass of `VNextRouter` with `TInputContext` and `TContext` set to the same type, for backcompat.
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 { MiddlewareFunction } from './internals/middlewares';
2
+ import { CreateProcedureWithInput, CreateProcedureWithInputOutputParser, CreateProcedureWithoutInput, inferProcedureFromOptions, Procedure } from './internals/procedure';
3
+ import { TRPCErrorShape, TRPC_ERROR_CODE_KEY, TRPC_ERROR_CODE_NUMBER } from './rpc';
4
+ import { Subscription } from './subscription';
5
+ import { CombinedDataTransformer, DataTransformerOptions } from './transformer';
6
+ import { TRPCError } from './TRPCError';
7
+ import { flatten, Prefixer, ThenArg } 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> = 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>>, 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>(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, TInput, TOutput>): Router<TInputContext, TContext, TQueries & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TMutations, TSubscriptions, TErrorShape>;
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, TInput, TOutput>): Router<TInputContext, TContext, TQueries, TMutations & Record<TPath, inferProcedureFromOptions<TInputContext, typeof procedure>>, TSubscriptions, TErrorShape>;
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, TInput, TOutput>): 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: 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
+ * Subclass of `VNextRouter` with `TInputContext` and `TContext` set to the same type, for backcompat.
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 {};
176
176
  //# sourceMappingURL=router.d.ts.map