@trpc/server 11.0.0-rc.741 → 11.0.0-rc.744
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 +54 -52
- package/dist/unstable-core-do-not-import/http/resolveResponse.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/http/resolveResponse.js +1 -0
- package/dist/unstable-core-do-not-import/http/resolveResponse.mjs +1 -0
- package/dist/unstable-core-do-not-import/rootConfig.d.ts +6 -0
- package/dist/unstable-core-do-not-import/rootConfig.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/stream/jsonl.d.ts +8 -2
- package/dist/unstable-core-do-not-import/stream/jsonl.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import/stream/jsonl.js +16 -3
- package/dist/unstable-core-do-not-import/stream/jsonl.mjs +16 -3
- package/dist/unstable-core-do-not-import.d.ts +2 -0
- package/dist/unstable-core-do-not-import.d.ts.map +1 -1
- package/dist/unstable-core-do-not-import.js +6 -0
- package/dist/unstable-core-do-not-import.mjs +2 -0
- package/package.json +2 -2
- package/src/unstable-core-do-not-import/http/resolveResponse.ts +1 -0
- package/src/unstable-core-do-not-import/rootConfig.ts +7 -0
- package/src/unstable-core-do-not-import/stream/jsonl.ts +28 -7
- package/src/unstable-core-do-not-import.ts +2 -0
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction": 13.
|
|
2
|
+
"bundleSize": 195330,
|
|
3
|
+
"bundleOrigSize": 226790,
|
|
4
|
+
"bundleReduction": 13.87,
|
|
5
5
|
"modules": [
|
|
6
6
|
{
|
|
7
7
|
"id": "/src/unstable-core-do-not-import/http/resolveResponse.ts",
|
|
8
|
-
"size":
|
|
9
|
-
"origSize":
|
|
8
|
+
"size": 21071,
|
|
9
|
+
"origSize": 19429,
|
|
10
10
|
"renderedExports": [
|
|
11
11
|
"resolveResponse"
|
|
12
12
|
],
|
|
@@ -18,36 +18,36 @@
|
|
|
18
18
|
"reduction": 0
|
|
19
19
|
},
|
|
20
20
|
{
|
|
21
|
-
"id": "/src/
|
|
22
|
-
"size":
|
|
23
|
-
"origSize":
|
|
21
|
+
"id": "/src/unstable-core-do-not-import/stream/jsonl.ts",
|
|
22
|
+
"size": 20426,
|
|
23
|
+
"origSize": 17485,
|
|
24
24
|
"renderedExports": [
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"
|
|
25
|
+
"isPromise",
|
|
26
|
+
"jsonlStreamProducer",
|
|
27
|
+
"jsonlStreamConsumer"
|
|
28
28
|
],
|
|
29
29
|
"removedExports": [],
|
|
30
30
|
"dependents": [
|
|
31
|
-
"/src/
|
|
31
|
+
"/src/unstable-core-do-not-import.ts",
|
|
32
|
+
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
32
33
|
],
|
|
33
|
-
"percent": 10.
|
|
34
|
+
"percent": 10.46,
|
|
34
35
|
"reduction": 0
|
|
35
36
|
},
|
|
36
37
|
{
|
|
37
|
-
"id": "/src/
|
|
38
|
-
"size":
|
|
39
|
-
"origSize":
|
|
38
|
+
"id": "/src/adapters/ws.ts",
|
|
39
|
+
"size": 20168,
|
|
40
|
+
"origSize": 15955,
|
|
40
41
|
"renderedExports": [
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
42
|
+
"getWSConnectionHandler",
|
|
43
|
+
"handleKeepAlive",
|
|
44
|
+
"applyWSSHandler"
|
|
44
45
|
],
|
|
45
46
|
"removedExports": [],
|
|
46
47
|
"dependents": [
|
|
47
|
-
"/src/
|
|
48
|
-
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
48
|
+
"/src/adapters/fastify/fastifyTRPCPlugin.ts"
|
|
49
49
|
],
|
|
50
|
-
"percent": 10.
|
|
50
|
+
"percent": 10.33,
|
|
51
51
|
"reduction": 0
|
|
52
52
|
},
|
|
53
53
|
{
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"/src/unstable-core-do-not-import.ts",
|
|
65
65
|
"/src/unstable-core-do-not-import/http/resolveResponse.ts"
|
|
66
66
|
],
|
|
67
|
-
"percent": 6.
|
|
67
|
+
"percent": 6.46,
|
|
68
68
|
"reduction": 0
|
|
69
69
|
},
|
|
70
70
|
{
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
],
|
|
78
78
|
"removedExports": [],
|
|
79
79
|
"dependents": [],
|
|
80
|
-
"percent": 6.
|
|
80
|
+
"percent": 6.22,
|
|
81
81
|
"reduction": 11.62
|
|
82
82
|
},
|
|
83
83
|
{
|
|
@@ -91,7 +91,7 @@
|
|
|
91
91
|
"dependents": [
|
|
92
92
|
"/src/unstable-core-do-not-import/stream/jsonl.ts"
|
|
93
93
|
],
|
|
94
|
-
"percent": 4.
|
|
94
|
+
"percent": 4.16,
|
|
95
95
|
"reduction": 0
|
|
96
96
|
},
|
|
97
97
|
{
|
|
@@ -124,7 +124,7 @@
|
|
|
124
124
|
"/src/unstable-core-do-not-import.ts",
|
|
125
125
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
126
126
|
],
|
|
127
|
-
"percent": 3.
|
|
127
|
+
"percent": 3.3,
|
|
128
128
|
"reduction": 39.41
|
|
129
129
|
},
|
|
130
130
|
{
|
|
@@ -138,12 +138,13 @@
|
|
|
138
138
|
],
|
|
139
139
|
"removedExports": [],
|
|
140
140
|
"dependents": [
|
|
141
|
+
"/src/unstable-core-do-not-import.ts",
|
|
141
142
|
"/src/adapters/ws.ts",
|
|
142
143
|
"/src/unstable-core-do-not-import/stream/jsonl.ts",
|
|
143
144
|
"/src/unstable-core-do-not-import/stream/sse.ts",
|
|
144
145
|
"/src/unstable-core-do-not-import/stream/utils/withPing.ts"
|
|
145
146
|
],
|
|
146
|
-
"percent": 2.
|
|
147
|
+
"percent": 2.98,
|
|
147
148
|
"reduction": 0
|
|
148
149
|
},
|
|
149
150
|
{
|
|
@@ -172,7 +173,7 @@
|
|
|
172
173
|
"dependents": [
|
|
173
174
|
"/src/adapters/aws-lambda/index.ts"
|
|
174
175
|
],
|
|
175
|
-
"percent": 2.
|
|
176
|
+
"percent": 2.77,
|
|
176
177
|
"reduction": 11.51
|
|
177
178
|
},
|
|
178
179
|
{
|
|
@@ -205,9 +206,10 @@
|
|
|
205
206
|
],
|
|
206
207
|
"removedExports": [],
|
|
207
208
|
"dependents": [
|
|
209
|
+
"/src/unstable-core-do-not-import/stream/jsonl.ts",
|
|
208
210
|
"/src/unstable-core-do-not-import/stream/sse.ts"
|
|
209
211
|
],
|
|
210
|
-
"percent": 2.
|
|
212
|
+
"percent": 2.27,
|
|
211
213
|
"reduction": 0
|
|
212
214
|
},
|
|
213
215
|
{
|
|
@@ -223,7 +225,7 @@
|
|
|
223
225
|
"/src/adapters/node-http/index.ts",
|
|
224
226
|
"/src/adapters/node-http/nodeHTTPRequestHandler.ts"
|
|
225
227
|
],
|
|
226
|
-
"percent": 2.
|
|
228
|
+
"percent": 2.07,
|
|
227
229
|
"reduction": 6.82
|
|
228
230
|
},
|
|
229
231
|
{
|
|
@@ -241,7 +243,7 @@
|
|
|
241
243
|
"dependents": [
|
|
242
244
|
"/src/observable/index.ts"
|
|
243
245
|
],
|
|
244
|
-
"percent": 2
|
|
246
|
+
"percent": 2,
|
|
245
247
|
"reduction": 1.66
|
|
246
248
|
},
|
|
247
249
|
{
|
|
@@ -270,7 +272,7 @@
|
|
|
270
272
|
"dependents": [
|
|
271
273
|
"/src/adapters/node-http/index.ts"
|
|
272
274
|
],
|
|
273
|
-
"percent": 1.
|
|
275
|
+
"percent": 1.4,
|
|
274
276
|
"reduction": 16.3
|
|
275
277
|
},
|
|
276
278
|
{
|
|
@@ -290,7 +292,7 @@
|
|
|
290
292
|
"/src/unstable-core-do-not-import/initTRPC.ts",
|
|
291
293
|
"/src/unstable-core-do-not-import/router.ts"
|
|
292
294
|
],
|
|
293
|
-
"percent": 1.
|
|
295
|
+
"percent": 1.4,
|
|
294
296
|
"reduction": 45.98
|
|
295
297
|
},
|
|
296
298
|
{
|
|
@@ -304,7 +306,7 @@
|
|
|
304
306
|
"dependents": [
|
|
305
307
|
"/src/unstable-core-do-not-import.ts"
|
|
306
308
|
],
|
|
307
|
-
"percent": 1.
|
|
309
|
+
"percent": 1.36,
|
|
308
310
|
"reduction": 40.81
|
|
309
311
|
},
|
|
310
312
|
{
|
|
@@ -324,7 +326,7 @@
|
|
|
324
326
|
"/src/unstable-core-do-not-import/initTRPC.ts",
|
|
325
327
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
326
328
|
],
|
|
327
|
-
"percent": 1.
|
|
329
|
+
"percent": 1.34,
|
|
328
330
|
"reduction": 55.79
|
|
329
331
|
},
|
|
330
332
|
{
|
|
@@ -401,7 +403,7 @@
|
|
|
401
403
|
"/src/unstable-core-do-not-import.ts",
|
|
402
404
|
"/src/unstable-core-do-not-import/router.ts"
|
|
403
405
|
],
|
|
404
|
-
"percent": 1.
|
|
406
|
+
"percent": 1.19,
|
|
405
407
|
"reduction": 0
|
|
406
408
|
},
|
|
407
409
|
{
|
|
@@ -524,7 +526,7 @@
|
|
|
524
526
|
],
|
|
525
527
|
"removedExports": [],
|
|
526
528
|
"dependents": [],
|
|
527
|
-
"percent": 0.
|
|
529
|
+
"percent": 0.82,
|
|
528
530
|
"reduction": 17.81
|
|
529
531
|
},
|
|
530
532
|
{
|
|
@@ -539,7 +541,7 @@
|
|
|
539
541
|
"/src/unstable-core-do-not-import.ts",
|
|
540
542
|
"/src/unstable-core-do-not-import/procedureBuilder.ts"
|
|
541
543
|
],
|
|
542
|
-
"percent": 0.
|
|
544
|
+
"percent": 0.82,
|
|
543
545
|
"reduction": 54.01
|
|
544
546
|
},
|
|
545
547
|
{
|
|
@@ -653,7 +655,7 @@
|
|
|
653
655
|
],
|
|
654
656
|
"removedExports": [],
|
|
655
657
|
"dependents": [],
|
|
656
|
-
"percent": 0.
|
|
658
|
+
"percent": 0.45,
|
|
657
659
|
"reduction": 34
|
|
658
660
|
},
|
|
659
661
|
{
|
|
@@ -750,7 +752,7 @@
|
|
|
750
752
|
{
|
|
751
753
|
"id": "/src/unstable-core-do-not-import/rootConfig.ts",
|
|
752
754
|
"size": 343,
|
|
753
|
-
"origSize":
|
|
755
|
+
"origSize": 3318,
|
|
754
756
|
"renderedExports": [
|
|
755
757
|
"isServerDefault"
|
|
756
758
|
],
|
|
@@ -760,7 +762,7 @@
|
|
|
760
762
|
"/src/unstable-core-do-not-import/initTRPC.ts"
|
|
761
763
|
],
|
|
762
764
|
"percent": 0.18,
|
|
763
|
-
"reduction":
|
|
765
|
+
"reduction": 89.66
|
|
764
766
|
},
|
|
765
767
|
{
|
|
766
768
|
"id": "/src/unstable-core-do-not-import/stream/utils/createDeferred.ts",
|
|
@@ -875,9 +877,9 @@
|
|
|
875
877
|
"reduction": 100
|
|
876
878
|
},
|
|
877
879
|
{
|
|
878
|
-
"id": "/src/
|
|
880
|
+
"id": "/src/rpc.ts",
|
|
879
881
|
"size": 0,
|
|
880
|
-
"origSize":
|
|
882
|
+
"origSize": 36,
|
|
881
883
|
"renderedExports": [],
|
|
882
884
|
"removedExports": [],
|
|
883
885
|
"dependents": [],
|
|
@@ -885,9 +887,9 @@
|
|
|
885
887
|
"reduction": 100
|
|
886
888
|
},
|
|
887
889
|
{
|
|
888
|
-
"id": "/src/
|
|
890
|
+
"id": "/src/shared.ts",
|
|
889
891
|
"size": 0,
|
|
890
|
-
"origSize":
|
|
892
|
+
"origSize": 653,
|
|
891
893
|
"renderedExports": [],
|
|
892
894
|
"removedExports": [],
|
|
893
895
|
"dependents": [],
|
|
@@ -897,14 +899,14 @@
|
|
|
897
899
|
{
|
|
898
900
|
"id": "/src/unstable-core-do-not-import.ts",
|
|
899
901
|
"size": 0,
|
|
900
|
-
"origSize":
|
|
902
|
+
"origSize": 2586,
|
|
901
903
|
"renderedExports": [],
|
|
902
904
|
"removedExports": [],
|
|
903
905
|
"dependents": [
|
|
904
906
|
"/src/adapters/express.ts",
|
|
905
|
-
"/src/adapters/ws.ts",
|
|
906
907
|
"/src/adapters/standalone.ts",
|
|
907
908
|
"/src/adapters/next.ts",
|
|
909
|
+
"/src/adapters/ws.ts",
|
|
908
910
|
"/src/adapters/node-http/nodeHTTPRequestHandler.ts",
|
|
909
911
|
"/src/adapters/next-app-dir/nextAppDirCaller.ts",
|
|
910
912
|
"/src/adapters/node-http/writeResponse.ts"
|
|
@@ -935,9 +937,9 @@
|
|
|
935
937
|
"reduction": 100
|
|
936
938
|
},
|
|
937
939
|
{
|
|
938
|
-
"id": "/src/adapters/
|
|
940
|
+
"id": "/src/adapters/fastify/index.ts",
|
|
939
941
|
"size": 0,
|
|
940
|
-
"origSize":
|
|
942
|
+
"origSize": 78,
|
|
941
943
|
"renderedExports": [],
|
|
942
944
|
"removedExports": [],
|
|
943
945
|
"dependents": [],
|
|
@@ -945,9 +947,9 @@
|
|
|
945
947
|
"reduction": 100
|
|
946
948
|
},
|
|
947
949
|
{
|
|
948
|
-
"id": "/src/adapters/
|
|
950
|
+
"id": "/src/adapters/fetch/index.ts",
|
|
949
951
|
"size": 0,
|
|
950
|
-
"origSize":
|
|
952
|
+
"origSize": 64,
|
|
951
953
|
"renderedExports": [],
|
|
952
954
|
"removedExports": [],
|
|
953
955
|
"dependents": [],
|
|
@@ -962,9 +964,9 @@
|
|
|
962
964
|
"removedExports": [],
|
|
963
965
|
"dependents": [
|
|
964
966
|
"/src/adapters/express.ts",
|
|
965
|
-
"/src/adapters/ws.ts",
|
|
966
967
|
"/src/adapters/standalone.ts",
|
|
967
968
|
"/src/adapters/next.ts",
|
|
969
|
+
"/src/adapters/ws.ts",
|
|
968
970
|
"/src/adapters/fastify/fastifyRequestHandler.ts"
|
|
969
971
|
],
|
|
970
972
|
"percent": 0,
|
|
@@ -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;AA+BjB,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;AA2ID,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;AA+BjB,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;AA2ID,wBAAsB,eAAe,CAAC,OAAO,SAAS,SAAS,EAC7D,IAAI,EAAE,yBAAyB,CAAC,OAAO,CAAC,GACvC,OAAO,CAAC,QAAQ,CAAC,CAqfnB"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CombinedDataTransformer } from '../unstable-core-do-not-import';
|
|
2
2
|
import type { DefaultErrorShape, ErrorFormatter } from './error/formatter';
|
|
3
|
+
import type { JSONLProducerOptions } from './stream/jsonl';
|
|
3
4
|
import type { SSEStreamProducerOptions } from './stream/sse';
|
|
4
5
|
/**
|
|
5
6
|
* The initial generics that are used in the init function
|
|
@@ -65,6 +66,11 @@ export interface RootConfig<TTypes extends RootTypes> {
|
|
|
65
66
|
*/
|
|
66
67
|
enabled?: boolean;
|
|
67
68
|
} & Pick<SSEStreamProducerOptions, 'ping' | 'emitAndEndImmediately' | 'maxDurationMs' | 'client'>;
|
|
69
|
+
/**
|
|
70
|
+
* Options for batch stream
|
|
71
|
+
* @see https://trpc.io/docs/client/links/httpBatchStreamLink
|
|
72
|
+
*/
|
|
73
|
+
jsonl?: Pick<JSONLProducerOptions, 'pingMs'>;
|
|
68
74
|
experimental?: {};
|
|
69
75
|
}
|
|
70
76
|
/**
|
|
@@ -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,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ACR,SAAS,SAAS,CAAC,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,IACvC,SAAS,CACX,MAAM,SAAS,QAAQ,GAAG,IAAI,GAAG,KAAK,EACtC;IACE;;QAEI;IACJ,aAAa,EAAE,SAAS,CAAC;CAC1B,CACF,CAAC"}
|
|
@@ -65,7 +65,7 @@ export type ProducerOnError = (opts: {
|
|
|
65
65
|
error: unknown;
|
|
66
66
|
path: PathArray;
|
|
67
67
|
}) => void;
|
|
68
|
-
export interface
|
|
68
|
+
export interface JSONLProducerOptions {
|
|
69
69
|
serialize?: Serialize;
|
|
70
70
|
data: Record<string, unknown> | unknown[];
|
|
71
71
|
onError?: ProducerOnError;
|
|
@@ -74,12 +74,18 @@ export interface ProducerOptions {
|
|
|
74
74
|
path: PathArray;
|
|
75
75
|
}) => unknown;
|
|
76
76
|
maxDepth?: number;
|
|
77
|
+
/**
|
|
78
|
+
* Interval in milliseconds to send a ping to the client to keep the connection alive
|
|
79
|
+
* This will be sent as a whitespace character
|
|
80
|
+
* @default undefined
|
|
81
|
+
*/
|
|
82
|
+
pingMs?: number;
|
|
77
83
|
}
|
|
78
84
|
/**
|
|
79
85
|
* JSON Lines stream producer
|
|
80
86
|
* @see https://jsonlines.org/
|
|
81
87
|
*/
|
|
82
|
-
export declare function jsonlStreamProducer(opts:
|
|
88
|
+
export declare function jsonlStreamProducer(opts: JSONLProducerOptions): ReadableStream<Uint8Array<ArrayBufferLike>>;
|
|
83
89
|
declare class StreamInterruptedError extends Error {
|
|
84
90
|
constructor(cause?: unknown);
|
|
85
91
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jsonl.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/stream/jsonl.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"jsonl.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/stream/jsonl.ts"],"names":[],"mappings":"AASA;;;GAGG;AACH,MAAM,MAAM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CAAC;QAAC,IAAI,EAAE,SAAS,CAAA;KAAE,KAAK,OAAO,CAAC;IACrE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB;;;;OAIG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAoJD;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,oBAAoB,+CA+B7D;AAED,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;AAkFjE;;GAEG;AACH,KAAK,eAAe,GAAG,SAAS,GAAG,sBAAsB,CAAC;AA8F1D;;;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;IAClD;;OAEG;IACH,eAAe,EAAE,eAAe,CAAC;CAClC;2BAxC+B,UAAU;qBArCvB,eAAe;;;;;;wBAiDL,OAAO;IA0JnC"}
|
|
@@ -6,6 +6,7 @@ var createDeferred = require('./utils/createDeferred.js');
|
|
|
6
6
|
var disposable = require('./utils/disposable.js');
|
|
7
7
|
var mergeAsyncIterables = require('./utils/mergeAsyncIterables.js');
|
|
8
8
|
var readableStreamFrom = require('./utils/readableStreamFrom.js');
|
|
9
|
+
var withPing = require('./utils/withPing.js');
|
|
9
10
|
|
|
10
11
|
function _define_property(obj, key, value) {
|
|
11
12
|
if (key in obj) {
|
|
@@ -284,7 +285,11 @@ async function* createBatchStreamProducer(opts) {
|
|
|
284
285
|
]);
|
|
285
286
|
}
|
|
286
287
|
yield newHead;
|
|
287
|
-
|
|
288
|
+
let iterable = mergedIterables;
|
|
289
|
+
if (opts.pingMs) {
|
|
290
|
+
iterable = withPing.withPing(mergedIterables, opts.pingMs);
|
|
291
|
+
}
|
|
292
|
+
for await (const value of iterable){
|
|
288
293
|
yield value;
|
|
289
294
|
}
|
|
290
295
|
}
|
|
@@ -297,13 +302,21 @@ async function* createBatchStreamProducer(opts) {
|
|
|
297
302
|
if (serialize) {
|
|
298
303
|
stream = stream.pipeThrough(new TransformStream({
|
|
299
304
|
transform (chunk, controller) {
|
|
300
|
-
|
|
305
|
+
if (chunk === withPing.PING_SYM) {
|
|
306
|
+
controller.enqueue(withPing.PING_SYM);
|
|
307
|
+
} else {
|
|
308
|
+
controller.enqueue(serialize(chunk));
|
|
309
|
+
}
|
|
301
310
|
}
|
|
302
311
|
}));
|
|
303
312
|
}
|
|
304
313
|
return stream.pipeThrough(new TransformStream({
|
|
305
314
|
transform (chunk, controller) {
|
|
306
|
-
|
|
315
|
+
if (chunk === withPing.PING_SYM) {
|
|
316
|
+
controller.enqueue(' ');
|
|
317
|
+
} else {
|
|
318
|
+
controller.enqueue(JSON.stringify(chunk) + '\n');
|
|
319
|
+
}
|
|
307
320
|
}
|
|
308
321
|
})).pipeThrough(new TextEncoderStream());
|
|
309
322
|
}
|
|
@@ -4,6 +4,7 @@ import { createDeferred } from './utils/createDeferred.mjs';
|
|
|
4
4
|
import { makeResource } from './utils/disposable.mjs';
|
|
5
5
|
import { mergeAsyncIterables } from './utils/mergeAsyncIterables.mjs';
|
|
6
6
|
import { readableStreamFrom } from './utils/readableStreamFrom.mjs';
|
|
7
|
+
import { PING_SYM, withPing } from './utils/withPing.mjs';
|
|
7
8
|
|
|
8
9
|
function _define_property(obj, key, value) {
|
|
9
10
|
if (key in obj) {
|
|
@@ -282,7 +283,11 @@ async function* createBatchStreamProducer(opts) {
|
|
|
282
283
|
]);
|
|
283
284
|
}
|
|
284
285
|
yield newHead;
|
|
285
|
-
|
|
286
|
+
let iterable = mergedIterables;
|
|
287
|
+
if (opts.pingMs) {
|
|
288
|
+
iterable = withPing(mergedIterables, opts.pingMs);
|
|
289
|
+
}
|
|
290
|
+
for await (const value of iterable){
|
|
286
291
|
yield value;
|
|
287
292
|
}
|
|
288
293
|
}
|
|
@@ -295,13 +300,21 @@ async function* createBatchStreamProducer(opts) {
|
|
|
295
300
|
if (serialize) {
|
|
296
301
|
stream = stream.pipeThrough(new TransformStream({
|
|
297
302
|
transform (chunk, controller) {
|
|
298
|
-
|
|
303
|
+
if (chunk === PING_SYM) {
|
|
304
|
+
controller.enqueue(PING_SYM);
|
|
305
|
+
} else {
|
|
306
|
+
controller.enqueue(serialize(chunk));
|
|
307
|
+
}
|
|
299
308
|
}
|
|
300
309
|
}));
|
|
301
310
|
}
|
|
302
311
|
return stream.pipeThrough(new TransformStream({
|
|
303
312
|
transform (chunk, controller) {
|
|
304
|
-
|
|
313
|
+
if (chunk === PING_SYM) {
|
|
314
|
+
controller.enqueue(' ');
|
|
315
|
+
} else {
|
|
316
|
+
controller.enqueue(JSON.stringify(chunk) + '\n');
|
|
317
|
+
}
|
|
305
318
|
}
|
|
306
319
|
})).pipeThrough(new TextEncoderStream());
|
|
307
320
|
}
|
|
@@ -37,9 +37,11 @@ export * from './unstable-core-do-not-import/stream/sse';
|
|
|
37
37
|
export * from './unstable-core-do-not-import/stream/tracked';
|
|
38
38
|
export * from './unstable-core-do-not-import/stream/utils/createDeferred';
|
|
39
39
|
export * from './unstable-core-do-not-import/stream/utils/disposable';
|
|
40
|
+
export * from './unstable-core-do-not-import/stream/utils/asyncIterable';
|
|
40
41
|
export * from './unstable-core-do-not-import/transformer';
|
|
41
42
|
export * from './unstable-core-do-not-import/types';
|
|
42
43
|
export * from './unstable-core-do-not-import/utils';
|
|
43
44
|
export * from './vendor/standard-schema-v1/error';
|
|
44
45
|
export * from './vendor/standard-schema-v1/spec';
|
|
46
|
+
export * from './vendor/unpromise';
|
|
45
47
|
//# sourceMappingURL=unstable-core-do-not-import.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unstable-core-do-not-import.d.ts","sourceRoot":"","sources":["../src/unstable-core-do-not-import.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,cAAc,mDAAmD,CAAC;AAClE,cAAc,oDAAoD,CAAC;AACnE,cAAc,mDAAmD,CAAC;AAClE,cAAc,2CAA2C,CAAC;AAC1D,cAAc,+CAA+C,CAAC;AAC9D,cAAc,mDAAmD,CAAC;AAClE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,gDAAgD,CAAC;AAC/D,cAAc,uDAAuD,CAAC;AACtE,cAAc,qDAAqD,CAAC;AACpE,cAAc,sDAAsD,CAAC;AACrE,cAAc,iDAAiD,CAAC;AAChE,cAAc,0DAA0D,CAAC;AACzE,cAAc,oDAAoD,CAAC;AACnE,cAAc,0CAA0C,CAAC;AACzD,cAAc,wCAAwC,CAAC;AACvD,cAAc,0CAA0C,CAAC;AACzD,cAAc,sCAAsC,CAAC;AACrD,cAAc,yCAAyC,CAAC;AACxD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,0CAA0C,CAAC;AACzD,cAAc,sCAAsC,CAAC;AACrD,cAAc,mCAAmC,CAAC;AAClD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,gDAAgD,CAAC;AAC/D,cAAc,0CAA0C,CAAC;AACzD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,2DAA2D,CAAC;AAC1E,cAAc,uDAAuD,CAAC;AACtE,cAAc,2CAA2C,CAAC;AAC1D,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC"}
|
|
1
|
+
{"version":3,"file":"unstable-core-do-not-import.d.ts","sourceRoot":"","sources":["../src/unstable-core-do-not-import.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,cAAc,mDAAmD,CAAC;AAClE,cAAc,oDAAoD,CAAC;AACnE,cAAc,mDAAmD,CAAC;AAClE,cAAc,2CAA2C,CAAC;AAC1D,cAAc,+CAA+C,CAAC;AAC9D,cAAc,mDAAmD,CAAC;AAClE,cAAc,+CAA+C,CAAC;AAC9D,cAAc,gDAAgD,CAAC;AAC/D,cAAc,uDAAuD,CAAC;AACtE,cAAc,qDAAqD,CAAC;AACpE,cAAc,sDAAsD,CAAC;AACrE,cAAc,iDAAiD,CAAC;AAChE,cAAc,0DAA0D,CAAC;AACzE,cAAc,oDAAoD,CAAC;AACnE,cAAc,0CAA0C,CAAC;AACzD,cAAc,wCAAwC,CAAC;AACvD,cAAc,0CAA0C,CAAC;AACzD,cAAc,sCAAsC,CAAC;AACrD,cAAc,yCAAyC,CAAC;AACxD,cAAc,gDAAgD,CAAC;AAC/D,cAAc,0CAA0C,CAAC;AACzD,cAAc,sCAAsC,CAAC;AACrD,cAAc,mCAAmC,CAAC;AAClD,cAAc,4CAA4C,CAAC;AAC3D,cAAc,gDAAgD,CAAC;AAC/D,cAAc,0CAA0C,CAAC;AACzD,cAAc,8CAA8C,CAAC;AAC7D,cAAc,2DAA2D,CAAC;AAC1E,cAAc,uDAAuD,CAAC;AACtE,cAAc,0DAA0D,CAAC;AACzE,cAAc,2CAA2C,CAAC;AAC1D,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC;AACpD,cAAc,mCAAmC,CAAC;AAClD,cAAc,kCAAkC,CAAC;AACjD,cAAc,oBAAoB,CAAC"}
|
|
@@ -25,9 +25,11 @@ var sse = require('./unstable-core-do-not-import/stream/sse.js');
|
|
|
25
25
|
var tracked = require('./unstable-core-do-not-import/stream/tracked.js');
|
|
26
26
|
var createDeferred = require('./unstable-core-do-not-import/stream/utils/createDeferred.js');
|
|
27
27
|
var disposable = require('./unstable-core-do-not-import/stream/utils/disposable.js');
|
|
28
|
+
var asyncIterable = require('./unstable-core-do-not-import/stream/utils/asyncIterable.js');
|
|
28
29
|
var transformer = require('./unstable-core-do-not-import/transformer.js');
|
|
29
30
|
var utils = require('./unstable-core-do-not-import/utils.js');
|
|
30
31
|
var error = require('./vendor/standard-schema-v1/error.js');
|
|
32
|
+
var unpromise = require('./vendor/unpromise/unpromise.js');
|
|
31
33
|
|
|
32
34
|
|
|
33
35
|
|
|
@@ -80,6 +82,9 @@ exports.tracked = tracked.tracked;
|
|
|
80
82
|
exports.createDeferred = createDeferred.createDeferred;
|
|
81
83
|
exports.makeAsyncResource = disposable.makeAsyncResource;
|
|
82
84
|
exports.makeResource = disposable.makeResource;
|
|
85
|
+
exports.iteratorResource = asyncIterable.iteratorResource;
|
|
86
|
+
exports.takeWithGrace = asyncIterable.takeWithGrace;
|
|
87
|
+
exports.withMaxDuration = asyncIterable.withMaxDuration;
|
|
83
88
|
exports.defaultTransformer = transformer.defaultTransformer;
|
|
84
89
|
exports.getDataTransformer = transformer.getDataTransformer;
|
|
85
90
|
exports.transformResult = transformer.transformResult;
|
|
@@ -97,3 +102,4 @@ exports.run = utils.run;
|
|
|
97
102
|
exports.sleep = utils.sleep;
|
|
98
103
|
exports.unsetMarker = utils.unsetMarker;
|
|
99
104
|
exports.StandardSchemaV1Error = error.StandardSchemaV1Error;
|
|
105
|
+
exports.Unpromise = unpromise.Unpromise;
|
|
@@ -23,6 +23,8 @@ export { sseHeaders, sseStreamConsumer, sseStreamProducer } from './unstable-cor
|
|
|
23
23
|
export { isTrackedEnvelope, sse, tracked } from './unstable-core-do-not-import/stream/tracked.mjs';
|
|
24
24
|
export { createDeferred } from './unstable-core-do-not-import/stream/utils/createDeferred.mjs';
|
|
25
25
|
export { makeAsyncResource, makeResource } from './unstable-core-do-not-import/stream/utils/disposable.mjs';
|
|
26
|
+
export { iteratorResource, takeWithGrace, withMaxDuration } from './unstable-core-do-not-import/stream/utils/asyncIterable.mjs';
|
|
26
27
|
export { defaultTransformer, getDataTransformer, transformResult, transformTRPCResponse } from './unstable-core-do-not-import/transformer.mjs';
|
|
27
28
|
export { abortSignalsAnyPonyfill, assert, identity, isAsyncIterable, isFunction, isObject, mergeWithoutOverrides, noop, omitPrototype, run, sleep, unsetMarker } from './unstable-core-do-not-import/utils.mjs';
|
|
28
29
|
export { StandardSchemaV1Error } from './vendor/standard-schema-v1/error.mjs';
|
|
30
|
+
export { Unpromise } from './vendor/unpromise/unpromise.mjs';
|
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.744+972d78b51",
|
|
4
4
|
"description": "The tRPC server library",
|
|
5
5
|
"author": "KATT",
|
|
6
6
|
"license": "MIT",
|
|
@@ -152,5 +152,5 @@
|
|
|
152
152
|
"peerDependencies": {
|
|
153
153
|
"typescript": ">=5.7.2"
|
|
154
154
|
},
|
|
155
|
-
"gitHead": "
|
|
155
|
+
"gitHead": "972d78b5142405cabf3ed52db3927a9fd1b031e4"
|
|
156
156
|
}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { CombinedDataTransformer } from '../unstable-core-do-not-import';
|
|
2
2
|
import type { DefaultErrorShape, ErrorFormatter } from './error/formatter';
|
|
3
|
+
import type { JSONLProducerOptions } from './stream/jsonl';
|
|
3
4
|
import type { SSEStreamProducerOptions } from './stream/sse';
|
|
4
5
|
|
|
5
6
|
/**
|
|
@@ -79,6 +80,12 @@ export interface RootConfig<TTypes extends RootTypes> {
|
|
|
79
80
|
SSEStreamProducerOptions,
|
|
80
81
|
'ping' | 'emitAndEndImmediately' | 'maxDurationMs' | 'client'
|
|
81
82
|
>;
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Options for batch stream
|
|
86
|
+
* @see https://trpc.io/docs/client/links/httpBatchStreamLink
|
|
87
|
+
*/
|
|
88
|
+
jsonl?: Pick<JSONLProducerOptions, 'pingMs'>;
|
|
82
89
|
experimental?: {};
|
|
83
90
|
}
|
|
84
91
|
|
|
@@ -5,6 +5,7 @@ import { createDeferred } from './utils/createDeferred';
|
|
|
5
5
|
import { makeResource } from './utils/disposable';
|
|
6
6
|
import { mergeAsyncIterables } from './utils/mergeAsyncIterables';
|
|
7
7
|
import { readableStreamFrom } from './utils/readableStreamFrom';
|
|
8
|
+
import { PING_SYM, withPing } from './utils/withPing';
|
|
8
9
|
|
|
9
10
|
/**
|
|
10
11
|
* A subset of the standard ReadableStream properties needed by tRPC internally.
|
|
@@ -107,12 +108,18 @@ export type ProducerOnError = (opts: {
|
|
|
107
108
|
error: unknown;
|
|
108
109
|
path: PathArray;
|
|
109
110
|
}) => void;
|
|
110
|
-
export interface
|
|
111
|
+
export interface JSONLProducerOptions {
|
|
111
112
|
serialize?: Serialize;
|
|
112
113
|
data: Record<string, unknown> | unknown[];
|
|
113
114
|
onError?: ProducerOnError;
|
|
114
115
|
formatError?: (opts: { error: unknown; path: PathArray }) => unknown;
|
|
115
116
|
maxDepth?: number;
|
|
117
|
+
/**
|
|
118
|
+
* Interval in milliseconds to send a ping to the client to keep the connection alive
|
|
119
|
+
* This will be sent as a whitespace character
|
|
120
|
+
* @default undefined
|
|
121
|
+
*/
|
|
122
|
+
pingMs?: number;
|
|
116
123
|
}
|
|
117
124
|
|
|
118
125
|
class MaxDepthError extends Error {
|
|
@@ -122,8 +129,8 @@ class MaxDepthError extends Error {
|
|
|
122
129
|
}
|
|
123
130
|
|
|
124
131
|
async function* createBatchStreamProducer(
|
|
125
|
-
opts:
|
|
126
|
-
): AsyncIterable<Head | ChunkData, void> {
|
|
132
|
+
opts: JSONLProducerOptions,
|
|
133
|
+
): AsyncIterable<Head | ChunkData | typeof PING_SYM, void> {
|
|
127
134
|
const { data } = opts;
|
|
128
135
|
let counter = 0 as ChunkIndex;
|
|
129
136
|
const placeholder = 0 as PlaceholderValue;
|
|
@@ -251,7 +258,13 @@ async function* createBatchStreamProducer(
|
|
|
251
258
|
|
|
252
259
|
yield newHead;
|
|
253
260
|
|
|
254
|
-
|
|
261
|
+
let iterable: AsyncIterable<Head | ChunkData | typeof PING_SYM, void> =
|
|
262
|
+
mergedIterables;
|
|
263
|
+
if (opts.pingMs) {
|
|
264
|
+
iterable = withPing(mergedIterables, opts.pingMs);
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
for await (const value of iterable) {
|
|
255
268
|
yield value;
|
|
256
269
|
}
|
|
257
270
|
}
|
|
@@ -259,7 +272,7 @@ async function* createBatchStreamProducer(
|
|
|
259
272
|
* JSON Lines stream producer
|
|
260
273
|
* @see https://jsonlines.org/
|
|
261
274
|
*/
|
|
262
|
-
export function jsonlStreamProducer(opts:
|
|
275
|
+
export function jsonlStreamProducer(opts: JSONLProducerOptions) {
|
|
263
276
|
let stream = readableStreamFrom(createBatchStreamProducer(opts));
|
|
264
277
|
|
|
265
278
|
const { serialize } = opts;
|
|
@@ -267,7 +280,11 @@ export function jsonlStreamProducer(opts: ProducerOptions) {
|
|
|
267
280
|
stream = stream.pipeThrough(
|
|
268
281
|
new TransformStream({
|
|
269
282
|
transform(chunk, controller) {
|
|
270
|
-
|
|
283
|
+
if (chunk === PING_SYM) {
|
|
284
|
+
controller.enqueue(PING_SYM);
|
|
285
|
+
} else {
|
|
286
|
+
controller.enqueue(serialize(chunk));
|
|
287
|
+
}
|
|
271
288
|
},
|
|
272
289
|
}),
|
|
273
290
|
);
|
|
@@ -277,7 +294,11 @@ export function jsonlStreamProducer(opts: ProducerOptions) {
|
|
|
277
294
|
.pipeThrough(
|
|
278
295
|
new TransformStream({
|
|
279
296
|
transform(chunk, controller) {
|
|
280
|
-
|
|
297
|
+
if (chunk === PING_SYM) {
|
|
298
|
+
controller.enqueue(' ');
|
|
299
|
+
} else {
|
|
300
|
+
controller.enqueue(JSON.stringify(chunk) + '\n');
|
|
301
|
+
}
|
|
281
302
|
},
|
|
282
303
|
}),
|
|
283
304
|
)
|
|
@@ -37,8 +37,10 @@ export * from './unstable-core-do-not-import/stream/sse';
|
|
|
37
37
|
export * from './unstable-core-do-not-import/stream/tracked';
|
|
38
38
|
export * from './unstable-core-do-not-import/stream/utils/createDeferred';
|
|
39
39
|
export * from './unstable-core-do-not-import/stream/utils/disposable';
|
|
40
|
+
export * from './unstable-core-do-not-import/stream/utils/asyncIterable';
|
|
40
41
|
export * from './unstable-core-do-not-import/transformer';
|
|
41
42
|
export * from './unstable-core-do-not-import/types';
|
|
42
43
|
export * from './unstable-core-do-not-import/utils';
|
|
43
44
|
export * from './vendor/standard-schema-v1/error';
|
|
44
45
|
export * from './vendor/standard-schema-v1/spec';
|
|
46
|
+
export * from './vendor/unpromise';
|