@trpc/client 11.0.0-alpha-tmp-issues-5851-take-two.475 → 11.0.0-alpha-tmp-issues-5851-take-two.477

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,7 @@
1
1
  {
2
- "bundleSize": 51744,
3
- "bundleOrigSize": 68776,
4
- "bundleReduction": 24.76,
2
+ "bundleSize": 51463,
3
+ "bundleOrigSize": 68565,
4
+ "bundleReduction": 24.94,
5
5
  "modules": [
6
6
  {
7
7
  "id": "/src/links/wsLink.ts",
@@ -13,20 +13,20 @@
13
13
  ],
14
14
  "removedExports": [],
15
15
  "dependents": [],
16
- "percent": 25.26,
16
+ "percent": 25.39,
17
17
  "reduction": 10.22
18
18
  },
19
19
  {
20
20
  "id": "/src/links/httpBatchStreamLink.ts",
21
- "size": 6208,
22
- "origSize": 6287,
21
+ "size": 6017,
22
+ "origSize": 6171,
23
23
  "renderedExports": [
24
24
  "unstable_httpBatchStreamLink"
25
25
  ],
26
26
  "removedExports": [],
27
27
  "dependents": [],
28
- "percent": 12,
29
- "reduction": 1.26
28
+ "percent": 11.69,
29
+ "reduction": 2.5
30
30
  },
31
31
  {
32
32
  "id": "/src/links/loggerLink.ts",
@@ -37,25 +37,13 @@
37
37
  ],
38
38
  "removedExports": [],
39
39
  "dependents": [],
40
- "percent": 10.55,
40
+ "percent": 10.6,
41
41
  "reduction": 18.48
42
42
  },
43
- {
44
- "id": "/src/links/httpBatchLink.ts",
45
- "size": 4099,
46
- "origSize": 4237,
47
- "renderedExports": [
48
- "httpBatchLink"
49
- ],
50
- "removedExports": [],
51
- "dependents": [],
52
- "percent": 7.92,
53
- "reduction": 3.26
54
- },
55
43
  {
56
44
  "id": "/src/internals/dataLoader.ts",
57
- "size": 4089,
58
- "origSize": 4369,
45
+ "size": 4084,
46
+ "origSize": 4328,
59
47
  "renderedExports": [
60
48
  "dataLoader"
61
49
  ],
@@ -64,8 +52,20 @@
64
52
  "/src/links/httpBatchLink.ts",
65
53
  "/src/links/httpBatchStreamLink.ts"
66
54
  ],
67
- "percent": 7.9,
68
- "reduction": 6.41
55
+ "percent": 7.94,
56
+ "reduction": 5.64
57
+ },
58
+ {
59
+ "id": "/src/links/httpBatchLink.ts",
60
+ "size": 4014,
61
+ "origSize": 4183,
62
+ "renderedExports": [
63
+ "httpBatchLink"
64
+ ],
65
+ "removedExports": [],
66
+ "dependents": [],
67
+ "percent": 7.8,
68
+ "reduction": 4.04
69
69
  },
70
70
  {
71
71
  "id": "/src/links/internals/httpUtils.ts",
@@ -88,7 +88,7 @@
88
88
  "/src/links/httpBatchStreamLink.ts",
89
89
  "/src/links/httpSubscriptionLink.ts"
90
90
  ],
91
- "percent": 7.59,
91
+ "percent": 7.63,
92
92
  "reduction": 36.09
93
93
  },
94
94
  {
@@ -100,7 +100,7 @@
100
100
  ],
101
101
  "removedExports": [],
102
102
  "dependents": [],
103
- "percent": 6.81,
103
+ "percent": 6.84,
104
104
  "reduction": 6.13
105
105
  },
106
106
  {
@@ -112,7 +112,7 @@
112
112
  ],
113
113
  "removedExports": [],
114
114
  "dependents": [],
115
- "percent": 6.15,
115
+ "percent": 6.19,
116
116
  "reduction": 14.15
