@trpc/server 11.0.0-rc.432 → 11.0.0-rc.435

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.
Files changed (44) hide show
  1. package/dist/@trpc/server/http.d.ts +1 -2
  2. package/dist/@trpc/server/http.d.ts.map +1 -1
  3. package/dist/@trpc/server/rpc.d.ts +1 -1
  4. package/dist/@trpc/server/rpc.d.ts.map +1 -1
  5. package/dist/adapters/next.js +1 -1
  6. package/dist/adapters/next.mjs +1 -1
  7. package/dist/adapters/ws.d.ts +2 -2
  8. package/dist/adapters/ws.d.ts.map +1 -1
  9. package/dist/adapters/ws.js +76 -35
  10. package/dist/adapters/ws.mjs +77 -36
  11. package/dist/bundle-analysis.json +82 -62
  12. package/dist/http.js +3 -0
  13. package/dist/http.mjs +1 -0
  14. package/dist/index.js +2 -2
  15. package/dist/index.mjs +1 -1
  16. package/dist/unstable-core-do-not-import/http/contentType.d.ts.map +1 -1
  17. package/dist/unstable-core-do-not-import/http/contentType.js +8 -3
  18. package/dist/unstable-core-do-not-import/http/contentType.mjs +8 -3
  19. package/dist/unstable-core-do-not-import/http/parseConnectionParams.d.ts +4 -0
  20. package/dist/unstable-core-do-not-import/http/parseConnectionParams.d.ts.map +1 -0
  21. package/dist/unstable-core-do-not-import/http/parseConnectionParams.js +42 -0
  22. package/dist/unstable-core-do-not-import/http/parseConnectionParams.mjs +39 -0
  23. package/dist/unstable-core-do-not-import/http/resolveResponse.d.ts.map +1 -1
  24. package/dist/unstable-core-do-not-import/http/types.d.ts +9 -14
  25. package/dist/unstable-core-do-not-import/http/types.d.ts.map +1 -1
  26. package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts +7 -0
  27. package/dist/unstable-core-do-not-import/rpc/envelopes.d.ts.map +1 -1
  28. package/dist/unstable-core-do-not-import/rpc/index.d.ts +1 -1
  29. package/dist/unstable-core-do-not-import/rpc/index.d.ts.map +1 -1
  30. package/dist/unstable-core-do-not-import.d.ts +4 -3
  31. package/dist/unstable-core-do-not-import.d.ts.map +1 -1
  32. package/dist/unstable-core-do-not-import.js +16 -13
  33. package/dist/unstable-core-do-not-import.mjs +4 -3
  34. package/package.json +2 -2
  35. package/src/@trpc/server/http.ts +7 -2
  36. package/src/@trpc/server/rpc.ts +1 -0
  37. package/src/adapters/ws.ts +95 -35
  38. package/src/unstable-core-do-not-import/http/contentType.ts +12 -7
  39. package/src/unstable-core-do-not-import/http/parseConnectionParams.ts +49 -0
  40. package/src/unstable-core-do-not-import/http/resolveResponse.ts +8 -6
  41. package/src/unstable-core-do-not-import/http/types.ts +9 -17
  42. package/src/unstable-core-do-not-import/rpc/envelopes.ts +9 -0
  43. package/src/unstable-core-do-not-import/rpc/index.ts +1 -0
  44. package/src/unstable-core-do-not-import.ts +4 -3
