@trpc/server 11.0.0-next-alpha.152 → 11.0.0-next-alpha.154

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 (295) hide show
  1. package/dist/adapters/aws-lambda/index.d.ts +1 -1
  2. package/dist/adapters/aws-lambda/index.d.ts.map +1 -1
  3. package/dist/adapters/aws-lambda/index.js +6 -13
  4. package/dist/adapters/aws-lambda/index.mjs +2 -9
  5. package/dist/adapters/aws-lambda/utils.d.ts +2 -3
  6. package/dist/adapters/aws-lambda/utils.d.ts.map +1 -1
  7. package/dist/adapters/express.d.ts +1 -1
  8. package/dist/adapters/express.d.ts.map +1 -1
  9. package/dist/adapters/express.js +3 -11
  10. package/dist/adapters/express.mjs +3 -11
  11. package/dist/adapters/fastify/fastifyRequestHandler.d.ts +1 -1
  12. package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +1 -1
  13. package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +1 -1
  14. package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
  15. package/dist/adapters/fastify/index.js +6 -14
  16. package/dist/adapters/fastify/index.mjs +4 -12
  17. package/dist/adapters/fetch/fetchRequestHandler.d.ts +1 -1
  18. package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +1 -1
  19. package/dist/adapters/fetch/index.js +3 -12
  20. package/dist/adapters/fetch/index.mjs +1 -10
  21. package/dist/adapters/fetch/types.d.ts +1 -1
  22. package/dist/adapters/next.d.ts +3 -2
  23. package/dist/adapters/next.d.ts.map +1 -1
  24. package/dist/adapters/next.js +5 -13
  25. package/dist/adapters/next.mjs +3 -11
  26. package/dist/adapters/node-http/content-type/json/getPostBody.d.ts +1 -1
  27. package/dist/adapters/node-http/content-type/json/getPostBody.d.ts.map +1 -1
  28. package/dist/adapters/node-http/content-type/json/index.js +4 -5
  29. package/dist/adapters/node-http/content-type/json/index.mjs +2 -3
  30. package/dist/adapters/node-http/index.js +3 -11
  31. package/dist/adapters/node-http/index.mjs +3 -11
  32. package/dist/adapters/node-http/internals/contentType.d.ts +2 -2
  33. package/dist/adapters/node-http/internals/contentType.d.ts.map +1 -1
  34. package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +1 -1
  35. package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
  36. package/dist/adapters/node-http/types.d.ts +1 -2
  37. package/dist/adapters/node-http/types.d.ts.map +1 -1
  38. package/dist/adapters/standalone.d.ts +1 -1
  39. package/dist/adapters/standalone.d.ts.map +1 -1
  40. package/dist/adapters/standalone.js +3 -11
  41. package/dist/adapters/standalone.mjs +3 -11
  42. package/dist/adapters/ws.d.ts +3 -3
  43. package/dist/adapters/ws.d.ts.map +1 -1
  44. package/dist/adapters/ws.js +25 -31
  45. package/dist/adapters/ws.mjs +3 -9
  46. package/dist/bundle-analysis.json +74 -604
  47. package/dist/http.d.ts +2 -0
  48. package/dist/http.d.ts.map +1 -0
  49. package/dist/http.js +14 -0
  50. package/dist/http.mjs +1 -0
  51. package/dist/index.d.ts +15 -7
  52. package/dist/index.d.ts.map +1 -1
  53. package/dist/index.js +17 -95
  54. package/dist/index.mjs +1 -90
  55. package/dist/{nodeHTTPRequestHandler-a7049e69.js → nodeHTTPRequestHandler-30028c9a.js} +3 -5
  56. package/dist/{nodeHTTPRequestHandler-ca65b7c9.mjs → nodeHTTPRequestHandler-36974696.mjs} +1 -3
  57. package/dist/{nodeHTTPRequestHandler-abbfb330.js → nodeHTTPRequestHandler-640c1f60.js} +1 -3
  58. package/dist/observable.d.ts +2 -0
  59. package/dist/observable.d.ts.map +1 -0
  60. package/dist/observable.js +14 -0
  61. package/dist/observable.mjs +1 -0
  62. package/dist/rpc.d.ts +2 -0
  63. package/dist/rpc.d.ts.map +1 -0
  64. package/dist/rpc.js +14 -0
  65. package/dist/rpc.mjs +1 -0
  66. package/dist/unstableDoNotImportThis.d.ts +9 -0
  67. package/dist/unstableDoNotImportThis.d.ts.map +1 -0
  68. package/package.json +32 -41
  69. package/src/adapters/aws-lambda/index.ts +2 -3
  70. package/src/adapters/aws-lambda/utils.ts +3 -4
  71. package/src/adapters/express.ts +1 -1
  72. package/src/adapters/fastify/fastifyRequestHandler.ts +4 -3
  73. package/src/adapters/fastify/fastifyTRPCPlugin.ts +1 -1
  74. package/src/adapters/fetch/fetchRequestHandler.ts +4 -3
  75. package/src/adapters/fetch/types.ts +1 -1
  76. package/src/adapters/next.ts +3 -8
  77. package/src/adapters/node-http/content-type/form-data/index.ts +1 -1
  78. package/src/adapters/node-http/content-type/json/getPostBody.ts +2 -2
  79. package/src/adapters/node-http/content-type/json/index.ts +1 -1
  80. package/src/adapters/node-http/internals/contentType.ts +2 -2
  81. package/src/adapters/node-http/nodeHTTPRequestHandler.ts +4 -3
  82. package/src/adapters/node-http/types.ts +1 -2
  83. package/src/adapters/standalone.ts +1 -1
  84. package/src/adapters/ws.ts +14 -9
  85. package/src/http.ts +2 -0
  86. package/src/index.ts +30 -14
  87. package/src/observable.ts +1 -0
  88. package/src/rpc.ts +2 -0
  89. package/src/unstableDoNotImportThis.ts +9 -0
  90. package/dist/TRPCError-0b220715.js +0 -42
  91. package/dist/TRPCError-2bb6a7d0.js +0 -37
  92. package/dist/TRPCError-7e8e2a1b.mjs +0 -39
  93. package/dist/batchStreamFormatter-2c1405a1.js +0 -31
  94. package/dist/batchStreamFormatter-93cdcdd4.js +0 -32
  95. package/dist/batchStreamFormatter-fc1ffb26.mjs +0 -30
  96. package/dist/codes-62b059d2.js +0 -48
  97. package/dist/codes-87f6824b.js +0 -48
  98. package/dist/codes-c924c3db.mjs +0 -44
  99. package/dist/config-50853f49.mjs +0 -6
  100. package/dist/config-774dae36.js +0 -8
  101. package/dist/config-e3dd843b.js +0 -11
  102. package/dist/contentType-0447b256.js +0 -58
  103. package/dist/contentType-31223e57.mjs +0 -52
  104. package/dist/contentType-a229790b.js +0 -54
  105. package/dist/core/index.d.ts +0 -9
  106. package/dist/core/index.d.ts.map +0 -1
  107. package/dist/core/initTRPC.d.ts +0 -84
  108. package/dist/core/initTRPC.d.ts.map +0 -1
  109. package/dist/core/internals/config.d.ts +0 -75
  110. package/dist/core/internals/config.d.ts.map +0 -1
  111. package/dist/core/internals/getParseFn.d.ts +0 -4
  112. package/dist/core/internals/getParseFn.d.ts.map +0 -1
  113. package/dist/core/internals/mergeRouters.d.ts +0 -15
  114. package/dist/core/internals/mergeRouters.d.ts.map +0 -1
  115. package/dist/core/internals/mergeWithoutOverrides.d.ts +0 -5
  116. package/dist/core/internals/mergeWithoutOverrides.d.ts.map +0 -1
  117. package/dist/core/internals/omitPrototype.d.ts +0 -6
  118. package/dist/core/internals/omitPrototype.d.ts.map +0 -1
  119. package/dist/core/internals/procedureBuilder.d.ts +0 -99
  120. package/dist/core/internals/procedureBuilder.d.ts.map +0 -1
  121. package/dist/core/internals/utils.d.ts +0 -50
  122. package/dist/core/internals/utils.d.ts.map +0 -1
  123. package/dist/core/middleware.d.ts +0 -106
  124. package/dist/core/middleware.d.ts.map +0 -1
  125. package/dist/core/parser.d.ts +0 -28
  126. package/dist/core/parser.d.ts.map +0 -1
  127. package/dist/core/procedure.d.ts +0 -54
  128. package/dist/core/procedure.d.ts.map +0 -1
  129. package/dist/core/router.d.ts +0 -64
  130. package/dist/core/router.d.ts.map +0 -1
  131. package/dist/core/types.d.ts +0 -24
  132. package/dist/core/types.d.ts.map +0 -1
  133. package/dist/error/TRPCError.d.ts +0 -12
  134. package/dist/error/TRPCError.d.ts.map +0 -1
  135. package/dist/error/formatter.d.ts +0 -33
  136. package/dist/error/formatter.d.ts.map +0 -1
  137. package/dist/error/utils.d.ts +0 -9
  138. package/dist/error/utils.d.ts.map +0 -1
  139. package/dist/getCauseFromUnknown-2d66414a.mjs +0 -33
  140. package/dist/getCauseFromUnknown-ac5f46a2.js +0 -34
  141. package/dist/getCauseFromUnknown-d535264a.js +0 -35
  142. package/dist/http/batchStreamFormatter.d.ts +0 -24
  143. package/dist/http/batchStreamFormatter.d.ts.map +0 -1
  144. package/dist/http/contentType.d.ts +0 -29
  145. package/dist/http/contentType.d.ts.map +0 -1
  146. package/dist/http/getHTTPStatusCode.d.ts +0 -24
  147. package/dist/http/getHTTPStatusCode.d.ts.map +0 -1
  148. package/dist/http/index.d.ts +0 -5
  149. package/dist/http/index.d.ts.map +0 -1
  150. package/dist/http/index.js +0 -22
  151. package/dist/http/index.mjs +0 -10
  152. package/dist/http/internals/types.d.ts +0 -32
  153. package/dist/http/internals/types.d.ts.map +0 -1
  154. package/dist/http/resolveHTTPResponse.d.ts +0 -52
  155. package/dist/http/resolveHTTPResponse.d.ts.map +0 -1
  156. package/dist/http/types.d.ts +0 -46
  157. package/dist/http/types.d.ts.map +0 -1
  158. package/dist/index-8759c3db.js +0 -48
  159. package/dist/index-a496f86b.js +0 -52
  160. package/dist/index-a9e3e610.mjs +0 -49
  161. package/dist/internals/invert.d.ts +0 -12
  162. package/dist/internals/invert.d.ts.map +0 -1
  163. package/dist/internals/types.d.ts +0 -26
  164. package/dist/internals/types.d.ts.map +0 -1
  165. package/dist/observable/index.d.ts +0 -5
  166. package/dist/observable/index.d.ts.map +0 -1
  167. package/dist/observable/index.js +0 -156
  168. package/dist/observable/index.mjs +0 -147
  169. package/dist/observable/internals/identity.d.ts +0 -2
  170. package/dist/observable/internals/identity.d.ts.map +0 -1
  171. package/dist/observable/internals/observableToPromise.d.ts +0 -10
  172. package/dist/observable/internals/observableToPromise.d.ts.map +0 -1
  173. package/dist/observable/internals/pipe.d.ts +0 -4
  174. package/dist/observable/internals/pipe.d.ts.map +0 -1
  175. package/dist/observable/observable.d.ts +0 -5
  176. package/dist/observable/observable.d.ts.map +0 -1
  177. package/dist/observable/operators/index.d.ts +0 -4
  178. package/dist/observable/operators/index.d.ts.map +0 -1
  179. package/dist/observable/operators/map.d.ts +0 -3
  180. package/dist/observable/operators/map.d.ts.map +0 -1
  181. package/dist/observable/operators/share.d.ts +0 -6
  182. package/dist/observable/operators/share.d.ts.map +0 -1
  183. package/dist/observable/operators/tap.d.ts +0 -3
  184. package/dist/observable/operators/tap.d.ts.map +0 -1
  185. package/dist/observable/types.d.ts +0 -29
  186. package/dist/observable/types.d.ts.map +0 -1
  187. package/dist/observable-15588f28.js +0 -83
  188. package/dist/observable-464116ac.js +0 -84
  189. package/dist/observable-ade1bad8.mjs +0 -81
  190. package/dist/parseTRPCMessage-1377f305.js +0 -56
  191. package/dist/parseTRPCMessage-95955211.js +0 -63
  192. package/dist/parseTRPCMessage-a0f17853.mjs +0 -54
  193. package/dist/procedureBuilder-0446e596.js +0 -327
  194. package/dist/procedureBuilder-4b68e226.js +0 -349
  195. package/dist/procedureBuilder-cf58dadb.mjs +0 -340
  196. package/dist/resolveHTTPResponse-3ebaa4f6.mjs +0 -292
  197. package/dist/resolveHTTPResponse-7c84e387.js +0 -294
  198. package/dist/resolveHTTPResponse-fa37ffd7.js +0 -266
  199. package/dist/router-18d63731.js +0 -163
  200. package/dist/router-8dcebd61.js +0 -153
  201. package/dist/router-f9ce121f.mjs +0 -156
  202. package/dist/rpc/codes.d.ts +0 -51
  203. package/dist/rpc/codes.d.ts.map +0 -1
  204. package/dist/rpc/envelopes.d.ts +0 -95
  205. package/dist/rpc/envelopes.d.ts.map +0 -1
  206. package/dist/rpc/index.d.ts +0 -4
  207. package/dist/rpc/index.d.ts.map +0 -1
  208. package/dist/rpc/index.js +0 -12
  209. package/dist/rpc/index.mjs +0 -2
  210. package/dist/rpc/parseTRPCMessage.d.ts +0 -5
  211. package/dist/rpc/parseTRPCMessage.d.ts.map +0 -1
  212. package/dist/shared/createProxy/index.d.ts +0 -19
  213. package/dist/shared/createProxy/index.d.ts.map +0 -1
  214. package/dist/shared/getCauseFromUnknown.d.ts +0 -2
  215. package/dist/shared/getCauseFromUnknown.d.ts.map +0 -1
  216. package/dist/shared/getErrorShape.d.ts +0 -15
  217. package/dist/shared/getErrorShape.d.ts.map +0 -1
  218. package/dist/shared/index.d.ts +0 -8
  219. package/dist/shared/index.d.ts.map +0 -1
  220. package/dist/shared/index.js +0 -16
  221. package/dist/shared/index.mjs +0 -4
  222. package/dist/shared/internal/serialize.d.ts +0 -62
  223. package/dist/shared/internal/serialize.d.ts.map +0 -1
  224. package/dist/shared/jsonify.d.ts +0 -11
  225. package/dist/shared/jsonify.d.ts.map +0 -1
  226. package/dist/shared/transformTRPCResponse.d.ts +0 -9
  227. package/dist/shared/transformTRPCResponse.d.ts.map +0 -1
  228. package/dist/shared/types.d.ts +0 -6
  229. package/dist/shared/types.d.ts.map +0 -1
  230. package/dist/transformTRPCResponse-31040a38.mjs +0 -98
  231. package/dist/transformTRPCResponse-59486a84.js +0 -97
  232. package/dist/transformTRPCResponse-9f3b865f.js +0 -104
  233. package/dist/transformer.d.ts +0 -67
  234. package/dist/transformer.d.ts.map +0 -1
  235. package/dist/types.d.ts +0 -68
  236. package/dist/types.d.ts.map +0 -1
  237. package/dist/unstableInternalsExport.d.ts +0 -12
  238. package/dist/unstableInternalsExport.d.ts.map +0 -1
  239. package/dist/unstableInternalsExport.js +0 -16
  240. package/dist/unstableInternalsExport.mjs +0 -5
  241. package/src/core/index.ts +0 -28
  242. package/src/core/initTRPC.ts +0 -186
  243. package/src/core/internals/config.ts +0 -90
  244. package/src/core/internals/getParseFn.ts +0 -43
  245. package/src/core/internals/mergeRouters.ts +0 -90
  246. package/src/core/internals/mergeWithoutOverrides.ts +0 -19
  247. package/src/core/internals/omitPrototype.ts +0 -9
  248. package/src/core/internals/procedureBuilder.ts +0 -455
  249. package/src/core/internals/utils.ts +0 -79
  250. package/src/core/middleware.ts +0 -236
  251. package/src/core/parser.ts +0 -52
  252. package/src/core/procedure.ts +0 -68
  253. package/src/core/router.ts +0 -241
  254. package/src/core/types.ts +0 -67
  255. package/src/error/TRPCError.ts +0 -52
  256. package/src/error/formatter.ts +0 -54
  257. package/src/error/utils.ts +0 -23
  258. package/src/http/batchStreamFormatter.ts +0 -29
  259. package/src/http/contentType.ts +0 -99
  260. package/src/http/getHTTPStatusCode.ts +0 -61
  261. package/src/http/index.ts +0 -4
  262. package/src/http/internals/types.ts +0 -40
  263. package/src/http/resolveHTTPResponse.ts +0 -458
  264. package/src/http/types.ts +0 -51
  265. package/src/internals/invert.ts +0 -21
  266. package/src/internals/types.ts +0 -27
  267. package/src/observable/index.ts +0 -4
  268. package/src/observable/internals/identity.ts +0 -3
  269. package/src/observable/internals/observableToPromise.ts +0 -49
  270. package/src/observable/internals/pipe.ts +0 -23
  271. package/src/observable/observable.ts +0 -78
  272. package/src/observable/operators/index.ts +0 -3
  273. package/src/observable/operators/map.ts +0 -25
  274. package/src/observable/operators/share.ts +0 -65
  275. package/src/observable/operators/tap.ts +0 -26
  276. package/src/observable/types.ts +0 -80
  277. package/src/rpc/codes.ts +0 -44
  278. package/src/rpc/envelopes.ts +0 -136
  279. package/src/rpc/index.ts +0 -3
  280. package/src/rpc/parseTRPCMessage.ts +0 -84
  281. package/src/shared/createProxy/index.ts +0 -59
  282. package/src/shared/getCauseFromUnknown.ts +0 -31
  283. package/src/shared/getErrorShape.ts +0 -36
  284. package/src/shared/index.ts +0 -11
  285. package/src/shared/internal/serialize.ts +0 -122
  286. package/src/shared/jsonify.ts +0 -22
  287. package/src/shared/transformTRPCResponse.ts +0 -40
  288. package/src/shared/types.ts +0 -9
  289. package/src/transformer.ts +0 -84
  290. package/src/types.ts +0 -104
  291. package/src/unstableInternalsExport.ts +0 -12
  292. package/subscription/index.d.ts +0 -1
  293. package/subscription/index.js +0 -1
  294. package/unstableInternalsExport/index.d.ts +0 -1
  295. package/unstableInternalsExport/index.js +0 -1