117
117
  },
118
118
  {
@@ -127,7 +127,7 @@
127
127
  "/src/createTRPCUntypedClient.ts",
128
128
  "/src/createTRPCClient.ts"
129
129
  ],
130
- "percent": 4.36,
130
+ "percent": 4.38,
131
131
  "reduction": 46.78
132
132
  },
133
133
  {
@@ -148,7 +148,7 @@
148
148
  "/src/internals/TRPCUntypedClient.ts",
149
149
  "/src/links/internals/httpUtils.ts"
150
150
  ],
151
- "percent": 3.61,
151
+ "percent": 3.63,
152
152
  "reduction": 45.71
153
153
  },
154
154
  {
@@ -165,7 +165,7 @@
165
165
  "dependents": [
166
166
  "/src/index.ts"
167
167
  ],
168
- "percent": 2.29,
168
+ "percent": 2.31,
169
169
  "reduction": 73.19
170
170
  },
171
171
  {
@@ -180,7 +180,7 @@
180
180
  "/src/links/splitLink.ts",
181
181
  "/src/internals/TRPCUntypedClient.ts"
182
182
  ],
183
- "percent": 1.33,
183
+ "percent": 1.34,
184
184
  "reduction": 32.75
185
185
  },
186
186
  {
@@ -192,7 +192,7 @@
192
192
  ],
193
193
  "removedExports": [],
194
194
  "dependents": [],
195
- "percent": 1.18,
195
+ "percent": 1.19,
196
196
  "reduction": 44.95
197
197
  },
198
198
  {
@@ -206,7 +206,7 @@
206
206
  "dependents": [
207
207
  "/src/unstable-internals.ts"
208
208
  ],
209
- "percent": 1.09,
209
+ "percent": 1.1,
210
210
  "reduction": 66.75
211
211
  },
