@trpc/server 11.0.0-rc.532 → 11.0.0-rc.551
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/ws.js +1 -1
- package/dist/adapters/ws.mjs +1 -1
- package/dist/bundle-analysis.json +50 -50
- package/dist/unstable-core-do-not-import/clientish/serialize.d.ts +1 -1
- package/dist/unstable-core-do-not-import/http/resolveResponse.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/http/resolveResponse.js +16 -4
- package/dist/unstable-core-do-not-import/http/resolveResponse.mjs +16 -4
- package/dist/unstable-core-do-not-import/http/types.d.ts +1 -1
- package/dist/unstable-core-do-not-import/initTRPC.d.ts +10 -10
- package/dist/unstable-core-do-not-import/initTRPC.js +9 -9
- package/dist/unstable-core-do-not-import/initTRPC.mjs +9 -9
- package/dist/unstable-core-do-not-import/middleware.d.ts +1 -1
- package/dist/unstable-core-do-not-import/middleware.js +1 -1
- package/dist/unstable-core-do-not-import/middleware.mjs +1 -1
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts +9 -9
- package/dist/unstable-core-do-not-import/procedureBuilder.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/rootConfig.d.ts +3 -3
- package/dist/unstable-core-do-not-import/router.d.ts +1 -1
- package/dist/unstable-core-do-not-import/types.d.ts +1 -1
- package/package.json +2 -2
- package/src/adapters/ws.ts +1 -1
- package/src/unstable-core-do-not-import/clientish/serialize.ts +1 -1
- package/src/unstable-core-do-not-import/http/resolveResponse.ts +19 -4
- package/src/unstable-core-do-not-import/http/types.ts +1 -1
- package/src/unstable-core-do-not-import/initTRPC.ts +10 -10
- package/src/unstable-core-do-not-import/middleware.ts +1 -1
- package/src/unstable-core-do-not-import/procedureBuilder.ts +19 -17
- package/src/unstable-core-do-not-import/rootConfig.ts +3 -3
- package/src/unstable-core-do-not-import/router.ts +1 -1
- package/src/unstable-core-do-not-import/types.ts +1 -1
package/dist/adapters/ws.js
CHANGED
|
@@ -14,7 +14,7 @@ var router = require('../unstable-core-do-not-import/router.js');
|
|
|
14
14
|
|
|
15
15
|
/**
|
|
16
16
|
* Importing ws causes a build error
|
|
17
|
-
* @
|
|
17
|
+
* @see https://github.com/trpc/trpc/pull/5279
|
|
18
18
|
*/ const WEBSOCKET_OPEN = 1; /* ws.WebSocket.OPEN */
|
|
19
19
|
const unsetContextPromiseSymbol = Symbol('unsetContextPromise');
|
|
20
20
|
function getWSConnectionHandler(opts) {
|
package/dist/adapters/ws.mjs
CHANGED
|
@@ -12,7 +12,7 @@ import { callProcedure } from '../unstable-core-do-not-import/router.mjs';
|
|
|
12
12
|
|
|
13
13
|
/**
|
|
14
14
|
* Importing ws causes a build error
|
|
15
|
-
* @
|
|
15
|
+
* @see https://github.com/trpc/trpc/pull/5279
|
|
16
16
|
*/ const WEBSOCKET_OPEN = 1; /* ws.WebSocket.OPEN */
|
|
17
17
|
const unsetContextPromiseSymbol = Symbol('unsetContextPromise');
|
|
18
18
|
function getWSConnectionHandler(opts) {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction": 26.
|
|
2
|
+
"bundleSize": 136668,
|
|
3
|
+
"bundleOrigSize": 186211,
|
|
4
|
+
"bundleReduction": 26.61,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
8
|
-
"size":
|
|
9
|
-
"origSize":
|
|
8
|
+
"size": 18439,
|
|
9
|
+
"origSize": 17070,
|
|
10
10
|
"renderedExports": [
|
|
11
11
|
"resolveResponse"
|
|
12
12
|
],
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"dependents": [
|
|
15
15
|
"/src/unstable-core-do-not-import.ts"
|
|
16
16
|
],
|
|
17
|
-
"percent": 13.
|
|
17
|
+
"percent": 13.49,
|
|
18
18
|
"reduction": 0
|
|
19
19
|
},
|
|
20
20
|
{
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
"/src/unstable-core-do-not-import.ts",
|
|
32
32
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
33
33
|
],
|
|
34
|
-
"percent": 12.
|
|
34
|
+
"percent": 12.85,
|
|
35
35
|
"reduction": 4.31
|
|
36
36
|
},
|
|
37
37
|
{
|
|
38
38
|
"id": "/src/adapters/ws.ts",
|
|
39
|
-
"size":
|
|
40
|
-
"origSize":
|
|
39
|
+
"size": 16285,
|
|
40
|
+
"origSize": 15255,
|
|
41
41
|
"renderedExports": [
|
|
42
42
|
"getWSConnectionHandler",
|
|
43
43
|
"handleKeepAlive",
|
|
@@ -47,7 +47,7 @@
|
|
|
47
47
|
"dependents": [
|
|
48
48
|
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
49
49
|
],
|
|
50
|
-
"percent": 11.
|
|
50
|
+
"percent": 11.92,
|
|
51
51
|
"reduction": 0
|
|
52
52
|
},
|
|
53
53
|
{
|
|
@@ -62,13 +62,13 @@
|
|
|
62
62
|
"/src/unstable-core-do-not-import.ts",
|
|
63
63
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
64
64
|
],
|
|
65
|
-
"percent": 5.
|
|
65
|
+
"percent": 5.63,
|
|
66
66
|
"reduction": 0
|
|
67
67
|
},
|
|
68
68
|
{
|
|
69
69
|
"id": "/src/unstable-core-do-not-import/router.ts",
|
|
70
70
|
"size": 6421,
|
|
71
|
-
"origSize":
|
|
71
|
+
"origSize": 10733,
|
|
72
72
|
"renderedExports": [
|
|
73
73
|
"createRouterFactory",
|
|
74
74
|
"callProcedure",
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"/src/unstable-core-do-not-import.ts",
|
|
81
81
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
82
82
|
],
|
|
83
|
-
"percent": 4.
|
|
83
|
+
"percent": 4.7,
|
|
84
84
|
"reduction": 40.18
|
|
85
85
|
},
|
|
86
86
|
{
|
|
@@ -97,13 +97,13 @@
|
|
|
97
97
|
"/src/unstable-core-do-not-import.ts",
|
|
98
98
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
99
99
|
],
|
|
100
|
-
"percent": 4.
|
|
100
|
+
"percent": 4.32,
|
|
101
101
|
"reduction": 15.22
|
|
102
102
|
},
|
|
103
103
|
{
|
|
104
104
|
"id": "/src/unstable-core-do-not-import/procedureBuilder.ts",
|
|
105
105
|
"size": 5795,
|
|
106
|
-
"origSize":
|
|
106
|
+
"origSize": 15690,
|
|
107
107
|
"renderedExports": [
|
|
108
108
|
"createBuilder"
|
|
109
109
|
],
|
|
@@ -112,8 +112,8 @@
|
|
|
112
112
|
"/src/unstable-core-do-not-import.ts",
|
|
113
113
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
114
114
|
],
|
|
115
|
-
"percent": 4.
|
|
116
|
-
"reduction": 63.
|
|
115
|
+
"percent": 4.24,
|
|
116
|
+
"reduction": 63.07
|
|
117
117
|
},
|
|
118
118
|
{
|
|
119
119
|
"id": "/src/adapters/aws-lambda/getPlanner.ts",
|
|
@@ -126,7 +126,7 @@
|
|
|
126
126
|
"dependents": [
|
|
127
127
|
"/src/adapters/aws-lambda/index.ts"
|
|
128
128
|
],
|
|
129
|
-
"percent": 3.
|
|
129
|
+
"percent": 3.96,
|
|
130
130
|
"reduction": 11.38
|
|
131
131
|
},
|
|
132
132
|
{
|
|
@@ -146,7 +146,7 @@
|
|
|
146
146
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
147
147
|
"/src/observable/operators.ts"
|
|
148
148
|
],
|
|
149
|
-
"percent": 3.
|
|
149
|
+
"percent": 3.01,
|
|
150
150
|
"reduction": 0
|
|
151
151
|
},
|
|
152
152
|
{
|
|
@@ -160,7 +160,7 @@
|
|
|
160
160
|
"dependents": [
|
|
161
161
|
"/src/adapters/next-app-dir.ts"
|
|
162
162
|
],
|
|
163
|
-
"percent": 2.
|
|
163
|
+
"percent": 2.36,
|
|
164
164
|
"reduction": 22.57
|
|
165
165
|
},
|
|
166
166
|
{
|
|
@@ -174,7 +174,7 @@
|
|
|
174
174
|
"dependents": [
|
|
175
175
|
"/src/adapters/node-http/index.ts"
|
|
176
176
|
],
|
|
177
|
-
"percent": 2.
|
|
177
|
+
"percent": 2.09,
|
|
178
178
|
"reduction": 6.07
|
|
179
179
|
},
|
|
180
180
|
{
|
|
@@ -210,13 +210,13 @@
|
|
|
210
210
|
"/src/unstable-core-do-not-import/initTRPC.ts",
|
|
211
211
|
"/src/unstable-core-do-not-import/router.ts"
|
|
212
212
|
],
|
|
213
|
-
"percent": 2.
|
|
213
|
+
"percent": 2.01,
|
|
214
214
|
"reduction": 45.94
|
|
215
215
|
},
|
|
216
216
|
{
|
|
217
217
|
"id": "/src/unstable-core-do-not-import/initTRPC.ts",
|
|
218
|
-
"size":
|
|
219
|
-
"origSize":
|
|
218
|
+
"size": 2695,
|
|
219
|
+
"origSize": 4566,
|
|
220
220
|
"renderedExports": [
|
|
221
221
|
"initTRPC"
|
|
222
222
|
],
|
|
@@ -224,13 +224,13 @@
|
|
|
224
224
|
"dependents": [
|
|
225
225
|
"/src/unstable-core-do-not-import.ts"
|
|
226
226
|
],
|
|
227
|
-
"percent": 1.
|
|
228
|
-
"reduction": 40.
|
|
227
|
+
"percent": 1.97,
|
|
228
|
+
"reduction": 40.98
|
|
229
229
|
},
|
|
230
230
|
{
|
|
231
231
|
"id": "/src/unstable-core-do-not-import/middleware.ts",
|
|
232
|
-
"size":
|
|
233
|
-
"origSize":
|
|
232
|
+
"size": 2626,
|
|
233
|
+
"origSize": 5939,
|
|
234
234
|
"renderedExports": [
|
|
235
235
|
"middlewareMarker",
|
|
236
236
|
"createMiddlewareFactory",
|
|
@@ -244,8 +244,8 @@
|
|
|
244
244
|
"/src/unstable-core-do-not-import/initTRPC.ts",
|
|
245
245
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
246
246
|
],
|
|
247
|
-
"percent": 1.
|
|
248
|
-
"reduction": 55.
|
|
247
|
+
"percent": 1.92,
|
|
248
|
+
"reduction": 55.78
|
|
249
249
|
},
|
|
250
250
|
{
|
|
251
251
|
"id": "/src/unstable-core-do-not-import/createProxy.ts",
|
|
@@ -260,7 +260,7 @@
|
|
|
260
260
|
"/src/unstable-core-do-not-import.ts",
|
|
261
261
|
"/src/unstable-core-do-not-import/router.ts"
|
|
262
262
|
],
|
|
263
|
-
"percent": 1.
|
|
263
|
+
"percent": 1.7,
|
|
264
264
|
"reduction": 0
|
|
265
265
|
},
|
|
266
266
|
{
|
|
@@ -274,7 +274,7 @@
|
|
|
274
274
|
"dependents": [
|
|
275
275
|
"/src/adapters/fetch/index.ts"
|
|
276
276
|
],
|
|
277
|
-
"percent": 1.
|
|
277
|
+
"percent": 1.65,
|
|
278
278
|
"reduction": 2.17
|
|
279
279
|
},
|
|
280
280
|
{
|
|
@@ -303,7 +303,7 @@
|
|
|
303
303
|
"dependents": [
|
|
304
304
|
"/src/adapters/next-app-dir/nextAppDirCaller.ts"
|
|
305
305
|
],
|
|
306
|
-
"percent": 1.
|
|
306
|
+
"percent": 1.5,
|
|
307
307
|
"reduction": 5.79
|
|
308
308
|
},
|
|
309
309
|
{
|
|
@@ -317,7 +317,7 @@
|
|
|
317
317
|
"dependents": [
|
|
318
318
|
"/src/adapters/fastify/index.ts"
|
|
319
319
|
],
|
|
320
|
-
"percent": 1.
|
|
320
|
+
"percent": 1.3,
|
|
321
321
|
"reduction": 29.88
|
|
322
322
|
},
|
|
323
323
|
{
|
|
@@ -353,7 +353,7 @@
|
|
|
353
353
|
],
|
|
354
354
|
"removedExports": [],
|
|
355
355
|
"dependents": [],
|
|
356
|
-
"percent": 1.
|
|
356
|
+
"percent": 1.24,
|
|
357
357
|
"reduction": 19.29
|
|
358
358
|
},
|
|
359
359
|
{
|
|
@@ -395,7 +395,7 @@
|
|
|
395
395
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
396
396
|
"/src/unstable-core-do-not-import/error/getErrorShape.ts"
|
|
397
397
|
],
|
|
398
|
-
"percent": 1.
|
|
398
|
+
"percent": 1.05,
|
|
399
399
|
"reduction": 16.73
|
|
400
400
|
},
|
|
401
401
|
{
|
|
@@ -432,11 +432,11 @@
|
|
|
432
432
|
"/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts",
|
|
433
433
|
"/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
|
|
434
434
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
435
|
-
"/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
|
|
436
435
|
"/src/unstable-core-do-not-import/error/TRPCError.ts",
|
|
437
436
|
"/src/unstable-core-do-not-import/transformer.ts",
|
|
438
437
|
"/src/unstable-core-do-not-import/middleware.ts",
|
|
439
438
|
"/src/unstable-core-do-not-import/router.ts",
|
|
439
|
+
"/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
|
|
440
440
|
"/src/unstable-core-do-not-import/http/contentType.ts",
|
|
441
441
|
"/src/unstable-core-do-not-import/procedureBuilder.ts",
|
|
442
442
|
"/src/unstable-core-do-not-import/stream/jsonl.ts",
|
|
@@ -539,7 +539,7 @@
|
|
|
539
539
|
"/src/unstable-core-do-not-import.ts",
|
|
540
540
|
"/src/unstable-core-do-not-import/stream/sse.ts"
|
|
541
541
|
],
|
|
542
|
-
"percent": 0.
|
|
542
|
+
"percent": 0.58,
|
|
543
543
|
"reduction": 44.65
|
|
544
544
|
},
|
|
545
545
|
{
|
|
@@ -567,7 +567,7 @@
|
|
|
567
567
|
"/src/unstable-core-do-not-import/stream/jsonl.ts",
|
|
568
568
|
"/src/unstable-core-do-not-import/stream/sse.ts"
|
|
569
569
|
],
|
|
570
|
-
"percent": 0.
|
|
570
|
+
"percent": 0.53,
|
|
571
571
|
"reduction": 20.74
|
|
572
572
|
},
|
|
573
573
|
{
|
|
@@ -615,7 +615,7 @@
|
|
|
615
615
|
{
|
|
616
616
|
"id": "/src/unstable-core-do-not-import/rootConfig.ts",
|
|
617
617
|
"size": 343,
|
|
618
|
-
"origSize":
|
|
618
|
+
"origSize": 3267,
|
|
619
619
|
"renderedExports": [
|
|
620
620
|
"isServerDefault"
|
|
621
621
|
],
|
|
@@ -625,7 +625,7 @@
|
|
|
625
625
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
626
626
|
],
|
|
627
627
|
"percent": 0.25,
|
|
628
|
-
"reduction": 89.
|
|
628
|
+
"reduction": 89.5
|
|
629
629
|
},
|
|
630
630
|
{
|
|
631
631
|
"id": "/src/adapters/express.ts",
|
|
@@ -636,7 +636,7 @@
|
|
|
636
636
|
],
|
|
637
637
|
"removedExports": [],
|
|
638
638
|
"dependents": [],
|
|
639
|
-
"percent": 0.
|
|
639
|
+
"percent": 0.2,
|
|
640
640
|
"reduction": 72.92
|
|
641
641
|
},
|
|
642
642
|
{
|
|
@@ -656,7 +656,7 @@
|
|
|
656
656
|
{
|
|
657
657
|
"id": "/src/unstable-core-do-not-import/types.ts",
|
|
658
658
|
"size": 221,
|
|
659
|
-
"origSize":
|
|
659
|
+
"origSize": 4054,
|
|
660
660
|
"renderedExports": [
|
|
661
661
|
"ERROR_SYMBOL"
|
|
662
662
|
],
|
|
@@ -707,7 +707,7 @@
|
|
|
707
707
|
"/src/unstable-core-do-not-import.ts",
|
|
708
708
|
"/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts"
|
|
709
709
|
],
|
|
710
|
-
"percent": 0.
|
|
710
|
+
"percent": 0.05,
|
|
711
711
|
"reduction": 97.19
|
|
712
712
|
},
|
|
713
713
|
{
|
|
@@ -739,9 +739,9 @@
|
|
|
739
739
|
"reduction": 100
|
|
740
740
|
},
|
|
741
741
|
{
|
|
742
|
-
"id": "/src/
|
|
742
|
+
"id": "/src/index.ts",
|
|
743
743
|
"size": 0,
|
|
744
|
-
"origSize":
|
|
744
|
+
"origSize": 32,
|
|
745
745
|
"renderedExports": [],
|
|
746
746
|
"removedExports": [],
|
|
747
747
|
"dependents": [],
|
|
@@ -749,9 +749,9 @@
|
|
|
749
749
|
"reduction": 100
|
|
750
750
|
},
|
|
751
751
|
{
|
|
752
|
-
"id": "/src/
|
|
752
|
+
"id": "/src/shared.ts",
|
|
753
753
|
"size": 0,
|
|
754
|
-
"origSize":
|
|
754
|
+
"origSize": 653,
|
|
755
755
|
"renderedExports": [],
|
|
756
756
|
"removedExports": [],
|
|
757
757
|
"dependents": [],
|
|
@@ -759,9 +759,9 @@
|
|
|
759
759
|
"reduction": 100
|
|
760
760
|
},
|
|
761
761
|
{
|
|
762
|
-
"id": "/src/
|
|
762
|
+
"id": "/src/rpc.ts",
|
|
763
763
|
"size": 0,
|
|
764
|
-
"origSize":
|
|
764
|
+
"origSize": 36,
|
|
765
765
|
"renderedExports": [],
|
|
766
766
|
"removedExports": [],
|
|
767
767
|
"dependents": [],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Simplify, WithoutIndexSignature } from '../types';
|
|
2
2
|
/**
|
|
3
|
-
* @
|
|
3
|
+
* @see https://github.com/remix-run/remix/blob/2248669ed59fd716e267ea41df5d665d4781f4a9/packages/remix-server-runtime/serialize.ts
|
|
4
4
|
*/
|
|
5
5
|
type JsonPrimitive = boolean | number | string | null;
|
|
6
6
|
type NonJsonPrimitive = Function | symbol | undefined;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveResponse.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/resolveResponse.ts"],"names":[],"mappings":"AAMA,OAAO,EAA2B,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,EACL,KAAK,SAAS,EAGf,MAAM,WAAW,CAAC;AAQnB,OAAO,KAAK,EACV,sBAAsB,EACtB,kCAAkC,EAEnC,MAAM,SAAS,CAAC;AA0BjB,UAAU,yBAAyB,CAAC,OAAO,SAAS,SAAS,CAC3D,SAAQ,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC;IAChD,aAAa,EAAE,kCAAkC,CAAC,OAAO,CAAC,CAAC;IAC3D,GAAG,EAAE,OAAO,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;CACzB;AAyID,wBAAsB,eAAe,CAAC,OAAO,SAAS,SAAS,EAC7D,IAAI,EAAE,yBAAyB,CAAC,OAAO,CAAC,GACvC,OAAO,CAAC,QAAQ,CAAC,
|
|
1
|
+
{"version":3,"file":"resolveResponse.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/resolveResponse.ts"],"names":[],"mappings":"AAMA,OAAO,EAA2B,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,EACL,KAAK,SAAS,EAGf,MAAM,WAAW,CAAC;AAQnB,OAAO,KAAK,EACV,sBAAsB,EACtB,kCAAkC,EAEnC,MAAM,SAAS,CAAC;AA0BjB,UAAU,yBAAyB,CAAC,OAAO,SAAS,SAAS,CAC3D,SAAQ,sBAAsB,CAAC,OAAO,EAAE,OAAO,CAAC;IAChD,aAAa,EAAE,kCAAkC,CAAC,OAAO,CAAC,CAAC;IAC3D,GAAG,EAAE,OAAO,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;CACzB;AAyID,wBAAsB,eAAe,CAAC,OAAO,SAAS,SAAS,EAC7D,IAAI,EAAE,yBAAyB,CAAC,OAAO,CAAC,GACvC,OAAO,CAAC,QAAQ,CAAC,CAibnB"}
|
|
@@ -292,13 +292,25 @@ async function resolveResponse(opts) {
|
|
|
292
292
|
data: dataAsIterable,
|
|
293
293
|
serialize: (v)=>config.transformer.output.serialize(v),
|
|
294
294
|
formatError (errorOpts) {
|
|
295
|
+
const error = TRPCError.getTRPCErrorFromUnknown(errorOpts.error);
|
|
296
|
+
const input = call?.result();
|
|
297
|
+
const path = call?.path;
|
|
298
|
+
const type = call?.procedure?._def.type ?? 'unknown';
|
|
295
299
|
const shape = getErrorShape.getErrorShape({
|
|
296
300
|
config,
|
|
297
301
|
ctx,
|
|
298
|
-
error
|
|
299
|
-
input
|
|
300
|
-
path
|
|
301
|
-
type
|
|
302
|
+
error,
|
|
303
|
+
input,
|
|
304
|
+
path,
|
|
305
|
+
type
|
|
306
|
+
});
|
|
307
|
+
opts.onError?.({
|
|
308
|
+
error,
|
|
309
|
+
path,
|
|
310
|
+
input,
|
|
311
|
+
ctx,
|
|
312
|
+
req: opts.req,
|
|
313
|
+
type
|
|
302
314
|
});
|
|
303
315
|
return shape;
|
|
304
316
|
}
|
|
@@ -290,13 +290,25 @@ async function resolveResponse(opts) {
|
|
|
290
290
|
data: dataAsIterable,
|
|
291
291
|
serialize: (v)=>config.transformer.output.serialize(v),
|
|
292
292
|
formatError (errorOpts) {
|
|
293
|
+
const error = getTRPCErrorFromUnknown(errorOpts.error);
|
|
294
|
+
const input = call?.result();
|
|
295
|
+
const path = call?.path;
|
|
296
|
+
const type = call?.procedure?._def.type ?? 'unknown';
|
|
293
297
|
const shape = getErrorShape({
|
|
294
298
|
config,
|
|
295
299
|
ctx,
|
|
296
|
-
error
|
|
297
|
-
input
|
|
298
|
-
path
|
|
299
|
-
type
|
|
300
|
+
error,
|
|
301
|
+
input,
|
|
302
|
+
path,
|
|
303
|
+
type
|
|
304
|
+
});
|
|
305
|
+
opts.onError?.({
|
|
306
|
+
error,
|
|
307
|
+
path,
|
|
308
|
+
input,
|
|
309
|
+
ctx,
|
|
310
|
+
req: opts.req,
|
|
311
|
+
type
|
|
300
312
|
});
|
|
301
313
|
return shape;
|
|
302
314
|
}
|
|
@@ -37,7 +37,7 @@ export interface HTTPBaseHandlerOptions<TRouter extends AnyRouter, TRequest> ext
|
|
|
37
37
|
/**
|
|
38
38
|
* Add handler to be called before response is sent to the user
|
|
39
39
|
* Useful for setting cache headers
|
|
40
|
-
* @
|
|
40
|
+
* @see https://trpc.io/docs/v11/caching
|
|
41
41
|
*/
|
|
42
42
|
responseMeta?: ResponseMetaFn<TRouter>;
|
|
43
43
|
}
|
|
@@ -12,7 +12,7 @@ interface RuntimeConfigOptions<TContext extends object, TMeta extends object> ex
|
|
|
12
12
|
}>, '$types' | 'transformer'>> {
|
|
13
13
|
/**
|
|
14
14
|
* Use a data transformer
|
|
15
|
-
* @
|
|
15
|
+
* @see https://trpc.io/docs/v11/data-transformers
|
|
16
16
|
*/
|
|
17
17
|
transformer?: DataTransformerOptions;
|
|
18
18
|
}
|
|
@@ -20,17 +20,17 @@ type ContextCallback = (...args: any[]) => object | Promise<object>;
|
|
|
20
20
|
declare class TRPCBuilder<TContext extends object, TMeta extends object> {
|
|
21
21
|
/**
|
|
22
22
|
* Add a context shape as a generic to the root object
|
|
23
|
-
* @
|
|
23
|
+
* @see https://trpc.io/docs/v11/server/context
|
|
24
24
|
*/
|
|
25
25
|
context<TNewContext extends object | ContextCallback>(): TRPCBuilder<TNewContext extends ContextCallback ? Unwrap<TNewContext> : TNewContext, TMeta>;
|
|
26
26
|
/**
|
|
27
27
|
* Add a meta shape as a generic to the root object
|
|
28
|
-
* @
|
|
28
|
+
* @see https://trpc.io/docs/v11/quickstart
|
|
29
29
|
*/
|
|
30
30
|
meta<TNewMeta extends object>(): TRPCBuilder<TContext, TNewMeta>;
|
|
31
31
|
/**
|
|
32
32
|
* Create the root object
|
|
33
|
-
* @
|
|
33
|
+
* @see https://trpc.io/docs/v11/server/routers#initialize-trpc
|
|
34
34
|
*/
|
|
35
35
|
create<TOptions extends RuntimeConfigOptions<TContext, TMeta>>(opts?: ValidateShape<TOptions, RuntimeConfigOptions<TContext, TMeta>> | undefined): {
|
|
36
36
|
/**
|
|
@@ -45,17 +45,17 @@ declare class TRPCBuilder<TContext extends object, TMeta extends object> {
|
|
|
45
45
|
}>;
|
|
46
46
|
/**
|
|
47
47
|
* Builder object for creating procedures
|
|
48
|
-
* @
|
|
48
|
+
* @see https://trpc.io/docs/v11/server/procedures
|
|
49
49
|
*/
|
|
50
50
|
procedure: import("./procedureBuilder").ProcedureBuilder<TContext, TMeta, object, typeof import("./utils").unsetMarker, typeof import("./utils").unsetMarker, typeof import("./utils").unsetMarker, typeof import("./utils").unsetMarker, false>;
|
|
51
51
|
/**
|
|
52
52
|
* Create reusable middlewares
|
|
53
|
-
* @
|
|
53
|
+
* @see https://trpc.io/docs/v11/server/middlewares
|
|
54
54
|
*/
|
|
55
55
|
middleware: <$ContextOverrides>(fn: import("./middleware").MiddlewareFunction<TContext, TMeta, object, $ContextOverrides, unknown>) => import("./middleware").MiddlewareBuilder<TContext, TMeta, $ContextOverrides, unknown>;
|
|
56
56
|
/**
|
|
57
57
|
* Create a router
|
|
58
|
-
* @
|
|
58
|
+
* @see https://trpc.io/docs/v11/server/routers
|
|
59
59
|
*/
|
|
60
60
|
router: {
|
|
61
61
|
<TInput extends import("./router").RouterRecord>(input: TInput): import("./router").BuiltRouter<{
|
|
@@ -73,12 +73,12 @@ declare class TRPCBuilder<TContext extends object, TMeta extends object> {
|
|
|
73
73
|
};
|
|
74
74
|
/**
|
|
75
75
|
* Merge Routers
|
|
76
|
-
* @
|
|
76
|
+
* @see https://trpc.io/docs/v11/server/merging-routers
|
|
77
77
|
*/
|
|
78
78
|
mergeRouters: typeof mergeRouters;
|
|
79
79
|
/**
|
|
80
80
|
* Create a server-side caller for a router
|
|
81
|
-
* @
|
|
81
|
+
* @see https://trpc.io/docs/v11/server/server-side-calls
|
|
82
82
|
*/
|
|
83
83
|
createCallerFactory: <TRecord extends import("./router").RouterRecord>(router: Pick<import("./router").Router<{
|
|
84
84
|
ctx: TContext;
|
|
@@ -95,7 +95,7 @@ declare class TRPCBuilder<TContext extends object, TMeta extends object> {
|
|
|
95
95
|
}
|
|
96
96
|
/**
|
|
97
97
|
* Builder to initialize the tRPC root object - use this exactly once per backend
|
|
98
|
-
* @
|
|
98
|
+
* @see https://trpc.io/docs/v11/quickstart
|
|
99
99
|
*/
|
|
100
100
|
export declare const initTRPC: TRPCBuilder<object, object>;
|
|
101
101
|
export type { TRPCBuilder };
|
|
@@ -10,19 +10,19 @@ var transformer = require('./transformer.js');
|
|
|
10
10
|
class TRPCBuilder {
|
|
11
11
|
/**
|
|
12
12
|
* Add a context shape as a generic to the root object
|
|
13
|
-
* @
|
|
13
|
+
* @see https://trpc.io/docs/v11/server/context
|
|
14
14
|
*/ context() {
|
|
15
15
|
return new TRPCBuilder();
|
|
16
16
|
}
|
|
17
17
|
/**
|
|
18
18
|
* Add a meta shape as a generic to the root object
|
|
19
|
-
* @
|
|
19
|
+
* @see https://trpc.io/docs/v11/quickstart
|
|
20
20
|
*/ meta() {
|
|
21
21
|
return new TRPCBuilder();
|
|
22
22
|
}
|
|
23
23
|
/**
|
|
24
24
|
* Create the root object
|
|
25
|
-
* @
|
|
25
|
+
* @see https://trpc.io/docs/v11/server/routers#initialize-trpc
|
|
26
26
|
*/ create(opts) {
|
|
27
27
|
const config = {
|
|
28
28
|
transformer: transformer.getDataTransformer(opts?.transformer ?? transformer.defaultTransformer),
|
|
@@ -51,32 +51,32 @@ class TRPCBuilder {
|
|
|
51
51
|
*/ _config: config,
|
|
52
52
|
/**
|
|
53
53
|
* Builder object for creating procedures
|
|
54
|
-
* @
|
|
54
|
+
* @see https://trpc.io/docs/v11/server/procedures
|
|
55
55
|
*/ procedure: procedureBuilder.createBuilder({
|
|
56
56
|
meta: opts?.defaultMeta
|
|
57
57
|
}),
|
|
58
58
|
/**
|
|
59
59
|
* Create reusable middlewares
|
|
60
|
-
* @
|
|
60
|
+
* @see https://trpc.io/docs/v11/server/middlewares
|
|
61
61
|
*/ middleware: middleware.createMiddlewareFactory(),
|
|
62
62
|
/**
|
|
63
63
|
* Create a router
|
|
64
|
-
* @
|
|
64
|
+
* @see https://trpc.io/docs/v11/server/routers
|
|
65
65
|
*/ router: router.createRouterFactory(config),
|
|
66
66
|
/**
|
|
67
67
|
* Merge Routers
|
|
68
|
-
* @
|
|
68
|
+
* @see https://trpc.io/docs/v11/server/merging-routers
|
|
69
69
|
*/ mergeRouters: router.mergeRouters,
|
|
70
70
|
/**
|
|
71
71
|
* Create a server-side caller for a router
|
|
72
|
-
* @
|
|
72
|
+
* @see https://trpc.io/docs/v11/server/server-side-calls
|
|
73
73
|
*/ createCallerFactory: router.createCallerFactory()
|
|
74
74
|
};
|
|
75
75
|
}
|
|
76
76
|
}
|
|
77
77
|
/**
|
|
78
78
|
* Builder to initialize the tRPC root object - use this exactly once per backend
|
|
79
|
-
* @
|
|
79
|
+
* @see https://trpc.io/docs/v11/quickstart
|
|
80
80
|
*/ const initTRPC = new TRPCBuilder();
|
|
81
81
|
|
|
82
82
|
exports.initTRPC = initTRPC;
|
|
@@ -8,19 +8,19 @@ import { getDataTransformer, defaultTransformer } from './transformer.mjs';
|
|
|
8
8
|
class TRPCBuilder {
|
|
9
9
|
/**
|
|
10
10
|
* Add a context shape as a generic to the root object
|
|
11
|
-
* @
|
|
11
|
+
* @see https://trpc.io/docs/v11/server/context
|
|
12
12
|
*/ context() {
|
|
13
13
|
return new TRPCBuilder();
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
16
16
|
* Add a meta shape as a generic to the root object
|
|
17
|
-
* @
|
|
17
|
+
* @see https://trpc.io/docs/v11/quickstart
|
|
18
18
|
*/ meta() {
|
|
19
19
|
return new TRPCBuilder();
|
|
20
20
|
}
|
|
21
21
|
/**
|
|
22
22
|
* Create the root object
|
|
23
|
-
* @
|
|
23
|
+
* @see https://trpc.io/docs/v11/server/routers#initialize-trpc
|
|
24
24
|
*/ create(opts) {
|
|
25
25
|
const config = {
|
|
26
26
|
transformer: getDataTransformer(opts?.transformer ?? defaultTransformer),
|
|
@@ -49,32 +49,32 @@ class TRPCBuilder {
|
|
|
49
49
|
*/ _config: config,
|
|
50
50
|
/**
|
|
51
51
|
* Builder object for creating procedures
|
|
52
|
-
* @
|
|
52
|
+
* @see https://trpc.io/docs/v11/server/procedures
|
|
53
53
|
*/ procedure: createBuilder({
|
|
54
54
|
meta: opts?.defaultMeta
|
|
55
55
|
}),
|
|
56
56
|
/**
|
|
57
57
|
* Create reusable middlewares
|
|
58
|
-
* @
|
|
58
|
+
* @see https://trpc.io/docs/v11/server/middlewares
|
|
59
59
|
*/ middleware: createMiddlewareFactory(),
|
|
60
60
|
/**
|
|
61
61
|
* Create a router
|
|
62
|
-
* @
|
|
62
|
+
* @see https://trpc.io/docs/v11/server/routers
|
|
63
63
|
*/ router: createRouterFactory(config),
|
|
64
64
|
/**
|
|
65
65
|
* Merge Routers
|
|
66
|
-
* @
|
|
66
|
+
* @see https://trpc.io/docs/v11/server/merging-routers
|
|
67
67
|
*/ mergeRouters,
|
|
68
68
|
/**
|
|
69
69
|
* Create a server-side caller for a router
|
|
70
|
-
* @
|
|
70
|
+
* @see https://trpc.io/docs/v11/server/server-side-calls
|
|
71
71
|
*/ createCallerFactory: createCallerFactory()
|
|
72
72
|
};
|
|
73
73
|
}
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
76
76
|
* Builder to initialize the tRPC root object - use this exactly once per backend
|
|
77
|
-
* @
|
|
77
|
+
* @see https://trpc.io/docs/v11/quickstart
|
|
78
78
|
*/ const initTRPC = new TRPCBuilder();
|
|
79
79
|
|
|
80
80
|
export { initTRPC };
|
|
@@ -72,7 +72,7 @@ export type AnyMiddlewareBuilder = MiddlewareBuilder<any, any, any, any>;
|
|
|
72
72
|
export declare function createMiddlewareFactory<TContext, TMeta, TInputOut = unknown>(): <$ContextOverrides>(fn: MiddlewareFunction<TContext, TMeta, object, $ContextOverrides, TInputOut>) => MiddlewareBuilder<TContext, TMeta, $ContextOverrides, TInputOut>;
|
|
73
73
|
/**
|
|
74
74
|
* Create a standalone middleware
|
|
75
|
-
* @
|
|
75
|
+
* @see https://trpc.io/docs/v11/server/middlewares#experimental-standalone-middlewares
|
|
76
76
|
* @deprecated use `.unstable_concat()` instead
|
|
77
77
|
*/
|
|
78
78
|
export declare const experimental_standaloneMiddleware: <TCtx extends {
|
|
@@ -30,7 +30,7 @@ var utils = require('./utils.js');
|
|
|
30
30
|
}
|
|
31
31
|
/**
|
|
32
32
|
* Create a standalone middleware
|
|
33
|
-
* @
|
|
33
|
+
* @see https://trpc.io/docs/v11/server/middlewares#experimental-standalone-middlewares
|
|
34
34
|
* @deprecated use `.unstable_concat()` instead
|
|
35
35
|
*/ const experimental_standaloneMiddleware = ()=>({
|
|
36
36
|
create: createMiddlewareFactory()
|
|
@@ -28,7 +28,7 @@ import { isObject } from './utils.mjs';
|
|
|
28
28
|
}
|
|
29
29
|
/**
|
|
30
30
|
* Create a standalone middleware
|
|
31
|
-
* @
|
|
31
|
+
* @see https://trpc.io/docs/v11/server/middlewares#experimental-standalone-middlewares
|
|
32
32
|
* @deprecated use `.unstable_concat()` instead
|
|
33
33
|
*/ const experimental_standaloneMiddleware = ()=>({
|
|
34
34
|
create: createMiddlewareFactory()
|
|
@@ -8,9 +8,9 @@ import type { UnsetMarker } from './utils';
|
|
|
8
8
|
type IntersectIfDefined<TType, TWith> = TType extends UnsetMarker ? TWith : TWith extends UnsetMarker ? TType : Simplify<TType & TWith>;
|
|
9
9
|
type DefaultValue<TValue, TFallback> = TValue extends UnsetMarker ? TFallback : TValue;
|
|
10
10
|
type inferSubscriptionOutput<TOutput> = TOutput extends AsyncIterable<infer $Output> ? inferTrackedOutput<$Output> : inferObservableValue<TOutput>;
|
|
11
|
-
type inferSubscriptionProcedure<TInputIn, TOutputOut, $Output> = $Output extends AsyncIterable<any> ? SubscriptionProcedure<{
|
|
11
|
+
type inferSubscriptionProcedure<TInputIn, TOutputOut, $Output> = DefaultValue<TOutputOut, $Output> extends AsyncIterable<any> ? SubscriptionProcedure<{
|
|
12
12
|
input: DefaultValue<TInputIn, void>;
|
|
13
|
-
output: DefaultValue<TOutputOut,
|
|
13
|
+
output: inferSubscriptionOutput<DefaultValue<TOutputOut, $Output>>;
|
|
14
14
|
}> : LegacyObservableSubscriptionProcedure<{
|
|
15
15
|
input: DefaultValue<TInputIn, void>;
|
|
16
16
|
output: DefaultValue<TOutputOut, inferSubscriptionOutput<$Output>>;
|
|
@@ -73,22 +73,22 @@ export type inferProcedureBuilderResolverOptions<TProcedureBuilder extends AnyPr
|
|
|
73
73
|
export interface ProcedureBuilder<TContext, TMeta, TContextOverrides, TInputIn, TInputOut, TOutputIn, TOutputOut, TCaller extends boolean> {
|
|
74
74
|
/**
|
|
75
75
|
* Add an input parser to the procedure.
|
|
76
|
-
* @
|
|
76
|
+
* @see https://trpc.io/docs/v11/server/validators
|
|
77
77
|
*/
|
|
78
78
|
input<$Parser extends Parser>(schema: TInputOut extends UnsetMarker ? $Parser : inferParser<$Parser>['out'] extends Record<string, unknown> | undefined ? TInputOut extends Record<string, unknown> | undefined ? undefined extends inferParser<$Parser>['out'] ? undefined extends TInputOut ? $Parser : TypeError<'Cannot chain an optional parser to a required parser'> : $Parser : TypeError<'All input parsers did not resolve to an object'> : TypeError<'All input parsers did not resolve to an object'>): ProcedureBuilder<TContext, TMeta, TContextOverrides, IntersectIfDefined<TInputIn, inferParser<$Parser>['in']>, IntersectIfDefined<TInputOut, inferParser<$Parser>['out']>, TOutputIn, TOutputOut, TCaller>;
|
|
79
79
|
/**
|
|
80
80
|
* Add an output parser to the procedure.
|
|
81
|
-
* @
|
|
81
|
+
* @see https://trpc.io/docs/v11/server/validators
|
|
82
82
|
*/
|
|
83
83
|
output<$Parser extends Parser>(schema: $Parser): ProcedureBuilder<TContext, TMeta, TContextOverrides, TInputIn, TInputOut, IntersectIfDefined<TOutputIn, inferParser<$Parser>['in']>, IntersectIfDefined<TOutputOut, inferParser<$Parser>['out']>, TCaller>;
|
|
84
84
|
/**
|
|
85
85
|
* Add a meta data to the procedure.
|
|
86
|
-
* @
|
|
86
|
+
* @see https://trpc.io/docs/v11/server/metadata
|
|
87
87
|
*/
|
|
88
88
|
meta(meta: TMeta): ProcedureBuilder<TContext, TMeta, TContextOverrides, TInputIn, TInputOut, TOutputIn, TOutputOut, TCaller>;
|
|
89
89
|
/**
|
|
90
90
|
* Add a middleware to the procedure.
|
|
91
|
-
* @
|
|
91
|
+
* @see https://trpc.io/docs/v11/server/middlewares
|
|
92
92
|
*/
|
|
93
93
|
use<$ContextOverridesOut>(fn: MiddlewareBuilder<Overwrite<TContext, TContextOverrides>, TMeta, $ContextOverridesOut, TInputOut> | MiddlewareFunction<TContext, TMeta, TContextOverrides, $ContextOverridesOut, TInputOut>): ProcedureBuilder<TContext, TMeta, Overwrite<TContextOverrides, $ContextOverridesOut>, TInputIn, TInputOut, TOutputIn, TOutputOut, TCaller>;
|
|
94
94
|
/**
|
|
@@ -97,7 +97,7 @@ export interface ProcedureBuilder<TContext, TMeta, TContextOverrides, TInputIn,
|
|
|
97
97
|
unstable_concat<$Context, $Meta, $ContextOverrides, $InputIn, $InputOut, $OutputIn, $OutputOut>(builder: Overwrite<TContext, TContextOverrides> extends $Context ? TMeta extends $Meta ? ProcedureBuilder<$Context, $Meta, $ContextOverrides, $InputIn, $InputOut, $OutputIn, $OutputOut, TCaller> : TypeError<'Meta mismatch'> : TypeError<'Context mismatch'>): ProcedureBuilder<TContext, TMeta, Overwrite<TContextOverrides, $ContextOverrides>, IntersectIfDefined<TInputIn, $InputIn>, IntersectIfDefined<TInputIn, $InputOut>, IntersectIfDefined<TOutputIn, $OutputIn>, IntersectIfDefined<TOutputOut, $OutputOut>, TCaller>;
|
|
98
98
|
/**
|
|
99
99
|
* Query procedure
|
|
100
|
-
* @
|
|
100
|
+
* @see https://trpc.io/docs/v11/concepts#vocabulary
|
|
101
101
|
*/
|
|
102
102
|
query<$Output>(resolver: ProcedureResolver<TContext, TMeta, TContextOverrides, TInputOut, TOutputIn, $Output>): TCaller extends true ? (input: DefaultValue<TInputIn, void>) => Promise<DefaultValue<TOutputOut, $Output>> : QueryProcedure<{
|
|
103
103
|
input: DefaultValue<TInputIn, void>;
|
|
@@ -105,7 +105,7 @@ export interface ProcedureBuilder<TContext, TMeta, TContextOverrides, TInputIn,
|
|
|
105
105
|
}>;
|
|
106
106
|
/**
|
|
107
107
|
* Mutation procedure
|
|
108
|
-
* @
|
|
108
|
+
* @see https://trpc.io/docs/v11/concepts#vocabulary
|
|
109
109
|
*/
|
|
110
110
|
mutation<$Output>(resolver: ProcedureResolver<TContext, TMeta, TContextOverrides, TInputOut, TOutputIn, $Output>): TCaller extends true ? (input: DefaultValue<TInputIn, void>) => Promise<DefaultValue<TOutputOut, $Output>> : MutationProcedure<{
|
|
111
111
|
input: DefaultValue<TInputIn, void>;
|
|
@@ -113,7 +113,7 @@ export interface ProcedureBuilder<TContext, TMeta, TContextOverrides, TInputIn,
|
|
|
113
113
|
}>;
|
|
114
114
|
/**
|
|
115
115
|
* Subscription procedure
|
|
116
|
-
* @
|
|
116
|
+
* @see https://trpc.io/docs/v11/concepts#vocabulary
|
|
117
117
|
*/
|
|
118
118
|
subscription<$Output>(resolver: ProcedureResolver<TContext, TMeta, TContextOverrides, TInputOut, TOutputIn, $Output>): TCaller extends true ? TypeError<'Not implemented'> : inferSubscriptionProcedure<TInputIn, TOutputOut, $Output>;
|
|
119
119
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"procedureBuilder.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/procedureBuilder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,KAAK,EACV,qBAAqB,EACrB,iBAAiB,EACjB,kBAAkB,EAEnB,MAAM,cAAc,CAAC;AAMtB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAEpD,OAAO,KAAK,EAEV,YAAY,EAEZ,qCAAqC,EACrC,iBAAiB,EACjB,aAAa,EACb,cAAc,EACd,qBAAqB,EACtB,MAAM,aAAa,CAAC;AACrB,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,KAAK,EACV,aAAa,EACb,YAAY,EACZ,SAAS,EACT,QAA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<TTypes extends RootTypes> {
|
|
|
27
27
|
$types: TTypes;
|
|
28
28
|
/**
|
|
29
29
|
* Use a data transformer
|
|
30
|
-
* @
|
|
30
|
+
* @see https://trpc.io/docs/v11/data-transformers
|
|
31
31
|
*/
|
|
32
32
|
transformer: CombinedDataTransformer;
|
|
33
33
|
/**
|
|
34
34
|
* Use custom error formatting
|
|
35
|
-
* @
|
|
35
|
+
* @see https://trpc.io/docs/v11/error-formatting
|
|
36
36
|
*/
|
|
37
37
|
errorFormatter: ErrorFormatter<TTypes['ctx'], TTypes['errorShape']>;
|
|
38
38
|
/**
|
|
@@ -89,7 +89,7 @@ type PartialIf<TCondition extends boolean, TType> = TCondition extends true ? Pa
|
|
|
89
89
|
*/
|
|
90
90
|
export type CreateContextCallback<TContext, TFunction extends (...args: any[]) => any> = PartialIf<object extends TContext ? true : false, {
|
|
91
91
|
/**
|
|
92
|
-
* @
|
|
92
|
+
* @see https://trpc.io/docs/v11/context
|
|
93
93
|
**/
|
|
94
94
|
createContext: TFunction;
|
|
95
95
|
}>;
|
|
@@ -41,7 +41,7 @@ export interface Router<TRoot extends AnyRootTypes, TRecord extends RouterRecord
|
|
|
41
41
|
};
|
|
42
42
|
/**
|
|
43
43
|
* @deprecated use `t.createCallerFactory(router)` instead
|
|
44
|
-
* @
|
|
44
|
+
* @see https://trpc.io/docs/v11/server/server-side-calls
|
|
45
45
|
*/
|
|
46
46
|
createCaller: RouterCaller<TRoot, TRecord>;
|
|
47
47
|
}
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
export type Maybe<TType> = TType | null | undefined;
|
|
10
10
|
/**
|
|
11
11
|
* @internal
|
|
12
|
-
* @
|
|
12
|
+
* @see https://github.com/ianstormtaylor/superstruct/blob/7973400cd04d8ad92bbdc2b6f35acbfb3c934079/src/utils.ts#L323-L325
|
|
13
13
|
*/
|
|
14
14
|
export type Simplify<TType> = TType extends any[] | Date ? TType : {
|
|
15
15
|
[K in keyof TType]: TType[K];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trpc/server",
|
|
3
|
-
"version": "11.0.0-rc.
|
|
3
|
+
"version": "11.0.0-rc.551+33a3515c1",
|
|
4
4
|
"description": "The tRPC server library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -149,5 +149,5 @@
|
|
|
149
149
|
"funding": [
|
|
150
150
|
"https://trpc.io/sponsor"
|
|
151
151
|
],
|
|
152
|
-
"gitHead": "
|
|
152
|
+
"gitHead": "33a3515c12fbf14105362278d42d32f92ef22740"
|
|
153
153
|
}
|
package/src/adapters/ws.ts
CHANGED
|
@@ -38,7 +38,7 @@ import type { NodeHTTPCreateContextFnOptions } from './node-http';
|
|
|
38
38
|
|
|
39
39
|
/**
|
|
40
40
|
* Importing ws causes a build error
|
|
41
|
-
* @
|
|
41
|
+
* @see https://github.com/trpc/trpc/pull/5279
|
|
42
42
|
*/
|
|
43
43
|
const WEBSOCKET_OPEN = 1; /* ws.WebSocket.OPEN */
|
|
44
44
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import type { Simplify, WithoutIndexSignature } from '../types';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
-
* @
|
|
5
|
+
* @see https://github.com/remix-run/remix/blob/2248669ed59fd716e267ea41df5d665d4781f4a9/packages/remix-server-runtime/serialize.ts
|
|
6
6
|
*/
|
|
7
7
|
type JsonPrimitive = boolean | number | string | null;
|
|
8
8
|
// eslint-disable-next-line @typescript-eslint/ban-types
|
|
@@ -384,18 +384,33 @@ export async function resolveResponse<TRouter extends AnyRouter>(
|
|
|
384
384
|
const dataAsIterable = isObservable(data)
|
|
385
385
|
? observableToAsyncIterable(data)
|
|
386
386
|
: data;
|
|
387
|
+
|
|
387
388
|
const stream = sseStreamProducer({
|
|
388
389
|
...config.experimental?.sseSubscriptions,
|
|
389
390
|
data: dataAsIterable,
|
|
390
391
|
serialize: (v) => config.transformer.output.serialize(v),
|
|
391
392
|
formatError(errorOpts) {
|
|
393
|
+
const error = getTRPCErrorFromUnknown(errorOpts.error);
|
|
394
|
+
const input = call?.result();
|
|
395
|
+
const path = call?.path;
|
|
396
|
+
const type = call?.procedure?._def.type ?? 'unknown';
|
|
397
|
+
|
|
392
398
|
const shape = getErrorShape({
|
|
393
399
|
config,
|
|
394
400
|
ctx,
|
|
395
|
-
error
|
|
396
|
-
input
|
|
397
|
-
path
|
|
398
|
-
type
|
|
401
|
+
error,
|
|
402
|
+
input,
|
|
403
|
+
path,
|
|
404
|
+
type,
|
|
405
|
+
});
|
|
406
|
+
|
|
407
|
+
opts.onError?.({
|
|
408
|
+
error,
|
|
409
|
+
path,
|
|
410
|
+
input,
|
|
411
|
+
ctx,
|
|
412
|
+
req: opts.req,
|
|
413
|
+
type,
|
|
399
414
|
});
|
|
400
415
|
|
|
401
416
|
return shape;
|
|
@@ -50,7 +50,7 @@ export interface HTTPBaseHandlerOptions<TRouter extends AnyRouter, TRequest>
|
|
|
50
50
|
/**
|
|
51
51
|
* Add handler to be called before response is sent to the user
|
|
52
52
|
* Useful for setting cache headers
|
|
53
|
-
* @
|
|
53
|
+
* @see https://trpc.io/docs/v11/caching
|
|
54
54
|
*/
|
|
55
55
|
responseMeta?: ResponseMetaFn<TRouter>;
|
|
56
56
|
}
|
|
@@ -36,7 +36,7 @@ interface RuntimeConfigOptions<TContext extends object, TMeta extends object>
|
|
|
36
36
|
> {
|
|
37
37
|
/**
|
|
38
38
|
* Use a data transformer
|
|
39
|
-
* @
|
|
39
|
+
* @see https://trpc.io/docs/v11/data-transformers
|
|
40
40
|
*/
|
|
41
41
|
transformer?: DataTransformerOptions;
|
|
42
42
|
}
|
|
@@ -46,7 +46,7 @@ type ContextCallback = (...args: any[]) => object | Promise<object>;
|
|
|
46
46
|
class TRPCBuilder<TContext extends object, TMeta extends object> {
|
|
47
47
|
/**
|
|
48
48
|
* Add a context shape as a generic to the root object
|
|
49
|
-
* @
|
|
49
|
+
* @see https://trpc.io/docs/v11/server/context
|
|
50
50
|
*/
|
|
51
51
|
context<TNewContext extends object | ContextCallback>() {
|
|
52
52
|
return new TRPCBuilder<
|
|
@@ -57,7 +57,7 @@ class TRPCBuilder<TContext extends object, TMeta extends object> {
|
|
|
57
57
|
|
|
58
58
|
/**
|
|
59
59
|
* Add a meta shape as a generic to the root object
|
|
60
|
-
* @
|
|
60
|
+
* @see https://trpc.io/docs/v11/quickstart
|
|
61
61
|
*/
|
|
62
62
|
meta<TNewMeta extends object>() {
|
|
63
63
|
return new TRPCBuilder<TContext, TNewMeta>();
|
|
@@ -65,7 +65,7 @@ class TRPCBuilder<TContext extends object, TMeta extends object> {
|
|
|
65
65
|
|
|
66
66
|
/**
|
|
67
67
|
* Create the root object
|
|
68
|
-
* @
|
|
68
|
+
* @see https://trpc.io/docs/v11/server/routers#initialize-trpc
|
|
69
69
|
*/
|
|
70
70
|
create<TOptions extends RuntimeConfigOptions<TContext, TMeta>>(
|
|
71
71
|
opts?:
|
|
@@ -116,29 +116,29 @@ class TRPCBuilder<TContext extends object, TMeta extends object> {
|
|
|
116
116
|
_config: config,
|
|
117
117
|
/**
|
|
118
118
|
* Builder object for creating procedures
|
|
119
|
-
* @
|
|
119
|
+
* @see https://trpc.io/docs/v11/server/procedures
|
|
120
120
|
*/
|
|
121
121
|
procedure: createBuilder<$Root['ctx'], $Root['meta']>({
|
|
122
122
|
meta: opts?.defaultMeta,
|
|
123
123
|
}),
|
|
124
124
|
/**
|
|
125
125
|
* Create reusable middlewares
|
|
126
|
-
* @
|
|
126
|
+
* @see https://trpc.io/docs/v11/server/middlewares
|
|
127
127
|
*/
|
|
128
128
|
middleware: createMiddlewareFactory<$Root['ctx'], $Root['meta']>(),
|
|
129
129
|
/**
|
|
130
130
|
* Create a router
|
|
131
|
-
* @
|
|
131
|
+
* @see https://trpc.io/docs/v11/server/routers
|
|
132
132
|
*/
|
|
133
133
|
router: createRouterFactory<$Root>(config),
|
|
134
134
|
/**
|
|
135
135
|
* Merge Routers
|
|
136
|
-
* @
|
|
136
|
+
* @see https://trpc.io/docs/v11/server/merging-routers
|
|
137
137
|
*/
|
|
138
138
|
mergeRouters,
|
|
139
139
|
/**
|
|
140
140
|
* Create a server-side caller for a router
|
|
141
|
-
* @
|
|
141
|
+
* @see https://trpc.io/docs/v11/server/server-side-calls
|
|
142
142
|
*/
|
|
143
143
|
createCallerFactory: createCallerFactory<$Root>(),
|
|
144
144
|
};
|
|
@@ -147,7 +147,7 @@ class TRPCBuilder<TContext extends object, TMeta extends object> {
|
|
|
147
147
|
|
|
148
148
|
/**
|
|
149
149
|
* Builder to initialize the tRPC root object - use this exactly once per backend
|
|
150
|
-
* @
|
|
150
|
+
* @see https://trpc.io/docs/v11/quickstart
|
|
151
151
|
*/
|
|
152
152
|
export const initTRPC = new TRPCBuilder();
|
|
153
153
|
export type { TRPCBuilder };
|
|
@@ -158,7 +158,7 @@ export function createMiddlewareFactory<
|
|
|
158
158
|
|
|
159
159
|
/**
|
|
160
160
|
* Create a standalone middleware
|
|
161
|
-
* @
|
|
161
|
+
* @see https://trpc.io/docs/v11/server/middlewares#experimental-standalone-middlewares
|
|
162
162
|
* @deprecated use `.unstable_concat()` instead
|
|
163
163
|
*/
|
|
164
164
|
export const experimental_standaloneMiddleware = <
|
|
@@ -50,16 +50,18 @@ type inferSubscriptionOutput<TOutput> = TOutput extends AsyncIterable<
|
|
|
50
50
|
? inferTrackedOutput<$Output>
|
|
51
51
|
: inferObservableValue<TOutput>;
|
|
52
52
|
|
|
53
|
-
type inferSubscriptionProcedure<TInputIn, TOutputOut, $Output> =
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
53
|
+
type inferSubscriptionProcedure<TInputIn, TOutputOut, $Output> = DefaultValue<
|
|
54
|
+
TOutputOut,
|
|
55
|
+
$Output
|
|
56
|
+
> extends AsyncIterable<any>
|
|
57
|
+
? SubscriptionProcedure<{
|
|
58
|
+
input: DefaultValue<TInputIn, void>;
|
|
59
|
+
output: inferSubscriptionOutput<DefaultValue<TOutputOut, $Output>>;
|
|
60
|
+
}>
|
|
61
|
+
: LegacyObservableSubscriptionProcedure<{
|
|
62
|
+
input: DefaultValue<TInputIn, void>;
|
|
63
|
+
output: DefaultValue<TOutputOut, inferSubscriptionOutput<$Output>>;
|
|
64
|
+
}>;
|
|
63
65
|
|
|
64
66
|
export type CallerOverride<TContext> = (opts: {
|
|
65
67
|
args: unknown[];
|
|
@@ -186,7 +188,7 @@ export interface ProcedureBuilder<
|
|
|
186
188
|
> {
|
|
187
189
|
/**
|
|
188
190
|
* Add an input parser to the procedure.
|
|
189
|
-
* @
|
|
191
|
+
* @see https://trpc.io/docs/v11/server/validators
|
|
190
192
|
*/
|
|
191
193
|
input<$Parser extends Parser>(
|
|
192
194
|
schema: TInputOut extends UnsetMarker
|
|
@@ -212,7 +214,7 @@ export interface ProcedureBuilder<
|
|
|
212
214
|
>;
|
|
213
215
|
/**
|
|
214
216
|
* Add an output parser to the procedure.
|
|
215
|
-
* @
|
|
217
|
+
* @see https://trpc.io/docs/v11/server/validators
|
|
216
218
|
*/
|
|
217
219
|
output<$Parser extends Parser>(
|
|
218
220
|
schema: $Parser,
|
|
@@ -228,7 +230,7 @@ export interface ProcedureBuilder<
|
|
|
228
230
|
>;
|
|
229
231
|
/**
|
|
230
232
|
* Add a meta data to the procedure.
|
|
231
|
-
* @
|
|
233
|
+
* @see https://trpc.io/docs/v11/server/metadata
|
|
232
234
|
*/
|
|
233
235
|
meta(
|
|
234
236
|
meta: TMeta,
|
|
@@ -244,7 +246,7 @@ export interface ProcedureBuilder<
|
|
|
244
246
|
>;
|
|
245
247
|
/**
|
|
246
248
|
* Add a middleware to the procedure.
|
|
247
|
-
* @
|
|
249
|
+
* @see https://trpc.io/docs/v11/server/middlewares
|
|
248
250
|
*/
|
|
249
251
|
use<$ContextOverridesOut>(
|
|
250
252
|
fn:
|
|
@@ -310,7 +312,7 @@ export interface ProcedureBuilder<
|
|
|
310
312
|
>;
|
|
311
313
|
/**
|
|
312
314
|
* Query procedure
|
|
313
|
-
* @
|
|
315
|
+
* @see https://trpc.io/docs/v11/concepts#vocabulary
|
|
314
316
|
*/
|
|
315
317
|
query<$Output>(
|
|
316
318
|
resolver: ProcedureResolver<
|
|
@@ -332,7 +334,7 @@ export interface ProcedureBuilder<
|
|
|
332
334
|
|
|
333
335
|
/**
|
|
334
336
|
* Mutation procedure
|
|
335
|
-
* @
|
|
337
|
+
* @see https://trpc.io/docs/v11/concepts#vocabulary
|
|
336
338
|
*/
|
|
337
339
|
mutation<$Output>(
|
|
338
340
|
resolver: ProcedureResolver<
|
|
@@ -354,7 +356,7 @@ export interface ProcedureBuilder<
|
|
|
354
356
|
|
|
355
357
|
/**
|
|
356
358
|
* Subscription procedure
|
|
357
|
-
* @
|
|
359
|
+
* @see https://trpc.io/docs/v11/concepts#vocabulary
|
|
358
360
|
*/
|
|
359
361
|
subscription<$Output>(
|
|
360
362
|
resolver: ProcedureResolver<
|
|
@@ -36,12 +36,12 @@ export interface RootConfig<TTypes extends RootTypes> {
|
|
|
36
36
|
$types: TTypes;
|
|
37
37
|
/**
|
|
38
38
|
* Use a data transformer
|
|
39
|
-
* @
|
|
39
|
+
* @see https://trpc.io/docs/v11/data-transformers
|
|
40
40
|
*/
|
|
41
41
|
transformer: CombinedDataTransformer;
|
|
42
42
|
/**
|
|
43
43
|
* Use custom error formatting
|
|
44
|
-
* @
|
|
44
|
+
* @see https://trpc.io/docs/v11/error-formatting
|
|
45
45
|
*/
|
|
46
46
|
errorFormatter: ErrorFormatter<TTypes['ctx'], TTypes['errorShape']>;
|
|
47
47
|
/**
|
|
@@ -114,7 +114,7 @@ export type CreateContextCallback<
|
|
|
114
114
|
object extends TContext ? true : false,
|
|
115
115
|
{
|
|
116
116
|
/**
|
|
117
|
-
* @
|
|
117
|
+
* @see https://trpc.io/docs/v11/context
|
|
118
118
|
**/
|
|
119
119
|
createContext: TFunction;
|
|
120
120
|
}
|
|
@@ -80,7 +80,7 @@ export interface Router<
|
|
|
80
80
|
};
|
|
81
81
|
/**
|
|
82
82
|
* @deprecated use `t.createCallerFactory(router)` instead
|
|
83
|
-
* @
|
|
83
|
+
* @see https://trpc.io/docs/v11/server/server-side-calls
|
|
84
84
|
*/
|
|
85
85
|
createCaller: RouterCaller<TRoot, TRecord>;
|
|
86
86
|
}
|
|
@@ -11,7 +11,7 @@ export type Maybe<TType> = TType | null | undefined;
|
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* @internal
|
|
14
|
-
* @
|
|
14
|
+
* @see https://github.com/ianstormtaylor/superstruct/blob/7973400cd04d8ad92bbdc2b6f35acbfb3c934079/src/utils.ts#L323-L325
|
|
15
15
|
*/
|
|
16
16
|
export type Simplify<TType> = TType extends any[] | Date
|
|
17
17
|
? TType
|