@trpc/server 11.23.0 → 11.23.1-canary.10.8a0997add

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 (215) hide show
  1. package/dist/adapters/aws-lambda/index.cjs +12 -2
  2. package/dist/adapters/aws-lambda/index.d.cts +24 -1
  3. package/dist/adapters/aws-lambda/index.d.cts.map +1 -1
  4. package/dist/adapters/aws-lambda/index.d.mts +24 -1
  5. package/dist/adapters/aws-lambda/index.d.mts.map +1 -1
  6. package/dist/adapters/aws-lambda/index.mjs +12 -2
  7. package/dist/adapters/aws-lambda/index.mjs.map +1 -1
  8. package/dist/adapters/express.cjs +8 -3
  9. package/dist/adapters/express.d.cts +12 -2
  10. package/dist/adapters/express.d.cts.map +1 -1
  11. package/dist/adapters/express.d.mts +12 -2
  12. package/dist/adapters/express.d.mts.map +1 -1
  13. package/dist/adapters/express.mjs +8 -3
  14. package/dist/adapters/express.mjs.map +1 -1
  15. package/dist/adapters/fastify/index.cjs +20 -4
  16. package/dist/adapters/fastify/index.d.cts +38 -4
  17. package/dist/adapters/fastify/index.d.cts.map +1 -1
  18. package/dist/adapters/fastify/index.d.mts +38 -4
  19. package/dist/adapters/fastify/index.d.mts.map +1 -1
  20. package/dist/adapters/fastify/index.mjs +20 -4
  21. package/dist/adapters/fastify/index.mjs.map +1 -1
  22. package/dist/adapters/fetch/index.cjs +13 -2
  23. package/dist/adapters/fetch/index.d.cts +26 -1
  24. package/dist/adapters/fetch/index.d.cts.map +1 -1
  25. package/dist/adapters/fetch/index.d.mts +26 -1
  26. package/dist/adapters/fetch/index.d.mts.map +1 -1
  27. package/dist/adapters/fetch/index.mjs +13 -2
  28. package/dist/adapters/fetch/index.mjs.map +1 -1
  29. package/dist/adapters/next-app-dir.cjs +19 -9
  30. package/dist/adapters/next-app-dir.d.cts +21 -11
  31. package/dist/adapters/next-app-dir.d.cts.map +1 -1
  32. package/dist/adapters/next-app-dir.d.mts +21 -11
  33. package/dist/adapters/next-app-dir.d.mts.map +1 -1
  34. package/dist/adapters/next-app-dir.mjs +19 -9
  35. package/dist/adapters/next-app-dir.mjs.map +1 -1
  36. package/dist/adapters/next.cjs +10 -4
  37. package/dist/adapters/next.d.cts +13 -2
  38. package/dist/adapters/next.d.cts.map +1 -1
  39. package/dist/adapters/next.d.mts +13 -2
  40. package/dist/adapters/next.d.mts.map +1 -1
  41. package/dist/adapters/next.mjs +10 -4
  42. package/dist/adapters/next.mjs.map +1 -1
  43. package/dist/adapters/node-http/index.cjs +1 -1
  44. package/dist/adapters/node-http/index.d.cts +1 -1
  45. package/dist/adapters/node-http/index.d.mts +1 -1
  46. package/dist/adapters/node-http/index.mjs +1 -1
  47. package/dist/adapters/standalone.cjs +19 -3
  48. package/dist/adapters/standalone.d.cts +32 -6
  49. package/dist/adapters/standalone.d.cts.map +1 -1
  50. package/dist/adapters/standalone.d.mts +32 -6
  51. package/dist/adapters/standalone.d.mts.map +1 -1
  52. package/dist/adapters/standalone.mjs +19 -3
  53. package/dist/adapters/standalone.mjs.map +1 -1
  54. package/dist/adapters/ws.cjs +1 -1
  55. package/dist/adapters/ws.d.cts +2 -2
  56. package/dist/adapters/ws.d.mts +2 -2
  57. package/dist/adapters/ws.mjs +1 -1
  58. package/dist/{asyncGeneratorDelegate-FcEJT04i.mjs → asyncGeneratorDelegate-Bl41FGB5.mjs} +41 -8
  59. package/dist/asyncGeneratorDelegate-Bl41FGB5.mjs.map +1 -0
  60. package/dist/{asyncGeneratorDelegate-Dj-8tGhf.cjs → asyncGeneratorDelegate-CPV0O1Hn.cjs} +40 -7
  61. package/dist/{codes-HK4UsP07.cjs → codes-Be-DrYMh.cjs} +8 -4
  62. package/dist/{codes-C9N0z0an.mjs → codes-nbrm_zWY.mjs} +9 -5
  63. package/dist/codes-nbrm_zWY.mjs.map +1 -0
  64. package/dist/{contentTypeParsers-B1e2ZNvN.cjs → contentTypeParsers-BTdoZrqN.cjs} +12 -0
  65. package/dist/contentTypeParsers-D1EBkFFY.mjs +26 -0
  66. package/dist/contentTypeParsers-D1EBkFFY.mjs.map +1 -0
  67. package/dist/{getErrorShape-hncV8cPE.cjs → getErrorShape-8t0oLscZ.cjs} +16 -5
  68. package/dist/{getErrorShape-zlj81BiC.mjs → getErrorShape-B6z8u8q0.mjs} +17 -6
  69. package/dist/getErrorShape-B6z8u8q0.mjs.map +1 -0
  70. package/dist/http.cjs +3 -3
  71. package/dist/http.d.cts +1 -1
  72. package/dist/http.d.mts +1 -1
  73. package/dist/http.mjs +3 -3
  74. package/dist/{index-BI3Qi_F-.d.cts → index-BGYvuCEh.d.cts} +68 -8
  75. package/dist/index-BGYvuCEh.d.cts.map +1 -0
  76. package/dist/{index-BI3Qi_F-.d.mts → index-BGYvuCEh.d.mts} +68 -8
  77. package/dist/index-BGYvuCEh.d.mts.map +1 -0
  78. package/dist/{index-Tpw5OCTF.d.cts → index-CTfJHk7_.d.cts} +41 -29
  79. package/dist/index-CTfJHk7_.d.cts.map +1 -0
  80. package/dist/{index-CtkOmZzm.d.mts → index-DD2oXVyh.d.mts} +41 -29
  81. package/dist/index-DD2oXVyh.d.mts.map +1 -0
  82. package/dist/index.cjs +3 -3
  83. package/dist/index.d.cts +3 -3
  84. package/dist/index.d.mts +3 -3
  85. package/dist/index.mjs +3 -3
  86. package/dist/{initTRPC-RMeQIy9H.mjs → initTRPC-JhlmAV6P.mjs} +31 -22
  87. package/dist/initTRPC-JhlmAV6P.mjs.map +1 -0
  88. package/dist/{initTRPC-DP-s8c4t.cjs → initTRPC-jn7uHFOx.cjs} +30 -21
  89. package/dist/{node-http-X8RiQEuH.cjs → node-http-CCpTZ1zd.cjs} +13 -6
  90. package/dist/{node-http-ChhZEv1k.mjs → node-http-DTcc6qM4.mjs} +14 -7
  91. package/dist/node-http-DTcc6qM4.mjs.map +1 -0
  92. package/dist/observable/index.cjs +2 -2
  93. package/dist/observable/index.d.cts +1 -1
  94. package/dist/observable/index.d.mts +1 -1
  95. package/dist/observable/index.mjs +2 -2
  96. package/dist/{observable-C-LvH26G.cjs → observable-B8nn0anr.cjs} +27 -4
  97. package/dist/{observable-yEyhfXUI.mjs → observable-CdPmrXKY.mjs} +28 -5
  98. package/dist/observable-CdPmrXKY.mjs.map +1 -0
  99. package/dist/{observable-CkXWrCsV.mjs → observable-F1Nt_3e4.mjs} +16 -4
  100. package/dist/observable-F1Nt_3e4.mjs.map +1 -0
  101. package/dist/{observable-xBsJ11Ns.cjs → observable-N4F1yT7s.cjs} +15 -3
  102. package/dist/{parseTRPCMessage-CJ4DJVBp.mjs → parseTRPCMessage-BO1-cCsX.mjs} +7 -3
  103. package/dist/parseTRPCMessage-BO1-cCsX.mjs.map +1 -0
  104. package/dist/{parseTRPCMessage-CPEfSSFx.cjs → parseTRPCMessage-BsPr5reh.cjs} +6 -2
  105. package/dist/{resolveResponse-DksrxZ2k.mjs → resolveResponse-B2MQmLSr.mjs} +17 -5
  106. package/dist/resolveResponse-B2MQmLSr.mjs.map +1 -0
  107. package/dist/{resolveResponse-CoGjFxK0.cjs → resolveResponse-BQcrvKyB.cjs} +16 -4
  108. package/dist/rpc.cjs +2 -2
  109. package/dist/rpc.d.cts +1 -1
  110. package/dist/rpc.d.mts +1 -1
  111. package/dist/rpc.mjs +2 -2
  112. package/dist/shared.cjs +1 -1
  113. package/dist/shared.d.cts +1 -1
  114. package/dist/shared.d.mts +1 -1
  115. package/dist/shared.mjs +1 -1
  116. package/dist/{unstable-core-do-not-import-B8epiErP.d.cts → unstable-core-do-not-import-DYnAWlN7.d.cts} +517 -161
  117. package/dist/unstable-core-do-not-import-DYnAWlN7.d.cts.map +1 -0
  118. package/dist/{unstable-core-do-not-import-Dbo98mkh.d.mts → unstable-core-do-not-import-hC2_7K-s.d.mts} +517 -161
  119. package/dist/unstable-core-do-not-import-hC2_7K-s.d.mts.map +1 -0
  120. package/dist/unstable-core-do-not-import.cjs +7 -7
  121. package/dist/unstable-core-do-not-import.d.cts +1 -1
  122. package/dist/unstable-core-do-not-import.d.mts +1 -1
  123. package/dist/unstable-core-do-not-import.mjs +7 -7
  124. package/dist/{ws-BYfo-HED.mjs → ws-B9v4J-4P.mjs} +30 -11
  125. package/dist/ws-B9v4J-4P.mjs.map +1 -0
  126. package/dist/ws-DVHbmgfC.d.mts +95 -0
  127. package/dist/ws-DVHbmgfC.d.mts.map +1 -0
  128. package/dist/ws-JzZs-0Zd.d.cts +95 -0
  129. package/dist/ws-JzZs-0Zd.d.cts.map +1 -0
  130. package/dist/{ws-7qWW7Uec.cjs → ws-_SClUVOu.cjs} +29 -10
  131. package/package.json +2 -2
  132. package/skills/adapter-aws-lambda/SKILL.md +1 -1
  133. package/skills/adapter-express/SKILL.md +1 -1
  134. package/skills/adapter-fastify/SKILL.md +1 -1
  135. package/skills/adapter-fetch/SKILL.md +1 -1
  136. package/skills/adapter-standalone/SKILL.md +1 -1
  137. package/skills/auth/SKILL.md +1 -1
  138. package/skills/caching/SKILL.md +2 -2
  139. package/skills/error-handling/SKILL.md +1 -1
  140. package/skills/middlewares/SKILL.md +1 -1
  141. package/skills/non-json-content-types/SKILL.md +1 -1
  142. package/skills/server-setup/SKILL.md +1 -1
  143. package/skills/server-side-calls/SKILL.md +1 -1
  144. package/skills/service-oriented-architecture/SKILL.md +1 -1
  145. package/skills/subscriptions/SKILL.md +1 -1
  146. package/skills/trpc-router/SKILL.md +1 -1
  147. package/skills/validators/SKILL.md +1 -1
  148. package/src/@trpc/server/index.ts +2 -2
  149. package/src/adapters/aws-lambda/index.ts +23 -0
  150. package/src/adapters/express.ts +10 -0
  151. package/src/adapters/fastify/fastifyRequestHandler.ts +5 -0
  152. package/src/adapters/fastify/fastifyTRPCPlugin.ts +30 -1
  153. package/src/adapters/fetch/fetchRequestHandler.ts +11 -0
  154. package/src/adapters/fetch/types.ts +14 -0
  155. package/src/adapters/next-app-dir/nextAppDirCaller.ts +8 -4
  156. package/src/adapters/next-app-dir/notFound.ts +3 -1
  157. package/src/adapters/next-app-dir/redirect.ts +6 -4
  158. package/src/adapters/next-app-dir/rethrowNextErrors.ts +5 -1
  159. package/src/adapters/next.ts +13 -1
  160. package/src/adapters/node-http/incomingMessageToRequest.ts +6 -1
  161. package/src/adapters/node-http/nodeHTTPRequestHandler.ts +3 -1
  162. package/src/adapters/node-http/types.ts +30 -25
  163. package/src/adapters/standalone.ts +30 -4
  164. package/src/adapters/ws.ts +42 -8
  165. package/src/adapters/wsEncoder.ts +5 -6
  166. package/src/observable/behaviorSubject.ts +6 -2
  167. package/src/observable/observable.ts +31 -5
  168. package/src/observable/operators.ts +12 -0
  169. package/src/observable/types.ts +18 -0
  170. package/src/unstable-core-do-not-import/clientish/inference.ts +22 -1
  171. package/src/unstable-core-do-not-import/clientish/inferrable.ts +5 -2
  172. package/src/unstable-core-do-not-import/createProxy.ts +4 -4
  173. package/src/unstable-core-do-not-import/error/TRPCError.ts +19 -0
  174. package/src/unstable-core-do-not-import/error/formatter.ts +15 -2
  175. package/src/unstable-core-do-not-import/error/getErrorShape.ts +2 -0
  176. package/src/unstable-core-do-not-import/http/contentTypeParsers.ts +15 -2
  177. package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +9 -0
  178. package/src/unstable-core-do-not-import/http/parseConnectionParams.ts +8 -0
  179. package/src/unstable-core-do-not-import/http/resolveResponse.ts +4 -0
  180. package/src/unstable-core-do-not-import/http/types.ts +55 -27
  181. package/src/unstable-core-do-not-import/initTRPC.ts +51 -27
  182. package/src/unstable-core-do-not-import/middleware.ts +25 -5
  183. package/src/unstable-core-do-not-import/procedure.ts +28 -2
  184. package/src/unstable-core-do-not-import/procedureBuilder.ts +56 -35
  185. package/src/unstable-core-do-not-import/rootConfig.ts +28 -19
  186. package/src/unstable-core-do-not-import/router.ts +71 -11
  187. package/src/unstable-core-do-not-import/rpc/codes.ts +13 -5
  188. package/src/unstable-core-do-not-import/rpc/envelopes.ts +45 -9
  189. package/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts +5 -1
  190. package/src/unstable-core-do-not-import/stream/tracked.ts +17 -5
  191. package/src/unstable-core-do-not-import/transformer.ts +12 -1
  192. package/src/unstable-core-do-not-import/types.ts +2 -0
  193. package/src/unstable-core-do-not-import/utils.ts +4 -1
  194. package/dist/asyncGeneratorDelegate-FcEJT04i.mjs.map +0 -1
  195. package/dist/codes-C9N0z0an.mjs.map +0 -1
  196. package/dist/contentTypeParsers-Bb-9hUEf.mjs +0 -14
  197. package/dist/contentTypeParsers-Bb-9hUEf.mjs.map +0 -1
  198. package/dist/getErrorShape-zlj81BiC.mjs.map +0 -1
  199. package/dist/index-BI3Qi_F-.d.cts.map +0 -1
  200. package/dist/index-BI3Qi_F-.d.mts.map +0 -1
  201. package/dist/index-CtkOmZzm.d.mts.map +0 -1
  202. package/dist/index-Tpw5OCTF.d.cts.map +0 -1
  203. package/dist/initTRPC-RMeQIy9H.mjs.map +0 -1
  204. package/dist/node-http-ChhZEv1k.mjs.map +0 -1
  205. package/dist/observable-CkXWrCsV.mjs.map +0 -1
  206. package/dist/observable-yEyhfXUI.mjs.map +0 -1
  207. package/dist/parseTRPCMessage-CJ4DJVBp.mjs.map +0 -1
  208. package/dist/resolveResponse-DksrxZ2k.mjs.map +0 -1
  209. package/dist/unstable-core-do-not-import-B8epiErP.d.cts.map +0 -1
  210. package/dist/unstable-core-do-not-import-Dbo98mkh.d.mts.map +0 -1
  211. package/dist/ws-BYfo-HED.mjs.map +0 -1
  212. package/dist/ws-DD1ukLuC.d.cts +0 -61
  213. package/dist/ws-DD1ukLuC.d.cts.map +0 -1
  214. package/dist/ws-DT37N43e.d.mts +0 -61
  215. package/dist/ws-DT37N43e.d.mts.map +0 -1
