@trpc/server 11.0.0-rc.444 → 11.0.0-rc.446

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 (30) hide show
  1. package/dist/adapters/next-app-dir/nextAppDirCaller.d.ts.map +1 -1
  2. package/dist/adapters/next-app-dir/nextAppDirCaller.js +1 -1
  3. package/dist/adapters/next-app-dir/nextAppDirCaller.mjs +1 -1
  4. package/dist/adapters/ws.js +1 -1
  5. package/dist/adapters/ws.mjs +1 -1
  6. package/dist/bundle-analysis.json +84 -83
  7. package/dist/unstable-core-do-not-import/createProxy.d.ts +2 -2
  8. package/dist/unstable-core-do-not-import/createProxy.d.ts.map +1 -1
  9. package/dist/unstable-core-do-not-import/createProxy.js +15 -5
  10. package/dist/unstable-core-do-not-import/createProxy.mjs +15 -5
  11. package/dist/unstable-core-do-not-import/http/formDataToObject.d.ts.map +1 -0
  12. package/dist/unstable-core-do-not-import/http/formDataToObject.js +40 -0
  13. package/dist/unstable-core-do-not-import/http/formDataToObject.mjs +38 -0
  14. package/dist/unstable-core-do-not-import/http/types.d.ts +1 -1
  15. package/dist/unstable-core-do-not-import/http/types.d.ts.map +1 -1
  16. package/dist/unstable-core-do-not-import.d.ts +2 -1
  17. package/dist/unstable-core-do-not-import.d.ts.map +1 -1
  18. package/dist/unstable-core-do-not-import.js +5 -3
  19. package/dist/unstable-core-do-not-import.mjs +2 -1
  20. package/package.json +2 -2
  21. package/src/adapters/next-app-dir/nextAppDirCaller.ts +2 -1
  22. package/src/unstable-core-do-not-import/createProxy.ts +18 -6
  23. package/src/{adapters/next-app-dir → unstable-core-do-not-import/http}/formDataToObject.ts +18 -10
  24. package/src/unstable-core-do-not-import/http/types.ts +1 -1
  25. package/src/unstable-core-do-not-import/router.ts +1 -1
  26. package/src/unstable-core-do-not-import.ts +2 -1
  27. package/dist/adapters/next-app-dir/formDataToObject.d.ts.map +0 -1
  28. package/dist/adapters/next-app-dir/formDataToObject.js +0 -34
  29. package/dist/adapters/next-app-dir/formDataToObject.mjs +0 -32
  30. /package/dist/{adapters/next-app-dir → unstable-core-do-not-import/http}/formDataToObject.d.ts +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"nextAppDirCaller.d.ts","sourceRoot":"","sources":["../../../src/adapters/next-app-dir/nextAppDirCaller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAIhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAGvF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAC;AAGzF,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EACT,MAAM,yCAAyC,CAAC;AAKjD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,KAAK,EAC9C,MAAM,EAAE,QAAQ,CACd;IACE;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,KAAK,CAAA;KAAE,KAAK,MAAM,CAAC;IAClD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,mBAAmB,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;CACzD,GAAG,qBAAqB,CAAC,QAAQ,EAAE,MAAM,YAAY,CAAC,QAAQ,CAAC,CAAC,CAClE,GACA,cAAc,CAAC,QAAQ,CAAC,CAyF1B"}