@@ -1,12 +1,12 @@
1
1
  {
2
- "bundleSize": 125989,
3
- "bundleOrigSize": 175377,
4
- "bundleReduction": 28.16,
2
+ "bundleSize": 129344,
3
+ "bundleOrigSize": 179000,
4
+ "bundleReduction": 27.74,
5
5
  "modules": [
6
6
  {
7
7
  "id": "/src/unstable-core-do-not-import/http/resolveResponse.ts",
8
8
  "size": 17074,
9
- "origSize": 16189,
9
+ "origSize": 16227,
10
10
  "renderedExports": [
11
11
  "resolveResponse"
12
12
  ],
@@ -14,7 +14,7 @@
14
14
  "dependents": [
15
15
  "/src/unstable-core-do-not-import.ts"
16
16
  ],
17
- "percent": 13.55,
17
+ "percent": 13.2,
18
18
  "reduction": 0
19
19
  },
20
20
  {
@@ -31,13 +31,13 @@
31
31
  "/src/unstable-core-do-not-import.ts",
32
32
  "/src/unstable-core-do-not-import/http/resolveResponse.ts"
33
33
  ],
34
- "percent": 12.44,
34
+ "percent": 12.12,
35
35
  "reduction": 6.72
36
36
  },
37
37
  {
38
38
  "id": "/src/adapters/ws.ts",
39
- "size": 12318,
40
- "origSize": 11607,
39
+ "size": 14274,
40
+ "origSize": 13514,
41
41
  "renderedExports": [
42
42
  "getWSConnectionHandler",
43
43
  "applyWSSHandler"
@@ -46,13 +46,13 @@
46
46
  "dependents": [
47
47
  "/src/adapters/fastify/fastifyTRPCPlugin.ts"
48
48
  ],
49
- "percent": 9.78,
49
+ "percent": 11.04,
50
50
  "reduction": 0
51
51
  },
52
52
  {
53
53
  "id": "/src/unstable-core-do-not-import/http/contentType.ts",
54
- "size": 7297,
55
- "origSize": 7226,
54
+ "size": 7592,
55
+ "origSize": 7530,
56
56
  "renderedExports": [
57
57
  "getRequestInfo"
58
58
  ],
@@ -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.79,
64
+ "percent": 5.87,
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": 5.06,
82
+ "percent": 4.93,
83
83
  "reduction": 39.72
84
84
  },
85
85
  {
@@ -94,7 +94,7 @@
94
94
  "/src/unstable-core-do-not-import.ts",
95
95
  "/src/unstable-core-do-not-import/initTRPC.ts"
96
96
  ],
97
- "percent": 5.02,
97
+ "percent": 4.89,
98
98
  "reduction": 60.06
99
99
  },
100
100
  {
@@ -113,7 +113,7 @@
113
113
  "/src/unstable-core-do-not-import.ts",
114
114
  "/src/unstable-core-do-not-import/http/resolveResponse.ts"
115
115
  ],
116
- "percent": 4.47,
116
+ "percent": 4.36,
117
117
  "reduction": 24.48
118
118
  },
119
119
  {
@@ -127,7 +127,7 @@
127
127
  "dependents": [
128
128
  "/src/adapters/aws-lambda/index.ts"
129
129
  ],
130
- "percent": 4.3,
130
+ "percent": 4.19,
131
131
  "reduction": 11.38
132
132
  },
133
133
  {
@@ -147,7 +147,7 @@
147
147
  "/src/unstable-core-do-not-import/http/resolveResponse.ts",
148
148
  "/src/observable/operators.ts"
149
149
  ],
150
- "percent": 3.56,
150
+ "percent": 3.47,
151
151
  "reduction": 0
152
152
  },
153
153
  {
@@ -161,7 +161,7 @@
161
161
  "dependents": [
162
162
  "/src/adapters/next-app-dir.ts"
163
163
  ],
164
- "percent": 2.49,
164
+ "percent": 2.42,
165
165
  "reduction": 22.27
166
166
  },
167
167
  {
@@ -177,7 +177,7 @@
177
177
  "dependents": [
178
178
  "/src/observable/index.ts"
179
179
  ],
180
- "percent": 2.19,
180
+ "percent": 2.13,
181
181
  "reduction": 0
182
182
  },
183
183
  {
@@ -197,7 +197,7 @@
197
197
  "/src/unstable-core-do-not-import/initTRPC.ts",
198
198
  "/src/unstable-core-do-not-import/router.ts"
199
199
  ],
200
- "percent": 2.18,
200
+ "percent": 2.12,
201
201
  "reduction": 45.94
202
202
  },
