@trpc/server 11.0.0-rc.475 → 11.0.0-rc.477
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 +101 -101
- package/dist/unstable-core-do-not-import/http/resolveResponse.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/http/resolveResponse.js +13 -2
- package/dist/unstable-core-do-not-import/http/resolveResponse.mjs +13 -2
- package/dist/unstable-core-do-not-import/rootConfig.d.ts +1 -1
- package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/stream/sse.d.ts +11 -1
- package/dist/unstable-core-do-not-import/stream/sse.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/stream/sse.js +25 -3
- package/dist/unstable-core-do-not-import/stream/sse.mjs +25 -3
- package/package.json +2 -2
- package/src/unstable-core-do-not-import/http/resolveResponse.ts +13 -1
- package/src/unstable-core-do-not-import/rootConfig.ts +4 -1
- package/src/unstable-core-do-not-import/stream/sse.ts +42 -7
|
@@ -1,8 +1,22 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction": 26.
|
|
2
|
+
"bundleSize": 134783,
|
|
3
|
+
"bundleOrigSize": 183711,
|
|
4
|
+
"bundleReduction": 26.63,
|
|
5
5
|
"modules": [
|
|
6
|
+
{
|
|
7
|
+
"id": "/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
8
|
+
"size": 17762,
|
|
9
|
+
"origSize": 16670,
|
|
10
|
+
"renderedExports": [
|
|
11
|
+
"resolveResponse"
|
|
12
|
+
],
|
|
13
|
+
"removedExports": [],
|
|
14
|
+
"dependents": [
|
|
15
|
+
"/src/unstable-core-do-not-import.ts"
|
|
16
|
+
],
|
|
17
|
+
"percent": 13.18,
|
|
18
|
+
"reduction": 0
|
|
19
|
+
},
|
|
6
20
|
{
|
|
7
21
|
"id": "/src/unstable-core-do-not-import/stream/jsonl.ts",
|
|
8
22
|
"size": 17400,
|
|
@@ -17,23 +31,9 @@
|
|
|
17
31
|
"/src/unstable-core-do-not-import.ts",
|
|
18
32
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
19
33
|
],
|
|
20
|
-
"percent":
|
|
34
|
+
"percent": 12.91,
|
|
21
35
|
"reduction": 4.62
|
|
22
36
|
},
|
|
23
|
-
{
|
|
24
|
-
"id": "/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
25
|
-
"size": 17157,
|
|
26
|
-
"origSize": 16294,
|
|
27
|
-
"renderedExports": [
|
|
28
|
-
"resolveResponse"
|
|
29
|
-
],
|
|
30
|
-
"removedExports": [],
|
|
31
|
-
"dependents": [
|
|
32
|
-
"/src/unstable-core-do-not-import.ts"
|
|
33
|
-
],
|
|
34
|
-
"percent": 12.86,
|
|
35
|
-
"reduction": 0
|
|
36
|
-
},
|
|
37
37
|
{
|
|
38
38
|
"id": "/src/adapters/ws.ts",
|
|
39
39
|
"size": 15730,
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"dependents": [
|
|
47
47
|
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
48
48
|
],
|
|
49
|
-
"percent": 11.
|
|
49
|
+
"percent": 11.67,
|
|
50
50
|
"reduction": 0
|
|
51
51
|
},
|
|
52
52
|
{
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"/src/unstable-core-do-not-import.ts",
|
|
62
62
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
63
63
|
],
|
|
64
|
-
"percent": 5.
|
|
64
|
+
"percent": 5.7,
|
|
65
65
|
"reduction": 0
|
|
66
66
|
},
|
|
67
67
|
{
|
|
@@ -79,7 +79,7 @@
|
|
|
79
79
|
"/src/unstable-core-do-not-import.ts",
|
|
80
80
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
81
81
|
],
|
|
82
|
-
"percent": 4.
|
|
82
|
+
"percent": 4.73,
|
|
83
83
|
"reduction": 39.77
|
|
84
84
|
},
|
|
85
85
|
{
|
|
@@ -94,39 +94,39 @@
|
|
|
94
94
|
"/src/unstable-core-do-not-import.ts",
|
|
95
95
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
96
96
|
],
|
|
97
|
-
"percent": 4.
|
|
97
|
+
"percent": 4.69,
|
|
98
98
|
"reduction": 60.09
|
|
99
99
|
},
|
|
100
100
|
{
|
|
101
|
-
"id": "/src/
|
|
102
|
-
"size":
|
|
103
|
-
"origSize":
|
|
101
|
+
"id": "/src/unstable-core-do-not-import/stream/sse.ts",
|
|
102
|
+
"size": 5910,
|
|
103
|
+
"origSize": 6971,
|
|
104
104
|
"renderedExports": [
|
|
105
|
-
"
|
|
105
|
+
"sseStreamProducer",
|
|
106
|
+
"sseStreamConsumer",
|
|
107
|
+
"sseHeaders"
|
|
106
108
|
],
|
|
107
109
|
"removedExports": [],
|
|
108
110
|
"dependents": [
|
|
109
|
-
"/src/
|
|
111
|
+
"/src/unstable-core-do-not-import.ts",
|
|
112
|
+
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
110
113
|
],
|
|
111
|
-
"percent": 4.
|
|
112
|
-
"reduction":
|
|
114
|
+
"percent": 4.38,
|
|
115
|
+
"reduction": 15.22
|
|
113
116
|
},
|
|
114
117
|
{
|
|
115
|
-
"id": "/src/
|
|
116
|
-
"size":
|
|
117
|
-
"origSize":
|
|
118
|
+
"id": "/src/adapters/aws-lambda/getPlanner.ts",
|
|
119
|
+
"size": 5418,
|
|
120
|
+
"origSize": 6114,
|
|
118
121
|
"renderedExports": [
|
|
119
|
-
"
|
|
120
|
-
"sseStreamConsumer",
|
|
121
|
-
"sseHeaders"
|
|
122
|
+
"getPlanner"
|
|
122
123
|
],
|
|
123
124
|
"removedExports": [],
|
|
124
125
|
"dependents": [
|
|
125
|
-
"/src/
|
|
126
|
-
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
126
|
+
"/src/adapters/aws-lambda/index.ts"
|
|
127
127
|
],
|
|
128
|
-
"percent":
|
|
129
|
-
"reduction":
|
|
128
|
+
"percent": 4.02,
|
|
129
|
+
"reduction": 11.38
|
|
130
130
|
},
|
|
131
131
|
{
|
|
132
132
|
"id": "/src/observable/observable.ts",
|
|
@@ -145,7 +145,7 @@
|
|
|
145
145
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
146
146
|
"/src/observable/operators.ts"
|
|
147
147
|
],
|
|
148
|
-
"percent": 3.
|
|
148
|
+
"percent": 3.05,
|
|
149
149
|
"reduction": 0
|
|
150
150
|
},
|
|
151
151
|
{
|
|
@@ -159,7 +159,7 @@
|
|
|
159
159
|
"dependents": [
|
|
160
160
|
"/src/adapters/next-app-dir.ts"
|
|
161
161
|
],
|
|
162
|
-
"percent": 2.
|
|
162
|
+
"percent": 2.33,
|
|
163
163
|
"reduction": 23.5
|
|
164
164
|
},
|
|
165
165
|
{
|
|
@@ -175,7 +175,7 @@
|
|
|
175
175
|
"dependents": [
|
|
176
176
|
"/src/observable/index.ts"
|
|
177
177
|
],
|
|
178
|
-
"percent": 2.
|
|
178
|
+
"percent": 2.04,
|
|
179
179
|
"reduction": 0
|
|
180
180
|
},
|
|
181
181
|
{
|
|
@@ -191,11 +191,11 @@
|
|
|
191
191
|
"removedExports": [],
|
|
192
192
|
"dependents": [
|
|
193
193
|
"/src/unstable-core-do-not-import.ts",
|
|
194
|
-
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
195
194
|
"/src/unstable-core-do-not-import/initTRPC.ts",
|
|
196
|
-
"/src/unstable-core-do-not-import/router.ts"
|
|
195
|
+
"/src/unstable-core-do-not-import/router.ts",
|
|
196
|
+
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
197
197
|
],
|
|
198
|
-
"percent": 2.
|
|
198
|
+
"percent": 2.04,
|
|
199
199
|
"reduction": 45.94
|
|
200
200
|
},
|
|
201
201
|
{
|
|
@@ -209,7 +209,7 @@
|
|
|
209
209
|
"dependents": [
|
|
210
210
|
"/src/adapters/node-http/index.ts"
|
|
211
211
|
],
|
|
212
|
-
"percent": 2.
|
|
212
|
+
"percent": 2.03,
|
|
213
213
|
"reduction": 6.79
|
|
214
214
|
},
|
|
215
215
|
{
|
|
@@ -223,7 +223,7 @@
|
|
|
223
223
|
"dependents": [
|
|
224
224
|
"/src/unstable-core-do-not-import.ts"
|
|
225
225
|
],
|
|
226
|
-
"percent": 2.
|
|
226
|
+
"percent": 2.01,
|
|
227
227
|
"reduction": 40.91
|
|
228
228
|
},
|
|
229
229
|
{
|
|
@@ -243,7 +243,7 @@
|
|
|
243
243
|
"/src/unstable-core-do-not-import/initTRPC.ts",
|
|
244
244
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
245
245
|
],
|
|
246
|
-
"percent": 1.
|
|
246
|
+
"percent": 1.95,
|
|
247
247
|
"reduction": 55.5
|
|
248
248
|
},
|
|
249
249
|
{
|
|
@@ -259,7 +259,7 @@
|
|
|
259
259
|
"/src/unstable-core-do-not-import.ts",
|
|
260
260
|
"/src/unstable-core-do-not-import/router.ts"
|
|
261
261
|
],
|
|
262
|
-
"percent": 1.
|
|
262
|
+
"percent": 1.73,
|
|
263
263
|
"reduction": 0
|
|
264
264
|
},
|
|
265
265
|
{
|
|
@@ -273,7 +273,7 @@
|
|
|
273
273
|
"dependents": [
|
|
274
274
|
"/src/adapters/fetch/index.ts"
|
|
275
275
|
],
|
|
276
|
-
"percent": 1.
|
|
276
|
+
"percent": 1.67,
|
|
277
277
|
"reduction": 2.17
|
|
278
278
|
},
|
|
279
279
|
{
|
|
@@ -288,7 +288,7 @@
|
|
|
288
288
|
"/src/adapters/node-http/index.ts",
|
|
289
289
|
"/src/adapters/node-http/nodeHTTPRequestHandler.ts"
|
|
290
290
|
],
|
|
291
|
-
"percent": 1.
|
|
291
|
+
"percent": 1.63,
|
|
292
292
|
"reduction": 13.79
|
|
293
293
|
},
|
|
294
294
|
{
|
|
@@ -302,7 +302,7 @@
|
|
|
302
302
|
"dependents": [
|
|
303
303
|
"/src/adapters/next-app-dir/nextAppDirCaller.ts"
|
|
304
304
|
],
|
|
305
|
-
"percent": 1.
|
|
305
|
+
"percent": 1.52,
|
|
306
306
|
"reduction": 5.79
|
|
307
307
|
},
|
|
308
308
|
{
|
|
@@ -317,16 +317,16 @@
|
|
|
317
317
|
"removedExports": [],
|
|
318
318
|
"dependents": [
|
|
319
319
|
"/src/unstable-core-do-not-import.ts",
|
|
320
|
-
"/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
|
|
321
|
-
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
322
320
|
"/src/unstable-core-do-not-import/middleware.ts",
|
|
323
321
|
"/src/unstable-core-do-not-import/router.ts",
|
|
322
|
+
"/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
|
|
323
|
+
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
324
324
|
"/src/unstable-core-do-not-import/http/contentType.ts",
|
|
325
325
|
"/src/unstable-core-do-not-import/procedureBuilder.ts",
|
|
326
326
|
"/src/unstable-core-do-not-import/stream/jsonl.ts",
|
|
327
327
|
"/src/unstable-core-do-not-import/stream/sse.ts"
|
|
328
328
|
],
|
|
329
|
-
"percent": 1.
|
|
329
|
+
"percent": 1.29,
|
|
330
330
|
"reduction": 19.47
|
|
331
331
|
},
|
|
332
332
|
{
|
|
@@ -338,7 +338,7 @@
|
|
|
338
338
|
],
|
|
339
339
|
"removedExports": [],
|
|
340
340
|
"dependents": [],
|
|
341
|
-
"percent": 1.
|
|
341
|
+
"percent": 1.26,
|
|
342
342
|
"reduction": 19.29
|
|
343
343
|
},
|
|
344
344
|
{
|
|
@@ -351,7 +351,7 @@
|
|
|
351
351
|
],
|
|
352
352
|
"removedExports": [],
|
|
353
353
|
"dependents": [],
|
|
354
|
-
"percent": 1.
|
|
354
|
+
"percent": 1.2,
|
|
355
355
|
"reduction": 27.47
|
|
356
356
|
},
|
|
357
357
|
{
|
|
@@ -363,7 +363,7 @@
|
|
|
363
363
|
],
|
|
364
364
|
"removedExports": [],
|
|
365
365
|
"dependents": [],
|
|
366
|
-
"percent": 1.
|
|
366
|
+
"percent": 1.14,
|
|
367
367
|
"reduction": 26.94
|
|
368
368
|
},
|
|
369
369
|
{
|
|
@@ -377,7 +377,7 @@
|
|
|
377
377
|
"dependents": [
|
|
378
378
|
"/src/adapters/fastify/index.ts"
|
|
379
379
|
],
|
|
380
|
-
"percent": 1.
|
|
380
|
+
"percent": 1.11,
|
|
381
381
|
"reduction": 34.7
|
|
382
382
|
},
|
|
383
383
|
{
|
|
@@ -391,10 +391,10 @@
|
|
|
391
391
|
"removedExports": [],
|
|
392
392
|
"dependents": [
|
|
393
393
|
"/src/unstable-core-do-not-import.ts",
|
|
394
|
-
"/src/unstable-core-do-not-import/
|
|
395
|
-
"/src/unstable-core-do-not-import/
|
|
394
|
+
"/src/unstable-core-do-not-import/error/getErrorShape.ts",
|
|
395
|
+
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
396
396
|
],
|
|
397
|
-
"percent": 1.
|
|
397
|
+
"percent": 1.01,
|
|
398
398
|
"reduction": 17.52
|
|
399
399
|
},
|
|
400
400
|
{
|
|
@@ -413,20 +413,20 @@
|
|
|
413
413
|
"removedExports": [],
|
|
414
414
|
"dependents": [
|
|
415
415
|
"/src/unstable-core-do-not-import.ts",
|
|
416
|
-
"/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts",
|
|
417
|
-
"/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
|
|
418
|
-
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
419
416
|
"/src/unstable-core-do-not-import/error/TRPCError.ts",
|
|
420
417
|
"/src/unstable-core-do-not-import/transformer.ts",
|
|
421
418
|
"/src/unstable-core-do-not-import/middleware.ts",
|
|
422
419
|
"/src/unstable-core-do-not-import/router.ts",
|
|
420
|
+
"/src/unstable-core-do-not-import/http/getHTTPStatusCode.ts",
|
|
421
|
+
"/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
|
|
422
|
+
"/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
423
423
|
"/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
|
|
424
424
|
"/src/unstable-core-do-not-import/http/contentType.ts",
|
|
425
425
|
"/src/unstable-core-do-not-import/procedureBuilder.ts",
|
|
426
426
|
"/src/unstable-core-do-not-import/stream/jsonl.ts",
|
|
427
427
|
"/src/unstable-core-do-not-import/stream/sse.ts"
|
|
428
428
|
],
|
|
429
|
-
"percent": 0.
|
|
429
|
+
"percent": 0.89,
|
|
430
430
|
"reduction": 28.12
|
|
431
431
|
},
|
|
432
432
|
{
|
|
@@ -441,7 +441,7 @@
|
|
|
441
441
|
"/src/adapters/fastify/index.ts",
|
|
442
442
|
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
443
443
|
],
|
|
444
|
-
"percent": 0.
|
|
444
|
+
"percent": 0.84,
|
|
445
445
|
"reduction": 47.59
|
|
446
446
|
},
|
|
447
447
|
{
|
|
@@ -457,7 +457,7 @@
|
|
|
457
457
|
"/src/unstable-core-do-not-import.ts",
|
|
458
458
|
"/src/unstable-core-do-not-import/http/contentType.ts"
|
|
459
459
|
],
|
|
460
|
-
"percent": 0.
|
|
460
|
+
"percent": 0.82,
|
|
461
461
|
"reduction": 15.08
|
|
462
462
|
},
|
|
463
463
|
{
|
|
@@ -486,7 +486,7 @@
|
|
|
486
486
|
"/src/unstable-core-do-not-import.ts",
|
|
487
487
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
488
488
|
],
|
|
489
|
-
"percent": 0.
|
|
489
|
+
"percent": 0.77,
|
|
490
490
|
"reduction": 58.57
|
|
491
491
|
},
|
|
492
492
|
{
|
|
@@ -503,7 +503,7 @@
|
|
|
503
503
|
"/src/adapters/next-app-dir/nextAppDirCaller.ts",
|
|
504
504
|
"/src/adapters/next-app-dir/rethrowNextErrors.ts"
|
|
505
505
|
],
|
|
506
|
-
"percent": 0.
|
|
506
|
+
"percent": 0.73,
|
|
507
507
|
"reduction": 13.65
|
|
508
508
|
},
|
|
509
509
|
{
|
|
@@ -521,7 +521,7 @@
|
|
|
521
521
|
"/src/unstable-core-do-not-import/stream/sse.ts",
|
|
522
522
|
"/src/unstable-core-do-not-import/stream/utils/createReadableStream.ts"
|
|
523
523
|
],
|
|
524
|
-
"percent": 0.
|
|
524
|
+
"percent": 0.73,
|
|
525
525
|
"reduction": 15.69
|
|
526
526
|
},
|
|
527
527
|
{
|
|
@@ -538,7 +538,7 @@
|
|
|
538
538
|
"/src/unstable-core-do-not-import.ts",
|
|
539
539
|
"/src/unstable-core-do-not-import/stream/sse.ts"
|
|
540
540
|
],
|
|
541
|
-
"percent": 0.
|
|
541
|
+
"percent": 0.59,
|
|
542
542
|
"reduction": 44.65
|
|
543
543
|
},
|
|
544
544
|
{
|
|
@@ -550,7 +550,7 @@
|
|
|
550
550
|
],
|
|
551
551
|
"removedExports": [],
|
|
552
552
|
"dependents": [],
|
|
553
|
-
"percent": 0.
|
|
553
|
+
"percent": 0.56,
|
|
554
554
|
"reduction": 66.9
|
|
555
555
|
},
|
|
556
556
|
{
|
|
@@ -564,7 +564,7 @@
|
|
|
564
564
|
"dependents": [
|
|
565
565
|
"/src/unstable-core-do-not-import.ts"
|
|
566
566
|
],
|
|
567
|
-
"percent": 0.
|
|
567
|
+
"percent": 0.49,
|
|
568
568
|
"reduction": 0.6
|
|
569
569
|
},
|
|
570
570
|
{
|
|
@@ -579,7 +579,7 @@
|
|
|
579
579
|
"/src/unstable-core-do-not-import.ts",
|
|
580
580
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
581
581
|
],
|
|
582
|
-
"percent": 0.
|
|
582
|
+
"percent": 0.46,
|
|
583
583
|
"reduction": 43.49
|
|
584
584
|
},
|
|
585
585
|
{
|
|
@@ -613,7 +613,7 @@
|
|
|
613
613
|
{
|
|
614
614
|
"id": "/src/unstable-core-do-not-import/rootConfig.ts",
|
|
615
615
|
"size": 343,
|
|
616
|
-
"origSize":
|
|
616
|
+
"origSize": 3270,
|
|
617
617
|
"renderedExports": [
|
|
618
618
|
"isServerDefault"
|
|
619
619
|
],
|
|
@@ -622,8 +622,8 @@
|
|
|
622
622
|
"/src/unstable-core-do-not-import.ts",
|
|
623
623
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
624
624
|
],
|
|
625
|
-
"percent": 0.
|
|
626
|
-
"reduction": 89.
|
|
625
|
+
"percent": 0.25,
|
|
626
|
+
"reduction": 89.51
|
|
627
627
|
},
|
|
628
628
|
{
|
|
629
629
|
"id": "/src/adapters/express.ts",
|
|
@@ -662,7 +662,7 @@
|
|
|
662
662
|
"dependents": [
|
|
663
663
|
"/src/unstable-core-do-not-import.ts"
|
|
664
664
|
],
|
|
665
|
-
"percent": 0.
|
|
665
|
+
"percent": 0.16,
|
|
666
666
|
"reduction": 94.55
|
|
667
667
|
},
|
|
668
668
|
{
|
|
@@ -725,31 +725,31 @@
|
|
|
725
725
|
"reduction": 93.8
|
|
726
726
|
},
|
|
727
727
|
{
|
|
728
|
-
"id": "/src/
|
|
728
|
+
"id": "/src/index.ts",
|
|
729
729
|
"size": 0,
|
|
730
|
-
"origSize":
|
|
730
|
+
"origSize": 32,
|
|
731
731
|
"renderedExports": [],
|
|
732
732
|
"removedExports": [],
|
|
733
|
-
"dependents": [
|
|
734
|
-
"/src/adapters/ws.ts"
|
|
735
|
-
],
|
|
733
|
+
"dependents": [],
|
|
736
734
|
"percent": 0,
|
|
737
735
|
"reduction": 100
|
|
738
736
|
},
|
|
739
737
|
{
|
|
740
|
-
"id": "/src/
|
|
738
|
+
"id": "/src/http.ts",
|
|
741
739
|
"size": 0,
|
|
742
|
-
"origSize":
|
|
740
|
+
"origSize": 37,
|
|
743
741
|
"renderedExports": [],
|
|
744
742
|
"removedExports": [],
|
|
745
|
-
"dependents": [
|
|
743
|
+
"dependents": [
|
|
744
|
+
"/src/adapters/ws.ts"
|
|
745
|
+
],
|
|
746
746
|
"percent": 0,
|
|
747
747
|
"reduction": 100
|
|
748
748
|
},
|
|
749
749
|
{
|
|
750
|
-
"id": "/src/
|
|
750
|
+
"id": "/src/rpc.ts",
|
|
751
751
|
"size": 0,
|
|
752
|
-
"origSize":
|
|
752
|
+
"origSize": 36,
|
|
753
753
|
"renderedExports": [],
|
|
754
754
|
"removedExports": [],
|
|
755
755
|
"dependents": [],
|
|
@@ -757,9 +757,9 @@
|
|
|
757
757
|
"reduction": 100
|
|
758
758
|
},
|
|
759
759
|
{
|
|
760
|
-
"id": "/src/
|
|
760
|
+
"id": "/src/shared.ts",
|
|
761
761
|
"size": 0,
|
|
762
|
-
"origSize":
|
|
762
|
+
"origSize": 653,
|
|
763
763
|
"renderedExports": [],
|
|
764
764
|
"removedExports": [],
|
|
765
765
|
"dependents": [],
|
|
@@ -811,6 +811,16 @@
|
|
|
811
811
|
"percent": 0,
|
|
812
812
|
"reduction": 100
|
|
813
813
|
},
|
|
814
|
+
{
|
|
815
|
+
"id": "/src/adapters/fetch/index.ts",
|
|
816
|
+
"size": 0,
|
|
817
|
+
"origSize": 64,
|
|
818
|
+
"renderedExports": [],
|
|
819
|
+
"removedExports": [],
|
|
820
|
+
"dependents": [],
|
|
821
|
+
"percent": 0,
|
|
822
|
+
"reduction": 100
|
|
823
|
+
},
|
|
814
824
|
{
|
|
815
825
|
"id": "/src/adapters/node-http/index.ts",
|
|
816
826
|
"size": 0,
|
|
@@ -825,16 +835,6 @@
|
|
|
825
835
|
],
|
|
826
836
|
"percent": 0,
|
|
827
837
|
"reduction": 100
|
|
828
|
-
},
|
|
829
|
-
{
|
|
830
|
-
"id": "/src/adapters/fetch/index.ts",
|
|
831
|
-
"size": 0,
|
|
832
|
-
"origSize": 64,
|
|
833
|
-
"renderedExports": [],
|
|
834
|
-
"removedExports": [],
|
|
835
|
-
"dependents": [],
|
|
836
|
-
"percent": 0,
|
|
837
|
-
"reduction": 100
|
|
838
838
|
}
|
|
839
839
|
],
|
|
840
840
|
"moduleCount": 56
|
|
@@ -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,CA6ZnB"}
|
|
@@ -284,9 +284,20 @@ async function resolveResponse(opts) {
|
|
|
284
284
|
}
|
|
285
285
|
const dataAsIterable = observable.isObservable(data) ? observable.observableToAsyncIterable(data) : data;
|
|
286
286
|
const stream = sse.sseStreamProducer({
|
|
287
|
-
...
|
|
287
|
+
...config.experimental?.sseSubscriptions,
|
|
288
288
|
data: dataAsIterable,
|
|
289
|
-
serialize: (v)=>config.transformer.output.serialize(v)
|
|
289
|
+
serialize: (v)=>config.transformer.output.serialize(v),
|
|
290
|
+
formatError (errorOpts) {
|
|
291
|
+
const shape = getErrorShape.getErrorShape({
|
|
292
|
+
config,
|
|
293
|
+
ctx,
|
|
294
|
+
error: TRPCError.getTRPCErrorFromUnknown(errorOpts.error),
|
|
295
|
+
input: call?.result(),
|
|
296
|
+
path: call?.path,
|
|
297
|
+
type: call?.procedure?._def.type ?? 'unknown'
|
|
298
|
+
});
|
|
299
|
+
return shape;
|
|
300
|
+
}
|
|
290
301
|
});
|
|
291
302
|
for (const [key, value] of Object.entries(sse.sseHeaders)){
|
|
292
303
|
headers.set(key, value);
|
|
@@ -282,9 +282,20 @@ async function resolveResponse(opts) {
|
|
|
282
282
|
}
|
|
283
283
|
const dataAsIterable = isObservable(data) ? observableToAsyncIterable(data) : data;
|
|
284
284
|
const stream = sseStreamProducer({
|
|
285
|
-
...
|
|
285
|
+
...config.experimental?.sseSubscriptions,
|
|
286
286
|
data: dataAsIterable,
|
|
287
|
-
serialize: (v)=>config.transformer.output.serialize(v)
|
|
287
|
+
serialize: (v)=>config.transformer.output.serialize(v),
|
|
288
|
+
formatError (errorOpts) {
|
|
289
|
+
const shape = getErrorShape({
|
|
290
|
+
config,
|
|
291
|
+
ctx,
|
|
292
|
+
error: getTRPCErrorFromUnknown(errorOpts.error),
|
|
293
|
+
input: call?.result(),
|
|
294
|
+
path: call?.path,
|
|
295
|
+
type: call?.procedure?._def.type ?? 'unknown'
|
|
296
|
+
});
|
|
297
|
+
return shape;
|
|
298
|
+
}
|
|
288
299
|
});
|
|
289
300
|
for (const [key, value] of Object.entries(sseHeaders)){
|
|
290
301
|
headers.set(key, value);
|
|
@@ -69,7 +69,7 @@ export interface RootConfig<TTypes extends RootTypes> {
|
|
|
69
69
|
* @default true
|
|
70
70
|
*/
|
|
71
71
|
enabled?: boolean;
|
|
72
|
-
} &
|
|
72
|
+
} & Pick<SSEStreamProducerOptions, 'ping' | 'emitAndEndImmediately' | 'maxDurationMs'>;
|
|
73
73
|
};
|
|
74
74
|
}
|
|
75
75
|
/**
|
|
@@ -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,gCAAgC,CAAC;AAC9E,OAAO,KAAK,EAAE,iBAAiB,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAC3E,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AAE7D;;;GAGG;AACH,MAAM,WAAW,SAAS;IACxB,GAAG,EAAE,MAAM,CAAC;IACZ,IAAI,EAAE,MAAM,CAAC;IACb,UAAU,EAAE,iBAAiB,CAAC;IAC9B,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,CAAC,MAAM,CAAC,KAAK,C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36
|
emitAndEndImmediately?: boolean;
|
|
37
|
+
formatError?: (opts: {
|
|
38
|
+
error: unknown;
|
|
39
|
+
}) => unknown;
|
|
37
40
|
}
|
|
38
41
|
/**
|
|
39
42
|
*
|
|
40
43
|
* @see https://html.spec.whatwg.org/multipage/server-sent-events.html
|
|
41
44
|
*/
|
|
42
45
|
export declare function sseStreamProducer(opts: SSEStreamProducerOptions): ReadableStream<string>;
|
|
46
|
+
type ConsumerStreamResult<TData> = {
|
|
47
|
+
ok: true;
|
|
48
|
+
data: inferTrackedOutput<TData>;
|
|
49
|
+
} | {
|
|
50
|
+
ok: false;
|
|
51
|
+
error: unknown;
|
|
52
|
+
};
|
|
43
53
|
/**
|
|
44
54
|
* @see https://html.spec.whatwg.org/multipage/server-sent-events.html
|
|
45
55
|
*/
|
|
@@ -47,7 +57,7 @@ export declare function sseStreamConsumer<TData>(opts: {
|
|
|
47
57
|
from: EventSource;
|
|
48
58
|
onError?: ConsumerOnError;
|
|
49
59
|
deserialize?: Deserialize;
|
|
50
|
-
}): AsyncIterable<
|
|
60
|
+
}): AsyncIterable<ConsumerStreamResult<TData>>;
|
|
51
61
|
export declare const sseHeaders: {
|
|
52
62
|
readonly 'Content-Type': "text/event-stream";
|
|
53
63
|
readonly 'Cache-Control': "no-cache, no-transform";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sse.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/stream/sse.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAC/C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAKpD,KAAK,SAAS,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC;AACrC,KAAK,WAAW,GAAG,CAAC,KAAK,EAAE,GAAG,KAAK,GAAG,CAAC;AAEvC;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B;;;OAGG;IACH,OAAO,EA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;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,wBAAwB,0BAoH/D;AAED,KAAK,oBAAoB,CAAC,KAAK,IAC3B;IACE,EAAE,EAAE,IAAI,CAAC;IACT,IAAI,EAAE,kBAAkB,CAAC,KAAK,CAAC,CAAC;CACjC,GACD;IACE,EAAE,EAAE,KAAK,CAAC;IACV,KAAK,EAAE,OAAO,CAAC;CAChB,CAAC;AAEN;;GAEG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,IAAI,EAAE;IAC7C,IAAI,EAAE,WAAW,CAAC;IAClB,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,WAAW,CAAC,EAAE,WAAW,CAAC;CAC3B,GAAG,aAAa,CAAC,oBAAoB,CAAC,KAAK,CAAC,CAAC,CA6E7C;AAED,eAAO,MAAM,UAAU;;;;;CAKb,CAAC"}
|
|
@@ -6,6 +6,7 @@ var tracked = require('./tracked.js');
|
|
|
6
6
|
var createDeferred = require('./utils/createDeferred.js');
|
|
7
7
|
var createReadableStream = require('./utils/createReadableStream.js');
|
|
8
8
|
|
|
9
|
+
const SERIALIZED_ERROR_EVENT = 'serialized-error';
|
|
9
10
|
/**
|
|
10
11
|
*
|
|
11
12
|
* @see https://html.spec.whatwg.org/multipage/server-sent-events.html
|
|
@@ -46,7 +47,13 @@ var createReadableStream = require('./utils/createReadableStream.js');
|
|
|
46
47
|
continue;
|
|
47
48
|
}
|
|
48
49
|
if (next instanceof Error) {
|
|
49
|
-
|
|
50
|
+
const data = opts.formatError ? opts.formatError({
|
|
51
|
+
error: next
|
|
52
|
+
}) : null;
|
|
53
|
+
stream.controller.enqueue({
|
|
54
|
+
event: SERIALIZED_ERROR_EVENT,
|
|
55
|
+
data: JSON.stringify(serialize(data))
|
|
56
|
+
});
|
|
50
57
|
break;
|
|
51
58
|
}
|
|
52
59
|
if (next.done) {
|
|
@@ -103,18 +110,33 @@ var createReadableStream = require('./utils/createReadableStream.js');
|
|
|
103
110
|
const stream = createReadableStream.createReadableStream();
|
|
104
111
|
const transform = new TransformStream({
|
|
105
112
|
async transform (chunk, controller) {
|
|
113
|
+
const data = deserialize(JSON.parse(chunk.data));
|
|
114
|
+
if (chunk.type === SERIALIZED_ERROR_EVENT) {
|
|
115
|
+
controller.enqueue({
|
|
116
|
+
ok: false,
|
|
117
|
+
error: data
|
|
118
|
+
});
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
// console.debug('transforming', chunk.type, chunk.data);
|
|
106
122
|
const def = {
|
|
107
|
-
data
|
|
123
|
+
data
|
|
108
124
|
};
|
|
109
125
|
if (chunk.lastEventId) {
|
|
110
126
|
def.id = chunk.lastEventId;
|
|
111
127
|
}
|
|
112
|
-
controller.enqueue(
|
|
128
|
+
controller.enqueue({
|
|
129
|
+
ok: true,
|
|
130
|
+
data: def
|
|
131
|
+
});
|
|
113
132
|
}
|
|
114
133
|
});
|
|
115
134
|
eventSource.addEventListener('message', (msg)=>{
|
|
116
135
|
stream.controller.enqueue(msg);
|
|
117
136
|
});
|
|
137
|
+
eventSource.addEventListener(SERIALIZED_ERROR_EVENT, (msg)=>{
|
|
138
|
+
stream.controller.enqueue(msg);
|
|
139
|
+
});
|
|
118
140
|
eventSource.addEventListener('error', (cause)=>{
|
|
119
141
|
if (eventSource.readyState === EventSource.CLOSED) {
|
|
120
142
|
stream.controller.error(cause);
|
|
@@ -4,6 +4,7 @@ import { isTrackedEnvelope } from './tracked.mjs';
|
|
|
4
4
|
import { createTimeoutPromise } from './utils/createDeferred.mjs';
|
|
5
5
|
import { createReadableStream } from './utils/createReadableStream.mjs';
|
|
6
6
|
|
|
7
|
+
const SERIALIZED_ERROR_EVENT = 'serialized-error';
|
|
7
8
|
/**
|
|
8
9
|
*
|
|
9
10
|
* @see https://html.spec.whatwg.org/multipage/server-sent-events.html
|
|
@@ -44,7 +45,13 @@ import { createReadableStream } from './utils/createReadableStream.mjs';
|
|
|
44
45
|
continue;
|
|
45
46
|
}
|
|
46
47
|
if (next instanceof Error) {
|
|
47
|
-
|
|
48
|
+
const data = opts.formatError ? opts.formatError({
|
|
49
|
+
error: next
|
|
50
|
+
}) : null;
|
|
51
|
+
stream.controller.enqueue({
|
|
52
|
+
event: SERIALIZED_ERROR_EVENT,
|
|
53
|
+
data: JSON.stringify(serialize(data))
|
|
54
|
+
});
|
|
48
55
|
break;
|
|
49
56
|
}
|
|
50
57
|
if (next.done) {
|
|
@@ -101,18 +108,33 @@ import { createReadableStream } from './utils/createReadableStream.mjs';
|
|
|
101
108
|
const stream = createReadableStream();
|
|
102
109
|
const transform = new TransformStream({
|
|
103
110
|
async transform (chunk, controller) {
|
|
111
|
+
const data = deserialize(JSON.parse(chunk.data));
|
|
112
|
+
if (chunk.type === SERIALIZED_ERROR_EVENT) {
|
|
113
|
+
controller.enqueue({
|
|
114
|
+
ok: false,
|
|
115
|
+
error: data
|
|
116
|
+
});
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
// console.debug('transforming', chunk.type, chunk.data);
|
|
104
120
|
const def = {
|
|
105
|
-
data
|
|
121
|
+
data
|
|
106
122
|
};
|
|
107
123
|
if (chunk.lastEventId) {
|
|
108
124
|
def.id = chunk.lastEventId;
|
|
109
125
|
}
|
|
110
|
-
controller.enqueue(
|
|
126
|
+
controller.enqueue({
|
|
127
|
+
ok: true,
|
|
128
|
+
data: def
|
|
129
|
+
});
|
|
111
130
|
}
|
|
112
131
|
});
|
|
113
132
|
eventSource.addEventListener('message', (msg)=>{
|
|
114
133
|
stream.controller.enqueue(msg);
|
|
115
134
|
});
|
|
135
|
+
eventSource.addEventListener(SERIALIZED_ERROR_EVENT, (msg)=>{
|
|
136
|
+
stream.controller.enqueue(msg);
|
|
137
|
+
});
|
|
116
138
|
eventSource.addEventListener('error', (cause)=>{
|
|
117
139
|
if (eventSource.readyState === EventSource.CLOSED) {
|
|
118
140
|
stream.controller.error(cause);
|
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.477+a467f8314",
|
|
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": "a467f831416d19c0bf96139fd4ca576fcf80de2a"
|
|
153
153
|
}
|
|
@@ -380,9 +380,21 @@ export async function resolveResponse<TRouter extends AnyRouter>(
|
|
|
380
380
|
? observableToAsyncIterable(data)
|
|
381
381
|
: data;
|
|
382
382
|
const stream = sseStreamProducer({
|
|
383
|
-
...
|
|
383
|
+
...config.experimental?.sseSubscriptions,
|
|
384
384
|
data: dataAsIterable,
|
|
385
385
|
serialize: (v) => config.transformer.output.serialize(v),
|
|
386
|
+
formatError(errorOpts) {
|
|
387
|
+
const shape = getErrorShape({
|
|
388
|
+
config,
|
|
389
|
+
ctx,
|
|
390
|
+
error: getTRPCErrorFromUnknown(errorOpts.error),
|
|
391
|
+
input: call?.result(),
|
|
392
|
+
path: call?.path,
|
|
393
|
+
type: call?.procedure?._def.type ?? 'unknown',
|
|
394
|
+
});
|
|
395
|
+
|
|
396
|
+
return shape;
|
|
397
|
+
},
|
|
386
398
|
});
|
|
387
399
|
for (const [key, value] of Object.entries(sseHeaders)) {
|
|
388
400
|
headers.set(key, value);
|
|
@@ -80,7 +80,10 @@ export interface RootConfig<TTypes extends RootTypes> {
|
|
|
80
80
|
* @default true
|
|
81
81
|
*/
|
|
82
82
|
enabled?: boolean;
|
|
83
|
-
} &
|
|
83
|
+
} & Pick<
|
|
84
|
+
SSEStreamProducerOptions,
|
|
85
|
+
'ping' | 'emitAndEndImmediately' | 'maxDurationMs'
|
|
86
|
+
>;
|
|
84
87
|
};
|
|
85
88
|
}
|
|
86
89
|
|
|
@@ -42,8 +42,11 @@ export interface SSEStreamProducerOptions {
|
|
|
42
42
|
* @default false
|
|
43
43
|
*/
|
|
44
44
|
emitAndEndImmediately?: boolean;
|
|
45
|
+
formatError?: (opts: { error: unknown }) => unknown;
|
|
45
46
|
}
|
|
46
47
|
|
|
48
|
+
const SERIALIZED_ERROR_EVENT = 'serialized-error';
|
|
49
|
+
|
|
47
50
|
type SSEvent = Partial<{
|
|
48
51
|
id: string;
|
|
49
52
|
data: unknown;
|
|
@@ -106,7 +109,13 @@ export function sseStreamProducer(opts: SSEStreamProducerOptions) {
|
|
|
106
109
|
}
|
|
107
110
|
|
|
108
111
|
if (next instanceof Error) {
|
|
109
|
-
|
|
112
|
+
const data = opts.formatError
|
|
113
|
+
? opts.formatError({ error: next })
|
|
114
|
+
: null;
|
|
115
|
+
stream.controller.enqueue({
|
|
116
|
+
event: SERIALIZED_ERROR_EVENT,
|
|
117
|
+
data: JSON.stringify(serialize(data)),
|
|
118
|
+
});
|
|
110
119
|
break;
|
|
111
120
|
}
|
|
112
121
|
if (next.done) {
|
|
@@ -165,15 +174,25 @@ export function sseStreamProducer(opts: SSEStreamProducerOptions) {
|
|
|
165
174
|
}),
|
|
166
175
|
);
|
|
167
176
|
}
|
|
177
|
+
|
|
178
|
+
type ConsumerStreamResult<TData> =
|
|
179
|
+
| {
|
|
180
|
+
ok: true;
|
|
181
|
+
data: inferTrackedOutput<TData>;
|
|
182
|
+
}
|
|
183
|
+
| {
|
|
184
|
+
ok: false;
|
|
185
|
+
error: unknown;
|
|
186
|
+
};
|
|
187
|
+
|
|
168
188
|
/**
|
|
169
189
|
* @see https://html.spec.whatwg.org/multipage/server-sent-events.html
|
|
170
190
|
*/
|
|
171
|
-
|
|
172
191
|
export function sseStreamConsumer<TData>(opts: {
|
|
173
192
|
from: EventSource;
|
|
174
193
|
onError?: ConsumerOnError;
|
|
175
194
|
deserialize?: Deserialize;
|
|
176
|
-
}): AsyncIterable<
|
|
195
|
+
}): AsyncIterable<ConsumerStreamResult<TData>> {
|
|
177
196
|
const { deserialize = (v) => v } = opts;
|
|
178
197
|
const eventSource = opts.from;
|
|
179
198
|
|
|
@@ -181,23 +200,39 @@ export function sseStreamConsumer<TData>(opts: {
|
|
|
181
200
|
|
|
182
201
|
const transform = new TransformStream<
|
|
183
202
|
MessageEvent,
|
|
184
|
-
|
|
203
|
+
ConsumerStreamResult<TData>
|
|
185
204
|
>({
|
|
186
205
|
async transform(chunk, controller) {
|
|
206
|
+
const data = deserialize(JSON.parse(chunk.data));
|
|
207
|
+
if (chunk.type === SERIALIZED_ERROR_EVENT) {
|
|
208
|
+
controller.enqueue({
|
|
209
|
+
ok: false,
|
|
210
|
+
error: data,
|
|
211
|
+
});
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
// console.debug('transforming', chunk.type, chunk.data);
|
|
187
215
|
const def: SSEvent = {
|
|
188
|
-
data
|
|
216
|
+
data,
|
|
189
217
|
};
|
|
190
218
|
|
|
191
219
|
if (chunk.lastEventId) {
|
|
192
220
|
def.id = chunk.lastEventId;
|
|
193
221
|
}
|
|
194
|
-
|
|
222
|
+
|
|
223
|
+
controller.enqueue({
|
|
224
|
+
ok: true,
|
|
225
|
+
data: def as inferTrackedOutput<TData>,
|
|
226
|
+
});
|
|
195
227
|
},
|
|
196
228
|
});
|
|
197
229
|
|
|
198
230
|
eventSource.addEventListener('message', (msg) => {
|
|
199
231
|
stream.controller.enqueue(msg);
|
|
200
232
|
});
|
|
233
|
+
eventSource.addEventListener(SERIALIZED_ERROR_EVENT, (msg) => {
|
|
234
|
+
stream.controller.enqueue(msg);
|
|
235
|
+
});
|
|
201
236
|
eventSource.addEventListener('error', (cause) => {
|
|
202
237
|
if (eventSource.readyState === EventSource.CLOSED) {
|
|
203
238
|
stream.controller.error(cause);
|
|
@@ -209,7 +244,7 @@ export function sseStreamConsumer<TData>(opts: {
|
|
|
209
244
|
[Symbol.asyncIterator]() {
|
|
210
245
|
const reader = readable.getReader();
|
|
211
246
|
|
|
212
|
-
const iterator: AsyncIterator<
|
|
247
|
+
const iterator: AsyncIterator<ConsumerStreamResult<TData>> = {
|
|
213
248
|
async next() {
|
|
214
249
|
const value = await reader.read();
|
|
215
250
|
if (value.done) {
|