1
+ {"version":3,"file":"nextAppDirCaller.d.ts","sourceRoot":"","sources":["../../../src/adapters/next-app-dir/nextAppDirCaller.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAMhE,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,6CAA6C,CAAC;AAGvF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,oDAAoD,CAAC;AAGzF,OAAO,KAAK,EACV,YAAY,EACZ,QAAQ,EACT,MAAM,yCAAyC,CAAC;AAIjD;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,KAAK,EAC9C,MAAM,EAAE,QAAQ,CACd;IACE;;OAEG;IACH,aAAa,CAAC,EAAE,CAAC,IAAI,EAAE;QAAE,IAAI,EAAE,KAAK,CAAA;KAAE,KAAK,MAAM,CAAC;IAClD;;;OAGG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B;;OAEG;IACH,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,mBAAmB,CAAC,QAAQ,CAAC,KAAK,IAAI,CAAC;CACzD,GAAG,qBAAqB,CAAC,QAAQ,EAAE,MAAM,YAAY,CAAC,QAAQ,CAAC,CAAC,CAClE,GACA,cAAc,CAAC,QAAQ,CAAC,CAyF1B"}
@@ -1,8 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var TRPCError = require('../../unstable-core-do-not-import/error/TRPCError.js');
4
+ var formDataToObject = require('../../unstable-core-do-not-import/http/formDataToObject.js');
4
5
  require('../../unstable-core-do-not-import/rootConfig.js');
5
- var formDataToObject = require('./formDataToObject.js');
6
6
  var redirect = require('./redirect.js');
7
7
  var rethrowNextErrors = require('./rethrowNextErrors.js');
8
8
 
@@ -1,6 +1,6 @@
1
1
  import { TRPCError, getTRPCErrorFromUnknown } from '../../unstable-core-do-not-import/error/TRPCError.mjs';
2
+ import { formDataToObject } from '../../unstable-core-do-not-import/http/formDataToObject.mjs';
2
3
  import '../../unstable-core-do-not-import/rootConfig.mjs';
3
- import { formDataToObject } from './formDataToObject.mjs';
4
4
  import { TRPCRedirectError } from './redirect.mjs';
5
5
  import { rethrowNextErrors } from './rethrowNextErrors.mjs';
6
6
 
@@ -2,8 +2,8 @@
2
2
 
3
3
  var getErrorShape = require('../unstable-core-do-not-import/error/getErrorShape.js');
4
4
  var TRPCError = require('../unstable-core-do-not-import/error/TRPCError.js');
5
- var parseConnectionParams = require('../unstable-core-do-not-import/http/parseConnectionParams.js');
6
5
  var utils = require('../unstable-core-do-not-import/utils.js');
6
+ var parseConnectionParams = require('../unstable-core-do-not-import/http/parseConnectionParams.js');
7
7
  var parseTRPCMessage = require('../unstable-core-do-not-import/rpc/parseTRPCMessage.js');
8
8
  var observable = require('../observable/observable.js');
9
9
  var transformer = require('../unstable-core-do-not-import/transformer.js');
@@ -1,7 +1,7 @@
1
1
  import { getErrorShape } from '../unstable-core-do-not-import/error/getErrorShape.mjs';
2
2
  import { TRPCError, getTRPCErrorFromUnknown } from '../unstable-core-do-not-import/error/TRPCError.mjs';
3
- import { parseConnectionParamsFromUnknown } from '../unstable-core-do-not-import/http/parseConnectionParams.mjs';
4
3
  import { run, isAsyncIterable, isObject } from '../unstable-core-do-not-import/utils.mjs';
4
+ import { parseConnectionParamsFromUnknown } from '../unstable-core-do-not-import/http/parseConnectionParams.mjs';
5
5
  import { parseTRPCMessage } from '../unstable-core-do-not-import/rpc/parseTRPCMessage.mjs';
6
6
  import { isObservable, observableToAsyncIterable } from '../observable/observable.mjs';
7
7
  import { transformTRPCResponse } from '../unstable-core-do-not-import/transformer.mjs';
@@ -1,7 +1,7 @@
1
1
  {
2
- "bundleSize": 129201,
3
- "bundleOrigSize": 178861,
4
- "bundleReduction": 27.76,
2
+ "bundleSize": 129790,
3
+ "bundleOrigSize": 179496,
4
+ "bundleReduction": 27.69,
5
5
  "modules": [
6
6
  {
7
7
  "id": "/src/unstable-core-do-not-import/http/resolveResponse.ts",
@@ -14,7 +14,7 @@
14
14
  "dependents": [
15
15
  "/src/unstable-core-do-not-import.ts"
16
16
  ],
17
- "percent": 13.22,
17
+ "percent": 13.16,
18
18
  "reduction": 0
19
19
  },
20
20
  {
@@ -31,7 +31,7 @@
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.13,
34
+ "percent": 12.08,
35
35
  "reduction": 6.72
36
36
  },
37
37
  {
@@ -46,7 +46,7 @@
46
46
  "dependents": [
47
47
  "/src/adapters/fastify/fastifyTRPCPlugin.ts"
48
48
  ],
49
- "percent": 11.05,
49
+ "percent": 11,
50
50
  "reduction": 0
51
51
  },
52
52
  {
@@ -61,13 +61,13 @@
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.88,
64
+ "percent": 5.85,
65
65
  "reduction": 0
66
66
  },
67
67
  {
68
68
  "id": "/src/unstable-core-do-not-import/router.ts",
69
69
  "size": 6381,
70
- "origSize": 10586,
70
+ "origSize": 10595,
71
71
  "renderedExports": [
72
72
  "createRouterFactory",
73
73
  "callProcedure",
@@ -79,8 +79,8 @@
79
79
  "/src/unstable-core-do-not-import.ts",
80
80
  "/src/unstable-core-do-not-import/initTRPC.ts"
81
81
  ],
82
- "percent": 4.94,
83
- "reduction": 39.72
82
+ "percent": 4.92,
83
+ "reduction": 39.77
84
84
  },
85
85
  {
86
86
  "id": "/src/unstable-core-do-not-import/procedureBuilder.ts",
@@ -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": 4.9,
97
+ "percent": 4.87,
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.36,
116
+ "percent": 4.34,
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.19,
130
+ "percent": 4.17,
131
131
  "reduction": 11.38
132
132
  },
133
133
  {
@@ -147,13 +147,13 @@
147
147
  "/src/unstable-core-do-not-import/http/resolveResponse.ts",
148
148
  "/src/observable/operators.ts"
149
149
  ],
150
- "percent": 3.47,
150
+ "percent": 3.45,
151
151
  "reduction": 0
152
152
  },
153
153
  {
154
154
  "id": "/src/adapters/next-app-dir/nextAppDirCaller.ts",
155
155
  "size": 3135,
156
- "origSize": 4033,
156
+ "origSize": 4098,
157
157
  "renderedExports": [
158
158
  "nextAppDirCaller"
159
159
  ],
@@ -161,8 +161,8 @@
161
161
  "dependents": [
162
162
  "/src/adapters/next-app-dir.ts"
163
163
  ],
164
- "percent": 2.43,
165
- "reduction": 22.27
164
+ "percent": 2.42,
165
+ "reduction": 23.5
166
166
  },
167
167
  {
168
168
  "id": "/src/observable/operators.ts",
@@ -177,7 +177,7 @@
177
177
  "dependents": [
178
178
  "/src/observable/index.ts"
179
179
  ],
180
- "percent": 2.13,
180
+ "percent": 2.12,
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.12,
200
+ "percent": 2.11,
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.09,
214
+ "percent": 2.08,
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.08,
228
+ "percent": 2.07,
229
229
  "reduction": 7.31
230
230
  },
231
231
  {
@@ -245,9 +245,25 @@
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.03,
248
+ "percent": 2.02,
249
249
  "reduction": 55.5
250
250
  },
251
+ {
252
+ "id": "/src/unstable-core-do-not-import/createProxy.ts",
253
+ "size": 2329,
254
+ "origSize": 2262,
255
+ "renderedExports": [
256
+ "createRecursiveProxy",
257
+ "createFlatProxy"
258
+ ],
259
+ "removedExports": [],
260
+ "dependents": [
261
+ "/src/unstable-core-do-not-import.ts",
262
+ "/src/unstable-core-do-not-import/router.ts"
263
+ ],
264
+ "percent": 1.79,
265
+ "reduction": 0
266
+ },
251
267
  {
252
268
  "id": "/src/adapters/fetch/fetchRequestHandler.ts",
253
269
  "size": 2255,
@@ -259,7 +275,7 @@
259
275
  "dependents": [
260
276
  "/src/adapters/fetch/index.ts"
261
277
  ],
262
- "percent": 1.75,
278
+ "percent": 1.74,
263
279
  "reduction": 2.17
264
280
  },
265
281
  {
@@ -274,7 +290,7 @@
274
290
  "/src/adapters/node-http/index.ts",
275
291
  "/src/adapters/node-http/nodeHTTPRequestHandler.ts"
276
292
  ],
277
- "percent": 1.7,
293
+ "percent": 1.69,
278
294
  "reduction": 13.79
279
295
  },
280
296
  {
@@ -288,25 +304,9 @@
288
304
  "dependents": [
289
305
  "/src/adapters/next-app-dir/nextAppDirCaller.ts"
290
306
  ],
291
- "percent": 1.59,
307
+ "percent": 1.58,
292
308
  "reduction": 5.79
293
309
  },
294
- {
295
- "id": "/src/unstable-core-do-not-import/createProxy.ts",
296
- "size": 1982,
297
- "origSize": 1991,
298
- "renderedExports": [
299
- "createRecursiveProxy",
300
- "createFlatProxy"
301
- ],
302
- "removedExports": [],
303
- "dependents": [
304
- "/src/unstable-core-do-not-import.ts",
305
- "/src/unstable-core-do-not-import/router.ts"
306
- ],
307
- "percent": 1.53,
308
- "reduction": 0.45
309
- },
310
310
  {
311
311
  "id": "/src/unstable-core-do-not-import/error/TRPCError.ts",
312
312
  "size": 1733,
@@ -365,7 +365,7 @@
365
365
  ],
366
366
  "removedExports": [],
367
367
  "dependents": [],
368
- "percent": 1.18,
368
+ "percent": 1.17,
369
369
  "reduction": 27.6
370
370
  },
