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

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 (209) hide show
  1. package/dist/@trpc-core-unstable-do-not-import-this-please.d.ts +9 -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 +1 -1
  4. package/dist/@trpc-server/http.d.ts.map +1 -1
  5. package/dist/@trpc-server.d.ts +3 -3
  6. package/dist/@trpc-server.d.ts.map +1 -1
  7. package/dist/adapters/aws-lambda/index.d.ts +1 -1
  8. package/dist/adapters/aws-lambda/index.js +7 -13
  9. package/dist/adapters/aws-lambda/index.mjs +3 -9
  10. package/dist/adapters/aws-lambda/utils.d.ts +1 -1
  11. package/dist/adapters/express.d.ts +1 -1
  12. package/dist/adapters/express.d.ts.map +1 -1
  13. package/dist/adapters/express.js +2 -9
  14. package/dist/adapters/express.mjs +2 -9
  15. package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +1 -1
  16. package/dist/adapters/fastify/index.js +4 -13
  17. package/dist/adapters/fastify/index.mjs +2 -11
  18. package/dist/adapters/fetch/fetchRequestHandler.d.ts +1 -1
  19. package/dist/adapters/fetch/index.js +4 -11
  20. package/dist/adapters/fetch/index.mjs +2 -9
  21. package/dist/adapters/fetch/types.d.ts +1 -1
  22. package/dist/adapters/next.d.ts +1 -1
  23. package/dist/adapters/next.js +5 -12
  24. package/dist/adapters/next.mjs +3 -10
  25. package/dist/adapters/node-http/content-type/json/index.js +3 -6
  26. package/dist/adapters/node-http/content-type/json/index.mjs +1 -4
  27. package/dist/adapters/node-http/index.js +2 -9
  28. package/dist/adapters/node-http/index.mjs +2 -9
  29. package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +1 -1
  30. package/dist/adapters/node-http/types.d.ts +2 -2
  31. package/dist/adapters/node-http/types.d.ts.map +1 -1
  32. package/dist/adapters/standalone.d.ts +1 -1
  33. package/dist/adapters/standalone.js +2 -9
  34. package/dist/adapters/standalone.mjs +2 -9
  35. package/dist/adapters/ws.d.ts +1 -2
  36. package/dist/adapters/ws.d.ts.map +1 -1
  37. package/dist/adapters/ws.js +26 -32
  38. package/dist/adapters/ws.mjs +1 -7
  39. package/dist/http.d.ts +6 -6
  40. package/dist/http.d.ts.map +1 -1
  41. package/dist/http.js +21 -13
  42. package/dist/http.mjs +1 -8
  43. package/dist/index.js +41 -16
  44. package/dist/index.mjs +1 -6
  45. package/dist/{nodeHTTPRequestHandler-d8558115.mjs → nodeHTTPRequestHandler-2d5c8791.mjs} +2 -4
  46. package/dist/{nodeHTTPRequestHandler-0bc1dc41.js → nodeHTTPRequestHandler-55f05150.js} +4 -6
  47. package/dist/{nodeHTTPRequestHandler-c7d41cde.js → nodeHTTPRequestHandler-7691fc79.js} +1 -3
  48. package/dist/observable.d.ts +3 -0
  49. package/dist/observable.d.ts.map +1 -0
  50. package/dist/observable.js +32 -0
  51. package/dist/observable.mjs +1 -0
  52. package/dist/rpc.d.ts +2 -2
  53. package/dist/rpc.d.ts.map +1 -1
  54. package/dist/rpc.js +13 -6
  55. package/dist/rpc.mjs +1 -3
  56. package/dist/shared.js +9 -5
  57. package/dist/shared.mjs +1 -3
  58. package/package.json +125 -53
  59. package/src/@trpc-core-unstable-do-not-import-this-please.ts +9 -0
  60. package/src/@trpc-server/http.ts +1 -2
  61. package/src/@trpc-server.ts +3 -3
  62. package/src/adapters/aws-lambda/index.ts +1 -1
  63. package/src/adapters/aws-lambda/utils.ts +1 -1
  64. package/src/adapters/express.ts +2 -1
  65. package/src/adapters/fastify/fastifyRequestHandler.ts +1 -1
  66. package/src/adapters/fastify/fastifyTRPCPlugin.ts +1 -1
  67. package/src/adapters/fetch/fetchRequestHandler.ts +1 -1
  68. package/src/adapters/fetch/types.ts +1 -1
  69. package/src/adapters/next.ts +1 -1
  70. package/src/adapters/node-http/nodeHTTPRequestHandler.ts +1 -1
  71. package/src/adapters/node-http/types.ts +3 -2
  72. package/src/adapters/standalone.ts +1 -1
  73. package/src/adapters/ws.ts +10 -9
  74. package/src/http.ts +6 -6
  75. package/src/observable.ts +16 -0
  76. package/src/rpc.ts +2 -2
  77. package/dist/TRPCError-57838b33.js +0 -67
  78. package/dist/TRPCError-af754aba.mjs +0 -63
  79. package/dist/TRPCError-ebbde27d.js +0 -61
  80. package/dist/batchStreamFormatter-1971db27.js +0 -32
  81. package/dist/batchStreamFormatter-378277dc.mjs +0 -30
  82. package/dist/batchStreamFormatter-4375dc8b.js +0 -31
  83. package/dist/bundle-analysis.json +0 -770
  84. package/dist/contentType-9756da28.js +0 -59
  85. package/dist/contentType-b31eab56.js +0 -54
  86. package/dist/contentType-f93c6ba8.mjs +0 -52
  87. package/dist/createProxy-7293f632.mjs +0 -121
  88. package/dist/createProxy-c5cd21e8.js +0 -127
  89. package/dist/createProxy-f6960c7b.js +0 -116
  90. package/dist/initTRPC-6c16fa27.mjs +0 -377
  91. package/dist/initTRPC-8b5714ea.js +0 -385
  92. package/dist/initTRPC-b65b35e2.js +0 -372
  93. package/dist/observable/index.d.ts +0 -5
  94. package/dist/observable/index.d.ts.map +0 -1
  95. package/dist/observable/index.js +0 -111
  96. package/dist/observable/index.mjs +0 -102
  97. package/dist/observable/observable.d.ts +0 -13
  98. package/dist/observable/observable.d.ts.map +0 -1
  99. package/dist/observable/operators.d.ts +0 -8
  100. package/dist/observable/operators.d.ts.map +0 -1
  101. package/dist/observable/types.d.ts +0 -26
  102. package/dist/observable/types.d.ts.map +0 -1
  103. package/dist/observable-7233bd21.mjs +0 -121
  104. package/dist/observable-7865c812.js +0 -125
  105. package/dist/observable-cbbc588a.js +0 -125
  106. package/dist/parseTRPCMessage-3ae1b295.js +0 -67
  107. package/dist/parseTRPCMessage-abbd6862.mjs +0 -62
  108. package/dist/parseTRPCMessage-c6022e94.js +0 -65
  109. package/dist/resolveHTTPResponse-3133d603.js +0 -265
  110. package/dist/resolveHTTPResponse-80c99f62.mjs +0 -291
  111. package/dist/resolveHTTPResponse-9e260431.js +0 -293
  112. package/dist/rootConfig-a1ad09d0.js +0 -48
  113. package/dist/rootConfig-db88d377.js +0 -44
  114. package/dist/rootConfig-f741a4e7.mjs +0 -40
  115. package/dist/router-68063d64.mjs +0 -252
  116. package/dist/router-7a7bb4fd.js +0 -262
  117. package/dist/router-c5bd7780.js +0 -259
  118. package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts +0 -6
  119. package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts.map +0 -1
  120. package/dist/unstable-core-do-not-import/createProxy.d.ts +0 -19
  121. package/dist/unstable-core-do-not-import/createProxy.d.ts.map +0 -1
  122. package/dist/unstable-core-do-not-import/error/TRPCError.d.ts +0 -13
  123. package/dist/unstable-core-do-not-import/error/TRPCError.d.ts.map +0 -1
  124. package/dist/unstable-core-do-not-import/error/formatter.d.ts +0 -33
  125. package/dist/unstable-core-do-not-import/error/formatter.d.ts.map +0 -1
  126. package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts +0 -15
  127. package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts.map +0 -1
  128. package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts +0 -24
  129. package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts.map +0 -1
  130. package/dist/unstable-core-do-not-import/http/contentType.d.ts +0 -29
  131. package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +0 -1
  132. package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts +0 -5
  133. package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +0 -1
  134. package/dist/unstable-core-do-not-import/http/index.d.ts +0 -7
  135. package/dist/unstable-core-do-not-import/http/index.d.ts.map +0 -1
  136. package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts +0 -51
  137. package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts.map +0 -1
  138. package/dist/unstable-core-do-not-import/http/types.d.ts +0 -96
  139. package/dist/unstable-core-do-not-import/http/types.d.ts.map +0 -1
  140. package/dist/unstable-core-do-not-import/index.d.ts +0 -34
  141. package/dist/unstable-core-do-not-import/index.d.ts.map +0 -1
  142. package/dist/unstable-core-do-not-import/index.js +0 -44
  143. package/dist/unstable-core-do-not-import/index.mjs +0 -10
  144. package/dist/unstable-core-do-not-import/initTRPC.d.ts +0 -96
  145. package/dist/unstable-core-do-not-import/initTRPC.d.ts.map +0 -1
  146. package/dist/unstable-core-do-not-import/middleware.d.ts +0 -105
  147. package/dist/unstable-core-do-not-import/middleware.d.ts.map +0 -1
  148. package/dist/unstable-core-do-not-import/parser.d.ts +0 -30
  149. package/dist/unstable-core-do-not-import/parser.d.ts.map +0 -1
  150. package/dist/unstable-core-do-not-import/procedure.d.ts +0 -72
  151. package/dist/unstable-core-do-not-import/procedure.d.ts.map +0 -1
  152. package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +0 -101
  153. package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +0 -1
  154. package/dist/unstable-core-do-not-import/rootConfig.d.ts +0 -75
  155. package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +0 -1
  156. package/dist/unstable-core-do-not-import/router.d.ts +0 -85
  157. package/dist/unstable-core-do-not-import/router.d.ts.map +0 -1
  158. package/dist/unstable-core-do-not-import/rpc/codes.d.ts +0 -51
  159. package/dist/unstable-core-do-not-import/rpc/codes.d.ts.map +0 -1
  160. package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts +0 -97
  161. package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts.map +0 -1
  162. package/dist/unstable-core-do-not-import/rpc/index.d.ts +0 -5
  163. package/dist/unstable-core-do-not-import/rpc/index.d.ts.map +0 -1
  164. package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts +0 -5
  165. package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts.map +0 -1
  166. package/dist/unstable-core-do-not-import/serialize.d.ts +0 -62
  167. package/dist/unstable-core-do-not-import/serialize.d.ts.map +0 -1
  168. package/dist/unstable-core-do-not-import/transformer.d.ts +0 -107
  169. package/dist/unstable-core-do-not-import/transformer.d.ts.map +0 -1
  170. package/dist/unstable-core-do-not-import/types.d.ts +0 -98
  171. package/dist/unstable-core-do-not-import/types.d.ts.map +0 -1
  172. package/dist/unstable-core-do-not-import/utils.d.ts +0 -31
  173. package/dist/unstable-core-do-not-import/utils.d.ts.map +0 -1
  174. package/dist/utils-42a3ba6d.js +0 -50
  175. package/dist/utils-cf6178ec.mjs +0 -44
  176. package/dist/utils-e1d51fac.js +0 -49
  177. package/src/observable/index.ts +0 -10
  178. package/src/observable/observable.ts +0 -155
  179. package/src/observable/operators.ts +0 -119
  180. package/src/observable/types.ts +0 -76
  181. package/src/unstable-core-do-not-import/TRPCInferrable.ts +0 -9
  182. package/src/unstable-core-do-not-import/createProxy.ts +0 -59
  183. package/src/unstable-core-do-not-import/error/TRPCError.ts +0 -82
  184. package/src/unstable-core-do-not-import/error/formatter.ts +0 -51
  185. package/src/unstable-core-do-not-import/error/getErrorShape.ts +0 -36
  186. package/src/unstable-core-do-not-import/http/batchStreamFormatter.ts +0 -29
  187. package/src/unstable-core-do-not-import/http/contentType.ts +0 -99
  188. package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +0 -57
  189. package/src/unstable-core-do-not-import/http/index.ts +0 -23
  190. package/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts +0 -458
  191. package/src/unstable-core-do-not-import/http/types.ts +0 -111
  192. package/src/unstable-core-do-not-import/index.ts +0 -107
  193. package/src/unstable-core-do-not-import/initTRPC.ts +0 -206
  194. package/src/unstable-core-do-not-import/middleware.ts +0 -233
  195. package/src/unstable-core-do-not-import/parser.ts +0 -94
  196. package/src/unstable-core-do-not-import/procedure.ts +0 -108
  197. package/src/unstable-core-do-not-import/procedureBuilder.ts +0 -458
  198. package/src/unstable-core-do-not-import/rootConfig.ts +0 -90
  199. package/src/unstable-core-do-not-import/router.ts +0 -370
  200. package/src/unstable-core-do-not-import/rpc/codes.ts +0 -44
  201. package/src/unstable-core-do-not-import/rpc/envelopes.ts +0 -136
  202. package/src/unstable-core-do-not-import/rpc/index.ts +0 -21
  203. package/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts +0 -85
  204. package/src/unstable-core-do-not-import/serialize.ts +0 -122
  205. package/src/unstable-core-do-not-import/transformer.ts +0 -202
  206. package/src/unstable-core-do-not-import/types.ts +0 -151
  207. package/src/unstable-core-do-not-import/utils.ts +0 -66
  208. package/unstable-core-do-not-import/index.d.ts +0 -1
  209. package/unstable-core-do-not-import/index.js +0 -1
@@ -1,59 +0,0 @@
1
- import { T as TRPCError } from './TRPCError-ebbde27d.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,54 +0,0 @@
1
- 'use strict';
2
-
3
- var TRPCError = require('./TRPCError-57838b33.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,52 +0,0 @@
1
- import { T as TRPCError } from './TRPCError-af754aba.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,121 +0,0 @@
1
- import { T as TRPC_ERROR_CODES_BY_NUMBER, a as TRPC_ERROR_CODES_BY_KEY } from './rootConfig-f741a4e7.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 };
@@ -1,127 +0,0 @@
1
- 'use strict';
2
-
3
- var rootConfig = require('./rootConfig-db88d377.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-a1ad09d0.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 };