@trpc/server 11.0.0-rc.435 → 11.0.0-rc.436
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.
- package/dist/bundle-analysis.json +24 -23
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.js +4 -4
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.mjs +4 -4
- package/package.json +2 -2
- package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +4 -7
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction": 27.
|
|
2
|
+
"bundleSize": 129365,
|
|
3
|
+
"bundleOrigSize": 178928,
|
|
4
|
+
"bundleReduction": 27.7,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"dependents": [
|
|
47
47
|
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
48
48
|
],
|
|
49
|
-
"percent": 11.
|
|
49
|
+
"percent": 11.03,
|
|
50
50
|
"reduction": 0
|
|
51
51
|
},
|
|
52
52
|
{
|
|
@@ -384,8 +384,8 @@
|
|
|
384
384
|
},
|
|
385
385
|
{
|
|
386
386
|
"id": "/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts",
|
|
387
|
-
"size":
|
|
388
|
-
"origSize":
|
|
387
|
+
"size": 1287,
|
|
388
|
+
"origSize": 1583,
|
|
389
389
|
"renderedExports": [
|
|
390
390
|
"getHTTPStatusCode",
|
|
391
391
|
"getHTTPStatusCodeFromError"
|
|
@@ -396,8 +396,8 @@
|
|
|
396
396
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
397
397
|
"/src/unstable-core-do-not-import/error/getErrorShape.ts"
|
|
398
398
|
],
|
|
399
|
-
"percent": 0.
|
|
400
|
-
"reduction":
|
|
399
|
+
"percent": 0.99,
|
|
400
|
+
"reduction": 18.7
|
|
401
401
|
},
|
|
402
402
|
{
|
|
403
403
|
"id": "/src/unstable-core-do-not-import/utils.ts",
|
|
@@ -415,6 +415,7 @@
|
|
|
415
415
|
"removedExports": [],
|
|
416
416
|
"dependents": [
|
|
417
417
|
"/src/unstable-core-do-not-import.ts",
|
|
418
|
+
"/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts",
|
|
418
419
|
"/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
|
|
419
420
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
420
421
|
"/src/unstable-core-do-not-import/error/TRPCError.ts",
|
|
@@ -730,9 +731,9 @@
|
|
|
730
731
|
"reduction": 100
|
|
731
732
|
},
|
|
732
733
|
{
|
|
733
|
-
"id": "/src/
|
|
734
|
+
"id": "/src/shared.ts",
|
|
734
735
|
"size": 0,
|
|
735
|
-
"origSize":
|
|
736
|
+
"origSize": 653,
|
|
736
737
|
"renderedExports": [],
|
|
737
738
|
"removedExports": [],
|
|
738
739
|
"dependents": [],
|
|
@@ -740,9 +741,9 @@
|
|
|
740
741
|
"reduction": 100
|
|
741
742
|
},
|
|
742
743
|
{
|
|
743
|
-
"id": "/src/
|
|
744
|
+
"id": "/src/rpc.ts",
|
|
744
745
|
"size": 0,
|
|
745
|
-
"origSize":
|
|
746
|
+
"origSize": 36,
|
|
746
747
|
"renderedExports": [],
|
|
747
748
|
"removedExports": [],
|
|
748
749
|
"dependents": [],
|
|
@@ -783,6 +784,16 @@
|
|
|
783
784
|
"percent": 0,
|
|
784
785
|
"reduction": 100
|
|
785
786
|
},
|
|
787
|
+
{
|
|
788
|
+
"id": "/src/adapters/fetch/index.ts",
|
|
789
|
+
"size": 0,
|
|
790
|
+
"origSize": 64,
|
|
791
|
+
"renderedExports": [],
|
|
792
|
+
"removedExports": [],
|
|
793
|
+
"dependents": [],
|
|
794
|
+
"percent": 0,
|
|
795
|
+
"reduction": 100
|
|
796
|
+
},
|
|
786
797
|
{
|
|
787
798
|
"id": "/src/adapters/fastify/index.ts",
|
|
788
799
|
"size": 0,
|
|
@@ -801,22 +812,12 @@
|
|
|
801
812
|
"removedExports": [],
|
|
802
813
|
"dependents": [
|
|
803
814
|
"/src/adapters/express.ts",
|
|
804
|
-
"/src/adapters/standalone.ts",
|
|
805
815
|
"/src/adapters/next.ts",
|
|
816
|
+
"/src/adapters/standalone.ts",
|
|
806
817
|
"/src/adapters/fastify/fastifyRequestHandler.ts"
|
|
807
818
|
],
|
|
808
819
|
"percent": 0,
|
|
809
820
|
"reduction": 100
|
|
810
|
-
},
|
|
811
|
-
{
|
|
812
|
-
"id": "/src/adapters/fetch/index.ts",
|
|
813
|
-
"size": 0,
|
|
814
|
-
"origSize": 64,
|
|
815
|
-
"renderedExports": [],
|
|
816
|
-
"removedExports": [],
|
|
817
|
-
"dependents": [],
|
|
818
|
-
"percent": 0,
|
|
819
|
-
"reduction": 100
|
|
820
821
|
}
|
|
821
822
|
],
|
|
822
823
|
"moduleCount": 55
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getHTTPStatusCode.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/getHTTPStatusCode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getHTTPStatusCode.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/getHTTPStatusCode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAA2B,YAAY,EAAE,MAAM,QAAQ,CAAC;AA8BpE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,YAAY,GAAG,YAAY,EAAE,GAAG,MAAM,CAsB7E;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,SAAS,UAE1D"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var codes = require('../rpc/codes.js');
|
|
4
|
+
var utils = require('../utils.js');
|
|
4
5
|
|
|
5
6
|
const JSONRPC2_TO_HTTP_CODE = {
|
|
6
7
|
PARSE_ERROR: 400,
|
|
@@ -28,10 +29,9 @@ function getHTTPStatusCode(json) {
|
|
|
28
29
|
json
|
|
29
30
|
];
|
|
30
31
|
const httpStatuses = new Set(arr.map((res)=>{
|
|
31
|
-
if ('error' in res) {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return data.httpStatus;
|
|
32
|
+
if ('error' in res && utils.isObject(res.error.data)) {
|
|
33
|
+
if (typeof res.error.data?.['httpStatus'] === 'number') {
|
|
34
|
+
return res.error.data['httpStatus'];
|
|
35
35
|
}
|
|
36
36
|
const code = codes.TRPC_ERROR_CODES_BY_NUMBER[res.error.code];
|
|
37
37
|
return getStatusCodeFromKey(code);
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { TRPC_ERROR_CODES_BY_NUMBER } from '../rpc/codes.mjs';
|
|
2
|
+
import { isObject } from '../utils.mjs';
|
|
2
3
|
|
|
3
4
|
const JSONRPC2_TO_HTTP_CODE = {
|
|
4
5
|
PARSE_ERROR: 400,
|
|
@@ -26,10 +27,9 @@ function getHTTPStatusCode(json) {
|
|
|
26
27
|
json
|
|
27
28
|
];
|
|
28
29
|
const httpStatuses = new Set(arr.map((res)=>{
|
|
29
|
-
if ('error' in res) {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
return data.httpStatus;
|
|
30
|
+
if ('error' in res && isObject(res.error.data)) {
|
|
31
|
+
if (typeof res.error.data?.['httpStatus'] === 'number') {
|
|
32
|
+
return res.error.data['httpStatus'];
|
|
33
33
|
}
|
|
34
34
|
const code = TRPC_ERROR_CODES_BY_NUMBER[res.error.code];
|
|
35
35
|
return getStatusCodeFromKey(code);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/server",
|
|
3
|
-
"version": "11.0.0-rc.
|
|
3
|
+
"version": "11.0.0-rc.436+fbb4a2fb4",
|
|
4
4
|
"description": "The tRPC server library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -149,5 +149,5 @@
|
|
|
149
149
|
"funding": [
|
|
150
150
|
"https://trpc.io/sponsor"
|
|
151
151
|
],
|
|
152
|
-
"gitHead": "
|
|
152
|
+
"gitHead": "fbb4a2fb4b71d2f5ab7ee97617d951f3a92517c8"
|
|
153
153
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { DefaultErrorData } from '../error/formatter';
|
|
2
1
|
import type { TRPCError } from '../error/TRPCError';
|
|
3
2
|
import type { TRPC_ERROR_CODES_BY_KEY, TRPCResponse } from '../rpc';
|
|
4
3
|
import { TRPC_ERROR_CODES_BY_NUMBER } from '../rpc';
|
|
4
|
+
import { isObject } from '../utils';
|
|
5
5
|
|
|
6
6
|
const JSONRPC2_TO_HTTP_CODE: Record<
|
|
7
7
|
keyof typeof TRPC_ERROR_CODES_BY_KEY,
|
|
@@ -33,12 +33,9 @@ export function getHTTPStatusCode(json: TRPCResponse | TRPCResponse[]): number {
|
|
|
33
33
|
const arr = Array.isArray(json) ? json : [json];
|
|
34
34
|
const httpStatuses = new Set<number>(
|
|
35
35
|
arr.map((res) => {
|
|
36
|
-
if ('error' in res) {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
| DefaultErrorData;
|
|
40
|
-
if (typeof data.httpStatus === 'number') {
|
|
41
|
-
return data.httpStatus;
|
|
36
|
+
if ('error' in res && isObject(res.error.data)) {
|
|
37
|
+
if (typeof res.error.data?.['httpStatus'] === 'number') {
|
|
38
|
+
return res.error.data['httpStatus'];
|
|
42
39
|
}
|
|
43
40
|
const code = TRPC_ERROR_CODES_BY_NUMBER[res.error.code];
|
|
44
41
|
return getStatusCodeFromKey(code);
|