@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,67 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
var rootConfig = require('./rootConfig-3371c473.js');
|
|
4
|
-
|
|
5
|
-
class UnknownCauseError extends Error {
|
|
6
|
-
}
|
|
7
|
-
function getCauseFromUnknown(cause) {
|
|
8
|
-
if (cause instanceof Error) {
|
|
9
|
-
return cause;
|
|
10
|
-
}
|
|
11
|
-
const type = typeof cause;
|
|
12
|
-
if (type === 'undefined' || type === 'function' || cause === null) {
|
|
13
|
-
return undefined;
|
|
14
|
-
}
|
|
15
|
-
// Primitive types just get wrapped in an error
|
|
16
|
-
if (type !== 'object') {
|
|
17
|
-
return new Error(String(cause));
|
|
18
|
-
}
|
|
19
|
-
// If it's an object, we'll create a synthetic error
|
|
20
|
-
if (rootConfig.isObject(cause)) {
|
|
21
|
-
const err = new UnknownCauseError();
|
|
22
|
-
for(const key in cause){
|
|
23
|
-
err[key] = cause[key];
|
|
24
|
-
}
|
|
25
|
-
return err;
|
|
26
|
-
}
|
|
27
|
-
return undefined;
|
|
28
|
-
}
|
|
29
|
-
function getTRPCErrorFromUnknown(cause) {
|
|
30
|
-
if (cause instanceof TRPCError) {
|
|
31
|
-
return cause;
|
|
32
|
-
}
|
|
33
|
-
if (cause instanceof Error && cause.name === 'TRPCError') {
|
|
34
|
-
// https://github.com/trpc/trpc/pull/4848
|
|
35
|
-
return cause;
|
|
36
|
-
}
|
|
37
|
-
const trpcError = new TRPCError({
|
|
38
|
-
code: 'INTERNAL_SERVER_ERROR',
|
|
39
|
-
cause
|
|
40
|
-
});
|
|
41
|
-
// Inherit stack from error
|
|
42
|
-
if (cause instanceof Error && cause.stack) {
|
|
43
|
-
trpcError.stack = cause.stack;
|
|
44
|
-
}
|
|
45
|
-
return trpcError;
|
|
46
|
-
}
|
|
47
|
-
class TRPCError extends Error {
|
|
48
|
-
constructor(opts){
|
|
49
|
-
const cause = getCauseFromUnknown(opts.cause);
|
|
50
|
-
const message = opts.message ?? cause?.message ?? opts.code;
|
|
51
|
-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
52
|
-
// @ts-ignore https://github.com/tc39/proposal-error-cause
|
|
53
|
-
super(message, {
|
|
54
|
-
cause
|
|
55
|
-
});
|
|
56
|
-
this.code = opts.code;
|
|
57
|
-
this.name = 'TRPCError';
|
|
58
|
-
if (!this.cause) {
|
|
59
|
-
// < ES2022 / < Node 16.9.0 compatability
|
|
60
|
-
this.cause = cause;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
exports.TRPCError = TRPCError;
|
|
66
|
-
exports.getCauseFromUnknown = getCauseFromUnknown;
|
|
67
|
-
exports.getTRPCErrorFromUnknown = getTRPCErrorFromUnknown;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Format a batch response as a line-delimited JSON stream
|
|
5
|
-
* that the `unstable_httpBatchStreamLink` can parse:
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```ts
|
|
9
|
-
* const formatter = getBatchStreamFormatter();
|
|
10
|
-
* res.send(formatter(1, 'response #2'));
|
|
11
|
-
* res.send(formatter(0, 'response #1'));
|
|
12
|
-
* res.send(formatter.end());
|
|
13
|
-
* ```
|
|
14
|
-
*
|
|
15
|
-
* Expected format:
|
|
16
|
-
* ```json
|
|
17
|
-
* {"1":"response #2"
|
|
18
|
-
* ,"0":"response #1"
|
|
19
|
-
* }
|
|
20
|
-
* ```
|
|
21
|
-
*/ function getBatchStreamFormatter() {
|
|
22
|
-
let first = true;
|
|
23
|
-
function format(index, string) {
|
|
24
|
-
const prefix = first ? '{' : ',';
|
|
25
|
-
first = false;
|
|
26
|
-
return `${prefix}"${index}":${string}\n`;
|
|
27
|
-
}
|
|
28
|
-
format.end = ()=>'}';
|
|
29
|
-
return format;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
exports.getBatchStreamFormatter = getBatchStreamFormatter;
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Format a batch response as a line-delimited JSON stream
|
|
3
|
-
* that the `unstable_httpBatchStreamLink` can parse:
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* ```ts
|
|
7
|
-
* const formatter = getBatchStreamFormatter();
|
|
8
|
-
* res.send(formatter(1, 'response #2'));
|
|
9
|
-
* res.send(formatter(0, 'response #1'));
|
|
10
|
-
* res.send(formatter.end());
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* Expected format:
|
|
14
|
-
* ```json
|
|
15
|
-
* {"1":"response #2"
|
|
16
|
-
* ,"0":"response #1"
|
|
17
|
-
* }
|
|
18
|
-
* ```
|
|
19
|
-
*/ function getBatchStreamFormatter() {
|
|
20
|
-
let first = true;
|
|
21
|
-
function format(index, string) {
|
|
22
|
-
const prefix = first ? '{' : ',';
|
|
23
|
-
first = false;
|
|
24
|
-
return `${prefix}"${index}":${string}\n`;
|
|
25
|
-
}
|
|
26
|
-
format.end = ()=>'}';
|
|
27
|
-
return format;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export { getBatchStreamFormatter as g };
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Format a batch response as a line-delimited JSON stream
|
|
3
|
-
* that the `unstable_httpBatchStreamLink` can parse:
|
|
4
|
-
*
|
|
5
|
-
* @example
|
|
6
|
-
* ```ts
|
|
7
|
-
* const formatter = getBatchStreamFormatter();
|
|
8
|
-
* res.send(formatter(1, 'response #2'));
|
|
9
|
-
* res.send(formatter(0, 'response #1'));
|
|
10
|
-
* res.send(formatter.end());
|
|
11
|
-
* ```
|
|
12
|
-
*
|
|
13
|
-
* Expected format:
|
|
14
|
-
* ```json
|
|
15
|
-
* {"1":"response #2"
|
|
16
|
-
* ,"0":"response #1"
|
|
17
|
-
* }
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
function getBatchStreamFormatter() {
|
|
21
|
-
let first = true;
|
|
22
|
-
function format(index, string) {
|
|
23
|
-
const prefix = first ? '{' : ',';
|
|
24
|
-
first = false;
|
|
25
|
-
return `${prefix}"${index}":${string}\n`;
|
|
26
|
-
}
|
|
27
|
-
format.end = () => '}';
|
|
28
|
-
return format;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export { getBatchStreamFormatter as g };
|