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

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-core-unstable-do-not-import-this-please.d.ts +10 -0
  2. package/dist/@trpc-core-unstable-do-not-import-this-please.d.ts.map +1 -0
  3. package/dist/@trpc-server/http.d.ts +2 -0
  4. package/dist/@trpc-server/http.d.ts.map +1 -0
  5. package/dist/{@trpc/server/index.d.ts → @trpc-server.d.ts} +4 -4
  6. package/dist/@trpc-server.d.ts.map +1 -0
  7. package/dist/adapters/aws-lambda/index.d.ts +2 -1
  8. package/dist/adapters/aws-lambda/index.d.ts.map +1 -1
  9. package/dist/adapters/aws-lambda/index.js +7 -10
  10. package/dist/adapters/aws-lambda/index.mjs +3 -6
  11. package/dist/adapters/aws-lambda/utils.d.ts +3 -2
  12. package/dist/adapters/aws-lambda/utils.d.ts.map +1 -1
  13. package/dist/adapters/express.d.ts +2 -1
  14. package/dist/adapters/express.d.ts.map +1 -1
  15. package/dist/adapters/express.js +2 -8
  16. package/dist/adapters/express.mjs +2 -8
  17. package/dist/adapters/fastify/fastifyRequestHandler.d.ts +2 -2
  18. package/dist/adapters/fastify/fastifyRequestHandler.d.ts.map +1 -1
  19. package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +2 -1
  20. package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts.map +1 -1
  21. package/dist/adapters/fastify/index.js +4 -11
  22. package/dist/adapters/fastify/index.mjs +2 -9
  23. package/dist/adapters/fetch/fetchRequestHandler.d.ts +2 -1
  24. package/dist/adapters/fetch/fetchRequestHandler.d.ts.map +1 -1
  25. package/dist/adapters/fetch/index.js +4 -9
  26. package/dist/adapters/fetch/index.mjs +2 -7
  27. package/dist/adapters/fetch/types.d.ts +3 -2
  28. package/dist/adapters/fetch/types.d.ts.map +1 -1
  29. package/dist/adapters/next.d.ts +2 -1
  30. package/dist/adapters/next.d.ts.map +1 -1
  31. package/dist/adapters/next.js +5 -10
  32. package/dist/adapters/next.mjs +3 -8
  33. package/dist/adapters/node-http/content-type/json/getPostBody.d.ts +1 -1
  34. package/dist/adapters/node-http/content-type/json/getPostBody.d.ts.map +1 -1
  35. package/dist/adapters/node-http/content-type/json/index.js +3 -5
  36. package/dist/adapters/node-http/content-type/json/index.mjs +1 -3
  37. package/dist/adapters/node-http/index.js +2 -8
  38. package/dist/adapters/node-http/index.mjs +2 -8
  39. package/dist/adapters/node-http/internals/contentType.d.ts +2 -2
  40. package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +2 -1
  41. package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
  42. package/dist/adapters/node-http/types.d.ts +4 -3
  43. package/dist/adapters/node-http/types.d.ts.map +1 -1
  44. package/dist/adapters/standalone.d.ts +2 -1
  45. package/dist/adapters/standalone.d.ts.map +1 -1
  46. package/dist/adapters/standalone.js +2 -9
  47. package/dist/adapters/standalone.mjs +2 -9
  48. package/dist/adapters/ws.d.ts +2 -3
  49. package/dist/adapters/ws.d.ts.map +1 -1
  50. package/dist/adapters/ws.js +26 -31
  51. package/dist/adapters/ws.mjs +1 -6
  52. package/dist/http.d.ts +6 -1
  53. package/dist/http.d.ts.map +1 -1
  54. package/dist/http.js +21 -12
  55. package/dist/http.mjs +1 -7
  56. package/dist/index.d.ts +1 -1
  57. package/dist/index.js +41 -15
  58. package/dist/index.mjs +1 -5
  59. package/dist/{nodeHTTPRequestHandler-c5d1d163.mjs → nodeHTTPRequestHandler-2d5c8791.mjs} +2 -3
  60. package/dist/{nodeHTTPRequestHandler-71a3f758.js → nodeHTTPRequestHandler-55f05150.js} +4 -5
  61. package/dist/{nodeHTTPRequestHandler-f60f0b99.js → nodeHTTPRequestHandler-7691fc79.js} +1 -3
  62. package/dist/observable.d.ts +3 -0
  63. package/dist/observable.d.ts.map +1 -0
  64. package/dist/observable.js +32 -0
  65. package/dist/observable.mjs +1 -0
  66. package/dist/rpc.d.ts +2 -1
  67. package/dist/rpc.d.ts.map +1 -1
  68. package/dist/rpc.js +13 -5
  69. package/dist/rpc.mjs +1 -2
  70. package/dist/shared.d.ts +1 -1
  71. package/dist/shared.js +9 -4
  72. package/dist/shared.mjs +1 -2
  73. package/package.json +125 -53
  74. package/src/@trpc-core-unstable-do-not-import-this-please.ts +146 -0
  75. package/src/@trpc-server/http.ts +2 -0
  76. package/src/{@trpc/server/index.ts → @trpc-server.ts} +3 -3
  77. package/src/adapters/aws-lambda/index.ts +5 -4
  78. package/src/adapters/aws-lambda/utils.ts +4 -3
  79. package/src/adapters/express.ts +3 -1
  80. package/src/adapters/fastify/fastifyRequestHandler.ts +4 -6
  81. package/src/adapters/fastify/fastifyTRPCPlugin.ts +2 -1
  82. package/src/adapters/fetch/fetchRequestHandler.ts +4 -6
  83. package/src/adapters/fetch/types.ts +3 -2
  84. package/src/adapters/next.ts +3 -2
  85. package/src/adapters/node-http/content-type/form-data/index.ts +1 -1
  86. package/src/adapters/node-http/content-type/json/getPostBody.ts +2 -2
  87. package/src/adapters/node-http/content-type/json/index.ts +1 -1
  88. package/src/adapters/node-http/internals/contentType.ts +2 -2
  89. package/src/adapters/node-http/nodeHTTPRequestHandler.ts +4 -6
  90. package/src/adapters/node-http/types.ts +5 -4
  91. package/src/adapters/standalone.ts +2 -2
  92. package/src/adapters/ws.ts +13 -14
  93. package/src/http.ts +26 -1
  94. package/src/index.ts +1 -1
  95. package/src/observable.ts +16 -0
  96. package/src/rpc.ts +26 -1
  97. package/src/shared.ts +1 -1
  98. package/dist/@trpc/server/http.d.ts +0 -7
  99. package/dist/@trpc/server/http.d.ts.map +0 -1
  100. package/dist/@trpc/server/index.d.ts.map +0 -1
  101. package/dist/@trpc/server/rpc.d.ts +0 -3
  102. package/dist/@trpc/server/rpc.d.ts.map +0 -1
  103. package/dist/TRPCError-54f51dec.mjs +0 -63
  104. package/dist/TRPCError-6f02e18d.js +0 -67
  105. package/dist/TRPCError-792b0901.js +0 -61
  106. package/dist/batchStreamFormatter-1971db27.js +0 -32
  107. package/dist/batchStreamFormatter-378277dc.mjs +0 -30
  108. package/dist/batchStreamFormatter-4375dc8b.js +0 -31
  109. package/dist/bundle-analysis.json +0 -757
  110. package/dist/contentType-19471015.js +0 -59
  111. package/dist/contentType-2e62862d.mjs +0 -52
  112. package/dist/contentType-4cd0be82.js +0 -54
  113. package/dist/createProxy-562377d3.js +0 -127
  114. package/dist/createProxy-72161f42.js +0 -116
  115. package/dist/createProxy-f7ba8b4d.mjs +0 -121
  116. package/dist/initTRPC-12d9099b.js +0 -371
  117. package/dist/initTRPC-69a60dfb.js +0 -384
  118. package/dist/initTRPC-dcdfb896.mjs +0 -376
  119. package/dist/observable/index.d.ts +0 -5
  120. package/dist/observable/index.d.ts.map +0 -1
  121. package/dist/observable/index.js +0 -110
  122. package/dist/observable/index.mjs +0 -101
  123. package/dist/observable/observable.d.ts +0 -13
  124. package/dist/observable/observable.d.ts.map +0 -1
  125. package/dist/observable/operators.d.ts +0 -8
  126. package/dist/observable/operators.d.ts.map +0 -1
  127. package/dist/observable/types.d.ts +0 -26
  128. package/dist/observable/types.d.ts.map +0 -1
  129. package/dist/observable-25f4098f.js +0 -126
  130. package/dist/observable-bf75028f.mjs +0 -122
  131. package/dist/observable-e837fe43.js +0 -126
  132. package/dist/parseTRPCMessage-aeb00dbd.js +0 -67
  133. package/dist/parseTRPCMessage-ddbcc719.mjs +0 -62
  134. package/dist/parseTRPCMessage-ee50b281.js +0 -65
  135. package/dist/resolveHTTPResponse-104460bf.js +0 -293
  136. package/dist/resolveHTTPResponse-6a85f0a7.js +0 -265
  137. package/dist/resolveHTTPResponse-eb29e5cf.mjs +0 -291
  138. package/dist/rootConfig-52aed7d7.js +0 -88
  139. package/dist/rootConfig-7d3e1fc8.mjs +0 -76
  140. package/dist/rootConfig-ccd626d6.js +0 -83
  141. package/dist/router-5a3e1181.mjs +0 -252
  142. package/dist/router-5e93cd14.js +0 -259
  143. package/dist/router-d9e22315.js +0 -262
  144. package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts +0 -6
  145. package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts.map +0 -1
  146. package/dist/unstable-core-do-not-import/createProxy.d.ts +0 -19
  147. package/dist/unstable-core-do-not-import/createProxy.d.ts.map +0 -1
  148. package/dist/unstable-core-do-not-import/error/TRPCError.d.ts +0 -13
  149. package/dist/unstable-core-do-not-import/error/TRPCError.d.ts.map +0 -1
  150. package/dist/unstable-core-do-not-import/error/formatter.d.ts +0 -33
  151. package/dist/unstable-core-do-not-import/error/formatter.d.ts.map +0 -1
  152. package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts +0 -15
  153. package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts.map +0 -1
  154. package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts +0 -24
  155. package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts.map +0 -1
  156. package/dist/unstable-core-do-not-import/http/contentType.d.ts +0 -29
  157. package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +0 -1
  158. package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts +0 -5
  159. package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +0 -1
  160. package/dist/unstable-core-do-not-import/http/index.d.ts +0 -7
  161. package/dist/unstable-core-do-not-import/http/index.d.ts.map +0 -1
  162. package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts +0 -51
  163. package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts.map +0 -1
  164. package/dist/unstable-core-do-not-import/http/types.d.ts +0 -96
  165. package/dist/unstable-core-do-not-import/http/types.d.ts.map +0 -1
  166. package/dist/unstable-core-do-not-import/index.d.ts +0 -37
  167. package/dist/unstable-core-do-not-import/index.d.ts.map +0 -1
  168. package/dist/unstable-core-do-not-import/index.js +0 -43
  169. package/dist/unstable-core-do-not-import/index.mjs +0 -9
  170. package/dist/unstable-core-do-not-import/initTRPC.d.ts +0 -96
  171. package/dist/unstable-core-do-not-import/initTRPC.d.ts.map +0 -1
  172. package/dist/unstable-core-do-not-import/middleware.d.ts +0 -105
  173. package/dist/unstable-core-do-not-import/middleware.d.ts.map +0 -1
  174. package/dist/unstable-core-do-not-import/parser.d.ts +0 -30
  175. package/dist/unstable-core-do-not-import/parser.d.ts.map +0 -1
  176. package/dist/unstable-core-do-not-import/procedure.d.ts +0 -72
  177. package/dist/unstable-core-do-not-import/procedure.d.ts.map +0 -1
  178. package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +0 -101
  179. package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +0 -1
  180. package/dist/unstable-core-do-not-import/rootConfig.d.ts +0 -75
  181. package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +0 -1
  182. package/dist/unstable-core-do-not-import/router.d.ts +0 -85
  183. package/dist/unstable-core-do-not-import/router.d.ts.map +0 -1
  184. package/dist/unstable-core-do-not-import/rpc/codes.d.ts +0 -51
  185. package/dist/unstable-core-do-not-import/rpc/codes.d.ts.map +0 -1
  186. package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts +0 -97
  187. package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts.map +0 -1
  188. package/dist/unstable-core-do-not-import/rpc/index.d.ts +0 -5
  189. package/dist/unstable-core-do-not-import/rpc/index.d.ts.map +0 -1
  190. package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts +0 -5
  191. package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts.map +0 -1
  192. package/dist/unstable-core-do-not-import/serialize.d.ts +0 -62
  193. package/dist/unstable-core-do-not-import/serialize.d.ts.map +0 -1
  194. package/dist/unstable-core-do-not-import/transformer.d.ts +0 -107
  195. package/dist/unstable-core-do-not-import/transformer.d.ts.map +0 -1
  196. package/dist/unstable-core-do-not-import/types.d.ts +0 -98
  197. package/dist/unstable-core-do-not-import/types.d.ts.map +0 -1
  198. package/dist/unstable-core-do-not-import/utils.d.ts +0 -27
  199. package/dist/unstable-core-do-not-import/utils.d.ts.map +0 -1
  200. package/src/@trpc/server/http.ts +0 -26
  201. package/src/@trpc/server/rpc.ts +0 -26
  202. package/src/observable/index.ts +0 -10
  203. package/src/observable/observable.ts +0 -158
  204. package/src/observable/operators.ts +0 -119
  205. package/src/observable/types.ts +0 -76
  206. package/src/unstable-core-do-not-import/TRPCInferrable.ts +0 -9
  207. package/src/unstable-core-do-not-import/createProxy.ts +0 -59
  208. package/src/unstable-core-do-not-import/error/TRPCError.ts +0 -82
  209. package/src/unstable-core-do-not-import/error/formatter.ts +0 -51
  210. package/src/unstable-core-do-not-import/error/getErrorShape.ts +0 -36
  211. package/src/unstable-core-do-not-import/http/batchStreamFormatter.ts +0 -29
  212. package/src/unstable-core-do-not-import/http/contentType.ts +0 -99
  213. package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +0 -57
  214. package/src/unstable-core-do-not-import/http/index.ts +0 -23
  215. package/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts +0 -458
  216. package/src/unstable-core-do-not-import/http/types.ts +0 -111
  217. package/src/unstable-core-do-not-import/index.ts +0 -110
  218. package/src/unstable-core-do-not-import/initTRPC.ts +0 -206
  219. package/src/unstable-core-do-not-import/middleware.ts +0 -233
  220. package/src/unstable-core-do-not-import/parser.ts +0 -94
  221. package/src/unstable-core-do-not-import/procedure.ts +0 -108
  222. package/src/unstable-core-do-not-import/procedureBuilder.ts +0 -458
  223. package/src/unstable-core-do-not-import/rootConfig.ts +0 -90
  224. package/src/unstable-core-do-not-import/router.ts +0 -370
  225. package/src/unstable-core-do-not-import/rpc/codes.ts +0 -44
  226. package/src/unstable-core-do-not-import/rpc/envelopes.ts +0 -136
  227. package/src/unstable-core-do-not-import/rpc/index.ts +0 -21
  228. package/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts +0 -85
  229. package/src/unstable-core-do-not-import/serialize.ts +0 -122
  230. package/src/unstable-core-do-not-import/transformer.ts +0 -202
  231. package/src/unstable-core-do-not-import/types.ts +0 -151
  232. package/src/unstable-core-do-not-import/utils.ts +0 -59
  233. package/unstable-core-do-not-import/index.d.ts +0 -1
  234. package/unstable-core-do-not-import/index.js +0 -1
@@ -1,59 +0,0 @@
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 };
@@ -1,52 +0,0 @@
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 };
@@ -1,54 +0,0 @@
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;
@@ -1,127 +0,0 @@
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;
@@ -1,116 +0,0 @@
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 };
@@ -1,121 +0,0 @@
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 };