371
371
  {
@@ -396,7 +396,7 @@
396
396
  "/src/unstable-core-do-not-import/http/resolveResponse.ts",
397
397
  "/src/unstable-core-do-not-import/error/getErrorShape.ts"
398
398
  ],
399
- "percent": 1,
399
+ "percent": 0.99,
400
400
  "reduction": 18.7
401
401
  },
402
402
  {
@@ -428,7 +428,7 @@
428
428
  "/src/unstable-core-do-not-import/procedureBuilder.ts",
429
429
  "/src/unstable-core-do-not-import/stream/jsonl.ts"
430
430
  ],
431
- "percent": 0.93,
431
+ "percent": 0.92,
432
432
  "reduction": 28.12
433
433
  },
434
434
  {
@@ -443,7 +443,7 @@
443
443
  "/src/adapters/fastify/index.ts",
444
444
  "/src/adapters/fastify/fastifyTRPCPlugin.ts"
445
445
  ],
446
- "percent": 0.88,
446
+ "percent": 0.87,
447
447
  "reduction": 47.59
448
448
  },
449
449
  {
@@ -462,6 +462,20 @@
462
462
  "percent": 0.85,
463
463
  "reduction": 15.08
464
464
  },
465
+ {
466
+ "id": "/src/unstable-core-do-not-import/http/formDataToObject.ts",
467
+ "size": 1060,
468
+ "origSize": 1047,
469
+ "renderedExports": [
470
+ "formDataToObject"
471
+ ],
472
+ "removedExports": [],
473
+ "dependents": [
474
+ "/src/unstable-core-do-not-import.ts"
475
+ ],
476
+ "percent": 0.82,
477
+ "reduction": 0
478
+ },
465
479
  {
466
480
  "id": "/src/unstable-core-do-not-import/parser.ts",
467
481
  "size": 1034,
@@ -511,20 +525,6 @@
511
525
  "percent": 0.76,
512
526
  "reduction": 15.69
513
527
  },
514
- {
515
- "id": "/src/adapters/next-app-dir/formDataToObject.ts",
516
- "size": 818,
517
- "origSize": 826,
518
- "renderedExports": [
519
- "formDataToObject"
520
- ],
521
- "removedExports": [],
522
- "dependents": [
523
- "/src/adapters/next-app-dir/nextAppDirCaller.ts"
524
- ],
525
- "percent": 0.63,
526
- "reduction": 0.97
527
- },
528
528
  {
529
529
  "id": "/src/adapters/aws-lambda/index.ts",
530
530
  "size": 759,
@@ -534,7 +534,7 @@
534
534
  ],
535
535
  "removedExports": [],
536
536
  "dependents": [],
537
- "percent": 0.59,
537
+ "percent": 0.58,
538
538
  "reduction": 66.9
539
539
  },
540
540
  {
@@ -548,7 +548,7 @@
548
548
  "dependents": [
549
549
  "/src/unstable-core-do-not-import.ts"
550
550
  ],
551
- "percent": 0.52,
551
+ "percent": 0.51,
552
552
  "reduction": 0.6
553
553
  },
554
554
  {
@@ -578,7 +578,7 @@
578
578
  "/src/unstable-core-do-not-import/stream/sse.ts",
579
579
  "/src/unstable-core-do-not-import/stream/jsonl.ts"
580
580
  ],
581
- "percent": 0.45,
581
+ "percent": 0.44,
582
582
  "reduction": 17.15
583
583
  },
584
584
  {
@@ -606,7 +606,7 @@
606
606
  "/src/unstable-core-do-not-import.ts",
607
607
  "/src/unstable-core-do-not-import/initTRPC.ts"
608
608
  ],
609
- "percent": 0.27,
609
+ "percent": 0.26,
610
610
  "reduction": 89.39
611
611
  },
612
612
  {
@@ -731,9 +731,9 @@
731
731
  "reduction": 100
732
732
  },
733
733
  {
734
- "id": "/src/rpc.ts",
734
+ "id": "/src/shared.ts",
735
735
  "size": 0,
736
- "origSize": 36,
736
+ "origSize": 653,
737
737
  "renderedExports": [],
738
738
  "removedExports": [],
739
739
  "dependents": [],
@@ -741,24 +741,25 @@
741
741
  "reduction": 100
742
742
  },