203
203
  {
@@ -211,7 +211,7 @@
211
211
  "dependents": [
212
212
  "/src/unstable-core-do-not-import.ts"
213
213
  ],
214
- "percent": 2.15,
214
+ "percent": 2.09,
215
215
  "reduction": 40.91
216
216
  },
217
217
  {
@@ -225,7 +225,7 @@
225
225
  "dependents": [
226
226
  "/src/adapters/node-http/index.ts"
227
227
  ],
228
- "percent": 2.13,
228
+ "percent": 2.07,
229
229
  "reduction": 7.33
230
230
  },
231
231
  {
@@ -245,7 +245,7 @@
245
245
  "/src/unstable-core-do-not-import/initTRPC.ts",
246
246
  "/src/unstable-core-do-not-import/procedureBuilder.ts"
247
247
  ],
248
- "percent": 2.09,
248
+ "percent": 2.03,
249
249
  "reduction": 55.5
250
250
  },
251
251
  {
@@ -259,7 +259,7 @@
259
259
  "dependents": [
260
260
  "/src/adapters/fetch/index.ts"
261
261
  ],
262
- "percent": 1.79,
262
+ "percent": 1.74,
263
263
  "reduction": 2.17
264
264
  },
265
265
  {
@@ -274,7 +274,7 @@
274
274
  "/src/adapters/node-http/index.ts",
275
275
  "/src/adapters/node-http/nodeHTTPRequestHandler.ts"
276
276
  ],
277
- "percent": 1.74,
277
+ "percent": 1.7,
278
278
  "reduction": 13.79
279
279
  },
280
280
  {
@@ -290,7 +290,7 @@
290
290
  "/src/unstable-core-do-not-import.ts",
291
291
  "/src/unstable-core-do-not-import/router.ts"
292
292
  ],
293
- "percent": 1.71,
293
+ "percent": 1.67,
294
294
  "reduction": 0
295
295
  },
296
296
  {
@@ -304,7 +304,7 @@
304
304
  "dependents": [
305
305
  "/src/adapters/next-app-dir/nextAppDirCaller.ts"
306
306
  ],
307
- "percent": 1.63,
307
+ "percent": 1.58,
308
308
  "reduction": 5.79
309
309
  },
310
310
  {
@@ -319,6 +319,7 @@
319
319
  "removedExports": [],
320
320
  "dependents": [
321
321
  "/src/unstable-core-do-not-import.ts",
322
+ "/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
322
323
  "/src/unstable-core-do-not-import/http/resolveResponse.ts",
323
324
  "/src/unstable-core-do-not-import/stream/sse.ts",
324
325
  "/src/unstable-core-do-not-import/middleware.ts",
@@ -327,7 +328,7 @@
327
328
  "/src/unstable-core-do-not-import/procedureBuilder.ts",
328
329
  "/src/unstable-core-do-not-import/stream/jsonl.ts"
329
330
  ],
330
- "percent": 1.38,
331
+ "percent": 1.34,
331
332
  "reduction": 19.47
332
333
  },
333
334
  {
@@ -339,7 +340,7 @@
339
340
  ],
340
341
  "removedExports": [],
341
342
  "dependents": [],
342
- "percent": 1.25,
343
+ "percent": 1.22,
343
344
  "reduction": 21.04
344
345
  },
345
346
  {
@@ -351,7 +352,7 @@
351
352
  ],
352
353
  "removedExports": [],
353
354
  "dependents": [],
354
- "percent": 1.22,
355
+ "percent": 1.19,
355
356
  "reduction": 26.94
356
357
  },
357
358
  {
@@ -364,7 +365,7 @@
364
365
  ],
365
366
  "removedExports": [],
366
367
  "dependents": [],
367
- "percent": 1.21,
368
+ "percent": 1.18,
368
369
  "reduction": 27.6
369
370
  },
370
371
  {
@@ -378,7 +379,7 @@
378
379
  "dependents": [
379
380
  "/src/adapters/fastify/index.ts"
380
381
  ],
381
- "percent": 1.19,
382
+ "percent": 1.16,
382
383
  "reduction": 34.7
383
384
  },