212
212
  {
@@ -1,8 +1,6 @@
1
1
  export type BatchLoader<TKey, TValue> = {
2
2
  validate: (keys: TKey[]) => boolean;
3
- fetch: (keys: TKey[]) => {
4
- promise: Promise<TValue[] | Promise<TValue>[]>;
5
- };
3
+ fetch: (keys: TKey[]) => Promise<TValue[] | Promise<TValue>[]>;
6
4
  };
7
5
  /**
8
6
  * Dataloader that's very inspired by https://github.com/graphql/dataloader
@@ -1 +1 @@
1
- {"version":3,"file":"dataLoader.d.ts","sourceRoot":"","sources":["../../src/internals/dataLoader.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,WAAW,CAAC,IAAI,EAAE,MAAM,IAAI;IACtC,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,OAAO,CAAC;IACpC,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK;QACvB,OAAO,EAAE,OAAO,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;KAChD,CAAC;CACH,CAAC;AAWF;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EACrC,WAAW,EAAE,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC;gBAwGnB,IAAI,KAAG,OAAO,CAAC,MAAM,CAAC;EA6B1C"}
1
+ {"version":3,"file":"dataLoader.d.ts","sourceRoot":"","sources":["../../src/internals/dataLoader.ts"],"names":[],"mappings":"AAYA,MAAM,MAAM,WAAW,CAAC,IAAI,EAAE,MAAM,IAAI;IACtC,QAAQ,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,OAAO,CAAC;IACpC,KAAK,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,OAAO,CAAC,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;CAChE,CAAC;AAWF;;;;GAIG;AACH,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,EACrC,WAAW,EAAE,WAAW,CAAC,IAAI,EAAE,MAAM,CAAC;gBAsGnB,IAAI,KAAG,OAAO,CAAC,MAAM,CAAC;EA6B1C"}
@@ -66,7 +66,7 @@
66
66
  for (const item of items){
67
67
  item.batch = batch;
68
68
  }
69
- const { promise } = batchLoader.fetch(batch.items.map((_item)=>_item.key));
69
+ const promise = batchLoader.fetch(batch.items.map((_item)=>_item.key));
70
70
  promise.then(async (result)=>{
71
71
  await Promise.all(result.map(async (valueOrPromise, index)=>{
72
72
  const item = batch.items[index];
@@ -64,7 +64,7 @@
64
64
  for (const item of items){
65
65
  item.batch = batch;
66
66
  }
67
- const { promise } = batchLoader.fetch(batch.items.map((_item)=>_item.key));
67
+ const promise = batchLoader.fetch(batch.items.map((_item)=>_item.key));
68
68
  promise.then(async (result)=>{
69
69
  await Promise.all(result.map(async (valueOrPromise, index)=>{
70
70
  const item = batch.items[index];
@@ -1 +1 @@
1
- {"version":3,"file":"httpBatchLink.d.ts","sourceRoot":"","sources":["../../src/links/httpBatchLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,cAAc,CAAC;AAO7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAQnE,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnD;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,SAAS,SAAS,EACrD,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,GAC/D,QAAQ,CAAC,OAAO,CAAC,CAwHnB"}
1
+ {"version":3,"file":"httpBatchLink.d.ts","sourceRoot":"","sources":["../../src/links/httpBatchLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,cAAc,CAAC;AAO7D,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAQnE,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnD;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,SAAS,SAAS,EACrD,IAAI,EAAE,oBAAoB,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,GAC/D,QAAQ,CAAC,OAAO,CAAC,CAsHnB"}
@@ -52,16 +52,14 @@ var httpUtils = require('./internals/httpUtils.js');
52
52
  },
53
53
  signal: ac.signal
54
54
  });
55
- return {
56
- promise: promise.then((res)=>{
57
- const resJSON = Array.isArray(res.json) ? res.json : batchOps.map(()=>res.json);
58
- const result = resJSON.map((item)=>({
59
- meta: res.meta,
60
- json: item
61
- }));
62
- return result;
63
- })
64
- };
55
+ return promise.then((res)=>{
56
+ const resJSON = Array.isArray(res.json) ? res.json : batchOps.map(()=>res.json);
57
+ const result = resJSON.map((item)=>({
58
+ meta: res.meta,
59
+ json: item
60
+ }));
61
+ return result;
62
+ });
65
63
  }
66
64
  };
67
65
  };
@@ -50,16 +50,14 @@ import { resolveHTTPLinkOptions, getUrl, mergeAbortSignals, jsonHttpRequester }
50
50
  },
51
51
  signal: ac.signal
52
52
  });
53
- return {
54
- promise: promise.then((res)=>{
55
- const resJSON = Array.isArray(res.json) ? res.json : batchOps.map(()=>res.json);
56
- const result = resJSON.map((item)=>({
57
- meta: res.meta,
58
- json: item
59
- }));
60
- return result;
61
- })
62
- };
53
+ return promise.then((res)=>{
54
+ const resJSON = Array.isArray(res.json) ? res.json : batchOps.map(()=>res.json);
55
+ const result = resJSON.map((item)=>({
56
+ meta: res.meta,
57
+ json: item
58
+ }));
59
+ return result;
60
+ });
63
61
  }
64
62
  };
65
63
  };
@@ -1 +1 @@
1
- {"version":3,"file":"httpBatchStreamLink.d.ts","sourceRoot":"","sources":["../../src/links/httpBatchStreamLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,cAAc,CAAC;AAG7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAM7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AASnE,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,MAAM,0BAA0B,CAAC,KAAK,SAAS,YAAY,IAC/D,oBAAoB,CAAC,KAAK,CAAC,GAAG;IAC5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEJ;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,SAAS,SAAS,EACpE,IAAI,EAAE,0BAA0B,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,GACrE,QAAQ,CAAC,OAAO,CAAC,CAiKnB"}
1
+ {"version":3,"file":"httpBatchStreamLink.d.ts","sourceRoot":"","sources":["../../src/links/httpBatchStreamLink.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAiB,MAAM,cAAc,CAAC;AAG7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AAM7E,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AASnE,OAAO,KAAK,EAAa,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEnD,MAAM,MAAM,0BAA0B,CAAC,KAAK,SAAS,YAAY,IAC/D,oBAAoB,CAAC,KAAK,CAAC,GAAG;IAC5B;;;OAGG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAEJ;;GAEG;AACH,wBAAgB,4BAA4B,CAAC,OAAO,SAAS,SAAS,EACpE,IAAI,EAAE,0BAA0B,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,GACrE,QAAQ,CAAC,OAAO,CAAC,CA+JnB"}
@@ -60,44 +60,42 @@ var httpUtils = require('./internals/httpUtils.js');
60
60
  return opts.headers;
61
61
  }
62
62
  });
63
- return {
64
- promise: responsePromise.then(async (res)=>{
65
- const [head] = await unstableCoreDoNotImport.jsonlStreamConsumer({
66
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
67
- from: res.body,
68
- deserialize: resolvedOpts.transformer.output.deserialize,
69
- // onError: console.error,
70
- formatError (opts) {
71
- const error = opts.error;
72
- return TRPCClientError.TRPCClientError.from({
73
- error
74
- });
75
- },
76
- abortController: ac
77
- });
78
- const promises = Object.keys(batchOps).map(async (key)=>{
79
- let json = await Promise.resolve(head[key]);
80
- if ('result' in json) {
81
- /**
82
- * Not very pretty, but we need to unwrap nested data as promises
83
- * Our stream producer will only resolve top-level async values or async values that are directly nested in another async value
84
- */ const result = await Promise.resolve(json.result);
85
- json = {
86
- result: {
87
- data: await Promise.resolve(result.data)
88
- }
89
- };
90
- }
91
- return {
92
- json,
93
- meta: {
94
- response: res
63
+ return responsePromise.then(async (res)=>{
64
+ const [head] = await unstableCoreDoNotImport.jsonlStreamConsumer({
65
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
66
+ from: res.body,
67
+ deserialize: resolvedOpts.transformer.output.deserialize,
68
+ // onError: console.error,
69
+ formatError (opts) {
70
+ const error = opts.error;
71
+ return TRPCClientError.TRPCClientError.from({
72
+ error
73
+ });
74
+ },
75
+ abortController: ac
76
+ });
77
+ const promises = Object.keys(batchOps).map(async (key)=>{
78
+ let json = await Promise.resolve(head[key]);
79
+ if ('result' in json) {
80
+ /**
81
+ * Not very pretty, but we need to unwrap nested data as promises
82
+ * Our stream producer will only resolve top-level async values or async values that are directly nested in another async value
83
+ */ const result = await Promise.resolve(json.result);
84
+ json = {
85
+ result: {
86
+ data: await Promise.resolve(result.data)
95
87
  }
96
88
  };
97
- });
98
- return promises;
99
- })
100
- };
89
+ }
90
+ return {
91
+ json,
92
+ meta: {
93
+ response: res
94
+ }
95
+ };
96
+ });
97
+ return promises;
98
+ });
101
99
  }
