@trpc/server 11.0.0-rc.383 → 11.0.0-rc.390
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 +40 -40
- 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/stream/stream.d.ts +10 -5
- package/dist/unstable-core-do-not-import/stream/stream.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/stream/stream.js +18 -6
- package/dist/unstable-core-do-not-import/stream/stream.mjs +18 -6
- package/package.json +2 -2
- package/src/unstable-core-do-not-import/http/resolveResponse.ts +17 -4
- package/src/unstable-core-do-not-import/stream/stream.ts +26 -15
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction": 31.
|
|
2
|
+
"bundleSize": 105459,
|
|
3
|
+
"bundleOrigSize": 153978,
|
|
4
|
+
"bundleReduction": 31.51,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/unstable-core-do-not-import/stream/stream.ts",
|
|
8
|
-
"size":
|
|
9
|
-
"origSize":
|
|
8
|
+
"size": 14926,
|
|
9
|
+
"origSize": 16301,
|
|
10
10
|
"renderedExports": [
|
|
11
11
|
"isPromise",
|
|
12
12
|
"jsonlStreamProducer",
|
|
@@ -17,8 +17,8 @@
|
|
|
17
17
|
"/src/unstable-core-do-not-import.ts",
|
|
18
18
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
19
19
|
],
|
|
20
|
-
"percent":
|
|
21
|
-
"reduction":
|
|
20
|
+
"percent": 14.15,
|
|
21
|
+
"reduction": 8.44
|
|
22
22
|
},
|
|
23
23
|
{
|
|
24
24
|
"id": "/src/adapters/ws.ts",
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"dependents": [
|
|
33
33
|
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
34
34
|
],
|
|
35
|
-
"percent": 10.
|
|
35
|
+
"percent": 10.66,
|
|
36
36
|
"reduction": 0
|
|
37
37
|
},
|
|
38
38
|
{
|
|
39
39
|
"id": "/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
40
|
-
"size":
|
|
41
|
-
"origSize":
|
|
40
|
+
"size": 10850,
|
|
41
|
+
"origSize": 11195,
|
|
42
42
|
"renderedExports": [
|
|
43
43
|
"resolveResponse"
|
|
44
44
|
],
|
|
@@ -46,8 +46,8 @@
|
|
|
46
46
|
"dependents": [
|
|
47
47
|
"/src/unstable-core-do-not-import.ts"
|
|
48
48
|
],
|
|
49
|
-
"percent": 10,
|
|
50
|
-
"reduction":
|
|
49
|
+
"percent": 10.29,
|
|
50
|
+
"reduction": 3.08
|
|
51
51
|
},
|
|
52
52
|
{
|
|
53
53
|
"id": "/src/unstable-core-do-not-import/procedureBuilder.ts",
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"/src/unstable-core-do-not-import.ts",
|
|
62
62
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
63
63
|
],
|
|
64
|
-
"percent": 6
|
|
64
|
+
"percent": 6,
|
|
65
65
|
"reduction": 59.52
|
|
66
66
|
},
|
|
67
67
|
{
|
|
@@ -80,7 +80,7 @@
|
|
|
80
80
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
81
81
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
82
82
|
],
|
|
83
|
-
"percent": 5.
|
|
83
|
+
"percent": 5.68,
|
|
84
84
|
"reduction": 41.05
|
|
85
85
|
},
|
|
86
86
|
{
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"/src/unstable-core-do-not-import.ts",
|
|
96
96
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
97
97
|
],
|
|
98
|
-
"percent": 5.
|
|
98
|
+
"percent": 5.26,
|
|
99
99
|
"reduction": 0
|
|
100
100
|
},
|
|
101
101
|
{
|
|
@@ -109,7 +109,7 @@
|
|
|
109
109
|
"dependents": [
|
|
110
110
|
"/src/adapters/aws-lambda/index.ts"
|
|
111
111
|
],
|
|
112
|
-
"percent": 4.
|
|
112
|
+
"percent": 4.6,
|
|
113
113
|
"reduction": 13.62
|
|
114
114
|
},
|
|
115
115
|
{
|
|
@@ -123,7 +123,7 @@
|
|
|
123
123
|
"dependents": [
|
|
124
124
|
"/src/adapters/next-app-dir.ts"
|
|
125
125
|
],
|
|
126
|
-
"percent":
|
|
126
|
+
"percent": 2.97,
|
|
127
127
|
"reduction": 22.27
|
|
128
128
|
},
|
|
129
129
|
{
|
|
@@ -140,7 +140,7 @@
|
|
|
140
140
|
"/src/observable/index.ts",
|
|
141
141
|
"/src/observable/operators.ts"
|
|
142
142
|
],
|
|
143
|
-
"percent": 2.
|
|
143
|
+
"percent": 2.97,
|
|
144
144
|
"reduction": 0.67
|
|
145
145
|
},
|
|
146
146
|
{
|
|
@@ -156,7 +156,7 @@
|
|
|
156
156
|
"dependents": [
|
|
157
157
|
"/src/observable/index.ts"
|
|
158
158
|
],
|
|
159
|
-
"percent": 2.
|
|
159
|
+
"percent": 2.61,
|
|
160
160
|
"reduction": 0
|
|
161
161
|
},
|
|
162
162
|
{
|
|
@@ -176,7 +176,7 @@
|
|
|
176
176
|
"/src/unstable-core-do-not-import/router.ts",
|
|
177
177
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
178
178
|
],
|
|
179
|
-
"percent": 2.
|
|
179
|
+
"percent": 2.6,
|
|
180
180
|
"reduction": 45.94
|
|
181
181
|
},
|
|
182
182
|
{
|
|
@@ -190,7 +190,7 @@
|
|
|
190
190
|
"dependents": [
|
|
191
191
|
"/src/unstable-core-do-not-import.ts"
|
|
192
192
|
],
|
|
193
|
-
"percent": 2.
|
|
193
|
+
"percent": 2.56,
|
|
194
194
|
"reduction": 40.91
|
|
195
195
|
},
|
|
196
196
|
{
|
|
@@ -210,7 +210,7 @@
|
|
|
210
210
|
"/src/unstable-core-do-not-import/initTRPC.ts",
|
|
211
211
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
212
212
|
],
|
|
213
|
-
"percent": 2.
|
|
213
|
+
"percent": 2.49,
|
|
214
214
|
"reduction": 55.5
|
|
215
215
|
},
|
|
216
216
|
{
|
|
@@ -224,7 +224,7 @@
|
|
|
224
224
|
"dependents": [
|
|
225
225
|
"/src/adapters/fetch/index.ts"
|
|
226
226
|
],
|
|
227
|
-
"percent": 2.
|
|
227
|
+
"percent": 2.14,
|
|
228
228
|
"reduction": 2.17
|
|
229
229
|
},
|
|
230
230
|
{
|
|
@@ -239,7 +239,7 @@
|
|
|
239
239
|
"/src/adapters/node-http/index.ts",
|
|
240
240
|
"/src/adapters/node-http/nodeHTTPRequestHandler.ts"
|
|
241
241
|
],
|
|
242
|
-
"percent": 2.
|
|
242
|
+
"percent": 2.06,
|
|
243
243
|
"reduction": 14.12
|
|
244
244
|
},
|
|
245
245
|
{
|
|
@@ -253,7 +253,7 @@
|
|
|
253
253
|
"dependents": [
|
|
254
254
|
"/src/adapters/next-app-dir/nextAppDirCaller.ts"
|
|
255
255
|
],
|
|
256
|
-
"percent": 1.
|
|
256
|
+
"percent": 1.94,
|
|
257
257
|
"reduction": 5.79
|
|
258
258
|
},
|
|
259
259
|
{
|
|
@@ -269,7 +269,7 @@
|
|
|
269
269
|
"/src/unstable-core-do-not-import.ts",
|
|
270
270
|
"/src/unstable-core-do-not-import/router.ts"
|
|
271
271
|
],
|
|
272
|
-
"percent": 1.
|
|
272
|
+
"percent": 1.9,
|
|
273
273
|
"reduction": 0
|
|
274
274
|
},
|
|
275
275
|
{
|
|
@@ -290,7 +290,7 @@
|
|
|
290
290
|
"/src/unstable-core-do-not-import/http/contentType.ts",
|
|
291
291
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
292
292
|
],
|
|
293
|
-
"percent": 1.
|
|
293
|
+
"percent": 1.64,
|
|
294
294
|
"reduction": 19.47
|
|
295
295
|
},
|
|
296
296
|
{
|
|
@@ -304,7 +304,7 @@
|
|
|
304
304
|
"dependents": [
|
|
305
305
|
"/src/adapters/node-http/index.ts"
|
|
306
306
|
],
|
|
307
|
-
"percent": 1.
|
|
307
|
+
"percent": 1.63,
|
|
308
308
|
"reduction": 20.03
|
|
309
309
|
},
|
|
310
310
|
{
|
|
@@ -316,7 +316,7 @@
|
|
|
316
316
|
],
|
|
317
317
|
"removedExports": [],
|
|
318
318
|
"dependents": [],
|
|
319
|
-
"percent": 1.
|
|
319
|
+
"percent": 1.5,
|
|
320
320
|
"reduction": 21.04
|
|
321
321
|
},
|
|
322
322
|
{
|
|
@@ -328,7 +328,7 @@
|
|
|
328
328
|
],
|
|
329
329
|
"removedExports": [],
|
|
330
330
|
"dependents": [],
|
|
331
|
-
"percent": 1.
|
|
331
|
+
"percent": 1.46,
|
|
332
332
|
"reduction": 26.94
|
|
333
333
|
},
|
|
334
334
|
{
|
|
@@ -341,7 +341,7 @@
|
|
|
341
341
|
],
|
|
342
342
|
"removedExports": [],
|
|
343
343
|
"dependents": [],
|
|
344
|
-
"percent": 1.
|
|
344
|
+
"percent": 1.45,
|
|
345
345
|
"reduction": 27.6
|
|
346
346
|
},
|
|
347
347
|
{
|
|
@@ -355,7 +355,7 @@
|
|
|
355
355
|
"dependents": [
|
|
356
356
|
"/src/adapters/fastify/index.ts"
|
|
357
357
|
],
|
|
358
|
-
"percent": 1.
|
|
358
|
+
"percent": 1.42,
|
|
359
359
|
"reduction": 34.7
|
|
360
360
|
},
|
|
361
361
|
{
|
|
@@ -372,7 +372,7 @@
|
|
|
372
372
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
373
373
|
"/src/unstable-core-do-not-import/error/getErrorShape.ts"
|
|
374
374
|
],
|
|
375
|
-
"percent": 1.
|
|
375
|
+
"percent": 1.2,
|
|
376
376
|
"reduction": 23.5
|
|
377
377
|
},
|
|
378
378
|
{
|
|
@@ -400,7 +400,7 @@
|
|
|
400
400
|
"/src/unstable-core-do-not-import/procedureBuilder.ts",
|
|
401
401
|
"/src/unstable-core-do-not-import/stream/stream.ts"
|
|
402
402
|
],
|
|
403
|
-
"percent": 1.
|
|
403
|
+
"percent": 1.09,
|
|
404
404
|
"reduction": 27.13
|
|
405
405
|
},
|
|
406
406
|
{
|
|
@@ -415,7 +415,7 @@
|
|
|
415
415
|
"/src/adapters/fastify/index.ts",
|
|
416
416
|
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
417
417
|
],
|
|
418
|
-
"percent": 1.
|
|
418
|
+
"percent": 1.07,
|
|
419
419
|
"reduction": 47.59
|
|
420
420
|
},
|
|
421
421
|
{
|
|
@@ -430,7 +430,7 @@
|
|
|
430
430
|
"/src/unstable-core-do-not-import.ts",
|
|
431
431
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
432
432
|
],
|
|
433
|
-
"percent": 0.
|
|
433
|
+
"percent": 0.94,
|
|
434
434
|
"reduction": 56.22
|
|
435
435
|
},
|
|
436
436
|
{
|
|
@@ -473,7 +473,7 @@
|
|
|
473
473
|
],
|
|
474
474
|
"removedExports": [],
|
|
475
475
|
"dependents": [],
|
|
476
|
-
"percent": 0.
|
|
476
|
+
"percent": 0.72,
|
|
477
477
|
"reduction": 66.9
|
|
478
478
|
},
|
|
479
479
|
{
|
|
@@ -487,7 +487,7 @@
|
|
|
487
487
|
"dependents": [
|
|
488
488
|
"/src/unstable-core-do-not-import.ts"
|
|
489
489
|
],
|
|
490
|
-
"percent": 0.
|
|
490
|
+
"percent": 0.63,
|
|
491
491
|
"reduction": 0.6
|
|
492
492
|
},
|
|
493
493
|
{
|
|
@@ -502,7 +502,7 @@
|
|
|
502
502
|
"/src/unstable-core-do-not-import.ts",
|
|
503
503
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
504
504
|
],
|
|
505
|
-
"percent": 0.
|
|
505
|
+
"percent": 0.59,
|
|
506
506
|
"reduction": 43.49
|
|
507
507
|
},
|
|
508
508
|
{
|
|
@@ -515,7 +515,7 @@
|
|
|
515
515
|
],
|
|
516
516
|
"removedExports": [],
|
|
517
517
|
"dependents": [],
|
|
518
|
-
"percent": 0.
|
|
518
|
+
"percent": 0.49,
|
|
519
519
|
"reduction": 67.09
|
|
520
520
|
},
|
|
521
521
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolveResponse.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/resolveResponse.ts"],"names":[],"mappings":"AAEA,OAAO,EAA2B,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,EAEL,KAAK,SAAS,EAGf,MAAM,WAAW,CAAC;AAOnB,OAAO,KAAK,EACV,sBAAsB,EACtB,kCAAkC,EAEnC,MAAM,SAAS,CAAC;AAUjB,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;AAsHD,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":"AAEA,OAAO,EAA2B,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAExE,OAAO,EAEL,KAAK,SAAS,EAGf,MAAM,WAAW,CAAC;AAOnB,OAAO,KAAK,EACV,sBAAsB,EACtB,kCAAkC,EAEnC,MAAM,SAAS,CAAC;AAUjB,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;AAsHD,wBAAsB,eAAe,CAAC,OAAO,SAAS,SAAS,EAC7D,IAAI,EAAE,yBAAyB,CAAC,OAAO,CAAC,GACvC,OAAO,CAAC,QAAQ,CAAC,CA8QnB"}
|
|
@@ -92,6 +92,7 @@ async function resolveResponse(opts) {
|
|
|
92
92
|
'trpc-accept'
|
|
93
93
|
]
|
|
94
94
|
]);
|
|
95
|
+
const config = router$1._def._config;
|
|
95
96
|
const url = new URL(req.url);
|
|
96
97
|
if (req.method === 'HEAD') {
|
|
97
98
|
// can be used for lambda warmup
|
|
@@ -105,12 +106,12 @@ async function resolveResponse(opts) {
|
|
|
105
106
|
let ctx = undefined;
|
|
106
107
|
let info = undefined;
|
|
107
108
|
const isStreamCall = req.headers.get('trpc-accept') === 'application/jsonl';
|
|
108
|
-
const experimentalIterablesAndDeferreds =
|
|
109
|
+
const experimentalIterablesAndDeferreds = config.experimental?.iterablesAndDeferreds ?? false;
|
|
109
110
|
try {
|
|
110
111
|
info = contentType.getRequestInfo({
|
|
111
112
|
req,
|
|
112
113
|
path: decodeURIComponent(opts.path),
|
|
113
|
-
config:
|
|
114
|
+
config: config,
|
|
114
115
|
searchParams: url.searchParams
|
|
115
116
|
});
|
|
116
117
|
// we create context early so that error handlers may access context information
|
|
@@ -176,7 +177,7 @@ async function resolveResponse(opts) {
|
|
|
176
177
|
});
|
|
177
178
|
return {
|
|
178
179
|
error: getErrorShape.getErrorShape({
|
|
179
|
-
config
|
|
180
|
+
config,
|
|
180
181
|
error,
|
|
181
182
|
type,
|
|
182
183
|
path: call.path,
|
|
@@ -244,6 +245,17 @@ async function resolveResponse(opts) {
|
|
|
244
245
|
* }
|
|
245
246
|
* }
|
|
246
247
|
*/ maxDepth: experimentalIterablesAndDeferreds ? 4 : 3,
|
|
248
|
+
formatError (errorOpts) {
|
|
249
|
+
const call = info?.calls[errorOpts.path[0]];
|
|
250
|
+
return getErrorShape.getErrorShape({
|
|
251
|
+
config,
|
|
252
|
+
ctx,
|
|
253
|
+
error: TRPCError.getTRPCErrorFromUnknown(errorOpts.error),
|
|
254
|
+
input: call?.result(),
|
|
255
|
+
path: call?.path,
|
|
256
|
+
type
|
|
257
|
+
});
|
|
258
|
+
},
|
|
247
259
|
data: promises.map(async (it)=>{
|
|
248
260
|
const response = await it;
|
|
249
261
|
if ('result' in response) {
|
|
@@ -260,7 +272,7 @@ async function resolveResponse(opts) {
|
|
|
260
272
|
}
|
|
261
273
|
return response;
|
|
262
274
|
}),
|
|
263
|
-
serialize:
|
|
275
|
+
serialize: config.transformer.output.serialize,
|
|
264
276
|
onError: (cause)=>{
|
|
265
277
|
opts.onError?.({
|
|
266
278
|
error: TRPCError.getTRPCErrorFromUnknown(cause),
|
|
@@ -90,6 +90,7 @@ async function resolveResponse(opts) {
|
|
|
90
90
|
'trpc-accept'
|
|
91
91
|
]
|
|
92
92
|
]);
|
|
93
|
+
const config = router._def._config;
|
|
93
94
|
const url = new URL(req.url);
|
|
94
95
|
if (req.method === 'HEAD') {
|
|
95
96
|
// can be used for lambda warmup
|
|
@@ -103,12 +104,12 @@ async function resolveResponse(opts) {
|
|
|
103
104
|
let ctx = undefined;
|
|
104
105
|
let info = undefined;
|
|
105
106
|
const isStreamCall = req.headers.get('trpc-accept') === 'application/jsonl';
|
|
106
|
-
const experimentalIterablesAndDeferreds =
|
|
107
|
+
const experimentalIterablesAndDeferreds = config.experimental?.iterablesAndDeferreds ?? false;
|
|
107
108
|
try {
|
|
108
109
|
info = getRequestInfo({
|
|
109
110
|
req,
|
|
110
111
|
path: decodeURIComponent(opts.path),
|
|
111
|
-
config:
|
|
112
|
+
config: config,
|
|
112
113
|
searchParams: url.searchParams
|
|
113
114
|
});
|
|
114
115
|
// we create context early so that error handlers may access context information
|
|
@@ -174,7 +175,7 @@ async function resolveResponse(opts) {
|
|
|
174
175
|
});
|
|
175
176
|
return {
|
|
176
177
|
error: getErrorShape({
|
|
177
|
-
config
|
|
178
|
+
config,
|
|
178
179
|
error,
|
|
179
180
|
type,
|
|
180
181
|
path: call.path,
|
|
@@ -242,6 +243,17 @@ async function resolveResponse(opts) {
|
|
|
242
243
|
* }
|
|
243
244
|
* }
|
|
244
245
|
*/ maxDepth: experimentalIterablesAndDeferreds ? 4 : 3,
|
|
246
|
+
formatError (errorOpts) {
|
|
247
|
+
const call = info?.calls[errorOpts.path[0]];
|
|
248
|
+
return getErrorShape({
|
|
249
|
+
config,
|
|
250
|
+
ctx,
|
|
251
|
+
error: getTRPCErrorFromUnknown(errorOpts.error),
|
|
252
|
+
input: call?.result(),
|
|
253
|
+
path: call?.path,
|
|
254
|
+
type
|
|
255
|
+
});
|
|
256
|
+
},
|
|
245
257
|
data: promises.map(async (it)=>{
|
|
246
258
|
const response = await it;
|
|
247
259
|
if ('result' in response) {
|
|
@@ -258,7 +270,7 @@ async function resolveResponse(opts) {
|
|
|
258
270
|
}
|
|
259
271
|
return response;
|
|
260
272
|
}),
|
|
261
|
-
serialize:
|
|
273
|
+
serialize: config.transformer.output.serialize,
|
|
262
274
|
onError: (cause)=>{
|
|
263
275
|
opts.onError?.({
|
|
264
276
|
error: getTRPCErrorFromUnknown(cause),
|
|
@@ -42,17 +42,15 @@ type PromiseChunk = [
|
|
|
42
42
|
chunkIndex: ChunkIndex,
|
|
43
43
|
status: PROMISE_STATUS_FULFILLED,
|
|
44
44
|
value: HydratedValue
|
|
45
|
-
] | [
|
|
46
|
-
chunkIndex: ChunkIndex,
|
|
47
|
-
status: PROMISE_STATUS_REJECTED
|
|
48
|
-
];
|
|
45
|
+
] | [chunkIndex: ChunkIndex, status: PROMISE_STATUS_REJECTED, error: unknown];
|
|
49
46
|
type IterableChunk = [chunkIndex: ChunkIndex, status: ASYNC_ITERABLE_STATUS_DONE] | [
|
|
50
47
|
chunkIndex: ChunkIndex,
|
|
51
48
|
status: ASYNC_ITERABLE_STATUS_VALUE,
|
|
52
49
|
value: HydratedValue
|
|
53
50
|
] | [
|
|
54
51
|
chunkIndex: ChunkIndex,
|
|
55
|
-
status: ASYNC_ITERABLE_STATUS_ERROR
|
|
52
|
+
status: ASYNC_ITERABLE_STATUS_ERROR,
|
|
53
|
+
error: unknown
|
|
56
54
|
];
|
|
57
55
|
type ChunkData = PromiseChunk | IterableChunk;
|
|
58
56
|
export declare function isPromise(value: unknown): value is Promise<unknown>;
|
|
@@ -66,6 +64,10 @@ export interface ProducerOptions {
|
|
|
66
64
|
serialize?: Serialize;
|
|
67
65
|
data: Record<number, unknown>;
|
|
68
66
|
onError?: ProducerOnError;
|
|
67
|
+
formatError?: (opts: {
|
|
68
|
+
error: unknown;
|
|
69
|
+
path: (string | number)[];
|
|
70
|
+
}) => unknown;
|
|
69
71
|
maxDepth?: number;
|
|
70
72
|
}
|
|
71
73
|
/**
|
|
@@ -87,6 +89,9 @@ export declare function jsonlStreamConsumer<THead>(opts: {
|
|
|
87
89
|
from: NodeJSReadableStreamEsque | WebReadableStreamEsque;
|
|
88
90
|
deserialize?: Deserialize;
|
|
89
91
|
onError?: ConsumerOnError;
|
|
92
|
+
formatError?: (opts: {
|
|
93
|
+
error: unknown;
|
|
94
|
+
}) => Error;
|
|
90
95
|
}): Promise<readonly [Awaited<THead>, {
|
|
91
96
|
readonly controllers: Map<ChunkIndex, ReadableStreamDefaultController<ChunkData | StreamInterruptedError>>;
|
|
92
97
|
}]>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/stream/stream.ts"],"names":[],"mappings":"AAiBA;;;GAGG;AACH,MAAM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,CAAC;IACtB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE;QACnB,KAAK,EAAE,OAAO,CAAC;QACf,IAAI,EAAE,CAAC,MAAM,GAAG,MAAM,CAAC,EAAE,CAAC;KAC3B,KAAK,OAAO,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAkJD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,eAAe,8BA2BxD;AACD,cAAM,sBAAuB,SAAQ,KAAK;gBAC5B,KAAK,CAAC,EAAE,OAAO;CAK5B;AAMD,MAAM,MAAM,eAAe,GAAG,CAAC,IAAI,EAAE;IAAE,KAAK,EAAE,OAAO,CAAA;CAAE,KAAK,IAAI,CAAC;AA6FjE;;;GAGG;AACH,wBAAsB,mBAAmB,CAAC,KAAK,EAAE,IAAI,EAAE;IACrD,IAAI,EAAE,yBAAyB,GAAG,sBAAsB,CAAC;IACzD,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,KAAK,EAAE,OAAO,CAAA;KAAE,KAAK,KAAK,CAAC;CACnD;;IAkLA"}
|
|
@@ -63,14 +63,18 @@ function createBatchStreamProducer(opts) {
|
|
|
63
63
|
PROMISE_STATUS_FULFILLED,
|
|
64
64
|
hydrate(it, path)
|
|
65
65
|
]);
|
|
66
|
-
}).catch((
|
|
66
|
+
}).catch((error)=>{
|
|
67
67
|
opts.onError?.({
|
|
68
|
-
error
|
|
68
|
+
error,
|
|
69
69
|
path
|
|
70
70
|
});
|
|
71
71
|
enqueue([
|
|
72
72
|
idx,
|
|
73
|
-
PROMISE_STATUS_REJECTED
|
|
73
|
+
PROMISE_STATUS_REJECTED,
|
|
74
|
+
opts.formatError?.({
|
|
75
|
+
error,
|
|
76
|
+
path
|
|
77
|
+
})
|
|
74
78
|
]);
|
|
75
79
|
}).finally(()=>{
|
|
76
80
|
pending.delete(idx);
|
|
@@ -109,7 +113,11 @@ function createBatchStreamProducer(opts) {
|
|
|
109
113
|
});
|
|
110
114
|
controller.enqueue([
|
|
111
115
|
idx,
|
|
112
|
-
ASYNC_ITERABLE_STATUS_ERROR
|
|
116
|
+
ASYNC_ITERABLE_STATUS_ERROR,
|
|
117
|
+
opts.formatError?.({
|
|
118
|
+
error,
|
|
119
|
+
path
|
|
120
|
+
})
|
|
113
121
|
]);
|
|
114
122
|
} finally{
|
|
115
123
|
pending.delete(idx);
|
|
@@ -355,7 +363,9 @@ function createDeferred() {
|
|
|
355
363
|
resolve(dehydrate(data));
|
|
356
364
|
break;
|
|
357
365
|
case PROMISE_STATUS_REJECTED:
|
|
358
|
-
reject(
|
|
366
|
+
reject(opts.formatError?.({
|
|
367
|
+
error: data
|
|
368
|
+
}) ?? new AsyncError(data));
|
|
359
369
|
break;
|
|
360
370
|
}
|
|
361
371
|
}).catch(reject).finally(()=>{
|
|
@@ -387,7 +397,9 @@ function createDeferred() {
|
|
|
387
397
|
return;
|
|
388
398
|
case ASYNC_ITERABLE_STATUS_ERROR:
|
|
389
399
|
controllers.delete(chunkId);
|
|
390
|
-
throw
|
|
400
|
+
throw opts.formatError?.({
|
|
401
|
+
error: data
|
|
402
|
+
}) ?? new AsyncError(data);
|
|
391
403
|
}
|
|
392
404
|
}
|
|
393
405
|
}
|
|
@@ -61,14 +61,18 @@ function createBatchStreamProducer(opts) {
|
|
|
61
61
|
PROMISE_STATUS_FULFILLED,
|
|
62
62
|
hydrate(it, path)
|
|
63
63
|
]);
|
|
64
|
-
}).catch((
|
|
64
|
+
}).catch((error)=>{
|
|
65
65
|
opts.onError?.({
|
|
66
|
-
error
|
|
66
|
+
error,
|
|
67
67
|
path
|
|
68
68
|
});
|
|
69
69
|
enqueue([
|
|
70
70
|
idx,
|
|
71
|
-
PROMISE_STATUS_REJECTED
|
|
71
|
+
PROMISE_STATUS_REJECTED,
|
|
72
|
+
opts.formatError?.({
|
|
73
|
+
error,
|
|
74
|
+
path
|
|
75
|
+
})
|
|
72
76
|
]);
|
|
73
77
|
}).finally(()=>{
|
|
74
78
|
pending.delete(idx);
|
|
@@ -107,7 +111,11 @@ function createBatchStreamProducer(opts) {
|
|
|
107
111
|
});
|
|
108
112
|
controller.enqueue([
|
|
109
113
|
idx,
|
|
110
|
-
ASYNC_ITERABLE_STATUS_ERROR
|
|
114
|
+
ASYNC_ITERABLE_STATUS_ERROR,
|
|
115
|
+
opts.formatError?.({
|
|
116
|
+
error,
|
|
117
|
+
path
|
|
118
|
+
})
|
|
111
119
|
]);
|
|
112
120
|
} finally{
|
|
113
121
|
pending.delete(idx);
|
|
@@ -353,7 +361,9 @@ function createDeferred() {
|
|
|
353
361
|
resolve(dehydrate(data));
|
|
354
362
|
break;
|
|
355
363
|
case PROMISE_STATUS_REJECTED:
|
|
356
|
-
reject(
|
|
364
|
+
reject(opts.formatError?.({
|
|
365
|
+
error: data
|
|
366
|
+
}) ?? new AsyncError(data));
|
|
357
367
|
break;
|
|
358
368
|
}
|
|
359
369
|
}).catch(reject).finally(()=>{
|
|
@@ -385,7 +395,9 @@ function createDeferred() {
|
|
|
385
395
|
return;
|
|
386
396
|
case ASYNC_ITERABLE_STATUS_ERROR:
|
|
387
397
|
controllers.delete(chunkId);
|
|
388
|
-
throw
|
|
398
|
+
throw opts.formatError?.({
|
|
399
|
+
error: data
|
|
400
|
+
}) ?? new AsyncError(data);
|
|
389
401
|
}
|
|
390
402
|
}
|
|
391
403
|
}
|
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.390+d846f1796",
|
|
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": "d846f1796c969778b647dcba43b2bcff1b3a4830"
|
|
153
153
|
}
|
|
@@ -160,6 +160,7 @@ export async function resolveResponse<TRouter extends AnyRouter>(
|
|
|
160
160
|
): Promise<Response> {
|
|
161
161
|
const { router, req } = opts;
|
|
162
162
|
const headers = new Headers([['vary', 'trpc-accept']]);
|
|
163
|
+
const config = router._def._config;
|
|
163
164
|
|
|
164
165
|
const url = new URL(req.url);
|
|
165
166
|
|
|
@@ -181,13 +182,13 @@ export async function resolveResponse<TRouter extends AnyRouter>(
|
|
|
181
182
|
const isStreamCall = req.headers.get('trpc-accept') === 'application/jsonl';
|
|
182
183
|
|
|
183
184
|
const experimentalIterablesAndDeferreds =
|
|
184
|
-
|
|
185
|
+
config.experimental?.iterablesAndDeferreds ?? false;
|
|
185
186
|
|
|
186
187
|
try {
|
|
187
188
|
info = getRequestInfo({
|
|
188
189
|
req,
|
|
189
190
|
path: decodeURIComponent(opts.path),
|
|
190
|
-
config:
|
|
191
|
+
config: config,
|
|
191
192
|
searchParams: url.searchParams,
|
|
192
193
|
});
|
|
193
194
|
|
|
@@ -268,7 +269,7 @@ export async function resolveResponse<TRouter extends AnyRouter>(
|
|
|
268
269
|
|
|
269
270
|
return {
|
|
270
271
|
error: getErrorShape({
|
|
271
|
-
config
|
|
272
|
+
config,
|
|
272
273
|
error,
|
|
273
274
|
type,
|
|
274
275
|
path: call.path,
|
|
@@ -351,6 +352,18 @@ export async function resolveResponse<TRouter extends AnyRouter>(
|
|
|
351
352
|
* }
|
|
352
353
|
*/
|
|
353
354
|
maxDepth: experimentalIterablesAndDeferreds ? 4 : 3,
|
|
355
|
+
formatError(errorOpts) {
|
|
356
|
+
const call = info?.calls[errorOpts.path[0] as any];
|
|
357
|
+
|
|
358
|
+
return getErrorShape({
|
|
359
|
+
config,
|
|
360
|
+
ctx,
|
|
361
|
+
error: getTRPCErrorFromUnknown(errorOpts.error),
|
|
362
|
+
input: call?.result(),
|
|
363
|
+
path: call?.path,
|
|
364
|
+
type,
|
|
365
|
+
});
|
|
366
|
+
},
|
|
354
367
|
data: promises.map(async (it) => {
|
|
355
368
|
const response = await it;
|
|
356
369
|
if ('result' in response) {
|
|
@@ -368,7 +381,7 @@ export async function resolveResponse<TRouter extends AnyRouter>(
|
|
|
368
381
|
}
|
|
369
382
|
return response;
|
|
370
383
|
}),
|
|
371
|
-
serialize:
|
|
384
|
+
serialize: config.transformer.output.serialize,
|
|
372
385
|
onError: (cause) => {
|
|
373
386
|
opts.onError?.({
|
|
374
387
|
error: getTRPCErrorFromUnknown(cause),
|
|
@@ -79,12 +79,7 @@ type PromiseChunk =
|
|
|
79
79
|
status: PROMISE_STATUS_FULFILLED,
|
|
80
80
|
value: HydratedValue,
|
|
81
81
|
]
|
|
82
|
-
| [
|
|
83
|
-
chunkIndex: ChunkIndex,
|
|
84
|
-
status: PROMISE_STATUS_REJECTED,
|
|
85
|
-
// do we want to serialize errors?
|
|
86
|
-
// , error?: unknown
|
|
87
|
-
];
|
|
82
|
+
| [chunkIndex: ChunkIndex, status: PROMISE_STATUS_REJECTED, error: unknown];
|
|
88
83
|
type IterableChunk =
|
|
89
84
|
| [chunkIndex: ChunkIndex, status: ASYNC_ITERABLE_STATUS_DONE]
|
|
90
85
|
| [
|
|
@@ -95,8 +90,7 @@ type IterableChunk =
|
|
|
95
90
|
| [
|
|
96
91
|
chunkIndex: ChunkIndex,
|
|
97
92
|
status: ASYNC_ITERABLE_STATUS_ERROR,
|
|
98
|
-
|
|
99
|
-
// , error?: unknown
|
|
93
|
+
error: unknown,
|
|
100
94
|
];
|
|
101
95
|
type ChunkData = PromiseChunk | IterableChunk;
|
|
102
96
|
type PlaceholderValue = 0 & { __placeholder: true };
|
|
@@ -119,6 +113,10 @@ export interface ProducerOptions {
|
|
|
119
113
|
serialize?: Serialize;
|
|
120
114
|
data: Record<number, unknown>;
|
|
121
115
|
onError?: ProducerOnError;
|
|
116
|
+
formatError?: (opts: {
|
|
117
|
+
error: unknown;
|
|
118
|
+
path: (string | number)[];
|
|
119
|
+
}) => unknown;
|
|
122
120
|
maxDepth?: number;
|
|
123
121
|
}
|
|
124
122
|
|
|
@@ -161,9 +159,13 @@ function createBatchStreamProducer(opts: ProducerOptions) {
|
|
|
161
159
|
.then((it) => {
|
|
162
160
|
enqueue([idx, PROMISE_STATUS_FULFILLED, hydrate(it, path)]);
|
|
163
161
|
})
|
|
164
|
-
.catch((
|
|
165
|
-
opts.onError?.({ error
|
|
166
|
-
enqueue([
|
|
162
|
+
.catch((error) => {
|
|
163
|
+
opts.onError?.({ error, path });
|
|
164
|
+
enqueue([
|
|
165
|
+
idx,
|
|
166
|
+
PROMISE_STATUS_REJECTED,
|
|
167
|
+
opts.formatError?.({ error, path }),
|
|
168
|
+
]);
|
|
167
169
|
})
|
|
168
170
|
.finally(() => {
|
|
169
171
|
pending.delete(idx);
|
|
@@ -197,7 +199,11 @@ function createBatchStreamProducer(opts: ProducerOptions) {
|
|
|
197
199
|
controller.enqueue([idx, ASYNC_ITERABLE_STATUS_DONE]);
|
|
198
200
|
} catch (error) {
|
|
199
201
|
opts.onError?.({ error, path });
|
|
200
|
-
controller.enqueue([
|
|
202
|
+
controller.enqueue([
|
|
203
|
+
idx,
|
|
204
|
+
ASYNC_ITERABLE_STATUS_ERROR,
|
|
205
|
+
opts.formatError?.({ error, path }),
|
|
206
|
+
]);
|
|
201
207
|
} finally {
|
|
202
208
|
pending.delete(idx);
|
|
203
209
|
maybeClose();
|
|
@@ -403,6 +409,7 @@ export async function jsonlStreamConsumer<THead>(opts: {
|
|
|
403
409
|
from: NodeJSReadableStreamEsque | WebReadableStreamEsque;
|
|
404
410
|
deserialize?: Deserialize;
|
|
405
411
|
onError?: ConsumerOnError;
|
|
412
|
+
formatError?: (opts: { error: unknown }) => Error;
|
|
406
413
|
}) {
|
|
407
414
|
const { deserialize = (v) => v } = opts;
|
|
408
415
|
|
|
@@ -459,7 +466,9 @@ export async function jsonlStreamConsumer<THead>(opts: {
|
|
|
459
466
|
resolve(dehydrate(data));
|
|
460
467
|
break;
|
|
461
468
|
case PROMISE_STATUS_REJECTED:
|
|
462
|
-
reject(
|
|
469
|
+
reject(
|
|
470
|
+
opts.formatError?.({ error: data }) ?? new AsyncError(data),
|
|
471
|
+
);
|
|
463
472
|
break;
|
|
464
473
|
}
|
|
465
474
|
})
|
|
@@ -494,7 +503,9 @@ export async function jsonlStreamConsumer<THead>(opts: {
|
|
|
494
503
|
return;
|
|
495
504
|
case ASYNC_ITERABLE_STATUS_ERROR:
|
|
496
505
|
controllers.delete(chunkId);
|
|
497
|
-
throw
|
|
506
|
+
throw (
|
|
507
|
+
opts.formatError?.({ error: data }) ?? new AsyncError(data)
|
|
508
|
+
);
|
|
498
509
|
}
|
|
499
510
|
}
|
|
500
511
|
},
|
|
@@ -541,7 +552,7 @@ export async function jsonlStreamConsumer<THead>(opts: {
|
|
|
541
552
|
const head = chunkOrHead as Record<number | string, unknown>;
|
|
542
553
|
|
|
543
554
|
for (const [key, value] of Object.entries(chunkOrHead)) {
|
|
544
|
-
const parsed = dehydrate(value);
|
|
555
|
+
const parsed = dehydrate(value as any);
|
|
545
556
|
head[key] = parsed;
|
|
546
557
|
}
|
|
547
558
|
headDeferred.resolve(head as THead);
|