384
385
  {
@@ -395,7 +396,7 @@
395
396
  "/src/unstable-core-do-not-import/http/resolveResponse.ts",
396
397
  "/src/unstable-core-do-not-import/error/getErrorShape.ts"
397
398
  ],
398
- "percent": 1,
399
+ "percent": 0.98,
399
400
  "reduction": 23.5
400
401
  },
401
402
  {
@@ -414,18 +415,19 @@
414
415
  "removedExports": [],
415
416
  "dependents": [
416
417
  "/src/unstable-core-do-not-import.ts",
418
+ "/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
417
419
  "/src/unstable-core-do-not-import/http/resolveResponse.ts",
418
- "/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
419
420
  "/src/unstable-core-do-not-import/error/TRPCError.ts",
420
421
  "/src/unstable-core-do-not-import/stream/sse.ts",
421
422
  "/src/unstable-core-do-not-import/transformer.ts",
422
423
  "/src/unstable-core-do-not-import/middleware.ts",
423
424
  "/src/unstable-core-do-not-import/router.ts",
425
+ "/src/unstable-core-do-not-import/rpc/parseTRPCMessage.ts",
424
426
  "/src/unstable-core-do-not-import/http/contentType.ts",
425
427
  "/src/unstable-core-do-not-import/procedureBuilder.ts",
426
428
  "/src/unstable-core-do-not-import/stream/jsonl.ts"
427
429
  ],
428
- "percent": 0.95,
430
+ "percent": 0.93,
429
431
  "reduction": 28.12
430
432
  },
431
433
  {
@@ -440,9 +442,25 @@
440
442
  "/src/adapters/fastify/index.ts",
441
443
  "/src/adapters/fastify/fastifyTRPCPlugin.ts"
442
444
  ],
443
- "percent": 0.9,
445
+ "percent": 0.88,
444
446
  "reduction": 47.59
445
447
  },
448
+ {
449
+ "id": "/src/unstable-core-do-not-import/http/parseConnectionParams.ts",
450
+ "size": 1104,
451
+ "origSize": 1300,
452
+ "renderedExports": [
453
+ "parseConnectionParamsFromUnknown",
454
+ "parseConnectionParamsFromString"
455
+ ],
456
+ "removedExports": [],
457
+ "dependents": [
458
+ "/src/unstable-core-do-not-import.ts",
459
+ "/src/unstable-core-do-not-import/http/contentType.ts"
460
+ ],
461
+ "percent": 0.85,
462
+ "reduction": 15.08
463
+ },
446
464
  {
447
465
  "id": "/src/unstable-core-do-not-import/parser.ts",
448
466
  "size": 1034,
@@ -455,7 +473,7 @@
455
473
  "/src/unstable-core-do-not-import.ts",
456
474
  "/src/unstable-core-do-not-import/procedureBuilder.ts"
457
475
  ],
458
- "percent": 0.82,
476
+ "percent": 0.8,
459
477
  "reduction": 58.57
460
478
  },
461
479
  {
@@ -472,7 +490,7 @@
472
490
  "/src/adapters/next-app-dir/nextAppDirCaller.ts",
473
491
  "/src/adapters/next-app-dir/rethrowNextErrors.ts"
474
492
  ],
475
- "percent": 0.78,
493
+ "percent": 0.76,
476
494
  "reduction": 13.65
477
495
  },
478
496
  {
@@ -489,7 +507,7 @@
489
507
  "/src/unstable-core-do-not-import/stream/jsonl.ts",
490
508
  "/src/unstable-core-do-not-import/stream/utils/createReadableStream.ts"
491
509
  ],
492
- "percent": 0.78,
510
+ "percent": 0.76,
493
511
  "reduction": 15.69
494
512
  },
495
513
  {
@@ -503,7 +521,7 @@
503
521
  "dependents": [
504
522
  "/src/adapters/next-app-dir/nextAppDirCaller.ts"
505
523
  ],
506
- "percent": 0.65,
524
+ "percent": 0.63,
507
525
  "reduction": 0.97
508
526
  },