102
100
  };
103
101
  };
@@ -58,44 +58,42 @@ import { resolveHTTPLinkOptions, getUrl, mergeAbortSignals, fetchHTTPResponse, g
58
58
  return opts.headers;
59
59
  }
60
60
  });
61
- return {
62
- promise: responsePromise.then(async (res)=>{
63
- const [head] = await jsonlStreamConsumer({
64
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
65
- from: res.body,
66
- deserialize: resolvedOpts.transformer.output.deserialize,
67
- // onError: console.error,
68
- formatError (opts) {
69
- const error = opts.error;
70
- return TRPCClientError.from({
71
- error
72
- });
73
- },
74
- abortController: ac
75
- });
76
- const promises = Object.keys(batchOps).map(async (key)=>{
77
- let json = await Promise.resolve(head[key]);
78
- if ('result' in json) {
79
- /**
80
- * Not very pretty, but we need to unwrap nested data as promises
81
- * Our stream producer will only resolve top-level async values or async values that are directly nested in another async value
82
- */ const result = await Promise.resolve(json.result);
83
- json = {
84
- result: {
85
- data: await Promise.resolve(result.data)
86
- }
87
- };
88
- }
89
- return {
90
- json,
91
- meta: {
92
- response: res
61
+ return responsePromise.then(async (res)=>{
62
+ const [head] = await jsonlStreamConsumer({
63
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
64
+ from: res.body,
65
+ deserialize: resolvedOpts.transformer.output.deserialize,
66
+ // onError: console.error,
67
+ formatError (opts) {
68
+ const error = opts.error;
69
+ return TRPCClientError.from({
70
+ error
71
+ });
72
+ },
73
+ abortController: ac
74
+ });
75
+ const promises = Object.keys(batchOps).map(async (key)=>{
76
+ let json = await Promise.resolve(head[key]);
77
+ if ('result' in json) {
78
+ /**
79
+ * Not very pretty, but we need to unwrap nested data as promises
80
+ * Our stream producer will only resolve top-level async values or async values that are directly nested in another async value
81
+ */ const result = await Promise.resolve(json.result);
82
+ json = {
83
+ result: {
84
+ data: await Promise.resolve(result.data)
93
85
  }
94
86
  };
95
- });
96
- return promises;
97
- })
98
- };
87
+ }
88
+ return {
89
+ json,
90
+ meta: {
91
+ response: res
92
+ }
93
+ };
94
+ });
95
+ return promises;
96
+ });
99
97
  }
100
98
  };
