@trpc/client 11.0.0-rc.359 → 11.0.0-rc.362

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 (40) hide show
  1. package/dist/bundle-analysis.json +71 -69
  2. package/dist/index.js +4 -2
  3. package/dist/index.mjs +1 -1
  4. package/dist/internals/getAbortController.d.ts.map +1 -1
  5. package/dist/internals/getAbortController.js +0 -2
  6. package/dist/internals/getAbortController.mjs +0 -2
  7. package/dist/internals/types.d.ts +1 -1
  8. package/dist/internals/types.d.ts.map +1 -1
  9. package/dist/links/httpLink.d.ts.map +1 -1
  10. package/dist/links/httpLink.js +1 -1
  11. package/dist/links/httpLink.mjs +2 -2
  12. package/dist/links/internals/contentTypes.d.ts +4 -0
  13. package/dist/links/internals/contentTypes.d.ts.map +1 -0
  14. package/dist/links/internals/contentTypes.js +16 -0
  15. package/dist/links/internals/contentTypes.mjs +12 -0
  16. package/dist/links/internals/getTextDecoder.d.ts.map +1 -1
  17. package/dist/links/internals/getTextDecoder.js +0 -2
  18. package/dist/links/internals/getTextDecoder.mjs +0 -2
  19. package/dist/links/internals/httpUtils.d.ts +1 -0
  20. package/dist/links/internals/httpUtils.d.ts.map +1 -1
  21. package/dist/links/internals/httpUtils.js +29 -0
  22. package/dist/links/internals/httpUtils.mjs +29 -1
  23. package/dist/links/types.d.ts +1 -1
  24. package/dist/links/types.d.ts.map +1 -1
  25. package/dist/links.d.ts +0 -1
  26. package/dist/links.d.ts.map +1 -1
  27. package/package.json +4 -4
  28. package/src/internals/getAbortController.ts +1 -2
  29. package/src/internals/types.ts +1 -1
  30. package/src/links/httpLink.ts +2 -2
  31. package/src/links/internals/contentTypes.ts +15 -0
  32. package/src/links/internals/getTextDecoder.ts +1 -2
  33. package/src/links/internals/httpUtils.ts +35 -0
  34. package/src/links/types.ts +6 -0
  35. package/src/links.ts +0 -1
  36. package/dist/links/httpFormDataLink.d.ts +0 -2
  37. package/dist/links/httpFormDataLink.d.ts.map +0 -1
  38. package/dist/links/httpFormDataLink.js +0 -31
  39. package/dist/links/httpFormDataLink.mjs +0 -29
  40. package/src/links/httpFormDataLink.ts +0 -29
@@ -1,7 +1,7 @@
1
1
  {
2
- "bundleSize": 46703,
3
- "bundleOrigSize": 65934,
4
- "bundleReduction": 29.17,
2
+ "bundleSize": 46982,
3
+ "bundleOrigSize": 66169,
4
+ "bundleReduction": 29,
5
5
  "modules": [
6
6
  {
7
7
  "id": "/src/links/wsLink.ts",
@@ -13,7 +13,7 @@
13
13
  ],
14
14
  "removedExports": [],
15
15
  "dependents": [],
16
- "percent": 25.82,
16
+ "percent": 25.67,
17
17
  "reduction": 11.68
18
18
  },
19
19
  {
@@ -25,7 +25,7 @@
25
25
  ],
26
26
  "removedExports": [],
27
27
  "dependents": [],
28
- "percent": 11.87,
28
+ "percent": 11.8,
29
29
  "reduction": 14.64
30
30
  },
31
31
  {
@@ -39,33 +39,19 @@
39
39
  "dependents": [
40
40
  "/src/links/internals/createHTTPBatchLink.ts"
41
41
  ],
42
- "percent": 9.44,
42
+ "percent": 9.38,
43
43
  "reduction": 7.49
44
44
  },
45
- {
46
- "id": "/src/links/internals/parseJSONStream.ts",
47
- "size": 4007,
48
- "origSize": 5037,
49
- "renderedExports": [
50
- "parseJSONStream",
51
- "streamingJsonHttpRequester"
52
- ],
53
- "removedExports": [],
54
- "dependents": [
55
- "/src/links/httpBatchStreamLink.ts"
56
- ],
57
- "percent": 8.58,
58
- "reduction": 20.45
59
- },
60
45
  {
61
46
  "id": "/src/links/internals/httpUtils.ts",
62
- "size": 3464,
63
- "origSize": 6007,
47
+ "size": 4407,
48
+ "origSize": 6905,
64
49
  "renderedExports": [
65
50
  "resolveHTTPLinkOptions",
66
51
  "getUrl",
67
52
  "getBody",
68
53
  "jsonHttpRequester",
54
+ "universalRequester",
69
55
  "fetchHTTPResponse",
70
56
  "httpRequest"
71
57
  ],
@@ -73,12 +59,26 @@
73
59
  "dependents": [
74
60
  "/src/links/httpBatchLink.ts",
75
61
  "/src/links/httpLink.ts",
76
- "/src/links/httpFormDataLink.ts",
77
62
  "/src/links/internals/createHTTPBatchLink.ts",
78
63
  "/src/links/internals/parseJSONStream.ts"
79
64
  ],
80
- "percent": 7.42,
81
- "reduction": 42.33
65
+ "percent": 9.38,
66
+ "reduction": 36.18
67
+ },
68
+ {
69
+ "id": "/src/links/internals/parseJSONStream.ts",
70
+ "size": 4007,
71
+ "origSize": 5037,
72
+ "renderedExports": [
73
+ "parseJSONStream",
74
+ "streamingJsonHttpRequester"
75
+ ],
76
+ "removedExports": [],
77
+ "dependents": [
78
+ "/src/links/httpBatchStreamLink.ts"
79
+ ],
80
+ "percent": 8.53,
81
+ "reduction": 20.45
82
82
  },