509
527
  {
@@ -515,7 +533,7 @@
515
533
  ],
516
534
  "removedExports": [],
517
535
  "dependents": [],
518
- "percent": 0.6,
536
+ "percent": 0.59,
519
537
  "reduction": 66.9
520
538
  },
521
539
  {
@@ -529,7 +547,7 @@
529
547
  "dependents": [
530
548
  "/src/unstable-core-do-not-import.ts"
531
549
  ],
532
- "percent": 0.53,
550
+ "percent": 0.52,
533
551
  "reduction": 0.6
534
552
  },
535
553
  {
@@ -544,7 +562,7 @@
544
562
  "/src/unstable-core-do-not-import.ts",
545
563
  "/src/unstable-core-do-not-import/http/resolveResponse.ts"
546
564
  ],
547
- "percent": 0.5,
565
+ "percent": 0.48,
548
566
  "reduction": 43.49
549
567
  },
550
568
  {
@@ -559,7 +577,7 @@
559
577
  "/src/unstable-core-do-not-import/stream/sse.ts",
560
578
  "/src/unstable-core-do-not-import/stream/jsonl.ts"
561
579
  ],
562
- "percent": 0.46,
580
+ "percent": 0.44,
563
581
  "reduction": 17.15
564
582
  },
565
583
  {
@@ -572,7 +590,7 @@
572
590
  ],
573
591
  "removedExports": [],
574
592
  "dependents": [],
575
- "percent": 0.41,
593
+ "percent": 0.4,
576
594
  "reduction": 67.09
577
595
  },
578
596
  {
@@ -613,7 +631,7 @@
613
631
  "dependents": [
614
632
  "/src/unstable-core-do-not-import.ts"
615
633
  ],
616
- "percent": 0.22,
634
+ "percent": 0.21,
617
635
  "reduction": 68.45
618
636
  },
619
637
  {
@@ -627,7 +645,7 @@
627
645
  "dependents": [
628
646
  "/src/unstable-core-do-not-import.ts"
629
647
  ],
630
- "percent": 0.18,
648
+ "percent": 0.17,
631
649
  "reduction": 94.55
632
650
  },
633
651
  {
@@ -655,7 +673,7 @@
655
673
  "dependents": [
656
674
  "/src/unstable-core-do-not-import.ts"
657
675
  ],
658
- "percent": 0.13,
676
+ "percent": 0.12,
659
677
  "reduction": 14.13
660
678
  },
661
679
  {
@@ -695,14 +713,16 @@
695
713
  "origSize": 37,
696
714
  "renderedExports": [],
697
715
  "removedExports": [],
698
- "dependents": [],
716
+ "dependents": [
717
+ "/src/adapters/ws.ts"
718
+ ],
699
719
  "percent": 0,
700
720
  "reduction": 100
701
721
  },
702
722
  {
703
- "id": "/src/rpc.ts",
723
+ "id": "/src/index.ts",
704
724
  "size": 0,
705
- "origSize": 36,
725
+ "origSize": 32,
706
726
  "renderedExports": [],
707
727
  "removedExports": [],
708
728
  "dependents": [],
@@ -710,9 +730,9 @@
710
730
  "reduction": 100
711
731
  },
712
732
  {
713
- "id": "/src/index.ts",
733
+ "id": "/src/rpc.ts",
714
734
  "size": 0,
715
- "origSize": 32,
735
+ "origSize": 36,
716
736
  "renderedExports": [],
717
737
  "removedExports": [],
718
738
  "dependents": [],
@@ -720,24 +740,24 @@
720
740
  "reduction": 100
721
741
  },
722
742
  {
723
- "id": "/src/unstable-core-do-not-import.ts",
743
+ "id": "/src/shared.ts",
724
744
  "size": 0,
725
- "origSize": 2026,
745
+ "origSize": 653,
726
746
  "renderedExports": [],
727
747
  "removedExports": [],
728
- "dependents": [
729
- "/src/adapters/ws.ts"
730
- ],
748
+ "dependents": [],
731
749
  "percent": 0,
732
750
  "reduction": 100
733
751
  },