@@ -1,4 +1,4 @@
1
- import { l as inferObservableValue, m as Observable } from "./index-BI3Qi_F-.mjs";
1
+ import { l as inferObservableValue, m as Observable } from "./index-BGYvuCEh.mjs";
2
2
  //#region src/unstable-core-do-not-import/types.d.ts
3
3
  /**
4
4
  * ================================
@@ -15,10 +15,12 @@ type Maybe<TType> = TType | null | undefined;
15
15
  */
16
16
  type Simplify<TType> = TType extends any[] | Date ? TType : { [K in keyof TType]: TType[K]; };
17
17
  /**
18
+ * An object with string keys whose values may be `undefined`.
18
19
  * @public
19
20
  */
20
21
  type Dict<TType> = Record<string, TType | undefined>;
21
22
  /**
23
+ * A value, or a promise of one.
22
24
  * @public
23
25
  */
24
26
  type MaybePromise<TType> = Promise<TType> | TType;
@@ -114,10 +116,10 @@ type inferAsyncIterableYield<T> = T extends AsyncIterable<infer U> ? U : T;
114
116
  //#endregion
115
117
  //#region src/unstable-core-do-not-import/rpc/codes.d.ts
116
118
  /**
117
- * JSON-RPC 2.0 Error codes
118
- *
119
- * `-32000` to `-32099` are reserved for implementation-defined server-errors.
120
- * For tRPC we're copying the last digits of HTTP 4XX errors.
119
+ * The JSON-RPC 2.0 error code of each tRPC error code. tRPC's own codes
120
+ * use the range JSON-RPC leaves for servers, `-32000` to `-32099`, ending
121
+ * in the digits of the matching HTTP status.
122
+ * @see https://trpc.io/docs/rpc#error-codes---json-rpc-20-error-codes
121
123
  */
