@trpc/server 11.0.0-alpha-tmp-export-from-main.211 → 11.0.0-alpha-tmp-export-from-main-nuke-core.229

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 (234) hide show
  1. package/dist/@trpc/server/http.d.ts +7 -0
  2. package/dist/@trpc/server/http.d.ts.map +1 -0
  3. package/dist/{@trpc-server.d.ts → @trpc/server/index.d.ts} +4 -4
  4. package/dist/@trpc/server/index.d.ts.map +1 -0
  5. package/dist/@trpc/server/rpc.d.ts +3 -0
  6. package/dist/@trpc/server/rpc.d.ts.map +1 -0
  7. package/dist/TRPCError-54f51dec.mjs +63 -0
  8. package/dist/TRPCError-6f02e18d.js +67 -0
  9. package/dist/TRPCError-792b0901.js +61 -0
  10. package/dist/adapters/aws-lambda/index.d.ts +1 -2
  11. package/dist/adapters/aws-lambda/index.d.ts.map +1 -1
  12. package/dist/adapters/aws-lambda/index.js +10 -7
  13. package/dist/adapters/aws-lambda/index.mjs +6 -3
  14. package/dist/adapters/aws-lambda/utils.d.ts +2 -3
  15. package/dist/adapters/aws-lambda/utils.d.ts.map +1 -1
  16. package/dist/adapters/express.d.ts +1 -2
  17. package/dist/adapters/express.d.ts.map +1 -1
  18. package/dist/adapters/express.js +8 -2
  19. package/dist/adapters/express.mjs +8 -2
  20. package/dist/adapters/fastify/fastifyRequestHandler.d.ts +2 -2
  21. package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +1 -1
  22. package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +1 -2
  23. package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
  24. package/dist/adapters/fastify/index.js +11 -4
  25. package/dist/adapters/fastify/index.mjs +9 -2
  26. package/dist/adapters/fetch/fetchRequestHandler.d.ts +1 -2
  27. package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +1 -1
  28. package/dist/adapters/fetch/index.js +9 -4
  29. package/dist/adapters/fetch/index.mjs +7 -2
  30. package/dist/adapters/fetch/types.d.ts +2 -3
  31. package/dist/adapters/fetch/types.d.ts.map +1 -1
  32. package/dist/adapters/next.d.ts +1 -2
  33. package/dist/adapters/next.d.ts.map +1 -1
  34. package/dist/adapters/next.js +10 -5
  35. package/dist/adapters/next.mjs +8 -3
  36. package/dist/adapters/node-http/content-type/json/getPostBody.d.ts +1 -1
  37. package/dist/adapters/node-http/content-type/json/getPostBody.d.ts.map +1 -1
  38. package/dist/adapters/node-http/content-type/json/index.js +5 -3
  39. package/dist/adapters/node-http/content-type/json/index.mjs +3 -1
  40. package/dist/adapters/node-http/index.js +8 -2
  41. package/dist/adapters/node-http/index.mjs +8 -2
  42. package/dist/adapters/node-http/internals/contentType.d.ts +2 -2
  43. package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +1 -2
  44. package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
  45. package/dist/adapters/node-http/types.d.ts +3 -4
  46. package/dist/adapters/node-http/types.d.ts.map +1 -1
  47. package/dist/adapters/standalone.d.ts +1 -2
  48. package/dist/adapters/standalone.d.ts.map +1 -1
  49. package/dist/adapters/standalone.js +9 -2
  50. package/dist/adapters/standalone.mjs +9 -2
  51. package/dist/adapters/ws.d.ts +3 -2
  52. package/dist/adapters/ws.d.ts.map +1 -1
  53. package/dist/adapters/ws.js +31 -26
  54. package/dist/adapters/ws.mjs +6 -1
  55. package/dist/batchStreamFormatter-1971db27.js +32 -0
  56. package/dist/batchStreamFormatter-378277dc.mjs +30 -0
  57. package/dist/batchStreamFormatter-4375dc8b.js +31 -0
  58. package/dist/bundle-analysis.json +757 -0
  59. package/dist/contentType-19471015.js +59 -0
  60. package/dist/contentType-2e62862d.mjs +52 -0
  61. package/dist/contentType-4cd0be82.js +54 -0
  62. package/dist/createProxy-562377d3.js +127 -0
  63. package/dist/createProxy-72161f42.js +116 -0
  64. package/dist/createProxy-f7ba8b4d.mjs +121 -0
  65. package/dist/http.d.ts +1 -6
  66. package/dist/http.d.ts.map +1 -1
  67. package/dist/http.js +12 -21
  68. package/dist/http.mjs +7 -1
  69. package/dist/index.d.ts +1 -1
  70. package/dist/index.js +15 -41
  71. package/dist/index.mjs +5 -1
  72. package/dist/initTRPC-12d9099b.js +371 -0
  73. package/dist/initTRPC-69a60dfb.js +384 -0
  74. package/dist/initTRPC-dcdfb896.mjs +376 -0
  75. package/dist/{nodeHTTPRequestHandler-55f05150.js → nodeHTTPRequestHandler-71a3f758.js} +5 -4
  76. package/dist/{nodeHTTPRequestHandler-2d5c8791.mjs → nodeHTTPRequestHandler-c5d1d163.mjs} +3 -2
  77. package/dist/{nodeHTTPRequestHandler-7691fc79.js → nodeHTTPRequestHandler-f60f0b99.js} +3 -1
  78. package/dist/observable/index.d.ts +5 -0
  79. package/dist/observable/index.d.ts.map +1 -0
  80. package/dist/observable/index.js +110 -0
  81. package/dist/observable/index.mjs +101 -0
  82. package/dist/observable/observable.d.ts +13 -0
  83. package/dist/observable/observable.d.ts.map +1 -0
  84. package/dist/observable/operators.d.ts +8 -0
  85. package/dist/observable/operators.d.ts.map +1 -0
  86. package/dist/observable/types.d.ts +26 -0
  87. package/dist/observable/types.d.ts.map +1 -0
  88. package/dist/observable-25f4098f.js +126 -0
  89. package/dist/observable-bf75028f.mjs +122 -0
  90. package/dist/observable-e837fe43.js +126 -0
  91. package/dist/parseTRPCMessage-aeb00dbd.js +67 -0
  92. package/dist/parseTRPCMessage-ddbcc719.mjs +62 -0
  93. package/dist/parseTRPCMessage-ee50b281.js +65 -0
  94. package/dist/resolveHTTPResponse-104460bf.js +293 -0
  95. package/dist/resolveHTTPResponse-6a85f0a7.js +265 -0
  96. package/dist/resolveHTTPResponse-eb29e5cf.mjs +291 -0
  97. package/dist/rootConfig-52aed7d7.js +88 -0
  98. package/dist/rootConfig-7d3e1fc8.mjs +76 -0
  99. package/dist/rootConfig-ccd626d6.js +83 -0
  100. package/dist/router-5a3e1181.mjs +252 -0
  101. package/dist/router-5e93cd14.js +259 -0
  102. package/dist/router-d9e22315.js +262 -0
  103. package/dist/rpc.d.ts +1 -2
  104. package/dist/rpc.d.ts.map +1 -1
  105. package/dist/rpc.js +5 -13
  106. package/dist/rpc.mjs +2 -1
  107. package/dist/shared.d.ts +1 -1
  108. package/dist/shared.js +4 -9
  109. package/dist/shared.mjs +2 -1
  110. package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts +6 -0
  111. package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts.map +1 -0
  112. package/dist/unstable-core-do-not-import/createProxy.d.ts +19 -0
  113. package/dist/unstable-core-do-not-import/createProxy.d.ts.map +1 -0
  114. package/dist/unstable-core-do-not-import/error/TRPCError.d.ts +13 -0
  115. package/dist/unstable-core-do-not-import/error/TRPCError.d.ts.map +1 -0
  116. package/dist/unstable-core-do-not-import/error/formatter.d.ts +33 -0
  117. package/dist/unstable-core-do-not-import/error/formatter.d.ts.map +1 -0
  118. package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts +15 -0
  119. package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts.map +1 -0
  120. package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts +24 -0
  121. package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts.map +1 -0
  122. package/dist/unstable-core-do-not-import/http/contentType.d.ts +29 -0
  123. package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +1 -0
  124. package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts +5 -0
  125. package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +1 -0
  126. package/dist/unstable-core-do-not-import/http/index.d.ts +7 -0
  127. package/dist/unstable-core-do-not-import/http/index.d.ts.map +1 -0
  128. package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts +51 -0
  129. package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts.map +1 -0
  130. package/dist/unstable-core-do-not-import/http/types.d.ts +96 -0
  131. package/dist/unstable-core-do-not-import/http/types.d.ts.map +1 -0
  132. package/dist/unstable-core-do-not-import/index.d.ts +37 -0
  133. package/dist/unstable-core-do-not-import/index.d.ts.map +1 -0
  134. package/dist/unstable-core-do-not-import/index.js +43 -0
  135. package/dist/unstable-core-do-not-import/index.mjs +9 -0
  136. package/dist/unstable-core-do-not-import/initTRPC.d.ts +96 -0
  137. package/dist/unstable-core-do-not-import/initTRPC.d.ts.map +1 -0
  138. package/dist/unstable-core-do-not-import/middleware.d.ts +105 -0
  139. package/dist/unstable-core-do-not-import/middleware.d.ts.map +1 -0
  140. package/dist/unstable-core-do-not-import/parser.d.ts +30 -0
  141. package/dist/unstable-core-do-not-import/parser.d.ts.map +1 -0
  142. package/dist/unstable-core-do-not-import/procedure.d.ts +72 -0
  143. package/dist/unstable-core-do-not-import/procedure.d.ts.map +1 -0
  144. package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +101 -0
  145. package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +1 -0
  146. package/dist/unstable-core-do-not-import/rootConfig.d.ts +75 -0
  147. package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +1 -0
  148. package/dist/unstable-core-do-not-import/router.d.ts +85 -0
  149. package/dist/unstable-core-do-not-import/router.d.ts.map +1 -0
  150. package/dist/unstable-core-do-not-import/rpc/codes.d.ts +51 -0
  151. package/dist/unstable-core-do-not-import/rpc/codes.d.ts.map +1 -0
  152. package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts +97 -0
  153. package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts.map +1 -0
  154. package/dist/unstable-core-do-not-import/rpc/index.d.ts +5 -0
  155. package/dist/unstable-core-do-not-import/rpc/index.d.ts.map +1 -0
  156. package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts +5 -0
  157. package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts.map +1 -0
  158. package/dist/unstable-core-do-not-import/serialize.d.ts +62 -0
  159. package/dist/unstable-core-do-not-import/serialize.d.ts.map +1 -0
  160. package/dist/unstable-core-do-not-import/transformer.d.ts +107 -0
  161. package/dist/unstable-core-do-not-import/transformer.d.ts.map +1 -0
  162. package/dist/unstable-core-do-not-import/types.d.ts +98 -0
  163. package/dist/unstable-core-do-not-import/types.d.ts.map +1 -0
  164. package/dist/unstable-core-do-not-import/utils.d.ts +27 -0
  165. package/dist/unstable-core-do-not-import/utils.d.ts.map +1 -0
  166. package/package.json +53 -125
  167. package/src/@trpc/server/http.ts +26 -0
  168. package/src/{@trpc-server.ts → @trpc/server/index.ts} +3 -3
  169. package/src/@trpc/server/rpc.ts +26 -0
  170. package/src/adapters/aws-lambda/index.ts +4 -5
  171. package/src/adapters/aws-lambda/utils.ts +3 -4
  172. package/src/adapters/express.ts +1 -3
  173. package/src/adapters/fastify/fastifyRequestHandler.ts +6 -4
  174. package/src/adapters/fastify/fastifyTRPCPlugin.ts +1 -2
  175. package/src/adapters/fetch/fetchRequestHandler.ts +6 -4
  176. package/src/adapters/fetch/types.ts +2 -3
  177. package/src/adapters/next.ts +2 -3
  178. package/src/adapters/node-http/content-type/form-data/index.ts +1 -1
  179. package/src/adapters/node-http/content-type/json/getPostBody.ts +2 -2
  180. package/src/adapters/node-http/content-type/json/index.ts +1 -1
  181. package/src/adapters/node-http/internals/contentType.ts +2 -2
  182. package/src/adapters/node-http/nodeHTTPRequestHandler.ts +6 -4
  183. package/src/adapters/node-http/types.ts +4 -5
  184. package/src/adapters/standalone.ts +2 -2
  185. package/src/adapters/ws.ts +14 -13
  186. package/src/http.ts +1 -26
  187. package/src/index.ts +1 -1
  188. package/src/observable/index.ts +10 -0
  189. package/src/observable/observable.ts +158 -0
  190. package/src/observable/operators.ts +119 -0
  191. package/src/observable/types.ts +76 -0
  192. package/src/rpc.ts +1 -26
  193. package/src/shared.ts +1 -1
  194. package/src/unstable-core-do-not-import/TRPCInferrable.ts +9 -0
  195. package/src/unstable-core-do-not-import/createProxy.ts +59 -0
  196. package/src/unstable-core-do-not-import/error/TRPCError.ts +82 -0
  197. package/src/unstable-core-do-not-import/error/formatter.ts +51 -0
  198. package/src/unstable-core-do-not-import/error/getErrorShape.ts +36 -0
  199. package/src/unstable-core-do-not-import/http/batchStreamFormatter.ts +29 -0
  200. package/src/unstable-core-do-not-import/http/contentType.ts +99 -0
  201. package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +57 -0
  202. package/src/unstable-core-do-not-import/http/index.ts +23 -0
  203. package/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts +458 -0
  204. package/src/unstable-core-do-not-import/http/types.ts +111 -0
  205. package/src/unstable-core-do-not-import/index.ts +110 -0
  206. package/src/unstable-core-do-not-import/initTRPC.ts +206 -0
  207. package/src/unstable-core-do-not-import/middleware.ts +233 -0
  208. package/src/unstable-core-do-not-import/parser.ts +94 -0
  209. package/src/unstable-core-do-not-import/procedure.ts +108 -0
  210. package/src/unstable-core-do-not-import/procedureBuilder.ts +458 -0
  211. package/src/unstable-core-do-not-import/rootConfig.ts +90 -0
  212. package/src/unstable-core-do-not-import/router.ts +370 -0
  213. package/src/unstable-core-do-not-import/rpc/codes.ts +44 -0
  214. package/src/unstable-core-do-not-import/rpc/envelopes.ts +136 -0
  215. package/src/unstable-core-do-not-import/rpc/index.ts +21 -0
  216. package/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts +85 -0
  217. package/src/unstable-core-do-not-import/serialize.ts +122 -0
  218. package/src/unstable-core-do-not-import/transformer.ts +202 -0
  219. package/src/unstable-core-do-not-import/types.ts +151 -0
  220. package/src/unstable-core-do-not-import/utils.ts +59 -0
  221. package/unstable-core-do-not-import/index.d.ts +1 -0
  222. package/unstable-core-do-not-import/index.js +1 -0
  223. package/dist/@trpc-core-unstable-do-not-import-this-please.d.ts +0 -9
  224. package/dist/@trpc-core-unstable-do-not-import-this-please.d.ts.map +0 -1
  225. package/dist/@trpc-server/http.d.ts +0 -2
  226. package/dist/@trpc-server/http.d.ts.map +0 -1
  227. package/dist/@trpc-server.d.ts.map +0 -1
  228. package/dist/observable.d.ts +0 -3
  229. package/dist/observable.d.ts.map +0 -1
  230. package/dist/observable.js +0 -32
  231. package/dist/observable.mjs +0 -1
  232. package/src/@trpc-core-unstable-do-not-import-this-please.ts +0 -9
  233. package/src/@trpc-server/http.ts +0 -2
  234. package/src/observable.ts +0 -16