83
83
  {
84
84
  "id": "/src/links/internals/createHTTPBatchLink.ts",
@@ -92,7 +92,7 @@
92
92
  "/src/links/httpBatchLink.ts",
93
93
  "/src/links/httpBatchStreamLink.ts"
94
94
  ],
95
- "percent": 6.3,
95
+ "percent": 6.27,
96
96
  "reduction": 20.67
97
97
  },
98
98
  {
@@ -107,23 +107,21 @@
107
107
  "/src/createTRPCUntypedClient.ts",
108
108
  "/src/createTRPCClient.ts"
109
109
  ],
110
- "percent": 4.92,
110
+ "percent": 4.89,
111
111
  "reduction": 45.35
112
112
  },
113
113
  {
114
114
  "id": "/src/links/httpLink.ts",
115
- "size": 2169,
116
- "origSize": 2753,
115
+ "size": 2170,
116
+ "origSize": 2755,
117
117
  "renderedExports": [
118
118
  "httpLinkFactory",
119
119
  "httpLink"
120
120
  ],
121
121
  "removedExports": [],
122
- "dependents": [
123
- "/src/links/httpFormDataLink.ts"
124
- ],
125
- "percent": 4.64,
126
- "reduction": 21.21
122
+ "dependents": [],
123
+ "percent": 4.62,
124
+ "reduction": 21.23
127
125
  },
128
126
  {
129
127
  "id": "/src/TRPCClientError.ts",
@@ -141,7 +139,7 @@
141
139
  "/src/links/internals/createHTTPBatchLink.ts",
142
140
  "/src/links/internals/httpUtils.ts"
143
141
  ],
144
- "percent": 4,
142
+ "percent": 3.97,
145
143
  "reduction": 45.71
146
144
  },
147
145
  {
@@ -153,7 +151,7 @@
153
151
  ],
154
152
  "removedExports": [],
155
153
  "dependents": [],
156
- "percent": 2.87,
154
+ "percent": 2.85,
157
155
  "reduction": 38.42
158
156
  },
159
157
  {
@@ -170,7 +168,7 @@
170
168
  "dependents": [
171
169
  "/src/index.ts"
172
170
  ],
173
- "percent": 2.58,
171
+ "percent": 2.57,
174
172
  "reduction": 72.4
175
173
  },
176
174
  {
@@ -182,21 +180,9 @@
182
180
  ],
183
181
  "removedExports": [],
184
182
  "dependents": [],
185
- "percent": 2.58,
183
+ "percent": 2.56,
186
184
  "reduction": 21.09
187
185
  },
188
- {
189
- "id": "/src/links/httpFormDataLink.ts",
190
- "size": 703,
191
- "origSize": 772,
192
- "renderedExports": [
193
- "experimental_formDataLink"
194
- ],
195
- "removedExports": [],
196
- "dependents": [],
197
- "percent": 1.51,
198
- "reduction": 8.94
199
- },
200
186
  {
201
187
  "id": "/src/links/internals/createChain.ts",
202
188
  "size": 690,
@@ -209,7 +195,7 @@
209
195
  "/src/links/splitLink.ts",
210
196
  "/src/internals/TRPCUntypedClient.ts"
211
197
  ],
212
- "percent": 1.48,
198
+ "percent": 1.47,
213
199
  "reduction": 32.75
214
200
  },
215
201
  {
@@ -221,7 +207,7 @@
221
207
  ],
222
208
  "removedExports": [],
223
209
  "dependents": [],
224
- "percent": 1.31,
210
+ "percent": 1.3,
225
211
  "reduction": 44.95
226
212
  },
227
213
  {
@@ -235,13 +221,28 @@
235
221
  "dependents": [
236
222
  "/src/unstable-internals.ts"
237
223
  ],
238
- "percent": 1.21,
224
+ "percent": 1.2,
239
225
  "reduction": 66.75
240
226
  },
227
+ {
228
+ "id": "/src/getFetch.ts",
229
+ "size": 428,
230
+ "origSize": 644,
231
+ "renderedExports": [
232
+ "getFetch"
233
+ ],
234
+ "removedExports": [],
235
+ "dependents": [
236
+ "/src/index.ts",
237
+ "/src/links/internals/httpUtils.ts"
238
+ ],
239
+ "percent": 0.91,
240
+ "reduction": 33.54
241
+ },
241
242
  {
242
243
  "id": "/src/links/internals/getTextDecoder.ts",
243
- "size": 553,
244
- "origSize": 634,
244
+ "size": 407,
245
+ "origSize": 493,
245
246
  "renderedExports": [
246
247
  "getTextDecoder"
247
248
  ],
@@ -249,13 +250,13 @@
249
250
  "dependents": [
250
251
  "/src/links/httpBatchStreamLink.ts"
251
252
  ],
252
- "percent": 1.18,
253
- "reduction": 12.78
253
+ "percent": 0.87,
254
+ "reduction": 17.44
254
255
  },
255
256
  {
256
257
  "id": "/src/internals/getAbortController.ts",
257
- "size": 542,
258
- "origSize": 710,
258
+ "size": 396,
259
+ "origSize": 569,
259
260
  "renderedExports": [
260
261
  "getAbortController"
261
262
  ],
@@ -263,23 +264,24 @@
263
264
  "dependents": [
264
265
  "/src/links/internals/httpUtils.ts"
265
266
  ],
266
- "percent": 1.16,
267
- "reduction": 23.66
267
+ "percent": 0.84,
268
+ "reduction": 30.4
268
269
  },