734
752
  {
735
- "id": "/src/shared.ts",
753
+ "id": "/src/unstable-core-do-not-import.ts",
736
754
  "size": 0,
737
- "origSize": 653,
755
+ "origSize": 2100,
738
756
  "renderedExports": [],
739
757
  "removedExports": [],
740
- "dependents": [],
758
+ "dependents": [
759
+ "/src/adapters/ws.ts"
760
+ ],
741
761
  "percent": 0,
742
762
  "reduction": 100
743
763
  },
@@ -799,5 +819,5 @@
799
819
  "reduction": 100
800
820
  }
801
821
  ],
802
- "moduleCount": 54
822
+ "moduleCount": 55
803
823
  }
package/dist/http.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  var getHTTPStatusCode = require('./unstable-core-do-not-import/http/getHTTPStatusCode.js');
4
4
  var batchStreamFormatter = require('./unstable-core-do-not-import/http/batchStreamFormatter.js');
5
+ var parseConnectionParams = require('./unstable-core-do-not-import/http/parseConnectionParams.js');
5
6
  var contentTypeParsers = require('./unstable-core-do-not-import/http/contentTypeParsers.js');
6
7
  var resolveResponse = require('./unstable-core-do-not-import/http/resolveResponse.js');
7
8
  var toURL = require('./unstable-core-do-not-import/http/toURL.js');
@@ -12,6 +13,8 @@ require('./unstable-core-do-not-import/rootConfig.js');
12
13
  exports.getHTTPStatusCode = getHTTPStatusCode.getHTTPStatusCode;
13
14
  exports.getHTTPStatusCodeFromError = getHTTPStatusCode.getHTTPStatusCodeFromError;
14
15
  exports.getBatchStreamFormatter = batchStreamFormatter.getBatchStreamFormatter;
16
+ exports.parseConnectionParamsFromString = parseConnectionParams.parseConnectionParamsFromString;
17
+ exports.parseConnectionParamsFromUnknown = parseConnectionParams.parseConnectionParamsFromUnknown;
15
18
  exports.octetInputParser = contentTypeParsers.octetInputParser;
16
19
  exports.resolveResponse = resolveResponse.resolveResponse;
17
20
  exports.toURL = toURL.toURL;
package/dist/http.mjs CHANGED
@@ -1,5 +1,6 @@
1
1
  export { getHTTPStatusCode, getHTTPStatusCodeFromError } from './unstable-core-do-not-import/http/getHTTPStatusCode.mjs';
2
2
  export { getBatchStreamFormatter } from './unstable-core-do-not-import/http/batchStreamFormatter.mjs';
3
+ export { parseConnectionParamsFromString, parseConnectionParamsFromUnknown } from './unstable-core-do-not-import/http/parseConnectionParams.mjs';
3
4
  export { octetInputParser } from './unstable-core-do-not-import/http/contentTypeParsers.mjs';
4
5
  export { resolveResponse } from './unstable-core-do-not-import/http/resolveResponse.mjs';
5
6
  export { toURL } from './unstable-core-do-not-import/http/toURL.mjs';
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var createProxy = require('./unstable-core-do-not-import/createProxy.js');
4
- var TRPCError = require('./unstable-core-do-not-import/error/TRPCError.js');
5
4
  var getErrorShape = require('./unstable-core-do-not-import/error/getErrorShape.js');
5
+ var TRPCError = require('./unstable-core-do-not-import/error/TRPCError.js');
6
6
  var sse = require('./unstable-core-do-not-import/stream/sse.js');
7
7
  var transformer = require('./unstable-core-do-not-import/transformer.js');
8
8
  var initTRPC = require('./unstable-core-do-not-import/initTRPC.js');
@@ -13,9 +13,9 @@ var router = require('./unstable-core-do-not-import/router.js');
13
13
 
14
14
 
15
15
  exports.createTRPCFlatProxy = createProxy.createFlatProxy;