101
99
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/client",
3
- "version": "11.0.0-alpha-tmp-issues-5851-take-two.475+556a48395",
3
+ "version": "11.0.0-alpha-tmp-issues-5851-take-two.477+1bb740385",
4
4
  "description": "The tRPC client library",
5
5
  "author": "KATT",
6
6
  "license": "MIT",
@@ -76,10 +76,10 @@
76
76
  "!**/*.test.*"
77
77
  ],
78
78
  "peerDependencies": {
79
- "@trpc/server": "11.0.0-alpha-tmp-issues-5851-take-two.475+556a48395"
79
+ "@trpc/server": "11.0.0-alpha-tmp-issues-5851-take-two.477+1bb740385"
80
80
  },
81
81
  "devDependencies": {
82
- "@trpc/server": "11.0.0-alpha-tmp-issues-5851-take-two.475+556a48395",
82
+ "@trpc/server": "11.0.0-alpha-tmp-issues-5851-take-two.477+1bb740385",
83
83
  "@types/isomorphic-fetch": "^0.0.39",
84
84
  "@types/node": "^20.10.0",
85
85
  "eslint": "^8.56.0",
@@ -96,5 +96,5 @@
96
96
  "funding": [
97
97
  "https://trpc.io/sponsor"
98
98
  ],
99
- "gitHead": "556a4839590ea9794598dff075e998e053c3dc02"
99
+ "gitHead": "1bb7403859d3cc30d446da446f9774fc840a3893"
100
100
  }
@@ -12,9 +12,7 @@ type Batch<TKey, TValue> = {
12
12
  };
13
13
  export type BatchLoader<TKey, TValue> = {
14
14
  validate: (keys: TKey[]) => boolean;
15
- fetch: (keys: TKey[]) => {
16
- promise: Promise<TValue[] | Promise<TValue>[]>;
17
- };
15
+ fetch: (keys: TKey[]) => Promise<TValue[] | Promise<TValue>[]>;
18
16
  };
19
17
 