@@ -0,0 +1,59 @@
1
+ import { T as TRPCError } from './TRPCError-792b0901.js';
2
+
3
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */
4
+ function getRawProcedureInputOrThrow(opts) {
5
+ const { req } = opts;
6
+ try {
7
+ if (req.method === 'GET') {
8
+ if (!req.query.has('input')) {
9
+ return undefined;
10
+ }
11
+ const raw = req.query.get('input');
12
+ return JSON.parse(raw);
13
+ }
14
+ if (!opts.preprocessedBody && typeof req.body === 'string') {
15
+ // A mutation with no inputs will have req.body === ''
16
+ return req.body.length === 0 ? undefined : JSON.parse(req.body);
17
+ }
18
+ return req.body;
19
+ }
20
+ catch (cause) {
21
+ throw new TRPCError({
22
+ code: 'PARSE_ERROR',
23
+ cause,
24
+ });
25
+ }
26
+ }
27
+ const deserializeInputValue = (rawValue, transformer) => {
28
+ return typeof rawValue !== 'undefined'
29
+ ? transformer.input.deserialize(rawValue)
30
+ : rawValue;
31
+ };
32
+ const getJsonContentTypeInputs = (opts) => {
33
+ const rawInput = getRawProcedureInputOrThrow(opts);
34
+ const transformer = opts.router._def._config.transformer;
35
+ if (!opts.isBatchCall) {
36
+ return {
37
+ 0: deserializeInputValue(rawInput, transformer),
38
+ };
39
+ }
40
+ /* istanbul ignore if */
41
+ if (rawInput == null ||
42
+ typeof rawInput !== 'object' ||
43
+ Array.isArray(rawInput)) {
44
+ throw new TRPCError({
45
+ code: 'BAD_REQUEST',
46
+ message: '"input" needs to be an object when doing a batch call',
47
+ });
48
+ }
49
+ const input = {};
50
+ for (const key in rawInput) {
51
+ const k = key;
52
+ const rawValue = rawInput[k];
53
+ const value = deserializeInputValue(rawValue, transformer);
54
+ input[k] = value;
55
+ }
56
+ return input;
57
+ };
58
+
59
+ export { getJsonContentTypeInputs as g };
@@ -0,0 +1,52 @@
1
+ import { T as TRPCError } from './TRPCError-54f51dec.mjs';
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
+ } catch (cause) {
19
+ throw new TRPCError({
20
+ code: 'PARSE_ERROR',
21
+ cause
22
+ });
23
+ }
24
+ }
25
+ const deserializeInputValue = (rawValue, transformer)=>{
26
+ return typeof rawValue !== 'undefined' ? transformer.input.deserialize(rawValue) : rawValue;
27
+ };
28
+ const getJsonContentTypeInputs = (opts)=>{
29
+ const rawInput = getRawProcedureInputOrThrow(opts);
30
+ const transformer = opts.router._def._config.transformer;
31
+ if (!opts.isBatchCall) {
32
+ return {
33
+ 0: deserializeInputValue(rawInput, transformer)
34
+ };
35
+ }
36
+ /* istanbul ignore if */ if (rawInput == null || typeof rawInput !== 'object' || Array.isArray(rawInput)) {
37
+ throw new TRPCError({
38
+ code: 'BAD_REQUEST',
39
+ message: '"input" needs to be an object when doing a batch call'
40
+ });
41
+ }
42
+ const input = {};
43
+ for(const key in rawInput){
44
+ const k = key;
45
+ const rawValue = rawInput[k];
46
+ const value = deserializeInputValue(rawValue, transformer);
47
+ input[k] = value;
48
+ }
49
+ return input;
50
+ };
51
+
52
+ export { getJsonContentTypeInputs as g };
@@ -0,0 +1,54 @@
1
+ 'use strict';
2
+
3
+ var TRPCError = require('./TRPCError-6f02e18d.js');
4
+
5
+ function getRawProcedureInputOrThrow(opts) {
6
+ const { req } = opts;
7
+ try {
8
+ if (req.method === 'GET') {
9
+ if (!req.query.has('input')) {
10
+ return undefined;
11
+ }
12
+ const raw = req.query.get('input');
13
+ return JSON.parse(raw);
14
+ }
15
+ if (!opts.preprocessedBody && typeof req.body === 'string') {
16
+ // A mutation with no inputs will have req.body === ''
17
+ return req.body.length === 0 ? undefined : JSON.parse(req.body);
18
+ }
19
+ return req.body;
20
+ } catch (cause) {
21
+ throw new TRPCError.TRPCError({
22
+ code: 'PARSE_ERROR',
23
+ cause
24
+ });
25
+ }
26
+ }
27
+ const deserializeInputValue = (rawValue, transformer)=>{
28
+ return typeof rawValue !== 'undefined' ? transformer.input.deserialize(rawValue) : rawValue;
29
+ };
30
+ const getJsonContentTypeInputs = (opts)=>{
31
+ const rawInput = getRawProcedureInputOrThrow(opts);
32
+ const transformer = opts.router._def._config.transformer;
33
+ if (!opts.isBatchCall) {
34
+ return {
35
+ 0: deserializeInputValue(rawInput, transformer)
36
+ };
37
+ }
38
+ /* istanbul ignore if */ if (rawInput == null || typeof rawInput !== 'object' || Array.isArray(rawInput)) {
39
+ throw new TRPCError.TRPCError({
40
+ code: 'BAD_REQUEST',
41
+ message: '"input" needs to be an object when doing a batch call'
42
+ });
43
+ }
44
+ const input = {};
45
+ for(const key in rawInput){
46
+ const k = key;
47
+ const rawValue = rawInput[k];
48
+ const value = deserializeInputValue(rawValue, transformer);
49
+ input[k] = value;
50
+ }
51
+ return input;
52
+ };
53
+
54
+ exports.getJsonContentTypeInputs = getJsonContentTypeInputs;
@@ -0,0 +1,127 @@
1
+ 'use strict';
2
+
3
+ var rootConfig = require('./rootConfig-ccd626d6.js');
4
+
5
+ const JSONRPC2_TO_HTTP_CODE = {
6
+ PARSE_ERROR: 400,
7
+ BAD_REQUEST: 400,
8
+ UNAUTHORIZED: 401,
9
+ NOT_FOUND: 404,
10
+ FORBIDDEN: 403,
11
+ METHOD_NOT_SUPPORTED: 405,
12
+ TIMEOUT: 408,
13
+ CONFLICT: 409,
14
+ PRECONDITION_FAILED: 412,
15
+ PAYLOAD_TOO_LARGE: 413,
16
+ UNPROCESSABLE_CONTENT: 422,
17
+ TOO_MANY_REQUESTS: 429,
18
+ CLIENT_CLOSED_REQUEST: 499,
19
+ INTERNAL_SERVER_ERROR: 500,
20
+ NOT_IMPLEMENTED: 501
21
+ };
22
+ function getStatusCodeFromKey(code) {
23
+ return JSONRPC2_TO_HTTP_CODE[code] ?? 500;
24
+ }
25
+ function getHTTPStatusCode(json) {
26
+ const arr = Array.isArray(json) ? json : [
27
+ json
28
+ ];
29
+ const httpStatuses = new Set(arr.map((res)=>{
30
+ if ('error' in res) {
31
+ const data = res.error.data;
32
+ if (typeof data['httpStatus'] === 'number') {
33
+ return data['httpStatus'];
34
+ }
35
+ const code = rootConfig.TRPC_ERROR_CODES_BY_NUMBER[res.error.code];
36
+ return getStatusCodeFromKey(code);
37
+ }
38
+ return 200;
39
+ }));
40
+ if (httpStatuses.size !== 1) {
41
+ return 207;
42
+ }
43
+ const httpStatus = httpStatuses.values().next().value;
44
+ return httpStatus;
45
+ }
46
+ function getHTTPStatusCodeFromError(error) {
47
+ return getStatusCodeFromKey(error.code);
48
+ }
49
+
50
+ /**
51
+ * @internal
52
+ */ function getErrorShape(opts) {
53
+ const { path , error , config } = opts;
54
+ const { code } = opts.error;
55
+ const shape = {
56
+ message: error.message,
57
+ code: rootConfig.TRPC_ERROR_CODES_BY_KEY[code],
58
+ data: {
59
+ code,
60
+ httpStatus: getHTTPStatusCodeFromError(error)
61
+ }
62
+ };
63
+ if (config.isDev && typeof opts.error.stack === 'string') {
64
+ shape.data.stack = opts.error.stack;
65
+ }
66
+ if (typeof path === 'string') {
67
+ shape.data.path = path;
68
+ }
69
+ return config.errorFormatter({
70
+ ...opts,
71
+ shape
72
+ });
73
+ }
74
+
75
+ const noop = ()=>{
76
+ // noop
77
+ };
78
+ function createInnerProxy(callback, path) {
79
+ const proxy = new Proxy(noop, {
80
+ get (_obj, key) {
81
+ if (typeof key !== 'string' || key === 'then') {
82
+ // special case for if the proxy is accidentally treated
83
+ // like a PromiseLike (like in `Promise.resolve(proxy)`)
84
+ return undefined;
85
+ }
86
+ return createInnerProxy(callback, [
87
+ ...path,
88
+ key
89
+ ]);
90
+ },
91
+ apply (_1, _2, args) {
92
+ const isApply = path[path.length - 1] === 'apply';
93
+ return callback({
94
+ args: isApply ? args.length >= 2 ? args[1] : [] : args,
95
+ path: isApply ? path.slice(0, -1) : path
96
+ });
97
+ }
98
+ });
99
+ return proxy;
100
+ }
101
+ /**
102
+ * Creates a proxy that calls the callback with the path and arguments
103
+ *
104
+ * @internal
105
+ */ const createRecursiveProxy = (callback)=>createInnerProxy(callback, []);
106
+ /**
107
+ * Used in place of `new Proxy` where each handler will map 1 level deep to another value.
108
+ *
109
+ * @internal
110
+ */ const createFlatProxy = (callback)=>{
111
+ return new Proxy(noop, {
112
+ get (_obj, name) {
113
+ if (typeof name !== 'string' || name === 'then') {
114
+ // special case for if the proxy is accidentally treated
115
+ // like a PromiseLike (like in `Promise.resolve(proxy)`)
116
+ return undefined;
117
+ }
118
+ return callback(name);
119
+ }
120
+ });
121
+ };
122
+
123
+ exports.createFlatProxy = createFlatProxy;
124
+ exports.createRecursiveProxy = createRecursiveProxy;
125
+ exports.getErrorShape = getErrorShape;
126
+ exports.getHTTPStatusCode = getHTTPStatusCode;
127
+ exports.getHTTPStatusCodeFromError = getHTTPStatusCodeFromError;
@@ -0,0 +1,116 @@
1
+ import { T as TRPC_ERROR_CODES_BY_NUMBER, a as TRPC_ERROR_CODES_BY_KEY } from './rootConfig-52aed7d7.js';
2
+
3
+ const JSONRPC2_TO_HTTP_CODE = {
4
+ PARSE_ERROR: 400,
5
+ BAD_REQUEST: 400,
6
+ UNAUTHORIZED: 401,
7
+ NOT_FOUND: 404,
8
+ FORBIDDEN: 403,
9
+ METHOD_NOT_SUPPORTED: 405,
10
+ TIMEOUT: 408,
11
+ CONFLICT: 409,
12
+ PRECONDITION_FAILED: 412,
13
+ PAYLOAD_TOO_LARGE: 413,
14
+ UNPROCESSABLE_CONTENT: 422,
15
+ TOO_MANY_REQUESTS: 429,
16
+ CLIENT_CLOSED_REQUEST: 499,
17
+ INTERNAL_SERVER_ERROR: 500,
18
+ NOT_IMPLEMENTED: 501,
19
+ };
20
+ function getStatusCodeFromKey(code) {
21
+ return JSONRPC2_TO_HTTP_CODE[code] ?? 500;
22
+ }
23
+ function getHTTPStatusCode(json) {
24
+ const arr = Array.isArray(json) ? json : [json];
25
+ const httpStatuses = new Set(arr.map((res) => {
26
+ if ('error' in res) {
27
+ const data = res.error.data;
28
+ if (typeof data['httpStatus'] === 'number') {
29
+ return data['httpStatus'];
30
+ }
31
+ const code = TRPC_ERROR_CODES_BY_NUMBER[res.error.code];
32
+ return getStatusCodeFromKey(code);
33
+ }
34
+ return 200;
35
+ }));
36
+ if (httpStatuses.size !== 1) {
37
+ return 207;
38
+ }
39
+ const httpStatus = httpStatuses.values().next().value;
40
+ return httpStatus;
41
+ }
42
+ function getHTTPStatusCodeFromError(error) {
43
+ return getStatusCodeFromKey(error.code);
44
+ }
45
+
46
+ /**
47
+ * @internal
48
+ */
49
+ function getErrorShape(opts) {
50
+ const { path, error, config } = opts;
51
+ const { code } = opts.error;
52
+ const shape = {
53
+ message: error.message,
54
+ code: TRPC_ERROR_CODES_BY_KEY[code],
55
+ data: {
56
+ code,
57
+ httpStatus: getHTTPStatusCodeFromError(error),
58
+ },
59
+ };
60
+ if (config.isDev && typeof opts.error.stack === 'string') {
61
+ shape.data.stack = opts.error.stack;
62
+ }
63
+ if (typeof path === 'string') {
64
+ shape.data.path = path;
65
+ }
66
+ return config.errorFormatter({ ...opts, shape });
67
+ }
68
+
69
+ const noop = () => {
70
+ // noop
71
+ };
72
+ function createInnerProxy(callback, path) {
73
+ const proxy = new Proxy(noop, {
74
+ get(_obj, key) {
75
+ if (typeof key !== 'string' || key === 'then') {
76
+ // special case for if the proxy is accidentally treated
77
+ // like a PromiseLike (like in `Promise.resolve(proxy)`)
78
+ return undefined;
79
+ }
80
+ return createInnerProxy(callback, [...path, key]);
81
+ },
82
+ apply(_1, _2, args) {
83
+ const isApply = path[path.length - 1] === 'apply';
84
+ return callback({
85
+ args: isApply ? (args.length >= 2 ? args[1] : []) : args,
86
+ path: isApply ? path.slice(0, -1) : path,
87
+ });
88
+ },
89
+ });
90
+ return proxy;
91
+ }
92
+ /**
93
+ * Creates a proxy that calls the callback with the path and arguments
94
+ *
95
+ * @internal
96
+ */
97
+ const createRecursiveProxy = (callback) => createInnerProxy(callback, []);
98
+ /**
99
+ * Used in place of `new Proxy` where each handler will map 1 level deep to another value.
100
+ *
101
+ * @internal
102
+ */
103
+ const createFlatProxy = (callback) => {
104
+ return new Proxy(noop, {
105
+ get(_obj, name) {
106
+ if (typeof name !== 'string' || name === 'then') {
107
+ // special case for if the proxy is accidentally treated
108
+ // like a PromiseLike (like in `Promise.resolve(proxy)`)
109
+ return undefined;
110
+ }
111
+ return callback(name);
112
+ },
113
+ });
114
+ };
115
+
116
+ export { getErrorShape as a, getHTTPStatusCodeFromError as b, createRecursiveProxy as c, createFlatProxy as d, getHTTPStatusCode as g };
@@ -0,0 +1,121 @@
1
+ import { T as TRPC_ERROR_CODES_BY_NUMBER, a as TRPC_ERROR_CODES_BY_KEY } from './rootConfig-7d3e1fc8.mjs';
2
+
3
+ const JSONRPC2_TO_HTTP_CODE = {
4
+ PARSE_ERROR: 400,
5
+ BAD_REQUEST: 400,
6
+ UNAUTHORIZED: 401,
7
+ NOT_FOUND: 404,
8
+ FORBIDDEN: 403,
9
+ METHOD_NOT_SUPPORTED: 405,
10
+ TIMEOUT: 408,
11
+ CONFLICT: 409,
12
+ PRECONDITION_FAILED: 412,
13
+ PAYLOAD_TOO_LARGE: 413,
14
+ UNPROCESSABLE_CONTENT: 422,
15
+ TOO_MANY_REQUESTS: 429,
16
+ CLIENT_CLOSED_REQUEST: 499,
17
+ INTERNAL_SERVER_ERROR: 500,
18
+ NOT_IMPLEMENTED: 501
19
+ };
20
+ function getStatusCodeFromKey(code) {
21
+ return JSONRPC2_TO_HTTP_CODE[code] ?? 500;
22
+ }
23
+ function getHTTPStatusCode(json) {
24
+ const arr = Array.isArray(json) ? json : [
25
+ json
26
+ ];
27
+ const httpStatuses = new Set(arr.map((res)=>{
28
+ if ('error' in res) {
29
+ const data = res.error.data;
30
+ if (typeof data['httpStatus'] === 'number') {
31
+ return data['httpStatus'];
32
+ }
33
+ const code = TRPC_ERROR_CODES_BY_NUMBER[res.error.code];
34
+ return getStatusCodeFromKey(code);
35
+ }
36
+ return 200;
37
+ }));
38
+ if (httpStatuses.size !== 1) {
39
+ return 207;
40
+ }
41
+ const httpStatus = httpStatuses.values().next().value;
42
+ return httpStatus;
43
+ }
44
+ function getHTTPStatusCodeFromError(error) {
45
+ return getStatusCodeFromKey(error.code);
46
+ }
47
+
48
+ /**
49
+ * @internal
50
+ */ function getErrorShape(opts) {
51
+ const { path , error , config } = opts;
52
+ const { code } = opts.error;
53
+ const shape = {
54
+ message: error.message,
55
+ code: TRPC_ERROR_CODES_BY_KEY[code],
56
+ data: {
57
+ code,
58
+ httpStatus: getHTTPStatusCodeFromError(error)
59
+ }
60
+ };
61
+ if (config.isDev && typeof opts.error.stack === 'string') {
62
+ shape.data.stack = opts.error.stack;
63
+ }
64
+ if (typeof path === 'string') {
65
+ shape.data.path = path;
66
+ }
67
+ return config.errorFormatter({
68
+ ...opts,
69
+ shape
70
+ });
71
+ }
72
+
73
+ const noop = ()=>{
74
+ // noop
75
+ };
76
+ function createInnerProxy(callback, path) {
77
+ const proxy = new Proxy(noop, {
78
+ get (_obj, key) {
79
+ if (typeof key !== 'string' || key === 'then') {
80
+ // special case for if the proxy is accidentally treated
81
+ // like a PromiseLike (like in `Promise.resolve(proxy)`)
82
+ return undefined;
83
+ }
84
+ return createInnerProxy(callback, [
85
+ ...path,
86
+ key
87
+ ]);
88
+ },
89
+ apply (_1, _2, args) {
90
+ const isApply = path[path.length - 1] === 'apply';
91
+ return callback({
92
+ args: isApply ? args.length >= 2 ? args[1] : [] : args,
93
+ path: isApply ? path.slice(0, -1) : path
94
+ });
95
+ }
96
+ });
97
+ return proxy;
98
+ }
99
+ /**
100
+ * Creates a proxy that calls the callback with the path and arguments
101
+ *
102
+ * @internal
103
+ */ const createRecursiveProxy = (callback)=>createInnerProxy(callback, []);
104
+ /**
105
+ * Used in place of `new Proxy` where each handler will map 1 level deep to another value.
106
+ *
107
+ * @internal
108
+ */ const createFlatProxy = (callback)=>{
109
+ return new Proxy(noop, {
110
+ get (_obj, name) {
111
+ if (typeof name !== 'string' || name === 'then') {
112
+ // special case for if the proxy is accidentally treated
113
+ // like a PromiseLike (like in `Promise.resolve(proxy)`)
114
+ return undefined;
115
+ }
116
+ return callback(name);
117
+ }
118
+ });
119
+ };
120
+
121
+ export { getErrorShape as a, getHTTPStatusCodeFromError as b, createRecursiveProxy as c, createFlatProxy as d, getHTTPStatusCode as g };
package/dist/http.d.ts CHANGED
@@ -1,7 +1,2 @@
1
- export { getHTTPStatusCode, getHTTPStatusCodeFromError, } from './@trpc-core-unstable-do-not-import-this-please';
2
- export { resolveHTTPResponse } from './@trpc-core-unstable-do-not-import-this-please';
3
- export type { BaseHandlerOptions, HTTPBaseHandlerOptions, HTTPHeaders, HTTPRequest, HTTPResponse, OnErrorFunction, ProcedureCall, ResolveHTTPRequestOptionsContextFn, ResponseChunk, ResponseMeta, ResponseMetaFn, TRPCRequestInfo, } from './@trpc-core-unstable-do-not-import-this-please';
4
- export { getBatchStreamFormatter } from './@trpc-core-unstable-do-not-import-this-please';
5
- export type { BaseContentTypeHandler, BodyResult, } from './@trpc-core-unstable-do-not-import-this-please';
6
- export { getJsonContentTypeInputs } from './@trpc-core-unstable-do-not-import-this-please';
1
+ export * from './@trpc/server/http';
7
2
  //# sourceMappingURL=http.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iDAAiD,CAAC;AACtF,YAAY,EACV,kBAAkB,EAClB,sBAAsB,EACtB,WAAW,EACX,WAAW,EACX,YAAY,EACZ,eAAe,EACf,aAAa,EACb,kCAAkC,EAClC,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,GAChB,MAAM,iDAAiD,CAAC;AAEzD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iDAAiD,CAAC;AAC1F,YAAY,EACV,sBAAsB,EACtB,UAAU,GACX,MAAM,iDAAiD,CAAC;AACzD,OAAO,EAAE,wBAAwB,EAAE,MAAM,iDAAiD,CAAC"}
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAAA,cAAc,qBAAqB,CAAC"}
package/dist/http.js CHANGED
@@ -2,27 +2,18 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var core = require('@trpc/core');
5
+ var createProxy = require('./createProxy-562377d3.js');
6
+ require('./rootConfig-ccd626d6.js');
7
+ var resolveHTTPResponse = require('./resolveHTTPResponse-104460bf.js');
8
+ var batchStreamFormatter = require('./batchStreamFormatter-1971db27.js');
9
+ var contentType = require('./contentType-4cd0be82.js');
10
+ require('./TRPCError-6f02e18d.js');
11
+ require('./router-d9e22315.js');
6
12
 