122
124
  declare const TRPC_ERROR_CODES_BY_KEY: {
123
125
  /**
@@ -149,8 +151,17 @@ declare const TRPC_ERROR_CODES_BY_KEY: {
149
151
  readonly TOO_MANY_REQUESTS: -32029;
150
152
  readonly CLIENT_CLOSED_REQUEST: -32099;
151
153
  };
154
+ /**
155
+ * The tRPC error code of each JSON-RPC 2.0 error code.
156
+ * @see https://trpc.io/docs/rpc#error-codes---json-rpc-20-error-codes
157
+ */
152
158
  declare const TRPC_ERROR_CODES_BY_NUMBER: InvertKeyValue<typeof TRPC_ERROR_CODES_BY_KEY>;
159
+ /** A JSON-RPC 2.0 error code tRPC sends, such as `-32004`. */
153
160
  type TRPC_ERROR_CODE_NUMBER = ValueOf<typeof TRPC_ERROR_CODES_BY_KEY>;
161
+ /**
162
+ * A tRPC error code, such as `'NOT_FOUND'`.
163
+ * @see https://trpc.io/docs/server/error-handling#error-codes
164
+ */
154
165
  type TRPC_ERROR_CODE_KEY = keyof typeof TRPC_ERROR_CODES_BY_KEY;
155
166
  /**
156
167
  * tRPC error codes that are considered retryable
@@ -160,13 +171,32 @@ declare const retryableRpcCodes: TRPC_ERROR_CODE_NUMBER[];
160
171
  //#endregion
161
172
  //#region src/unstable-core-do-not-import/error/TRPCError.d.ts
162
173
  declare function getCauseFromUnknown(cause: unknown): Error | undefined;
174
+ /**
175
+ * Turns anything thrown into a `TRPCError`. A `TRPCError` is returned as
176
+ * is; anything else becomes an `INTERNAL_SERVER_ERROR` with it as the
177
+ * cause.
178
+ */
163
179
  declare function getTRPCErrorFromUnknown(cause: unknown): TRPCError;
180
+ /**
181
+ * An error with a tRPC error code, which sets the HTTP status and the code
182
+ * the client sees. Throw it from resolvers and middlewares.
183
+ * @example
184
+ * ```ts
185
+ * throw new TRPCError({ code: 'NOT_FOUND', message: 'No such post' });
186
+ * ```
187
+ * @see https://trpc.io/docs/server/error-handling#throwing-errors
188
+ */
164
189
  declare class TRPCError extends Error {
190
+ /** The error this one wraps, if any. */
165
191
  readonly cause?: Error;
192
+ /** The tRPC error code, such as `'NOT_FOUND'`. */
166
193
  readonly code: "BAD_GATEWAY" | "BAD_REQUEST" | "CLIENT_CLOSED_REQUEST" | "CONFLICT" | "FORBIDDEN" | "GATEWAY_TIMEOUT" | "INTERNAL_SERVER_ERROR" | "METHOD_NOT_SUPPORTED" | "NOT_FOUND" | "NOT_IMPLEMENTED" | "PARSE_ERROR" | "PAYLOAD_TOO_LARGE" | "PAYMENT_REQUIRED" | "PRECONDITION_FAILED" | "PRECONDITION_REQUIRED" | "SERVICE_UNAVAILABLE" | "TIMEOUT" | "TOO_MANY_REQUESTS" | "UNAUTHORIZED" | "UNPROCESSABLE_CONTENT" | "UNSUPPORTED_MEDIA_TYPE";
167
194
  constructor(opts: {
195
+ /** Defaults to the cause's message, or else the code. */
168
196
  message?: string;
197
+ /** @see https://trpc.io/docs/server/error-handling#error-codes */
169
198
  code: TRPC_ERROR_CODE_KEY;
199
+ /** The original error. Anything that isn't an `Error` is wrapped in one. */
170
200
  cause?: unknown;
171
201
  });
172
202
  }
@@ -375,30 +405,42 @@ declare const trackedSymbol: unique symbol;
375
405
  type TrackedId = string & {
376
406
  __brand: 'TrackedId';
377
407
  };
408
+ /** An event wrapped by `tracked()`, with its id. */
378
409
  type TrackedEnvelope<TData> = [TrackedId, TData, typeof trackedSymbol];
410
+ /** A tracked event as the client gets it. */
379
411
  interface TrackedData<TData> {
380
412
  /**
381
- * The id of the message to keep track of in case the connection gets lost
413
+ * The event's id, which the client sends back as `lastEventId` when it
414
+ * reconnects.
382
415
  */
383
416
  id: string;
384
417
  /**
385
- * The data field of the message
418
+ * The event's data.
386
419
  */
387
420
  data: TData;
388
421
  }
389
422
  /**
390
- * Produce a typed server-sent event message
391
- * @deprecated use `tracked(id, data)` instead
423
+ * Wraps an event with an id, so a client can resume from it.
424
+ * @deprecated Use `tracked(id, data)` instead.
392
425
  */
393
426
  declare function sse<TData>(event: {
394
427
  id: string;
395
428
  data: TData;
396
429
  }): TrackedEnvelope<TData>;
430
+ /** Whether a value was made by `tracked()`. */
397
431
  declare function isTrackedEnvelope<TData>(value: unknown): value is TrackedEnvelope<TData>;
398
432
  /**
399
- * Automatically track an event so that it can be resumed from a given id if the connection is lost
433
+ * Gives a subscription event an id. When the connection drops, the client
434
+ * reconnects with the last id it got, as `input.lastEventId`, so the
435
+ * subscription can resume from there. The id can't be empty.
436
+ * @example
437
+ * ```ts
438
+ * yield tracked(post.id, post);
439
+ * ```
440
+ * @see https://trpc.io/docs/server/subscriptions#tracked
400
441
  */
401
442
  declare function tracked<TData>(id: string, data: TData): TrackedEnvelope<TData>;
443
+ /** The type a client gets for an event, unwrapping `tracked()` events. */
402
444
  type inferTrackedOutput<TData> = TData extends TrackedEnvelope<infer $Data> ? TrackedData<$Data> : TData;
403
445
  //#endregion
404
446
  //#region src/unstable-core-do-not-import/stream/sse.d.ts
@@ -547,7 +589,8 @@ declare const isServerDefault: boolean;
547
589
  */
548
590
  declare function isDevDefault(): boolean;
549
591
  /**
550
- * The tRPC root config
592
+ * The config of a tRPC root object, with the defaults filled in.
593
+ * @see https://trpc.io/docs/server/routers#runtime-configuration
551
594
  * @internal
552
595
  */
553
596
  interface RootConfig<TTypes extends RootTypes> {
@@ -557,56 +600,63 @@ interface RootConfig<TTypes extends RootTypes> {
557
600
  */
558
601
  $types: TTypes;
559
602
  /**
560
- * Use a data transformer
561
- * @see https://trpc.io/docs/v11/data-transformers
603
+ * Serializes inputs and outputs, so they can carry types JSON can't.
604
+ * @see https://trpc.io/docs/server/data-transformers
562
605
  */
563
606
  transformer: CombinedDataTransformer;
564
607
  /**
565
- * Use custom error formatting
566
- * @see https://trpc.io/docs/v11/error-formatting
608
+ * Shapes the errors sent to the client.
609
+ * @see https://trpc.io/docs/server/error-formatting
567
610
  */
568
611
  errorFormatter: ErrorFormatter<TTypes['ctx'], TTypes['errorShape']>;
569
612
  /**
570
- * Allow `@trpc/server` to run in non-server environments
571
- * @warning **Use with caution**, this should likely mainly be used within testing.
613
+ * Lets `@trpc/server` run outside a server, such as in a browser. Meant
614
+ * for tests.
572
615
  * @default false
573
616
  */
574
617
  allowOutsideOfServer: boolean;
575
618
  /**
576
- * Is this a server environment?
577
- * @warning **Use with caution**, this should likely mainly be used within testing.
619
+ * Whether this is a server. Meant for tests.
578
620
  * @default typeof window === 'undefined' || 'Deno' in window || process.env.NODE_ENV === 'test'
579
621
  */
580
622
  isServer: boolean;
581
623
  /**
582
- * Is this development?
583
- * Will be used to decide if the API should return stack traces
624
+ * Whether this is development. Errors include stack traces when it is.
584
625
  * @default process.env.NODE_ENV !== 'production'
585
626
  */
586
627
  isDev: boolean;
628
+ /**
629
+ * The metadata every procedure starts with.
630
+ * @see https://trpc.io/docs/server/metadata#default-meta-chaining-and-shallow-merging
631
+ */
587
632
  defaultMeta?: TTypes['meta'] extends object ? TTypes['meta'] : never;
588
633
  /**
589
- * Options for server-sent events (SSE) subscriptions
590
- * @see https://trpc.io/docs/client/links/httpSubscriptionLink
634
+ * Options for subscriptions over server-sent events (SSE).
635
+ * @see https://trpc.io/docs/client/links/httpSubscriptionLink#sse-options-on-the-server
591
636
  */
592
637
  sse?: {
593
638
  /**
594
- * Enable server-sent events (SSE) subscriptions
639
+ * Whether subscriptions can be served over SSE.
595
640
  * @default true
596
641
  */
597
642
  enabled?: boolean;
598
643
  } & Pick<SSEStreamProducerOptions, 'ping' | 'emitAndEndImmediately' | 'maxDurationMs' | 'client'>;
599
644
  /**
600
- * Options for batch stream
601
- * @see https://trpc.io/docs/client/links/httpBatchStreamLink
645
+ * Options for streamed batch responses, which `httpBatchStreamLink`
646
+ * reads.
647
+ * @see https://trpc.io/docs/client/links/httpBatchStreamLink#configure-jsonl-streaming-options
602
648
  */
603
649
  jsonl?: JSONLConfig;
650
+ /** Experimental options. None right now. */
604
651
  experimental?: {};
605
652
  }
606
653
  /**
654
+ * The root types: context, metadata, error shape and whether there's a
655
+ * transformer.
607
656
  * @internal
608
657
  */
609
658
  type CreateRootTypes<TGenerics extends RootTypes> = TGenerics;
659
+ /** Any root types, for use in generic constraints. */
610
660
  type AnyRootTypes = CreateRootTypes<{
611
661
  ctx: any;
612
662
  meta: any;
@@ -615,42 +665,52 @@ type AnyRootTypes = CreateRootTypes<{
615
665
  }>;
616
666
  type PartialIf<TCondition extends boolean, TType> = TCondition extends true ? Partial<TType> : TType;
617
667
  /**
618
- * Adds a `createContext` option with a given callback function
619
- * If context is the default value, then the `createContext` option is optional
668
+ * Adds a `createContext` option to an adapter's options. It's optional
669
+ * when the context is an empty object.
620
670
  */
621
671
  type CreateContextCallback<TContext, TFunction extends (...args: any[]) => any> = PartialIf<object extends TContext ? true : false, {
622
672
  /**
623
- * @see https://trpc.io/docs/v11/context
673
+ * Creates the context for each request.
674
+ * @see https://trpc.io/docs/server/context#creating-the-context
624
675
  **/
625
676
  createContext: TFunction;
626
677
  }>;
627
678
  //#endregion
628
679
  //#region src/unstable-core-do-not-import/router.d.ts
680
+ /**
681
+ * The procedures and sub-routers of a router, by name.
682
+ */
629
683
  interface RouterRecord {
630
684
  [key: string]: AnyProcedure | RouterRecord;
631
685
  }
632
686
  type DecorateProcedure<TProcedure extends AnyProcedure> = (input: inferProcedureInput<TProcedure>) => Promise<TProcedure['_def']['type'] extends 'subscription' ? TProcedure extends LegacyObservableSubscriptionProcedure<any> ? Observable<inferProcedureOutput<TProcedure>, TRPCError> : inferProcedureOutput<TProcedure> : inferProcedureOutput<TProcedure>>;
633
687
  /**
688
+ * A router's record with every procedure turned into a function, as a
689
+ * caller has it.
634
690
  * @internal
635
691
  */
636
692
  type DecorateRouterRecord<TRecord extends RouterRecord> = { [TKey in keyof TRecord]: TRecord[TKey] extends (infer $Value) ? $Value extends AnyProcedure ? DecorateProcedure<$Value> : $Value extends RouterRecord ? DecorateRouterRecord<$Value> : never : never; };
637
693
  /**
694
+ * Called when a procedure called through a caller throws.
638
695
  * @internal
639
696
  */
640
697
  type RouterCallerErrorHandler<TContext> = (opts: ErrorHandlerOptions<TContext>) => void;
641
698
  /**
699
+ * Creates a caller from a context, or from a function that returns one.
700
+ * A function is called on each procedure call, so cache it (for example
701
+ * with `React.cache`).
642
702
  * @internal
643
703
  */
644
- type RouterCaller<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = (
645
- /**
646
- * @note
647
- * If passing a function, we recommend it's a cached function
648
- * e.g. wrapped in `React.cache` to avoid unnecessary computations
649
- */
650
- ctx: TRoot['ctx'] | (() => MaybePromise<TRoot['ctx']>), options?: {
704
+ type RouterCaller<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = (ctx: TRoot['ctx'] | (() => MaybePromise<TRoot['ctx']>), options?: {
705
+ /** Called when a procedure throws, before the error is rethrown. */
651
706
  onError?: RouterCallerErrorHandler<TRoot['ctx']>;
707
+ /**
708
+ * Passed to middleware and resolvers as `signal`. It doesn't stop a
709
+ * call by itself; the resolver has to check it.
710
+ */
652
711
  signal?: AbortSignal;
653
712
  }) => DecorateRouterRecord<TRecord>;
713
+ /** A router that `lazy()` loads on its first call. */
654
714
  type Lazy<TAny> = (() => Promise<TAny>) & {};
655
715
  type LazyLoader<TAny> = {
656
716
  load: () => Promise<void>;
@@ -659,13 +719,22 @@ type LazyLoader<TAny> = {
659
719
  key: string;
660
720
  };
661
721
  /**
662
- * Lazy load a router
722
+ * Loads a router on its first call instead of at startup, which can make
723
+ * cold starts faster. Pass a function that imports the router, or a module
724
+ * whose only export is the router.
725
+ * @example
726
+ * ```ts
727
+ * const appRouter = router({
728
+ * slow: lazy(() => import('./slow.js').then((m) => m.slowRouter)),
729
+ * });
730
+ * ```
663
731
  * @see https://trpc.io/docs/server/merging-routers#lazy-load
664
732
  */
665
733
  declare function lazy<TRouter extends AnyRouter>(importRouter: () => Promise<TRouter | {
666
734
  [key: string]: TRouter;
667
735
  }>): Lazy<NoInfer<TRouter>>;
668
736
  /**
737
+ * A router's definition: its config and procedures.
669
738
  * @internal
670
739
  */
671
740
  interface RouterDef<TRoot extends AnyRootTypes, TRecord extends RouterRecord> {
@@ -676,27 +745,59 @@ interface RouterDef<TRoot extends AnyRootTypes, TRecord extends RouterRecord> {
676
745
  record: TRecord;
677
746
  lazy: Record<string, LazyLoader<AnyRouter>>;
678
747
  }
748
+ /**
749
+ * A router: procedures and sub-routers under one root config.
750
+ * @see https://trpc.io/docs/server/routers
751
+ */
679
752
  interface Router<TRoot extends AnyRootTypes, TRecord extends RouterRecord> {
680
753
  _def: RouterDef<TRoot, TRecord>;
681
754
  /**
682
- * @see https://trpc.io/docs/v11/server/server-side-calls
755
+ * Creates a caller, which calls the router's procedures directly on the
756
+ * server, from a context.
757
+ * @see https://trpc.io/docs/server/server-side-calls#routercreatecaller
683
758
  */
684
759
  createCaller: RouterCaller<TRoot, TRecord>;
685
760
  }
761
+ /**
762
+ * A router as `t.router()` returns it, with its procedures and sub-routers
763
+ * as properties.
764
+ */
686
765
  type BuiltRouter<TRoot extends AnyRootTypes, TRecord extends RouterRecord> = Router<TRoot, TRecord> & TRecord;
766
+ /**
767
+ * The type of `t.router()`.
768
+ * @see https://trpc.io/docs/server/routers
769
+ */
687
770
  interface RouterBuilder<TRoot extends AnyRootTypes> {
688
771
  <TIn extends CreateRouterOptions>(_: TIn): BuiltRouter<TRoot, DecorateCreateRouterOptions<TIn>>;
689
772
  }
773
+ /** Any router, for use in generic constraints. */
690
774
  type AnyRouter = Router<any, any>;
775
+ /** A router's root types: its context, metadata, error shape and transformer. */
691
776
  type inferRouterRootTypes<TRouter extends AnyRouter> = TRouter['_def']['_config']['$types'];
777
+ /** The type of a router's context. */
692
778
  type inferRouterContext<TRouter extends AnyRouter> = inferRouterRootTypes<TRouter>['ctx'];
779
+ /**
780
+ * The shape of a router's errors, as its error formatter returns them.
781
+ * @see https://trpc.io/docs/server/error-formatting
782
+ */
693
783
  type inferRouterError<TRouter extends AnyRouter> = inferRouterRootTypes<TRouter>['errorShape'];
784
+ /**
785
+ * The type of a router's metadata.
786
+ * @see https://trpc.io/docs/server/metadata
787
+ */
694
788
  type inferRouterMeta<TRouter extends AnyRouter> = inferRouterRootTypes<TRouter>['meta'];
695
- /** @internal */
789
+ /**
790
+ * What `t.router()` takes: procedures, routers, lazy routers and nested
791
+ * objects of them, by name.
792
+ * @internal
793
+ */
696
794
  type CreateRouterOptions = {
697
795
  [key: string]: AnyProcedure | AnyRouter | CreateRouterOptions | Lazy<AnyRouter>;
698
796
  };
699
- /** @internal */
797
+ /**
798
+ * The record of the router `t.router()` builds from its options.
799
+ * @internal
800
+ */
700
801
  type DecorateCreateRouterOptions<TRouterOptions extends CreateRouterOptions> = { [K in keyof TRouterOptions]: TRouterOptions[K] extends (infer $Value) ? $Value extends AnyProcedure ? $Value : $Value extends Router<any, infer TRecord> ? TRecord : $Value extends Lazy<Router<any, infer TRecord>> ? TRecord : $Value extends CreateRouterOptions ? DecorateCreateRouterOptions<$Value> : never : never; };
701
802
  /**
702
803
  * @internal
@@ -707,68 +808,92 @@ declare function createRouterFactory<TRoot extends AnyRootTypes>(config: RootCon
707
808
  */
708
809
  declare function getProcedureAtPath(router: Pick<Router<any, any>, '_def'>, path: string): Promise<AnyProcedure | null>;
709
810
  /**
811
+ * Calls the procedure at `path`, throwing `NOT_FOUND` if there's none of
812
+ * that type.
710
813
  * @internal
711
814
  */
712
815
  declare function callProcedure(opts: ProcedureCallOptions<unknown> & {
713
816
  router: AnyRouter;
714
817
  allowMethodOverride?: boolean;
715
818
  }): Promise<any>;
819
+ /**
820
+ * The type of `t.createCallerFactory()`: takes a router and returns its
821
+ * `createCaller`.
822
+ * @see https://trpc.io/docs/server/server-side-calls#create-caller
823
+ */
716
824
  interface RouterCallerFactory<TRoot extends AnyRootTypes> {
717
825
  <TRecord extends RouterRecord>(router: Pick<Router<TRoot, TRecord>, '_def'>): RouterCaller<TRoot, TRecord>;
718
826
  }
719
827
  declare function createCallerFactory<TRoot extends AnyRootTypes>(): RouterCallerFactory<TRoot>;
720
- /** @internal */
828
+ /**
829
+ * The router `t.mergeRouters()` returns.
830
+ * @internal
831
+ */
721
832
  type MergeRouters<TRouters extends AnyRouter[], TRoot extends AnyRootTypes = TRouters[0]['_def']['_config']['$types'], TRecord extends RouterRecord = {}> = TRouters extends [infer Head extends AnyRouter, ...infer Tail extends AnyRouter[]] ? MergeRouters<Tail, TRoot, Head['_def']['record'] & TRecord> : BuiltRouter<TRoot, TRecord>;
722
833
  declare function mergeRouters<TRouters extends AnyRouter[]>(...routerList: [...TRouters]): MergeRouters<TRouters>;
723
834
  //#endregion
724
835
  //#region src/unstable-core-do-not-import/http/types.d.ts
725
836
  /**
726
- * @deprecated use `Headers` instead, this will be removed in v12
837
+ * @deprecated Use `Headers` instead. This will be removed in v12.
727
838
  */
728
839
  type HTTPHeaders = Dict<string[] | string>;
840
+ /**
841
+ * The status and headers `responseMeta` sets on a response.
842
+ * @see https://trpc.io/docs/server/caching#using-responsemeta-to-cache-responses
843
+ */
729
844
  interface ResponseMeta {
845
+ /** The HTTP status. Defaults to the one tRPC picks from the results. */
730
846
  status?: number;
847
+ /** Headers to add to the response. */
731
848
  headers?: Headers | HTTPHeaders;
732
849
  }
733
850
  /**
851
+ * Sets a response's status and headers from the request and its results.
852
+ * @see https://trpc.io/docs/server/caching#using-responsemeta-to-cache-responses
734
853
  * @internal
735
854
  */
736
855
  type ResponseMetaFn<TRouter extends AnyRouter> = (opts: {
737
856
  data: TRPCResponse<unknown, inferRouterError<TRouter>>[];
738
857
  ctx?: inferRouterContext<TRouter>;
739
858
  /**
740
- * The different tRPC paths requested
741
- * @deprecated use `info` instead, this will be removed in v12
859
+ * The paths of the procedures called.
860
+ * @deprecated Use `info` instead. This will be removed in v12.
742
861
  **/
743
862
  paths: readonly string[] | undefined;
863
+ /** The request, if it could be parsed. */
744
864
  info: TRPCRequestInfo | undefined;
745
865
  type: ProcedureType | 'unknown';
866
+ /** The errors the calls threw. */
746
867
  errors: TRPCError[];
747
868
  /**
748
- * `true` if the `ResponseMeta` is being generated without knowing the response data (e.g. for streamed requests).
869
+ * `true` when it's called before the results are known, as for streamed
870
+ * responses.
749
871
  */
750
872
  eagerGeneration: boolean;
751
873
  }) => ResponseMeta;
752
874
  /**
753
- * Base interface for anything using HTTP
875
+ * The options every HTTP adapter takes.
754
876
  */
755
877
  interface HTTPBaseHandlerOptions<TRouter extends AnyRouter, TRequest> extends BaseHandlerOptions<TRouter, TRequest> {
756
878
  /**
757
- * Add handler to be called before response is sent to the user
758
- * Useful for setting cache headers
759
- * @see https://trpc.io/docs/v11/caching
879
+ * Sets the response's status and headers before it's sent, for example
880
+ * to cache it.
881
+ * @see https://trpc.io/docs/server/caching#using-responsemeta-to-cache-responses
760
882
  */
761
883
  responseMeta?: ResponseMetaFn<TRouter>;
762
884
  }
885
+ /** The `trpc-accept` header's value for a streamed response. */
763
886
  type TRPCAcceptHeader = 'application/jsonl';
887
+ /** One procedure call in a request. */
764
888
  interface TRPCRequestInfoProcedureCall {
765
889
  path: string;
766
890
  /**
767
- * Read the raw input (deduped and memoized)
891
+ * Reads the call's input as the client sent it. It's read once, however
892
+ * often it's called.
768
893
  */
769
894
  getRawInput: () => Promise<unknown>;
770
895
  /**
771
- * Get already parsed inputs - won't trigger reading the body or parsing the inputs
896
+ * The input if it was read already. Doesn't read the body.
772
897
  */
773
898
  result: () => unknown;
774
899
  /**
@@ -782,42 +907,45 @@ interface TRPCRequestInfoProcedureCall {
782
907
  batchIndex: number;
783
908
  }
784
909
  /**
785
- * Information about the incoming request
910
+ * What tRPC knows about a request, which `createContext` gets as `info`.
911
+ * @see https://trpc.io/docs/server/context#creating-the-context
786
912
  * @public
787
913
  */
788
914
  interface TRPCRequestInfo {
789
915
  /**
790
- * The `trpc-accept` header
916
+ * The `trpc-accept` header.
791
917
  */
792
918
  accept: TRPCAcceptHeader | null;
793
919
  /**
794
- * The type of the request
920
+ * The type of the procedures called.
795
921
  */
796
922
  type: ProcedureType | 'unknown';
797
923
  /**
798
- * If the content type handler has detected that this is a batch call
924
+ * Whether the request is a batch.
799
925
  */
800
926
  isBatchCall: boolean;
801
927
  /**
802
- * The calls being made
928
+ * The procedure calls in the request.
803
929
  */
804
930
  calls: TRPCRequestInfoProcedureCall[];
805
931
  /**
806
- * Connection params when using `httpSubscriptionLink` or `createWSClient`
932
+ * The connection params the client sent with `httpSubscriptionLink` or
933
+ * `createWSClient`.
807
934
  */
808
935
  connectionParams: Dict<string> | null;
809
936
  /**
810
- * Signal when the request is aborted
811
- * Can be used to abort async operations during the request, e.g. `fetch()`-requests
937
+ * Aborts when the request does. Pass it on to work the request starts,
938
+ * such as `fetch()` calls.
812
939
  */
813
940
  signal: AbortSignal;
814
941
  /**
815
- * The URL of the request if available
942
+ * The request's URL, if known.
816
943
  */
817
944
  url: URL | null;
818
945
  }
819
946
  /**
820
- * Inner createContext function for `resolveResponse` used to forward `TRPCRequestInfo` to `createContext`
947
+ * The `createContext` that `resolveResponse` takes: it gets the request's
948
+ * `info`.
821
949
  * @internal
822
950
  */
823
951
  type ResolveHTTPRequestOptionsContextFn<TRouter extends AnyRouter> = (opts: {
@@ -827,17 +955,24 @@ interface HTTPErrorHandlerOptions<TRouter extends AnyRouter, TRequest> extends E
827
955
  req: TRequest;
828
956
  }
829
957
  /**
958
+ * Called with each error a procedure throws. With streamed responses the
959
+ * response may have started already, so don't rely on setting headers.
960
+ * @see https://trpc.io/docs/server/error-handling#handling-errors
830
961
  * @internal
831
962
  */
832
963
  type HTTPErrorHandler<TRouter extends AnyRouter, TRequest> = (opts: HTTPErrorHandlerOptions<TRouter, TRequest>) => void;
833
964
  /**
834
- * Base interface for any response handler
965
+ * The options every adapter takes.
835
966
  * @internal
836
967
  */
837
968
  interface BaseHandlerOptions<TRouter extends AnyRouter, TRequest> {
969
+ /**
970
+ * Called with each error a procedure throws, for example to log it.
971
+ * @see https://trpc.io/docs/server/error-handling#handling-errors
972
+ */
838
973
  onError?: HTTPErrorHandler<TRouter, TRequest>;
839
974
  /**
840
- * @deprecated use `allowBatching` instead, this will be removed in v12
975
+ * @deprecated Use `allowBatching` instead. This will be removed in v12.
841
976
  */
842
977
  batching?: {
843
978
  /**
@@ -845,21 +980,25 @@ interface BaseHandlerOptions<TRouter extends AnyRouter, TRequest> {
845
980
  */
846
981
  enabled: boolean;
847
982
  };
983
+ /** The router to serve. */
848
984
  router: TRouter;
849
985
  /**
850
- * Allow method override - will skip the method check
986
+ * Lets clients call queries and subscriptions with POST as well as GET.
987
+ * Mutations always use POST.
988
+ * @see https://trpc.io/docs/rpc#overriding-the-default-http-method
851
989
  * @default false
852
990
  */
853
991
  allowMethodOverride?: boolean;
854
992
  /**
855
- * Allow request batching
993
+ * Whether clients can batch calls into one request.
994
+ * @see https://trpc.io/docs/client/links/httpBatchLink#disabling-request-batching
856
995
  * @default true
857
996
  */
858
997
  allowBatching?: boolean;
859
998
  /**
860
- * Restrict the maximum size of a batch call, invalid requests will be rejected with a 400 error
861
- *
862
- * @important Ensure you set the same or lower limit on your client batch link
999
+ * The most calls a batch can have. Larger batches get a 400 error. Set
1000
+ * the client's `maxItems` to the same or a lower number.
1001
+ * @see https://trpc.io/docs/client/links/httpBatchLink#limiting-batch-size
863
1002
  * @default unlimited
864
1003
  */
865
1004
  maxBatchSize?: number;
@@ -867,15 +1006,19 @@ interface BaseHandlerOptions<TRouter extends AnyRouter, TRequest> {
867
1006
  //#endregion
868
1007
  //#region src/unstable-core-do-not-import/rpc/envelopes.d.ts
869
1008
  /**
870
- * Error response
1009
+ * The error object of an error response: a JSON-RPC code, a message and
1010
+ * any `data` the error formatter adds.
1011
+ * @see https://trpc.io/docs/rpc#error-response
871
1012
  */
872
1013
  interface TRPCErrorShape<TData extends object = object> {
873
1014
  code: TRPC_ERROR_CODE_NUMBER;
874
1015
  message: string;
1016
+ /** Extra details, such as the tRPC code and HTTP status. */
875
1017
  data: TData;
876
1018
  }
877
1019
  /**
878
- * JSON-RPC 2.0 Specification
1020
+ * Types for the JSON-RPC 2.0 messages tRPC's envelopes build on.
1021
+ * @see https://www.jsonrpc.org/specification
879
1022
  */
880
1023
  declare namespace JSONRPC2 {
881
1024
  type RequestId = number | string | null;
@@ -899,6 +1042,7 @@ declare namespace JSONRPC2 {
899
1042
  error: TError;
900
1043
  }
901
1044
  }
1045
+ /** A call to a procedure. */
902
1046
  interface TRPCRequest extends JSONRPC2.Request<ProcedureType, {
903
1047
  path: string;
904
1048
  input: unknown;
@@ -907,6 +1051,7 @@ interface TRPCRequest extends JSONRPC2.Request<ProcedureType, {
907
1051
  */
908
1052
  lastEventId?: string;
909
1053
  }> {}
1054
+ /** The `result` of a successful response. */
910
1055
  interface TRPCResult<TData = unknown> {
911
1056
  data: TData;
912
1057
  type?: 'data';
@@ -915,28 +1060,51 @@ interface TRPCResult<TData = unknown> {
915
1060
  */
916
1061
  id?: string;
917
1062
  }
1063
+ /**
1064
+ * A successful response.
1065
+ * @see https://trpc.io/docs/rpc#successful-response
1066
+ */
918
1067
  interface TRPCSuccessResponse<TData> extends JSONRPC2.ResultResponse<TRPCResult<TData>> {}
1068
+ /**
1069
+ * An error response.
1070
+ * @see https://trpc.io/docs/rpc#error-response
1071
+ */
919
1072
  interface TRPCErrorResponse<TError extends TRPCErrorShape = TRPCErrorShape> extends JSONRPC2.ErrorResponse<TError> {}
1073
+ /**
1074
+ * A response to a call: a success or an error.
1075
+ * @see https://trpc.io/docs/rpc#http-response-specification
1076
+ */
920
1077
  type TRPCResponse<TData = unknown, TError extends TRPCErrorShape = TRPCErrorShape> = TRPCErrorResponse<TError> | TRPCSuccessResponse<TData>;
1078
+ /**
1079
+ * A call to a procedure over WebSockets, with the id its responses carry.
1080
+ * @see https://trpc.io/docs/server/websockets#websockets-rpc-specification
1081
+ */
921
1082
  type TRPCRequestMessage = TRPCRequest & {
922
1083
  id: JSONRPC2.RequestId;
923
1084
  };
924
1085
  /**
925
- * The client asked the server to unsubscribe
1086
+ * The client asks the server to stop a subscription.
1087
+ * @see https://trpc.io/docs/server/websockets#to-cancel-a-subscription-call-subscriptionstop
926
1088
  */
927
1089
  interface TRPCSubscriptionStopNotification extends JSONRPC2.BaseRequest<'subscription.stop'> {
928
1090
  id: null;
929
1091
  }
930
1092
  /**
931
- * The client's outgoing request types
1093
+ * The notifications a WebSocket client sends.
932
1094
  */
933
1095
  type TRPCClientOutgoingRequest = TRPCSubscriptionStopNotification;
934
1096
  /**
935
- * The client's sent messages shape
1097
+ * Any message a WebSocket client sends.
1098
+ * @see https://trpc.io/docs/server/websockets#websockets-rpc-specification
936
1099
  */
937
1100
  type TRPCClientOutgoingMessage = TRPCRequestMessage | (JSONRPC2.BaseRequest<'subscription.stop'> & {
938
1101
  id: JSONRPC2.RequestId;
939
1102
  });
1103
+ /**
1104
+ * A result sent over WebSockets: data, or a subscription's `started` or
1105
+ * `stopped` event.
1106
+ * @see https://trpc.io/docs/server/websockets#subscription-response-shape
1107
+ */
940
1108
  interface TRPCResultMessage<TData> extends JSONRPC2.ResultResponse<{
941
1109
  type: 'started';
942
1110
  data?: never;
@@ -944,25 +1112,32 @@ interface TRPCResultMessage<TData> extends JSONRPC2.ResultResponse<{
944
1112
  type: 'stopped';
945
1113
  data?: never;
946
1114
  } | TRPCResult<TData>> {}
1115
+ /**
1116
+ * A response sent over WebSockets, with the id of the call it answers.
1117
+ * @see https://trpc.io/docs/server/websockets#response
1118
+ */
947
1119
  type TRPCResponseMessage<TData = unknown, TError extends TRPCErrorShape = TRPCErrorShape> = {
948
1120
  id: JSONRPC2.RequestId;
949
1121
  } & (TRPCErrorResponse<TError> | TRPCResultMessage<TData>);
950
1122
  /**
951
- * The server asked the client to reconnect - useful when restarting/redeploying service
1123
+ * The server asks the client to reconnect, for example before a restart.
1124
+ * @see https://trpc.io/docs/server/websockets#notifications-from-server-to-client
952
1125
  */
953
1126
  interface TRPCReconnectNotification extends JSONRPC2.BaseRequest<'reconnect'> {
954
1127
  id: JSONRPC2.RequestId;
955
1128
  }
956
1129
  /**
957
- * The client's incoming request types
1130
+ * The notifications a WebSocket client receives.
958
1131
  */
959
1132
  type TRPCClientIncomingRequest = TRPCReconnectNotification;
960
1133
  /**
961
- * The client's received messages shape
1134
+ * Any message a WebSocket client receives.
1135
+ * @see https://trpc.io/docs/server/websockets#websockets-rpc-specification
962
1136
  */
963
1137
  type TRPCClientIncomingMessage<TResult = unknown, TError extends TRPCErrorShape = TRPCErrorShape> = TRPCClientIncomingRequest | TRPCResponseMessage<TResult, TError>;
964
1138
  /**
965
- * The client sends connection params - always sent as the first message
1139
+ * The connection params a WebSocket client sends as its first message.
1140
+ * @see https://trpc.io/docs/server/websockets#connection-params
966
1141
  */
967
1142
  interface TRPCConnectionParamsMessage extends JSONRPC2.BaseRequest<'connectionParams'> {
968
1143
  data: TRPCRequestInfo['connectionParams'];
@@ -970,6 +1145,9 @@ interface TRPCConnectionParamsMessage extends JSONRPC2.BaseRequest<'connectionPa
970
1145
  //#endregion
971
1146
  //#region src/unstable-core-do-not-import/transformer.d.ts
972
1147
  /**
1148
+ * A transformer that serializes and deserializes data the same way in
1149
+ * both directions, such as `superjson`.
1150
+ * @see https://trpc.io/docs/server/data-transformers#datatransformer-interface
973
1151
  * @public
974
1152
  */
975
1153
  interface DataTransformer {
@@ -997,6 +1175,8 @@ interface OutputDataTransformer extends DataTransformer {
997
1175
  deserialize(object: any): any;
998
1176
  }
999
1177
  /**
1178
+ * A transformer with one serializer for inputs and another for outputs.
1179
+ * @see https://trpc.io/docs/server/data-transformers#different-transformers-for-upload-and-download
1000
1180
  * @public
1001
1181
  */
1002
1182
  interface CombinedDataTransformer {
@@ -1010,6 +1190,8 @@ interface CombinedDataTransformer {
1010
1190
  output: OutputDataTransformer;
1011
1191
  }
1012
1192
  /**
1193
+ * The half of a combined transformer the client uses: serializing inputs
1194
+ * and deserializing outputs.
1013
1195
  * @public
1014
1196
  */
1015
1197
  type CombinedDataTransformerClient = {
@@ -1017,6 +1199,9 @@ type CombinedDataTransformerClient = {
1017
1199
  output: Pick<CombinedDataTransformer['output'], 'deserialize'>;
1018
1200
  };
1019
1201
  /**
1202
+ * A transformer: one for both directions, or separate ones for inputs and
1203
+ * outputs.
1204
+ * @see https://trpc.io/docs/server/data-transformers
1020
1205
  * @public
1021
1206
  */
1022
1207
  type DataTransformerOptions = CombinedDataTransformer | DataTransformer;
@@ -1029,7 +1214,8 @@ declare function getDataTransformer(transformer: DataTransformerOptions): Combin
1029
1214
  */
1030
1215
  declare const defaultTransformer: CombinedDataTransformer;
1031
1216
  /**
1032
- * Takes a unserialized `TRPCResponse` and serializes it with the router's transformers
1217
+ * Serializes a response, or a list of them, with the router's output
1218
+ * transformer. Meant for custom adapters.
1033
1219
  **/
1034
1220
  declare function transformTRPCResponse<TResponse extends TRPCResponse | TRPCResponse[] | TRPCResponseMessage | TRPCResponseMessage[]>(config: RootConfig<AnyRootTypes>, itemOrItems: TResponse): (TRPCResponse | TRPCResponseMessage)[] | TRPCErrorResponse<TRPCErrorShape<object>> | TRPCSuccessResponse<unknown> | ({
1035
1221
  id: JSONRPC2.RequestId;
@@ -1065,26 +1251,40 @@ declare function transformResultInner<TRouter extends AnyRouter, TOutput>(respon
1065
1251
  declare function transformResult<TRouter extends AnyRouter, TOutput>(response: TRPCResponse<TOutput, inferRouterError<TRouter>> | TRPCResponseMessage<TOutput, inferRouterError<TRouter>>, transformer: DataTransformer): ReturnType<typeof transformResultInner>;
1066
1252
  //#endregion
1067
1253
  //#region src/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts
1068
- /** @public */
1254
+ /**
1255
+ * Checks that a message a WebSocket client sent is a valid tRPC message,
1256
+ * and deserializes its input. Throws if it isn't.
1257
+ * @public
1258
+ */
1069
1259
  declare function parseTRPCMessage(obj: unknown, transformer: CombinedDataTransformer): TRPCClientOutgoingMessage;
1070
1260
  //#endregion
1071
1261
  //#region src/unstable-core-do-not-import/error/formatter.d.ts
1072
1262
  /**
1263
+ * What an error formatter gets.
1264
+ * @see https://trpc.io/docs/server/error-formatting#all-properties-sent-to-errorformatter
1073
1265
  * @internal
1074
1266
  */
1075
1267
  interface ErrorFormatterOptions<TContext> {
1076
1268
  error: TRPCError;
1077
1269
  type: ProcedureType | 'unknown';
1270
+ /** The procedure's path, if the error came from one. */
1078
1271
  path: string | undefined;
1079
1272
  input: unknown;
1273
+ /** The context, if it was created before the error. */
1080
1274
  ctx: TContext;
1275
+ /** The shape tRPC sends by default, to extend or replace. */
1081
1276
  shape: DefaultErrorShape;
1082
1277
  }
1083
1278
  /**
1279
+ * Shapes the errors a router sends to the client.
1280
+ * @see https://trpc.io/docs/server/error-formatting
1084
1281
  * @internal
1085
1282
  */
1086
1283
  type ErrorFormatter<TContext, TShape extends TRPCErrorShape> = (opts: ErrorFormatterOptions<TContext | undefined>) => TShape;
1087
1284
  /**
1285
+ * An error formatter for one procedure, as `.errors()` takes it. Return
1286
+ * `undefined` to leave the error to the next formatter.
1287
+ * @see https://trpc.io/docs/server/error-formatting#per-procedure-error-formatting
1088
1288
  * @internal
1089
1289
  */
1090
1290
  type ProcedureErrorFormatter<TContext, TContextOverrides, TShape extends TRPCErrorShape | undefined | void> = (opts: ErrorFormatterOptions<Simplify<Overwrite<TContext, TContextOverrides>>>) => TShape;
@@ -1093,21 +1293,24 @@ type ProcedureErrorFormatter<TContext, TContextOverrides, TShape extends TRPCErr
1093
1293
  */
1094
1294
  type AnyProcedureErrorFormatter = ProcedureErrorFormatter<any, any, any>;
1095
1295
  /**
1296
+ * The `data` of the default error shape.
1096
1297
  * @internal
1097
1298
  */
1098
1299
  type DefaultErrorData = {
1099
1300
  code: TRPC_ERROR_CODE_KEY;
1100
1301
  httpStatus: number;
1101
1302
  /**
1102
- * Path to the procedure that threw the error
1303
+ * The path of the procedure that threw.
1103
1304
  */
1104
1305
  path?: string;
1105
1306
  /**
1106
- * Stack trace of the error (only in development)
1307
+ * The error's stack trace, only when `isDev` is set.
1107
1308
  */
1108
1309
  stack?: string;
1109
1310
  };
1110
1311
  /**
1312
+ * The error shape tRPC sends when there's no error formatter.
1313
+ * @see https://trpc.io/docs/server/error-formatting
1111
1314
  * @internal
1112
1315
  */
1113
1316
  interface DefaultErrorShape extends TRPCErrorShape<DefaultErrorData> {
@@ -1160,38 +1363,55 @@ interface MiddlewareErrorResult<_TContextOverride> extends MiddlewareResultBase
1160
1363
  error: TRPCError;
1161
1364
  }
1162
1365
  /**
1366
+ * What a middleware's `next()` returns, and what the middleware must
1367
+ * return in turn.
1163
1368
  * @internal
1164
1369
  */
1165
1370
  type MiddlewareResult<_TContextOverride> = MiddlewareErrorResult<_TContextOverride> | MiddlewareOKResult<_TContextOverride>;
1166
1371
  /**
1372
+ * A reusable middleware, as `t.middleware()` returns it.
1373
+ * @see https://trpc.io/docs/server/middlewares
1167
1374
  * @internal
1168
1375
  */
1169
1376
  interface MiddlewareBuilder<TContext, TMeta, TContextOverrides, TInputOut> {
1170
1377
  /**
1171
- * Create a new builder based on the current middleware builder
1378
+ * Returns a new middleware that runs this one, then `fn`, which sees the
1379
+ * context this one set.
1380
+ * @see https://trpc.io/docs/server/middlewares#extending-middlewares
1172
1381
  */
1173
1382
  unstable_pipe<$ContextOverridesOut>(fn: MiddlewareFunction<TContext, TMeta, TContextOverrides, $ContextOverridesOut, TInputOut> | MiddlewareBuilder<Overwrite<TContext, TContextOverrides>, TMeta, $ContextOverridesOut, TInputOut>): MiddlewareBuilder<TContext, TMeta, Overwrite<TContextOverrides, $ContextOverridesOut>, TInputOut>;
1174
1383
  /**
1175
- * List of middlewares within this middleware builder
1384
+ * The middlewares this builder runs, in order.
1176
1385
  */
1177
1386
  _middlewares: MiddlewareFunction<TContext, TMeta, TContextOverrides, object, TInputOut>[];
1178
1387
  }
1179
1388
  /**
1389
+ * A middleware: it gets the call's options and must return the result of
1390
+ * calling `next()`, optionally with a new `ctx` or `input`.
1391
+ * @see https://trpc.io/docs/server/middlewares
1180
1392
  * @internal
1181
1393
  */
1182
1394
  type MiddlewareFunction<TContext, TMeta, TContextOverridesIn, $ContextOverridesOut, TInputOut> = {
1183
1395
  (opts: {
1184
1396
  ctx: Simplify<Overwrite<TContext, TContextOverridesIn>>;
1185
1397
  type: ProcedureType;
1398
+ /** The procedure's path, such as `post.byId`. */
1186
1399
  path: string;
1400
+ /** The input, as the validators that ran before this middleware left it. */
1187
1401
  input: TInputOut;
1402
+ /** Reads the input as the client sent it, before any validator ran. */
1188
1403
  getRawInput: GetRawInputFn;
1189
1404
  meta: TMeta | undefined;
1405
+ /** Aborts when the client cancels the request or disconnects. */
1190
1406
  signal: AbortSignal | undefined;
1191
1407
  /**
1192
1408
  * The index of this call in a batch request.
1193
1409
  */
1194
1410
  batchIndex: number;
1411
+ /**
1412
+ * Runs the next middleware, or the resolver. Pass `ctx` to add to the
1413
+ * context, or `input` to replace the input.
1414
+ */
1195
1415
  next: {
1196
1416
  (): Promise<MiddlewareResult<TContextOverridesIn>>;
1197
1417
  <$ContextOverride>(opts: {
@@ -1205,16 +1425,19 @@ type MiddlewareFunction<TContext, TMeta, TContextOverridesIn, $ContextOverridesO
1205
1425
  }): Promise<MiddlewareResult<$ContextOverridesOut>>;
1206
1426
  _type?: string | undefined;
1207
1427
  };
1428
+ /** Any middleware function, for use in generic constraints. */
1208
1429
  type AnyMiddlewareFunction = MiddlewareFunction<any, any, any, any, any>;
1430
+ /** Any middleware builder, for use in generic constraints. */
1209
1431
  type AnyMiddlewareBuilder = MiddlewareBuilder<any, any, any, any>;
1210
1432
  /**
1211
1433
  * @internal
1212
1434
  */
1213
1435
  declare function createMiddlewareFactory<TContext, TMeta, TInputOut = unknown>(): <$ContextOverrides>(fn: MiddlewareFunction<TContext, TMeta, object, $ContextOverrides, TInputOut>) => MiddlewareBuilder<TContext, TMeta, $ContextOverrides, TInputOut>;
1214
1436
  /**
1215
- * Create a standalone middleware
1216
- * @see https://trpc.io/docs/v11/server/middlewares#experimental-standalone-middlewares
1217
- * @deprecated use `.concat()` instead
1437
+ * Creates a middleware that isn't tied to a root object, for the context,
1438
+ * metadata and input types you give it.
1439
+ * @deprecated Use `.concat()` with a procedure builder instead.
1440
+ * @see https://trpc.io/docs/server/middlewares#concat
1218
1441
  */
1219
1442
  declare const experimental_standaloneMiddleware: <TCtx extends {
1220
1443
  ctx?: object;
@@ -1250,7 +1473,10 @@ declare function createErrorFormatterMiddleware(formatter: AnyProcedureErrorForm
1250
1473
  declare function createOutputMiddleware<TOutput>(parse: ParseFn<TOutput>): AnyMiddlewareFunction;
1251
1474
  //#endregion
1252
1475
  //#region src/unstable-core-do-not-import/utils.d.ts
1253
- /** @internal */
1476
+ /**
1477
+ * Marks a type a procedure builder hasn't set yet, such as its input.
1478
+ * @internal
1479
+ */
1254
1480
  type UnsetMarker = 'unsetMarker' & {
1255
1481
  __brand: 'unsetMarker';
1256
1482
  };
@@ -1333,23 +1559,29 @@ type ProcedureBuilderDef<TMeta> = {
1333
1559
  };
1334
1560
  type AnyProcedureBuilderDef = ProcedureBuilderDef<any>;
1335
1561
  /**
1336
- * Procedure resolver options (what the `.query()`, `.mutation()`, and `.subscription()` functions receive)
1562
+ * What a resolver passed to `.query()`, `.mutation()` or `.subscription()`
1563
+ * gets.
1337
1564
  * @internal
1338
1565
  */
1339
1566
  interface ProcedureResolverOptions<TContext, _TMeta, TContextOverridesIn, TInputOut> {
1567
+ /** The context, after middlewares have added to or changed it. */
1340
1568
  ctx: Simplify<Overwrite<TContext, TContextOverridesIn>>;
1569
+ /**
1570
+ * The input, after the validators and any middleware that replaced it
1571
+ * with `next({ input })`.
1572
+ */
1341
1573
  input: TInputOut extends UnsetMarker ? undefined : TInputOut;
1342
1574
  /**
1343
- * The AbortSignal of the request
1575
+ * Aborts when the client cancels the request or disconnects.
1344
1576
  */
1345
1577
  signal: AbortSignal | undefined;
1346
1578
  /**
1347
- * The path of the procedure
1579
+ * The procedure's path, such as `post.byId`.
1348
1580
  */
1349
1581
  path: string;
1350
1582
  /**
1351
- * The index of this call in a batch request.
1352
- * Will be set when the procedure is called as part of a batch.
1583
+ * The call's zero-based index in its batch. A call that wasn't batched
1584
+ * gets `0`.
1353
1585
  */
1354
1586
  batchIndex?: number;
1355
1587
  }
@@ -1359,8 +1591,9 @@ interface ProcedureResolverOptions<TContext, _TMeta, TContextOverridesIn, TInput
1359
1591
  type ProcedureResolver<TContext, TMeta, TContextOverrides, TInputOut, TOutputParserIn, $Output> = (opts: ProcedureResolverOptions<TContext, TMeta, TContextOverrides, TInputOut>) => MaybePromise<DefaultValue<TOutputParserIn, $Output>>;
1360
1592
  type AnyProcedureBuilder = ProcedureBuilder<any, any, any, any, any, any, any, any, any>;
1361
1593
  /**
1362
- * Infer the context type from a procedure builder
1363
- * Useful to create common helper functions for different procedures
1594
+ * The options a resolver built from this procedure builder gets: its
1595
+ * `ctx`, `input` and so on. Use it to type helpers that resolvers call.
1596
+ * @see https://trpc.io/docs/server/procedures#inferProcedureBuilderResolverOptions
1364
1597
  */
1365
1598
  type inferProcedureBuilderResolverOptions<TProcedureBuilder extends AnyProcedureBuilder> = TProcedureBuilder extends ProcedureBuilder<infer TContext, infer TMeta, infer TContextOverrides, infer _TInputIn, infer TInputOut, infer _TOutputIn, infer _TOutputOut, infer _TCaller, infer _TErrorShape> ? ProcedureResolverOptions<TContext, TMeta, TContextOverrides, TInputOut extends UnsetMarker ? unknown : TInputOut extends object ? Simplify<TInputOut & {
1366
1599
  /**
@@ -1368,6 +1601,11 @@ type inferProcedureBuilderResolverOptions<TProcedureBuilder extends AnyProcedure
1368
1601
  */
1369
1602
  [keyAddedByInputCallFurtherDown: string]: unknown;
1370
1603
  }> : TInputOut> : never;
1604
+ /**
1605
+ * Builds a procedure step by step. Each method returns a new builder, so a
1606
+ * builder can be the base of many procedures.
1607
+ * @see https://trpc.io/docs/server/procedures
1608
+ */
1371
1609
  interface ProcedureBuilder<TContext, TMeta, TContextOverrides, TInputIn, TInputOut, TOutputIn, TOutputOut, TCaller extends boolean,
1372
1610
  /**
1373
1611
  * Defaults to `unknown` so that an annotation written without it falls back
@@ -1377,45 +1615,50 @@ interface ProcedureBuilder<TContext, TMeta, TContextOverrides, TInputIn, TInputO
1377
1615
  */
1378
1616
  TErrorShape = unknown> {
1379
1617
  /**
1380
- * Add an input parser to the procedure.
1381
- * @see https://trpc.io/docs/v11/server/validators
1618
+ * Adds a validator for the input. Chain several to merge object inputs.
1619
+ * @see https://trpc.io/docs/server/validators#input-validators
1382
1620
  */
1383
1621
  input<$Parser extends Parser>(schema: TInputOut extends UnsetMarker ? $Parser : inferParser<$Parser>['out'] extends Record<string, unknown> | undefined ? TInputOut extends Record<string, unknown> | undefined ? undefined extends inferParser<$Parser>['out'] ? undefined extends TInputOut ? $Parser : TypeError<'Cannot chain an optional parser to a required parser'> : $Parser : TypeError<'All input parsers did not resolve to an object'> : TypeError<'All input parsers did not resolve to an object'>): ProcedureBuilder<TContext, TMeta, TContextOverrides, IntersectIfDefined<TInputIn, inferParser<$Parser>['in']>, IntersectIfDefined<TInputOut, inferParser<$Parser>['out']>, TOutputIn, TOutputOut, TCaller, TErrorShape>;
1384
1622
  /**
1385
- * Add an output parser to the procedure.
1386
- * @see https://trpc.io/docs/v11/server/validators
1623
+ * Adds a validator for the output, which checks what the resolver
1624
+ * returns.
1625
+ * @see https://trpc.io/docs/server/validators#output-validators
1387
1626
  */
1388
1627
  output<$Parser extends Parser>(schema: $Parser): ProcedureBuilder<TContext, TMeta, TContextOverrides, TInputIn, TInputOut, IntersectIfDefined<TOutputIn, inferParser<$Parser>['in']>, IntersectIfDefined<TOutputOut, inferParser<$Parser>['out']>, TCaller, TErrorShape>;
1389
1628
  /**
1390
- * Add a meta data to the procedure.
1391
- * @see https://trpc.io/docs/v11/server/metadata
1629
+ * Sets the procedure's metadata, which middlewares can read. It's
1630
+ * shallow-merged with any metadata set before.
1631
+ * @see https://trpc.io/docs/server/metadata
1392
1632
  */
1393
1633
  meta(meta: TMeta): ProcedureBuilder<TContext, TMeta, TContextOverrides, TInputIn, TInputOut, TOutputIn, TOutputOut, TCaller, TErrorShape>;
1394
1634
  /**
1395
- * Add per procedure error formatters.
1396
- *
1397
- * An error will bubble until a `.errors()` handler returns a shape
1398
- * or it reaches the global errorFormatter
1399
- *
1400
- * @see https://trpc.io/docs/v11/server/error-formatting
1635
+ * Adds an error formatter for this procedure. An error goes to the last
1636
+ * `.errors()` formatter first, and on to earlier ones and the root
1637
+ * `errorFormatter` until one returns a shape. A formatter only sees
1638
+ * errors from the steps after it, so put `.errors()` before `.input()`
1639
+ * to format input errors.
1640
+ * @see https://trpc.io/docs/server/error-formatting#per-procedure-error-formatting
1401
1641
  */
1402
1642
  errors<$Shape extends TRPCErrorShape | undefined | void>(formatter: ProcedureErrorFormatter<TContext, TContextOverrides, $Shape>): ProcedureBuilder<TContext, TMeta, TContextOverrides, TInputIn, TInputOut, TOutputIn, TOutputOut, TCaller, FoldErrorShape<TErrorShape, $Shape>>;
1403
1643
  /**
1404
- * Add a middleware to the procedure.
1405
- * @see https://trpc.io/docs/v11/server/middlewares
1644
+ * Adds a middleware, which runs before the resolver and can change the
1645
+ * context.
1646
+ * @see https://trpc.io/docs/server/middlewares
1406
1647
  */
1407
1648
  use<$ContextOverridesOut>(fn: MiddlewareBuilder<Overwrite<TContext, TContextOverrides>, TMeta, $ContextOverridesOut, TInputOut> | MiddlewareFunction<TContext, TMeta, TContextOverrides, $ContextOverridesOut, TInputOut>): ProcedureBuilder<TContext, TMeta, Overwrite<TContextOverrides, $ContextOverridesOut>, TInputIn, TInputOut, TOutputIn, TOutputOut, TCaller, TErrorShape>;
1408
1649
  /**
1409
- * @deprecated use {@link concat} instead
1650
+ * @deprecated Use {@link concat} instead.
1410
1651
  */
1411
1652
  unstable_concat<$Context, $Meta, $ContextOverrides, $InputIn, $InputOut, $OutputIn, $OutputOut, $ErrorShape>(builder: Overwrite<TContext, TContextOverrides> extends $Context ? TMeta extends $Meta ? ProcedureBuilder<$Context, $Meta, $ContextOverrides, $InputIn, $InputOut, $OutputIn, $OutputOut, TCaller, $ErrorShape> : TypeError<'Meta mismatch'> : TypeError<'Context mismatch'>): ProcedureBuilder<TContext, TMeta, Overwrite<TContextOverrides, $ContextOverrides>, IntersectIfDefined<TInputIn, $InputIn>, IntersectIfDefined<TInputOut, $InputOut>, IntersectIfDefined<TOutputIn, $OutputIn>, IntersectIfDefined<TOutputOut, $OutputOut>, TCaller, FoldErrorShape<TErrorShape, $ErrorShape>>;
1412
1653
  /**
1413
- * Combine two procedure builders
1654
+ * Adds another procedure builder's inputs, middlewares and context to
1655
+ * this one. Useful for plugins that ship their own procedure builder.
1656
+ * @see https://trpc.io/docs/server/middlewares#concat
1414
1657
  */
1415
1658
  concat<$Context, $Meta, $ContextOverrides, $InputIn, $InputOut, $OutputIn, $OutputOut, $ErrorShape>(builder: Overwrite<TContext, TContextOverrides> extends $Context ? TMeta extends $Meta ? ProcedureBuilder<$Context, $Meta, $ContextOverrides, $InputIn, $InputOut, $OutputIn, $OutputOut, TCaller, $ErrorShape> : TypeError<'Meta mismatch'> : TypeError<'Context mismatch'>): ProcedureBuilder<TContext, TMeta, Overwrite<TContextOverrides, $ContextOverrides>, IntersectIfDefined<TInputIn, $InputIn>, IntersectIfDefined<TInputOut, $InputOut>, IntersectIfDefined<TOutputIn, $OutputIn>, IntersectIfDefined<TOutputOut, $OutputOut>, TCaller, FoldErrorShape<TErrorShape, $ErrorShape>>;
1416
1659
  /**
1417
- * Query procedure
1418
- * @see https://trpc.io/docs/v11/concepts#vocabulary
1660
+ * Ends the builder with a query: a procedure that reads data.
1661
+ * @see https://trpc.io/docs/server/procedures#writing-procedures
1419
1662
  */
1420
1663
  query<$Output>(resolver: ProcedureResolver<TContext, TMeta, TContextOverrides, TInputOut, TOutputIn, $Output>): TCaller extends true ? (input: DefaultValue<TInputIn, void>) => Promise<DefaultValue<TOutputOut, $Output>> : QueryProcedure<{
1421
1664
  input: DefaultValue<TInputIn, void>;
@@ -1424,8 +1667,8 @@ TErrorShape = unknown> {
1424
1667
  errorShape: TErrorShape;
1425
1668
  }>;
1426
1669
  /**
1427
- * Mutation procedure
1428
- * @see https://trpc.io/docs/v11/concepts#vocabulary
1670
+ * Ends the builder with a mutation: a procedure that changes data.
1671
+ * @see https://trpc.io/docs/server/procedures#writing-procedures
1429
1672
  */
1430
1673
  mutation<$Output>(resolver: ProcedureResolver<TContext, TMeta, TContextOverrides, TInputOut, TOutputIn, $Output>): TCaller extends true ? (input: DefaultValue<TInputIn, void>) => Promise<DefaultValue<TOutputOut, $Output>> : MutationProcedure<{
1431
1674
  input: DefaultValue<TInputIn, void>;
@@ -1434,8 +1677,9 @@ TErrorShape = unknown> {
1434
1677
  errorShape: TErrorShape;
1435
1678
  }>;
1436
1679
  /**
1437
- * Subscription procedure
1438
- * @see https://trpc.io/docs/v11/server/subscriptions
1680
+ * Ends the builder with a subscription: a procedure that streams events
1681
+ * from an async iterable, such as an async generator.
1682
+ * @see https://trpc.io/docs/server/subscriptions
1439
1683
  */
1440
1684
  subscription<$Output extends AsyncIterable<any, void, any>>(resolver: ProcedureResolver<TContext, TMeta, TContextOverrides, TInputOut, TOutputIn, $Output>): TCaller extends true ? TypeError<'Not implemented'> : SubscriptionProcedure<{
1441
1685
  input: DefaultValue<TInputIn, void>;
@@ -1444,9 +1688,10 @@ TErrorShape = unknown> {
1444
1688
  errorShape: TErrorShape;
1445
1689
  }>;
1446
1690
  /**
1447
- * @deprecated Using subscriptions with an observable is deprecated. Use an async generator instead.
1448
- * This feature will be removed in v12 of tRPC.
1449
- * @see https://trpc.io/docs/v11/server/subscriptions
1691
+ * Ends the builder with a subscription that returns an observable.
1692
+ * @deprecated Return an async generator instead. Observable subscriptions
1693
+ * will be removed in v12.
1694
+ * @see https://trpc.io/docs/server/subscriptions
1450
1695
  */
1451
1696
  subscription<$Output extends Observable<any, any>>(resolver: ProcedureResolver<TContext, TMeta, TContextOverrides, TInputOut, TOutputIn, $Output>): TCaller extends true ? TypeError<'Not implemented'> : LegacyObservableSubscriptionProcedure<{
1452
1697
  input: DefaultValue<TInputIn, void>;
@@ -1455,8 +1700,9 @@ TErrorShape = unknown> {
1455
1700
  errorShape: TErrorShape;
1456
1701
  }>;
1457
1702
  /**
1458
- * Overrides the way a procedure is invoked
1459
- * Do not use this unless you know what you're doing - this is an experimental API
1703
+ * Replaces how the procedure is called, for example to make it a server
1704
+ * action. Experimental: it may change in any release.
1705
+ * @see https://trpc.io/docs/client/nextjs/server-actions#1-define-a-base-procedure-with-experimental_caller
1460
1706
  */
1461
1707
  experimental_caller(caller: CallerOverride<TContext>): ProcedureBuilder<TContext, TMeta, TContextOverrides, TInputIn, TInputOut, TOutputIn, TOutputOut, true, TErrorShape>;
1462
1708
  /**
@@ -1467,6 +1713,7 @@ TErrorShape = unknown> {
1467
1713
  type ProcedureBuilderResolver = (opts: ProcedureResolverOptions<any, any, any, any>) => Promise<unknown>;
1468
1714
  declare function createBuilder<TContext, TMeta, TErrorShape = unknown>(initDef?: Partial<AnyProcedureBuilderDef>): ProcedureBuilder<TContext, TMeta, object, UnsetMarker, UnsetMarker, UnsetMarker, UnsetMarker, false, TErrorShape>;
1469
1715
  /**
1716
+ * What calling a procedure takes.
1470
1717
  * @internal
1471
1718
  */
1472
1719
  interface ProcedureCallOptions<TContext> {
@@ -1485,6 +1732,7 @@ interface ProcedureCallOptions<TContext> {
1485
1732
  //#region src/unstable-core-do-not-import/procedure.d.ts
1486
1733
  declare const procedureTypes: readonly ['query', 'mutation', 'subscription'];
1487
1734
  /**
1735
+ * A procedure's kind: `'query'`, `'mutation'` or `'subscription'`.
1488
1736
  * @public
1489
1737
  */
1490
1738
  type ProcedureType = (typeof procedureTypes)[number];
@@ -1495,7 +1743,7 @@ interface BuiltProcedureDef {
1495
1743
  errorShape?: unknown;
1496
1744
  }
1497
1745
  /**
1498
- *
1746
+ * A built procedure, as a router holds it.
1499
1747
  * @internal
1500
1748
  */
1501
1749
  interface Procedure<TType extends ProcedureType, TDef extends BuiltProcedureDef> {
@@ -1528,23 +1776,48 @@ interface Procedure<TType extends ProcedureType, TDef extends BuiltProcedureDef>
1528
1776
  */
1529
1777
  (opts: ProcedureCallOptions<unknown>): Promise<TDef['output']>;
1530
1778
  }
1779
+ /** A built query procedure. */
1531
1780
  interface QueryProcedure<TDef extends BuiltProcedureDef> extends Procedure<'query', TDef> {}
1781
+ /** A built mutation procedure. */
1532
1782
  interface MutationProcedure<TDef extends BuiltProcedureDef> extends Procedure<'mutation', TDef> {}
1783
+ /** A built subscription procedure. */
1533
1784
  interface SubscriptionProcedure<TDef extends BuiltProcedureDef> extends Procedure<'subscription', TDef> {}
1534
1785
  /**
1535
- * @deprecated
1786
+ * A subscription procedure that returns an observable.
1787
+ * @deprecated Return an async generator from `.subscription()` instead.
1536
1788
  */
1537
1789
  interface LegacyObservableSubscriptionProcedure<TDef extends BuiltProcedureDef> extends SubscriptionProcedure<TDef> {
1538
1790
  _observable: true;
1539
1791
  }
1792
+ /** Any query procedure, for use in generic constraints. */
1540
1793
  type AnyQueryProcedure = QueryProcedure<any>;
1794
+ /** Any mutation procedure, for use in generic constraints. */
1541
1795
  type AnyMutationProcedure = MutationProcedure<any>;
1796
+ /** Any subscription procedure, for use in generic constraints. */
1542
1797
  type AnySubscriptionProcedure = SubscriptionProcedure<any> | LegacyObservableSubscriptionProcedure<any>;
1798
+ /** Any procedure, for use in generic constraints. */
1543
1799
  type AnyProcedure = AnyQueryProcedure | AnyMutationProcedure | AnySubscriptionProcedure;
1800
+ /**
1801
+ * The input type a procedure takes, before its validators run.
1802
+ * @see https://trpc.io/docs/client/vanilla/infer-types#inferring-individual-procedure-types
1803
+ */
1544
1804
  type inferProcedureInput<TProcedure extends AnyProcedure> = undefined extends inferProcedureParams<TProcedure>['$types']['input'] ? void | inferProcedureParams<TProcedure>['$types']['input'] : inferProcedureParams<TProcedure>['$types']['input'];
1805
+ /** @internal */
1545
1806
  type inferProcedureParams<TProcedure> = TProcedure extends AnyProcedure ? TProcedure['_def'] : never;
1807
+ /**
1808
+ * The output type a procedure returns, after its output validator runs.
1809
+ * @see https://trpc.io/docs/client/vanilla/infer-types#inferring-individual-procedure-types
1810
+ */
1546
1811
  type inferProcedureOutput<TProcedure> = inferProcedureParams<TProcedure>['$types']['output'];
1812
+ /**
1813
+ * The input type a subscription procedure takes.
1814
+ * @see https://trpc.io/docs/client/vanilla/infer-types#inferring-individual-procedure-types
1815
+ */
1547
1816
  type inferSubscriptionInput<TProcedure extends AnySubscriptionProcedure> = inferProcedureInput<TProcedure>;
1817
+ /**
1818
+ * The type of each event a subscription procedure emits.
1819
+ * @see https://trpc.io/docs/client/vanilla/infer-types#inferring-individual-procedure-types
1820
+ */
1548
1821
  type inferSubscriptionOutput<TProcedure extends AnySubscriptionProcedure> = TProcedure extends LegacyObservableSubscriptionProcedure<any> ? inferProcedureOutput<TProcedure> : inferAsyncIterableYield<inferProcedureOutput<TProcedure>>;
1549
1822
  /**
1550
1823
  * @internal
@@ -1558,6 +1831,7 @@ interface ErrorHandlerOptions<TContext> {
1558
1831
  }
1559
1832
  //#endregion
1560
1833
  //#region src/unstable-core-do-not-import/clientish/inferrable.d.ts
1834
+ /** The root types a client needs: the error shape and whether there's a transformer. */
1561
1835
  type AnyClientTypes = Pick<AnyRootTypes, 'errorShape' | 'transformer'>;
1562
1836
  /**
1563
1837
  * Result of `initTRPC.create()`
@@ -1580,7 +1854,8 @@ type RootConfigLike = {
1580
1854
  $types: AnyClientTypes;
1581
1855
  };
1582
1856
  /**
1583
- * Anything that can be inferred to the root config types needed for a TRPC client
1857
+ * Anything a client's root types can be read from: a router, a root
1858
+ * object, a root config or the types themselves.
1584
1859
  */
1585
1860
  type InferrableClientTypes = RouterLike | InitLike | RootConfigLike | AnyClientTypes;
1586
1861
  type PickTypes<T extends AnyClientTypes> = {
@@ -1588,7 +1863,8 @@ type PickTypes<T extends AnyClientTypes> = {
1588
1863
  errorShape: T['errorShape'];
1589
1864
  };
1590
1865
  /**
1591
- * Infer the root types from a InferrableClientTypes
1866
+ * The root types a client needs, read from a router, a root object or a
1867
+ * root config.
1592
1868
  */
1593
1869
  type inferClientTypes<TInferrable extends InferrableClientTypes> = TInferrable extends AnyClientTypes ? PickTypes<TInferrable> : TInferrable extends RootConfigLike ? PickTypes<TInferrable['$types']> : TInferrable extends InitLike ? PickTypes<TInferrable['_config']['$types']> : TInferrable extends RouterLike ? PickTypes<TInferrable['_def']['_config']['$types']> : never;
1594
1870
  //#endregion
@@ -1660,17 +1936,38 @@ type UndefinedToOptional<T extends object> = Pick<WithoutIndexSignature<T>, Filt
1660
1936
  //#endregion
1661
1937
  //#region src/unstable-core-do-not-import/clientish/inference.d.ts
1662
1938
  /**
1939
+ * A procedure's output as the client gets it: as is with a transformer,
1940
+ * or as it comes out of JSON without one.
1663
1941
  * @internal
1664
1942
  */
1665
1943
  type inferTransformedProcedureOutput<TInferrable extends InferrableClientTypes, TProcedure extends AnyProcedure> = inferClientTypes<TInferrable>['transformer'] extends false ? Serialize<inferProcedureOutput<TProcedure>> : inferProcedureOutput<TProcedure>;
1666
1944
  /**
1945
+ * The error shapes a procedure's errors can have: the router's shape, plus
1946
+ * one for each `.errors()` call.
1667
1947
  * @internal
1668
1948
  */
1669
1949
  type inferProcedureErrorShape<TInferrable extends InferrableClientTypes, TProcedure extends AnyProcedure> = TProcedure['_def']['$types']['errorShape'] extends (infer $Shape) ? unknown extends $Shape ? inferClientTypes<TInferrable>['errorShape'] : $Shape : never;
1670
- /** @internal */
1950
+ /**
1951
+ * A subscription's events as the client gets them.
1952
+ * @internal
1953
+ */
1671
1954
  type inferTransformedSubscriptionOutput<TInferrable extends InferrableClientTypes, TProcedure extends AnyProcedure> = inferClientTypes<TInferrable>['transformer'] extends false ? Serialize<inferObservableValue<inferProcedureOutput<TProcedure>>> : inferObservableValue<inferProcedureOutput<TProcedure>>;
1955
+ /** @internal */
1672
1956
  type GetInferenceHelpers<TType extends 'input' | 'output', TRoot extends AnyClientTypes, TRecord extends RouterRecord> = { [TKey in keyof TRecord]: TRecord[TKey] extends (infer $Value) ? $Value extends AnyProcedure ? TType extends 'input' ? inferProcedureInput<$Value> : inferTransformedProcedureOutput<TRoot, $Value> : $Value extends RouterRecord ? GetInferenceHelpers<TType, TRoot, $Value> : never : never; };
1957
+ /**
1958
+ * The input types of every procedure in a router, by path.
1959
+ * @example
1960
+ * ```ts
1961
+ * type PostByIdInput = inferRouterInputs<AppRouter>['post']['byId'];
1962
+ * ```
1963
+ * @see https://trpc.io/docs/client/vanilla/infer-types#inferring-input--output-types
1964
+ */
1673
1965
  type inferRouterInputs<TRouter extends AnyRouter> = GetInferenceHelpers<'input', TRouter['_def']['_config']['$types'], TRouter['_def']['record']>;
1966
+ /**
1967
+ * The output types of every procedure in a router, by path, as the client
1968
+ * gets them.
1969
+ * @see https://trpc.io/docs/client/vanilla/infer-types#inferring-input--output-types
1970
+ */
1674
1971
  type inferRouterOutputs<TRouter extends AnyRouter> = GetInferenceHelpers<'output', TRouter['_def']['_config']['$types'], TRouter['_def']['record']>;
1675
1972
  //#endregion
1676
1973
  //#region src/unstable-core-do-not-import/createProxy.d.ts
@@ -1680,20 +1977,22 @@ interface ProxyCallbackOptions {
1680
1977
  }
1681
1978
  type ProxyCallback = (opts: ProxyCallbackOptions) => unknown;
1682
1979
  /**
1683
- * Creates a proxy that calls the callback with the path and arguments
1684
- *
1980
+ * Creates a proxy that records the property path it's accessed with, and
1981
+ * calls `callback` with the path and arguments when it's called.
1685
1982
  * @internal
1686
1983
  */
1687
1984
  declare const createRecursiveProxy: <TFaux = unknown>(callback: ProxyCallback) => TFaux;
1688
1985
  /**
1689
- * Used in place of `new Proxy` where each handler will map 1 level deep to another value.
1690
- *
1986
+ * Creates a proxy that maps each property to `callback(name)`, one level
1987
+ * deep. It's not thenable.
1691
1988
  * @internal
1692
1989
  */
1693
1990
  declare const createFlatProxy: <TFaux>(callback: (path: keyof TFaux) => any) => TFaux;
1694
1991
  //#endregion
1695
1992
  //#region src/unstable-core-do-not-import/error/getErrorShape.d.ts
1696
1993
  /**
1994
+ * The shape of an error as the client gets it: from a procedure's
1995
+ * `.errors()` formatter if one ran, or else from the root error formatter.
1697
1996
  * @internal
1698
1997
  */
1699
1998
  declare function getErrorShape<TRoot extends AnyRootTypes>(opts: {
@@ -1724,23 +2023,36 @@ declare function getRequestInfo(opts: GetRequestInfoOptions): Promise<TRPCReques
1724
2023
  //#endregion
1725
2024
  //#region src/unstable-core-do-not-import/http/contentTypeParsers.d.ts
1726
2025
  /**
2026
+ * A validator tRPC ships for a special input type.
1727
2027
  * @internal
1728
2028
  */
1729
2029
  type UtilityParser<TInput, TOutput> = ParserZodEsque<TInput, TOutput> & {
1730
2030
  parse: (input: unknown) => TOutput;
1731
2031
  };
1732
2032
  /**
2033
+ * A `File`. Node 18 has no `File` type, but a `File` is always a `Blob`.
1733
2034
  * @internal
1734
- *
1735
- * File is only available from Node19+ but it always extends Blob so we can use that as a type until we eventually drop Node18
1736
2035
  */
1737
2036
  interface FileLike extends Blob {
1738
2037
  readonly name: string;
1739
2038
  }
1740
2039
  /**
2040
+ * The binary inputs a client can send with `octetInputParser`.
1741
2041
  * @internal
1742
2042
  */
1743
2043
  type OctetInput = Blob | Uint8Array | FileLike;
2044
+ /**
2045
+ * An input validator for binary data, such as a `File` or `Blob`. The
2046
+ * resolver gets the input as a `ReadableStream`.
2047
+ * @example
2048
+ * ```ts
2049
+ * t.procedure.input(octetInputParser).mutation(async ({ input }) => {
2050
+ * const bytes = await new Response(input).arrayBuffer();
2051
+ * return { size: bytes.byteLength };
2052
+ * });
2053
+ * ```
2054
+ * @see https://trpc.io/docs/server/non-json-content-types#file-and-other-binary-type-inputs
2055
+ */
1744
2056
  declare const octetInputParser: UtilityParser<OctetInput, ReadableStream>;
1745
2057
  //#endregion
1746
2058
  //#region src/unstable-core-do-not-import/http/formDataToObject.d.ts
@@ -1751,7 +2063,16 @@ declare const JSONRPC2_TO_HTTP_CODE: Record<keyof typeof TRPC_ERROR_CODES_BY_KEY
1751
2063
  declare const HTTP_CODE_TO_JSONRPC2: InvertKeyValue<typeof JSONRPC2_TO_HTTP_CODE>;
1752
2064
  declare function getStatusCodeFromKey(code: keyof typeof TRPC_ERROR_CODES_BY_KEY): number;
1753
2065
  declare function getStatusKeyFromCode(code: keyof typeof HTTP_CODE_TO_JSONRPC2): ValueOf<typeof HTTP_CODE_TO_JSONRPC2>;
2066
+ /**
2067
+ * The HTTP status for a response, or for a batch of them: `207` when the
2068
+ * responses' statuses differ.
2069
+ * @see https://trpc.io/docs/rpc#error-codes---http-status
2070
+ */
1754
2071
  declare function getHTTPStatusCode(json: TRPCResponse | TRPCResponse[]): number;
2072
+ /**
2073
+ * The HTTP status of a `TRPCError`'s code.
2074
+ * @see https://trpc.io/docs/rpc#error-codes---http-status
2075
+ */
1755
2076
  declare function getHTTPStatusCodeFromError(error: TRPCError): number;
1756
2077
  //#endregion
1757
2078
  //#region src/unstable-core-do-not-import/http/abortError.d.ts
@@ -1761,7 +2082,15 @@ declare function isAbortError(error: unknown): error is DOMException | Error | {
1761
2082
  declare function throwAbortError(message?: string): never;
1762
2083
  //#endregion
1763
2084
  //#region src/unstable-core-do-not-import/http/parseConnectionParams.d.ts
2085
+ /**
2086
+ * Checks that connection params are an object of strings, or `null`.
2087
+ * Throws a `PARSE_ERROR` if they aren't.
2088
+ */
1764
2089
  declare function parseConnectionParamsFromUnknown(parsed: unknown): TRPCRequestInfo['connectionParams'];
2090
+ /**
2091
+ * Parses connection params from JSON, as `parseConnectionParamsFromUnknown`
2092
+ * checks them.
2093
+ */
1765
2094
  declare function parseConnectionParamsFromString(str: string): TRPCRequestInfo['connectionParams'];
1766
2095
  //#endregion
1767
2096
  //#region src/unstable-core-do-not-import/http/resolveResponse.d.ts
@@ -1774,11 +2103,18 @@ interface ResolveHTTPRequestOptions<TRouter extends AnyRouter> extends HTTPBaseH
1774
2103
  */
1775
2104
  error: TRPCError | null;
1776
2105
  }
2106
+ /**
2107
+ * Handles a Fetch API `Request` for a router and returns its `Response`.
2108
+ * Every adapter uses it; call it to write your own.
2109
+ */
1777
2110
  declare function resolveResponse<TRouter extends AnyRouter>(opts: ResolveHTTPRequestOptions<TRouter>): Promise<Response>;
1778
2111
  //#endregion
1779
2112
  //#region src/unstable-core-do-not-import/initTRPC.d.ts
1780
2113
  type inferErrorFormatterShape<TType> = TType extends ErrorFormatter<any, infer TShape> ? TShape : DefaultErrorShape;
1781
- /** @internal */
2114
+ /**
2115
+ * The options `initTRPC.create()` takes.
2116
+ * @internal
2117
+ */
1782
2118
  interface RuntimeConfigOptions<TContext extends object, TMeta extends object> extends Partial<Omit<RootConfig<{
1783
2119
  ctx: TContext;
1784
2120
  meta: TMeta;
@@ -1786,12 +2122,18 @@ interface RuntimeConfigOptions<TContext extends object, TMeta extends object> ex
1786
2122
  transformer: any;
1787
2123
  }>, '$types' | 'transformer'>> {
1788
2124
  /**
1789
- * Use a data transformer
1790
- * @see https://trpc.io/docs/v11/data-transformers
2125
+ * Serializes inputs and outputs, so they can carry types JSON can't, such
2126
+ * as `Date`. The client's links must use the same transformer.
2127
+ * @see https://trpc.io/docs/server/data-transformers
1791
2128
  */
1792
2129
  transformer?: DataTransformerOptions;
1793
2130
  }
1794
2131
  type ContextCallback = (...args: any[]) => object | Promise<object>;
2132
+ /**
2133
+ * What `initTRPC.create()` returns: the builders for your procedures,
2134
+ * middlewares and routers. Create it once per backend.
2135
+ * @see https://trpc.io/docs/server/routers#initialize-trpc
2136
+ */
1795
2137
  interface TRPCRootObject<TContext extends object, TMeta extends object, TOptions extends RuntimeConfigOptions<TContext, TMeta>, $Root extends AnyRootTypes = {
1796
2138
  ctx: TContext;
1797
2139
  meta: TMeta;
@@ -1799,56 +2141,71 @@ interface TRPCRootObject<TContext extends object, TMeta extends object, TOptions
1799
2141
  transformer: undefined extends TOptions['transformer'] ? false : true;
1800
2142
  }> {
1801
2143
  /**
1802
- * Your router config
2144
+ * The config the root object was created with.
1803
2145
  * @internal
1804
2146
  */
1805
2147
  _config: RootConfig<$Root>;
1806
2148
  /**
1807
- * Builder object for creating procedures
1808
- * @see https://trpc.io/docs/v11/server/procedures
2149
+ * The base procedure builder. Add inputs, middlewares and a resolver to
2150
+ * make a query, mutation or subscription.
2151
+ * @see https://trpc.io/docs/server/procedures
1809
2152
  */
1810
2153
  procedure: ProcedureBuilder<TContext, TMeta, object, UnsetMarker, UnsetMarker, UnsetMarker, UnsetMarker, false, $Root['errorShape']>;
1811
2154
  /**
1812
- * Create reusable middlewares
1813
- * @see https://trpc.io/docs/v11/server/middlewares
2155
+ * Creates a middleware you can reuse across procedures with `.use()`.
2156
+ * @see https://trpc.io/docs/server/middlewares
1814
2157
  */
1815
2158
  middleware: <$ContextOverrides>(fn: MiddlewareFunction<TContext, TMeta, object, $ContextOverrides, unknown>) => MiddlewareBuilder<TContext, TMeta, $ContextOverrides, unknown>;
1816
2159
  /**
1817
- * Create a router
1818
- * @see https://trpc.io/docs/v11/server/routers
2160
+ * Creates a router from a record of procedures and sub-routers.
2161
+ * @see https://trpc.io/docs/server/routers
1819
2162
  */
1820
2163
  router: RouterBuilder<$Root>;
1821
2164
  /**
1822
- * Merge Routers
1823
- * @see https://trpc.io/docs/v11/server/merging-routers
2165
+ * Merges routers into one, flattening their procedures into the same
2166
+ * namespace.
2167
+ * @see https://trpc.io/docs/server/merging-routers#merging-with-tmergerouters
1824
2168
  */
1825
2169
  mergeRouters: <TRouters extends AnyRouter[]>(...routerList: [...TRouters]) => MergeRouters<TRouters>;
1826
2170
  /**
1827
- * Create a server-side caller for a router
1828
- * @see https://trpc.io/docs/v11/server/server-side-calls
2171
+ * Creates a factory for callers, which call a router's procedures
2172
+ * directly on the server, without HTTP.
2173
+ * @see https://trpc.io/docs/server/server-side-calls
1829
2174
  */
1830
2175
  createCallerFactory: RouterCallerFactory<$Root>;
1831
2176
  }
2177
+ /**
2178
+ * The type of `initTRPC`. Chain `.context()` and `.meta()` to set their
2179
+ * types, then call `.create()`.
2180
+ */
1832
2181
  declare class TRPCBuilder<TContext extends object, TMeta extends object> {
1833
2182
  /**
1834
- * Add a context shape as a generic to the root object
1835
- * @see https://trpc.io/docs/v11/server/context
2183
+ * Sets the type of the context every procedure gets. Pass the type, or
2184
+ * the type of your `createContext` function.
2185
+ * @see https://trpc.io/docs/server/context#defining-the-context-type
1836
2186
  */
1837
2187
  context<TNewContext extends object | ContextCallback>(): TRPCBuilder<TNewContext extends ContextCallback ? Unwrap<TNewContext> : TNewContext, TMeta>;
1838
2188
  /**
1839
- * Add a meta shape as a generic to the root object
1840
- * @see https://trpc.io/docs/v11/quickstart
2189
+ * Sets the type of the metadata procedures can set with `.meta()`.
2190
+ * @see https://trpc.io/docs/server/metadata
1841
2191
  */
1842
2192
  meta<TNewMeta extends object>(): TRPCBuilder<TContext, TNewMeta>;
1843
2193
  /**
1844
- * Create the root object
1845
- * @see https://trpc.io/docs/v11/server/routers#initialize-trpc
2194
+ * Creates the root object, which holds the builders for your procedures,
2195
+ * middlewares and routers.
2196
+ * @see https://trpc.io/docs/server/routers#initialize-trpc
1846
2197
  */
1847
2198
  create<TOptions extends RuntimeConfigOptions<TContext, TMeta>>(opts?: ValidateShape<TOptions, RuntimeConfigOptions<TContext, TMeta>>): TRPCRootObject<TContext, TMeta, TOptions>;
1848
2199
  }
1849
2200
  /**
1850
- * Builder to initialize the tRPC root object - use this exactly once per backend
1851
- * @see https://trpc.io/docs/v11/quickstart
2201
+ * The starting point of every tRPC backend. Call it once.
2202
+ * @example
2203
+ * ```ts
2204
+ * const t = initTRPC.context<Context>().create();
2205
+ * export const router = t.router;
2206
+ * export const publicProcedure = t.procedure;
2207
+ * ```
2208
+ * @see https://trpc.io/docs/server/routers#initialize-trpc
1852
2209
  */
1853
2210
  declare const initTRPC: TRPCBuilder<object, object>;
1854
2211
  //#endregion
@@ -2048,8 +2405,8 @@ declare class Unpromise<T> implements ProxyPromise<T> {
2048
2405
  //#endregion
2049
2406
  //#region src/adapters/wsEncoder.d.ts
2050
2407
  /**
2051
- * Encoder for WebSocket wire format.
2052
- * Encodes outgoing messages and decodes incoming messages.
2408
+ * Encodes the messages a WebSocket server sends and decodes the ones it
2409
+ * gets. The client's `experimental_encoder` must match.
2053
2410
  *
2054
2411
  * @example
2055
2412
  * ```ts
@@ -2060,17 +2417,16 @@ declare class Unpromise<T> implements ProxyPromise<T> {
2060
2417
  * ```
2061
2418
  */
2062
2419
  interface Encoder {
2063
- /** Encode data for transmission over the wire */
2420
+ /** Encodes a message to send. */
2064
2421
  encode(data: unknown): string | Uint8Array<ArrayBuffer>;
2065
- /** Decode data received from the wire */
2422
+ /** Decodes a received message. */
2066
2423
  decode(data: string | ArrayBuffer | Uint8Array): unknown;
2067
2424
  }
2068
2425
  /**
2069
- * Default JSON encoder - used when no encoder is specified.
2070
- * This maintains backwards compatibility with existing behavior.
2426
+ * The default encoder: JSON in text frames.
2071
2427
  */
2072
2428
  declare const jsonEncoder: Encoder;
2073
2429
  //#endregion
2074
2430
  export { AnyMutationProcedure as $, callProcedure as $n, getParseFn as $r, defaultFormatter as $t, formDataToObject as A, ValueOf as Ai, BaseHandlerOptions as An, tracked as Ar, isFunction as At, createRecursiveProxy as B, BuiltRouter as Bn, ParseFn as Br, MiddlewareResult as Bt, throwAbortError as C, PickFirstDefined as Ci, TRPCRequestMessage as Cn, sseStreamConsumer as Cr, UnsetMarker as Ct, getHTTPStatusCodeFromError as D, TypeError as Di, TRPCResultMessage as Dn, inferTrackedOutput as Dr, emptyObject as Dt, getHTTPStatusCode as E, Simplify as Ei, TRPCResult as En, TrackedEnvelope as Er, assertNever as Et, getAcceptHeader as F, ResponseMetaFn as Fn, ProducerOnError as Fr, sleep as Ft, inferTransformedProcedureOutput as G, MergeRouters as Gn, ParserScaleEsque as Gr, experimental_standaloneMiddleware as Gt, inferProcedureErrorShape as H, DecorateCreateRouterOptions as Hn, ParserArkTypeEsque as Hr, createInputMiddleware as Ht, getLastEventId as I, TRPCAcceptHeader as In, WebReadableStreamEsque as Ir, AnyMiddlewareBuilder as It, SerializeObject as J, RouterCaller as Jn, ParserValibotEsque as Jr, DefaultErrorData as Jt, inferTransformedSubscriptionOutput as K, Router as Kn, ParserStandardSchemaEsque as Kr, middlewareMarker as Kt, getRequestInfo as L, TRPCRequestInfo as Ln, isPromise as Lr, AnyMiddlewareFunction as Lt, OctetInput as M, coerceAsyncIterableToArray as Mi, HTTPErrorHandler as Mn, ConsumerOnError as Mr, mergeWithoutOverrides as Mt, UtilityParser as N, inferAsyncIterableYield as Ni, ResolveHTTPRequestOptionsContextFn as Nn, JSONLProducerOptions as Nr, noop as Nt, getStatusCodeFromKey as O, Unwrap as Oi, TRPCSubscriptionStopNotification as On, isTrackedEnvelope as Or, identity as Ot, octetInputParser as P, ResponseMeta as Pn, NodeJSReadableStreamEsque as Pr, run as Pt, inferClientTypes as Q, RouterRecord as Qn, ParserZodEsque as Qr, ProcedureErrorFormatter as Qt, getErrorShape as R, TRPCRequestInfoProcedureCall as Rn, jsonlStreamConsumer as Rr, MiddlewareBuilder as Rt, isAbortError as S, Overwrite as Si, TRPCRequest as Sn, sseHeaders as Sr, inferProcedureBuilderResolverOptions as St, JSONRPC2_TO_HTTP_CODE as T, Result$1 as Ti, TRPCResponseMessage as Tn, TrackedData as Tr, assert as Tt, inferRouterInputs as U, DecorateRouterRecord as Un, ParserCustomValidatorEsque as Ur, createMiddlewareFactory as Ut, GetInferenceHelpers as V, CreateRouterOptions as Vn, Parser as Vr, createErrorFormatterMiddleware as Vt, inferRouterOutputs as W, Lazy as Wn, ParserMyZodEsque as Wr, createOutputMiddleware as Wt, AnyClientTypes as X, RouterCallerFactory as Xn, ParserWithoutInput as Xr, ErrorFormatter as Xt, SerializeRecord as Y, RouterCallerErrorHandler as Yn, ParserWithInputOutput as Yr, DefaultErrorShape as Yt, InferrableClientTypes as Z, RouterDef as Zn, ParserYupEsque as Zr, ErrorFormatterOptions as Zt, TRPCRootObject as _, IntersectionError as _i, TRPCClientOutgoingRequest as _n, isServerDefault as _r, CallerOverride as _t, PromiseWithResolvers as a, TRPC_ERROR_CODES_BY_KEY as ai, CombinedDataTransformer as an, inferRouterMeta as ar, MutationProcedure as at, parseConnectionParamsFromString as b, Maybe as bi, TRPCErrorShape as bn, SSEStreamConsumerOptions as br, ProcedureResolverOptions as bt, StandardSchemaV1Error as c, TRPC_ERROR_CODE_NUMBER as ci, DataTransformerOptions as cn, mergeRouters as cr, QueryProcedure as ct, makeAsyncResource as d, Dict as di, transformResult as dn, CreateRootTypes as dr, inferProcedureOutput as dt, inferParser as ei, getDefaultErrorShape as en, createCallerFactory as er, AnyProcedure as et, makeResource as f, DistributiveOmit as fi, transformTRPCResponse as fn, JSONLConfig as fr, inferProcedureParams as ft, TRPCBuilder as g, GetRawInputFn as gi, TRPCClientOutgoingMessage as gn, isDevDefault as gr, AnyProcedureBuilder as gt, RuntimeConfigOptions as h, FilterKeys as hi, TRPCClientIncomingRequest as hn, RootTypes as hr, procedureTypes as ht, PromiseExecutor as i, getTRPCErrorFromUnknown as ii, parseTRPCMessage as in, inferRouterError as ir, LegacyObservableSubscriptionProcedure as it, FileLike as j, WithoutIndexSignature as ji, HTTPBaseHandlerOptions as jn, EventSourceLike as jr, isObject as jt, getStatusKeyFromCode as k, ValidateShape as ki, TRPCSuccessResponse as kn, sse as kr, isAsyncIterable as kt, iteratorResource as l, retryableRpcCodes as li, defaultTransformer as ln, AnyRootTypes as lr, SubscriptionProcedure as lt, createDeferred as m, Filter as mi, TRPCClientIncomingMessage as mn, RootConfig as mr, inferSubscriptionOutput as mt, jsonEncoder as n, TRPCError as ni, isFormattedErrorShape as nn, getProcedureAtPath as nr, AnySubscriptionProcedure as nt, ProxyPromise as o, TRPC_ERROR_CODES_BY_NUMBER as oi, CombinedDataTransformerClient as on, inferRouterRootTypes as or, Procedure as ot, Deferred as p, ErrorSymbol as pi, JSONRPC2 as pn, JSONLContentType as pr, inferSubscriptionInput as pt, Serialize as q, RouterBuilder as qn, ParserSuperstructEsque as qr, AnyProcedureErrorFormatter as qt, Unpromise as r, getCauseFromUnknown as ri, setFormattedErrorShape as rn, inferRouterContext as rr, ErrorHandlerOptions as rt, SubscribedPromise as s, TRPC_ERROR_CODE_KEY as si, DataTransformer as sn, lazy as sr, ProcedureType as st, Encoder as t, StandardSchemaV1 as ti, getFormattedErrorShape as tn, createRouterFactory as tr, AnyQueryProcedure as tt, takeWithGrace as u, DeepPartial as ui, getDataTransformer as un, CreateContextCallback as ur, inferProcedureInput as ut, initTRPC as v, InvertKeyValue as vi, TRPCConnectionParamsMessage as vn, SSEClientOptions as vr, ProcedureBuilder as vt, HTTP_CODE_TO_JSONRPC2 as w, ProtectedIntersection as wi, TRPCResponse as wn, sseStreamProducer as wr, abortSignalsAnyPonyfill as wt, parseConnectionParamsFromUnknown as x, MaybePromise as xi, TRPCReconnectNotification as xn, SSEStreamProducerOptions as xr, createBuilder as xt, resolveResponse as y, KeyFromValue as yi, TRPCErrorResponse as yn, SSEPingOptions as yr, ProcedureCallOptions as yt, createFlatProxy as z, AnyRouter as zn, jsonlStreamProducer as zr, MiddlewareFunction as zt };
2075
2431
  import './unstable-core-do-not-import.mjs';
2076
- //# sourceMappingURL=unstable-core-do-not-import-Dbo98mkh.d.mts.map
2432
+ //# sourceMappingURL=unstable-core-do-not-import-hC2_7K-s.d.mts.map