20
18
  /**
@@ -100,9 +98,7 @@ export function dataLoader<TKey, TValue>(
100
98
  for (const item of items) {
101
99
  item.batch = batch;
102
100
  }
103
- const { promise } = batchLoader.fetch(
104
- batch.items.map((_item) => _item.key),
105
- );
101
+ const promise = batchLoader.fetch(batch.items.map((_item) => _item.key));
106
102
 
107
103
  promise
108
104
  .then(async (result) => {
@@ -70,20 +70,18 @@ export function httpBatchLink<TRouter extends AnyRouter>(
70
70
  },
71
71
  signal: ac.signal,
72
72
  });
73
- return {
74
- promise: promise.then((res) => {
75
- const resJSON = Array.isArray(res.json)
76
- ? res.json
77
- : batchOps.map(() => res.json);
73
+ return promise.then((res) => {
74
+ const resJSON = Array.isArray(res.json)
75
+ ? res.json
76
+ : batchOps.map(() => res.json);
78
77
 
79
- const result = resJSON.map((item) => ({
80
- meta: res.meta,
81
- json: item,
82
- }));
78
+ const result = resJSON.map((item) => ({
79
+ meta: res.meta,
80
+ json: item,
81
+ }));
83
82
 
84
- return result;
85
- }),
86
- };
83
+ return result;
84
+ });
87
85
  },
88
86
  };
89
87
  };
@@ -92,52 +92,50 @@ export function unstable_httpBatchStreamLink<TRouter extends AnyRouter>(
92
92
  },
93
93
  });
94
94
 
95
- return {
96
- promise: responsePromise.then(async (res) => {
97
- const [head] = await jsonlStreamConsumer<
98
- Record<string, Promise<any>>
99
- >({
100
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
101
- from: res.body!,
102
- deserialize: resolvedOpts.transformer.output.deserialize,
103
- // onError: console.error,
104
- formatError(opts) {
105
- const error = opts.error as TRPCErrorShape;
106
- return TRPCClientError.from({
107
- error,
108
- });
109
- },
110
- abortController: ac,
111
- });
112
-
113
- const promises = Object.keys(batchOps).map(
114
- async (key): Promise<HTTPResult> => {
115
- let json: TRPCResponse = await Promise.resolve(head[key]);
116
-
117
- if ('result' in json) {
118
- /**
119
- * Not very pretty, but we need to unwrap nested data as promises
120
- * Our stream producer will only resolve top-level async values or async values that are directly nested in another async value
121
- */
122
- const result = await Promise.resolve(json.result);
123
- json = {
124
- result: {
125
- data: await Promise.resolve(result.data),
126
- },
127
- };
128
- }
129
-
130
- return {
131
- json,
132
- meta: {
133
- response: res,
95
+ return responsePromise.then(async (res) => {
96
+ const [head] = await jsonlStreamConsumer<
97
+ Record<string, Promise<any>>
98
+ >({
99
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
100
+ from: res.body!,
101
+ deserialize: resolvedOpts.transformer.output.deserialize,
102
+ // onError: console.error,
103
+ formatError(opts) {
104
+ const error = opts.error as TRPCErrorShape;
105
+ return TRPCClientError.from({
106
+ error,
107
+ });
108
+ },
109
+ abortController: ac,
110
+ });
111
+
112
+ const promises = Object.keys(batchOps).map(
113
+ async (key): Promise<HTTPResult> => {
114
+ let json: TRPCResponse = await Promise.resolve(head[key]);
115
+
116
+ if ('result' in json) {
117
+ /**
118
+ * Not very pretty, but we need to unwrap nested data as promises
119
+ * Our stream producer will only resolve top-level async values or async values that are directly nested in another async value
120
+ */
121
+ const result = await Promise.resolve(json.result);
122
+ json = {
123
+ result: {
124
+ data: await Promise.resolve(result.data),
134
125
  },
135
126
  };
136
- },
137
- );
138
- return promises;
139
- }),
140
- };
127
+ }
128
+
129
+ return {
130
+ json,
131
+ meta: {
132
+ response: res,
133
+ },
134
+ };
135
+ },
136
+ );
137
+ return promises;
138
+ });
141
139
  },
142
140
  };
143
141
  };