16
+ exports.getErrorShape = getErrorShape.getErrorShape;
16
17
  exports.TRPCError = TRPCError.TRPCError;
17
18
  exports.getTRPCErrorFromUnknown = TRPCError.getTRPCErrorFromUnknown;
18
- exports.getErrorShape = getErrorShape.getErrorShape;
19
19
  exports.sse = sse.sse;
20
20
  exports.transformTRPCResponse = transformer.transformTRPCResponse;
21
21
  exports.initTRPC = initTRPC.initTRPC;
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  export { createFlatProxy as createTRPCFlatProxy } from './unstable-core-do-not-import/createProxy.mjs';
2
- export { TRPCError, getTRPCErrorFromUnknown } from './unstable-core-do-not-import/error/TRPCError.mjs';
3
2
  export { getErrorShape } from './unstable-core-do-not-import/error/getErrorShape.mjs';
3
+ export { TRPCError, getTRPCErrorFromUnknown } from './unstable-core-do-not-import/error/TRPCError.mjs';
4
4
  export { sse } from './unstable-core-do-not-import/stream/sse.mjs';
5
5
  export { transformTRPCResponse } from './unstable-core-do-not-import/transformer.mjs';
6
6
  export { initTRPC } from './unstable-core-do-not-import/initTRPC.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"contentType.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/contentType.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,OAAO,KAAK,EAEV,eAAe,EAEhB,MAAM,SAAS,CAAC;AAEjB,KAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,OAAO,CAAC;IACb,YAAY,EAAE,eAAe,CAAC;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,SAAS,CAAC;CACnB,CAAC;AA6PF,wBAAgB,cAAc,CAAC,IAAI,EAAE,qBAAqB,GAAG,eAAe,CAG3E"}
1
+ {"version":3,"file":"contentType.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/contentType.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAG3C,OAAO,KAAK,EAAoB,eAAe,EAAE,MAAM,SAAS,CAAC;AAEjE,KAAK,qBAAqB,GAAG;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,OAAO,CAAC;IACb,YAAY,EAAE,eAAe,CAAC;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,MAAM,EAAE,SAAS,CAAC;CACnB,CAAC;AAqQF,wBAAgB,cAAc,CAAC,IAAI,EAAE,qBAAqB,GAAG,eAAe,CAG3E"}
@@ -2,6 +2,7 @@
2
2
 
3
3
  var TRPCError = require('../error/TRPCError.js');
4
4
  var utils = require('../utils.js');
5
+ var parseConnectionParams = require('./parseConnectionParams.js');
5
6
 
