@trpc/server 10.0.0-alpha.26 → 10.0.0-alpha.27
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/{TRPCError-ddec3395.js → TRPCError-9050a68d.js} +0 -0
- package/dist/{TRPCError-7971540a.mjs → TRPCError-b7fa0c31.mjs} +0 -0
- package/dist/adapters/express.js +3 -3
- package/dist/adapters/express.mjs +3 -3
- package/dist/adapters/fastify/index.js +2 -2
- package/dist/adapters/fastify/index.mjs +2 -2
- package/dist/adapters/fetch/index.js +2 -2
- package/dist/adapters/fetch/index.mjs +2 -2
- package/dist/adapters/next.d.ts.map +1 -1
- package/dist/adapters/next.js +3 -3
- package/dist/adapters/next.mjs +3 -3
- package/dist/adapters/node-http/index.js +3 -3
- package/dist/adapters/node-http/index.mjs +3 -3
- package/dist/adapters/node-http/internals/getPostBody.d.ts +1 -1
- package/dist/adapters/node-http/internals/getPostBody.d.ts.map +1 -1
- package/dist/adapters/standalone.js +3 -3
- package/dist/adapters/standalone.mjs +3 -3
- package/dist/adapters/ws.d.ts.map +1 -1
- package/dist/adapters/ws.js +1 -1
- package/dist/adapters/ws.mjs +1 -1
- package/dist/core/internals/__generated__/mergeRoutersGeneric.d.ts +60 -0
- package/dist/core/internals/__generated__/mergeRoutersGeneric.d.ts.map +1 -1
- package/dist/core/internals/internalProcedure.d.ts +1 -1
- package/dist/core/internals/internalProcedure.d.ts.map +1 -1
- package/dist/core/internals/mergeRoutersGeneric.d.ts +21 -0
- package/dist/core/internals/mergeRoutersGeneric.d.ts.map +1 -0
- package/dist/core/internals/procedureBuilder.d.ts +3 -2
- package/dist/core/internals/procedureBuilder.d.ts.map +1 -1
- package/dist/core/router.d.ts +13 -1
- package/dist/core/router.d.ts.map +1 -1
- package/dist/deprecated/internals/middlewares.d.ts +1 -1
- package/dist/deprecated/internals/middlewares.d.ts.map +1 -1
- package/dist/deprecated/internals/procedure.d.ts.map +1 -1
- package/dist/deprecated/router.d.ts +1 -1
- package/dist/deprecated/router.d.ts.map +1 -1
- package/dist/error/TRPCError.d.ts +1 -1
- package/dist/error/TRPCError.d.ts.map +1 -1
- package/dist/http/internals/getHTTPStatusCode.d.ts +1 -1
- package/dist/http/internals/getHTTPStatusCode.d.ts.map +1 -1
- package/dist/http/internals/types.d.ts +1 -1
- package/dist/http/internals/types.d.ts.map +1 -1
- package/dist/http/resolveHTTPResponse.d.ts +1 -1
- package/dist/http/resolveHTTPResponse.d.ts.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +69 -62
- package/dist/index.mjs +71 -64
- package/dist/internals/types.d.ts +1 -1
- package/dist/internals/types.d.ts.map +1 -1
- package/dist/{nodeHTTPRequestHandler-5ad62229.mjs → nodeHTTPRequestHandler-174459c5.mjs} +2 -2
- package/dist/{nodeHTTPRequestHandler-9ddd18f2.js → nodeHTTPRequestHandler-6b7c8622.js} +2 -2
- package/dist/{resolveHTTPResponse-ccb9cfa1.mjs → resolveHTTPResponse-8657b8de.mjs} +1 -1
- package/dist/{resolveHTTPResponse-5932d785.js → resolveHTTPResponse-fcc8f644.js} +1 -1
- package/dist/subscription.js +1 -1
- package/dist/subscription.mjs +1 -1
- package/package.json +3 -2
- package/src/adapters/next.ts +1 -1
- package/src/adapters/node-http/internals/getPostBody.ts +1 -1
- package/src/adapters/ws.ts +2 -2
- package/src/core/internals/__generated__/mergeRoutersGeneric.ts +60 -0
- package/src/core/internals/internalProcedure.ts +4 -4
- package/src/core/internals/mergeRoutersGeneric.ts +35 -0
- package/src/core/internals/procedureBuilder.ts +3 -2
- package/src/core/router.ts +46 -1
- package/src/deprecated/internals/middlewares.ts +1 -1
- package/src/deprecated/internals/procedure.ts +2 -5
- package/src/deprecated/router.ts +3 -13
- package/src/error/TRPCError.ts +2 -2
- package/src/http/internals/getHTTPStatusCode.ts +1 -1
- package/src/http/internals/types.ts +1 -1
- package/src/http/resolveHTTPResponse.ts +2 -2
- package/src/index.ts +1 -1
- package/src/internals/types.ts +1 -1
- package/src/subscription.ts +1 -1
- package/dist/TRPCError.d.ts +0 -11
- package/dist/TRPCError.d.ts.map +0 -1
- package/dist/internals/errors.d.ts +0 -5
- package/dist/internals/errors.d.ts.map +0 -1
- package/src/TRPCError.ts +0 -27
- package/src/internals/errors.ts +0 -49
package/dist/index.mjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { a as assertNotBrowser, g as getHTTPStatusCodeFromError } from './resolveHTTPResponse-
|
|
2
|
-
export { a as assertNotBrowser, r as resolveHTTPResponse } from './resolveHTTPResponse-
|
|
1
|
+
import { a as assertNotBrowser, g as getHTTPStatusCodeFromError } from './resolveHTTPResponse-8657b8de.mjs';
|
|
2
|
+
export { a as assertNotBrowser, r as resolveHTTPResponse } from './resolveHTTPResponse-8657b8de.mjs';
|
|
3
3
|
import { T as TRPC_ERROR_CODES_BY_KEY } from './envelopes-af8c2959.mjs';
|
|
4
|
-
import { T as TRPCError, g as getCauseFromUnknown
|
|
5
|
-
export { T as TRPCError } from './TRPCError-
|
|
4
|
+
import { T as TRPCError, g as getCauseFromUnknown, a as getErrorFromUnknown } from './TRPCError-b7fa0c31.mjs';
|
|
5
|
+
export { T as TRPCError } from './TRPCError-b7fa0c31.mjs';
|
|
6
6
|
import './transformTRPCResponse-747b9a68.mjs';
|
|
7
7
|
|
|
8
8
|
assertNotBrowser();
|
|
@@ -49,7 +49,7 @@ function getDataTransformer$1(transformer) {
|
|
|
49
49
|
/**
|
|
50
50
|
* @internal
|
|
51
51
|
*/
|
|
52
|
-
const defaultTransformer
|
|
52
|
+
const defaultTransformer = {
|
|
53
53
|
_default: true,
|
|
54
54
|
input: {
|
|
55
55
|
serialize: obj => obj,
|
|
@@ -61,6 +61,23 @@ const defaultTransformer$1 = {
|
|
|
61
61
|
}
|
|
62
62
|
};
|
|
63
63
|
|
|
64
|
+
/**
|
|
65
|
+
* @internal
|
|
66
|
+
*/
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
const defaultFormatter = ({
|
|
76
|
+
shape
|
|
77
|
+
}) => {
|
|
78
|
+
return shape;
|
|
79
|
+
};
|
|
80
|
+
|
|
64
81
|
/**
|
|
65
82
|
* @deprecated
|
|
66
83
|
*/
|
|
@@ -139,7 +156,7 @@ class Procedure {
|
|
|
139
156
|
} catch (cause) {
|
|
140
157
|
throw new TRPCError({
|
|
141
158
|
code: 'BAD_REQUEST',
|
|
142
|
-
cause: getCauseFromUnknown
|
|
159
|
+
cause: getCauseFromUnknown(cause)
|
|
143
160
|
});
|
|
144
161
|
}
|
|
145
162
|
}
|
|
@@ -150,7 +167,7 @@ class Procedure {
|
|
|
150
167
|
} catch (cause) {
|
|
151
168
|
throw new TRPCError({
|
|
152
169
|
code: 'INTERNAL_SERVER_ERROR',
|
|
153
|
-
cause: getCauseFromUnknown
|
|
170
|
+
cause: getCauseFromUnknown(cause),
|
|
154
171
|
message: 'Output validation failed'
|
|
155
172
|
});
|
|
156
173
|
}
|
|
@@ -309,14 +326,6 @@ function getParseFnOrPassThrough(procedureParser) {
|
|
|
309
326
|
return getParseFn(procedureParser);
|
|
310
327
|
}
|
|
311
328
|
|
|
312
|
-
function getCauseFromUnknown(cause) {
|
|
313
|
-
if (cause instanceof Error) {
|
|
314
|
-
return cause;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
return undefined;
|
|
318
|
-
}
|
|
319
|
-
|
|
320
329
|
/**
|
|
321
330
|
* Ensures there are no duplicate keys when building a procedure.
|
|
322
331
|
*/
|
|
@@ -536,7 +545,7 @@ function createInternalBuilder(initDef) {
|
|
|
536
545
|
return createProcedureCaller(finalBuilder._def);
|
|
537
546
|
},
|
|
538
547
|
|
|
539
|
-
|
|
548
|
+
unstable_concat(builder) {
|
|
540
549
|
return createNewInternalBuilder(_def, builder._def);
|
|
541
550
|
},
|
|
542
551
|
|
|
@@ -549,23 +558,6 @@ function createInternalBuilder(initDef) {
|
|
|
549
558
|
};
|
|
550
559
|
}
|
|
551
560
|
|
|
552
|
-
/**
|
|
553
|
-
* @internal
|
|
554
|
-
*/
|
|
555
|
-
|
|
556
|
-
/**
|
|
557
|
-
* @internal
|
|
558
|
-
*/
|
|
559
|
-
|
|
560
|
-
/**
|
|
561
|
-
* @internal
|
|
562
|
-
*/
|
|
563
|
-
const defaultFormatter$1 = ({
|
|
564
|
-
shape
|
|
565
|
-
}) => {
|
|
566
|
-
return shape;
|
|
567
|
-
};
|
|
568
|
-
|
|
569
561
|
/**
|
|
570
562
|
* Create an object without inheriting anything from `Object.prototype`
|
|
571
563
|
* @internal
|
|
@@ -575,6 +567,16 @@ function omitPrototype(obj1) {
|
|
|
575
567
|
}
|
|
576
568
|
|
|
577
569
|
/* eslint-disable @typescript-eslint/ban-types */
|
|
570
|
+
|
|
571
|
+
function createRouterProxy(callback) {
|
|
572
|
+
return new Proxy({}, {
|
|
573
|
+
get(_, path) {
|
|
574
|
+
return (...args) => callback(path, ...args);
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
});
|
|
578
|
+
}
|
|
579
|
+
|
|
578
580
|
const emptyRouter = {
|
|
579
581
|
_ctx: null,
|
|
580
582
|
_errorShape: null,
|
|
@@ -582,8 +584,8 @@ const emptyRouter = {
|
|
|
582
584
|
queries: {},
|
|
583
585
|
mutations: {},
|
|
584
586
|
subscriptions: {},
|
|
585
|
-
errorFormatter: defaultFormatter
|
|
586
|
-
transformer: defaultTransformer
|
|
587
|
+
errorFormatter: defaultFormatter,
|
|
588
|
+
transformer: defaultTransformer
|
|
587
589
|
}; // type EmptyRouter = typeof emptyRouter;
|
|
588
590
|
|
|
589
591
|
const PROCEDURE_DEFINITION_MAP$1 = {
|
|
@@ -601,8 +603,8 @@ function createRouterFactory(defaults) {
|
|
|
601
603
|
var _defaults$transformer, _defaults$errorFormat;
|
|
602
604
|
|
|
603
605
|
const result = mergeWithoutOverrides({
|
|
604
|
-
transformer: (_defaults$transformer = defaults === null || defaults === void 0 ? void 0 : defaults.transformer) !== null && _defaults$transformer !== void 0 ? _defaults$transformer : defaultTransformer
|
|
605
|
-
errorFormatter: (_defaults$errorFormat = defaults === null || defaults === void 0 ? void 0 : defaults.errorFormatter) !== null && _defaults$errorFormat !== void 0 ? _defaults$errorFormat : defaultFormatter
|
|
606
|
+
transformer: (_defaults$transformer = defaults === null || defaults === void 0 ? void 0 : defaults.transformer) !== null && _defaults$transformer !== void 0 ? _defaults$transformer : defaultTransformer,
|
|
607
|
+
errorFormatter: (_defaults$errorFormat = defaults === null || defaults === void 0 ? void 0 : defaults.errorFormatter) !== null && _defaults$errorFormat !== void 0 ? _defaults$errorFormat : defaultFormatter
|
|
606
608
|
}, {
|
|
607
609
|
queries: omitPrototype(procedures.queries),
|
|
608
610
|
mutations: omitPrototype(procedures.mutations),
|
|
@@ -656,7 +658,25 @@ function createRouterFactory(defaults) {
|
|
|
656
658
|
rawInput: args[0],
|
|
657
659
|
ctx,
|
|
658
660
|
type: 'subscription'
|
|
659
|
-
})
|
|
661
|
+
}),
|
|
662
|
+
queries: createRouterProxy((path, rawInput) => callProcedure({
|
|
663
|
+
path,
|
|
664
|
+
rawInput,
|
|
665
|
+
ctx,
|
|
666
|
+
type: 'query'
|
|
667
|
+
})),
|
|
668
|
+
mutations: createRouterProxy((path, rawInput) => callProcedure({
|
|
669
|
+
path,
|
|
670
|
+
rawInput,
|
|
671
|
+
ctx,
|
|
672
|
+
type: 'mutation'
|
|
673
|
+
})),
|
|
674
|
+
subscriptions: createRouterProxy((path, rawInput) => callProcedure({
|
|
675
|
+
path,
|
|
676
|
+
rawInput,
|
|
677
|
+
ctx,
|
|
678
|
+
type: 'subscription'
|
|
679
|
+
}))
|
|
660
680
|
};
|
|
661
681
|
},
|
|
662
682
|
|
|
@@ -774,23 +794,6 @@ function safeObject(...args) {
|
|
|
774
794
|
return Object.assign(Object.create(null), ...args);
|
|
775
795
|
}
|
|
776
796
|
|
|
777
|
-
const defaultFormatter = ({
|
|
778
|
-
shape
|
|
779
|
-
}) => {
|
|
780
|
-
return shape;
|
|
781
|
-
};
|
|
782
|
-
|
|
783
|
-
const defaultTransformer = {
|
|
784
|
-
input: {
|
|
785
|
-
serialize: obj => obj,
|
|
786
|
-
deserialize: obj => obj
|
|
787
|
-
},
|
|
788
|
-
output: {
|
|
789
|
-
serialize: obj => obj,
|
|
790
|
-
deserialize: obj => obj
|
|
791
|
-
}
|
|
792
|
-
};
|
|
793
|
-
|
|
794
797
|
/**
|
|
795
798
|
* @internal The type signature of this class may change without warning.
|
|
796
799
|
* @deprecated
|
|
@@ -1057,8 +1060,8 @@ function mergeRouters(...routerList) {
|
|
|
1057
1060
|
const mutations = mergeWithoutOverrides({}, ...routerList.map(r => r.mutations));
|
|
1058
1061
|
const subscriptions = mergeWithoutOverrides({}, ...routerList.map(r => r.subscriptions));
|
|
1059
1062
|
const errorFormatter = routerList.reduce((currentErrorFormatter, nextRouter) => {
|
|
1060
|
-
if (nextRouter.errorFormatter && nextRouter.errorFormatter !== defaultFormatter
|
|
1061
|
-
if (currentErrorFormatter !== defaultFormatter
|
|
1063
|
+
if (nextRouter.errorFormatter && nextRouter.errorFormatter !== defaultFormatter) {
|
|
1064
|
+
if (currentErrorFormatter !== defaultFormatter && currentErrorFormatter !== nextRouter.errorFormatter) {
|
|
1062
1065
|
throw new Error('You seem to have several error formatters');
|
|
1063
1066
|
}
|
|
1064
1067
|
|
|
@@ -1066,10 +1069,10 @@ function mergeRouters(...routerList) {
|
|
|
1066
1069
|
}
|
|
1067
1070
|
|
|
1068
1071
|
return currentErrorFormatter;
|
|
1069
|
-
}, defaultFormatter
|
|
1072
|
+
}, defaultFormatter);
|
|
1070
1073
|
const transformer = routerList.reduce((prev, current) => {
|
|
1071
|
-
if (current.transformer && current.transformer !== defaultTransformer
|
|
1072
|
-
if (prev !== defaultTransformer
|
|
1074
|
+
if (current.transformer && current.transformer !== defaultTransformer) {
|
|
1075
|
+
if (prev !== defaultTransformer && prev !== current.transformer) {
|
|
1073
1076
|
throw new Error('You seem to have several transformers');
|
|
1074
1077
|
}
|
|
1075
1078
|
|
|
@@ -1077,7 +1080,7 @@ function mergeRouters(...routerList) {
|
|
|
1077
1080
|
}
|
|
1078
1081
|
|
|
1079
1082
|
return prev;
|
|
1080
|
-
}, defaultTransformer
|
|
1083
|
+
}, defaultTransformer);
|
|
1081
1084
|
const router = createRouterFactory({
|
|
1082
1085
|
errorFormatter,
|
|
1083
1086
|
transformer
|
|
@@ -1089,6 +1092,10 @@ function mergeRouters(...routerList) {
|
|
|
1089
1092
|
return router;
|
|
1090
1093
|
}
|
|
1091
1094
|
|
|
1095
|
+
/**
|
|
1096
|
+
* @deprecated Only keeping this for future reference if our testing was a false-positive
|
|
1097
|
+
*/
|
|
1098
|
+
|
|
1092
1099
|
function mergeRoutersGeneric(...args) {
|
|
1093
1100
|
return mergeRouters(...args);
|
|
1094
1101
|
}
|
|
@@ -1133,8 +1140,8 @@ function initTRPC() {
|
|
|
1133
1140
|
return function initTRPCInner(options) {
|
|
1134
1141
|
var _options$errorFormatt, _options$transformer;
|
|
1135
1142
|
|
|
1136
|
-
const errorFormatter = (_options$errorFormatt = options === null || options === void 0 ? void 0 : options.errorFormatter) !== null && _options$errorFormatt !== void 0 ? _options$errorFormatt : defaultFormatter
|
|
1137
|
-
const transformer = getDataTransformer$1((_options$transformer = options === null || options === void 0 ? void 0 : options.transformer) !== null && _options$transformer !== void 0 ? _options$transformer : defaultTransformer
|
|
1143
|
+
const errorFormatter = (_options$errorFormatt = options === null || options === void 0 ? void 0 : options.errorFormatter) !== null && _options$errorFormatt !== void 0 ? _options$errorFormatt : defaultFormatter;
|
|
1144
|
+
const transformer = getDataTransformer$1((_options$transformer = options === null || options === void 0 ? void 0 : options.transformer) !== null && _options$transformer !== void 0 ? _options$transformer : defaultTransformer);
|
|
1138
1145
|
return {
|
|
1139
1146
|
/**
|
|
1140
1147
|
* These are just types, they can't be used
|
|
@@ -1169,4 +1176,4 @@ function initTRPC() {
|
|
|
1169
1176
|
};
|
|
1170
1177
|
}
|
|
1171
1178
|
|
|
1172
|
-
export { defaultTransformer
|
|
1179
|
+
export { defaultTransformer, getDataTransformer$1 as getDataTransformer, initTRPC, router };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { TRPCError } from '../TRPCError';
|
|
2
1
|
import { inferRouterParams } from '../core';
|
|
3
2
|
import { ProcedureType } from '../core';
|
|
4
3
|
import { AnyRouter } from '../core/router';
|
|
4
|
+
import { TRPCError } from '../error/TRPCError';
|
|
5
5
|
/**
|
|
6
6
|
* Base interface for any response handler
|
|
7
7
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/internals/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/internals/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAE/C;;GAEG;AACH,MAAM,WAAW,kBAAkB,CAAC,OAAO,SAAS,SAAS,EAAE,QAAQ;IACrE,OAAO,CAAC,EAAE,eAAe,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC7C,QAAQ,CAAC,EAAE;QACT,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;IACF,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,oBAAY,eAAe,CAAC,OAAO,SAAS,SAAS,EAAE,QAAQ,IAAI,CAAC,IAAI,EAAE;IACxE,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE,aAAa,GAAG,SAAS,CAAC;IAChC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,GAAG,EAAE,QAAQ,CAAC;IACd,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,EAAE,SAAS,GAAG,iBAAiB,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,CAAC;CACrD,KAAK,IAAI,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { a as assertNotBrowser, r as resolveHTTPResponse } from './resolveHTTPResponse-
|
|
2
|
-
import { T as TRPCError } from './TRPCError-
|
|
1
|
+
import { a as assertNotBrowser, r as resolveHTTPResponse } from './resolveHTTPResponse-8657b8de.mjs';
|
|
2
|
+
import { T as TRPCError } from './TRPCError-b7fa0c31.mjs';
|
|
3
3
|
|
|
4
4
|
async function getPostBody({
|
|
5
5
|
req,
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var resolveHTTPResponse = require('./resolveHTTPResponse-
|
|
4
|
-
var TRPCError = require('./TRPCError-
|
|
3
|
+
var resolveHTTPResponse = require('./resolveHTTPResponse-fcc8f644.js');
|
|
4
|
+
var TRPCError = require('./TRPCError-9050a68d.js');
|
|
5
5
|
|
|
6
6
|
async function getPostBody({
|
|
7
7
|
req,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { T as TRPCError, a as getErrorFromUnknown, g as getCauseFromUnknown } from './TRPCError-
|
|
1
|
+
import { T as TRPCError, a as getErrorFromUnknown, g as getCauseFromUnknown } from './TRPCError-b7fa0c31.mjs';
|
|
2
2
|
import { t as transformTRPCResponse } from './transformTRPCResponse-747b9a68.mjs';
|
|
3
3
|
import { T as TRPC_ERROR_CODES_BY_KEY } from './envelopes-af8c2959.mjs';
|
|
4
4
|
|
package/dist/subscription.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var TRPCError = require('./TRPCError-
|
|
5
|
+
var TRPCError = require('./TRPCError-9050a68d.js');
|
|
6
6
|
var observable = require('./observable-3aa4d911.js');
|
|
7
7
|
|
|
8
8
|
function subscriptionPullFactory(opts) {
|
package/dist/subscription.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/server",
|
|
3
|
-
"version": "10.0.0-alpha.
|
|
3
|
+
"version": "10.0.0-alpha.27",
|
|
4
4
|
"description": "tRPC Server",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -22,6 +22,7 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"test": "jest",
|
|
24
24
|
"build": "rollup -c",
|
|
25
|
+
"benchmark": "yarn tsc --project tsconfig.benchmark.json",
|
|
25
26
|
"ts-watch": "tsc --project tsconfig.watch.json"
|
|
26
27
|
},
|
|
27
28
|
"main": "dist/index.js",
|
|
@@ -132,5 +133,5 @@
|
|
|
132
133
|
"dependencies": {
|
|
133
134
|
"tslib": "^2.1.0"
|
|
134
135
|
},
|
|
135
|
-
"gitHead": "
|
|
136
|
+
"gitHead": "bef0292d6b89d3be3a4cb8c21fb12f5f4ec2f896"
|
|
136
137
|
}
|
package/src/adapters/next.ts
CHANGED
|
@@ -5,8 +5,8 @@ import type {
|
|
|
5
5
|
NextApiRequest,
|
|
6
6
|
NextApiResponse,
|
|
7
7
|
} from 'next/types';
|
|
8
|
-
import { TRPCError } from '../TRPCError';
|
|
9
8
|
import { AnyRouter } from '../core';
|
|
9
|
+
import { TRPCError } from '../error/TRPCError';
|
|
10
10
|
import { nodeHTTPRequestHandler } from './node-http';
|
|
11
11
|
import {
|
|
12
12
|
NodeHTTPCreateContextFnOptions,
|
package/src/adapters/ws.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { IncomingMessage } from 'http';
|
|
2
2
|
import ws from 'ws';
|
|
3
|
-
import { TRPCError } from '../TRPCError';
|
|
4
3
|
import { AnyRouter, ProcedureType, inferRouterContext } from '../core';
|
|
5
|
-
import {
|
|
4
|
+
import { TRPCError } from '../error/TRPCError';
|
|
5
|
+
import { getCauseFromUnknown, getErrorFromUnknown } from '../error/utils';
|
|
6
6
|
import { transformTRPCResponse } from '../internals/transformTRPCResponse';
|
|
7
7
|
import { BaseHandlerOptions } from '../internals/types';
|
|
8
8
|
import { Unsubscribable, isObservable } from '../observable';
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import { AnyRouter, AnyRouterParams, Router } from "../../router";
|
|
2
2
|
import { mergeRouters } from '../mergeRouters';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* @deprecated Only keeping this for future reference if our testing was a false-positive
|
|
6
|
+
*/
|
|
4
7
|
export function mergeRoutersGeneric<
|
|
5
8
|
RP0 extends AnyRouterParams
|
|
6
9
|
>(
|
|
@@ -16,6 +19,9 @@ export function mergeRoutersGeneric<
|
|
|
16
19
|
subscriptions: RP0['subscriptions'];
|
|
17
20
|
}>;
|
|
18
21
|
|
|
22
|
+
/**
|
|
23
|
+
* @deprecated Only keeping this for future reference if our testing was a false-positive
|
|
24
|
+
*/
|
|
19
25
|
export function mergeRoutersGeneric<
|
|
20
26
|
RP0 extends AnyRouterParams, RP1 extends AnyRouterParams
|
|
21
27
|
>(
|
|
@@ -31,6 +37,9 @@ export function mergeRoutersGeneric<
|
|
|
31
37
|
subscriptions: RP0['subscriptions'] & RP1['subscriptions'];
|
|
32
38
|
}>;
|
|
33
39
|
|
|
40
|
+
/**
|
|
41
|
+
* @deprecated Only keeping this for future reference if our testing was a false-positive
|
|
42
|
+
*/
|
|
34
43
|
export function mergeRoutersGeneric<
|
|
35
44
|
RP0 extends AnyRouterParams, RP1 extends AnyRouterParams, RP2 extends AnyRouterParams
|
|
36
45
|
>(
|
|
@@ -46,6 +55,9 @@ export function mergeRoutersGeneric<
|
|
|
46
55
|
subscriptions: RP0['subscriptions'] & RP1['subscriptions'] & RP2['subscriptions'];
|
|
47
56
|
}>;
|
|
48
57
|
|
|
58
|
+
/**
|
|
59
|
+
* @deprecated Only keeping this for future reference if our testing was a false-positive
|
|
60
|
+
*/
|
|
49
61
|
export function mergeRoutersGeneric<
|
|
50
62
|
RP0 extends AnyRouterParams, RP1 extends AnyRouterParams, RP2 extends AnyRouterParams, RP3 extends AnyRouterParams
|
|
51
63
|
>(
|
|
@@ -61,6 +73,9 @@ export function mergeRoutersGeneric<
|
|
|
61
73
|
subscriptions: RP0['subscriptions'] & RP1['subscriptions'] & RP2['subscriptions'] & RP3['subscriptions'];
|
|
62
74
|
}>;
|
|
63
75
|
|
|
76
|
+
/**
|
|
77
|
+
* @deprecated Only keeping this for future reference if our testing was a false-positive
|
|
78
|
+
*/
|
|
64
79
|
export function mergeRoutersGeneric<
|
|
65
80
|
RP0 extends AnyRouterParams, RP1 extends AnyRouterParams, RP2 extends AnyRouterParams, RP3 extends AnyRouterParams, RP4 extends AnyRouterParams
|
|
66
81
|
>(
|
|
@@ -76,6 +91,9 @@ export function mergeRoutersGeneric<
|
|
|
76
91
|
subscriptions: RP0['subscriptions'] & RP1['subscriptions'] & RP2['subscriptions'] & RP3['subscriptions'] & RP4['subscriptions'];
|
|
77
92
|
}>;
|
|
78
93
|
|
|
94
|
+
/**
|
|
95
|
+
* @deprecated Only keeping this for future reference if our testing was a false-positive
|
|
96
|
+
*/
|
|
79
97
|
export function mergeRoutersGeneric<
|
|
80
98
|
RP0 extends AnyRouterParams, RP1 extends AnyRouterParams, RP2 extends AnyRouterParams, RP3 extends AnyRouterParams, RP4 extends AnyRouterParams, RP5 extends AnyRouterParams
|
|
81
99
|
>(
|
|
@@ -91,6 +109,9 @@ export function mergeRoutersGeneric<
|
|
|
91
109
|
subscriptions: RP0['subscriptions'] & RP1['subscriptions'] & RP2['subscriptions'] & RP3['subscriptions'] & RP4['subscriptions'] & RP5['subscriptions'];
|
|
92
110
|
}>;
|
|
93
111
|
|
|
112
|
+
/**
|
|
113
|
+
* @deprecated Only keeping this for future reference if our testing was a false-positive
|
|
114
|
+
*/
|
|
94
115
|
export function mergeRoutersGeneric<
|
|
95
116
|
RP0 extends AnyRouterParams, RP1 extends AnyRouterParams, RP2 extends AnyRouterParams, RP3 extends AnyRouterParams, RP4 extends AnyRouterParams, RP5 extends AnyRouterParams, RP6 extends AnyRouterParams
|
|
96
117
|
>(
|
|
@@ -106,6 +127,9 @@ export function mergeRoutersGeneric<
|
|
|
106
127
|
subscriptions: RP0['subscriptions'] & RP1['subscriptions'] & RP2['subscriptions'] & RP3['subscriptions'] & RP4['subscriptions'] & RP5['subscriptions'] & RP6['subscriptions'];
|
|
107
128
|
}>;
|
|
108
129
|
|
|
130
|
+
/**
|
|
131
|
+
* @deprecated Only keeping this for future reference if our testing was a false-positive
|
|
132
|
+
*/
|
|
109
133
|
export function mergeRoutersGeneric<
|
|
110
134
|
RP0 extends AnyRouterParams, RP1 extends AnyRouterParams, RP2 extends AnyRouterParams, RP3 extends AnyRouterParams, RP4 extends AnyRouterParams, RP5 extends AnyRouterParams, RP6 extends AnyRouterParams, RP7 extends AnyRouterParams
|
|
111
135
|
>(
|
|
@@ -121,6 +145,9 @@ export function mergeRoutersGeneric<
|
|
|
121
145
|
subscriptions: RP0['subscriptions'] & RP1['subscriptions'] & RP2['subscriptions'] & RP3['subscriptions'] & RP4['subscriptions'] & RP5['subscriptions'] & RP6['subscriptions'] & RP7['subscriptions'];
|
|
122
146
|
}>;
|
|
123
147
|
|
|
148
|
+
/**
|
|
149
|
+
* @deprecated Only keeping this for future reference if our testing was a false-positive
|
|
150
|
+
*/
|
|
124
151
|
export function mergeRoutersGeneric<
|
|
125
152
|
RP0 extends AnyRouterParams, RP1 extends AnyRouterParams, RP2 extends AnyRouterParams, RP3 extends AnyRouterParams, RP4 extends AnyRouterParams, RP5 extends AnyRouterParams, RP6 extends AnyRouterParams, RP7 extends AnyRouterParams, RP8 extends AnyRouterParams
|
|
126
153
|
>(
|
|
@@ -136,6 +163,9 @@ export function mergeRoutersGeneric<
|
|
|
136
163
|
subscriptions: RP0['subscriptions'] & RP1['subscriptions'] & RP2['subscriptions'] & RP3['subscriptions'] & RP4['subscriptions'] & RP5['subscriptions'] & RP6['subscriptions'] & RP7['subscriptions'] & RP8['subscriptions'];
|
|
137
164
|
}>;
|
|
138
165
|
|
|
166
|
+
/**
|
|
167
|
+
* @deprecated Only keeping this for future reference if our testing was a false-positive
|
|
168
|
+
*/
|
|
139
169
|
export function mergeRoutersGeneric<
|
|
140
170
|
RP0 extends AnyRouterParams, RP1 extends AnyRouterParams, RP2 extends AnyRouterParams, RP3 extends AnyRouterParams, RP4 extends AnyRouterParams, RP5 extends AnyRouterParams, RP6 extends AnyRouterParams, RP7 extends AnyRouterParams, RP8 extends AnyRouterParams, RP9 extends AnyRouterParams
|
|
141
171
|
>(
|
|
@@ -151,6 +181,9 @@ export function mergeRoutersGeneric<
|
|
|
151
181
|
subscriptions: RP0['subscriptions'] & RP1['subscriptions'] & RP2['subscriptions'] & RP3['subscriptions'] & RP4['subscriptions'] & RP5['subscriptions'] & RP6['subscriptions'] & RP7['subscriptions'] & RP8['subscriptions'] & RP9['subscriptions'];
|
|
152
182
|
}>;
|
|
153
183
|
|
|
184
|
+
/**
|
|
185
|
+
* @deprecated Only keeping this for future reference if our testing was a false-positive
|
|
186
|
+
*/
|
|
154
187
|
export function mergeRoutersGeneric<
|
|
155
188
|
RP0 extends AnyRouterParams, RP1 extends AnyRouterParams, RP2 extends AnyRouterParams, RP3 extends AnyRouterParams, RP4 extends AnyRouterParams, RP5 extends AnyRouterParams, RP6 extends AnyRouterParams, RP7 extends AnyRouterParams, RP8 extends AnyRouterParams, RP9 extends AnyRouterParams, RP10 extends AnyRouterParams
|
|
156
189
|
>(
|
|
@@ -166,6 +199,9 @@ export function mergeRoutersGeneric<
|
|
|
166
199
|
subscriptions: RP0['subscriptions'] & RP1['subscriptions'] & RP2['subscriptions'] & RP3['subscriptions'] & RP4['subscriptions'] & RP5['subscriptions'] & RP6['subscriptions'] & RP7['subscriptions'] & RP8['subscriptions'] & RP9['subscriptions'] & RP10['subscriptions'];
|
|
167
200
|
}>;
|
|
168
201
|
|
|
202
|
+
/**
|
|
203
|
+
* @deprecated Only keeping this for future reference if our testing was a false-positive
|
|
204
|
+
*/
|
|
169
205
|
export function mergeRoutersGeneric<
|
|
170
206
|
RP0 extends AnyRouterParams, RP1 extends AnyRouterParams, RP2 extends AnyRouterParams, RP3 extends AnyRouterParams, RP4 extends AnyRouterParams, RP5 extends AnyRouterParams, RP6 extends AnyRouterParams, RP7 extends AnyRouterParams, RP8 extends AnyRouterParams, RP9 extends AnyRouterParams, RP10 extends AnyRouterParams, RP11 extends AnyRouterParams
|
|
171
207
|
>(
|
|
@@ -181,6 +217,9 @@ export function mergeRoutersGeneric<
|
|
|
181
217
|
subscriptions: RP0['subscriptions'] & RP1['subscriptions'] & RP2['subscriptions'] & RP3['subscriptions'] & RP4['subscriptions'] & RP5['subscriptions'] & RP6['subscriptions'] & RP7['subscriptions'] & RP8['subscriptions'] & RP9['subscriptions'] & RP10['subscriptions'] & RP11['subscriptions'];
|
|
182
218
|
}>;
|
|
183
219
|
|
|
220
|
+
/**
|
|
221
|
+
* @deprecated Only keeping this for future reference if our testing was a false-positive
|
|
222
|
+
*/
|
|
184
223
|
export function mergeRoutersGeneric<
|
|
185
224
|
RP0 extends AnyRouterParams, RP1 extends AnyRouterParams, RP2 extends AnyRouterParams, RP3 extends AnyRouterParams, RP4 extends AnyRouterParams, RP5 extends AnyRouterParams, RP6 extends AnyRouterParams, RP7 extends AnyRouterParams, RP8 extends AnyRouterParams, RP9 extends AnyRouterParams, RP10 extends AnyRouterParams, RP11 extends AnyRouterParams, RP12 extends AnyRouterParams
|
|
186
225
|
>(
|
|
@@ -196,6 +235,9 @@ export function mergeRoutersGeneric<
|
|
|
196
235
|
subscriptions: RP0['subscriptions'] & RP1['subscriptions'] & RP2['subscriptions'] & RP3['subscriptions'] & RP4['subscriptions'] & RP5['subscriptions'] & RP6['subscriptions'] & RP7['subscriptions'] & RP8['subscriptions'] & RP9['subscriptions'] & RP10['subscriptions'] & RP11['subscriptions'] & RP12['subscriptions'];
|
|
197
236
|
}>;
|
|
198
237
|
|
|
238
|
+
/**
|
|
239
|
+
* @deprecated Only keeping this for future reference if our testing was a false-positive
|
|
240
|
+
*/
|
|
199
241
|
export function mergeRoutersGeneric<
|
|
200
242
|
RP0 extends AnyRouterParams, RP1 extends AnyRouterParams, RP2 extends AnyRouterParams, RP3 extends AnyRouterParams, RP4 extends AnyRouterParams, RP5 extends AnyRouterParams, RP6 extends AnyRouterParams, RP7 extends AnyRouterParams, RP8 extends AnyRouterParams, RP9 extends AnyRouterParams, RP10 extends AnyRouterParams, RP11 extends AnyRouterParams, RP12 extends AnyRouterParams, RP13 extends AnyRouterParams
|
|
201
243
|
>(
|
|
@@ -211,6 +253,9 @@ export function mergeRoutersGeneric<
|
|
|
211
253
|
subscriptions: RP0['subscriptions'] & RP1['subscriptions'] & RP2['subscriptions'] & RP3['subscriptions'] & RP4['subscriptions'] & RP5['subscriptions'] & RP6['subscriptions'] & RP7['subscriptions'] & RP8['subscriptions'] & RP9['subscriptions'] & RP10['subscriptions'] & RP11['subscriptions'] & RP12['subscriptions'] & RP13['subscriptions'];
|
|
212
254
|
}>;
|
|
213
255
|
|
|
256
|
+
/**
|
|
257
|
+
* @deprecated Only keeping this for future reference if our testing was a false-positive
|
|
258
|
+
*/
|
|
214
259
|
export function mergeRoutersGeneric<
|
|
215
260
|
RP0 extends AnyRouterParams, RP1 extends AnyRouterParams, RP2 extends AnyRouterParams, RP3 extends AnyRouterParams, RP4 extends AnyRouterParams, RP5 extends AnyRouterParams, RP6 extends AnyRouterParams, RP7 extends AnyRouterParams, RP8 extends AnyRouterParams, RP9 extends AnyRouterParams, RP10 extends AnyRouterParams, RP11 extends AnyRouterParams, RP12 extends AnyRouterParams, RP13 extends AnyRouterParams, RP14 extends AnyRouterParams
|
|
216
261
|
>(
|
|
@@ -226,6 +271,9 @@ export function mergeRoutersGeneric<
|
|
|
226
271
|
subscriptions: RP0['subscriptions'] & RP1['subscriptions'] & RP2['subscriptions'] & RP3['subscriptions'] & RP4['subscriptions'] & RP5['subscriptions'] & RP6['subscriptions'] & RP7['subscriptions'] & RP8['subscriptions'] & RP9['subscriptions'] & RP10['subscriptions'] & RP11['subscriptions'] & RP12['subscriptions'] & RP13['subscriptions'] & RP14['subscriptions'];
|
|
227
272
|
}>;
|
|
228
273
|
|
|
274
|
+
/**
|
|
275
|
+
* @deprecated Only keeping this for future reference if our testing was a false-positive
|
|
276
|
+
*/
|
|
229
277
|
export function mergeRoutersGeneric<
|
|
230
278
|
RP0 extends AnyRouterParams, RP1 extends AnyRouterParams, RP2 extends AnyRouterParams, RP3 extends AnyRouterParams, RP4 extends AnyRouterParams, RP5 extends AnyRouterParams, RP6 extends AnyRouterParams, RP7 extends AnyRouterParams, RP8 extends AnyRouterParams, RP9 extends AnyRouterParams, RP10 extends AnyRouterParams, RP11 extends AnyRouterParams, RP12 extends AnyRouterParams, RP13 extends AnyRouterParams, RP14 extends AnyRouterParams, RP15 extends AnyRouterParams
|
|
231
279
|
>(
|
|
@@ -241,6 +289,9 @@ export function mergeRoutersGeneric<
|
|
|
241
289
|
subscriptions: RP0['subscriptions'] & RP1['subscriptions'] & RP2['subscriptions'] & RP3['subscriptions'] & RP4['subscriptions'] & RP5['subscriptions'] & RP6['subscriptions'] & RP7['subscriptions'] & RP8['subscriptions'] & RP9['subscriptions'] & RP10['subscriptions'] & RP11['subscriptions'] & RP12['subscriptions'] & RP13['subscriptions'] & RP14['subscriptions'] & RP15['subscriptions'];
|
|
242
290
|
}>;
|
|
243
291
|
|
|
292
|
+
/**
|
|
293
|
+
* @deprecated Only keeping this for future reference if our testing was a false-positive
|
|
294
|
+
*/
|
|
244
295
|
export function mergeRoutersGeneric<
|
|
245
296
|
RP0 extends AnyRouterParams, RP1 extends AnyRouterParams, RP2 extends AnyRouterParams, RP3 extends AnyRouterParams, RP4 extends AnyRouterParams, RP5 extends AnyRouterParams, RP6 extends AnyRouterParams, RP7 extends AnyRouterParams, RP8 extends AnyRouterParams, RP9 extends AnyRouterParams, RP10 extends AnyRouterParams, RP11 extends AnyRouterParams, RP12 extends AnyRouterParams, RP13 extends AnyRouterParams, RP14 extends AnyRouterParams, RP15 extends AnyRouterParams, RP16 extends AnyRouterParams
|
|
246
297
|
>(
|
|
@@ -256,6 +307,9 @@ export function mergeRoutersGeneric<
|
|
|
256
307
|
subscriptions: RP0['subscriptions'] & RP1['subscriptions'] & RP2['subscriptions'] & RP3['subscriptions'] & RP4['subscriptions'] & RP5['subscriptions'] & RP6['subscriptions'] & RP7['subscriptions'] & RP8['subscriptions'] & RP9['subscriptions'] & RP10['subscriptions'] & RP11['subscriptions'] & RP12['subscriptions'] & RP13['subscriptions'] & RP14['subscriptions'] & RP15['subscriptions'] & RP16['subscriptions'];
|
|
257
308
|
}>;
|
|
258
309
|
|
|
310
|
+
/**
|
|
311
|
+
* @deprecated Only keeping this for future reference if our testing was a false-positive
|
|
312
|
+
*/
|
|
259
313
|
export function mergeRoutersGeneric<
|
|
260
314
|
RP0 extends AnyRouterParams, RP1 extends AnyRouterParams, RP2 extends AnyRouterParams, RP3 extends AnyRouterParams, RP4 extends AnyRouterParams, RP5 extends AnyRouterParams, RP6 extends AnyRouterParams, RP7 extends AnyRouterParams, RP8 extends AnyRouterParams, RP9 extends AnyRouterParams, RP10 extends AnyRouterParams, RP11 extends AnyRouterParams, RP12 extends AnyRouterParams, RP13 extends AnyRouterParams, RP14 extends AnyRouterParams, RP15 extends AnyRouterParams, RP16 extends AnyRouterParams, RP17 extends AnyRouterParams
|
|
261
315
|
>(
|
|
@@ -271,6 +325,9 @@ export function mergeRoutersGeneric<
|
|
|
271
325
|
subscriptions: RP0['subscriptions'] & RP1['subscriptions'] & RP2['subscriptions'] & RP3['subscriptions'] & RP4['subscriptions'] & RP5['subscriptions'] & RP6['subscriptions'] & RP7['subscriptions'] & RP8['subscriptions'] & RP9['subscriptions'] & RP10['subscriptions'] & RP11['subscriptions'] & RP12['subscriptions'] & RP13['subscriptions'] & RP14['subscriptions'] & RP15['subscriptions'] & RP16['subscriptions'] & RP17['subscriptions'];
|
|
272
326
|
}>;
|
|
273
327
|
|
|
328
|
+
/**
|
|
329
|
+
* @deprecated Only keeping this for future reference if our testing was a false-positive
|
|
330
|
+
*/
|
|
274
331
|
export function mergeRoutersGeneric<
|
|
275
332
|
RP0 extends AnyRouterParams, RP1 extends AnyRouterParams, RP2 extends AnyRouterParams, RP3 extends AnyRouterParams, RP4 extends AnyRouterParams, RP5 extends AnyRouterParams, RP6 extends AnyRouterParams, RP7 extends AnyRouterParams, RP8 extends AnyRouterParams, RP9 extends AnyRouterParams, RP10 extends AnyRouterParams, RP11 extends AnyRouterParams, RP12 extends AnyRouterParams, RP13 extends AnyRouterParams, RP14 extends AnyRouterParams, RP15 extends AnyRouterParams, RP16 extends AnyRouterParams, RP17 extends AnyRouterParams, RP18 extends AnyRouterParams
|
|
276
333
|
>(
|
|
@@ -286,6 +343,9 @@ export function mergeRoutersGeneric<
|
|
|
286
343
|
subscriptions: RP0['subscriptions'] & RP1['subscriptions'] & RP2['subscriptions'] & RP3['subscriptions'] & RP4['subscriptions'] & RP5['subscriptions'] & RP6['subscriptions'] & RP7['subscriptions'] & RP8['subscriptions'] & RP9['subscriptions'] & RP10['subscriptions'] & RP11['subscriptions'] & RP12['subscriptions'] & RP13['subscriptions'] & RP14['subscriptions'] & RP15['subscriptions'] & RP16['subscriptions'] & RP17['subscriptions'] & RP18['subscriptions'];
|
|
287
344
|
}>;
|
|
288
345
|
|
|
346
|
+
/**
|
|
347
|
+
* @deprecated Only keeping this for future reference if our testing was a false-positive
|
|
348
|
+
*/
|
|
289
349
|
export function mergeRoutersGeneric<
|
|
290
350
|
RP0 extends AnyRouterParams, RP1 extends AnyRouterParams, RP2 extends AnyRouterParams, RP3 extends AnyRouterParams, RP4 extends AnyRouterParams, RP5 extends AnyRouterParams, RP6 extends AnyRouterParams, RP7 extends AnyRouterParams, RP8 extends AnyRouterParams, RP9 extends AnyRouterParams, RP10 extends AnyRouterParams, RP11 extends AnyRouterParams, RP12 extends AnyRouterParams, RP13 extends AnyRouterParams, RP14 extends AnyRouterParams, RP15 extends AnyRouterParams, RP16 extends AnyRouterParams, RP17 extends AnyRouterParams, RP18 extends AnyRouterParams, RP19 extends AnyRouterParams
|
|
291
351
|
>(
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
* This is the actual internal representation of a builder
|
|
3
3
|
* FIXME - I want to get rid of this and use the public API instead
|
|
4
4
|
*/
|
|
5
|
-
import { TRPCError } from '../../TRPCError';
|
|
5
|
+
import { TRPCError } from '../../error/TRPCError';
|
|
6
6
|
import { getCauseFromUnknown } from '../../error/utils';
|
|
7
|
-
import { getErrorFromUnknown } from '../../
|
|
7
|
+
import { getErrorFromUnknown } from '../../error/utils';
|
|
8
8
|
import { MaybePromise } from '../../types';
|
|
9
9
|
import { MiddlewareFunction, MiddlewareResult } from '../middleware';
|
|
10
10
|
import { Parser } from '../parser';
|
|
@@ -55,7 +55,7 @@ interface ProcedureBuilderInternal {
|
|
|
55
55
|
/**
|
|
56
56
|
* @internal
|
|
57
57
|
*/
|
|
58
|
-
|
|
58
|
+
unstable_concat: (proc: ProcedureBuilderInternal) => ProcedureBuilderInternal;
|
|
59
59
|
/**
|
|
60
60
|
* @internal
|
|
61
61
|
*/
|
|
@@ -253,7 +253,7 @@ export function createInternalBuilder(
|
|
|
253
253
|
|
|
254
254
|
return createProcedureCaller(finalBuilder._def);
|
|
255
255
|
},
|
|
256
|
-
|
|
256
|
+
unstable_concat(builder) {
|
|
257
257
|
return createNewInternalBuilder(_def, builder._def);
|
|
258
258
|
},
|
|
259
259
|
use(middleware) {
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thanks to @phryneas!
|
|
3
|
+
*
|
|
4
|
+
* @link https://twitter.com/phry/status/1538516854058242048
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import { AnyRouterParams, AnyRouter, Router } from "../router";
|
|
8
|
+
import { mergeRouters } from "./mergeRouters";
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
type TailIntersectProperty<Elements extends AnyRouterParams[], Property extends keyof AnyRouterParams, Acc = unknown> =
|
|
12
|
+
// eslint-disable-next-line prettier/prettier
|
|
13
|
+
Elements extends [infer Head extends AnyRouterParams, ...infer Tail extends AnyRouterParams[]] ? TailIntersectProperty<Tail, Property, Head[Property] & Acc> : Acc;
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
type RouterToParam<R extends Router<any>> = R extends Router<infer P> ? P : never
|
|
17
|
+
|
|
18
|
+
type RoutersToParams<T, Acc extends unknown[] = []> =
|
|
19
|
+
T extends [infer Head extends Router<any>, ...infer Tail] ? RoutersToParams<Tail, [...Acc, RouterToParam<Head>]> : Acc;
|
|
20
|
+
|
|
21
|
+
export function mergeRoutersGeneric<Routers extends [...AnyRouter[]]>(
|
|
22
|
+
...routers: Routers
|
|
23
|
+
): RoutersToParams<Routers> extends infer AllParams extends AnyRouterParams[] ?
|
|
24
|
+
Router<{
|
|
25
|
+
_ctx: RouterToParam<Routers[0]>['_ctx'];
|
|
26
|
+
_errorShape: RouterToParam<Routers[0]>['_errorShape'];
|
|
27
|
+
_meta: RouterToParam<Routers[0]>['_meta'];
|
|
28
|
+
transformer: RouterToParam<Routers[0]>['transformer'];
|
|
29
|
+
errorFormatter: RouterToParam<Routers[0]>['errorFormatter'];
|
|
30
|
+
queries: TailIntersectProperty<AllParams, 'queries'>;
|
|
31
|
+
mutations: TailIntersectProperty<AllParams, 'mutations'>;
|
|
32
|
+
subscriptions: TailIntersectProperty<AllParams, 'subscriptions'>;
|
|
33
|
+
}> : never {
|
|
34
|
+
return mergeRouters(...routers) as any;
|
|
35
|
+
}
|