7
13
 
8
14
 
9
- Object.defineProperty(exports, 'getBatchStreamFormatter', {
10
- enumerable: true,
11
- get: function () { return core.getBatchStreamFormatter; }
12
- });
13
- Object.defineProperty(exports, 'getHTTPStatusCode', {
14
- enumerable: true,
15
- get: function () { return core.getHTTPStatusCode; }
16
- });
17
- Object.defineProperty(exports, 'getHTTPStatusCodeFromError', {
18
- enumerable: true,
19
- get: function () { return core.getHTTPStatusCodeFromError; }
20
- });
21
- Object.defineProperty(exports, 'getJsonContentTypeInputs', {
22
- enumerable: true,
23
- get: function () { return core.getJsonContentTypeInputs; }
24
- });
25
- Object.defineProperty(exports, 'resolveHTTPResponse', {
26
- enumerable: true,
27
- get: function () { return core.resolveHTTPResponse; }
28
- });
15
+ exports.getHTTPStatusCode = createProxy.getHTTPStatusCode;
16
+ exports.getHTTPStatusCodeFromError = createProxy.getHTTPStatusCodeFromError;
17
+ exports.resolveHTTPResponse = resolveHTTPResponse.resolveHTTPResponse;
18
+ exports.getBatchStreamFormatter = batchStreamFormatter.getBatchStreamFormatter;
19
+ exports.getJsonContentTypeInputs = contentType.getJsonContentTypeInputs;
package/dist/http.mjs CHANGED
@@ -1 +1,7 @@
1
- export { getBatchStreamFormatter, getHTTPStatusCode, getHTTPStatusCodeFromError, getJsonContentTypeInputs, resolveHTTPResponse } from '@trpc/core';
1
+ export { g as getHTTPStatusCode, b as getHTTPStatusCodeFromError } from './createProxy-f7ba8b4d.mjs';
2
+ import './rootConfig-7d3e1fc8.mjs';
3
+ export { r as resolveHTTPResponse } from './resolveHTTPResponse-eb29e5cf.mjs';
4
+ export { g as getBatchStreamFormatter } from './batchStreamFormatter-378277dc.mjs';
5
+ export { g as getJsonContentTypeInputs } from './contentType-2e62862d.mjs';
6
+ import './TRPCError-54f51dec.mjs';
7
+ import './router-5a3e1181.mjs';
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export * from './@trpc-server';
1
+ export * from './@trpc/server';
2
2
  //# sourceMappingURL=index.d.ts.map