@@ -10,10 +10,10 @@
10
10
  */
11
11
  import * as fs from 'fs/promises';
12
12
  import { Readable } from 'node:stream';
13
+ import { CombinedDataTransformer } from '@trpc/core';
13
14
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
14
15
  // @ts-ignore the type definitions for this package are borked
15
16
  import { streamMultipart } from '@web3-storage/multipart-parser';
16
- import { CombinedDataTransformer } from '../../../../transformer';
17
17
  import { createNodeHTTPContentTypeHandler } from '../../internals/contentType';
18
18
  import { NodeHTTPRequest } from '../../types';
19
19
  import { NodeOnDiskFile } from './fileUploadHandler';
@@ -1,5 +1,5 @@
1
- import { TRPCError } from '../../../../error/TRPCError';
2
- import { BodyResult } from '../../../../http/contentType';
1
+ import { TRPCError } from '@trpc/core';
2
+ import { BodyResult } from '../../../../http';
3
3
  import { NodeHTTPRequest } from '../../types';
4
4
 
5
5
  export async function getPostBody(opts: {
@@ -1,4 +1,4 @@
1
- import { getJsonContentTypeInputs } from '../../../../http/contentType';
1
+ import { getJsonContentTypeInputs } from '../../../../http';
2
2
  import { createNodeHTTPContentTypeHandler } from '../../internals/contentType';
3
3
  import { getPostBody } from './getPostBody';
4
4
 
@@ -1,5 +1,5 @@
1
- import { AnyRouter } from '../../../core';
2
- import { BaseContentTypeHandler } from '../../../http/contentType';
1
+ import { AnyRouter } from '@trpc/core';
2
+ import { BaseContentTypeHandler } from '../../../http';
3
3
  import {
4
4
  NodeHTTPRequest,
5
5
  NodeHTTPRequestHandlerOptions,
@@ -1,12 +1,13 @@
1
1
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
2
- import { AnyRouter } from '../../core';
2
+ import { AnyRouter } from '@trpc/core';
3
3
  import {
4
4
  getBatchStreamFormatter,
5
5
  HTTPRequest,
6
+ HTTPResponse,
6
7
  ResolveHTTPRequestOptionsContextFn,
8
+ resolveHTTPResponse,
9
+ ResponseChunk,
7
10
  } from '../../http';
8
- import { HTTPResponse, ResponseChunk } from '../../http/internals/types';
9
- import { resolveHTTPResponse } from '../../http/resolveHTTPResponse';
10
11
  import { nodeHTTPJSONContentTypeHandler } from './content-type/json';
11
12
  import { NodeHTTPContentTypeHandler } from './internals/contentType';
12
13
  import {
@@ -1,7 +1,6 @@
1
1
  import { IncomingMessage, ServerResponse } from 'http';
2
- import { AnyRouter, inferRouterContext } from '../../core';
2
+ import { AnyRouter, inferRouterContext, MaybePromise } from '@trpc/core';
3
3
  import { HTTPBaseHandlerOptions, TRPCRequestInfo } from '../../http';
4
- import { MaybePromise } from '../../types';
5
4
  import { NodeHTTPContentTypeHandler } from './internals/contentType';
6
5
 
7
6
  interface ParsedQs {
@@ -1,6 +1,6 @@
1
1
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
2
2
  import http from 'http';
3
- import { AnyRouter } from '../core';
3
+ import { AnyRouter } from '@trpc/core';
4
4
  import {
5
5
  NodeHTTPCreateContextFnOptions,
6
6
  NodeHTTPHandlerOptions,
@@ -1,19 +1,24 @@
1
1
  import { IncomingMessage } from 'http';
2
- import { WebSocket, WebSocketServer } from 'ws';
3
- import { AnyRouter, callProcedure, inferRouterContext } from '../core';
4
- import { getTRPCErrorFromUnknown, TRPCError } from '../error/TRPCError';
5
- import { BaseHandlerOptions } from '../internals/types';
6
- import { isObservable, Unsubscribable } from '../observable';
2
+ import {
3
+ AnyRouter,
4
+ callProcedure,
5
+ getErrorShape,
6
+ getTRPCErrorFromUnknown,
7
+ inferRouterContext,
8
+ MaybePromise,
9
+ transformTRPCResponse,
10
+ TRPCError,
11
+ } from '@trpc/core';
12
+ import { BaseHandlerOptions } from '@trpc/core/http';
13
+ import { isObservable, Unsubscribable } from '@trpc/core/observable';
7
14
  import {
8
15
  JSONRPC2,
9
16
  parseTRPCMessage,
10
17
  TRPCClientOutgoingMessage,
11
18
  TRPCReconnectNotification,
12
19
  TRPCResponseMessage,
13
- } from '../rpc';
14
- import { getErrorShape } from '../shared/getErrorShape';
15
- import { transformTRPCResponse } from '../shared/transformTRPCResponse';
16
- import { MaybePromise } from '../types';
20
+ } from '@trpc/core/rpc';
21
+ import { WebSocket, WebSocketServer } from 'ws';
17
22
  import { NodeHTTPCreateContextFnOptions } from './node-http';
18
23
 
19
24
  /**
package/src/http.ts ADDED
@@ -0,0 +1,2 @@
1
+ // This should be moved to a like `@trpc/plugin`-package
2
+ export * from '@trpc/core/http';
package/src/index.ts CHANGED
@@ -1,18 +1,34 @@
1
- // FIXME: this file should only export
2
- // - `initTRPC`
3
- // - `TRPCError`
4
- // - (maybe something else?)
5
-
6
- export * from './transformer';
7
- export * from './error/TRPCError';
8
- export * from './core';
9
- export { type DefaultErrorShape } from './error/formatter';
10
- export type { RootConfig, AnyRootConfig } from './core/internals/config';
1
+ export {
2
+ TRPCError,
3
+ /**
4
+ * @deprecated use `experimental_trpcMiddleware` instead
5
+ */
6
+ experimental_standaloneMiddleware,
7
+ experimental_standaloneMiddleware as experimental_trpcMiddleware,
8
+ initTRPC,
9
+ type inferProcedureInput,
10
+ type inferProcedureOutput,
11
+ type inferRouterError,
12
+ type inferRouterInputs,
13
+ type inferRouterOutputs,
14
+ type AnyProcedure as AnyTRPCProcedure,
15
+ type AnyRouter as AnyTRPCRouter,
16
+ } from './unstableDoNotImportThis';
11
17
 
12
18
  export type {
13
19
  /**
14
- * @deprecated
15
- * Use `Awaited<ReturnType<T>>` instead
20
+ * @deprecated use `AnyTRPCProcedure` instead
16
21
  */
17
- inferAsyncReturnType,
18
- } from './types';
22
+ AnyProcedure,
23
+ /**
24
+ * @deprecated use `AnyTRPCRouter` instead
25
+ */
26
+ AnyRouter,
27
+ } from '@trpc/core';
28
+
29
+ /**
30
+ * @deprecated
31
+ * Use `Awaited<ReturnType<typeof myFunction>>` instead
32
+ */
33
+ export type inferAsyncReturnType<TFunction extends (...args: any[]) => any> =
34
+ Awaited<ReturnType<TFunction>>;
@@ -0,0 +1 @@
1
+ export * from '@trpc/core/observable';
package/src/rpc.ts ADDED
@@ -0,0 +1,2 @@
1
+ // Note: this should likely be moved to a sort of `@trpc/plugin` package
2
+ export * from '@trpc/core/rpc';
@@ -0,0 +1,9 @@
1
+ /**
2
+ * This file is here to make TypeScript happy and prevent _"The inferred type of 'createContext' cannot be named without a reference to [...]"_.
3
+ *
4
+ * We're basically just re-exporting everything from @trpc/core here.
5
+ *
6
+ * If you need to import anything from here, please open an issue at https://github.com/trpc/trpc/issues
7
+ */
8
+
9
+ export * from '@trpc/core';
@@ -1,42 +0,0 @@
1
- 'use strict';
2
-
3
- var getCauseFromUnknown = require('./getCauseFromUnknown-d535264a.js');
4
-
5
- function getTRPCErrorFromUnknown(cause) {
6
- if (cause instanceof TRPCError) {
7
- return cause;
8
- }
9
- if (cause instanceof Error && cause.name === 'TRPCError') {
10
- // https://github.com/trpc/trpc/pull/4848
11
- return cause;
12
- }
13
- const trpcError = new TRPCError({
14
- code: 'INTERNAL_SERVER_ERROR',
15
- cause
16
- });
17
- // Inherit stack from error
18
- if (cause instanceof Error && cause.stack) {
19
- trpcError.stack = cause.stack;
20
- }
21
- return trpcError;
22
- }
23
- class TRPCError extends Error {
24
- constructor(opts){
25
- const cause = getCauseFromUnknown.getCauseFromUnknown(opts.cause);
26
- const message = opts.message ?? cause?.message ?? opts.code;
27
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
28
- // @ts-ignore https://github.com/tc39/proposal-error-cause
29
- super(message, {
30
- cause
31
- });
32
- this.code = opts.code;
33
- this.name = 'TRPCError';
34
- if (!this.cause) {
35
- // idk why this is needed, but it is
36
- this.cause = cause;
37
- }
38
- }
39
- }
40
-
41
- exports.TRPCError = TRPCError;
42
- exports.getTRPCErrorFromUnknown = getTRPCErrorFromUnknown;
@@ -1,37 +0,0 @@
1
- import { g as getCauseFromUnknown } from './getCauseFromUnknown-ac5f46a2.js';
2
-
3
- function getTRPCErrorFromUnknown(cause) {
4
- if (cause instanceof TRPCError) {
5
- return cause;
6
- }
7
- if (cause instanceof Error && cause.name === 'TRPCError') {
8
- // https://github.com/trpc/trpc/pull/4848
9
- return cause;
10
- }
11
- const trpcError = new TRPCError({
12
- code: 'INTERNAL_SERVER_ERROR',
13
- cause,
14
- });
15
- // Inherit stack from error
16
- if (cause instanceof Error && cause.stack) {
17
- trpcError.stack = cause.stack;
18
- }
19
- return trpcError;
20
- }
21
- class TRPCError extends Error {
22
- constructor(opts) {
23
- const cause = getCauseFromUnknown(opts.cause);
24
- const message = opts.message ?? cause?.message ?? opts.code;
25
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
26
- // @ts-ignore https://github.com/tc39/proposal-error-cause
27
- super(message, { cause });
28
- this.code = opts.code;
29
- this.name = 'TRPCError';
30
- if (!this.cause) {
31
- // idk why this is needed, but it is
32
- this.cause = cause;
33
- }
34
- }
35
- }
36
-
37
- export { TRPCError as T, getTRPCErrorFromUnknown as g };
@@ -1,39 +0,0 @@
1
- import { g as getCauseFromUnknown } from './getCauseFromUnknown-2d66414a.mjs';
2
-
3
- function getTRPCErrorFromUnknown(cause) {
4
- if (cause instanceof TRPCError) {
5
- return cause;
6
- }
7
- if (cause instanceof Error && cause.name === 'TRPCError') {
8
- // https://github.com/trpc/trpc/pull/4848
9
- return cause;
10
- }
11
- const trpcError = new TRPCError({
12
- code: 'INTERNAL_SERVER_ERROR',
13
- cause
14
- });
15
- // Inherit stack from error
16
- if (cause instanceof Error && cause.stack) {
17
- trpcError.stack = cause.stack;
18
- }
19
- return trpcError;
20
- }
21
- class TRPCError extends Error {
22
- constructor(opts){
23
- const cause = getCauseFromUnknown(opts.cause);
24
- const message = opts.message ?? cause?.message ?? opts.code;
25
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
26
- // @ts-ignore https://github.com/tc39/proposal-error-cause
27
- super(message, {
28
- cause
29
- });
30
- this.code = opts.code;
31
- this.name = 'TRPCError';
32
- if (!this.cause) {
33
- // idk why this is needed, but it is
34
- this.cause = cause;
35
- }
36
- }
37
- }
38
-
39
- export { TRPCError as T, getTRPCErrorFromUnknown as g };
@@ -1,31 +0,0 @@
1
- /**
2
- * Format a batch response as a line-delimited JSON stream
3
- * that the `unstable_httpBatchStreamLink` can parse:
4
- *
5
- * @example
6
- * ```ts
7
- * const formatter = getBatchStreamFormatter();
8
- * res.send(formatter(1, 'response #2'));
9
- * res.send(formatter(0, 'response #1'));
10
- * res.send(formatter.end());
11
- * ```
12
- *
13
- * Expected format:
14
- * ```json
15
- * {"1":"response #2"
16
- * ,"0":"response #1"
17
- * }
18
- * ```
19
- */
20
- function getBatchStreamFormatter() {
21
- let first = true;
22
- function format(index, string) {
23
- const prefix = first ? '{' : ',';
24
- first = false;
25
- return `${prefix}"${index}":${string}\n`;
26
- }
27
- format.end = () => '}';
28
- return format;
29
- }
30
-
31
- export { getBatchStreamFormatter as g };
@@ -1,32 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * Format a batch response as a line-delimited JSON stream
5
- * that the `unstable_httpBatchStreamLink` can parse:
6
- *
7
- * @example
8
- * ```ts
9
- * const formatter = getBatchStreamFormatter();
10
- * res.send(formatter(1, 'response #2'));
11
- * res.send(formatter(0, 'response #1'));
12
- * res.send(formatter.end());
13
- * ```
14
- *
15
- * Expected format:
16
- * ```json
17
- * {"1":"response #2"
18
- * ,"0":"response #1"
19
- * }
20
- * ```
21
- */ function getBatchStreamFormatter() {
22
- let first = true;
23
- function format(index, string) {
24
- const prefix = first ? '{' : ',';
25
- first = false;
26
- return `${prefix}"${index}":${string}\n`;
27
- }
28
- format.end = ()=>'}';
29
- return format;
30
- }
31
-
32
- exports.getBatchStreamFormatter = getBatchStreamFormatter;
@@ -1,30 +0,0 @@
1
- /**
2
- * Format a batch response as a line-delimited JSON stream
3
- * that the `unstable_httpBatchStreamLink` can parse:
4
- *
5
- * @example
6
- * ```ts
7
- * const formatter = getBatchStreamFormatter();
8
- * res.send(formatter(1, 'response #2'));
9
- * res.send(formatter(0, 'response #1'));
10
- * res.send(formatter.end());
11
- * ```
12
- *
13
- * Expected format:
14
- * ```json
15
- * {"1":"response #2"
16
- * ,"0":"response #1"
17
- * }
18
- * ```
19
- */ function getBatchStreamFormatter() {
20
- let first = true;
21
- function format(index, string) {
22
- const prefix = first ? '{' : ',';
23
- first = false;
24
- return `${prefix}"${index}":${string}\n`;
25
- }
26
- format.end = ()=>'}';
27
- return format;
28
- }
29
-
30
- export { getBatchStreamFormatter as g };
@@ -1,48 +0,0 @@
1
- /**
2
- * @internal
3
- */
4
- function invert(obj) {
5
- const newObj = Object.create(null);
6
- for (const key in obj) {
7
- const v = obj[key];
8
- newObj[v] = key;
9
- }
10
- return newObj;
11
- }
12
-
13
- // reference: https://www.jsonrpc.org/specification
14
- /**
15
- * JSON-RPC 2.0 Error codes
16
- *
17
- * `-32000` to `-32099` are reserved for implementation-defined server-errors.
18
- * For tRPC we're copying the last digits of HTTP 4XX errors.
19
- */
20
- const TRPC_ERROR_CODES_BY_KEY = {
21
- /**
22
- * Invalid JSON was received by the server.
23
- * An error occurred on the server while parsing the JSON text.
24
- */
25
- PARSE_ERROR: -32700,
26
- /**
27
- * The JSON sent is not a valid Request object.
28
- */
29
- BAD_REQUEST: -32600, // 400
30
- // Internal JSON-RPC error
31
- INTERNAL_SERVER_ERROR: -32603,
32
- NOT_IMPLEMENTED: -32603,
33
- // Implementation specific errors
34
- UNAUTHORIZED: -32001, // 401
35
- FORBIDDEN: -32003, // 403
36
- NOT_FOUND: -32004, // 404
37
- METHOD_NOT_SUPPORTED: -32005, // 405
38
- TIMEOUT: -32008, // 408
39
- CONFLICT: -32009, // 409
40
- PRECONDITION_FAILED: -32012, // 412
41
- PAYLOAD_TOO_LARGE: -32013, // 413
42
- UNPROCESSABLE_CONTENT: -32022, // 422
43
- TOO_MANY_REQUESTS: -32029, // 429
44
- CLIENT_CLOSED_REQUEST: -32099, // 499
45
- };
46
- const TRPC_ERROR_CODES_BY_NUMBER = invert(TRPC_ERROR_CODES_BY_KEY);
47
-
48
- export { TRPC_ERROR_CODES_BY_KEY as T, TRPC_ERROR_CODES_BY_NUMBER as a, invert as i };
@@ -1,48 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * @internal
5
- */ function invert(obj) {
6
- const newObj = Object.create(null);
7
- for(const key in obj){
8
- const v = obj[key];
9
- newObj[v] = key;
10
- }
11
- return newObj;
12
- }
13
-
14
- // reference: https://www.jsonrpc.org/specification
15
- /**
16
- * JSON-RPC 2.0 Error codes
17
- *
18
- * `-32000` to `-32099` are reserved for implementation-defined server-errors.
19
- * For tRPC we're copying the last digits of HTTP 4XX errors.
20
- */ const TRPC_ERROR_CODES_BY_KEY = {
21
- /**
22
- * Invalid JSON was received by the server.
23
- * An error occurred on the server while parsing the JSON text.
24
- */ PARSE_ERROR: -32700,
25
- /**
26
- * The JSON sent is not a valid Request object.
27
- */ BAD_REQUEST: -32600,
28
- // Internal JSON-RPC error
29
- INTERNAL_SERVER_ERROR: -32603,
30
- NOT_IMPLEMENTED: -32603,
31
- // Implementation specific errors
32
- UNAUTHORIZED: -32001,
33
- FORBIDDEN: -32003,
34
- NOT_FOUND: -32004,
35
- METHOD_NOT_SUPPORTED: -32005,
36
- TIMEOUT: -32008,
37
- CONFLICT: -32009,
38
- PRECONDITION_FAILED: -32012,
39
- PAYLOAD_TOO_LARGE: -32013,
40
- UNPROCESSABLE_CONTENT: -32022,
41
- TOO_MANY_REQUESTS: -32029,
42
- CLIENT_CLOSED_REQUEST: -32099
43
- };
44
- const TRPC_ERROR_CODES_BY_NUMBER = invert(TRPC_ERROR_CODES_BY_KEY);
45
-
46
- exports.TRPC_ERROR_CODES_BY_KEY = TRPC_ERROR_CODES_BY_KEY;
47
- exports.TRPC_ERROR_CODES_BY_NUMBER = TRPC_ERROR_CODES_BY_NUMBER;
48
- exports.invert = invert;
@@ -1,44 +0,0 @@
1
- /**
2
- * @internal
3
- */ function invert(obj) {
4
- const newObj = Object.create(null);
5
- for(const key in obj){
6
- const v = obj[key];
7
- newObj[v] = key;
8
- }
9
- return newObj;
10
- }
11
-
12
- // reference: https://www.jsonrpc.org/specification
13
- /**
14
- * JSON-RPC 2.0 Error codes
15
- *
16
- * `-32000` to `-32099` are reserved for implementation-defined server-errors.
17
- * For tRPC we're copying the last digits of HTTP 4XX errors.
18
- */ const TRPC_ERROR_CODES_BY_KEY = {
19
- /**
20
- * Invalid JSON was received by the server.
21
- * An error occurred on the server while parsing the JSON text.
22
- */ PARSE_ERROR: -32700,
23
- /**
24
- * The JSON sent is not a valid Request object.
25
- */ BAD_REQUEST: -32600,
26
- // Internal JSON-RPC error
27
- INTERNAL_SERVER_ERROR: -32603,
28
- NOT_IMPLEMENTED: -32603,
29
- // Implementation specific errors
30
- UNAUTHORIZED: -32001,
31
- FORBIDDEN: -32003,
32
- NOT_FOUND: -32004,
33
- METHOD_NOT_SUPPORTED: -32005,
34
- TIMEOUT: -32008,
35
- CONFLICT: -32009,
36
- PRECONDITION_FAILED: -32012,
37
- PAYLOAD_TOO_LARGE: -32013,
38
- UNPROCESSABLE_CONTENT: -32022,
39
- TOO_MANY_REQUESTS: -32029,
40
- CLIENT_CLOSED_REQUEST: -32099
41
- };
42
- const TRPC_ERROR_CODES_BY_NUMBER = invert(TRPC_ERROR_CODES_BY_KEY);
43
-
44
- export { TRPC_ERROR_CODES_BY_KEY as T, TRPC_ERROR_CODES_BY_NUMBER as a, invert as i };
@@ -1,6 +0,0 @@
1
- /**
2
- * The default check to see if we're in a server
3
- */ const isServerDefault = typeof window === 'undefined' || 'Deno' in window || // eslint-disable-next-line @typescript-eslint/dot-notation
4
- globalThis.process?.env?.['NODE_ENV'] === 'test' || !!globalThis.process?.env?.['JEST_WORKER_ID'] || !!globalThis.process?.env?.['VITEST_WORKER_ID'];
5
-
6
- export { isServerDefault as i };
@@ -1,8 +0,0 @@
1
- 'use strict';
2
-
3
- /**
4
- * The default check to see if we're in a server
5
- */ const isServerDefault = typeof window === 'undefined' || 'Deno' in window || // eslint-disable-next-line @typescript-eslint/dot-notation
6
- globalThis.process?.env?.['NODE_ENV'] === 'test' || !!globalThis.process?.env?.['JEST_WORKER_ID'] || !!globalThis.process?.env?.['VITEST_WORKER_ID'];
7
-
8
- exports.isServerDefault = isServerDefault;
@@ -1,11 +0,0 @@
1
- /**
2
- * The default check to see if we're in a server
3
- */
4
- const isServerDefault = typeof window === 'undefined' ||
5
- 'Deno' in window ||
6
- // eslint-disable-next-line @typescript-eslint/dot-notation
7
- globalThis.process?.env?.['NODE_ENV'] === 'test' ||
8
- !!globalThis.process?.env?.['JEST_WORKER_ID'] ||
9
- !!globalThis.process?.env?.['VITEST_WORKER_ID'];
10
-
11
- export { isServerDefault as i };
@@ -1,58 +0,0 @@
1
- import { T as TRPCError } from './TRPCError-2bb6a7d0.js';
2
-
3
- function getRawProcedureInputOrThrow(opts) {
4
- const { req } = opts;
5
- try {
6
- if (req.method === 'GET') {
7
- if (!req.query.has('input')) {
8
- return undefined;
9
- }
10
- const raw = req.query.get('input');
11
- return JSON.parse(raw);
12
- }
13
- if (!opts.preprocessedBody && typeof req.body === 'string') {
14
- // A mutation with no inputs will have req.body === ''
15
- return req.body.length === 0 ? undefined : JSON.parse(req.body);
16
- }
17
- return req.body;
18
- }
19
- catch (cause) {
20
- throw new TRPCError({
21
- code: 'PARSE_ERROR',
22
- cause,
23
- });
24
- }
25
- }
26
- const deserializeInputValue = (rawValue, transformer) => {
27
- return typeof rawValue !== 'undefined'
28
- ? transformer.input.deserialize(rawValue)
29
- : rawValue;
30
- };
31
- const getJsonContentTypeInputs = (opts) => {
32
- const rawInput = getRawProcedureInputOrThrow(opts);
33
- const transformer = opts.router._def._config.transformer;
34
- if (!opts.isBatchCall) {
35
- return {
36
- 0: deserializeInputValue(rawInput, transformer),
37
- };
38
- }
39
- /* istanbul ignore if */
40
- if (rawInput == null ||
41
- typeof rawInput !== 'object' ||
42
- Array.isArray(rawInput)) {
43
- throw new TRPCError({
44
- code: 'BAD_REQUEST',
45
- message: '"input" needs to be an object when doing a batch call',
46
- });
47
- }
48
- const input = {};
49
- for (const key in rawInput) {
50
- const k = key;
51
- const rawValue = rawInput[k];
52
- const value = deserializeInputValue(rawValue, transformer);
53
- input[k] = value;
54
- }
55
- return input;
56
- };
57
-
58
- export { getJsonContentTypeInputs as g };