269
270
  {
270
- "id": "/src/getFetch.ts",
271
- "size": 428,
272
- "origSize": 644,
271
+ "id": "/src/links/internals/contentTypes.ts",
272
+ "size": 330,
273
+ "origSize": 389,
273
274
  "renderedExports": [
274
- "getFetch"
275
+ "isOctetType",
276
+ "isFormData",
277
+ "isNonJsonSerializable"
275
278
  ],
276
279
  "removedExports": [],
277
280
  "dependents": [
278
- "/src/index.ts",
279
281
  "/src/links/internals/httpUtils.ts"
280
282
  ],
281
- "percent": 0.92,
282
- "reduction": 33.54
283
+ "percent": 0.7,
284
+ "reduction": 15.17
283
285
  },
284
286
  {
285
287
  "id": "/src/createTRPCUntypedClient.ts",
package/dist/index.js CHANGED
@@ -4,13 +4,13 @@ var createTRPCUntypedClient = require('./createTRPCUntypedClient.js');
4
4
  var createTRPCClient = require('./createTRPCClient.js');
5
5
  var getFetch = require('./getFetch.js');
6
6
  var TRPCClientError = require('./TRPCClientError.js');
7
+ var contentTypes = require('./links/internals/contentTypes.js');
7
8
  var httpBatchLink = require('./links/httpBatchLink.js');
8
9
  var httpBatchStreamLink = require('./links/httpBatchStreamLink.js');
9
10
  var httpLink = require('./links/httpLink.js');
10
11
  var loggerLink = require('./links/loggerLink.js');
11
12
  var splitLink = require('./links/splitLink.js');
12
13
  var wsLink = require('./links/wsLink.js');
13
- var httpFormDataLink = require('./links/httpFormDataLink.js');
14
14
  var TRPCUntypedClient = require('./internals/TRPCUntypedClient.js');
15
15
 
16
16
 
@@ -23,6 +23,9 @@ exports.createTRPCProxyClient = createTRPCClient.createTRPCClient;
23
23
  exports.getUntypedClient = createTRPCClient.getUntypedClient;
24
24
  exports.getFetch = getFetch.getFetch;
25
25
  exports.TRPCClientError = TRPCClientError.TRPCClientError;
26
+ exports.isFormData = contentTypes.isFormData;
27
+ exports.isNonJsonSerializable = contentTypes.isNonJsonSerializable;
28
+ exports.isOctetType = contentTypes.isOctetType;
26
29
  exports.httpBatchLink = httpBatchLink.httpBatchLink;
27
30
  exports.unstable_httpBatchStreamLink = httpBatchStreamLink.unstable_httpBatchStreamLink;
28
31
  exports.httpLink = httpLink.httpLink;
@@ -31,5 +34,4 @@ exports.loggerLink = loggerLink.loggerLink;
31
34
  exports.splitLink = splitLink.splitLink;
32
35
  exports.createWSClient = wsLink.createWSClient;
33
36
  exports.wsLink = wsLink.wsLink;
34
- exports.experimental_formDataLink = httpFormDataLink.experimental_formDataLink;
35
37
  exports.TRPCUntypedClient = TRPCUntypedClient.TRPCUntypedClient;
package/dist/index.mjs CHANGED
@@ -2,11 +2,11 @@ export { createTRPCUntypedClient } from './createTRPCUntypedClient.mjs';
2
2
  export { clientCallTypeToProcedureType, createTRPCClient, createTRPCClientProxy, createTRPCClient as createTRPCProxyClient, getUntypedClient } from './createTRPCClient.mjs';
3
3
  export { getFetch } from './getFetch.mjs';
4
4
  export { TRPCClientError } from './TRPCClientError.mjs';
5
+ export { isFormData, isNonJsonSerializable, isOctetType } from './links/internals/contentTypes.mjs';
5
6
  export { httpBatchLink } from './links/httpBatchLink.mjs';
6
7
  export { unstable_httpBatchStreamLink } from './links/httpBatchStreamLink.mjs';
7
8
  export { httpLink, httpLinkFactory } from './links/httpLink.mjs';
8
9
  export { loggerLink } from './links/loggerLink.mjs';
9
10
  export { splitLink } from './links/splitLink.mjs';
10
11
  export { createWSClient, wsLink } from './links/wsLink.mjs';
11
- export { experimental_formDataLink } from './links/httpFormDataLink.mjs';
12
12
  export { TRPCUntypedClient } from './internals/TRPCUntypedClient.mjs';
@@ -1 +1 @@
1
- {"version":3,"file":"getAbortController.d.ts","sourceRoot":"","sources":["../../src/internals/getAbortController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,wBAAgB,kBAAkB,CAChC,yBAAyB,EAAE,KAAK,CAAC,oBAAoB,CAAC,GACrD,oBAAoB,GAAG,IAAI,CAe7B"}
1
+ {"version":3,"file":"getAbortController.d.ts","sourceRoot":"","sources":["../../src/internals/getAbortController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,0CAA0C,CAAC;AACtE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,SAAS,CAAC;AAEpD,wBAAgB,kBAAkB,CAChC,yBAAyB,EAAE,KAAK,CAAC,oBAAoB,CAAC,GACrD,oBAAoB,GAAG,IAAI,CAc7B"}
@@ -4,11 +4,9 @@ function getAbortController(customAbortControllerImpl) {
4
4
  if (customAbortControllerImpl) {
5
5
  return customAbortControllerImpl;
6
6
  }
7
- // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
8
7
  if (typeof window !== 'undefined' && window.AbortController) {
9
8
  return window.AbortController;
10
9
  }
11
- // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
12
10
  if (typeof globalThis !== 'undefined' && globalThis.AbortController) {
13
11
  return globalThis.AbortController;
14
12
  }
@@ -2,11 +2,9 @@ function getAbortController(customAbortControllerImpl) {
2
2
  if (customAbortControllerImpl) {
3
3
  return customAbortControllerImpl;
4
4
  }
5
- // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
6
5
  if (typeof window !== 'undefined' && window.AbortController) {
7
6
  return window.AbortController;
8
7
  }
9
- // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
10
8
  if (typeof globalThis !== 'undefined' && globalThis.AbortController) {
11
9
  return globalThis.AbortController;
12
10
  }
@@ -40,7 +40,7 @@ export interface RequestInitEsque {
40
40
  /**
41
41
  * Sets the request's body.
42
42
  */
43
- body?: FormData | ReadableStream | string | null;
43
+ body?: FormData | string | null | Uint8Array | Blob | File;
44
44
  /**
45
45
  * Sets the request's associated headers.
46
46
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/internals/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG,UAAU,4BAA4B,CAAC;AAE1E;;GAEG;AACH,MAAM,WAAW,4BAA4B;IAC3C;;OAEG;IACH,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAE7B;;;OAGG;IACH,KAAK,IAAI,IAAI,CAAC;CACf;AAED;;;;;;GAMG;AACH,MAAM,MAAM,UAAU,GAAG,CACvB,KAAK,EAAE,WAAW,GAAG,GAAG,GAAG,MAAM,EACjC,IAAI,CAAC,EAAE,WAAW,GAAG,gBAAgB,KAClC,OAAO,CAAC,aAAa,CAAC,CAAC;AAE5B;;;GAGG;AACH,MAAM,MAAM,gBAAgB,GAAG,CAC7B,GAAG,EAAE,GAAG,GAAG,MAAM,EACjB,IAAI,CAAC,EAAE,yBAAyB,KAC7B,OAAO,CAAC,aAAa,CAAC,CAAC;AAE5B,MAAM,WAAW,yBAAyB;IACxC,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED;;;;;;GAMG;AACH,MAAM,WAAW,gBAAgB;IAC/B;;OAEG;IACH,IAAI,CAAC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AC,KAAK,IAAI,CAAC,KAAK,EAAE,GAAG,KAAK,EAAE,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"httpLink.d.ts","sourceRoot":"","sources":["../../src/links/httpLink.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACV,MAAM,0CAA0C,CAAC;AAGlD,OAAO,KAAK,EACV,mBAAmB,EAEnB,SAAS,EACV,MAAM,uBAAuB,CAAC;AAK/B,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEhE,MAAM,MAAM,eAAe,CAAC,KAAK,SAAS,YAAY,IACpD,mBAAmB,CAAC,KAAK,CAAC,GAAG;IAC3B;;;OAGG;IACH,OAAO,CAAC,EACJ,WAAW,GACX,CAAC,CAAC,IAAI,EAAE;QAAE,EAAE,EAAE,SAAS,CAAA;KAAE,KAAK,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;CACvE,CAAC;AAEJ,wBAAgB,eAAe,CAAC,WAAW,EAAE;IAAE,SAAS,EAAE,SAAS,CAAA;CAAE,qCAE3D,gBAAgB,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,KAC1D,SAAS,OAAO,CAAC,CAwDrB;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,oCA9DX,gBAAgB,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,KAC1D,SAAS,OAAO,CA6DoD,CAAC"}
1
+ {"version":3,"file":"httpLink.d.ts","sourceRoot":"","sources":["../../src/links/httpLink.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,YAAY,EACZ,SAAS,EACV,MAAM,0CAA0C,CAAC;AAGlD,OAAO,KAAK,EACV,mBAAmB,EAEnB,SAAS,EACV,MAAM,uBAAuB,CAAC;AAK/B,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAEhE,MAAM,MAAM,eAAe,CAAC,KAAK,SAAS,YAAY,IACpD,mBAAmB,CAAC,KAAK,CAAC,GAAG;IAC3B;;;OAGG;IACH,OAAO,CAAC,EACJ,WAAW,GACX,CAAC,CAAC,IAAI,EAAE;QAAE,EAAE,EAAE,SAAS,CAAA;KAAE,KAAK,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC;CACvE,CAAC;AAEJ,wBAAgB,eAAe,CAAC,WAAW,EAAE;IAAE,SAAS,EAAE,SAAS,CAAA;CAAE,qCAE3D,gBAAgB,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,KAC1D,SAAS,OAAO,CAAC,CAwDrB;AAED;;GAEG;AACH,eAAO,MAAM,QAAQ,oCA9DX,gBAAgB,OAAO,CAAC,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAC,KAC1D,SAAS,OAAO,CA6DqD,CAAC"}
@@ -56,7 +56,7 @@ function httpLinkFactory(factoryOpts) {
56
56
  /**
57
57
  * @link https://trpc.io/docs/v11/client/links/httpLink
58
58
  */ const httpLink = httpLinkFactory({
59
- requester: httpUtils.jsonHttpRequester
59
+ requester: httpUtils.universalRequester
60
60
  });
61
61
 
62
62
  exports.httpLink = httpLink;
@@ -1,7 +1,7 @@
1
1
  import { observable } from '@trpc/server/observable';
2
2
  import { transformResult } from '@trpc/server/unstable-core-do-not-import';
3
3
  import { TRPCClientError } from '../TRPCClientError.mjs';
4
- import { resolveHTTPLinkOptions, jsonHttpRequester } from './internals/httpUtils.mjs';
4
+ import { resolveHTTPLinkOptions, universalRequester } from './internals/httpUtils.mjs';
5
5
 
6
6
  function httpLinkFactory(factoryOpts) {
7
7
  return (opts)=>{
@@ -54,7 +54,7 @@ function httpLinkFactory(factoryOpts) {
54
54
  /**
55
55
  * @link https://trpc.io/docs/v11/client/links/httpLink
56
56
  */ const httpLink = httpLinkFactory({
57
- requester: jsonHttpRequester
57
+ requester: universalRequester
58
58
  });
59
59
 
60
60
  export { httpLink, httpLinkFactory };
@@ -0,0 +1,4 @@
1
+ export declare function isOctetType(input: unknown): boolean;
2
+ export declare function isFormData(input: unknown): boolean;
3
+ export declare function isNonJsonSerializable(input: unknown): boolean;
4
+ //# sourceMappingURL=contentTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"contentTypes.d.ts","sourceRoot":"","sources":["../../../src/links/internals/contentTypes.ts"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,KAAK,EAAE,OAAO,WAMzC;AAED,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,WAExC;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,OAAO,WAEnD"}
@@ -0,0 +1,16 @@
1
+ 'use strict';
2
+
3
+ function isOctetType(input) {
4
+ return input instanceof Uint8Array || // File extends from Blob but is only available in nodejs from v20
5
+ input instanceof Blob;
6
+ }
7
+ function isFormData(input) {
8
+ return input instanceof FormData;
9
+ }
10
+ function isNonJsonSerializable(input) {
11
+ return isOctetType(input) || isFormData(input);
12
+ }
13
+
14
+ exports.isFormData = isFormData;
15
+ exports.isNonJsonSerializable = isNonJsonSerializable;
16
+ exports.isOctetType = isOctetType;
@@ -0,0 +1,12 @@
1
+ function isOctetType(input) {
2
+ return input instanceof Uint8Array || // File extends from Blob but is only available in nodejs from v20
3
+ input instanceof Blob;
4
+ }
5
+ function isFormData(input) {
6
+ return input instanceof FormData;
7
+ }
8
+ function isNonJsonSerializable(input) {
9
+ return isOctetType(input) || isFormData(input);
10
+ }
11
+
12
+ export { isFormData, isNonJsonSerializable, isOctetType };
@@ -1 +1 @@
1
- {"version":3,"file":"getTextDecoder.d.ts","sourceRoot":"","sources":["../../../src/links/internals/getTextDecoder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,wBAAgB,cAAc,CAC5B,iBAAiB,CAAC,EAAE,gBAAgB,GACnC,gBAAgB,CAelB"}
1
+ {"version":3,"file":"getTextDecoder.d.ts","sourceRoot":"","sources":["../../../src/links/internals/getTextDecoder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAEzD,wBAAgB,cAAc,CAC5B,iBAAiB,CAAC,EAAE,gBAAgB,GACnC,gBAAgB,CAclB"}
@@ -4,11 +4,9 @@ function getTextDecoder(customTextDecoder) {
4
4
  if (customTextDecoder) {
5
5
  return customTextDecoder;
6
6
  }
7
- // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
8
7
  if (typeof window !== 'undefined' && window.TextDecoder) {
9
8
  return new window.TextDecoder();
10
9
  }
11
- // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
12
10
  if (typeof globalThis !== 'undefined' && globalThis.TextDecoder) {
13
11
  return new globalThis.TextDecoder();
14
12
  }
@@ -2,11 +2,9 @@ function getTextDecoder(customTextDecoder) {
2
2
  if (customTextDecoder) {
3
3
  return customTextDecoder;
4
4
  }
5
- // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
6
5
  if (typeof window !== 'undefined' && window.TextDecoder) {
7
6
  return new window.TextDecoder();
8
7
  }
9
- // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
10
8
  if (typeof globalThis !== 'undefined' && globalThis.TextDecoder) {
11
9
  return new globalThis.TextDecoder();
12
10
  }
@@ -63,6 +63,7 @@ export type Requester = (opts: HTTPBaseRequestOptions & {
63
63
  headers: () => HTTPHeaders | Promise<HTTPHeaders>;
64
64
  }) => PromiseAndCancel<HTTPResult>;
65
65
  export declare const jsonHttpRequester: Requester;
66
+ export declare const universalRequester: Requester;
66
67
  export type HTTPRequestOptions = ContentOptions & HTTPBaseRequestOptions & {
67
68
  headers: () => HTTPHeaders | Promise<HTTPHeaders>;
68
69
  TextDecoder?: TextDecoderEsque;
@@ -1 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C7C,sBAAsB,GAAG;IACvB,OAAO,EAAE,MAAM,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;IAClD,WAAW,CAAC,EAAE,gBAAgB,CAAC;CAChC,CAAC;AAEJ,wBAAsB,iBAAiB,CACrC,IAAI,EAAE,kBAAkB,EACxB,EAAE,CAAC,EAAE,4BAA4B,GAAG,IAAI,0BAgCzC;AAED,wBAAgB,WAAW,CACzB,IAAI,EAAE,kBAAkB,GACvB,gBAAgB,CAAC,UAAU,CAAC,CA8B9B"}
@@ -4,6 +4,7 @@ var getFetch = require('../../getFetch.js');
4
4
  var getAbortController = require('../../internals/getAbortController.js');
5
5
  var TRPCClientError = require('../../TRPCClientError.js');
6
6
  var transformer = require('../../internals/transformer.js');
7
+ var contentTypes = require('./contentTypes.js');
7
8
 
8
9
  function resolveHTTPLinkOptions(opts) {
9
10
  return {
@@ -62,6 +63,33 @@ const jsonHttpRequester = (opts)=>{
62
63
  getBody
63
64
  });
64
65
  };
66
+ const universalRequester = (opts)=>{
67
+ const input = getInput(opts);
68
+ if (contentTypes.isFormData(input)) {
69
+ if (opts.type !== 'mutation' && opts.methodOverride !== 'POST') {
70
+ throw new Error('FormData is only supported for mutations');
71
+ }
72
+ return httpRequest({
73
+ ...opts,
74
+ // The browser will set this automatically and include the boundary= in it
75
+ contentTypeHeader: undefined,
76
+ getUrl,
77
+ getBody: ()=>input
78
+ });
79
+ }
80
+ if (contentTypes.isOctetType(input)) {
81
+ if (opts.type !== 'mutation' && opts.methodOverride !== 'POST') {
82
+ throw new Error('Octet type input is only supported for mutations');
83
+ }
84
+ return httpRequest({
85
+ ...opts,
86
+ contentTypeHeader: 'application/octet-stream',
87
+ getUrl,
88
+ getBody: ()=>input
89
+ });
90
+ }
91
+ return jsonHttpRequester(opts);
92
+ };
65
93
  async function fetchHTTPResponse(opts, ac) {
66
94
  const url = opts.getUrl(opts);
67
95
  const body = opts.getBody(opts);
@@ -131,3 +159,4 @@ exports.getUrl = getUrl;
131
159
  exports.httpRequest = httpRequest;
132
160
  exports.jsonHttpRequester = jsonHttpRequester;
133
161
  exports.resolveHTTPLinkOptions = resolveHTTPLinkOptions;
162
+ exports.universalRequester = universalRequester;
@@ -2,6 +2,7 @@ import { getFetch } from '../../getFetch.mjs';
2
2
  import { getAbortController } from '../../internals/getAbortController.mjs';
3
3
  import { TRPCClientError } from '../../TRPCClientError.mjs';
4
4
  import { getTransformer } from '../../internals/transformer.mjs';
5
+ import { isFormData, isOctetType } from './contentTypes.mjs';
5
6
 
6
7
  function resolveHTTPLinkOptions(opts) {
7
8
  return {
@@ -60,6 +61,33 @@ const jsonHttpRequester = (opts)=>{
60
61
  getBody
61
62
  });
62
63
  };
64
+ const universalRequester = (opts)=>{
65
+ const input = getInput(opts);
66
+ if (isFormData(input)) {
67
+ if (opts.type !== 'mutation' && opts.methodOverride !== 'POST') {
68
+ throw new Error('FormData is only supported for mutations');
69
+ }
70
+ return httpRequest({
71
+ ...opts,
72
+ // The browser will set this automatically and include the boundary= in it
73
+ contentTypeHeader: undefined,
74
+ getUrl,
75
+ getBody: ()=>input
76
+ });
77
+ }
78
+ if (isOctetType(input)) {
79
+ if (opts.type !== 'mutation' && opts.methodOverride !== 'POST') {
80
+ throw new Error('Octet type input is only supported for mutations');
81
+ }
82
+ return httpRequest({
83
+ ...opts,
84
+ contentTypeHeader: 'application/octet-stream',
85
+ getUrl,
86
+ getBody: ()=>input
87
+ });
88
+ }
89
+ return jsonHttpRequester(opts);
90
+ };
63
91
  async function fetchHTTPResponse(opts, ac) {
64
92
  const url = opts.getUrl(opts);
65
93
  const body = opts.getBody(opts);
@@ -123,4 +151,4 @@ function httpRequest(opts) {
123
151
  };
124
152
  }
125
153
 
126
- export { fetchHTTPResponse, getBody, getUrl, httpRequest, jsonHttpRequester, resolveHTTPLinkOptions };
154
+ export { fetchHTTPResponse, getBody, getUrl, httpRequest, jsonHttpRequester, resolveHTTPLinkOptions, universalRequester };
@@ -2,6 +2,7 @@ import type { Observable, Observer } from '@trpc/server/observable';
2
2
  import type { InferrableClientTypes, TRPCResultMessage, TRPCSuccessResponse } from '@trpc/server/unstable-core-do-not-import';
3
3
  import type { ResponseEsque } from '../internals/types';
4
4
  import type { TRPCClientError } from '../TRPCClientError';
5
+ export { isNonJsonSerializable, isFormData, isOctetType, } from './internals/contentTypes';
5
6
  /**
6
7
  * @internal
7
8
  */
@@ -68,5 +69,4 @@ export type OperationLink<TInferrable extends InferrableClientTypes, TInput = un
68
69
  * @public
69
70
  */
70
71
  export type TRPCLink<TInferrable extends InferrableClientTypes> = (opts: TRPCClientRuntime) => OperationLink<TInferrable>;
71
- export {};
72
72
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/links/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AACpE,OAAO,KAAK,EACV,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,EACpB,MAAM,0CAA0C,CAAC;AAClD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;GAEG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC;AAElC;;GAEG;AACH,MAAM,MAAM,gBAAgB,CAAC,MAAM,IAAI;IACrC,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;IACzB,MAAM,EAAE,QAAQ,CAAC;CAClB,CAAC;AAEF;;GAEG;AACH,MAAM,WAAW,gBAAiB,SAAQ,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAAG;AAEpE;;GAEG;AACH,MAAM,MAAM,SAAS,CAAC,MAAM,GAAG,OAAO,IAAI;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,UAAU,GAAG,OAAO,GAAG,cAAc,CAAC;IAC5C,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SAAS,CAAC,MAAM,CAAC,KAClB,yBAAyB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;CACtD,KAAK,yBAAyB,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;AAEtD;;GAEG;AACH,MAAM,MAAM,QAAQ,CAAC,WAAW,SAAS,qBAAqB,IAAI,CAChE,IAAI,EAAE,iBAAiB,KACpB,aAAa,CAAC,WAAW,CAAC,CAAC"}
package/dist/links.d.ts CHANGED
@@ -6,5 +6,4 @@ export * from './links/httpLink';
6
6
  export * from './links/loggerLink';
7
7
  export * from './links/splitLink';
8
8
  export * from './links/wsLink';
9
- export * from './links/httpFormDataLink';
10
9
  //# sourceMappingURL=links.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAE9B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,0BAA0B,CAAC"}
1
+ {"version":3,"file":"links.d.ts","sourceRoot":"","sources":["../src/links.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAE9B,cAAc,8BAA8B,CAAC;AAC7C,cAAc,uBAAuB,CAAC;AACtC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,kBAAkB,CAAC;AACjC,cAAc,oBAAoB,CAAC;AACnC,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trpc/client",
3
- "version": "11.0.0-rc.359+3bb71110f",
3
+ "version": "11.0.0-rc.362+01bb2eade",
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-rc.359+3bb71110f"
79
+ "@trpc/server": "11.0.0-rc.362+01bb2eade"
80
80
  },
81
81
  "devDependencies": {
82
- "@trpc/server": "11.0.0-rc.359+3bb71110f",
82
+ "@trpc/server": "11.0.0-rc.362+01bb2eade",
83
83
  "@types/isomorphic-fetch": "^0.0.39",
84
84
  "@types/node": "^20.10.0",
85
85
  "eslint": "^8.56.0",
@@ -95,5 +95,5 @@
95
95
  "funding": [
96
96
  "https://trpc.io/sponsor"
97
97
  ],
98
- "gitHead": "3bb71110fc13467b7fa1b692f949e1249488a4f3"
98
+ "gitHead": "01bb2eadebe880a91f31192b2d4e16bfd679d99a"
99
99
  }
@@ -8,11 +8,10 @@ export function getAbortController(
8
8
  return customAbortControllerImpl;
9
9
  }
10
10
 
11
- // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
12
11
  if (typeof window !== 'undefined' && window.AbortController) {
13
12
  return window.AbortController;
14
13
  }
15
- // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
14
+
16
15
  if (typeof globalThis !== 'undefined' && globalThis.AbortController) {
17
16
  return globalThis.AbortController;
18
17
  }
@@ -52,7 +52,7 @@ export interface RequestInitEsque {
52
52
  /**
53
53
  * Sets the request's body.
54
54
  */
55
- body?: FormData | ReadableStream | string | null;
55
+ body?: FormData | string | null | Uint8Array | Blob | File;
56
56
 
57
57
  /**
58
58
  * Sets the request's associated headers.
@@ -11,8 +11,8 @@ import type {
11
11
  Requester,
12
12
  } from './internals/httpUtils';
13
13
  import {
14
- jsonHttpRequester,
15
14
  resolveHTTPLinkOptions,
15
+ universalRequester,
16
16
  } from './internals/httpUtils';
17
17
  import type { HTTPHeaders, Operation, TRPCLink } from './types';
18
18
 
@@ -91,4 +91,4 @@ export function httpLinkFactory(factoryOpts: { requester: Requester }) {
91
91
  /**
92
92
  * @link https://trpc.io/docs/v11/client/links/httpLink
93
93
  */
94
- export const httpLink = httpLinkFactory({ requester: jsonHttpRequester });
94
+ export const httpLink = httpLinkFactory({ requester: universalRequester });
@@ -0,0 +1,15 @@
1
+ export function isOctetType(input: unknown) {
2
+ return (
3
+ input instanceof Uint8Array ||
4
+ // File extends from Blob but is only available in nodejs from v20
5
+ input instanceof Blob
6
+ );
7
+ }
8
+
9
+ export function isFormData(input: unknown) {
10
+ return input instanceof FormData;
11
+ }
12
+
13
+ export function isNonJsonSerializable(input: unknown) {
14
+ return isOctetType(input) || isFormData(input);
15
+ }
@@ -7,11 +7,10 @@ export function getTextDecoder(
7
7
  return customTextDecoder;
8
8
  }
9
9
 
10
- // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
11
10
  if (typeof window !== 'undefined' && window.TextDecoder) {
12
11
  return new window.TextDecoder();
13
12
  }
14
- // eslint-disable-next-line @typescript-eslint/prefer-optional-chain
13
+
15
14
  if (typeof globalThis !== 'undefined' && globalThis.TextDecoder) {
16
15
  return new globalThis.TextDecoder();
17
16
  }
@@ -18,6 +18,7 @@ import type { TransformerOptions } from '../../unstable-internals';
18
18
  import { getTransformer } from '../../unstable-internals';
19
19
  import type { TextDecoderEsque } from '../internals/streamingUtils';
20
20
  import type { HTTPHeaders, PromiseAndCancel } from '../types';
21
+ import { isFormData, isOctetType } from './contentTypes';
21
22
 
22
23
  /**
23
24
  * @internal
@@ -105,6 +106,7 @@ export type HTTPBaseRequestOptions = GetInputOptions &
105
106
 
106
107
  type GetUrl = (opts: HTTPBaseRequestOptions) => string;
107
108
  type GetBody = (opts: HTTPBaseRequestOptions) => RequestInitEsque['body'];
109
+
108
110
  export type ContentOptions = {
109
111
  batchModeHeader?: 'stream';
110
112
  contentTypeHeader?: string;
@@ -153,6 +155,39 @@ export const jsonHttpRequester: Requester = (opts) => {
153
155
  });
154
156
  };
155
157
 
158
+ export const universalRequester: Requester = (opts) => {
159
+ const input = getInput(opts);
160
+
161
+ if (isFormData(input)) {
162
+ if (opts.type !== 'mutation' && opts.methodOverride !== 'POST') {
163
+ throw new Error('FormData is only supported for mutations');
164
+ }
165
+
166
+ return httpRequest({
167
+ ...opts,
168
+ // The browser will set this automatically and include the boundary= in it
169
+ contentTypeHeader: undefined,
170
+ getUrl,
171
+ getBody: () => input,
172
+ });
173
+ }
174
+
175
+ if (isOctetType(input)) {
176
+ if (opts.type !== 'mutation' && opts.methodOverride !== 'POST') {
177
+ throw new Error('Octet type input is only supported for mutations');
178
+ }
179
+
180
+ return httpRequest({
181
+ ...opts,
182
+ contentTypeHeader: 'application/octet-stream',
183
+ getUrl,
184
+ getBody: () => input,
185
+ });
186
+ }
187
+
188
+ return jsonHttpRequester(opts);
189
+ };
190
+
156
191
  export type HTTPRequestOptions = ContentOptions &
157
192
  HTTPBaseRequestOptions & {
158
193
  headers: () => HTTPHeaders | Promise<HTTPHeaders>;
@@ -7,6 +7,12 @@ import type {
7
7
  import type { ResponseEsque } from '../internals/types';
8
8
  import type { TRPCClientError } from '../TRPCClientError';
9
9
 
10
+ export {
11
+ isNonJsonSerializable,
12
+ isFormData,
13
+ isOctetType,
14
+ } from './internals/contentTypes';
15
+
10
16
  /**
11
17
  * @internal
12
18
  */
package/src/links.ts CHANGED
@@ -7,7 +7,6 @@ export * from './links/httpLink';
7
7
  export * from './links/loggerLink';
8
8
  export * from './links/splitLink';
9
9
  export * from './links/wsLink';
10
- export * from './links/httpFormDataLink';
11
10
 
12
11
  // These are not public (yet) as we get this functionality from tanstack query
13
12
  // export * from './links/internals/retryLink';
@@ -1,2 +0,0 @@
1
- export declare const experimental_formDataLink: <TRouter extends import("@trpc/server/unstable-core-do-not-import").AnyRouter>(opts: import("./httpLink").HTTPLinkOptions<TRouter["_def"]["_config"]["$types"]>) => import("./types").TRPCLink<TRouter>;
2
- //# sourceMappingURL=httpFormDataLink.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"httpFormDataLink.d.ts","sourceRoot":"","sources":["../../src/links/httpFormDataLink.ts"],"names":[],"mappings":"AA0BA,eAAO,MAAM,yBAAyB,yMAEpC,CAAC"}
@@ -1,31 +0,0 @@
1
- 'use strict';
2
-
3
- var httpLink = require('./httpLink.js');
4
- var httpUtils = require('./internals/httpUtils.js');
5
-
6
- const formDataRequester = (opts)=>{
7
- if (opts.type !== 'mutation') {
8
- // TODO(?) handle formdata queries
9
- throw new Error('We only handle mutations with formdata');
10
- }
11
- return httpUtils.httpRequest({
12
- ...opts,
13
- getUrl () {
14
- return `${opts.url}/${opts.path}`;
15
- },
16
- getBody (opts) {
17
- if (!('input' in opts)) {
18
- return undefined;
19
- }
20
- if (!(opts.input instanceof FormData)) {
21
- throw new Error('Input is not FormData');
22
- }
23
- return opts.input;
24
- }
25
- });
26
- };
27
- const experimental_formDataLink = httpLink.httpLinkFactory({
28
- requester: formDataRequester
29
- });
30
-
31
- exports.experimental_formDataLink = experimental_formDataLink;
@@ -1,29 +0,0 @@
1
- import { httpLinkFactory } from './httpLink.mjs';
2
- import { httpRequest } from './internals/httpUtils.mjs';
3
-
4
- const formDataRequester = (opts)=>{
5
- if (opts.type !== 'mutation') {
6
- // TODO(?) handle formdata queries
7
- throw new Error('We only handle mutations with formdata');
8
- }
9
- return httpRequest({
10
- ...opts,
11
- getUrl () {
12
- return `${opts.url}/${opts.path}`;
13
- },
14
- getBody (opts) {
15
- if (!('input' in opts)) {
16
- return undefined;
17
- }
18
- if (!(opts.input instanceof FormData)) {
19
- throw new Error('Input is not FormData');
20
- }
21
- return opts.input;
22
- }
23
- });
24
- };
25
- const experimental_formDataLink = httpLinkFactory({
26
- requester: formDataRequester
27
- });
28
-
29
- export { experimental_formDataLink };
@@ -1,29 +0,0 @@
1
- import { httpLinkFactory } from './httpLink';
2
- import type { Requester } from './internals/httpUtils';
3
- import { httpRequest } from './internals/httpUtils';
4
-
5
- const formDataRequester: Requester = (opts) => {
6
- if (opts.type !== 'mutation') {
7
- // TODO(?) handle formdata queries
8
- throw new Error('We only handle mutations with formdata');
9
- }
10
- return httpRequest({
11
- ...opts,
12
- getUrl() {
13
- return `${opts.url}/${opts.path}`;
14
- },
15
- getBody(opts) {
16
- if (!('input' in opts)) {
17
- return undefined;
18
- }
19
- if (!(opts.input instanceof FormData)) {
20
- throw new Error('Input is not FormData');
21
- }
22
- return opts.input;
23
- },
24
- });
25
- };
26
-
27
- export const experimental_formDataLink = httpLinkFactory({
28
- requester: formDataRequester,
29
- });