package/dist/index.js CHANGED
@@ -2,47 +2,21 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var core = require('@trpc/core');
5
+ var createProxy = require('./createProxy-562377d3.js');
6
+ var TRPCError = require('./TRPCError-6f02e18d.js');
7
+ var initTRPC = require('./initTRPC-69a60dfb.js');
8
+ var router = require('./router-d9e22315.js');
9
+ require('./rootConfig-ccd626d6.js');
6
10
 
7
11
 
8
12
 
9
- Object.defineProperty(exports, 'TRPCError', {
10
- enumerable: true,
11
- get: function () { return core.TRPCError; }
12
- });
13
- Object.defineProperty(exports, 'callProcedure', {
14
- enumerable: true,
15
- get: function () { return core.callProcedure; }
16
- });
17
- Object.defineProperty(exports, 'callTRPCProcedure', {
18
- enumerable: true,
19
- get: function () { return core.callProcedure; }
20
- });
21
- Object.defineProperty(exports, 'createTRPCFlatProxy', {
22
- enumerable: true,
23
- get: function () { return core.createFlatProxy; }
24
- });
25
- Object.defineProperty(exports, 'experimental_standaloneMiddleware', {
26
- enumerable: true,
27
- get: function () { return core.experimental_standaloneMiddleware; }
28
- });
29
- Object.defineProperty(exports, 'experimental_trpcMiddleware', {
30
- enumerable: true,
31
- get: function () { return core.experimental_standaloneMiddleware; }
32
- });
33
- Object.defineProperty(exports, 'getErrorShape', {
34
- enumerable: true,
35
- get: function () { return core.getErrorShape; }
36
- });
37
- Object.defineProperty(exports, 'getTRPCErrorFromUnknown', {
38
- enumerable: true,
39
- get: function () { return core.getTRPCErrorFromUnknown; }
40
- });
41
- Object.defineProperty(exports, 'initTRPC', {
42
- enumerable: true,
43
- get: function () { return core.initTRPC; }
44
- });
45
- Object.defineProperty(exports, 'transformTRPCResponse', {
46
- enumerable: true,
47
- get: function () { return core.transformTRPCResponse; }
48
- });
13
+ exports.createTRPCFlatProxy = createProxy.createFlatProxy;
14
+ exports.getErrorShape = createProxy.getErrorShape;
15
+ exports.TRPCError = TRPCError.TRPCError;
16
+ exports.getTRPCErrorFromUnknown = TRPCError.getTRPCErrorFromUnknown;
17
+ exports.experimental_standaloneMiddleware = initTRPC.experimental_standaloneMiddleware;
18
+ exports.experimental_trpcMiddleware = initTRPC.experimental_standaloneMiddleware;
19
+ exports.initTRPC = initTRPC.initTRPC;
20
+ exports.callProcedure = router.callProcedure;
21
+ exports.callTRPCProcedure = router.callProcedure;
22
+ exports.transformTRPCResponse = router.transformTRPCResponse;
package/dist/index.mjs CHANGED
@@ -1 +1,5 @@
1
- export { TRPCError, callProcedure, callProcedure as callTRPCProcedure, createFlatProxy as createTRPCFlatProxy, experimental_standaloneMiddleware, experimental_standaloneMiddleware as experimental_trpcMiddleware, getErrorShape, getTRPCErrorFromUnknown, initTRPC, transformTRPCResponse } from '@trpc/core';
1
+ export { d as createTRPCFlatProxy, a as getErrorShape } from './createProxy-f7ba8b4d.mjs';
2
+ export { T as TRPCError, g as getTRPCErrorFromUnknown } from './TRPCError-54f51dec.mjs';
3
+ export { e as experimental_standaloneMiddleware, e as experimental_trpcMiddleware, i as initTRPC } from './initTRPC-dcdfb896.mjs';
4
+ export { c as callProcedure, c as callTRPCProcedure, t as transformTRPCResponse } from './router-5a3e1181.mjs';
5
+ import './rootConfig-7d3e1fc8.mjs';