@trpc/server 11.0.0-alpha-tmp-export-from-main-nuke-core.215 → 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.
- package/dist/@trpc-core-unstable-do-not-import-this-please.d.ts +9 -0
- package/dist/@trpc-core-unstable-do-not-import-this-please.d.ts.map +1 -0
- package/dist/@trpc-server/http.d.ts +1 -1
- package/dist/@trpc-server/http.d.ts.map +1 -1
- package/dist/@trpc-server.d.ts +3 -3
- package/dist/@trpc-server.d.ts.map +1 -1
- package/dist/adapters/aws-lambda/index.d.ts +1 -1
- package/dist/adapters/aws-lambda/index.js +7 -12
- package/dist/adapters/aws-lambda/index.mjs +3 -8
- package/dist/adapters/aws-lambda/utils.d.ts +1 -1
- package/dist/adapters/express.d.ts +1 -1
- package/dist/adapters/express.d.ts.map +1 -1
- package/dist/adapters/express.js +2 -8
- package/dist/adapters/express.mjs +2 -8
- package/dist/adapters/fastify/fastifyTRPCPlugin.d.ts +1 -1
- package/dist/adapters/fastify/index.js +4 -12
- package/dist/adapters/fastify/index.mjs +2 -10
- package/dist/adapters/fetch/fetchRequestHandler.d.ts +1 -1
- package/dist/adapters/fetch/index.js +4 -10
- package/dist/adapters/fetch/index.mjs +2 -8
- package/dist/adapters/fetch/types.d.ts +1 -1
- package/dist/adapters/next.d.ts +1 -1
- package/dist/adapters/next.js +5 -11
- package/dist/adapters/next.mjs +3 -9
- package/dist/adapters/node-http/content-type/json/index.js +3 -5
- package/dist/adapters/node-http/content-type/json/index.mjs +1 -3
- package/dist/adapters/node-http/index.js +2 -8
- package/dist/adapters/node-http/index.mjs +2 -8
- package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts +1 -1
- package/dist/adapters/node-http/types.d.ts +2 -2
- package/dist/adapters/node-http/types.d.ts.map +1 -1
- package/dist/adapters/standalone.d.ts +1 -1
- package/dist/adapters/standalone.js +2 -8
- package/dist/adapters/standalone.mjs +2 -8
- package/dist/adapters/ws.d.ts +1 -2
- package/dist/adapters/ws.d.ts.map +1 -1
- package/dist/adapters/ws.js +26 -31
- package/dist/adapters/ws.mjs +1 -6
- package/dist/http.d.ts +6 -6
- package/dist/http.d.ts.map +1 -1
- package/dist/http.js +21 -12
- package/dist/http.mjs +1 -7
- package/dist/index.js +41 -15
- package/dist/index.mjs +1 -5
- package/dist/{nodeHTTPRequestHandler-257a3b5f.mjs → nodeHTTPRequestHandler-2d5c8791.mjs} +2 -4
- package/dist/{nodeHTTPRequestHandler-f4b7e374.js → nodeHTTPRequestHandler-55f05150.js} +4 -6
- package/dist/{nodeHTTPRequestHandler-29178135.js → nodeHTTPRequestHandler-7691fc79.js} +1 -3
- package/dist/observable.d.ts +2 -2
- package/dist/observable.d.ts.map +1 -1
- package/dist/observable.js +25 -9
- package/dist/observable.mjs +1 -3
- package/dist/rpc.d.ts +2 -2
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js +13 -5
- package/dist/rpc.mjs +1 -2
- package/dist/shared.js +9 -4
- package/dist/shared.mjs +1 -2
- package/package.json +125 -53
- package/src/@trpc-core-unstable-do-not-import-this-please.ts +9 -0
- package/src/@trpc-server/http.ts +1 -2
- package/src/@trpc-server.ts +3 -3
- package/src/adapters/aws-lambda/index.ts +1 -1
- package/src/adapters/aws-lambda/utils.ts +1 -1
- package/src/adapters/express.ts +2 -1
- package/src/adapters/fastify/fastifyRequestHandler.ts +1 -1
- package/src/adapters/fastify/fastifyTRPCPlugin.ts +1 -1
- package/src/adapters/fetch/fetchRequestHandler.ts +1 -1
- package/src/adapters/fetch/types.ts +1 -1
- package/src/adapters/next.ts +1 -1
- package/src/adapters/node-http/nodeHTTPRequestHandler.ts +1 -1
- package/src/adapters/node-http/types.ts +3 -2
- package/src/adapters/standalone.ts +1 -1
- package/src/adapters/ws.ts +10 -9
- package/src/http.ts +6 -6
- package/src/observable.ts +2 -2
- package/src/rpc.ts +2 -2
- package/dist/TRPCError-10da405a.js +0 -61
- package/dist/TRPCError-14edcf88.mjs +0 -63
- package/dist/TRPCError-e2c8eb77.js +0 -67
- package/dist/batchStreamFormatter-1971db27.js +0 -32
- package/dist/batchStreamFormatter-378277dc.mjs +0 -30
- package/dist/batchStreamFormatter-4375dc8b.js +0 -31
- package/dist/bundle-analysis.json +0 -767
- package/dist/contentType-2ed02bef.mjs +0 -52
- package/dist/contentType-3a829011.js +0 -54
- package/dist/contentType-e4a2373e.js +0 -59
- package/dist/createProxy-0306dcaa.mjs +0 -121
- package/dist/createProxy-7e413449.js +0 -127
- package/dist/createProxy-dce0c414.js +0 -116
- package/dist/initTRPC-2cef03ab.js +0 -384
- package/dist/initTRPC-38faa18f.js +0 -371
- package/dist/initTRPC-fa1b3d57.mjs +0 -376
- package/dist/observable-2a5a96d5.js +0 -125
- package/dist/observable-62674916.js +0 -125
- package/dist/observable-6d025a37.mjs +0 -121
- package/dist/operators-0cc4956a.js +0 -99
- package/dist/operators-b08617cb.js +0 -103
- package/dist/operators-d0c3e794.mjs +0 -99
- package/dist/parseTRPCMessage-6e6c204e.js +0 -65
- package/dist/parseTRPCMessage-8eb0bbe9.mjs +0 -62
- package/dist/parseTRPCMessage-ebdfe3ca.js +0 -67
- package/dist/resolveHTTPResponse-833ca2b8.js +0 -265
- package/dist/resolveHTTPResponse-9322334c.mjs +0 -291
- package/dist/resolveHTTPResponse-d64c48e1.js +0 -293
- package/dist/rootConfig-3371c473.js +0 -89
- package/dist/rootConfig-571c9267.js +0 -94
- package/dist/rootConfig-6b04a6b8.mjs +0 -81
- package/dist/router-3344b52a.js +0 -262
- package/dist/router-919c37eb.js +0 -259
- package/dist/router-d6789e4b.mjs +0 -252
- package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts +0 -6
- package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/createProxy.d.ts +0 -19
- package/dist/unstable-core-do-not-import/createProxy.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts +0 -13
- package/dist/unstable-core-do-not-import/error/TRPCError.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/formatter.d.ts +0 -33
- package/dist/unstable-core-do-not-import/error/formatter.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts +0 -15
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts +0 -24
- package/dist/unstable-core-do-not-import/http/batchStreamFormatter.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/contentType.d.ts +0 -29
- package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts +0 -5
- package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/index.d.ts +0 -7
- package/dist/unstable-core-do-not-import/http/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts +0 -51
- package/dist/unstable-core-do-not-import/http/resolveHTTPResponse.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/http/types.d.ts +0 -96
- package/dist/unstable-core-do-not-import/http/types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/index.d.ts +0 -35
- package/dist/unstable-core-do-not-import/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/index.js +0 -51
- package/dist/unstable-core-do-not-import/index.mjs +0 -11
- package/dist/unstable-core-do-not-import/initTRPC.d.ts +0 -96
- package/dist/unstable-core-do-not-import/initTRPC.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/middleware.d.ts +0 -105
- package/dist/unstable-core-do-not-import/middleware.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/observable/index.d.ts +0 -5
- package/dist/unstable-core-do-not-import/observable/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/observable/observable.d.ts +0 -13
- package/dist/unstable-core-do-not-import/observable/observable.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/observable/operators.d.ts +0 -8
- package/dist/unstable-core-do-not-import/observable/operators.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/observable/types.d.ts +0 -26
- package/dist/unstable-core-do-not-import/observable/types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/parser.d.ts +0 -30
- package/dist/unstable-core-do-not-import/parser.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/procedure.d.ts +0 -72
- package/dist/unstable-core-do-not-import/procedure.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +0 -101
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rootConfig.d.ts +0 -75
- package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/router.d.ts +0 -85
- package/dist/unstable-core-do-not-import/router.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts +0 -51
- package/dist/unstable-core-do-not-import/rpc/codes.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts +0 -97
- package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/index.d.ts +0 -5
- package/dist/unstable-core-do-not-import/rpc/index.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts +0 -5
- package/dist/unstable-core-do-not-import/rpc/parseTRPCMessage.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/serialize.d.ts +0 -62
- package/dist/unstable-core-do-not-import/serialize.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/transformer.d.ts +0 -107
- package/dist/unstable-core-do-not-import/transformer.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/types.d.ts +0 -98
- package/dist/unstable-core-do-not-import/types.d.ts.map +0 -1
- package/dist/unstable-core-do-not-import/utils.d.ts +0 -31
- package/dist/unstable-core-do-not-import/utils.d.ts.map +0 -1
- package/src/unstable-core-do-not-import/TRPCInferrable.ts +0 -9
- package/src/unstable-core-do-not-import/createProxy.ts +0 -59
- package/src/unstable-core-do-not-import/error/TRPCError.ts +0 -82
- package/src/unstable-core-do-not-import/error/formatter.ts +0 -51
- package/src/unstable-core-do-not-import/error/getErrorShape.ts +0 -36
- package/src/unstable-core-do-not-import/http/batchStreamFormatter.ts +0 -29
- package/src/unstable-core-do-not-import/http/contentType.ts +0 -99
- package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +0 -57
- package/src/unstable-core-do-not-import/http/index.ts +0 -23
- package/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts +0 -458
- package/src/unstable-core-do-not-import/http/types.ts +0 -111
- package/src/unstable-core-do-not-import/index.ts +0 -108
- package/src/unstable-core-do-not-import/initTRPC.ts +0 -206
- package/src/unstable-core-do-not-import/middleware.ts +0 -233
- package/src/unstable-core-do-not-import/observable/index.ts +0 -10
- package/src/unstable-core-do-not-import/observable/observable.ts +0 -155
- package/src/unstable-core-do-not-import/observable/operators.ts +0 -119
- package/src/unstable-core-do-not-import/observable/types.ts +0 -76
- package/src/unstable-core-do-not-import/parser.ts +0 -94
- package/src/unstable-core-do-not-import/procedure.ts +0 -108
- package/src/unstable-core-do-not-import/procedureBuilder.ts +0 -458
- package/src/unstable-core-do-not-import/rootConfig.ts +0 -90
- package/src/unstable-core-do-not-import/router.ts +0 -370
- package/src/unstable-core-do-not-import/rpc/codes.ts +0 -44
- package/src/unstable-core-do-not-import/rpc/envelopes.ts +0 -136
- package/src/unstable-core-do-not-import/rpc/index.ts +0 -21
- package/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts +0 -85
- package/src/unstable-core-do-not-import/serialize.ts +0 -122
- package/src/unstable-core-do-not-import/transformer.ts +0 -202
- package/src/unstable-core-do-not-import/types.ts +0 -151
- package/src/unstable-core-do-not-import/utils.ts +0 -66
- package/unstable-core-do-not-import/index.d.ts +0 -1
- package/unstable-core-do-not-import/index.js +0 -1
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import { T as TRPCError } from './TRPCError-14edcf88.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-e2c8eb77.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,59 +0,0 @@
|
|
|
1
|
-
import { T as TRPCError } from './TRPCError-10da405a.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,121 +0,0 @@
|
|
|
1
|
-
import { T as TRPC_ERROR_CODES_BY_NUMBER, a as TRPC_ERROR_CODES_BY_KEY } from './rootConfig-6b04a6b8.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-3371c473.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-571c9267.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 };
|