@trpc/server 11.0.0-next-beta.237 → 11.0.0-next-beta.239
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/bundle-analysis.json +27 -27
- package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts +4 -4
- package/dist/unstable-core-do-not-import/TRPCInferrable.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts +5 -5
- package/dist/unstable-core-do-not-import/error/getErrorShape.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/index.d.ts +2 -2
- package/dist/unstable-core-do-not-import/index.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/index.js +2 -0
- package/dist/unstable-core-do-not-import/index.mjs +1 -1
- package/dist/unstable-core-do-not-import/initTRPC.d.ts +4 -4
- package/dist/unstable-core-do-not-import/initTRPC.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/procedure.d.ts +3 -3
- package/dist/unstable-core-do-not-import/procedure.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/rootConfig.d.ts +4 -7
- package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/router.d.ts +10 -10
- package/dist/unstable-core-do-not-import/router.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/router.mjs +1 -1
- package/dist/unstable-core-do-not-import/transformer.d.ts +2 -2
- package/dist/unstable-core-do-not-import/transformer.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/unstable-core-do-not-import/TRPCInferrable.ts +7 -7
- package/src/unstable-core-do-not-import/error/getErrorShape.ts +5 -5
- package/src/unstable-core-do-not-import/index.ts +2 -2
- package/src/unstable-core-do-not-import/initTRPC.ts +7 -12
- package/src/unstable-core-do-not-import/procedure.ts +3 -3
- package/src/unstable-core-do-not-import/rootConfig.ts +4 -8
- package/src/unstable-core-do-not-import/router.ts +17 -21
- package/src/unstable-core-do-not-import/transformer.ts +3 -3
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"bundleSize": 102411,
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction": 35
|
|
3
|
+
"bundleOrigSize": 157550,
|
|
4
|
+
"bundleReduction": 35,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/adapters/ws.ts",
|
|
@@ -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": 10365,
|
|
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":
|
|
65
|
+
"reduction": 45.64
|
|
66
66
|
},
|
|
67
67
|
{
|
|
68
68
|
"id": "/src/unstable-core-do-not-import/procedureBuilder.ts",
|
|
@@ -216,7 +216,7 @@
|
|
|
216
216
|
{
|
|
217
217
|
"id": "/src/unstable-core-do-not-import/initTRPC.ts",
|
|
218
218
|
"size": 2879,
|
|
219
|
-
"origSize":
|
|
219
|
+
"origSize": 4650,
|
|
220
220
|
"renderedExports": [
|
|
221
221
|
"initTRPC"
|
|
222
222
|
],
|
|
@@ -225,12 +225,12 @@
|
|
|
225
225
|
"/src/unstable-core-do-not-import/index.ts"
|
|
226
226
|
],
|
|
227
227
|
"percent": 2.81,
|
|
228
|
-
"reduction": 38.
|
|
228
|
+
"reduction": 38.09
|
|
229
229
|
},
|
|
230
230
|
{
|
|
231
231
|
"id": "/src/unstable-core-do-not-import/transformer.ts",
|
|
232
232
|
"size": 2744,
|
|
233
|
-
"origSize":
|
|
233
|
+
"origSize": 5076,
|
|
234
234
|
"renderedExports": [
|
|
235
235
|
"getDataTransformer",
|
|
236
236
|
"defaultTransformer",
|
|
@@ -245,7 +245,7 @@
|
|
|
245
245
|
"/src/unstable-core-do-not-import/router.ts"
|
|
246
246
|
],
|
|
247
247
|
"percent": 2.68,
|
|
248
|
-
"reduction": 45.
|
|
248
|
+
"reduction": 45.94
|
|
249
249
|
},
|
|
250
250
|
{
|
|
251
251
|
"id": "/src/adapters/fastify/fastifyRequestHandler.ts",
|
|
@@ -408,8 +408,8 @@
|
|
|
408
408
|
],
|
|
409
409
|
"removedExports": [],
|
|
410
410
|
"dependents": [
|
|
411
|
-
"/src/unstable-core-do-not-import/
|
|
412
|
-
"/src/unstable-core-do-not-import/
|
|
411
|
+
"/src/unstable-core-do-not-import/error/getErrorShape.ts",
|
|
412
|
+
"/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts"
|
|
413
413
|
],
|
|
414
414
|
"percent": 1.21,
|
|
415
415
|
"reduction": 16.62
|
|
@@ -455,11 +455,11 @@
|
|
|
455
455
|
"dependents": [
|
|
456
456
|
"/src/unstable-core-do-not-import/index.ts",
|
|
457
457
|
"/src/unstable-core-do-not-import/rpc/codes.ts",
|
|
458
|
+
"/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
|
|
458
459
|
"/src/unstable-core-do-not-import/error/TRPCError.ts",
|
|
459
460
|
"/src/unstable-core-do-not-import/middleware.ts",
|
|
460
461
|
"/src/unstable-core-do-not-import/router.ts",
|
|
461
462
|
"/src/unstable-core-do-not-import/transformer.ts",
|
|
462
|
-
"/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
|
|
463
463
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
464
464
|
],
|
|
465
465
|
"percent": 0.98,
|
|
@@ -559,7 +559,7 @@
|
|
|
559
559
|
{
|
|
560
560
|
"id": "/src/unstable-core-do-not-import/error/getErrorShape.ts",
|
|
561
561
|
"size": 625,
|
|
562
|
-
"origSize":
|
|
562
|
+
"origSize": 1106,
|
|
563
563
|
"renderedExports": [
|
|
564
564
|
"getErrorShape"
|
|
565
565
|
],
|
|
@@ -569,12 +569,12 @@
|
|
|
569
569
|
"/src/unstable-core-do-not-import/http/resolveHTTPResponse.ts"
|
|
570
570
|
],
|
|
571
571
|
"percent": 0.61,
|
|
572
|
-
"reduction": 43.
|
|
572
|
+
"reduction": 43.49
|
|
573
573
|
},
|
|
574
574
|
{
|
|
575
575
|
"id": "/src/unstable-core-do-not-import/rootConfig.ts",
|
|
576
576
|
"size": 343,
|
|
577
|
-
"origSize":
|
|
577
|
+
"origSize": 2166,
|
|
578
578
|
"renderedExports": [
|
|
579
579
|
"isServerDefault"
|
|
580
580
|
],
|
|
@@ -584,7 +584,7 @@
|
|
|
584
584
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
585
585
|
],
|
|
586
586
|
"percent": 0.33,
|
|
587
|
-
"reduction": 84.
|
|
587
|
+
"reduction": 84.16
|
|
588
588
|
},
|
|
589
589
|
{
|
|
590
590
|
"id": "/src/adapters/express.ts",
|
|
@@ -621,8 +621,8 @@
|
|
|
621
621
|
],
|
|
622
622
|
"removedExports": [],
|
|
623
623
|
"dependents": [
|
|
624
|
-
"/src/adapters/node-http/content-type/
|
|
625
|
-
"/src/adapters/node-http/content-type/
|
|
624
|
+
"/src/adapters/node-http/content-type/json/index.ts",
|
|
625
|
+
"/src/adapters/node-http/content-type/form-data/index.ts"
|
|
626
626
|
],
|
|
627
627
|
"percent": 0.11,
|
|
628
628
|
"reduction": 86.68
|
|
@@ -630,7 +630,7 @@
|
|
|
630
630
|
{
|
|
631
631
|
"id": "/src/unstable-core-do-not-import/procedure.ts",
|
|
632
632
|
"size": 75,
|
|
633
|
-
"origSize":
|
|
633
|
+
"origSize": 2754,
|
|
634
634
|
"renderedExports": [
|
|
635
635
|
"procedureTypes"
|
|
636
636
|
],
|
|
@@ -658,9 +658,9 @@
|
|
|
658
658
|
"reduction": 94.08
|
|
659
659
|
},
|
|
660
660
|
{
|
|
661
|
-
"id": "/src/
|
|
661
|
+
"id": "/src/rpc.ts",
|
|
662
662
|
"size": 0,
|
|
663
|
-
"origSize":
|
|
663
|
+
"origSize": 36,
|
|
664
664
|
"renderedExports": [],
|
|
665
665
|
"removedExports": [],
|
|
666
666
|
"dependents": [],
|
|
@@ -668,9 +668,9 @@
|
|
|
668
668
|
"reduction": 100
|
|
669
669
|
},
|
|
670
670
|
{
|
|
671
|
-
"id": "/src/
|
|
671
|
+
"id": "/src/shared.ts",
|
|
672
672
|
"size": 0,
|
|
673
|
-
"origSize":
|
|
673
|
+
"origSize": 653,
|
|
674
674
|
"renderedExports": [],
|
|
675
675
|
"removedExports": [],
|
|
676
676
|
"dependents": [],
|
|
@@ -678,9 +678,9 @@
|
|
|
678
678
|
"reduction": 100
|
|
679
679
|
},
|
|
680
680
|
{
|
|
681
|
-
"id": "/src/
|
|
681
|
+
"id": "/src/http.ts",
|
|
682
682
|
"size": 0,
|
|
683
|
-
"origSize":
|
|
683
|
+
"origSize": 37,
|
|
684
684
|
"renderedExports": [],
|
|
685
685
|
"removedExports": [],
|
|
686
686
|
"dependents": [],
|
|
@@ -688,9 +688,9 @@
|
|
|
688
688
|
"reduction": 100
|
|
689
689
|
},
|
|
690
690
|
{
|
|
691
|
-
"id": "/src/
|
|
691
|
+
"id": "/src/index.ts",
|
|
692
692
|
"size": 0,
|
|
693
|
-
"origSize":
|
|
693
|
+
"origSize": 32,
|
|
694
694
|
"renderedExports": [],
|
|
695
695
|
"removedExports": [],
|
|
696
696
|
"dependents": [],
|
|
@@ -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": 2758,
|
|
716
716
|
"renderedExports": [],
|
|
717
717
|
"removedExports": [],
|
|
718
718
|
"dependents": [],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AnyRootTypes } from './rootConfig';
|
|
2
2
|
import type { AnyRouter } from './router';
|
|
3
|
-
export type TRPCInferrable = AnyRouter |
|
|
4
|
-
export type
|
|
5
|
-
export type inferErrorShape<TInferrable extends TRPCInferrable> =
|
|
3
|
+
export type TRPCInferrable = AnyRouter | AnyRootTypes;
|
|
4
|
+
export type inferRootTypes<TInferrable extends TRPCInferrable> = TInferrable extends AnyRootTypes ? TInferrable : TInferrable extends AnyRouter ? TInferrable['_def']['_config']['$types'] : never;
|
|
5
|
+
export type inferErrorShape<TInferrable extends TRPCInferrable> = inferRootTypes<TInferrable>['errorShape'];
|
|
6
6
|
//# sourceMappingURL=TRPCInferrable.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TRPCInferrable.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/TRPCInferrable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"TRPCInferrable.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/TRPCInferrable.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,YAAY,CAAC;AACtD,MAAM,MAAM,cAAc,CAAC,WAAW,SAAS,cAAc,IAC3D,WAAW,SAAS,YAAY,GAC5B,WAAW,GACX,WAAW,SAAS,SAAS,GAC7B,WAAW,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,GACxC,KAAK,CAAC;AAEZ,MAAM,MAAM,eAAe,CAAC,WAAW,SAAS,cAAc,IAC5D,cAAc,CAAC,WAAW,CAAC,CAAC,YAAY,CAAC,CAAC"}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import type { ProcedureType } from '../procedure';
|
|
2
|
-
import type {
|
|
2
|
+
import type { AnyRootTypes, RootConfig } from '../rootConfig';
|
|
3
3
|
import type { TRPCError } from './TRPCError';
|
|
4
4
|
/**
|
|
5
5
|
* @internal
|
|
6
6
|
*/
|
|
7
|
-
export declare function getErrorShape<
|
|
8
|
-
config:
|
|
7
|
+
export declare function getErrorShape<TRoot extends AnyRootTypes>(opts: {
|
|
8
|
+
config: RootConfig<TRoot>;
|
|
9
9
|
error: TRPCError;
|
|
10
10
|
type: ProcedureType | 'unknown';
|
|
11
11
|
path: string | undefined;
|
|
12
12
|
input: unknown;
|
|
13
|
-
ctx:
|
|
14
|
-
}):
|
|
13
|
+
ctx: TRoot['ctx'] | undefined;
|
|
14
|
+
}): TRoot['errorShape'];
|
|
15
15
|
//# sourceMappingURL=getErrorShape.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getErrorShape.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/error/getErrorShape.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"getErrorShape.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/error/getErrorShape.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG9D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAE7C;;GAEG;AACH,wBAAgB,aAAa,CAAC,KAAK,SAAS,YAAY,EAAE,IAAI,EAAE;IAC9D,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IAC1B,KAAK,EAAE,SAAS,CAAC;IACjB,IAAI,EAAE,aAAa,GAAG,SAAS,CAAC;IAChC,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,KAAK,EAAE,OAAO,CAAC;IACf,GAAG,EAAE,KAAK,CAAC,KAAK,CAAC,GAAG,SAAS,CAAC;CAC/B,GAAG,KAAK,CAAC,YAAY,CAAC,CAkBtB"}
|
|
@@ -21,8 +21,8 @@ export { createBuilder, unsetMarker } from './procedureBuilder';
|
|
|
21
21
|
export type { ProcedureBuilder } from './procedureBuilder';
|
|
22
22
|
export * from './rootConfig';
|
|
23
23
|
export type { AnyRouter, AnyRouterDef, CreateRouterInner, ProcedureRecord, ProcedureRouterRecord, Router, RouterCaller, createRouterFactory, inferRouterContext, inferRouterError, inferRouterInputs, inferRouterMeta, inferRouterOutputs, } from './router';
|
|
24
|
-
export
|
|
25
|
-
export
|
|
24
|
+
export * from './TRPCInferrable';
|
|
25
|
+
export * from './router';
|
|
26
26
|
export { transformResult, transformTRPCResponse } from './transformer';
|
|
27
27
|
export type { CombinedDataTransformer, CombinedDataTransformerClient, DataTransformer, DataTransformerOptions, } from './transformer';
|
|
28
28
|
export { createFlatProxy, createRecursiveProxy } from './createProxy';
|
|
@@ -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,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,qBAAqB,EACrB,MAAM,EACN,YAAY,EACZ,mBAAmB,EACnB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,kBAAkB,GACnB,MAAM,UAAU,CAAC;AAElB,
|
|
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,E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AACvB,cAAc,OAAO,CAAC"}
|
|
@@ -34,6 +34,8 @@ exports.createBuilder = procedureBuilder.createBuilder;
|
|
|
34
34
|
exports.unsetMarker = procedureBuilder.unsetMarker;
|
|
35
35
|
exports.isServerDefault = rootConfig.isServerDefault;
|
|
36
36
|
exports.callProcedure = router.callProcedure;
|
|
37
|
+
exports.createCallerFactory = router.createCallerFactory;
|
|
38
|
+
exports.createRouterFactory = router.createRouterFactory;
|
|
37
39
|
exports.mergeRouters = router.mergeRouters;
|
|
38
40
|
exports.transformResult = transformer.transformResult;
|
|
39
41
|
exports.transformTRPCResponse = transformer.transformTRPCResponse;
|
|
@@ -5,7 +5,7 @@ export { createInputMiddleware, createOutputMiddleware, experimental_standaloneM
|
|
|
5
5
|
export { procedureTypes } from './procedure.mjs';
|
|
6
6
|
export { createBuilder, unsetMarker } from './procedureBuilder.mjs';
|
|
7
7
|
export { isServerDefault } from './rootConfig.mjs';
|
|
8
|
-
export { callProcedure, mergeRouters } from './router.mjs';
|
|
8
|
+
export { callProcedure, createCallerFactory, createRouterFactory, mergeRouters } from './router.mjs';
|
|
9
9
|
export { transformResult, transformTRPCResponse } from './transformer.mjs';
|
|
10
10
|
export { createFlatProxy, createRecursiveProxy } from './createProxy.mjs';
|
|
11
11
|
export { isObject } from './utils.mjs';
|
|
@@ -55,12 +55,12 @@ 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").CreateRouterInner<
|
|
58
|
+
router: <TProcRouterRecord extends import("./router").ProcedureRouterRecord>(procedures: TProcRouterRecord) => import("./router").CreateRouterInner<{
|
|
59
59
|
ctx: TContext;
|
|
60
60
|
meta: TMeta;
|
|
61
61
|
errorShape: ErrorFormatterShape<PickFirstDefined<TOptions["errorFormatter"], ErrorFormatter<TContext, DefaultErrorShape>>>;
|
|
62
62
|
transformer: undefined extends TOptions["transformer"] ? false : true;
|
|
63
|
-
}
|
|
63
|
+
}, TProcRouterRecord>;
|
|
64
64
|
/**
|
|
65
65
|
* Merge Routers
|
|
66
66
|
* @link https://trpc.io/docs/v11/server/merging-routers
|
|
@@ -70,12 +70,12 @@ 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: <TRouter extends import("./router").Router<import("./router").
|
|
73
|
+
createCallerFactory: <TRouter extends import("./router").Router<import("./router").RouterDef<{
|
|
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
|
+
}, any>>>(router: TRouter) => import("./router").RouterCaller<TRouter["_def"]>;
|
|
79
79
|
};
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
@@ -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;
|
|
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,OAAO,EAAmB,KAAK,UAAU,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAGL,YAAY,EACb,MA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'../observable';
|
|
2
2
|
import type { ProcedureCallOptions } from './procedureBuilder';
|
|
3
3
|
import type { Serialize } from './serialize';
|
|
4
|
-
import type {
|
|
4
|
+
import type { inferRootTypes, TRPCInferrable } from './TRPCInferrable';
|
|
5
5
|
export declare const procedureTypes: readonly ["query", "mutation", "subscription"];
|
|
6
6
|
/**
|
|
7
7
|
* @public
|
|
@@ -56,9 +56,9 @@ export type AnyProcedure = Procedure<ProcedureType, any>;
|
|
|
56
56
|
/**
|
|
57
57
|
* @internal
|
|
58
58
|
*/
|
|
59
|
-
export type inferTransformedProcedureOutput<TInferrable extends TRPCInferrable, TProcedure extends AnyProcedure> =
|
|
59
|
+
export type inferTransformedProcedureOutput<TInferrable extends TRPCInferrable, TProcedure extends AnyProcedure> = inferRootTypes<TInferrable>['transformer'] extends false ? Serialize<TProcedure['_def']['_output_out']> : TProcedure['_def']['_output_out'];
|
|
60
60
|
/** @internal */
|
|
61
|
-
export type inferTransformedSubscriptionOutput<TInferrable extends TRPCInferrable, TProcedure extends AnyProcedure> =
|
|
61
|
+
export type inferTransformedSubscriptionOutput<TInferrable extends TRPCInferrable, TProcedure extends AnyProcedure> = inferRootTypes<TInferrable>['transformer'] extends false ? Serialize<inferObservableValue<TProcedure['_def']['_output_out']>> : inferObservableValue<TProcedure['_def']['_output_out']>;
|
|
62
62
|
export type inferProcedureInput<TProcedure extends AnyProcedure> = undefined extends inferProcedureParams<TProcedure>['_input_in'] ? void | inferProcedureParams<TProcedure>['_input_in'] : inferProcedureParams<TProcedure>['_input_in'];
|
|
63
63
|
export type inferProcedureParams<TProcedure> = TProcedure extends AnyProcedure ? TProcedure['_def'] : never;
|
|
64
64
|
export type inferProcedureOutput<TProcedure> = inferProcedureParams<TProcedure>['_output_out'];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"procedure.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/procedure.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB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C,CAAC,aAAa,CAAC,CAAC,CAAC;AAE5D,MAAM,MAAM,mBAAmB,CAAC,UAAU,SAAS,YAAY,IAC7D,SAAS,SAAS,oBAAoB,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,GAC3D,IAAI,GAAG,oBAAoB,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,GACpD,oBAAoB,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,CAAC;AAEpD,MAAM,MAAM,oBAAoB,CAAC,UAAU,IAAI,UAAU,SAAS,YAAY,GAC1E,UAAU,CAAC,MAAM,CAAC,GAClB,KAAK,CAAC;AACV,MAAM,MAAM,oBAAoB,CAAC,UAAU,IACzC,oBAAoB,CAAC,UAAU,CAAC,CAAC,aAAa,CAAC,CAAC"}
|
|
@@ -5,7 +5,7 @@ import type { TRPCErrorShape } from './rpc';
|
|
|
5
5
|
* The initial generics that are used in the init function
|
|
6
6
|
* @internal
|
|
7
7
|
*/
|
|
8
|
-
export interface
|
|
8
|
+
export interface RootTypes {
|
|
9
9
|
ctx: object;
|
|
10
10
|
meta: object;
|
|
11
11
|
errorShape: unknown;
|
|
@@ -19,7 +19,7 @@ export declare const isServerDefault: boolean;
|
|
|
19
19
|
* The tRPC root config
|
|
20
20
|
* @internal
|
|
21
21
|
*/
|
|
22
|
-
export interface RootConfig<TTypes extends
|
|
22
|
+
export interface RootConfig<TTypes extends RootTypes> {
|
|
23
23
|
/**
|
|
24
24
|
* The types that are used in the config
|
|
25
25
|
* @internal
|
|
@@ -60,11 +60,8 @@ export interface RootConfig<TTypes extends RootConfigTypes> {
|
|
|
60
60
|
/**
|
|
61
61
|
* @internal
|
|
62
62
|
*/
|
|
63
|
-
export type
|
|
64
|
-
|
|
65
|
-
* @internal
|
|
66
|
-
*/
|
|
67
|
-
export type AnyRootConfig = RootConfig<{
|
|
63
|
+
export type CreateRootTypes<TGenerics extends RootTypes> = TGenerics;
|
|
64
|
+
export type AnyRootTypes = CreateRootTypes<{
|
|
68
65
|
ctx: any;
|
|
69
66
|
meta: any;
|
|
70
67
|
errorShape: any;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rootConfig.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/rootConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,GAAG,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C;;;GAGG;AACH,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"rootConfig.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/rootConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,GAAG,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACxD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAE5C;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,OAAO,CAAC;IACpB,WAAW,EAAE,OAAO,CAAC;CACtB;AAED;;GAEG;AACH,eAAO,MAAM,eAAe,EAAE,OAMmB,CAAC;AAElD;;;GAGG;AACH,MAAM,WAAW,UAAU,CAAC,MAAM,SAAS,SAAS;IAClD;;;OAGG;IACH,MAAM,EAAE,MAAM,CAAC;IACf;;;OAGG;IACH,WAAW,EAAE,uBAAuB,CAAC;IACrC;;;OAGG;IACH,cAAc,EAAE,cAAc,CAC5B,MAAM,CAAC,KAAK,CAAC,EACb,cAAc,CAAC,MAAM,CAAC,GAAG;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAE,CAChD,CAAC;IACF;;;;OAIG;IACH,oBAAoB,EAAE,OAAO,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,EAAE,OAAO,CAAC;IAClB;;;;OAIG;IACH,KAAK,EAAE,OAAO,CAAC;IAEf,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC;CACtE;AAED;;GAEG;AACH,MAAM,MAAM,eAAe,CAAC,SAAS,SAAS,SAAS,IAAI,SAAS,CAAC;AAErE,MAAM,MAAM,YAAY,GAAG,eAAe,CAAC;IACzC,GAAG,EAAE,GAAG,CAAC;IACT,IAAI,EAAE,GAAG,CAAC;IACV,UAAU,EAAE,GAAG,CAAC;IAChB,WAAW,EAAE,GAAG,CAAC;CAClB,CAAC,CAAC"}
|
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import type { AnyProcedure, inferProcedureInput, inferTransformedProcedureOutput } from './procedure';
|
|
2
2
|
import type { ProcedureCallOptions } from './procedureBuilder';
|
|
3
|
-
import type {
|
|
3
|
+
import type { AnyRootTypes, RootConfig } from './rootConfig';
|
|
4
4
|
import type { MaybePromise } from './types';
|
|
5
5
|
/** @internal **/
|
|
6
6
|
export type ProcedureRecord = Record<string, AnyProcedure>;
|
|
7
7
|
export interface ProcedureRouterRecord {
|
|
8
8
|
[key: string]: AnyProcedure | AnyRouter;
|
|
9
9
|
}
|
|
10
|
-
export interface RouterDef<
|
|
11
|
-
_config:
|
|
10
|
+
export interface RouterDef<TRoot extends AnyRootTypes, TRecord extends ProcedureRouterRecord> {
|
|
11
|
+
_config: RootConfig<TRoot>;
|
|
12
12
|
router: true;
|
|
13
13
|
procedure?: never;
|
|
14
14
|
procedures: TRecord;
|
|
15
15
|
record: TRecord;
|
|
16
16
|
}
|
|
17
|
-
export type AnyRouterDef
|
|
17
|
+
export type AnyRouterDef = RouterDef<any, any>;
|
|
18
18
|
type DecorateProcedure<TProcedure extends AnyProcedure> = (input: inferProcedureInput<TProcedure>) => Promise<TProcedure['_def']['_output_out']>;
|
|
19
19
|
/**
|
|
20
20
|
* @internal
|
|
@@ -41,20 +41,20 @@ export interface Router<TDef extends AnyRouterDef> {
|
|
|
41
41
|
createCaller: RouterCaller<TDef>;
|
|
42
42
|
}
|
|
43
43
|
export type AnyRouter = Router<AnyRouterDef>;
|
|
44
|
-
type inferRouterDef<TRouter extends AnyRouter> = TRouter extends Router<infer TParams> ? TParams extends AnyRouterDef
|
|
44
|
+
type inferRouterDef<TRouter extends AnyRouter> = TRouter extends Router<infer TParams> ? TParams extends AnyRouterDef ? TParams : never : never;
|
|
45
45
|
type inferRouterConfig<TRouter extends AnyRouter> = inferRouterDef<TRouter>['_config'];
|
|
46
46
|
export type inferRouterContext<TRouter extends AnyRouter> = inferRouterConfig<TRouter>['$types']['ctx'];
|
|
47
47
|
export type inferRouterError<TRouter extends AnyRouter> = inferRouterConfig<TRouter>['$types']['errorShape'];
|
|
48
48
|
export type inferRouterMeta<TRouter extends AnyRouter> = inferRouterConfig<TRouter>['$types']['meta'];
|
|
49
49
|
type GetInferenceHelpers<TType extends 'input' | 'output', TRouter extends AnyRouter> = {
|
|
50
|
-
[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
|
|
50
|
+
[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
51
|
};
|
|
52
52
|
export type inferRouterInputs<TRouter extends AnyRouter> = GetInferenceHelpers<'input', TRouter>;
|
|
53
53
|
export type inferRouterOutputs<TRouter extends AnyRouter> = GetInferenceHelpers<'output', TRouter>;
|
|
54
54
|
/**
|
|
55
55
|
* @internal
|
|
56
56
|
*/
|
|
57
|
-
export type CreateRouterInner<
|
|
57
|
+
export type CreateRouterInner<TRoot extends AnyRootTypes, TProcRouterRecord extends ProcedureRouterRecord> = Router<RouterDef<TRoot, TProcRouterRecord>> &
|
|
58
58
|
/**
|
|
59
59
|
* This adds ability to call procedures directly but is primarily used for quick access in type inference
|
|
60
60
|
*/
|
|
@@ -62,16 +62,16 @@ TProcRouterRecord;
|
|
|
62
62
|
/**
|
|
63
63
|
* @internal
|
|
64
64
|
*/
|
|
65
|
-
export declare function createRouterFactory<
|
|
65
|
+
export declare function createRouterFactory<TRoot extends AnyRootTypes>(config: RootConfig<TRoot>): <TProcRouterRecord extends ProcedureRouterRecord>(procedures: TProcRouterRecord) => CreateRouterInner<TRoot, TProcRouterRecord>;
|
|
66
66
|
/**
|
|
67
67
|
* @internal
|
|
68
68
|
*/
|
|
69
69
|
export declare function callProcedure(opts: ProcedureCallOptions & {
|
|
70
70
|
procedures: ProcedureRouterRecord;
|
|
71
71
|
}): Promise<unknown>;
|
|
72
|
-
export declare function createCallerFactory<
|
|
72
|
+
export declare function createCallerFactory<TRoot extends AnyRootTypes>(): <TRouter extends Router<RouterDef<TRoot, any>>>(router: TRouter) => RouterCaller<TRouter["_def"]>;
|
|
73
73
|
/** @internal */
|
|
74
|
-
type MergeRouters<TRouters extends AnyRouter[], TRouterDef extends AnyRouterDef = RouterDef<TRouters[0]['_def']['_config'], {}>> = TRouters extends [
|
|
74
|
+
type MergeRouters<TRouters extends AnyRouter[], TRouterDef extends AnyRouterDef = RouterDef<TRouters[0]['_def']['_config']['$types'], {}>> = TRouters extends [
|
|
75
75
|
infer Head extends AnyRouter,
|
|
76
76
|
...infer Tail extends AnyRouter[]
|
|
77
77
|
] ? MergeRouters<Tail, {
|
|
@@ -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,
|
|
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;AA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AC,KAAK,CAAC,mIAkE1B;AAOD;;GAEG;AACH,wBAAgB,aAAa,CAC3B,IAAI,EAAE,oBAAoB,GAAG;IAAE,UAAU,EAAE,qBAAqB,CAAA;CAAE,oBAYnE;AAED,wBAAgB,mBAAmB,CAAC,KAAK,SAAS,YAAY,uGAkC7D;AAED,gBAAgB;AAChB,KAAK,YAAY,CACf,QAAQ,SAAS,SAAS,EAAE,EAC5B,UAAU,SAAS,YAAY,GAAG,SAAS,CACzC,QAAQ,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,EAExC,EAAE,CACH,IACC,QAAQ,SAAS;IACnB,MAAM,IAAI,SAAS,SAAS;IAC5B,GAAG,MAAM,IAAI,SAAS,SAAS,EAAE;CAClC,GACG,YAAY,CACV,IAAI,EACJ;IACE,OAAO,EAAE,UAAU,CAAC,SAAS,CAAC,CAAC;IAC/B,MAAM,EAAE,IAAI,CAAC;IACb,UAAU,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,YAAY,CAAC,GAAG,UAAU,CAAC,YAAY,CAAC,CAAC;IAClE,MAAM,EAAE,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;CACvD,CACF,GACD,MAAM,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC,QAAQ,CAAC,CAAC;AAE9C,wBAAgB,YAAY,CAAC,QAAQ,SAAS,SAAS,EAAE,EACvD,GAAG,UAAU,EAAE,CAAC,GAAG,QAAQ,CAAC,GAC3B,YAAY,CAAC,QAAQ,CAAC,CAmDxB"}
|
|
@@ -2,7 +2,7 @@ import { createRecursiveProxy } from './createProxy.mjs';
|
|
|
2
2
|
import { defaultFormatter } from './error/formatter.mjs';
|
|
3
3
|
import { TRPCError } from './error/TRPCError.mjs';
|
|
4
4
|
import { defaultTransformer } from './transformer.mjs';
|
|
5
|
-
import {
|
|
5
|
+
import { omitPrototype, mergeWithoutOverrides } from './utils.mjs';
|
|
6
6
|
|
|
7
7
|
function isRouter(procedureOrRouter) {
|
|
8
8
|
return 'router' in procedureOrRouter._def;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AnyRootTypes, RootConfig } from './rootConfig';
|
|
2
2
|
import type { AnyRouter, inferRouterError } from './router';
|
|
3
3
|
import type { TRPCResponse, TRPCResponseMessage, TRPCResultMessage } from './rpc';
|
|
4
4
|
/**
|
|
@@ -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:
|
|
66
|
+
export declare function transformTRPCResponse<TResponse extends TRPCResponse | TRPCResponse[] | TRPCResponseMessage | TRPCResponseMessage[]>(config: RootConfig<AnyRootTypes>, itemOrItems: TResponse): import("./rpc").TRPCErrorResponse<import("./rpc").TRPCErrorShape<import("./rpc").TRPC_ERROR_CODE_NUMBER, Record<string, unknown>>> | import("./rpc").TRPCSuccessResponse<unknown> | ({
|
|
67
67
|
id: import("./rpc").JSONRPC2.RequestId;
|
|
68
68
|
} & TRPCResultMessage<unknown>) | (TRPCResponse | TRPCResponseMessage)[];
|
|
69
69
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/transformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"transformer.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/transformer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC7D,OAAO,KAAK,EAAE,SAAS,EAAE,gB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BAAgB,qBAAqB,CACnC,SAAS,SACL,YAAY,GACZ,YAAY,EAAE,GACd,mBAAmB,GACnB,mBAAmB,EAAE,EACzB,MAAM,EAAE,UAAU,CAAC,YAAY,CAAC,EAAE,WAAW,EAAE,SAAS;;yEAIzD;AAKD,gBAAgB;AAChB,iBAAS,oBAAoB,CAAC,OAAO,SAAS,SAAS,EAAE,OAAO,EAC9D,QAAQ,EACJ,YAAY,CAAC,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,GAChD,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,EAC3D,WAAW,EAAE,eAAe;;;;;;;;;;;;;;;;;;;;;;;;EAuB7B;AAQD;;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,SAAS,SAAS,EAAE,OAAO,EAChE,QAAQ,EACJ,YAAY,CAAC,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,GAChD,mBAAmB,CAAC,OAAO,EAAE,gBAAgB,CAAC,OAAO,CAAC,CAAC,EAC3D,WAAW,EAAE,eAAe,GAC3B,UAAU,CAAC,OAAO,oBAAoB,CAAC,CAqBzC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/server",
|
|
3
|
-
"version": "11.0.0-next-beta.
|
|
3
|
+
"version": "11.0.0-next-beta.239+423669add",
|
|
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": "423669addeb27890ad11e8816dc3ecb682df90f2"
|
|
161
161
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AnyRootTypes } from './rootConfig';
|
|
2
2
|
import type { AnyRouter } from './router';
|
|
3
3
|
|
|
4
|
-
export type TRPCInferrable = AnyRouter |
|
|
5
|
-
export type
|
|
6
|
-
TInferrable extends
|
|
4
|
+
export type TRPCInferrable = AnyRouter | AnyRootTypes;
|
|
5
|
+
export type inferRootTypes<TInferrable extends TRPCInferrable> =
|
|
6
|
+
TInferrable extends AnyRootTypes
|
|
7
|
+
? TInferrable
|
|
8
|
+
: TInferrable extends AnyRouter
|
|
7
9
|
? TInferrable['_def']['_config']['$types']
|
|
8
|
-
: TInferrable extends AnyRootConfig
|
|
9
|
-
? TInferrable['$types']
|
|
10
10
|
: never;
|
|
11
11
|
|
|
12
12
|
export type inferErrorShape<TInferrable extends TRPCInferrable> =
|
|
13
|
-
|
|
13
|
+
inferRootTypes<TInferrable>['errorShape'];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { getHTTPStatusCodeFromError } from '../http/getHTTPStatusCode';
|
|
2
2
|
import type { ProcedureType } from '../procedure';
|
|
3
|
-
import type {
|
|
3
|
+
import type { AnyRootTypes, RootConfig } from '../rootConfig';
|
|
4
4
|
import { TRPC_ERROR_CODES_BY_KEY } from '../rpc';
|
|
5
5
|
import type { DefaultErrorShape } from './formatter';
|
|
6
6
|
import type { TRPCError } from './TRPCError';
|
|
@@ -8,14 +8,14 @@ import type { TRPCError } from './TRPCError';
|
|
|
8
8
|
/**
|
|
9
9
|
* @internal
|
|
10
10
|
*/
|
|
11
|
-
export function getErrorShape<
|
|
12
|
-
config:
|
|
11
|
+
export function getErrorShape<TRoot extends AnyRootTypes>(opts: {
|
|
12
|
+
config: RootConfig<TRoot>;
|
|
13
13
|
error: TRPCError;
|
|
14
14
|
type: ProcedureType | 'unknown';
|
|
15
15
|
path: string | undefined;
|
|
16
16
|
input: unknown;
|
|
17
|
-
ctx:
|
|
18
|
-
}):
|
|
17
|
+
ctx: TRoot['ctx'] | undefined;
|
|
18
|
+
}): TRoot['errorShape'] {
|
|
19
19
|
const { path, error, config } = opts;
|
|
20
20
|
const { code } = opts.error;
|
|
21
21
|
const shape: DefaultErrorShape = {
|
|
@@ -66,8 +66,8 @@ export type {
|
|
|
66
66
|
inferRouterOutputs,
|
|
67
67
|
} from './router';
|
|
68
68
|
|
|
69
|
-
export
|
|
70
|
-
export
|
|
69
|
+
export * from './TRPCInferrable';
|
|
70
|
+
export * from './router';
|
|
71
71
|
export { transformResult, transformTRPCResponse } from './transformer';
|
|
72
72
|
export type {
|
|
73
73
|
CombinedDataTransformer,
|
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
} from './error/formatter';
|
|
8
8
|
import { createMiddlewareFactory } from './middleware';
|
|
9
9
|
import { createBuilder } from './procedureBuilder';
|
|
10
|
+
import type { CreateRootTypes } from './rootConfig';
|
|
10
11
|
import { isServerDefault, type RootConfig } from './rootConfig';
|
|
11
12
|
import {
|
|
12
13
|
createCallerFactory,
|
|
@@ -72,7 +73,7 @@ class TRPCBuilder<TContext extends object, TMeta extends object> {
|
|
|
72
73
|
>
|
|
73
74
|
>;
|
|
74
75
|
|
|
75
|
-
type $
|
|
76
|
+
type $Root = CreateRootTypes<{
|
|
76
77
|
ctx: TContext;
|
|
77
78
|
meta: TMeta;
|
|
78
79
|
errorShape: $ErrorShape;
|
|
@@ -84,7 +85,7 @@ class TRPCBuilder<TContext extends object, TMeta extends object> {
|
|
|
84
85
|
opts?.transformer ?? defaultTransformer,
|
|
85
86
|
);
|
|
86
87
|
|
|
87
|
-
const config:
|
|
88
|
+
const config: RootConfig<$Root> = {
|
|
88
89
|
transformer,
|
|
89
90
|
isDev:
|
|
90
91
|
opts?.isDev ??
|
|
@@ -124,25 +125,19 @@ class TRPCBuilder<TContext extends object, TMeta extends object> {
|
|
|
124
125
|
* Builder object for creating procedures
|
|
125
126
|
* @link https://trpc.io/docs/v11/server/procedures
|
|
126
127
|
*/
|
|
127
|
-
procedure: createBuilder
|
|
128
|
-
$Config['$types']['ctx'],
|
|
129
|
-
$Config['$types']['meta']
|
|
130
|
-
>({
|
|
128
|
+
procedure: createBuilder<$Root['ctx'], $Root['meta']>({
|
|
131
129
|
meta: opts?.defaultMeta,
|
|
132
130
|
}),
|
|
133
131
|
/**
|
|
134
132
|
* Create reusable middlewares
|
|
135
133
|
* @link https://trpc.io/docs/v11/server/middlewares
|
|
136
134
|
*/
|
|
137
|
-
middleware: createMiddlewareFactory
|
|
138
|
-
$Config['$types']['ctx'],
|
|
139
|
-
$Config['$types']['meta']
|
|
140
|
-
>(),
|
|
135
|
+
middleware: createMiddlewareFactory<$Root['ctx'], $Root['meta']>(),
|
|
141
136
|
/**
|
|
142
137
|
* Create a router
|
|
143
138
|
* @link https://trpc.io/docs/v11/server/routers
|
|
144
139
|
*/
|
|
145
|
-
router: createRouterFactory<$
|
|
140
|
+
router: createRouterFactory<$Root>(config),
|
|
146
141
|
/**
|
|
147
142
|
* Merge Routers
|
|
148
143
|
* @link https://trpc.io/docs/v11/server/merging-routers
|
|
@@ -152,7 +147,7 @@ class TRPCBuilder<TContext extends object, TMeta extends object> {
|
|
|
152
147
|
* Create a server-side caller for a router
|
|
153
148
|
* @link https://trpc.io/docs/v11/server/server-side-calls
|
|
154
149
|
*/
|
|
155
|
-
createCallerFactory: createCallerFactory<$
|
|
150
|
+
createCallerFactory: createCallerFactory<$Root>(),
|
|
156
151
|
};
|
|
157
152
|
}
|
|
158
153
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { inferObservableValue } from '../observable';
|
|
2
2
|
import type { ProcedureCallOptions } from './procedureBuilder';
|
|
3
3
|
import type { Serialize } from './serialize';
|
|
4
|
-
import type {
|
|
4
|
+
import type { inferRootTypes, TRPCInferrable } from './TRPCInferrable';
|
|
5
5
|
|
|
6
6
|
export const procedureTypes = ['query', 'mutation', 'subscription'] as const;
|
|
7
7
|
/**
|
|
@@ -71,7 +71,7 @@ export type AnyProcedure = Procedure<ProcedureType, any>;
|
|
|
71
71
|
export type inferTransformedProcedureOutput<
|
|
72
72
|
TInferrable extends TRPCInferrable,
|
|
73
73
|
TProcedure extends AnyProcedure,
|
|
74
|
-
> =
|
|
74
|
+
> = inferRootTypes<TInferrable>['transformer'] extends false
|
|
75
75
|
? Serialize<TProcedure['_def']['_output_out']>
|
|
76
76
|
: TProcedure['_def']['_output_out'];
|
|
77
77
|
|
|
@@ -79,7 +79,7 @@ export type inferTransformedProcedureOutput<
|
|
|
79
79
|
export type inferTransformedSubscriptionOutput<
|
|
80
80
|
TInferrable extends TRPCInferrable,
|
|
81
81
|
TProcedure extends AnyProcedure,
|
|
82
|
-
> =
|
|
82
|
+
> = inferRootTypes<TInferrable>['transformer'] extends false
|
|
83
83
|
? Serialize<inferObservableValue<TProcedure['_def']['_output_out']>>
|
|
84
84
|
: inferObservableValue<TProcedure['_def']['_output_out']>;
|
|
85
85
|
|
|
@@ -6,7 +6,7 @@ import type { TRPCErrorShape } from './rpc';
|
|
|
6
6
|
* The initial generics that are used in the init function
|
|
7
7
|
* @internal
|
|
8
8
|
*/
|
|
9
|
-
export interface
|
|
9
|
+
export interface RootTypes {
|
|
10
10
|
ctx: object;
|
|
11
11
|
meta: object;
|
|
12
12
|
errorShape: unknown;
|
|
@@ -28,7 +28,7 @@ export const isServerDefault: boolean =
|
|
|
28
28
|
* The tRPC root config
|
|
29
29
|
* @internal
|
|
30
30
|
*/
|
|
31
|
-
export interface RootConfig<TTypes extends
|
|
31
|
+
export interface RootConfig<TTypes extends RootTypes> {
|
|
32
32
|
/**
|
|
33
33
|
* The types that are used in the config
|
|
34
34
|
* @internal
|
|
@@ -72,13 +72,9 @@ export interface RootConfig<TTypes extends RootConfigTypes> {
|
|
|
72
72
|
/**
|
|
73
73
|
* @internal
|
|
74
74
|
*/
|
|
75
|
-
export type
|
|
76
|
-
TGenerics;
|
|
75
|
+
export type CreateRootTypes<TGenerics extends RootTypes> = TGenerics;
|
|
77
76
|
|
|
78
|
-
|
|
79
|
-
* @internal
|
|
80
|
-
*/
|
|
81
|
-
export type AnyRootConfig = RootConfig<{
|
|
77
|
+
export type AnyRootTypes = CreateRootTypes<{
|
|
82
78
|
ctx: any;
|
|
83
79
|
meta: any;
|
|
84
80
|
errorShape: any;
|
|
@@ -7,7 +7,7 @@ import type {
|
|
|
7
7
|
inferTransformedProcedureOutput,
|
|
8
8
|
} from './procedure';
|
|
9
9
|
import type { ProcedureCallOptions } from './procedureBuilder';
|
|
10
|
-
import type {
|
|
10
|
+
import type { AnyRootTypes, RootConfig } from './rootConfig';
|
|
11
11
|
import { defaultTransformer } from './transformer';
|
|
12
12
|
import type { MaybePromise } from './types';
|
|
13
13
|
import { mergeWithoutOverrides, omitPrototype } from './utils';
|
|
@@ -20,18 +20,17 @@ export interface ProcedureRouterRecord {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
export interface RouterDef<
|
|
23
|
-
|
|
23
|
+
TRoot extends AnyRootTypes,
|
|
24
24
|
TRecord extends ProcedureRouterRecord,
|
|
25
25
|
> {
|
|
26
|
-
_config:
|
|
26
|
+
_config: RootConfig<TRoot>;
|
|
27
27
|
router: true;
|
|
28
28
|
procedure?: never;
|
|
29
29
|
procedures: TRecord;
|
|
30
30
|
record: TRecord;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
export type AnyRouterDef
|
|
34
|
-
RouterDef<TConfig, any>;
|
|
33
|
+
export type AnyRouterDef = RouterDef<any, any>;
|
|
35
34
|
|
|
36
35
|
type DecorateProcedure<TProcedure extends AnyProcedure> = (
|
|
37
36
|
input: inferProcedureInput<TProcedure>,
|
|
@@ -76,7 +75,7 @@ export type AnyRouter = Router<AnyRouterDef>;
|
|
|
76
75
|
type inferRouterDef<TRouter extends AnyRouter> = TRouter extends Router<
|
|
77
76
|
infer TParams
|
|
78
77
|
>
|
|
79
|
-
? TParams extends AnyRouterDef
|
|
78
|
+
? TParams extends AnyRouterDef
|
|
80
79
|
? TParams
|
|
81
80
|
: never
|
|
82
81
|
: never;
|
|
@@ -100,10 +99,7 @@ type GetInferenceHelpers<
|
|
|
100
99
|
: TRouterOrProcedure extends AnyProcedure
|
|
101
100
|
? TType extends 'input'
|
|
102
101
|
? inferProcedureInput<TRouterOrProcedure>
|
|
103
|
-
: inferTransformedProcedureOutput<
|
|
104
|
-
TRouter['_def']['_config'],
|
|
105
|
-
TRouterOrProcedure
|
|
106
|
-
>
|
|
102
|
+
: inferTransformedProcedureOutput<TRouter, TRouterOrProcedure>
|
|
107
103
|
: never
|
|
108
104
|
: never;
|
|
109
105
|
};
|
|
@@ -150,9 +146,9 @@ const reservedWords = [
|
|
|
150
146
|
* @internal
|
|
151
147
|
*/
|
|
152
148
|
export type CreateRouterInner<
|
|
153
|
-
|
|
149
|
+
TRoot extends AnyRootTypes,
|
|
154
150
|
TProcRouterRecord extends ProcedureRouterRecord,
|
|
155
|
-
> = Router<RouterDef<
|
|
151
|
+
> = Router<RouterDef<TRoot, TProcRouterRecord>> &
|
|
156
152
|
/**
|
|
157
153
|
* This adds ability to call procedures directly but is primarily used for quick access in type inference
|
|
158
154
|
*/
|
|
@@ -161,14 +157,14 @@ export type CreateRouterInner<
|
|
|
161
157
|
/**
|
|
162
158
|
* @internal
|
|
163
159
|
*/
|
|
164
|
-
export function createRouterFactory<
|
|
165
|
-
config:
|
|
160
|
+
export function createRouterFactory<TRoot extends AnyRootTypes>(
|
|
161
|
+
config: RootConfig<TRoot>,
|
|
166
162
|
) {
|
|
167
163
|
return function createRouterInner<
|
|
168
164
|
TProcRouterRecord extends ProcedureRouterRecord,
|
|
169
165
|
>(
|
|
170
166
|
procedures: TProcRouterRecord,
|
|
171
|
-
): CreateRouterInner<
|
|
167
|
+
): CreateRouterInner<TRoot, TProcRouterRecord> {
|
|
172
168
|
const reservedWordsUsed = new Set(
|
|
173
169
|
Object.keys(procedures).filter((v) => reservedWords.includes(v)),
|
|
174
170
|
);
|
|
@@ -198,7 +194,7 @@ export function createRouterFactory<TConfig extends AnyRootConfig>(
|
|
|
198
194
|
}
|
|
199
195
|
recursiveGetPaths(procedures);
|
|
200
196
|
|
|
201
|
-
const _def: AnyRouterDef
|
|
197
|
+
const _def: AnyRouterDef = {
|
|
202
198
|
_config: config,
|
|
203
199
|
router: true,
|
|
204
200
|
procedures: routerProcedures,
|
|
@@ -253,12 +249,12 @@ export function callProcedure(
|
|
|
253
249
|
return proc(opts);
|
|
254
250
|
}
|
|
255
251
|
|
|
256
|
-
export function createCallerFactory<
|
|
252
|
+
export function createCallerFactory<TRoot extends AnyRootTypes>() {
|
|
257
253
|
return function createCallerInner<
|
|
258
|
-
TRouter extends Router<
|
|
254
|
+
TRouter extends Router<RouterDef<TRoot, any>>,
|
|
259
255
|
>(router: TRouter): RouterCaller<TRouter['_def']> {
|
|
260
256
|
const _def = router._def;
|
|
261
|
-
type Context =
|
|
257
|
+
type Context = TRoot['ctx'];
|
|
262
258
|
|
|
263
259
|
return function createCaller(maybeContext) {
|
|
264
260
|
const proxy = createRecursiveProxy(({ path, args }) => {
|
|
@@ -293,7 +289,7 @@ export function createCallerFactory<TConfig extends AnyRootConfig>() {
|
|
|
293
289
|
type MergeRouters<
|
|
294
290
|
TRouters extends AnyRouter[],
|
|
295
291
|
TRouterDef extends AnyRouterDef = RouterDef<
|
|
296
|
-
TRouters[0]['_def']['_config'],
|
|
292
|
+
TRouters[0]['_def']['_config']['$types'],
|
|
297
293
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
298
294
|
{}
|
|
299
295
|
>,
|
|
@@ -362,7 +358,7 @@ export function mergeRouters<TRouters extends AnyRouter[]>(
|
|
|
362
358
|
(r) => r._def._config.allowOutsideOfServer,
|
|
363
359
|
),
|
|
364
360
|
isServer: routerList.some((r) => r._def._config.isServer),
|
|
365
|
-
$types: routerList[0]?._def._config.$types
|
|
361
|
+
$types: routerList[0]?._def._config.$types,
|
|
366
362
|
})(record);
|
|
367
363
|
return router as any;
|
|
368
364
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { AnyRootTypes, RootConfig } from './rootConfig';
|
|
2
2
|
import type { AnyRouter, inferRouterError } from './router';
|
|
3
3
|
import type {
|
|
4
4
|
TRPCResponse,
|
|
@@ -86,7 +86,7 @@ export const defaultTransformer: CombinedDataTransformer = {
|
|
|
86
86
|
|
|
87
87
|
function transformTRPCResponseItem<
|
|
88
88
|
TResponseItem extends TRPCResponse | TRPCResponseMessage,
|
|
89
|
-
>(config:
|
|
89
|
+
>(config: RootConfig<AnyRootTypes>, item: TResponseItem): TResponseItem {
|
|
90
90
|
if ('error' in item) {
|
|
91
91
|
return {
|
|
92
92
|
...item,
|
|
@@ -116,7 +116,7 @@ export function transformTRPCResponse<
|
|
|
116
116
|
| TRPCResponse[]
|
|
117
117
|
| TRPCResponseMessage
|
|
118
118
|
| TRPCResponseMessage[],
|
|
119
|
-
>(config:
|
|
119
|
+
>(config: RootConfig<AnyRootTypes>, itemOrItems: TResponse) {
|
|
120
120
|
return Array.isArray(itemOrItems)
|
|
121
121
|
? itemOrItems.map((item) => transformTRPCResponseItem(config, item))
|
|
122
122
|
: transformTRPCResponseItem(config, itemOrItems);
|