@trpc/server 11.0.0-next-beta.241 → 11.0.0-next-beta.242

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.
Files changed (27) hide show
  1. package/dist/adapters/node-http/nodeHTTPRequestHandler.d.ts.map +1 -1
  2. package/dist/adapters/node-http/nodeHTTPRequestHandler.js +2 -0
  3. package/dist/adapters/node-http/nodeHTTPRequestHandler.mjs +2 -0
  4. package/dist/adapters/node-http/types.d.ts +3 -3
  5. package/dist/adapters/node-http/types.d.ts.map +1 -1
  6. package/dist/bundle-analysis.json +24 -24
  7. package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.d.ts.map +1 -1
  8. package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.js +2 -2
  9. package/dist/unstable-core-do-not-import/http/getHTTPStatusCode.mjs +2 -2
  10. package/dist/unstable-core-do-not-import/index.d.ts +1 -1
  11. package/dist/unstable-core-do-not-import/index.d.ts.map +1 -1
  12. package/dist/unstable-core-do-not-import/initTRPC.d.ts +8 -3
  13. package/dist/unstable-core-do-not-import/initTRPC.d.ts.map +1 -1
  14. package/dist/unstable-core-do-not-import/router.d.ts +23 -38
  15. package/dist/unstable-core-do-not-import/router.d.ts.map +1 -1
  16. package/dist/unstable-core-do-not-import/router.js +3 -3
  17. package/dist/unstable-core-do-not-import/router.mjs +3 -3
  18. package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts +1 -1
  19. package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts.map +1 -1
  20. package/dist/unstable-core-do-not-import/transformer.d.ts +1 -1
  21. package/package.json +2 -2
  22. package/src/adapters/node-http/nodeHTTPRequestHandler.ts +4 -2
  23. package/src/adapters/node-http/types.ts +3 -3
  24. package/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts +6 -3
  25. package/src/unstable-core-do-not-import/index.ts +0 -2
  26. package/src/unstable-core-do-not-import/router.ts +53 -78
  27. package/src/unstable-core-do-not-import/rpc/envelopes.ts +1 -3
@@ -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,iBA4HlE"}
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 { IncomingMessage, ServerResponse } from 'http';
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,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,MAAM,CAAC;AAE5D,OAAO,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,KAAK,EACV,sBAAsB,EACtB,eAAe,EAChB,MAAM,yBAAyB,CAAC;AAEjC,O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;;;;;;;;;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": 102398,
3
- "bundleOrigSize": 157219,
4
- "bundleReduction": 34.87,
2
+ "bundleSize": 102517,
3
+ "bundleOrigSize": 156851,
4
+ "bundleReduction": 34.64,
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.65,
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.04,
29
+ "percent": 9.03,
30
30
  "reduction": 21.53
31
31
  },
32
32
  {
@@ -47,8 +47,8 @@
47
47
  },
48
48
  {
49
49
  "id": "/src/unstable-core-do-not-import/router.ts",
50
- "size": 5634,
51
- "origSize": 10365,
50
+ "size": 5637,
51
+ "origSize": 9784,
52
52
  "renderedExports": [
53
53
  "createRouterFactory",
54
54
  "callProcedure",
@@ -62,7 +62,7 @@
62
62
  "/src/unstable-core-do-not-import/initTRPC.ts"
63
63
  ],
64
64
  "percent": 5.5,
65
- "reduction": 45.64
65
+ "reduction": 42.39
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.47,
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.86,
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.31,
134
+ "percent": 4.3,
135
135
  "reduction": 32.87
136
136
  },
137
137
  {
138
138
  "id": "/src/adapters/node-http/nodeHTTPRequestHandler.ts",
139
- "size": 3934,
140
- "origSize": 4505,
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.84,
149
- "reduction": 12.67
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.47,
162
+ "percent": 3.46,
163
163
  "reduction": 9.42
164
164
  },
165
165
  {
@@ -400,8 +400,8 @@
400
400
  },
401
401
  {
402
402
  "id": "/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts",
403
- "size": 1239,
404
- "origSize": 1486,
403
+ "size": 1233,
404
+ "origSize": 1608,
405
405
  "renderedExports": [
406
406
  "getHTTPStatusCode",
407
407
  "getHTTPStatusCodeFromError"
@@ -411,8 +411,8 @@
411
411
  "/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts",
412
412
  "/src/unstable-core-do-not-import/error/getErrorShape.ts"
413
413
  ],
414
- "percent": 1.21,
415
- "reduction": 16.62
414
+ "percent": 1.2,
415
+ "reduction": 23.32
416
416
  },
