@trpc/server 11.0.0-next-beta.302 → 11.0.0-next-beta.303

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 (48) hide show
  1. package/dist/adapters/aws-lambda/index.js +0 -1
  2. package/dist/adapters/aws-lambda/index.mjs +0 -1
  3. package/dist/adapters/aws-lambda/utils.js +0 -1
  4. package/dist/adapters/aws-lambda/utils.mjs +0 -1
  5. package/dist/adapters/fastify/fastifyRequestHandler.js +0 -1
  6. package/dist/adapters/fastify/fastifyRequestHandler.mjs +0 -1
  7. package/dist/adapters/fetch/fetchRequestHandler.js +0 -1
  8. package/dist/adapters/fetch/fetchRequestHandler.mjs +0 -1
  9. package/dist/adapters/next.js +0 -1
  10. package/dist/adapters/next.mjs +0 -1
  11. package/dist/adapters/node-http/content-type/json/getPostBody.d.ts.map +1 -1
  12. package/dist/adapters/node-http/content-type/json/getPostBody.js +3 -4
  13. package/dist/adapters/node-http/content-type/json/getPostBody.mjs +3 -4
  14. package/dist/adapters/node-http/content-type/json/index.js +0 -1
  15. package/dist/adapters/node-http/content-type/json/index.mjs +0 -1
  16. package/dist/adapters/node-http/nodeHTTPRequestHandler.js +0 -1
  17. package/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +0 -1
  18. package/dist/adapters/standalone.js +0 -1
  19. package/dist/adapters/standalone.mjs +0 -1
  20. package/dist/adapters/ws.js +0 -1
  21. package/dist/adapters/ws.mjs +0 -1
  22. package/dist/bundle-analysis.json +76 -78
  23. package/dist/http.js +0 -1
  24. package/dist/http.mjs +0 -1
  25. package/dist/index.js +0 -1
  26. package/dist/index.mjs +0 -1
  27. package/dist/shared.js +0 -1
  28. package/dist/shared.mjs +0 -1
  29. package/dist/unstable-core-do-not-import/error/TRPCError.d.ts +1 -1
  30. package/dist/unstable-core-do-not-import/error/TRPCError.d.ts.map +1 -1
  31. package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +1 -1
  32. package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.js +1 -0
  33. package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.mjs +1 -0
  34. package/dist/unstable-core-do-not-import/rpc/codes.d.ts +8 -15
  35. package/dist/unstable-core-do-not-import/rpc/codes.d.ts.map +1 -1
  36. package/dist/unstable-core-do-not-import/rpc/codes.js +19 -3
  37. package/dist/unstable-core-do-not-import/rpc/codes.mjs +19 -3
  38. package/dist/unstable-core-do-not-import/utils.d.ts +0 -11
  39. package/dist/unstable-core-do-not-import/utils.d.ts.map +1 -1
  40. package/dist/unstable-core-do-not-import/utils.js +0 -11
  41. package/dist/unstable-core-do-not-import/utils.mjs +1 -11
  42. package/dist/unstable-core-do-not-import.js +0 -1
  43. package/dist/unstable-core-do-not-import.mjs +1 -1
  44. package/package.json +2 -2
  45. package/src/adapters/node-http/content-type/json/getPostBody.ts +6 -5
  46. package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +1 -0
  47. package/src/unstable-core-do-not-import/rpc/codes.ts +29 -2
  48. package/src/unstable-core-do-not-import/utils.ts +0 -21
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- require('../../unstable-core-do-not-import/rpc/codes.js');
4
3
  var TRPCError = require('../../unstable-core-do-not-import/error/TRPCError.js');
5
4
  var resolveHTTPResponse = require('../../unstable-core-do-not-import/http/resolveHTTPResponse.js');
6
5
  require('../../unstable-core-do-not-import/rootConfig.js');
@@ -1,4 +1,3 @@
1
- import '../../unstable-core-do-not-import/rpc/codes.mjs';
2
1
  import { TRPCError } from '../../unstable-core-do-not-import/error/TRPCError.mjs';
3
2
  import { resolveHTTPResponse } from '../../unstable-core-do-not-import/http/resolveHTTPResponse.mjs';
4
3
  import '../../unstable-core-do-not-import/rootConfig.mjs';
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- require('../../unstable-core-do-not-import/rpc/codes.js');
4
3
  var TRPCError = require('../../unstable-core-do-not-import/error/TRPCError.js');
5
4
  require('../../unstable-core-do-not-import/rootConfig.js');
6
5
 
@@ -1,4 +1,3 @@
1
- import '../../unstable-core-do-not-import/rpc/codes.mjs';
2
1
  import { TRPCError } from '../../unstable-core-do-not-import/error/TRPCError.mjs';
3
2
  import '../../unstable-core-do-not-import/rootConfig.mjs';
4
3
 
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var node_stream = require('node:stream');
4
- require('../../unstable-core-do-not-import/rpc/codes.js');
5
4
  var resolveHTTPResponse = require('../../unstable-core-do-not-import/http/resolveHTTPResponse.js');
6
5
  var batchStreamFormatter = require('../../unstable-core-do-not-import/http/batchStreamFormatter.js');
7
6
  require('../../unstable-core-do-not-import/rootConfig.js');
@@ -1,5 +1,4 @@
1
1
  import { Readable } from 'node:stream';
2
- import '../../unstable-core-do-not-import/rpc/codes.mjs';
3
2
  import { resolveHTTPResponse } from '../../unstable-core-do-not-import/http/resolveHTTPResponse.mjs';
4
3
  import { getBatchStreamFormatter } from '../../unstable-core-do-not-import/http/batchStreamFormatter.mjs';
5
4
  import '../../unstable-core-do-not-import/rootConfig.mjs';
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- require('../../unstable-core-do-not-import/rpc/codes.js');
4
3
  var resolveHTTPResponse = require('../../unstable-core-do-not-import/http/resolveHTTPResponse.js');
5
4
  var batchStreamFormatter = require('../../unstable-core-do-not-import/http/batchStreamFormatter.js');
6
5
  var toURL = require('../../unstable-core-do-not-import/http/toURL.js');
@@ -1,4 +1,3 @@
1
- import '../../unstable-core-do-not-import/rpc/codes.mjs';
2
1
  import { resolveHTTPResponse } from '../../unstable-core-do-not-import/http/resolveHTTPResponse.mjs';
3
2
  import { getBatchStreamFormatter } from '../../unstable-core-do-not-import/http/batchStreamFormatter.mjs';
4
3
  import { toURL } from '../../unstable-core-do-not-import/http/toURL.mjs';
@@ -2,7 +2,6 @@
2
2
 
3
3
  var getErrorShape = require('../unstable-core-do-not-import/error/getErrorShape.js');
4
4
  var TRPCError = require('../unstable-core-do-not-import/error/TRPCError.js');
5
- require('../unstable-core-do-not-import/rpc/codes.js');
6
5
  require('../unstable-core-do-not-import/rootConfig.js');