743
743
  {
744
- "id": "/src/unstable-core-do-not-import.ts",
744
+ "id": "/src/rpc.ts",
745
745
  "size": 0,
746
- "origSize": 2100,
746
+ "origSize": 36,
747
747
  "renderedExports": [],
748
748
  "removedExports": [],
749
- "dependents": [
750
- "/src/adapters/ws.ts"
751
- ],
749
+ "dependents": [],
752
750
  "percent": 0,
753
751
  "reduction": 100
754
752
  },
755
753
  {
756
- "id": "/src/shared.ts",
754
+ "id": "/src/unstable-core-do-not-import.ts",
757
755
  "size": 0,
758
- "origSize": 653,
756
+ "origSize": 2169,
759
757
  "renderedExports": [],
760
758
  "removedExports": [],
761
- "dependents": [],
759
+ "dependents": [
760
+ "/src/adapters/ws.ts",
761
+ "/src/adapters/next-app-dir/nextAppDirCaller.ts"
762
+ ],
762
763
  "percent": 0,
763
764
  "reduction": 100
764
765
  },
@@ -784,6 +785,16 @@
784
785
  "percent": 0,
785
786
  "reduction": 100
786
787
  },
788
+ {
789
+ "id": "/src/adapters/fetch/index.ts",
790
+ "size": 0,
791
+ "origSize": 64,
792
+ "renderedExports": [],
793
+ "removedExports": [],
794
+ "dependents": [],
795
+ "percent": 0,
796
+ "reduction": 100
797
+ },
787
798
  {
788
799
  "id": "/src/adapters/fastify/index.ts",
789
800
  "size": 0,
@@ -808,16 +819,6 @@
808
819
  ],
809
820
  "percent": 0,
810
821
  "reduction": 100
811
- },
812
- {
813
- "id": "/src/adapters/fetch/index.ts",
814
- "size": 0,
815
- "origSize": 64,
816
- "renderedExports": [],
817
- "removedExports": [],
818
- "dependents": [],
819
- "percent": 0,
820
- "reduction": 100
821
822
  }
822
823
  ],
823
824
  "moduleCount": 55
@@ -1,6 +1,6 @@
1
1
  interface ProxyCallbackOptions {
2
- path: string[];
3
- args: unknown[];
2
+ path: readonly string[];
3
+ args: readonly unknown[];
4
4
  }
5
5
  type ProxyCallback = (opts: ProxyCallbackOptions) => unknown;
6
6
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"createProxy.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/createProxy.ts"],"names":[],"mappings":"AAAA,UAAU,oBAAoB;IAC5B,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,IAAI,EAAE,OAAO,EAAE,CAAC;CACjB;AACD,KAAK,aAAa,GAAG,CAAC,IAAI,EAAE,oBAAoB,KAAK,OAAO,CAAC;AAyC7D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,KAAK,sBAC9B,aAAa,KACtB,KAAqE,CAAC;AAEzE;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,YACzB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,KAAK,KAAK,GAAG,KAC5C,KAWF,CAAC"}
1
+ {"version":3,"file":"createProxy.d.ts","sourceRoot":"","sources":["../../src/unstable-core-do-not-import/createProxy.ts"],"names":[],"mappings":"AAAA,UAAU,oBAAoB;IAC5B,IAAI,EAAE,SAAS,MAAM,EAAE,CAAC;IACxB,IAAI,EAAE,SAAS,OAAO,EAAE,CAAC;CAC1B;AACD,KAAK,aAAa,GAAG,CAAC,IAAI,EAAE,oBAAoB,KAAK,OAAO,CAAC;AAqD7D;;;;GAIG;AACH,eAAO,MAAM,oBAAoB,GAAI,KAAK,sBAC9B,aAAa,KACtB,KAAqE,CAAC;AAEzE;;;;GAIG;AACH,eAAO,MAAM,eAAe,GAAI,KAAK,YACzB,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,KAAK,KAAK,GAAG,KAC5C,KAWF,CAAC"}
@@ -1,10 +1,17 @@
1
1
  'use strict';
2
2
 
3
+ var _memo, _cacheKey;
3
4
  const noop = ()=>{
4
5
  // noop
5
6
  };
6
- function createInnerProxy(callback, path, cache) {
7
- return new Proxy(noop, {
7
+ const freezeIfAvailable = (obj)=>{
8
+ if (Object.freeze) {
9
+ Object.freeze(obj);
10
+ }
11
+ };
12
+ function createInnerProxy(callback, path, memo) {
13
+ const cacheKey = path.join('.');
14
+ (_memo = memo)[_cacheKey = cacheKey] ?? (_memo[_cacheKey] = new Proxy(noop, {
8
15
  get (_obj, key) {
9
16
  if (typeof key !== 'string' || key === 'then') {
10
17
  // special case for if the proxy is accidentally treated
@@ -14,7 +21,7 @@ function createInnerProxy(callback, path, cache) {
14
21
  return createInnerProxy(callback, [
15
22
  ...path,
16
23
  key
17
- ]);
24
+ ], memo);
18
25
  },
19
26
  apply (_1, _2, args) {
20
27
  const lastOfPath = path[path.length - 1];
@@ -36,15 +43,18 @@ function createInnerProxy(callback, path, cache) {
36
43
  path: path.slice(0, -1)
37
44
  };
38
45
  }
46
+ freezeIfAvailable(opts.args);
47
+ freezeIfAvailable(opts.path);
39
48
  return callback(opts);
40
49
  }
41
- });
50
+ }));
51
+ return memo[cacheKey];
42
52
  }