417
417
  {
418
418
  "id": "/src/adapters/node-http/content-type/json/getPostBody.ts",
@@ -438,7 +438,7 @@
438
438
  ],
439
439
  "removedExports": [],
440
440
  "dependents": [],
441
- "percent": 1,
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.29,
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": 2758,
715
+ "origSize": 2721,
716
716
  "renderedExports": [],
717
717
  "removedExports": [],
718
718
  "dependents": [],
@@ -746,8 +746,8 @@
746
746
  "renderedExports": [],
747
747
  "removedExports": [],
748
748
  "dependents": [
749
- "/src/adapters/next.ts",
750
749
  "/src/adapters/express.ts",
750
+ "/src/adapters/next.ts",
751
751
  "/src/adapters/standalone.ts"
752
752
  ],
753
753
  "percent": 0,
@@ -1 +1 @@
1
- {"version":3,"file":"getHTTPStatusCode.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/getHTTPStatusCode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAA2B,YAAY,EAAE,MAAM,QAAQ,CAAC;AA4BpE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,YAAY,GAAG,YAAY,EAAE,OAuBpE;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,SAAS,UAE1D"}
1
+ {"version":3,"file":"getHTTPStatusCode.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/getHTTPStatusCode.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EAA2B,YAAY,EAAE,MAAM,QAAQ,CAAC;AA4BpE,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,YAAY,GAAG,YAAY,EAAE,OAyBpE;AAED,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,SAAS,UAE1D"}
@@ -29,8 +29,8 @@ function getHTTPStatusCode(json) {
29
29
  const httpStatuses = new Set(arr.map((res)=>{
30
30
  if ('error' in res) {
31
31
  const data = res.error.data;
32
- if (typeof data['httpStatus'] === 'number') {
33
- return data['httpStatus'];
32
+ if (typeof data.httpStatus === 'number') {
33
+ return data.httpStatus;
34
34
  }
35
35
  const code = codes.TRPC_ERROR_CODES_BY_NUMBER[res.error.code];
36
36
  return getStatusCodeFromKey(code);
@@ -27,8 +27,8 @@ function getHTTPStatusCode(json) {
27
27
  const httpStatuses = new Set(arr.map((res)=>{
28
28
  if ('error' in res) {
29
29
  const data = res.error.data;
30
- if (typeof data['httpStatus'] === 'number') {
31
- return data['httpStatus'];
30
+ if (typeof data.httpStatus === 'number') {
31
+ return data.httpStatus;
32
32
  }
33
33
  const code = TRPC_ERROR_CODES_BY_NUMBER[res.error.code];
34
34
  return getStatusCodeFromKey(code);
@@ -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, AnyRouterDef, CreateRouterInner, ProcedureRecord, ProcedureRouterRecord, Router, RouterCaller, createRouterFactory, inferRouterContext, inferRouterError, inferRouterInputs, inferRouterMeta, inferRouterOutputs, } from './router';
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,aA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,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"}
@@ -56,7 +56,7 @@ declare class TRPCBuilder<TContext extends object, TMeta extends object> {
56
56
  * Create a router
57
57
  * @link https://trpc.io/docs/v11/server/routers
58
58
  */
59
- router: <TProcRouterRecord extends import("./router").ProcedureRouterRecord>(procedures: TProcRouterRecord) => import("./router").CreateRouterInner<{
59
+ router: <TProcRouterRecord extends import("./router").ProcedureRouterRecord>(procedures: TProcRouterRecord) => import("./router").BuiltRouter<{
60
60
  ctx: TContext;
61
61
  meta: TMeta;
62
62
  errorShape: undefined extends TOptions["errorFormatter"] ? DefaultErrorShape : inferErrorFormatterShape<TOptions["errorFormatter"]>;
@@ -71,12 +71,17 @@ declare class TRPCBuilder<TContext extends object, TMeta extends object> {
71
71
  * Create a server-side caller for a router
72
72
  * @link https://trpc.io/docs/v11/server/server-side-calls
73
73
  */
74
- createCallerFactory: <TRouter extends import("./router").Router<import("./router").RouterDef<{
74
+ createCallerFactory: <TRecord extends import("./router").ProcedureRouterRecord>(router: import("./router").Router<{
75
75
  ctx: TContext;
76
76
  meta: TMeta;
77
77
  errorShape: undefined extends TOptions["errorFormatter"] ? DefaultErrorShape : inferErrorFormatterShape<TOptions["errorFormatter"]>;
78
78
  transformer: undefined extends TOptions["transformer"] ? false : true;
79
- }, any>>>(router: TRouter) => import("./router").RouterCaller<TRouter["_def"]>;
79
+ }, TRecord>) => import("./router").RouterCaller<{
80
+ ctx: TContext;
81
+ meta: TMeta;
82
+ errorShape: undefined extends TOptions["errorFormatter"] ? DefaultErrorShape : inferErrorFormatterShape<TOptions["errorFormatter"]>;
83
+ transformer: undefined extends TOptions["transformer"] ? false : true;
84
+ }, TRecord>;
80
85
  };
81
86
  }
82
87
  /**
@@ -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,EACpB,MAAM,mBAAmB,CAAC;AAI3B,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAGL,YAAY,EACb,MAAM,UAAU,CAAC;AAClB,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,eAAe,CAAC;AAE5D,OAAO,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAErD,KAAK,wBAAwB,CAAC,KAAK,IAAI,KAAK,SAAS,cAAc,CACjE,GAAG,EACH,MAAM,MAAM,CACb,GACG,MAAM,GACN,iBAAiB,CAAC;AACtB,UAAU,oBAAoB,CAAC,QAAQ,SAAS,MAAM,EAAE,KAAK,SAAS,MAAM,CAC1E,SAAQ,OAAO,CACb,IAAI,CACF,UAAU,CAAC;IACT,GAAG,EAAE,QAAQ,CAAC;IACd,IAAI,EAAE,KAAK,CAAC;IACZ,UAAU,EAAE,GAAG,CAAC;IAChB,WAAW,EAAE,GAAG,CAAC;CAClB,CAAC,EACF,QAAQ,GAAG,aAAa,CACzB,CACF;IACD;;;OAGG;IACH,WAAW,CAAC,EAAE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BAAoB,CAAC,QAAQ,SAAS,MAAM,EAAE,KAAK,SAAS,MAAM,CAC1E,SAAQ,OAAO,CACb,IAAI,CACF,UAAU,CAAC;IACT,GAAG,EAAE,QAAQ,CAAC;IACd,IAAI,EAAE,KAAK,CAAC;IACZ,UAAU,EAAE,GAAG,CAAC;IAChB,WAAW,EAAE,GAAG,CAAC;CAClB,CAAC,EACF,QAAQ,GAAG,aAAa,CACzB,CACF;IACD;;;OAGG;IACH,WAAW,CAAC,EAAE,sBAAsB,CAAC;CACtC;AAED,cAAM,WAAW,CAAC,QAAQ,SAAS,MAAM,EAAE,KAAK,SAAS,MAAM;IAC7D;;;OAGG;IACH,OAAO,CAAC,WAAW,SAAS,MAAM,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,MAAM,CAAC;IAIrE;;;OAGG;IACH,IAAI,CAAC,QAAQ,SAAS,MAAM;IAI5B;;;OAGG;IACH,MAAM,CAAC,QAAQ,SAAS,oBAAoB,CAAC,QAAQ,EAAE,KAAK,CAAC,EAC3D,IAAI,CAAC,EACD,aAAa,CAAC,QAAQ,EAAE,oBAAoB,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC,GAC9D,SAAS;QAoDX;;;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,46 +7,44 @@ 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
21
13
  */
22
- type DecoratedProcedureRecord<TProcedures extends ProcedureRouterRecord> = {
14
+ export type DecoratedProcedureRecord<TProcedures extends ProcedureRouterRecord> = {
23
15
  [TKey in keyof TProcedures]: TProcedures[TKey] extends AnyRouter ? DecoratedProcedureRecord<TProcedures[TKey]['_def']['record']> : TProcedures[TKey] extends AnyProcedure ? DecorateProcedure<TProcedures[TKey]> : never;
24
16
  };
25
17
  /**
26
18
  * @internal
27
19
  */
28
- export type RouterCaller<TDef extends AnyRouterDef> = (
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: TDef['_config']['$types']['ctx'] | (() => MaybePromise<TDef['_config']['$types']['ctx']>)) => DecoratedProcedureRecord<TDef['record']>;
35
- export interface Router<TDef extends AnyRouterDef> {
36
- _def: TDef;
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<TDef>;
39
+ createCaller: RouterCaller<TRoot, TRecord>;
42
40
  }
43
- export type AnyRouter = Router<AnyRouterDef>;
44
- type inferRouterDef<TRouter extends AnyRouter> = TRouter extends Router<infer TParams> ? TParams extends AnyRouterDef ? TParams : never : never;
45
- type inferRouterConfig<TRouter extends AnyRouter> = inferRouterDef<TRouter>['_config'];
46
- export type inferRouterContext<TRouter extends AnyRouter> = inferRouterConfig<TRouter>['$types']['ctx'];
47
- export type inferRouterError<TRouter extends AnyRouter> = inferRouterConfig<TRouter>['$types']['errorShape'];
48
- export type inferRouterMeta<TRouter extends AnyRouter> = inferRouterConfig<TRouter>['$types']['meta'];
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
+ export 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 type CreateRouterInner<TRoot extends AnyRootTypes, TProcRouterRecord extends ProcedureRouterRecord> = Router<RouterDef<TRoot, TProcRouterRecord>> &
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>(): <TRouter extends Router<RouterDef<TRoot, any>>>(router: TRouter) => RouterCaller<TRouter["_def"]>;
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[], TRouterDef extends AnyRouterDef = RouterDef<TRouters[0]['_def']['_config']['$types'], {}>> = TRouters extends [
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,MAAM,WAAW,SAAS,CACxB,KAAK,SAAS,YAAY,EAC1B,OAAO,SAAS,qBAAqB;IAErC,OAAO,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IAC3B,MAAM,EAAE,IAAI,CAAC;IACb,SAAS,CAAC,EAAE,KAAK,CAAC;IAClB,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,OAAO,CAAC;CACjB;AAED,MAAM,MAAM,YAAY,GAAG,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAE/C,KAAK,iBAAiB,CAAC,UAAU,SAAS,YAAY,IAAI,CACxD,KAAK,EAAE,mBAAmB,CAAC,UAAU,CAAC,KACnC,OAAO,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;AAEhD;;GAEG;AACH,KAAK,wBAAwB,CAAC,WAAW,SAAS,qBAAqB,IAAI;KACxE,IAAI,IAAI,MAAM,W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D,KAAK,GACP,KAAK;CACV,CAAC;AAEF,MAAM,MAAM,iBAAiB,CAAC,OAAO,SAAS,SAAS,IAAI,mBAAmB,CAC5E,OAAO,EACP,OAAO,CACR,CAAC;AAEF,MAAM,MAAM,kBAAkB,CAAC,OAAO,SAAS,SAAS,IAAI,mBAAmB,CAC7E,QAAQ,EACR,OAAO,CACR,CAAC;AA8BF;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,SAAS,YAAY,EAC5D,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,6HAgE1B;AAOD;;GAEG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,oBAAoB,GAAG;IAAE,UAAU,EAAE,qBAAqB,CAAA;CAAE,oBAYnE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,SAAS,YAAY,6GAmC7D;AAED,gBAAgB;AAChB,KAAK,YAAY,CACf,QAAQ,SAAS,SAAS,EAAE,EAC5B,KAAK,SAAS,YAAY,GAAG,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,EAErE,OAAO,SAAS,qBAAqB,GAAG,EAAE,IACxC,QAAQ,SAAS;IACnB,MAAM,IAAI,SAAS,SAAS;IAC5B,GAAG,MAAM,IAAI,SAAS,SAAS,EAAE;CAClC,GACG,YAAY,CAAC,IAAI,EAAE,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,OAAO,CAAC,GAC3D,WAAW,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;AAEhC,wBAAgB,YAAY,CAAC,QAAQ,SAAS,SAAS,EAAE,EACvD,GAAG,UAAU,EAAE,CAAC,GAAG,QAAQ,CAAC,GAC3B,YAAY,CAAC,QAAQ,CAAC,CAoDxB"}
@@ -142,9 +142,9 @@ function mergeRouters(...routerList) {
142
142
  const router = createRouterFactory({
143
143
  errorFormatter,
144
144
  transformer: transformer$1,
145
- isDev: routerList.some((r)=>r._def._config.isDev),
146
- allowOutsideOfServer: routerList.some((r)=>r._def._config.allowOutsideOfServer),
147
- isServer: routerList.some((r)=>r._def._config.isServer),
145
+ isDev: routerList.every((r)=>r._def._config.isDev),
146
+ allowOutsideOfServer: routerList.every((r)=>r._def._config.allowOutsideOfServer),
147
+ isServer: routerList.every((r)=>r._def._config.isServer),
148
148
  $types: routerList[0]?._def._config.$types
149
149
  })(record);
150
150
  return router;
@@ -140,9 +140,9 @@ function mergeRouters(...routerList) {
140
140
  const router = createRouterFactory({
141
141
  errorFormatter,
142
142
  transformer,
143
- isDev: routerList.some((r)=>r._def._config.isDev),
144
- allowOutsideOfServer: routerList.some((r)=>r._def._config.allowOutsideOfServer),
145
- isServer: routerList.some((r)=>r._def._config.isServer),
143
+ isDev: routerList.every((r)=>r._def._config.isDev),
144
+ allowOutsideOfServer: routerList.every((r)=>r._def._config.allowOutsideOfServer),
145
+ isServer: routerList.every((r)=>r._def._config.isServer),
146
146
  $types: routerList[0]?._def._config.$types
147
147
  })(record);
148
148
  return router;
@@ -3,7 +3,7 @@ import type { TRPC_ERROR_CODE_NUMBER } from './codes';
3
3
  /**
4
4
  * Error response
5
5
  */
6
- export interface TRPCErrorShape<TData extends Record<string, unknown> = Record<string, unknown>> {
6
+ export interface TRPCErrorShape<TData extends object = object> {
7
7
  code: TRPC_ERROR_CODE_NUMBER;
8
8
  message: string;
9
9
  data: TData;
@@ -1 +1 @@
1
- {"version":3,"file":"envelopes.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/rpc/envelopes.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEtD;;GAEG;AACH,MAAM,WAAW,cAAc,CAC7B,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAE/D,I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EAAE,QAAQ,CAAC,SAAS,CAAA;CAAE,CAAC,CAAC;AAE7E,MAAM,WAAW,iBAAiB,CAAC,KAAK,CACtC,SAAQ,QAAQ,CAAC,cAAc,CAC3B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,CAAC,EAAE,KAAK,CAAA;CAAE,GACjC;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,IAAI,CAAC,EAAE,KAAK,CAAA;CAAE,GACjC,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC,CACzC;CAAG;AAEN,MAAM,MAAM,mBAAmB,CAC7B,KAAK,GAAG,OAAO,EACf,MAAM,SAAS,cAAc,GAAG,cAAc,IAC5C;IAAE,EAAE,EAAE,QAAQ,CAAC,SAAS,CAAA;CAAE,GAAG,CAC7B,iBAAiB,CAAC,MAAM,CAAC,GACzB,iBAAiB,CAAC,KAAK,CAAC,CAC3B,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,yBACf,SAAQ,QAAQ,CAAC,WAAW,CAAC,WAAW,CAAC;IACzC,EAAE,EAAE,QAAQ,CAAC,SAAS,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,yBAAyB,CAAC;AAElE;;GAEG;AACH,MAAM,MAAM,yBAAyB,CACnC,OAAO,GAAG,OAAO,EACjB,MAAM,SAAS,cAAc,GAAG,cAAc,IAC5C,yBAAyB,GAAG,mBAAmB,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC"}
@@ -63,7 +63,7 @@ export declare const defaultTransformer: CombinedDataTransformer;
63
63
  /**
64
64
  * Takes a unserialized `TRPCResponse` and serializes it with the router's transformers
65
65
  **/
66
- export declare function transformTRPCResponse<TResponse extends TRPCResponse | TRPCResponse[] | TRPCResponseMessage | TRPCResponseMessage[]>(config: RootConfig<AnyRootTypes>, itemOrItems: TResponse): import("./rpc").TRPCErrorResponse<import("./rpc").TRPCErrorShape<Record<string, unknown>>> | import("./rpc").TRPCSuccessResponse<unknown> | ({
66
+ export declare function transformTRPCResponse<TResponse extends TRPCResponse | TRPCResponse[] | TRPCResponseMessage | TRPCResponseMessage[]>(config: RootConfig<AnyRootTypes>, itemOrItems: TResponse): import("./rpc").TRPCErrorResponse<import("./rpc").TRPCErrorShape<object>> | import("./rpc").TRPCSuccessResponse<unknown> | ({
67
67
  id: import("./rpc").JSONRPC2.RequestId;
68
68
  } & TRPCResultMessage<unknown>) | (TRPCResponse | TRPCResponseMessage)[];
69
69
  /** @internal */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/server",
3
- "version": "11.0.0-next-beta.241+afd416625",
3
+ "version": "11.0.0-next-beta.242+4377b3cf6",
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": "afd4166250f89d213dcdfc3c2fb59ee389e5da6b"
160
+ "gitHead": "4377b3cf6370c6af33064a7ae7c34299c8c00fa1"
161
161
  }
@@ -69,7 +69,8 @@ export async function nodeHTTPRequestHandler<
69
69
  const contentTypeHandler =
70
70
  contentTypeHandlers.find((handler) =>
71
71
  handler.isMatch({
72
- ...opts,
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
- ...opts,
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 { IncomingMessage, ServerResponse } from 'http';
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
  *
@@ -1,3 +1,4 @@
1
+ import type { DefaultErrorData } from '../error/formatter';
1
2
  import type { TRPCError } from '../error/TRPCError';
2
3
  import type { TRPC_ERROR_CODES_BY_KEY, TRPCResponse } from '../rpc';
3
4
  import { TRPC_ERROR_CODES_BY_NUMBER } from '../rpc';
@@ -32,9 +33,11 @@ export function getHTTPStatusCode(json: TRPCResponse | TRPCResponse[]) {
32
33
  const httpStatuses = new Set(
33
34
  arr.map((res) => {
34
35
  if ('error' in res) {
35
- const data = res.error.data;
36
- if (typeof data['httpStatus'] === 'number') {
37
- return data['httpStatus'];
36
+ const data = res.error.data as
37
+ | Record<string, unknown>
38
+ | DefaultErrorData;
39
+ if (typeof data.httpStatus === 'number') {
40
+ return data.httpStatus;
38
41
  }
39
42
  const code = TRPC_ERROR_CODES_BY_NUMBER[res.error.code];
40
43
  return getStatusCodeFromKey(code);
@@ -52,8 +52,6 @@ export type { ProcedureBuilder } from './procedureBuilder';
52
52
  export * from './rootConfig';
53
53
  export type {
54
54
  AnyRouter,
55
- AnyRouterDef,
56
- CreateRouterInner,
57
55
  ProcedureRecord,
58
56
  ProcedureRouterRecord,
59
57
  Router,
@@ -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']>;
@@ -39,7 +26,9 @@ type DecorateProcedure<TProcedure extends AnyProcedure> = (
39
26
  /**
40
27
  * @internal
41
28
  */
42
- type DecoratedProcedureRecord<TProcedures extends ProcedureRouterRecord> = {
29
+ export type DecoratedProcedureRecord<
30
+ TProcedures extends ProcedureRouterRecord,
31
+ > = {
43
32
  [TKey in keyof TProcedures]: TProcedures[TKey] extends AnyRouter
44
33
  ? DecoratedProcedureRecord<TProcedures[TKey]['_def']['record']>
45
34
  : TProcedures[TKey] extends AnyProcedure
@@ -50,46 +39,54 @@ type DecoratedProcedureRecord<TProcedures extends ProcedureRouterRecord> = {
50
39
  /**
51
40
  * @internal
52
41
  */
53
- export type RouterCaller<TDef extends AnyRouterDef> = (
42
+ export type RouterCaller<
43
+ TRoot extends AnyRootTypes,
44
+ TRecord extends ProcedureRouterRecord,
45
+ > = (
54
46
  /**
55
47
  * @note
56
48
  * If passing a function, we recommend it's a cached function
57
49
  * e.g. wrapped in `React.cache` to avoid unnecessary computations
58
50
  */
59
- ctx:
60
- | TDef['_config']['$types']['ctx']
61
- | (() => MaybePromise<TDef['_config']['$types']['ctx']>),
62
- ) => DecoratedProcedureRecord<TDef['record']>;
51
+ ctx: TRoot['ctx'] | (() => MaybePromise<TRoot['ctx']>),
52
+ ) => DecoratedProcedureRecord<TRecord>;
63
53
 
64
- export interface Router<TDef extends AnyRouterDef> {
65
- _def: TDef;
54
+ export interface Router<
55
+ TRoot extends AnyRootTypes,
56
+ TRecord extends ProcedureRouterRecord,
57
+ > {
58
+ _def: {
59
+ _config: RootConfig<TRoot>;
60
+ router: true;
61
+ procedure?: never;
62
+ procedures: TRecord;
63
+ record: TRecord;
64
+ };
66
65
  /**
67
66
  * @deprecated use `t.createCallerFactory(router)` instead
68
67
  * @link https://trpc.io/docs/v11/server/server-side-calls
69
68
  */
70
- createCaller: RouterCaller<TDef>;
69
+ createCaller: RouterCaller<TRoot, TRecord>;
71
70
  }
72
71
 
73
- export type AnyRouter = Router<AnyRouterDef>;
72
+ export type BuiltRouter<
73
+ TRoot extends AnyRootTypes,
74
+ TRecord extends ProcedureRouterRecord,
75
+ > = Router<TRoot, TRecord> & TRecord;
74
76
 
75
- type inferRouterDef<TRouter extends AnyRouter> = TRouter extends Router<
76
- infer TParams
77
- >
78
- ? TParams extends AnyRouterDef
79
- ? TParams
80
- : never
81
- : never;
82
- type inferRouterConfig<TRouter extends AnyRouter> =
83
- inferRouterDef<TRouter>['_config'];
77
+ export type AnyRouter = Router<any, any>;
78
+
79
+ export type inferRouterRootTypes<TRouter extends AnyRouter> =
80
+ TRouter['_def']['_config']['$types'];
84
81
 
85
82
  export type inferRouterContext<TRouter extends AnyRouter> =
86
- inferRouterConfig<TRouter>['$types']['ctx'];
83
+ inferRouterRootTypes<TRouter>['ctx'];
87
84
  export type inferRouterError<TRouter extends AnyRouter> =
88
- inferRouterConfig<TRouter>['$types']['errorShape'];
85
+ inferRouterRootTypes<TRouter>['errorShape'];
89
86
  export type inferRouterMeta<TRouter extends AnyRouter> =
90
- inferRouterConfig<TRouter>['$types']['meta'];
87
+ inferRouterRootTypes<TRouter>['meta'];
91
88
 
92
- type GetInferenceHelpers<
89
+ export type GetInferenceHelpers<
93
90
  TType extends 'input' | 'output',
94
91
  TRouter extends AnyRouter,
95
92
  > = {
@@ -142,18 +139,6 @@ const reservedWords = [
142
139
  'then',
143
140
  ];
144
141
 
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
142
  /**
158
143
  * @internal
159
144
  */
@@ -162,9 +147,7 @@ export function createRouterFactory<TRoot extends AnyRootTypes>(
162
147
  ) {
163
148
  return function createRouterInner<
164
149
  TProcRouterRecord extends ProcedureRouterRecord,
165
- >(
166
- procedures: TProcRouterRecord,
167
- ): CreateRouterInner<TRoot, TProcRouterRecord> {
150
+ >(procedures: TProcRouterRecord): BuiltRouter<TRoot, TProcRouterRecord> {
168
151
  const reservedWordsUsed = new Set(
169
152
  Object.keys(procedures).filter((v) => reservedWords.includes(v)),
170
153
  );
@@ -194,7 +177,7 @@ export function createRouterFactory<TRoot extends AnyRootTypes>(
194
177
  }
195
178
  recursiveGetPaths(procedures);
196
179
 
197
- const _def: AnyRouterDef = {
180
+ const _def: AnyRouter['_def'] = {
198
181
  _config: config,
199
182
  router: true,
200
183
  procedures: routerProcedures,
@@ -202,7 +185,7 @@ export function createRouterFactory<TRoot extends AnyRootTypes>(
202
185
  record: procedures,
203
186
  };
204
187
 
205
- const router: AnyRouter = {
188
+ const router: BuiltRouter<TRoot, TProcRouterRecord> = {
206
189
  ...procedures,
207
190
  _def,
208
191
  createCaller(ctx) {
@@ -218,11 +201,11 @@ export function createRouterFactory<TRoot extends AnyRootTypes>(
218
201
  });
219
202
  });
220
203
 
221
- return proxy as ReturnType<RouterCaller<any>>;
204
+ return proxy as ReturnType<RouterCaller<any, any>>;
222
205
  },
223
206
  };
224
207
 
225
- return router as any;
208
+ return router;
226
209
  };
227
210
  }
228
211
 
@@ -250,15 +233,16 @@ export function callProcedure(
250
233
  }
251
234
 
252
235
  export function createCallerFactory<TRoot extends AnyRootTypes>() {
253
- return function createCallerInner<
254
- TRouter extends Router<RouterDef<TRoot, any>>,
255
- >(router: TRouter): RouterCaller<TRouter['_def']> {
236
+ return function createCallerInner<TRecord extends ProcedureRouterRecord>(
237
+ router: Router<TRoot, TRecord>,
238
+ ): RouterCaller<TRoot, TRecord> {
256
239
  const _def = router._def;
257
240
  type Context = TRoot['ctx'];
258
241
 
259
242
  return function createCaller(maybeContext) {
260
243
  const proxy = createRecursiveProxy(({ path, args }) => {
261
244
  const fullPath = path.join('.');
245
+
262
246
  const procedure = _def.procedures[fullPath] as AnyProcedure;
263
247
 
264
248
  const callProc = (ctx: Context) =>
@@ -280,7 +264,7 @@ export function createCallerFactory<TRoot extends AnyRootTypes>() {
280
264
  return callProc(maybeContext);
281
265
  });
282
266
 
283
- return proxy as ReturnType<RouterCaller<any>>;
267
+ return proxy as ReturnType<RouterCaller<any, any>>;
284
268
  };
285
269
  };
286
270
  }
@@ -288,25 +272,15 @@ export function createCallerFactory<TRoot extends AnyRootTypes>() {
288
272
  /** @internal */
289
273
  type MergeRouters<
290
274
  TRouters extends AnyRouter[],
291
- TRouterDef extends AnyRouterDef = RouterDef<
292
- TRouters[0]['_def']['_config']['$types'],
293
- // eslint-disable-next-line @typescript-eslint/ban-types
294
- {}
295
- >,
275
+ TRoot extends AnyRootTypes = TRouters[0]['_def']['_config']['$types'],
276
+ // eslint-disable-next-line @typescript-eslint/ban-types
277
+ TRecord extends ProcedureRouterRecord = {},
296
278
  > = TRouters extends [
297
279
  infer Head extends AnyRouter,
298
280
  ...infer Tail extends AnyRouter[],
299
281
  ]
300
- ? MergeRouters<
301
- Tail,
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'];
282
+ ? MergeRouters<Tail, TRoot, Head['_def']['record'] & TRecord>
283
+ : BuiltRouter<TRoot, TRecord>;
310
284
 
311
285
  export function mergeRouters<TRouters extends AnyRouter[]>(
312
286
  ...routerList: [...TRouters]
@@ -353,12 +327,13 @@ export function mergeRouters<TRouters extends AnyRouter[]>(
353
327
  const router = createRouterFactory({
354
328
  errorFormatter,
355
329
  transformer,
356
- isDev: routerList.some((r) => r._def._config.isDev),
357
- allowOutsideOfServer: routerList.some(
330
+ isDev: routerList.every((r) => r._def._config.isDev),
331
+ allowOutsideOfServer: routerList.every(
358
332
  (r) => r._def._config.allowOutsideOfServer,
359
333
  ),
360
- isServer: routerList.some((r) => r._def._config.isServer),
334
+ isServer: routerList.every((r) => r._def._config.isServer),
361
335
  $types: routerList[0]?._def._config.$types,
362
336
  })(record);
363
- return router as any;
337
+
338
+ return router as MergeRouters<TRouters>;
364
339
  }
@@ -5,9 +5,7 @@ import type { TRPC_ERROR_CODE_NUMBER } from './codes';
5
5
  /**
6
6
  * Error response
7
7
  */
8
- export interface TRPCErrorShape<
9
- TData extends Record<string, unknown> = Record<string, unknown>,
10
- > {
8
+ export interface TRPCErrorShape<TData extends object = object> {
11
9
  code: TRPC_ERROR_CODE_NUMBER;
12
10
  message: string;
13
11
  data: TData;