@trpc/server 11.0.0-alpha-tmp-01-26-rootconfigtypes.270 → 11.0.0-alpha-tmp-01-26-simplify-router.272
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/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
- package/dist/adapters/node-http/nodeHTTPRequestHandler.js +2 -0
- package/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +2 -0
- package/dist/adapters/node-http/types.d.ts +3 -3
- package/dist/adapters/node-http/types.d.ts.map +1 -1
- package/dist/bundle-analysis.json +19 -19
- package/dist/unstable-core-do-not-import/index.d.ts +1 -1
- package/dist/unstable-core-do-not-import/index.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/initTRPC.d.ts +8 -3
- package/dist/unstable-core-do-not-import/initTRPC.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/router.d.ts +22 -37
- package/dist/unstable-core-do-not-import/router.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/adapters/node-http/nodeHTTPRequestHandler.ts +4 -2
- package/src/adapters/node-http/types.ts +3 -3
- package/src/unstable-core-do-not-import/index.ts +0 -2
- package/src/unstable-core-do-not-import/router.ts +46 -73
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodeHTTPRequestHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/node-http/nodeHTTPRequestHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAapD,OAAO,KAAK,EACV,eAAe,EACf,6BAA6B,EAC7B,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAIjB,wBAAsB,sBAAsB,CAC1C,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,eAAe,EAChC,SAAS,SAAS,gBAAgB,EAClC,IAAI,EAAE,6BAA6B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,
|
|
1
|
+
{"version":3,"file":"nodeHTTPRequestHandler.d.ts","sourceRoot":"","sources":["../../../src/adapters/node-http/nodeHTTPRequestHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAGH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAapD,OAAO,KAAK,EACV,eAAe,EACf,6BAA6B,EAC7B,gBAAgB,EACjB,MAAM,SAAS,CAAC;AAIjB,wBAAsB,sBAAsB,CAC1C,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,eAAe,EAChC,SAAS,SAAS,gBAAgB,EAClC,IAAI,EAAE,6BAA6B,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,iBA8HlE"}
|
|
@@ -34,11 +34,13 @@ async function nodeHTTPRequestHandler(opts) {
|
|
|
34
34
|
jsonContentTypeHandler
|
|
35
35
|
];
|
|
36
36
|
const contentTypeHandler = contentTypeHandlers.find((handler)=>handler.isMatch({
|
|
37
|
+
// FIXME: no typecasting should be needed here
|
|
37
38
|
...opts,
|
|
38
39
|
query
|
|
39
40
|
})) ?? // fallback to json
|
|
40
41
|
jsonContentTypeHandler;
|
|
41
42
|
const bodyResult = await contentTypeHandler.getBody({
|
|
43
|
+
// FIXME: no typecasting should be needed here
|
|
42
44
|
...opts,
|
|
43
45
|
query
|
|
44
46
|
});
|
|
@@ -32,11 +32,13 @@ async function nodeHTTPRequestHandler(opts) {
|
|
|
32
32
|
jsonContentTypeHandler
|
|
33
33
|
];
|
|
34
34
|
const contentTypeHandler = contentTypeHandlers.find((handler)=>handler.isMatch({
|
|
35
|
+
// FIXME: no typecasting should be needed here
|
|
35
36
|
...opts,
|
|
36
37
|
query
|
|
37
38
|
})) ?? // fallback to json
|
|
38
39
|
jsonContentTypeHandler;
|
|
39
40
|
const bodyResult = await contentTypeHandler.getBody({
|
|
41
|
+
// FIXME: no typecasting should be needed here
|
|
40
42
|
...opts,
|
|
41
43
|
query
|
|
42
44
|
});
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
9
9
|
* ```
|
|
10
10
|
*/
|
|
11
|
-
import type
|
|
11
|
+
import type * as http from 'http';
|
|
12
12
|
import type { AnyRouter, inferRouterContext } from '../../@trpc/server';
|
|
13
13
|
import type { HTTPBaseHandlerOptions, TRPCRequestInfo } from '../../@trpc/server/http';
|
|
14
14
|
import type { MaybePromise } from '../../unstable-core-do-not-import';
|
|
@@ -16,11 +16,11 @@ import type { NodeHTTPContentTypeHandler } from './internals/contentType';
|
|
|
16
16
|
interface ParsedQs {
|
|
17
17
|
[key: string]: ParsedQs | ParsedQs[] | string[] | string | undefined;
|
|
18
18
|
}
|
|
19
|
-
export type NodeHTTPRequest = IncomingMessage & {
|
|
19
|
+
export type NodeHTTPRequest = http.IncomingMessage & {
|
|
20
20
|
query?: ParsedQs;
|
|
21
21
|
body?: unknown;
|
|
22
22
|
};
|
|
23
|
-
export type NodeHTTPResponse = ServerResponse & {
|
|
23
|
+
export type NodeHTTPResponse = http.ServerResponse & {
|
|
24
24
|
/**
|
|
25
25
|
* Force the partially-compressed response to be flushed to the client.
|
|
26
26
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/adapters/node-http/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/adapters/node-http/types.ts"],"names":[],"mappings":";AAAA;;;;;;;;GAQG;AACH,OAAO,KAAK,KAAK,IAAI,MAAM,MAAM,CAAC;AAElC,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,KAAK,EACV,sBAAsB,EACtB,eAAe,EAChB,MAAM,yBAAyB,CAAC;AAEjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC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,SAAS,CAAC,GAAG;IAC1D;;;;;;;;;;;;;;;OAeG;IACH,UAAU,CAAC,EAAE,iBAAiB,CAAC;IAC/B,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gCAAgC,CAAC,EAAE,0BAA0B,CAC3D,QAAQ,EACR,SAAS,CACV,EAAE,CAAC;CACL,CAAC;AAEJ,MAAM,MAAM,6BAA6B,CACvC,OAAO,SAAS,SAAS,EACzB,QAAQ,SAAS,eAAe,EAChC,SAAS,SAAS,gBAAgB,IAChC;IACF,GAAG,EAAE,QAAQ,CAAC;IACd,GAAG,EAAE,SAAS,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;CACd,GAAG,sBAAsB,CAAC,OAAO,EAAE,QAAQ,EAAE,SAAS,CAAC,CAAC;AAEzD,MAAM,MAAM,8BAA8B,CAAC,QAAQ,EAAE,SAAS,IAAI;IAChE,GAAG,EAAE,QAAQ,CAAC;IACd,GAAG,EAAE,SAAS,CAAC;IACf,IAAI,EAAE,eAAe,CAAC;CACvB,CAAC;AACF,MAAM,MAAM,uBAAuB,CACjC,OAAO,SAAS,SAAS,EACzB,QAAQ,EACR,SAAS,IACP,CACF,IAAI,EAAE,8BAA8B,CAAC,QAAQ,EAAE,SAAS,CAAC,KACtD,YAAY,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction":
|
|
2
|
+
"bundleSize": 102533,
|
|
3
|
+
"bundleOrigSize": 157066,
|
|
4
|
+
"bundleReduction": 34.72,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/adapters/ws.ts",
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"dependents": [
|
|
15
15
|
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
16
16
|
],
|
|
17
|
-
"percent": 9.
|
|
17
|
+
"percent": 9.63,
|
|
18
18
|
"reduction": 0
|
|
19
19
|
},
|
|
20
20
|
{
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
],
|
|
27
27
|
"removedExports": [],
|
|
28
28
|
"dependents": [],
|
|
29
|
-
"percent": 9.
|
|
29
|
+
"percent": 9.04,
|
|
30
30
|
"reduction": 23.34
|
|
31
31
|
},
|
|
32
32
|
{
|
|
@@ -48,7 +48,7 @@
|
|
|
48
48
|
{
|
|
49
49
|
"id": "/src/unstable-core-do-not-import/router.ts",
|
|
50
50
|
"size": 5634,
|
|
51
|
-
"origSize":
|
|
51
|
+
"origSize": 9790,
|
|
52
52
|
"renderedExports": [
|
|
53
53
|
"createRouterFactory",
|
|
54
54
|
"callProcedure",
|
|
@@ -61,8 +61,8 @@
|
|
|
61
61
|
"/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts",
|
|
62
62
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
63
63
|
],
|
|
64
|
-
"percent": 5.
|
|
65
|
-
"reduction": 45
|
|
64
|
+
"percent": 5.49,
|
|
65
|
+
"reduction": 42.45
|
|
66
66
|
},
|
|
67
67
|
{
|
|
68
68
|
"id": "/src/unstable-core-do-not-import/procedureBuilder.ts",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"/src/unstable-core-do-not-import/index.ts",
|
|
78
78
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
79
79
|
],
|
|
80
|
-
"percent": 5.
|
|
80
|
+
"percent": 5.46,
|
|
81
81
|
"reduction": 51.52
|
|
82
82
|
},
|
|
83
83
|
{
|
|
@@ -93,7 +93,7 @@
|
|
|
93
93
|
"dependents": [
|
|
94
94
|
"/src/adapters/node-http/content-type/form-data/index.ts"
|
|
95
95
|
],
|
|
96
|
-
"percent": 4.
|
|
96
|
+
"percent": 4.85,
|
|
97
97
|
"reduction": 36.77
|
|
98
98
|
},
|
|
99
99
|
{
|
|
@@ -131,13 +131,13 @@
|
|
|
131
131
|
],
|
|
132
132
|
"removedExports": [],
|
|
133
133
|
"dependents": [],
|
|
134
|
-
"percent": 4.
|
|
134
|
+
"percent": 4.3,
|
|
135
135
|
"reduction": 32.87
|
|
136
136
|
},
|
|
137
137
|
{
|
|
138
138
|
"id": "/src/adapters/node-http/nodeHTTPRequestHandler.ts",
|
|
139
|
-
"size":
|
|
140
|
-
"origSize":
|
|
139
|
+
"size": 4056,
|
|
140
|
+
"origSize": 4633,
|
|
141
141
|
"renderedExports": [
|
|
142
142
|
"nodeHTTPRequestHandler"
|
|
143
143
|
],
|
|
@@ -145,8 +145,8 @@
|
|
|
145
145
|
"dependents": [
|
|
146
146
|
"/src/adapters/node-http/index.ts"
|
|
147
147
|
],
|
|
148
|
-
"percent": 3.
|
|
149
|
-
"reduction": 12.
|
|
148
|
+
"percent": 3.96,
|
|
149
|
+
"reduction": 12.45
|
|
150
150
|
},
|
|
151
151
|
{
|
|
152
152
|
"id": "/src/adapters/fetch/fetchRequestHandler.ts",
|
|
@@ -159,7 +159,7 @@
|
|
|
159
159
|
"dependents": [
|
|
160
160
|
"/src/adapters/fetch/index.ts"
|
|
161
161
|
],
|
|
162
|
-
"percent": 3.
|
|
162
|
+
"percent": 3.46,
|
|
163
163
|
"reduction": 9.42
|
|
164
164
|
},
|
|
165
165
|
{
|
|
@@ -438,7 +438,7 @@
|
|
|
438
438
|
],
|
|
439
439
|
"removedExports": [],
|
|
440
440
|
"dependents": [],
|
|
441
|
-
"percent":
|
|
441
|
+
"percent": 0.99,
|
|
442
442
|
"reduction": 22.9
|
|
443
443
|
},
|
|
444
444
|
{
|
|
@@ -609,7 +609,7 @@
|
|
|
609
609
|
"dependents": [
|
|
610
610
|
"/src/adapters/node-http/nodeHTTPRequestHandler.ts"
|
|
611
611
|
],
|
|
612
|
-
"percent": 0.
|
|
612
|
+
"percent": 0.28,
|
|
613
613
|
"reduction": 35.11
|
|
614
614
|
},
|
|
615
615
|
{
|
|
@@ -712,7 +712,7 @@
|
|
|
712
712
|
{
|
|
713
713
|
"id": "/src/unstable-core-do-not-import/index.ts",
|
|
714
714
|
"size": 0,
|
|
715
|
-
"origSize":
|
|
715
|
+
"origSize": 2721,
|
|
716
716
|
"renderedExports": [],
|
|
717
717
|
"removedExports": [],
|
|
718
718
|
"dependents": [],
|
|
@@ -20,7 +20,7 @@ export type { AnyMutationProcedure, AnyProcedure, AnyQueryProcedure, AnySubscrip
|
|
|
20
20
|
export { createBuilder, unsetMarker } from './procedureBuilder';
|
|
21
21
|
export type { ProcedureBuilder } from './procedureBuilder';
|
|
22
22
|
export * from './rootConfig';
|
|
23
|
-
export type { AnyRouter,
|
|
23
|
+
export type { AnyRouter, ProcedureRecord, ProcedureRouterRecord, Router, RouterCaller, createRouterFactory, inferRouterContext, inferRouterError, inferRouterInputs, inferRouterMeta, inferRouterOutputs, } from './router';
|
|
24
24
|
export * from './TRPCInferrable';
|
|
25
25
|
export * from './router';
|
|
26
26
|
export { transformResult, transformTRPCResponse } from './transformer';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,iCAAiC,EACjC,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,YAAY,EACV,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,EACxB,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,+BAA+B,EAC/B,kCAAkC,GACnC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAChE,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,cAAc,cAAc,CAAC;AAC7B,YAAY,EACV,SAAS,EACT,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EACL,SAAS,EACT,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,mBAAmB,CAAC;AAC3B,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC7E,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,iCAAiC,EACjC,gBAAgB,GACjB,MAAM,cAAc,CAAC;AACtB,YAAY,EACV,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,YAAY,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAC5C,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,YAAY,EACV,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,wBAAwB,EACxB,iBAAiB,EACjB,SAAS,EACT,gBAAgB,EAChB,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,+BAA+B,EAC/B,kCAAkC,GACnC,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAChE,YAAY,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,cAAc,cAAc,CAAC;AAC7B,YAAY,EACV,SAAS,EACT,eAAe,EACf,qBAAqB,EACrB,MAAM,EACN,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAElB,cAAc,kBAAkB,CAAC;AACjC,cAAc,UAAU,CAAC;AACzB,OAAO,EAAE,eAAe,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACvE,YAAY,EACV,uBAAuB,EACvB,6BAA6B,EAC7B,eAAe,EACf,sBAAsB,GACvB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,eAAe,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAGtE,YAAY,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAE9D,YAAY,EACV,WAAW,EACX,IAAI,EACJ,gBAAgB,EAChB,MAAM,EACN,UAAU,EACV,iBAAiB,EACjB,KAAK,EACL,YAAY,EACZ,SAAS,EACT,gBAAgB,EAChB,qBAAqB,EACrB,QAAQ,EACR,MAAM,EACN,aAAa,EACb,qBAAqB,EACrB,SAAS,GACV,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnC,cAAc,kBAAkB,CAAC;AACjC;;GAEG;AACH,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC"}
|
|
@@ -55,7 +55,7 @@ declare class TRPCBuilder<TContext extends object, TMeta extends object> {
|
|
|
55
55
|
* Create a router
|
|
56
56
|
* @link https://trpc.io/docs/v11/server/routers
|
|
57
57
|
*/
|
|
58
|
-
router: <TProcRouterRecord extends import("./router").ProcedureRouterRecord>(procedures: TProcRouterRecord) => import("./router").
|
|
58
|
+
router: <TProcRouterRecord extends import("./router").ProcedureRouterRecord>(procedures: TProcRouterRecord) => import("./router").BuiltRouter<{
|
|
59
59
|
ctx: TContext;
|
|
60
60
|
meta: TMeta;
|
|
61
61
|
errorShape: ErrorFormatterShape<PickFirstDefined<TOptions["errorFormatter"], ErrorFormatter<TContext, DefaultErrorShape>>>;
|
|
@@ -70,12 +70,17 @@ declare class TRPCBuilder<TContext extends object, TMeta extends object> {
|
|
|
70
70
|
* Create a server-side caller for a router
|
|
71
71
|
* @link https://trpc.io/docs/v11/server/server-side-calls
|
|
72
72
|
*/
|
|
73
|
-
createCallerFactory: <
|
|
73
|
+
createCallerFactory: <TRecord extends import("./router").ProcedureRouterRecord>(router: import("./router").Router<{
|
|
74
74
|
ctx: TContext;
|
|
75
75
|
meta: TMeta;
|
|
76
76
|
errorShape: ErrorFormatterShape<PickFirstDefined<TOptions["errorFormatter"], ErrorFormatter<TContext, DefaultErrorShape>>>;
|
|
77
77
|
transformer: undefined extends TOptions["transformer"] ? false : true;
|
|
78
|
-
},
|
|
78
|
+
}, TRecord>) => import("./router").RouterCaller<{
|
|
79
|
+
ctx: TContext;
|
|
80
|
+
meta: TMeta;
|
|
81
|
+
errorShape: ErrorFormatterShape<PickFirstDefined<TOptions["errorFormatter"], ErrorFormatter<TContext, DefaultErrorShape>>>;
|
|
82
|
+
transformer: undefined extends TOptions["transformer"] ? false : true;
|
|
83
|
+
}, TRecord>;
|
|
79
84
|
};
|
|
80
85
|
}
|
|
81
86
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"initTRPC.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/initTRPC.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,mBAAmB,EACzB,MAAM,mBAAmB,CAAC;AAI3B,OA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AuDX;;;WAGG;;iBA7CE,QAAQ;kBACP,KAAK;;;;QA8CX;;;WAGG;;QAIH;;;WAGG;;QAEH;;;WAGG;;iBA9DE,QAAQ;kBACP,KAAK;;;;QA+DX;;;WAGG;;QAEH;;;WAGG;;iBAxEE,QAAQ;kBACP,KAAK;;;;iBADN,QAAQ;kBACP,KAAK;;;;;CA2EhB;AAED;;;GAGG;AACH,eAAO,MAAM,QAAQ,6BAAoB,CAAC"}
|
|
@@ -7,14 +7,6 @@ export type ProcedureRecord = Record<string, AnyProcedure>;
|
|
|
7
7
|
export interface ProcedureRouterRecord {
|
|
8
8
|
[key: string]: AnyProcedure | AnyRouter;
|
|
9
9
|
}
|
|
10
|
-
export interface RouterDef<TRoot extends AnyRootTypes, TRecord extends ProcedureRouterRecord> {
|
|
11
|
-
_config: RootConfig<TRoot>;
|
|
12
|
-
router: true;
|
|
13
|
-
procedure?: never;
|
|
14
|
-
procedures: TRecord;
|
|
15
|
-
record: TRecord;
|
|
16
|
-
}
|
|
17
|
-
export type AnyRouterDef = RouterDef<any, any>;
|
|
18
10
|
type DecorateProcedure<TProcedure extends AnyProcedure> = (input: inferProcedureInput<TProcedure>) => Promise<TProcedure['_def']['_output_out']>;
|
|
19
11
|
/**
|
|
20
12
|
* @internal
|
|
@@ -25,28 +17,34 @@ type DecoratedProcedureRecord<TProcedures extends ProcedureRouterRecord> = {
|
|
|
25
17
|
/**
|
|
26
18
|
* @internal
|
|
27
19
|
*/
|
|
28
|
-
export type RouterCaller<
|
|
20
|
+
export type RouterCaller<TRoot extends AnyRootTypes, TRecord extends ProcedureRouterRecord> = (
|
|
29
21
|
/**
|
|
30
22
|
* @note
|
|
31
23
|
* If passing a function, we recommend it's a cached function
|
|
32
24
|
* e.g. wrapped in `React.cache` to avoid unnecessary computations
|
|
33
25
|
*/
|
|
34
|
-
ctx:
|
|
35
|
-
export interface Router<
|
|
36
|
-
_def:
|
|
26
|
+
ctx: TRoot['ctx'] | (() => MaybePromise<TRoot['ctx']>)) => DecoratedProcedureRecord<TRecord>;
|
|
27
|
+
export interface Router<TRoot extends AnyRootTypes, TRecord extends ProcedureRouterRecord> {
|
|
28
|
+
_def: {
|
|
29
|
+
_config: RootConfig<TRoot>;
|
|
30
|
+
router: true;
|
|
31
|
+
procedure?: never;
|
|
32
|
+
procedures: TRecord;
|
|
33
|
+
record: TRecord;
|
|
34
|
+
};
|
|
37
35
|
/**
|
|
38
36
|
* @deprecated use `t.createCallerFactory(router)` instead
|
|
39
37
|
* @link https://trpc.io/docs/v11/server/server-side-calls
|
|
40
38
|
*/
|
|
41
|
-
createCaller: RouterCaller<
|
|
39
|
+
createCaller: RouterCaller<TRoot, TRecord>;
|
|
42
40
|
}
|
|
43
|
-
export type
|
|
44
|
-
type
|
|
45
|
-
type
|
|
46
|
-
export type inferRouterContext<TRouter extends AnyRouter> =
|
|
47
|
-
export type inferRouterError<TRouter extends AnyRouter> =
|
|
48
|
-
export type inferRouterMeta<TRouter extends AnyRouter> =
|
|
49
|
-
type GetInferenceHelpers<TType extends 'input' | 'output', TRouter extends AnyRouter> = {
|
|
41
|
+
export type BuiltRouter<TRoot extends AnyRootTypes, TRecord extends ProcedureRouterRecord> = Router<TRoot, TRecord> & TRecord;
|
|
42
|
+
export type AnyRouter = Router<any, any>;
|
|
43
|
+
type inferRouterRootTypes<TRouter extends AnyRouter> = TRouter['_def']['_config']['$types'];
|
|
44
|
+
export type inferRouterContext<TRouter extends AnyRouter> = inferRouterRootTypes<TRouter>['ctx'];
|
|
45
|
+
export type inferRouterError<TRouter extends AnyRouter> = inferRouterRootTypes<TRouter>['errorShape'];
|
|
46
|
+
export type inferRouterMeta<TRouter extends AnyRouter> = inferRouterRootTypes<TRouter>['meta'];
|
|
47
|
+
export type GetInferenceHelpers<TType extends 'input' | 'output', TRouter extends AnyRouter> = {
|
|
50
48
|
[TKey in keyof TRouter['_def']['record']]: TRouter['_def']['record'][TKey] extends infer TRouterOrProcedure ? TRouterOrProcedure extends AnyRouter ? GetInferenceHelpers<TType, TRouterOrProcedure> : TRouterOrProcedure extends AnyProcedure ? TType extends 'input' ? inferProcedureInput<TRouterOrProcedure> : inferTransformedProcedureOutput<TRouter, TRouterOrProcedure> : never : never;
|
|
51
49
|
};
|
|
52
50
|
export type inferRouterInputs<TRouter extends AnyRouter> = GetInferenceHelpers<'input', TRouter>;
|
|
@@ -54,32 +52,19 @@ export type inferRouterOutputs<TRouter extends AnyRouter> = GetInferenceHelpers<
|
|
|
54
52
|
/**
|
|
55
53
|
* @internal
|
|
56
54
|
*/
|
|
57
|
-
export
|
|
58
|
-
/**
|
|
59
|
-
* This adds ability to call procedures directly but is primarily used for quick access in type inference
|
|
60
|
-
*/
|
|
61
|
-
TProcRouterRecord;
|
|
62
|
-
/**
|
|
63
|
-
* @internal
|
|
64
|
-
*/
|
|
65
|
-
export declare function createRouterFactory<TRoot extends AnyRootTypes>(config: RootConfig<TRoot>): <TProcRouterRecord extends ProcedureRouterRecord>(procedures: TProcRouterRecord) => CreateRouterInner<TRoot, TProcRouterRecord>;
|
|
55
|
+
export declare function createRouterFactory<TRoot extends AnyRootTypes>(config: RootConfig<TRoot>): <TProcRouterRecord extends ProcedureRouterRecord>(procedures: TProcRouterRecord) => BuiltRouter<TRoot, TProcRouterRecord>;
|
|
66
56
|
/**
|
|
67
57
|
* @internal
|
|
68
58
|
*/
|
|
69
59
|
export declare function callProcedure(opts: ProcedureCallOptions & {
|
|
70
60
|
procedures: ProcedureRouterRecord;
|
|
71
61
|
}): Promise<unknown>;
|
|
72
|
-
export declare function createCallerFactory<TRoot extends AnyRootTypes>(): <
|
|
62
|
+
export declare function createCallerFactory<TRoot extends AnyRootTypes>(): <TRecord extends ProcedureRouterRecord>(router: Router<TRoot, TRecord>) => RouterCaller<TRoot, TRecord>;
|
|
73
63
|
/** @internal */
|
|
74
|
-
type MergeRouters<TRouters extends AnyRouter[],
|
|
64
|
+
type MergeRouters<TRouters extends AnyRouter[], TRoot extends AnyRootTypes = TRouters[0]['_def']['_config']['$types'], TRecord extends ProcedureRouterRecord = {}> = TRouters extends [
|
|
75
65
|
infer Head extends AnyRouter,
|
|
76
66
|
...infer Tail extends AnyRouter[]
|
|
77
|
-
] ? MergeRouters<Tail,
|
|
78
|
-
_config: TRouterDef['_config'];
|
|
79
|
-
router: true;
|
|
80
|
-
procedures: Head['_def']['procedures'] & TRouterDef['procedures'];
|
|
81
|
-
record: Head['_def']['record'] & TRouterDef['record'];
|
|
82
|
-
}> : Router<TRouterDef> & TRouterDef['record'];
|
|
67
|
+
] ? MergeRouters<Tail, TRoot, Head['_def']['record'] & TRecord> : BuiltRouter<TRoot, TRecord>;
|
|
83
68
|
export declare function mergeRouters<TRouters extends AnyRouter[]>(...routerList: [...TRouters]): MergeRouters<TRouters>;
|
|
84
69
|
export {};
|
|
85
70
|
//# sourceMappingURL=router.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/router.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,+BAA+B,EAChC,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAG5C,iBAAiB;AACjB,MAAM,MAAM,eAAe,GAAG,MAAM,CAAC,MAAM,EAAE,YAAY,CAAC,CAAC;AAE3D,MAAM,WAAW,qBAAqB;IACpC,CAAC,GAAG,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAAC;CACzC;AAED,
|
|
1
|
+
{"version":3,"file":"router.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/router.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,+BAA+B,E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GAC3B,YAAY,CAAC,QAAQ,CAAC,CAoDxB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/server",
|
|
3
|
-
"version": "11.0.0-alpha-tmp-01-26-
|
|
3
|
+
"version": "11.0.0-alpha-tmp-01-26-simplify-router.272+d44b79eca",
|
|
4
4
|
"description": "The tRPC server library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -157,5 +157,5 @@
|
|
|
157
157
|
"funding": [
|
|
158
158
|
"https://trpc.io/sponsor"
|
|
159
159
|
],
|
|
160
|
-
"gitHead": "
|
|
160
|
+
"gitHead": "d44b79eca0f19c651f1f4ec126be747c29412181"
|
|
161
161
|
}
|
|
@@ -69,7 +69,8 @@ export async function nodeHTTPRequestHandler<
|
|
|
69
69
|
const contentTypeHandler =
|
|
70
70
|
contentTypeHandlers.find((handler) =>
|
|
71
71
|
handler.isMatch({
|
|
72
|
-
|
|
72
|
+
// FIXME: no typecasting should be needed here
|
|
73
|
+
...(opts as any),
|
|
73
74
|
query,
|
|
74
75
|
}),
|
|
75
76
|
) ??
|
|
@@ -77,7 +78,8 @@ export async function nodeHTTPRequestHandler<
|
|
|
77
78
|
jsonContentTypeHandler;
|
|
78
79
|
|
|
79
80
|
const bodyResult = await contentTypeHandler.getBody({
|
|
80
|
-
|
|
81
|
+
// FIXME: no typecasting should be needed here
|
|
82
|
+
...(opts as any),
|
|
81
83
|
query,
|
|
82
84
|
});
|
|
83
85
|
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* import type { HTTPBaseHandlerOptions } from '@trpc/server/http'
|
|
8
8
|
* ```
|
|
9
9
|
*/
|
|
10
|
-
import type
|
|
10
|
+
import type * as http from 'http';
|
|
11
11
|
// @trpc/server
|
|
12
12
|
import type { AnyRouter, inferRouterContext } from '../../@trpc/server';
|
|
13
13
|
// @trpc/server/http
|
|
@@ -23,11 +23,11 @@ interface ParsedQs {
|
|
|
23
23
|
[key: string]: ParsedQs | ParsedQs[] | string[] | string | undefined;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
|
-
export type NodeHTTPRequest = IncomingMessage & {
|
|
26
|
+
export type NodeHTTPRequest = http.IncomingMessage & {
|
|
27
27
|
query?: ParsedQs;
|
|
28
28
|
body?: unknown;
|
|
29
29
|
};
|
|
30
|
-
export type NodeHTTPResponse = ServerResponse & {
|
|
30
|
+
export type NodeHTTPResponse = http.ServerResponse & {
|
|
31
31
|
/**
|
|
32
32
|
* Force the partially-compressed response to be flushed to the client.
|
|
33
33
|
*
|
|
@@ -19,19 +19,6 @@ export interface ProcedureRouterRecord {
|
|
|
19
19
|
[key: string]: AnyProcedure | AnyRouter;
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
export interface RouterDef<
|
|
23
|
-
TRoot extends AnyRootTypes,
|
|
24
|
-
TRecord extends ProcedureRouterRecord,
|
|
25
|
-
> {
|
|
26
|
-
_config: RootConfig<TRoot>;
|
|
27
|
-
router: true;
|
|
28
|
-
procedure?: never;
|
|
29
|
-
procedures: TRecord;
|
|
30
|
-
record: TRecord;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export type AnyRouterDef = RouterDef<any, any>;
|
|
34
|
-
|
|
35
22
|
type DecorateProcedure<TProcedure extends AnyProcedure> = (
|
|
36
23
|
input: inferProcedureInput<TProcedure>,
|
|
37
24
|
) => Promise<TProcedure['_def']['_output_out']>;
|
|
@@ -50,46 +37,54 @@ type DecoratedProcedureRecord<TProcedures extends ProcedureRouterRecord> = {
|
|
|
50
37
|
/**
|
|
51
38
|
* @internal
|
|
52
39
|
*/
|
|
53
|
-
export type RouterCaller<
|
|
40
|
+
export type RouterCaller<
|
|
41
|
+
TRoot extends AnyRootTypes,
|
|
42
|
+
TRecord extends ProcedureRouterRecord,
|
|
43
|
+
> = (
|
|
54
44
|
/**
|
|
55
45
|
* @note
|
|
56
46
|
* If passing a function, we recommend it's a cached function
|
|
57
47
|
* e.g. wrapped in `React.cache` to avoid unnecessary computations
|
|
58
48
|
*/
|
|
59
|
-
ctx:
|
|
60
|
-
|
|
61
|
-
| (() => MaybePromise<TDef['_config']['$types']['ctx']>),
|
|
62
|
-
) => DecoratedProcedureRecord<TDef['record']>;
|
|
49
|
+
ctx: TRoot['ctx'] | (() => MaybePromise<TRoot['ctx']>),
|
|
50
|
+
) => DecoratedProcedureRecord<TRecord>;
|
|
63
51
|
|
|
64
|
-
export interface Router<
|
|
65
|
-
|
|
52
|
+
export interface Router<
|
|
53
|
+
TRoot extends AnyRootTypes,
|
|
54
|
+
TRecord extends ProcedureRouterRecord,
|
|
55
|
+
> {
|
|
56
|
+
_def: {
|
|
57
|
+
_config: RootConfig<TRoot>;
|
|
58
|
+
router: true;
|
|
59
|
+
procedure?: never;
|
|
60
|
+
procedures: TRecord;
|
|
61
|
+
record: TRecord;
|
|
62
|
+
};
|
|
66
63
|
/**
|
|
67
64
|
* @deprecated use `t.createCallerFactory(router)` instead
|
|
68
65
|
* @link https://trpc.io/docs/v11/server/server-side-calls
|
|
69
66
|
*/
|
|
70
|
-
createCaller: RouterCaller<
|
|
67
|
+
createCaller: RouterCaller<TRoot, TRecord>;
|
|
71
68
|
}
|
|
72
69
|
|
|
73
|
-
export type
|
|
70
|
+
export type BuiltRouter<
|
|
71
|
+
TRoot extends AnyRootTypes,
|
|
72
|
+
TRecord extends ProcedureRouterRecord,
|
|
73
|
+
> = Router<TRoot, TRecord> & TRecord;
|
|
74
|
+
|
|
75
|
+
export type AnyRouter = Router<any, any>;
|
|
74
76
|
|
|
75
|
-
type
|
|
76
|
-
|
|
77
|
-
>
|
|
78
|
-
? TParams extends AnyRouterDef
|
|
79
|
-
? TParams
|
|
80
|
-
: never
|
|
81
|
-
: never;
|
|
82
|
-
type inferRouterConfig<TRouter extends AnyRouter> =
|
|
83
|
-
inferRouterDef<TRouter>['_config'];
|
|
77
|
+
type inferRouterRootTypes<TRouter extends AnyRouter> =
|
|
78
|
+
TRouter['_def']['_config']['$types'];
|
|
84
79
|
|
|
85
80
|
export type inferRouterContext<TRouter extends AnyRouter> =
|
|
86
|
-
|
|
81
|
+
inferRouterRootTypes<TRouter>['ctx'];
|
|
87
82
|
export type inferRouterError<TRouter extends AnyRouter> =
|
|
88
|
-
|
|
83
|
+
inferRouterRootTypes<TRouter>['errorShape'];
|
|
89
84
|
export type inferRouterMeta<TRouter extends AnyRouter> =
|
|
90
|
-
|
|
85
|
+
inferRouterRootTypes<TRouter>['meta'];
|
|
91
86
|
|
|
92
|
-
type GetInferenceHelpers<
|
|
87
|
+
export type GetInferenceHelpers<
|
|
93
88
|
TType extends 'input' | 'output',
|
|
94
89
|
TRouter extends AnyRouter,
|
|
95
90
|
> = {
|
|
@@ -142,18 +137,6 @@ const reservedWords = [
|
|
|
142
137
|
'then',
|
|
143
138
|
];
|
|
144
139
|
|
|
145
|
-
/**
|
|
146
|
-
* @internal
|
|
147
|
-
*/
|
|
148
|
-
export type CreateRouterInner<
|
|
149
|
-
TRoot extends AnyRootTypes,
|
|
150
|
-
TProcRouterRecord extends ProcedureRouterRecord,
|
|
151
|
-
> = Router<RouterDef<TRoot, TProcRouterRecord>> &
|
|
152
|
-
/**
|
|
153
|
-
* This adds ability to call procedures directly but is primarily used for quick access in type inference
|
|
154
|
-
*/
|
|
155
|
-
TProcRouterRecord;
|
|
156
|
-
|
|
157
140
|
/**
|
|
158
141
|
* @internal
|
|
159
142
|
*/
|
|
@@ -162,9 +145,7 @@ export function createRouterFactory<TRoot extends AnyRootTypes>(
|
|
|
162
145
|
) {
|
|
163
146
|
return function createRouterInner<
|
|
164
147
|
TProcRouterRecord extends ProcedureRouterRecord,
|
|
165
|
-
>(
|
|
166
|
-
procedures: TProcRouterRecord,
|
|
167
|
-
): CreateRouterInner<TRoot, TProcRouterRecord> {
|
|
148
|
+
>(procedures: TProcRouterRecord): BuiltRouter<TRoot, TProcRouterRecord> {
|
|
168
149
|
const reservedWordsUsed = new Set(
|
|
169
150
|
Object.keys(procedures).filter((v) => reservedWords.includes(v)),
|
|
170
151
|
);
|
|
@@ -194,7 +175,7 @@ export function createRouterFactory<TRoot extends AnyRootTypes>(
|
|
|
194
175
|
}
|
|
195
176
|
recursiveGetPaths(procedures);
|
|
196
177
|
|
|
197
|
-
const _def:
|
|
178
|
+
const _def: AnyRouter['_def'] = {
|
|
198
179
|
_config: config,
|
|
199
180
|
router: true,
|
|
200
181
|
procedures: routerProcedures,
|
|
@@ -218,11 +199,11 @@ export function createRouterFactory<TRoot extends AnyRootTypes>(
|
|
|
218
199
|
});
|
|
219
200
|
});
|
|
220
201
|
|
|
221
|
-
return proxy as ReturnType<RouterCaller<any>>;
|
|
202
|
+
return proxy as ReturnType<RouterCaller<any, any>>;
|
|
222
203
|
},
|
|
223
204
|
};
|
|
224
205
|
|
|
225
|
-
return router as
|
|
206
|
+
return router as Router<TRoot, TProcRouterRecord> & TProcRouterRecord;
|
|
226
207
|
};
|
|
227
208
|
}
|
|
228
209
|
|
|
@@ -250,15 +231,16 @@ export function callProcedure(
|
|
|
250
231
|
}
|
|
251
232
|
|
|
252
233
|
export function createCallerFactory<TRoot extends AnyRootTypes>() {
|
|
253
|
-
return function createCallerInner<
|
|
254
|
-
|
|
255
|
-
|
|
234
|
+
return function createCallerInner<TRecord extends ProcedureRouterRecord>(
|
|
235
|
+
router: Router<TRoot, TRecord>,
|
|
236
|
+
): RouterCaller<TRoot, TRecord> {
|
|
256
237
|
const _def = router._def;
|
|
257
238
|
type Context = TRoot['ctx'];
|
|
258
239
|
|
|
259
240
|
return function createCaller(maybeContext) {
|
|
260
241
|
const proxy = createRecursiveProxy(({ path, args }) => {
|
|
261
242
|
const fullPath = path.join('.');
|
|
243
|
+
|
|
262
244
|
const procedure = _def.procedures[fullPath] as AnyProcedure;
|
|
263
245
|
|
|
264
246
|
const callProc = (ctx: Context) =>
|
|
@@ -280,7 +262,7 @@ export function createCallerFactory<TRoot extends AnyRootTypes>() {
|
|
|
280
262
|
return callProc(maybeContext);
|
|
281
263
|
});
|
|
282
264
|
|
|
283
|
-
return proxy as ReturnType<RouterCaller<any>>;
|
|
265
|
+
return proxy as ReturnType<RouterCaller<any, any>>;
|
|
284
266
|
};
|
|
285
267
|
};
|
|
286
268
|
}
|
|
@@ -288,25 +270,15 @@ export function createCallerFactory<TRoot extends AnyRootTypes>() {
|
|
|
288
270
|
/** @internal */
|
|
289
271
|
type MergeRouters<
|
|
290
272
|
TRouters extends AnyRouter[],
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
{}
|
|
295
|
-
>,
|
|
273
|
+
TRoot extends AnyRootTypes = TRouters[0]['_def']['_config']['$types'],
|
|
274
|
+
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
275
|
+
TRecord extends ProcedureRouterRecord = {},
|
|
296
276
|
> = TRouters extends [
|
|
297
277
|
infer Head extends AnyRouter,
|
|
298
278
|
...infer Tail extends AnyRouter[],
|
|
299
279
|
]
|
|
300
|
-
? MergeRouters<
|
|
301
|
-
|
|
302
|
-
{
|
|
303
|
-
_config: TRouterDef['_config'];
|
|
304
|
-
router: true;
|
|
305
|
-
procedures: Head['_def']['procedures'] & TRouterDef['procedures'];
|
|
306
|
-
record: Head['_def']['record'] & TRouterDef['record'];
|
|
307
|
-
}
|
|
308
|
-
>
|
|
309
|
-
: Router<TRouterDef> & TRouterDef['record'];
|
|
280
|
+
? MergeRouters<Tail, TRoot, Head['_def']['record'] & TRecord>
|
|
281
|
+
: BuiltRouter<TRoot, TRecord>;
|
|
310
282
|
|
|
311
283
|
export function mergeRouters<TRouters extends AnyRouter[]>(
|
|
312
284
|
...routerList: [...TRouters]
|
|
@@ -360,5 +332,6 @@ export function mergeRouters<TRouters extends AnyRouter[]>(
|
|
|
360
332
|
isServer: routerList.some((r) => r._def._config.isServer),
|
|
361
333
|
$types: routerList[0]?._def._config.$types,
|
|
362
334
|
})(record);
|
|
363
|
-
|
|
335
|
+
|
|
336
|
+
return router as MergeRouters<TRouters>;
|
|
364
337
|
}
|