6
7
  /**
7
8
  * Memoize a function that takes no arguments
@@ -121,11 +122,13 @@ const jsonContentTypeHandler = {
121
122
  });
122
123
  }
123
124
  const type = types.values().next().value ?? 'unknown';
125
+ const connectionParamsStr = opts.searchParams.get('connectionParams');
124
126
  const info = {
125
127
  isBatchCall,
126
128
  accept: req.headers.get('trpc-accept'),
127
129
  calls,
128
- type
130
+ type,
131
+ connectionParams: connectionParamsStr === null ? null : parseConnectionParams.parseConnectionParamsFromString(connectionParamsStr)
129
132
  };
130
133
  return info;
131
134
  }
@@ -157,7 +160,8 @@ const formDataContentTypeHandler = {
157
160
  }
158
161
  ],
159
162
  isBatchCall: false,
160
- type: 'mutation'
163
+ type: 'mutation',
164
+ connectionParams: null
161
165
  };
162
166
  }
163
167
  };
@@ -187,7 +191,8 @@ const octetStreamContentTypeHandler = {
187
191
  ],
188
192
  isBatchCall: false,
189
193
  accept: null,
190
- type: 'mutation'
194
+ type: 'mutation',
195
+ connectionParams: null
191
196
  };
192
197
  }
193
198
  };
@@ -1,5 +1,6 @@
1
1
  import { TRPCError } from '../error/TRPCError.mjs';
2
2
  import { isObject, unsetMarker } from '../utils.mjs';
3
+ import { parseConnectionParamsFromString } from './parseConnectionParams.mjs';
3
4
 
4
5
  /**
5
6
  * Memoize a function that takes no arguments
@@ -119,11 +120,13 @@ const jsonContentTypeHandler = {
119
120
  });
120
121
  }
121
122
  const type = types.values().next().value ?? 'unknown';
123
+ const connectionParamsStr = opts.searchParams.get('connectionParams');
122
124
  const info = {
123
125
  isBatchCall,
124
126
  accept: req.headers.get('trpc-accept'),
125
127
  calls,
126
- type
128
+ type,
129
+ connectionParams: connectionParamsStr === null ? null : parseConnectionParamsFromString(connectionParamsStr)
127
130
  };
128
131
  return info;
129
132
  }
@@ -155,7 +158,8 @@ const formDataContentTypeHandler = {
155
158
  }
156
159
  ],
157
160
  isBatchCall: false,
158
- type: 'mutation'
161
+ type: 'mutation',
162
+ connectionParams: null
159
163
  };
160
164
  }
161
165
  };
@@ -185,7 +189,8 @@ const octetStreamContentTypeHandler = {
185
189
  ],
186
190
  isBatchCall: false,
187
191
  accept: null,
188
- type: 'mutation'
192
+ type: 'mutation',
193
+ connectionParams: null
189
194
  };
190
195
  }
191
196
  };
@@ -0,0 +1,4 @@
1
+ import type { TRPCRequestInfo } from './types';
2
+ export declare function parseConnectionParamsFromUnknown(parsed: unknown): TRPCRequestInfo['connectionParams'];
3
+ export declare function parseConnectionParamsFromString(str: string): TRPCRequestInfo['connectionParams'];
4
+ //# sourceMappingURL=parseConnectionParams.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parseConnectionParams.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/parseConnectionParams.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,SAAS,CAAC;AAE/C,wBAAgB,gCAAgC,CAC9C,MAAM,EAAE,OAAO,GACd,eAAe,CAAC,kBAAkB,CAAC,CA2BrC;AACD,wBAAgB,+BAA+B,CAC7C,GAAG,EAAE,MAAM,GACV,eAAe,CAAC,kBAAkB,CAAC,CAYrC"}
@@ -0,0 +1,42 @@
1
+ 'use strict';
2
+
3
+ var TRPCError = require('../error/TRPCError.js');
4
+ var utils = require('../utils.js');
5
+
6
+ function parseConnectionParamsFromUnknown(parsed) {
7
+ try {
8
+ if (parsed === null) {
9
+ return null;
10
+ }
11
+ if (!utils.isObject(parsed)) {
12
+ throw new Error('Expected object');
13
+ }
14
+ const nonStringValues = Object.entries(parsed).filter(([_key, value])=>typeof value !== 'string');
15
+ if (nonStringValues.length > 0) {
16
+ throw new Error(`Expected connectionParams to be string values. Got ${nonStringValues.map(([key, value])=>`${key}: ${typeof value}`).join(', ')}`);
17
+ }
18
+ return parsed;
19
+ } catch (cause) {
20
+ throw new TRPCError.TRPCError({
21
+ code: 'PARSE_ERROR',
22
+ message: 'Invalid connection params shape',
23
+ cause
24
+ });
25
+ }
26
+ }
27
+ function parseConnectionParamsFromString(str) {
28
+ let parsed;
29
+ try {
30
+ parsed = JSON.parse(str);
31
+ } catch (cause) {
32
+ throw new TRPCError.TRPCError({
33
+ code: 'PARSE_ERROR',
34
+ message: 'Not JSON-parsable query params',
35
+ cause
36
+ });
37
+ }
38
+ return parseConnectionParamsFromUnknown(parsed);
39
+ }
40
+
41
+ exports.parseConnectionParamsFromString = parseConnectionParamsFromString;
42
+ exports.parseConnectionParamsFromUnknown = parseConnectionParamsFromUnknown;