@trpc/server 11.0.0-rc.445 → 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.
@@ -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": 129548,
3
- "bundleOrigSize": 179141,
4
- "bundleReduction": 27.68,
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.18,
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.1,
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.02,
49
+ "percent": 11,
50
50
  "reduction": 0
51
51
  },
52
52
  {
@@ -61,7 +61,7 @@
61
61
  "/src/unstable-core-do-not-import.ts",
62
62
  "/src/unstable-core-do-not-import/http/resolveResponse.ts"
63
63
  ],
64
- "percent": 5.86,
64
+ "percent": 5.85,
65
65
  "reduction": 0
66
66
  },
67
67
  {
@@ -79,7 +79,7 @@
79
79
  "/src/unstable-core-do-not-import.ts",
80
80
  "/src/unstable-core-do-not-import/initTRPC.ts"
81
81
  ],
82
- "percent": 4.93,
82
+ "percent": 4.92,
83
83
  "reduction": 39.77
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": 4.88,
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.35,
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.18,
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.46,
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
  ],
@@ -162,7 +162,7 @@
162
162
  "/src/adapters/next-app-dir.ts"
163
163
  ],
164
164
  "percent": 2.42,
165
- "reduction": 22.27
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
  {
@@ -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.03,
248
+ "percent": 2.02,
249
249
  "reduction": 55.5
250
250
  },
251
251
  {
@@ -261,7 +261,7 @@
261
261
  "/src/unstable-core-do-not-import.ts",
262
262
  "/src/unstable-core-do-not-import/router.ts"
263
263
  ],
264
- "percent": 1.8,
264
+ "percent": 1.79,
265
265
  "reduction": 0
266
266
  },
267
267
  {
@@ -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
  {
@@ -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
  {
@@ -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
  {
@@ -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,9 +741,9 @@
741
741
  "reduction": 100
742
742
  },
743
743
  {
744
- "id": "/src/shared.ts",
744
+ "id": "/src/rpc.ts",
745
745
  "size": 0,
746
- "origSize": 653,
746
+ "origSize": 36,
747
747
  "renderedExports": [],
748
748
  "removedExports": [],
749
749
  "dependents": [],
@@ -753,11 +753,12 @@
753
753
  {
754
754
  "id": "/src/unstable-core-do-not-import.ts",
755
755
  "size": 0,
756
- "origSize": 2100,
756
+ "origSize": 2169,
757
757
  "renderedExports": [],
758
758
  "removedExports": [],
759
759
  "dependents": [
760
- "/src/adapters/ws.ts"
760
+ "/src/adapters/ws.ts",
761
+ "/src/adapters/next-app-dir/nextAppDirCaller.ts"
761
762
  ],
762
763
  "percent": 0,
763
764
  "reduction": 100
@@ -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
@@ -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 };
@@ -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.445+8cb82e3c8",
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": "8cb82e3c8f7d036ab5cdbf6dc769c23af7e56f6c"
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,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;
@@ -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 };