7
6
  var nodeHTTPRequestHandler = require('./node-http/nodeHTTPRequestHandler.js');
8
7
 
@@ -1,6 +1,5 @@
1
1
  import { getErrorShape } from '../unstable-core-do-not-import/error/getErrorShape.mjs';
2
2
  import { TRPCError } from '../unstable-core-do-not-import/error/TRPCError.mjs';
3
- import '../unstable-core-do-not-import/rpc/codes.mjs';
4
3
  import '../unstable-core-do-not-import/rootConfig.mjs';
5
4
  import { nodeHTTPRequestHandler } from './node-http/nodeHTTPRequestHandler.mjs';
6
5
 
@@ -1 +1 @@
1
- {"version":3,"file":"getPostBody.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/node-http/content-type/json/getPostBody.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,wBAAsB,WAAW,CAAC,IAAI,EAAE;IACtC,GAAG,EAAE,eAAe,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,UAAU,CAAC,CAgDtB"}
1
+ {"version":3,"file":"getPostBody.d.ts","sourceRoot":"","sources":["../../../../../src/adapters/node-http/content-type/json/getPostBody.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,wBAAsB,WAAW,CAAC,IAAI,EAAE;IACtC,GAAG,EAAE,eAAe,CAAC;IACrB,WAAW,CAAC,EAAE,MAAM,CAAC;CACtB,GAAG,OAAO,CAAC,UAAU,CAAC,CAiDtB"}
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- require('../../../../unstable-core-do-not-import/rpc/codes.js');
4
3
  var TRPCError = require('../../../../unstable-core-do-not-import/error/TRPCError.js');
5
4
  require('../../../../unstable-core-do-not-import/rootConfig.js');
6
5
 
@@ -8,12 +7,12 @@ require('../../../../unstable-core-do-not-import/rootConfig.js');
8
7
  async function getPostBody(opts) {
9
8
  const { req , maxBodySize =Infinity } = opts;
10
9
  return new Promise((resolve)=>{
11
- if (!req.headers['content-type']?.startsWith('application/json') && req.method !== 'GET' && req.method !== 'OPTIONS' && req.method !== 'HEAD') {
10
+ if (!req.headers['content-type']?.startsWith('application/json') && (!req.method || req.method !== 'GET' && req.method !== 'OPTIONS' && req.method !== 'HEAD')) {
12
11
  resolve({
13
12
  ok: false,
14
13
  error: new TRPCError.TRPCError({
15
- code: 'BAD_REQUEST',
16
- message: 'Invalid content-type header (expected application/json)'
14
+ code: 'UNSUPPORTED_MEDIA_TYPE',
15
+ message: 'Invalid Content-Type header (expected application/json)'
17
16
  })
18
17
  });
19
18
  return;
@@ -1,4 +1,3 @@
1
- import '../../../../unstable-core-do-not-import/rpc/codes.mjs';
2
1
  import { TRPCError } from '../../../../unstable-core-do-not-import/error/TRPCError.mjs';
3
2
  import '../../../../unstable-core-do-not-import/rootConfig.mjs';
4
3
 
@@ -6,12 +5,12 @@ import '../../../../unstable-core-do-not-import/rootConfig.mjs';
6
5
  async function getPostBody(opts) {
7
6
  const { req , maxBodySize =Infinity } = opts;
8
7
  return new Promise((resolve)=>{
9
- if (!req.headers['content-type']?.startsWith('application/json') && req.method !== 'GET' && req.method !== 'OPTIONS' && req.method !== 'HEAD') {
8
+ if (!req.headers['content-type']?.startsWith('application/json') && (!req.method || req.method !== 'GET' && req.method !== 'OPTIONS' && req.method !== 'HEAD')) {
10
9
  resolve({
11
10
  ok: false,
12
11
  error: new TRPCError({
13
- code: 'BAD_REQUEST',
14
- message: 'Invalid content-type header (expected application/json)'
12
+ code: 'UNSUPPORTED_MEDIA_TYPE',
13
+ message: 'Invalid Content-Type header (expected application/json)'
15
14
  })
16
15
  });
17
16
  return;
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- require('../../../../unstable-core-do-not-import/rpc/codes.js');
4
3
  var contentType$1 = require('../../../../unstable-core-do-not-import/http/contentType.js');
5
4
  require('../../../../unstable-core-do-not-import/rootConfig.js');
6
5
  var contentType = require('../../internals/contentType.js');
@@ -1,4 +1,3 @@
1
- import '../../../../unstable-core-do-not-import/rpc/codes.mjs';
2
1
  import { getJsonContentTypeInputs } from '../../../../unstable-core-do-not-import/http/contentType.mjs';
3
2
  import '../../../../unstable-core-do-not-import/rootConfig.mjs';
4
3
  import { createNodeHTTPContentTypeHandler } from '../../internals/contentType.mjs';
@@ -1,6 +1,5 @@
1
1
  'use strict';
2
2
 
3
- require('../../unstable-core-do-not-import/rpc/codes.js');
4
3
  var resolveHTTPResponse = require('../../unstable-core-do-not-import/http/resolveHTTPResponse.js');
5
4
  var batchStreamFormatter = require('../../unstable-core-do-not-import/http/batchStreamFormatter.js');
6
5
  require('../../unstable-core-do-not-import/rootConfig.js');
@@ -1,4 +1,3 @@
1
- import '../../unstable-core-do-not-import/rpc/codes.mjs';
2
1
  import { resolveHTTPResponse } from '../../unstable-core-do-not-import/http/resolveHTTPResponse.mjs';
3
2
  import { getBatchStreamFormatter } from '../../unstable-core-do-not-import/http/batchStreamFormatter.mjs';
4
3
  import '../../unstable-core-do-not-import/rootConfig.mjs';
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var http = require('node:http');
4
- require('../unstable-core-do-not-import/rpc/codes.js');
5
4
  var toURL = require('../unstable-core-do-not-import/http/toURL.js');
6
5
  require('../unstable-core-do-not-import/rootConfig.js');
7
6
  var nodeHTTPRequestHandler = require('./node-http/nodeHTTPRequestHandler.js');
@@ -1,5 +1,4 @@
1
1
  import http from 'node:http';
2
- import '../unstable-core-do-not-import/rpc/codes.mjs';
3
2
  import { toURL } from '../unstable-core-do-not-import/http/toURL.mjs';
4
3
  import '../unstable-core-do-not-import/rootConfig.mjs';
5
4
  import { nodeHTTPRequestHandler } from './node-http/nodeHTTPRequestHandler.mjs';
@@ -2,7 +2,6 @@
2
2
 
3
3
  var getErrorShape = require('../unstable-core-do-not-import/error/getErrorShape.js');
4
4
  var TRPCError = require('../unstable-core-do-not-import/error/TRPCError.js');
5
- require('../unstable-core-do-not-import/rpc/codes.js');
6
5
  var parseTRPCMessage = require('../unstable-core-do-not-import/rpc/parseTRPCMessage.js');
7
6
  var router = require('../unstable-core-do-not-import/router.js');
8
7
  var transformer = require('../unstable-core-do-not-import/transformer.js');
@@ -1,6 +1,5 @@
1
1
  import { getErrorShape } from '../unstable-core-do-not-import/error/getErrorShape.mjs';
2
2
  import { TRPCError, getTRPCErrorFromUnknown } from '../unstable-core-do-not-import/error/TRPCError.mjs';
3
- import '../unstable-core-do-not-import/rpc/codes.mjs';
4
3
  import { parseTRPCMessage } from '../unstable-core-do-not-import/rpc/parseTRPCMessage.mjs';
5
4
  import { callProcedure } from '../unstable-core-do-not-import/router.mjs';
6
5
  import { transformTRPCResponse } from '../unstable-core-do-not-import/transformer.mjs';
@@ -1,7 +1,7 @@
1
1
  {
2
- "bundleSize": 92734,
3
- "bundleOrigSize": 147860,
4
- "bundleReduction": 37.28,
2
+ "bundleSize": 93108,
3
+ "bundleOrigSize": 148167,
4
+ "bundleReduction": 37.16,
5
5
  "modules": [
6
6
  {
7
7
  "id": "/src/adapters/ws.ts",
@@ -14,7 +14,7 @@
14
14
  "dependents": [
15
15
  "/src/adapters/fastify/fastifyTRPCPlugin.ts"
16
16
  ],
17
- "percent": 10.75,
17
+ "percent": 10.71,
18
18
  "reduction": 0
19
19
  },
20
20
  {
@@ -26,7 +26,7 @@
26
26
  ],
27
27
  "removedExports": [],
28
28
  "dependents": [],
29
- "percent": 10.12,
29
+ "percent": 10.08,
30
30
  "reduction": 21.23
31
31
  },
32
32
  {
@@ -45,7 +45,7 @@
45
45
  "/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts",
46
46
  "/src/unstable-core-do-not-import/initTRPC.ts"
47
47
  ],
48
- "percent": 6.54,
48
+ "percent": 6.52,
49
49
  "reduction": 38.58
50
50
  },
51
51
  {
@@ -61,7 +61,7 @@
61
61
  "/src/unstable-core-do-not-import.ts",
62
62
  "/src/unstable-core-do-not-import/initTRPC.ts"
63
63
  ],
64
- "percent": 6.15,
64
+ "percent": 6.13,
65
65
  "reduction": 58.57
66
66
  },
67
67
  {
@@ -77,7 +77,7 @@
77
77
  "dependents": [
78
78
  "/src/adapters/node-http/content-type/form-data/index.ts"
79
79
  ],
80
- "percent": 5.37,
80
+ "percent": 5.35,
81
81
  "reduction": 36.77
82
82
  },
83
83
  {
@@ -91,7 +91,7 @@
91
91
  ],
92
92
  "removedExports": [],
93
93
  "dependents": [],
94
- "percent": 4.77,
94
+ "percent": 4.75,
95
95
  "reduction": 32.71
96
96
  },
97
97
  {
@@ -105,7 +105,7 @@
105
105
  "dependents": [
106
106
  "/src/adapters/node-http/index.ts"
107
107
  ],
108
- "percent": 4.24,
108
+ "percent": 4.22,
109
109
  "reduction": 13.56
110
110
  },
111
111
  {
@@ -119,7 +119,7 @@
119
119
  "dependents": [
120
120
  "/src/adapters/fetch/index.ts"
121
121
  ],
122
- "percent": 3.83,
122
+ "percent": 3.82,
123
123
  "reduction": 9.5
124
124
  },
125
125
  {
@@ -135,7 +135,7 @@
135
135
  "dependents": [
136
136
  "/src/observable/index.ts"
137
137
  ],
138
- "percent": 3.7,
138
+ "percent": 3.68,
139
139
  "reduction": 5.43
140
140
  },
141
141
  {
@@ -154,7 +154,7 @@
154
154
  "dependents": [
155
155
  "/src/adapters/aws-lambda/index.ts"
156
156
  ],
157
- "percent": 3.57,
157
+ "percent": 3.55,
158
158
  "reduction": 36.48
159
159
  },
160
160
  {
@@ -170,7 +170,7 @@
170
170
  "dependents": [
171
171
  "/src/observable/index.ts"
172
172
  ],
173
- "percent": 3.21,
173
+ "percent": 3.2,
174
174
  "reduction": 0
175
175
  },
176
176
  {
@@ -190,7 +190,7 @@
190
190
  "/src/unstable-core-do-not-import/router.ts",
191
191
  "/src/unstable-core-do-not-import/initTRPC.ts"
192
192
  ],
193
- "percent": 2.96,
193
+ "percent": 2.95,
194
194
  "reduction": 45.94
195
195
  },
196
196
  {
@@ -204,7 +204,7 @@
204
204
  "dependents": [
205
205
  "/src/unstable-core-do-not-import.ts"
206
206
  ],
207
- "percent": 2.94,
207
+ "percent": 2.93,
208
208
  "reduction": 39.13
209
209
  },
210
210
  {
@@ -224,7 +224,7 @@
224
224
  "/src/unstable-core-do-not-import/initTRPC.ts",
225
225
  "/src/unstable-core-do-not-import/procedureBuilder.ts"
226
226
  ],
227
- "percent": 2.83,
227
+ "percent": 2.82,
228
228
  "reduction": 55.5
229
229
  },
230
230
  {
@@ -239,7 +239,7 @@
239
239
  "/src/adapters/fastify/index.ts",
240
240
  "/src/adapters/fastify/fastifyTRPCPlugin.ts"
241
241
  ],
242
- "percent": 2.79,
242
+ "percent": 2.78,
243
243
  "reduction": 35.33
244
244
  },
245
245
  {
@@ -251,7 +251,7 @@
251
251
  ],
252
252
  "removedExports": [],
253
253
  "dependents": [],
254
- "percent": 2.74,
254
+ "percent": 2.73,
255
255
  "reduction": 31.37
256
256
  },
257
257
  {
@@ -272,7 +272,7 @@
272
272
  "/src/unstable-core-do-not-import/middleware.ts",
273
273
  "/src/unstable-core-do-not-import/procedureBuilder.ts"
274
274
  ],
275
- "percent": 1.87,
275
+ "percent": 1.86,
276
276
  "reduction": 19.47
277
277
  },
278
278
  {
@@ -286,7 +286,7 @@
286
286
  "dependents": [
287
287
  "/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts"
288
288
  ],
289
- "percent": 1.77,
289
+ "percent": 1.76,
290
290
  "reduction": 34.79
291
291
  },
292
292
  {
@@ -300,7 +300,7 @@
300
300
  "dependents": [
301
301
  "/src/adapters/fastify/index.ts"
302
302
  ],
303
- "percent": 1.73,
303
+ "percent": 1.72,
304
304
  "reduction": 31.58
305
305
  },
306
306
  {
@@ -312,9 +312,23 @@
312
312
  ],
313
313
  "removedExports": [],
314
314
  "dependents": [],
315
- "percent": 1.73,
315
+ "percent": 1.72,
316
316
  "reduction": 29.12
317
317
  },
318
+ {
319
+ "id": "/src/adapters/node-http/content-type/json/getPostBody.ts",
320
+ "size": 1590,
321
+ "origSize": 1593,
322
+ "renderedExports": [
323
+ "getPostBody"
324
+ ],
325
+ "removedExports": [],
326
+ "dependents": [
327
+ "/src/adapters/node-http/content-type/json/index.ts"
328
+ ],
329
+ "percent": 1.71,
330
+ "reduction": 0.19
331
+ },
318
332
  {
319
333
  "id": "/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
320
334
  "size": 1580,
@@ -328,18 +342,17 @@
328
342
  "reduction": 21.04
329
343
  },
330
344
  {
331
- "id": "/src/adapters/node-http/content-type/json/getPostBody.ts",
332
- "size": 1562,
333
- "origSize": 1547,
345
+ "id": "/src/unstable-core-do-not-import/rpc/codes.ts",
346
+ "size": 1524,
347
+ "origSize": 2105,
334
348
  "renderedExports": [
335
- "getPostBody"
349
+ "TRPC_ERROR_CODES_BY_KEY",
350
+ "TRPC_ERROR_CODES_BY_NUMBER"
336
351
  ],
337
352
  "removedExports": [],
338
- "dependents": [
339
- "/src/adapters/node-http/content-type/json/index.ts"
340
- ],
341
- "percent": 1.68,
342
- "reduction": 0
353
+ "dependents": [],
354
+ "percent": 1.64,
355
+ "reduction": 27.6
343
356
  },
344
357
  {
345
358
  "id": "/src/unstable-core-do-not-import/createProxy.ts",
@@ -355,7 +368,7 @@
355
368
  "/src/unstable-core-do-not-import/router.ts",
356
369
  "/src/unstable-core-do-not-import/initTRPC.ts"
357
370
  ],
358
- "percent": 1.63,
371
+ "percent": 1.62,
359
372
  "reduction": 5.58
360
373
  },
361
374
  {
@@ -374,8 +387,8 @@
374
387
  },
375
388
  {
376
389
  "id": "/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts",
377
- "size": 1233,
378
- "origSize": 1608,
390
+ "size": 1266,
391
+ "origSize": 1639,
379
392
  "renderedExports": [
380
393
  "getHTTPStatusCode",
381
394
  "getHTTPStatusCodeFromError"
@@ -385,28 +398,29 @@
385
398
  "/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts",
386
399
  "/src/unstable-core-do-not-import/error/getErrorShape.ts"
387
400
  ],
388
- "percent": 1.33,
389
- "reduction": 23.32
401
+ "percent": 1.36,
402
+ "reduction": 22.76
390
403
  },
391
404
  {
392
- "id": "/src/unstable-core-do-not-import/rpc/codes.ts",
393
- "size": 1020,
394
- "origSize": 1325,
405
+ "id": "/src/unstable-core-do-not-import/parser.ts",
406
+ "size": 992,
407
+ "origSize": 2266,
395
408
  "renderedExports": [
396
- "TRPC_ERROR_CODES_BY_KEY",
397
- "TRPC_ERROR_CODES_BY_NUMBER"
409
+ "getParseFn"
398
410
  ],
399
411
  "removedExports": [],
400
- "dependents": [],
401
- "percent": 1.1,
402
- "reduction": 23.02
412
+ "dependents": [
413
+ "/src/unstable-core-do-not-import.ts",
414
+ "/src/unstable-core-do-not-import/procedureBuilder.ts"
415
+ ],
416
+ "percent": 1.07,
417
+ "reduction": 56.22
403
418
  },
404
419
  {
405
420
  "id": "/src/unstable-core-do-not-import/utils.ts",
406
- "size": 1006,
407
- "origSize": 1566,
421
+ "size": 815,
422
+ "origSize": 1016,
408
423
  "renderedExports": [
409
- "invert",
410
424
  "mergeWithoutOverrides",
411
425
  "isObject",
412
426
  "omitPrototype"
@@ -414,7 +428,6 @@
414
428
  "removedExports": [],
415
429
  "dependents": [
416
430
  "/src/unstable-core-do-not-import.ts",
417
- "/src/unstable-core-do-not-import/rpc/codes.ts",
418
431
  "/src/unstable-core-do-not-import/error/TRPCError.ts",
419
432
  "/src/unstable-core-do-not-import/router.ts",
420
433
  "/src/unstable-core-do-not-import/transformer.ts",
@@ -422,23 +435,8 @@
422
435
  "/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
423
436
  "/src/unstable-core-do-not-import/procedureBuilder.ts"
424
437
  ],
425
- "percent": 1.08,
426
- "reduction": 35.76
427
- },
428
- {
429
- "id": "/src/unstable-core-do-not-import/parser.ts",
430
- "size": 992,
431
- "origSize": 2266,
432
- "renderedExports": [
433
- "getParseFn"
434
- ],
435
- "removedExports": [],
436
- "dependents": [
437
- "/src/unstable-core-do-not-import.ts",
438
- "/src/unstable-core-do-not-import/procedureBuilder.ts"
439
- ],
440
- "percent": 1.07,
441
- "reduction": 56.22
438
+ "percent": 0.88,
439
+ "reduction": 19.78
442
440
  },
443
441
  {
444
442
  "id": "/src/adapters/node-http/content-type/form-data/uploadHandler.ts",
@@ -538,7 +536,7 @@
538
536
  ],
539
537
  "removedExports": [],
540
538
  "dependents": [],
541
- "percent": 0.37,
539
+ "percent": 0.36,
542
540
  "reduction": 71.37
543
541
  },
544
542
  {
@@ -593,7 +591,7 @@
593
591
  "/src/adapters/node-http/content-type/form-data/index.ts",
594
592
  "/src/adapters/node-http/content-type/json/index.ts"
595
593
  ],
596
- "percent": 0.13,
594
+ "percent": 0.12,
597
595
  "reduction": 86.68
598
596
  },
599
597
  {
@@ -700,26 +698,26 @@
700
698
  "reduction": 100
701
699
  },
702
700
  {
703
- "id": "/src/adapters/node-http/index.ts",
701
+ "id": "/src/adapters/fetch/index.ts",
704
702
  "size": 0,
705
- "origSize": 67,
703
+ "origSize": 64,
706
704
  "renderedExports": [],
707
705
  "removedExports": [],
708
- "dependents": [
709
- "/src/adapters/express.ts",
710
- "/src/adapters/standalone.ts",
711
- "/src/adapters/next.ts"
712
- ],
706
+ "dependents": [],
713
707
  "percent": 0,
714
708
  "reduction": 100
715
709
  },
716
710
  {
717
- "id": "/src/adapters/fetch/index.ts",
711
+ "id": "/src/adapters/node-http/index.ts",
718
712
  "size": 0,
719
- "origSize": 64,
713
+ "origSize": 67,
720
714
  "renderedExports": [],
721
715
  "removedExports": [],
722
- "dependents": [],
716
+ "dependents": [
717
+ "/src/adapters/express.ts",
718
+ "/src/adapters/next.ts",
719
+ "/src/adapters/standalone.ts"
720
+ ],
723
721
  "percent": 0,
724
722
  "reduction": 100
725
723
  }
package/dist/http.js CHANGED
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var getHTTPStatusCode = require('./unstable-core-do-not-import/http/getHTTPStatusCode.js');
4
- require('./unstable-core-do-not-import/rpc/codes.js');
5
4
  var resolveHTTPResponse = require('./unstable-core-do-not-import/http/resolveHTTPResponse.js');
6
5
  var batchStreamFormatter = require('./unstable-core-do-not-import/http/batchStreamFormatter.js');
7
6
  var contentType = require('./unstable-core-do-not-import/http/contentType.js');
package/dist/http.mjs CHANGED
@@ -1,5 +1,4 @@
1
1
  export { getHTTPStatusCode, getHTTPStatusCodeFromError } from './unstable-core-do-not-import/http/getHTTPStatusCode.mjs';
2
- import './unstable-core-do-not-import/rpc/codes.mjs';
3
2
  export { resolveHTTPResponse } from './unstable-core-do-not-import/http/resolveHTTPResponse.mjs';
4
3
  export { getBatchStreamFormatter } from './unstable-core-do-not-import/http/batchStreamFormatter.mjs';
5
4
  export { getJsonContentTypeInputs } from './unstable-core-do-not-import/http/contentType.mjs';
package/dist/index.js CHANGED
@@ -3,7 +3,6 @@
3
3
  var createProxy = require('./unstable-core-do-not-import/createProxy.js');
4
4
  var getErrorShape = require('./unstable-core-do-not-import/error/getErrorShape.js');
5
5
  var TRPCError = require('./unstable-core-do-not-import/error/TRPCError.js');
6
- require('./unstable-core-do-not-import/rpc/codes.js');
7
6
  var router = require('./unstable-core-do-not-import/router.js');
8
7
  var transformer = require('./unstable-core-do-not-import/transformer.js');
9
8
  var initTRPC = require('./unstable-core-do-not-import/initTRPC.js');
package/dist/index.mjs CHANGED
@@ -1,7 +1,6 @@
1
1
  export { createFlatProxy as createTRPCFlatProxy } from './unstable-core-do-not-import/createProxy.mjs';
2
2
  export { getErrorShape } from './unstable-core-do-not-import/error/getErrorShape.mjs';
3
3
  export { TRPCError, getTRPCErrorFromUnknown } from './unstable-core-do-not-import/error/TRPCError.mjs';
4
- import './unstable-core-do-not-import/rpc/codes.mjs';
5
4
  export { callProcedure, callProcedure as callTRPCProcedure } from './unstable-core-do-not-import/router.mjs';
6
5
  export { transformTRPCResponse } from './unstable-core-do-not-import/transformer.mjs';
7
6
  export { initTRPC } from './unstable-core-do-not-import/initTRPC.mjs';
package/dist/shared.js CHANGED
@@ -2,7 +2,6 @@
2
2
 
3
3
  var createProxy = require('./unstable-core-do-not-import/createProxy.js');
4
4
  var getErrorShape = require('./unstable-core-do-not-import/error/getErrorShape.js');
5
- require('./unstable-core-do-not-import/rpc/codes.js');
6
5
  require('./unstable-core-do-not-import/rootConfig.js');
7
6
 
8
7
 
package/dist/shared.mjs CHANGED
@@ -1,4 +1,3 @@
1
1
  export { createFlatProxy } from './unstable-core-do-not-import/createProxy.mjs';
2
2
  export { getErrorShape } from './unstable-core-do-not-import/error/getErrorShape.mjs';
3
- import './unstable-core-do-not-import/rpc/codes.mjs';
4
3
  import './unstable-core-do-not-import/rootConfig.mjs';
@@ -3,7 +3,7 @@ export declare function getCauseFromUnknown(cause: unknown): Error | undefined;
3
3
  export declare function getTRPCErrorFromUnknown(cause: unknown): TRPCError;
4
4
  export declare class TRPCError extends Error {
5
5
  readonly cause?: Error;
6
- readonly code: "INTERNAL_SERVER_ERROR" | "PARSE_ERROR" | "BAD_REQUEST" | "NOT_IMPLEMENTED" | "UNAUTHORIZED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_SUPPORTED" | "TIMEOUT" | "CONFLICT" | "PRECONDITION_FAILED" | "PAYLOAD_TOO_LARGE" | "UNPROCESSABLE_CONTENT" | "TOO_MANY_REQUESTS" | "CLIENT_CLOSED_REQUEST";
6
+ readonly code: "INTERNAL_SERVER_ERROR" | "PARSE_ERROR" | "BAD_REQUEST" | "NOT_IMPLEMENTED" | "UNAUTHORIZED" | "FORBIDDEN" | "NOT_FOUND" | "METHOD_NOT_SUPPORTED" | "TIMEOUT" | "CONFLICT" | "PRECONDITION_FAILED" | "UNSUPPORTED_MEDIA_TYPE" | "PAYLOAD_TOO_LARGE" | "UNPROCESSABLE_CONTENT" | "TOO_MANY_REQUESTS" | "CLIENT_CLOSED_REQUEST";
7
7
  constructor(opts: {
8
8
  message?: string;
9
9
  code: TRPC_ERROR_CODE_KEY;
@@ -1 +1 @@
1
- {"version":3,"file":"TRPCError.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/error/TRPCError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAMxD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,GAAG,SAAS,CAyBrE;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAoBjE;AAED,qBAAa,SAAU,SAAQ,KAAK;IAGlC,SAAyB,KAAK,CAAC,EAAE,KAAK,CAAC;IACvC,SAAgB,IAAI,qSAAC;gBAET,IAAI,EAAE;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,mBAAmB,CAAC;QAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB;CAgBF"}
1
+ {"version":3,"file":"TRPCError.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/error/TRPCError.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAMxD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,GAAG,SAAS,CAyBrE;AAED,wBAAgB,uBAAuB,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAoBjE;AAED,qBAAa,SAAU,SAAQ,KAAK;IAGlC,SAAyB,KAAK,CAAC,EAAE,KAAK,CAAC;IACvC,SAAgB,IAAI,gUAAC;gBAET,IAAI,EAAE;QAChB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,IAAI,EAAE,mBAAmB,CAAC;QAC1B,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB;CAgBF"}
@@ -1 +1 @@
1
- {"version":3,"file":"getHTTPStatusCode.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/getHTTPStatusCode.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAA2B,YAAY,EAAE,MAAM,QAAQ,CAAC;AA4BpE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,YAAY,GAAG,YAAY,EAAE,OAyBpE;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,SAAS,UAE1D"}
1
+ {"version":3,"file":"getHTTPStatusCode.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/getHTTPStatusCode.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAA2B,YAAY,EAAE,MAAM,QAAQ,CAAC;AA6BpE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,YAAY,GAAG,YAAY,EAAE,OAyBpE;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,SAAS,UAE1D"}
@@ -13,6 +13,7 @@ const JSONRPC2_TO_HTTP_CODE = {
13
13
  CONFLICT: 409,
14
14
  PRECONDITION_FAILED: 412,
15
15
  PAYLOAD_TOO_LARGE: 413,
16
+ UNSUPPORTED_MEDIA_TYPE: 415,
16
17
  UNPROCESSABLE_CONTENT: 422,
17
18
  TOO_MANY_REQUESTS: 429,
18
19
  CLIENT_CLOSED_REQUEST: 499,
@@ -11,6 +11,7 @@ const JSONRPC2_TO_HTTP_CODE = {
11
11
  CONFLICT: 409,
12
12
  PRECONDITION_FAILED: 412,
13
13
  PAYLOAD_TOO_LARGE: 413,
14
+ UNSUPPORTED_MEDIA_TYPE: 415,
14
15
  UNPROCESSABLE_CONTENT: 422,
15
16
  TOO_MANY_REQUESTS: 429,
16
17
  CLIENT_CLOSED_REQUEST: 499,
@@ -24,27 +24,20 @@ export declare const TRPC_ERROR_CODES_BY_KEY: {
24
24
  readonly TIMEOUT: -32008;
25
25
  readonly CONFLICT: -32009;
26
26
  readonly PRECONDITION_FAILED: -32012;
27
+ readonly UNSUPPORTED_MEDIA_TYPE: -32015;
27
28
  readonly PAYLOAD_TOO_LARGE: -32013;
28
29
  readonly UNPROCESSABLE_CONTENT: -32022;
29
30
  readonly TOO_MANY_REQUESTS: -32029;
30
31
  readonly CLIENT_CLOSED_REQUEST: -32099;
31
32
  };
32
- export declare const TRPC_ERROR_CODES_BY_NUMBER: {
33
- [-32700]: "PARSE_ERROR";
34
- [-32600]: "BAD_REQUEST";
35
- [-32603]: "INTERNAL_SERVER_ERROR" | "NOT_IMPLEMENTED";
36
- [-32001]: "UNAUTHORIZED";
37
- [-32003]: "FORBIDDEN";
38
- [-32004]: "NOT_FOUND";
39
- [-32005]: "METHOD_NOT_SUPPORTED";
40
- [-32008]: "TIMEOUT";
41
- [-32009]: "CONFLICT";
42
- [-32012]: "PRECONDITION_FAILED";
43
- [-32013]: "PAYLOAD_TOO_LARGE";
44
- [-32022]: "UNPROCESSABLE_CONTENT";
45
- [-32029]: "TOO_MANY_REQUESTS";
46
- [-32099]: "CLIENT_CLOSED_REQUEST";
33
+ type KeyFromValue<TValue, TType extends Record<PropertyKey, PropertyKey>> = {
34
+ [K in keyof TType]: TValue extends TType[K] ? K : never;
35
+ }[keyof TType];
36
+ type Invert<TType extends Record<PropertyKey, PropertyKey>> = {
37
+ [TValue in TType[keyof TType]]: KeyFromValue<TValue, TType>;
47
38
  };
39
+ export declare const TRPC_ERROR_CODES_BY_NUMBER: Invert<typeof TRPC_ERROR_CODES_BY_KEY>;
48
40
  export type TRPC_ERROR_CODE_NUMBER = ValueOf<typeof TRPC_ERROR_CODES_BY_KEY>;
49
41
  export type TRPC_ERROR_CODE_KEY = keyof typeof TRPC_ERROR_CODES_BY_KEY;
42
+ export {};
50
43
  //# sourceMappingURL=codes.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"codes.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/rpc/codes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAKxC;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB;IAClC;;;OAGG;;IAEH;;OAEG;;;;;;;;;;;;;;;CAmBK,CAAC;AAEX,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;CAAkC,CAAC;AAE1E,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAC7E,MAAM,MAAM,mBAAmB,GAAG,MAAM,OAAO,uBAAuB,CAAC"}
1
+ {"version":3,"file":"codes.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/rpc/codes.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,UAAU,CAAC;AAIxC;;;;;GAKG;AACH,eAAO,MAAM,uBAAuB;IAClC;;;OAGG;;IAEH;;OAEG;;;;;;;;;;;;;;;;CAoBK,CAAC;AAEX,KAAK,YAAY,CAAC,MAAM,EAAE,KAAK,SAAS,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,IAAI;KACzE,CAAC,IAAI,MAAM,KAAK,GAAG,MAAM,SAAS,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK;CACxD,CAAC,MAAM,KAAK,CAAC,CAAC;AAEf,KAAK,MAAM,CAAC,KAAK,SAAS,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,IAAI;KAC3D,MAAM,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC;CAC5D,CAAC;AAGF,eAAO,MAAM,0BAA0B,EAAE,MAAM,CAC7C,OAAO,uBAAuB,CAiB/B,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG,OAAO,CAAC,OAAO,uBAAuB,CAAC,CAAC;AAC7E,MAAM,MAAM,mBAAmB,GAAG,MAAM,OAAO,uBAAuB,CAAC"}
@@ -1,7 +1,5 @@
1
1
  'use strict';
2
2
 
3
- var utils = require('../utils.js');
4
-
5
3
  // reference: https://www.jsonrpc.org/specification
6
4
  /**
7
5
  * JSON-RPC 2.0 Error codes
@@ -27,12 +25,30 @@ var utils = require('../utils.js');
27
25
  TIMEOUT: -32008,
28
26
  CONFLICT: -32009,
29
27
  PRECONDITION_FAILED: -32012,
28
+ UNSUPPORTED_MEDIA_TYPE: -32015,
30
29
  PAYLOAD_TOO_LARGE: -32013,
31
30
  UNPROCESSABLE_CONTENT: -32022,
32
31
  TOO_MANY_REQUESTS: -32029,
33
32
  CLIENT_CLOSED_REQUEST: -32099
34
33
  };
35
- const TRPC_ERROR_CODES_BY_NUMBER = utils.invert(TRPC_ERROR_CODES_BY_KEY);
34
+ // pure
35
+ const TRPC_ERROR_CODES_BY_NUMBER = {
36
+ [-32700]: 'PARSE_ERROR',
37
+ [-32600]: 'BAD_REQUEST',
38
+ [-32603]: 'INTERNAL_SERVER_ERROR',
39
+ [-32001]: 'UNAUTHORIZED',
40
+ [-32003]: 'FORBIDDEN',
41
+ [-32004]: 'NOT_FOUND',
42
+ [-32005]: 'METHOD_NOT_SUPPORTED',
43
+ [-32008]: 'TIMEOUT',
44
+ [-32009]: 'CONFLICT',
45
+ [-32012]: 'PRECONDITION_FAILED',
46
+ [-32013]: 'PAYLOAD_TOO_LARGE',
47
+ [-32015]: 'UNSUPPORTED_MEDIA_TYPE',
48
+ [-32022]: 'UNPROCESSABLE_CONTENT',
49
+ [-32029]: 'TOO_MANY_REQUESTS',
50
+ [-32099]: 'CLIENT_CLOSED_REQUEST'
51
+ };
36
52
 
37
53
  exports.TRPC_ERROR_CODES_BY_KEY = TRPC_ERROR_CODES_BY_KEY;
38
54
  exports.TRPC_ERROR_CODES_BY_NUMBER = TRPC_ERROR_CODES_BY_NUMBER;
@@ -1,5 +1,3 @@
1
- import { invert } from '../utils.mjs';
2
-
3
1
  // reference: https://www.jsonrpc.org/specification
4
2
  /**
5
3
  * JSON-RPC 2.0 Error codes
@@ -25,11 +23,29 @@ import { invert } from '../utils.mjs';
25
23
  TIMEOUT: -32008,
26
24
  CONFLICT: -32009,
27
25
  PRECONDITION_FAILED: -32012,
26
+ UNSUPPORTED_MEDIA_TYPE: -32015,
28
27
  PAYLOAD_TOO_LARGE: -32013,
29
28
  UNPROCESSABLE_CONTENT: -32022,
30
29
  TOO_MANY_REQUESTS: -32029,
31
30
  CLIENT_CLOSED_REQUEST: -32099
32
31
  };
33
- const TRPC_ERROR_CODES_BY_NUMBER = invert(TRPC_ERROR_CODES_BY_KEY);
32
+ // pure
33
+ const TRPC_ERROR_CODES_BY_NUMBER = {
34
+ [-32700]: 'PARSE_ERROR',
35
+ [-32600]: 'BAD_REQUEST',
36
+ [-32603]: 'INTERNAL_SERVER_ERROR',
37
+ [-32001]: 'UNAUTHORIZED',
38
+ [-32003]: 'FORBIDDEN',
39
+ [-32004]: 'NOT_FOUND',
40
+ [-32005]: 'METHOD_NOT_SUPPORTED',
41
+ [-32008]: 'TIMEOUT',
42
+ [-32009]: 'CONFLICT',
43
+ [-32012]: 'PRECONDITION_FAILED',
44
+ [-32013]: 'PAYLOAD_TOO_LARGE',
45
+ [-32015]: 'UNSUPPORTED_MEDIA_TYPE',
46
+ [-32022]: 'UNPROCESSABLE_CONTENT',
47
+ [-32029]: 'TOO_MANY_REQUESTS',
48
+ [-32099]: 'CLIENT_CLOSED_REQUEST'
49
+ };
34
50
 
35
51
  export { TRPC_ERROR_CODES_BY_KEY, TRPC_ERROR_CODES_BY_NUMBER };
@@ -1,13 +1,3 @@
1
- type KeyFromValue<TValue, TType extends Record<PropertyKey, PropertyKey>> = {
2
- [K in keyof TType]: TValue extends TType[K] ? K : never;
3
- }[keyof TType];
4
- type Invert<TType extends Record<PropertyKey, PropertyKey>> = {
5
- [TValue in TType[keyof TType]]: KeyFromValue<TValue, TType>;
6
- };
7
- /**
8
- * @internal
9
- */
10
- export declare function invert<TRecord extends Record<PropertyKey, PropertyKey>>(obj: TRecord): Invert<TRecord>;
11
1
  /**
12
2
  * Ensures there are no duplicate keys when building a procedure.
13
3
  * @internal
@@ -23,5 +13,4 @@ export declare function isObject(value: unknown): value is Record<string, unknow
23
13
  * @internal
24
14
  */
25
15
  export declare function omitPrototype<TObj extends Record<string, unknown>>(obj: TObj): TObj;
26
- export {};
27
16
  //# sourceMappingURL=utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/utils.ts"],"names":[],"mappings":"AAAA,KAAK,YAAY,CAAC,MAAM,EAAE,KAAK,SAAS,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,IAAI;KACzE,CAAC,IAAI,MAAM,KAAK,GAAG,MAAM,SAAS,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,GAAG,KAAK;CACxD,CAAC,MAAM,KAAK,CAAC,CAAC;AAEf,KAAK,MAAM,CAAC,KAAK,SAAS,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,IAAI;KAC3D,MAAM,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,GAAG,YAAY,CAAC,MAAM,EAAE,KAAK,CAAC;CAC5D,CAAC;AACF;;GAEG;AACH,wBAAgB,MAAM,CAAC,OAAO,SAAS,MAAM,CAAC,WAAW,EAAE,WAAW,CAAC,EACrE,GAAG,EAAE,OAAO,GACX,MAAM,CAAC,OAAO,CAAC,CAOjB;AAED;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzE,IAAI,EAAE,KAAK,EACX,GAAG,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,GACxB,KAAK,CAYP;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,GAAG,EAAE,IAAI,GACR,IAAI,CAEN"}
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACzE,IAAI,EAAE,KAAK,EACX,GAAG,IAAI,EAAE,OAAO,CAAC,KAAK,CAAC,EAAE,GACxB,KAAK,CAYP;AAED;;;GAGG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAEzE;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,IAAI,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChE,GAAG,EAAE,IAAI,GACR,IAAI,CAEN"}
@@ -1,15 +1,5 @@
1
1
  'use strict';
2
2
 
3
- /**
4
- * @internal
5
- */ function invert(obj) {
6
- const newObj = Object.create(null);
7
- for(const key in obj){
8
- const v = obj[key];
9
- newObj[v] = key;
10
- }
11
- return newObj;
12
- }
13
3
  /**
14
4
  * Ensures there are no duplicate keys when building a procedure.
15
5
  * @internal
@@ -38,7 +28,6 @@
38
28
  return Object.assign(Object.create(null), obj);
39
29
  }
40
30
 
41
- exports.invert = invert;
42
31
  exports.isObject = isObject;
43
32
  exports.mergeWithoutOverrides = mergeWithoutOverrides;
44
33
  exports.omitPrototype = omitPrototype;
@@ -1,13 +1,3 @@
1
- /**
2
- * @internal
3
- */ function invert(obj) {
4
- const newObj = Object.create(null);
5
- for(const key in obj){
6
- const v = obj[key];
7
- newObj[v] = key;
8
- }
9
- return newObj;
10
- }
11
1
  /**
12
2
  * Ensures there are no duplicate keys when building a procedure.
13
3
  * @internal
@@ -36,4 +26,4 @@
36
26
  return Object.assign(Object.create(null), obj);
37
27
  }
38
28
 
39
- export { invert, isObject, mergeWithoutOverrides, omitPrototype };
29
+ export { isObject, mergeWithoutOverrides, omitPrototype };
@@ -60,7 +60,6 @@ exports.getDataTransformer = transformer.getDataTransformer;
60
60
  exports.transformResult = transformer.transformResult;
61
61
  exports.transformTRPCResponse = transformer.transformTRPCResponse;
62
62
  exports.ERROR_SYMBOL = types.ERROR_SYMBOL;
63
- exports.invert = utils.invert;
64
63
  exports.isObject = utils.isObject;
65
64
  exports.mergeWithoutOverrides = utils.mergeWithoutOverrides;
66
65
  exports.omitPrototype = utils.omitPrototype;
@@ -18,4 +18,4 @@ export { TRPC_ERROR_CODES_BY_KEY, TRPC_ERROR_CODES_BY_NUMBER } from './unstable-
18
18
  export { parseTRPCMessage } from './unstable-core-do-not-import/rpc/parseTRPCMessage.mjs';
19
19
  export { defaultTransformer, getDataTransformer, transformResult, transformTRPCResponse } from './unstable-core-do-not-import/transformer.mjs';
20
20
  export { ERROR_SYMBOL } from './unstable-core-do-not-import/types.mjs';
21
- export { invert, isObject, mergeWithoutOverrides, omitPrototype } from './unstable-core-do-not-import/utils.mjs';
21
+ export { isObject, mergeWithoutOverrides, omitPrototype } from './unstable-core-do-not-import/utils.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/server",
3
- "version": "11.0.0-next-beta.302+95ed0a569",
3
+ "version": "11.0.0-next-beta.303+cdf215127",
4
4
  "description": "The tRPC server library",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -157,5 +157,5 @@
157
157
  "funding": [
158
158
  "https://trpc.io/sponsor"
159
159
  ],
160
- "gitHead": "95ed0a569aa4ba8a0a5867f7df92f746f0d11f15"
160
+ "gitHead": "cdf215127a172e497468dec04acb8ea12e840e84"
161
161
  }
@@ -11,15 +11,16 @@ export async function getPostBody(opts: {
11
11
  return new Promise((resolve) => {
12
12
  if (
13
13
  !req.headers['content-type']?.startsWith('application/json') &&
14
- req.method !== 'GET' &&
15
- req.method !== 'OPTIONS' &&
16
- req.method !== 'HEAD'
14
+ (!req.method ||
15
+ (req.method !== 'GET' &&
16
+ req.method !== 'OPTIONS' &&
17
+ req.method !== 'HEAD'))
17
18
  ) {
18
19
  resolve({
19
20
  ok: false,
20
21
  error: new TRPCError({
21
- code: 'BAD_REQUEST',
22
- message: 'Invalid content-type header (expected application/json)',
22
+ code: 'UNSUPPORTED_MEDIA_TYPE',
23
+ message: 'Invalid Content-Type header (expected application/json)',
23
24
  }),
24
25
  });
25
26
  return;
@@ -17,6 +17,7 @@ const JSONRPC2_TO_HTTP_CODE: Record<
17
17
  CONFLICT: 409,
18
18
  PRECONDITION_FAILED: 412,
19
19
  PAYLOAD_TOO_LARGE: 413,
20
+ UNSUPPORTED_MEDIA_TYPE: 415,
20
21
  UNPROCESSABLE_CONTENT: 422,
21
22
  TOO_MANY_REQUESTS: 429,
22
23
  CLIENT_CLOSED_REQUEST: 499,
@@ -1,5 +1,4 @@
1
1
  import type { ValueOf } from '../types';
2
- import { invert } from '../utils';
3
2
 
4
3
  // reference: https://www.jsonrpc.org/specification
5
4
 
@@ -32,13 +31,41 @@ export const TRPC_ERROR_CODES_BY_KEY = {
32
31
  TIMEOUT: -32008, // 408
33
32
  CONFLICT: -32009, // 409
34
33
  PRECONDITION_FAILED: -32012, // 412
34
+ UNSUPPORTED_MEDIA_TYPE: -32015, // 415
35
35
  PAYLOAD_TOO_LARGE: -32013, // 413
36
36
  UNPROCESSABLE_CONTENT: -32022, // 422
37
37
  TOO_MANY_REQUESTS: -32029, // 429
38
38
  CLIENT_CLOSED_REQUEST: -32099, // 499
39
39
  } as const;
40
40
 
41
- export const TRPC_ERROR_CODES_BY_NUMBER = invert(TRPC_ERROR_CODES_BY_KEY);
41
+ type KeyFromValue<TValue, TType extends Record<PropertyKey, PropertyKey>> = {
42
+ [K in keyof TType]: TValue extends TType[K] ? K : never;
43
+ }[keyof TType];
44
+
45
+ type Invert<TType extends Record<PropertyKey, PropertyKey>> = {
46
+ [TValue in TType[keyof TType]]: KeyFromValue<TValue, TType>;
47
+ };
48
+
49
+ // pure
50
+ export const TRPC_ERROR_CODES_BY_NUMBER: Invert<
51
+ typeof TRPC_ERROR_CODES_BY_KEY
52
+ > = {
53
+ [-32700]: 'PARSE_ERROR',
54
+ [-32600]: 'BAD_REQUEST',
55
+ [-32603]: 'INTERNAL_SERVER_ERROR',
56
+ [-32001]: 'UNAUTHORIZED',
57
+ [-32003]: 'FORBIDDEN',
58
+ [-32004]: 'NOT_FOUND',
59
+ [-32005]: 'METHOD_NOT_SUPPORTED',
60
+ [-32008]: 'TIMEOUT',
61
+ [-32009]: 'CONFLICT',
62
+ [-32012]: 'PRECONDITION_FAILED',
63
+ [-32013]: 'PAYLOAD_TOO_LARGE',
64
+ [-32015]: 'UNSUPPORTED_MEDIA_TYPE',
65
+ [-32022]: 'UNPROCESSABLE_CONTENT',
66
+ [-32029]: 'TOO_MANY_REQUESTS',
67
+ [-32099]: 'CLIENT_CLOSED_REQUEST',
68
+ };
42
69
 
43
70
  export type TRPC_ERROR_CODE_NUMBER = ValueOf<typeof TRPC_ERROR_CODES_BY_KEY>;
44
71
  export type TRPC_ERROR_CODE_KEY = keyof typeof TRPC_ERROR_CODES_BY_KEY;
@@ -1,24 +1,3 @@
1
- type KeyFromValue<TValue, TType extends Record<PropertyKey, PropertyKey>> = {
2
- [K in keyof TType]: TValue extends TType[K] ? K : never;
3
- }[keyof TType];
4
-
5
- type Invert<TType extends Record<PropertyKey, PropertyKey>> = {
6
- [TValue in TType[keyof TType]]: KeyFromValue<TValue, TType>;
7
- };
8
- /**
9
- * @internal
10
- */
11
- export function invert<TRecord extends Record<PropertyKey, PropertyKey>>(
12
- obj: TRecord,
13
- ): Invert<TRecord> {
14
- const newObj = Object.create(null);
15
- for (const key in obj) {
16
- const v = obj[key];
17
- newObj[v] = key;
18
- }
19
- return newObj;
20
- }
21
-
22
1
  /**
23
2
  * Ensures there are no duplicate keys when building a procedure.
24
3
  * @internal