43
53
  /**
44
54
  * Creates a proxy that calls the callback with the path and arguments
45
55
  *
46
56
  * @internal
47
- */ const createRecursiveProxy = (callback)=>createInnerProxy(callback, []);
57
+ */ const createRecursiveProxy = (callback)=>createInnerProxy(callback, [], Object.create(null));
48
58
  /**
49
59
  * Used in place of `new Proxy` where each handler will map 1 level deep to another value.
50
60
  *
@@ -1,8 +1,15 @@
1
+ var _memo, _cacheKey;
1
2
  const noop = ()=>{
2
3
  // noop
3
4
  };
4
- function createInnerProxy(callback, path, cache) {
5
- return new Proxy(noop, {
5
+ const freezeIfAvailable = (obj)=>{
6
+ if (Object.freeze) {
7
+ Object.freeze(obj);
8
+ }
9
+ };
10
+ function createInnerProxy(callback, path, memo) {
11
+ const cacheKey = path.join('.');
12
+ (_memo = memo)[_cacheKey = cacheKey] ?? (_memo[_cacheKey] = new Proxy(noop, {
6
13
  get (_obj, key) {
7
14
  if (typeof key !== 'string' || key === 'then') {
8
15
  // special case for if the proxy is accidentally treated
@@ -12,7 +19,7 @@ function createInnerProxy(callback, path, cache) {
12
19
  return createInnerProxy(callback, [
13
20
  ...path,
14
21
  key
15
- ]);
22
+ ], memo);
16
23
  },
17
24
  apply (_1, _2, args) {
18
25
  const lastOfPath = path[path.length - 1];
@@ -34,15 +41,18 @@ function createInnerProxy(callback, path, cache) {
34
41
  path: path.slice(0, -1)
35
42
  };
36
43
  }
44
+ freezeIfAvailable(opts.args);
45
+ freezeIfAvailable(opts.path);
37
46
  return callback(opts);
38
47
  }
39
- });
48
+ }));
49
+ return memo[cacheKey];
40
50
  }
41
51
  /**
42
52
  * Creates a proxy that calls the callback with the path and arguments
43
53
  *
44
54
  * @internal
45
- */ const createRecursiveProxy = (callback)=>createInnerProxy(callback, []);
55
+ */ const createRecursiveProxy = (callback)=>createInnerProxy(callback, [], Object.create(null));
46
56
  /**
47
57
  * Used in place of `new Proxy` where each handler will map 1 level deep to another value.
48
58
  *
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formDataToObject.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/formDataToObject.ts"],"names":[],"mappings":"AAkCA,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,2BASlD"}
@@ -0,0 +1,40 @@
1
+ 'use strict';
2
+
3
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */ const isNumberString = (str)=>/^\d+$/.test(str);
4
+ function set(obj, path, value) {
5
+ if (path.length > 1) {
6
+ const newPath = [
7
+ ...path
8
+ ];
9
+ const key = newPath.shift();
10
+ const nextKey = newPath[0];
11
+ if (!obj[key]) {
12
+ obj[key] = isNumberString(nextKey) ? [] : {};
13
+ } else if (Array.isArray(obj[key]) && !isNumberString(nextKey)) {
14
+ obj[key] = Object.fromEntries(Object.entries(obj[key]));
15
+ }
16
+ set(obj[key], newPath, value);
17
+ return;
18
+ }
19
+ const p = path[0];
20
+ if (obj[p] === undefined) {
21
+ obj[p] = value;
22
+ } else if (Array.isArray(obj[p])) {
23
+ obj[p].push(value);
24
+ } else {
25
+ obj[p] = [
26
+ obj[p],
27
+ value
28
+ ];
29
+ }
30
+ }
31
+ function formDataToObject(formData) {
32
+ const obj = {};
33
+ for (const [key, value] of formData.entries()){
34
+ const parts = key.split(/[\.\[\]]/).filter(Boolean);
35
+ set(obj, parts, value);
36
+ }
37
+ return obj;
38
+ }
39
+
40
+ exports.formDataToObject = formDataToObject;
@@ -0,0 +1,38 @@
1
+ /* eslint-disable @typescript-eslint/no-non-null-assertion */ const isNumberString = (str)=>/^\d+$/.test(str);
2
+ function set(obj, path, value) {
3
+ if (path.length > 1) {
4
+ const newPath = [
5
+ ...path
6
+ ];
7
+ const key = newPath.shift();
8
+ const nextKey = newPath[0];
9
+ if (!obj[key]) {
10
+ obj[key] = isNumberString(nextKey) ? [] : {};
11
+ } else if (Array.isArray(obj[key]) && !isNumberString(nextKey)) {
12
+ obj[key] = Object.fromEntries(Object.entries(obj[key]));
13
+ }
14
+ set(obj[key], newPath, value);
15
+ return;
16
+ }
17
+ const p = path[0];
18
+ if (obj[p] === undefined) {
19
+ obj[p] = value;
20
+ } else if (Array.isArray(obj[p])) {
21
+ obj[p].push(value);
22
+ } else {
23
+ obj[p] = [
24
+ obj[p],
25
+ value
26
+ ];
27
+ }
28
+ }
29
+ function formDataToObject(formData) {
30
+ const obj = {};
31
+ for (const [key, value] of formData.entries()){
32
+ const parts = key.split(/[\.\[\]]/).filter(Boolean);
33
+ set(obj, parts, value);
34
+ }
35
+ return obj;
36
+ }
37
+
38
+ export { formDataToObject };
@@ -21,7 +21,7 @@ export type ResponseMetaFn<TRouter extends AnyRouter> = (opts: {
21
21
  * The different tRPC paths requested
22
22
  * @deprecated use `info` instead, this will be removed in v12
23
23
  **/
24
- paths: string[] | undefined;
24
+ paths: readonly string[] | undefined;
25
25
  info: TRPCRequestInfo | undefined;
26
26
  type: ProcedureType | 'unknown';
27
27
  errors: TRPCError[];
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/unstable-core-do-not-import/http/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AACpD,OAAO,KAAK,EACV,YAAY,EACZ,mBAAmB,EACnB,aAAa,EACd,MAAM,cAAc,CAAC;AACtB,OAAO,KAAK,EACV,SAAS,EACT,kBAAkB,EAClB,gBAAgB,EACjB,MAAM,WAAW,CAAC;AACnB,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC3C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAErC;;GAEG;AACH,KAAK,WAAW,GAAG,IAAI,CAAC,MAAM,EAAE,GAAG,MAAM,CAAC,CAAC;AAE3C,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,GAAG,WAAW,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,CAAC,OAAO,SAAS,SAAS,IAAI,CAAC,IAAI,EAAE;IAC7D,IAAI,EAAE,YAAY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AAI,CAAC;IAChC;;OAEG;IACH,IAAI,EAAE,aAAa,GAAG,SAAS,CAAC;IAChC;;OAEG;IACH,WAAW,EAAE,OAAO,CAAC;IACrB;;OAEG;IACH,KAAK,EAAE,4BAA4B,EAAE,CAAC;IACtC;;OAEG;IACH,gBAAgB,EAAE,IAAI,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC;CACvC;AAED;;;GAGG;AACH,MAAM,MAAM,kCAAkC,CAAC,OAAO,SAAS,SAAS,IACtE,CAAC,IAAI,EAAE;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,KAAK,OAAO,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC,CAAC;AAE5E,UAAU,uBAAuB,CAAC,OAAO,SAAS,SAAS,EAAE,QAAQ,CACnE,SAAQ,mBAAmB,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;IACxD,GAAG,EAAE,QAAQ,CAAC;CACf;AACD;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,OAAO,SAAS,SAAS,EAAE,QAAQ,IAAI,CAClE,IAAI,EAAE,uBAAuB,CAAC,OAAO,EAAE,QAAQ,CAAC,KAC7C,IAAI,CAAC;AAEV;;;GAGG;AACH,MAAM,WAAW,kBAAkB,CAAC,OAAO,SAAS,SAAS,EAAE,QAAQ;IACrE,OAAO,CAAC,EAAE,gBAAgB,CAAC,OAAO,EAAE,QAAQ,CAAC,CAAC;IAC9C;;OAEG;IACH,QAAQ,CAAC,EAAE;QACT;;WAEG;QACH,OAAO,EAAE,OAAO,CAAC;KAClB,CAAC;IACF,MAAM,EAAE,OAAO,CAAC;IAChB;;;OAGG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;CACzB"}
@@ -16,10 +16,11 @@ export * from './unstable-core-do-not-import/error/formatter';
16
16
  export * from './unstable-core-do-not-import/error/getErrorShape';
17
17
  export * from './unstable-core-do-not-import/error/TRPCError';
18
18
  export * from './unstable-core-do-not-import/http/batchStreamFormatter';
19
- export * from './unstable-core-do-not-import/http/parseConnectionParams';
20
19
  export * from './unstable-core-do-not-import/http/contentType';
21
20
  export * from './unstable-core-do-not-import/http/contentTypeParsers';
21
+ export * from './unstable-core-do-not-import/http/formDataToObject';
22
22
  export * from './unstable-core-do-not-import/http/getHTTPStatusCode';
23
+ export * from './unstable-core-do-not-import/http/parseConnectionParams';
23
24
  export * from './unstable-core-do-not-import/http/resolveResponse';
24
25
  export * from './unstable-core-do-not-import/http/toURL';
25
26
  export * from './unstable-core-do-not-import/http/types';
@@ -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,yDAAyD,CAAC;AACxE,cAAc,0DAA0D,CAAC;AACzE,cAAc,gDAAgD,CAAC;AAC/D,cAAc,uDAAuD,CAAC;AACtE,cAAc,sDAAsD,CAAC;AACrE,cAAc,oDAAoD,CAAC;AACnE,cAAc,0CAA0C,CAAC;AACzD,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,0CAA0C,CAAC;AACzD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,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,yDAAyD,CAAC;AACxE,cAAc,gDAAgD,CAAC;AAC/D,cAAc,uDAAuD,CAAC;AACtE,cAAc,qDAAqD,CAAC;AACpE,cAAc,sDAAsD,CAAC;AACrE,cAAc,0DAA0D,CAAC;AACzE,cAAc,oDAAoD,CAAC;AACnE,cAAc,0CAA0C,CAAC;AACzD,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,0CAA0C,CAAC;AACzD,cAAc,2CAA2C,CAAC;AAC1D,cAAc,qCAAqC,CAAC;AACpD,cAAc,qCAAqC,CAAC"}
@@ -5,10 +5,11 @@ var formatter = require('./unstable-core-do-not-import/error/formatter.js');
5
5
  var getErrorShape = require('./unstable-core-do-not-import/error/getErrorShape.js');
6
6
  var TRPCError = require('./unstable-core-do-not-import/error/TRPCError.js');
7
7
  var batchStreamFormatter = require('./unstable-core-do-not-import/http/batchStreamFormatter.js');
8
- var parseConnectionParams = require('./unstable-core-do-not-import/http/parseConnectionParams.js');
9
8
  var contentType = require('./unstable-core-do-not-import/http/contentType.js');
10
9
  var contentTypeParsers = require('./unstable-core-do-not-import/http/contentTypeParsers.js');
10
+ var formDataToObject = require('./unstable-core-do-not-import/http/formDataToObject.js');
11
11
  var getHTTPStatusCode = require('./unstable-core-do-not-import/http/getHTTPStatusCode.js');
12
+ var parseConnectionParams = require('./unstable-core-do-not-import/http/parseConnectionParams.js');
12
13
  var resolveResponse = require('./unstable-core-do-not-import/http/resolveResponse.js');
13
14
  var toURL = require('./unstable-core-do-not-import/http/toURL.js');
14
15
  var initTRPC = require('./unstable-core-do-not-import/initTRPC.js');
@@ -36,12 +37,13 @@ exports.TRPCError = TRPCError.TRPCError;
36
37
  exports.getCauseFromUnknown = TRPCError.getCauseFromUnknown;
37
38
  exports.getTRPCErrorFromUnknown = TRPCError.getTRPCErrorFromUnknown;
38
39
  exports.getBatchStreamFormatter = batchStreamFormatter.getBatchStreamFormatter;
39
- exports.parseConnectionParamsFromString = parseConnectionParams.parseConnectionParamsFromString;
40
- exports.parseConnectionParamsFromUnknown = parseConnectionParams.parseConnectionParamsFromUnknown;
41
40
  exports.getRequestInfo = contentType.getRequestInfo;
42
41
  exports.octetInputParser = contentTypeParsers.octetInputParser;
42
+ exports.formDataToObject = formDataToObject.formDataToObject;
43
43
  exports.getHTTPStatusCode = getHTTPStatusCode.getHTTPStatusCode;
44
44
  exports.getHTTPStatusCodeFromError = getHTTPStatusCode.getHTTPStatusCodeFromError;
45
+ exports.parseConnectionParamsFromString = parseConnectionParams.parseConnectionParamsFromString;
46
+ exports.parseConnectionParamsFromUnknown = parseConnectionParams.parseConnectionParamsFromUnknown;
45
47
  exports.resolveResponse = resolveResponse.resolveResponse;
46
48
  exports.toURL = toURL.toURL;
47
49
  exports.initTRPC = initTRPC.initTRPC;
@@ -3,10 +3,11 @@ export { defaultFormatter } from './unstable-core-do-not-import/error/formatter.
3
3
  export { getErrorShape } from './unstable-core-do-not-import/error/getErrorShape.mjs';
4
4
  export { TRPCError, getCauseFromUnknown, getTRPCErrorFromUnknown } from './unstable-core-do-not-import/error/TRPCError.mjs';
5
5
  export { getBatchStreamFormatter } from './unstable-core-do-not-import/http/batchStreamFormatter.mjs';
6
- export { parseConnectionParamsFromString, parseConnectionParamsFromUnknown } from './unstable-core-do-not-import/http/parseConnectionParams.mjs';
7
6
  export { getRequestInfo } from './unstable-core-do-not-import/http/contentType.mjs';
8
7
  export { octetInputParser } from './unstable-core-do-not-import/http/contentTypeParsers.mjs';
8
+ export { formDataToObject } from './unstable-core-do-not-import/http/formDataToObject.mjs';
9
9
  export { getHTTPStatusCode, getHTTPStatusCodeFromError } from './unstable-core-do-not-import/http/getHTTPStatusCode.mjs';
10
+ export { parseConnectionParamsFromString, parseConnectionParamsFromUnknown } from './unstable-core-do-not-import/http/parseConnectionParams.mjs';
10
11
  export { resolveResponse } from './unstable-core-do-not-import/http/resolveResponse.mjs';
11
12
  export { toURL } from './unstable-core-do-not-import/http/toURL.mjs';
12
13
  export { initTRPC } from './unstable-core-do-not-import/initTRPC.mjs';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/server",
3
- "version": "11.0.0-rc.444+18aad1614",
3
+ "version": "11.0.0-rc.446+c679f5317",
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": "18aad16142282eb159b683b08e485692d739c38b"
152
+ "gitHead": "c679f5317416367b838f93d07d5a1a103f12fbdf"
153
153
  }
@@ -1,5 +1,7 @@
1
1
  import type { CreateContextCallback } from '../../@trpc/server';
2
2
  import { getTRPCErrorFromUnknown, TRPCError } from '../../@trpc/server';
3
+ // eslint-disable-next-line no-restricted-imports
4
+ import { formDataToObject } from '../../unstable-core-do-not-import';
3
5
  // FIXME: fix lint rule, this is ok
4
6
  // eslint-disable-next-line no-restricted-imports
5
7
  import type { ErrorHandlerOptions } from '../../unstable-core-do-not-import/procedure';
@@ -12,7 +14,6 @@ import type {
12
14
  MaybePromise,
13
15
  Simplify,
14
16
  } from '../../unstable-core-do-not-import/types';
15
- import { formDataToObject } from './formDataToObject';
16
17
  import { TRPCRedirectError } from './redirect';
17
18
  import { rethrowNextErrors } from './rethrowNextErrors';
18
19
 
@@ -1,6 +1,6 @@
1
1
  interface ProxyCallbackOptions {
2
- path: string[];
3
- args: unknown[];
2
+ path: readonly string[];
3
+ args: readonly unknown[];
4
4
  }
5
5
  type ProxyCallback = (opts: ProxyCallbackOptions) => unknown;
6
6
 
@@ -8,19 +8,27 @@ const noop = () => {
8
8
  // noop
9
9
  };
10
10
 
11
+ const freezeIfAvailable = (obj: object) => {
12
+ if (Object.freeze) {
13
+ Object.freeze(obj);
14
+ }
15
+ };
16
+
11
17
  function createInnerProxy(
12
18
  callback: ProxyCallback,
13
- path: string[],
14
- cache: Record<string, unknown>,
19
+ path: readonly string[],
20
+ memo: Record<string, unknown>,
15
21
  ) {
16
- return new Proxy(noop, {
22
+ const cacheKey = path.join('.');
23
+
24
+ memo[cacheKey] ??= new Proxy(noop, {
17
25
  get(_obj, key) {
18
26
  if (typeof key !== 'string' || key === 'then') {
19
27
  // special case for if the proxy is accidentally treated
20
28
  // like a PromiseLike (like in `Promise.resolve(proxy)`)
21
29
  return undefined;
22
30
  }
23
- return createInnerProxy(callback, [...path, key], cache);
31
+ return createInnerProxy(callback, [...path, key], memo);
24
32
  },
25
33
  apply(_1, _2, args) {
26
34
  const lastOfPath = path[path.length - 1];
@@ -38,9 +46,13 @@ function createInnerProxy(
38
46
  path: path.slice(0, -1),
39
47
  };
40
48
  }
49
+ freezeIfAvailable(opts.args);
50
+ freezeIfAvailable(opts.path);
41
51
  return callback(opts);
42
52
  },
43
53
  });
54
+
55
+ return memo[cacheKey];
44
56
  }
45
57
 
46
58
  /**
@@ -1,18 +1,25 @@
1
1
  /* eslint-disable @typescript-eslint/no-non-null-assertion */
2
+
3
+ const isNumberString = (str: string) => /^\d+$/.test(str);
4
+
2
5
  function set(
3
6
  obj: Record<string, any>,
4
- path: string[] | string,
7
+ path: readonly string[],
5
8
  value: unknown,
6
9
  ): void {
7
- if (typeof path === 'string') {
8
- path = path.split(/[\.\[\]]/).filter(Boolean);
9
- }
10
-
11
10
  if (path.length > 1) {
12
- const p = path.shift()!;
13
- const isArrayIndex = /^\d+$/.test(path[0]!);
14
- obj[p] = obj[p] || (isArrayIndex ? [] : {});
15
- set(obj[p], path, value);
11
+ const newPath = [...path];
12
+ const key = newPath.shift()!;
13
+ const nextKey = newPath[0]!;
14
+
15
+ if (!obj[key]) {
16
+ obj[key] = isNumberString(nextKey) ? [] : {};
17
+ } else if (Array.isArray(obj[key]) && !isNumberString(nextKey)) {
18
+ obj[key] = Object.fromEntries(Object.entries(obj[key]));
19
+ }
20
+
21
+ set(obj[key], newPath, value);
22
+
16
23
  return;
17
24
  }
18
25
  const p = path[0]!;
@@ -29,7 +36,8 @@ export function formDataToObject(formData: FormData) {
29
36
  const obj: Record<string, unknown> = {};
30
37
 
31
38
  for (const [key, value] of formData.entries()) {
32
- set(obj, key, value);
39
+ const parts = key.split(/[\.\[\]]/).filter(Boolean);
40
+ set(obj, parts, value);
33
41
  }
34
42
 
35
43
  return obj;
@@ -32,7 +32,7 @@ export type ResponseMetaFn<TRouter extends AnyRouter> = (opts: {
32
32
  * The different tRPC paths requested
33
33
  * @deprecated use `info` instead, this will be removed in v12
34
34
  **/
35
- paths: string[] | undefined;
35
+ paths: readonly string[] | undefined;
36
36
  info: TRPCRequestInfo | undefined;
37
37
  type: ProcedureType | 'unknown';
38
38
  errors: TRPCError[];
@@ -174,7 +174,7 @@ export function createRouterFactory<TRoot extends AnyRootTypes>(
174
174
 
175
175
  const procedures: Record<string, AnyProcedure> = omitPrototype({});
176
176
 
177
- function step(from: CreateRouterOptions, path: string[] = []) {
177
+ function step(from: CreateRouterOptions, path: readonly string[] = []) {
178
178
  const aggregate: RouterRecord = omitPrototype({});
179
179
  for (const [key, item] of Object.entries(from ?? {})) {
180
180
  if (isRouter(item)) {
@@ -16,10 +16,11 @@ export * from './unstable-core-do-not-import/error/formatter';
16
16
  export * from './unstable-core-do-not-import/error/getErrorShape';
17
17
  export * from './unstable-core-do-not-import/error/TRPCError';
18
18
  export * from './unstable-core-do-not-import/http/batchStreamFormatter';
19
- export * from './unstable-core-do-not-import/http/parseConnectionParams';
20
19
  export * from './unstable-core-do-not-import/http/contentType';
21
20
  export * from './unstable-core-do-not-import/http/contentTypeParsers';
21
+ export * from './unstable-core-do-not-import/http/formDataToObject';
22
22
  export * from './unstable-core-do-not-import/http/getHTTPStatusCode';
23
+ export * from './unstable-core-do-not-import/http/parseConnectionParams';
23
24
  export * from './unstable-core-do-not-import/http/resolveResponse';
24
25
  export * from './unstable-core-do-not-import/http/toURL';
25
26
  export * from './unstable-core-do-not-import/http/types';
@@ -1 +0,0 @@
1
- {"version":3,"file":"formDataToObject.d.ts","sourceRoot":"","sources":["../../../src/adapters/next-app-dir/formDataToObject.ts"],"names":[],"mappings":"AA2BA,wBAAgB,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,2BAQlD"}
@@ -1,34 +0,0 @@
1
- 'use strict';
2
-
3
- /* eslint-disable @typescript-eslint/no-non-null-assertion */ function set(obj, path, value) {
4
- if (typeof path === 'string') {
5
- path = path.split(/[\.\[\]]/).filter(Boolean);
6
- }
7
- if (path.length > 1) {
8
- const p = path.shift();
9
- const isArrayIndex = /^\d+$/.test(path[0]);
10
- obj[p] = obj[p] || (isArrayIndex ? [] : {});
11
- set(obj[p], path, value);
12
- return;
13
- }
14
- const p1 = path[0];
15
- if (obj[p1] === undefined) {
16
- obj[p1] = value;
17
- } else if (Array.isArray(obj[p1])) {
18
- obj[p1].push(value);
19
- } else {
20
- obj[p1] = [
21
- obj[p1],
22
- value
23
- ];
24
- }
25
- }
26
- function formDataToObject(formData) {
27
- const obj = {};
28
- for (const [key, value] of formData.entries()){
29
- set(obj, key, value);
30
- }
31
- return obj;
32
- }
33
-
34
- exports.formDataToObject = formDataToObject;
@@ -1,32 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-non-null-assertion */ function set(obj, path, value) {
2
- if (typeof path === 'string') {
3
- path = path.split(/[\.\[\]]/).filter(Boolean);
4
- }
5
- if (path.length > 1) {
6
- const p = path.shift();
7
- const isArrayIndex = /^\d+$/.test(path[0]);
8
- obj[p] = obj[p] || (isArrayIndex ? [] : {});
9
- set(obj[p], path, value);
10
- return;
11
- }
12
- const p1 = path[0];
13
- if (obj[p1] === undefined) {
14
- obj[p1] = value;
15
- } else if (Array.isArray(obj[p1])) {
16
- obj[p1].push(value);
17
- } else {
18
- obj[p1] = [
19
- obj[p1],
20
- value
21
- ];
22
- }
23
- }
24
- function formDataToObject(formData) {
25
- const obj = {};
26
- for (const [key, value] of formData.entries()){
27
- set(obj, key, value);
28
- }
29
- return obj;
30
- }
31
-
32
- export { formDataToObject };