@trpc/client 11.0.0-rc.340 → 11.0.0-rc.345
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.
- package/dist/bundle-analysis.json +59 -57
- package/dist/index.js +4 -2
- package/dist/index.mjs +1 -1
- package/dist/internals/types.d.ts +1 -1
- package/dist/internals/types.d.ts.map +1 -1
- package/dist/links/httpLink.d.ts.map +1 -1
- package/dist/links/httpLink.js +1 -1
- package/dist/links/httpLink.mjs +2 -2
- package/dist/links/internals/contentTypes.d.ts +4 -0
- package/dist/links/internals/contentTypes.d.ts.map +1 -0
- package/dist/links/internals/contentTypes.js +16 -0
- package/dist/links/internals/contentTypes.mjs +12 -0
- package/dist/links/internals/httpUtils.d.ts +1 -0
- package/dist/links/internals/httpUtils.d.ts.map +1 -1
- package/dist/links/internals/httpUtils.js +29 -0
- package/dist/links/internals/httpUtils.mjs +29 -1
- package/dist/links/types.d.ts +1 -1
- package/dist/links/types.d.ts.map +1 -1
- package/dist/links.d.ts +0 -1
- package/dist/links.d.ts.map +1 -1
- package/package.json +4 -4
- package/src/internals/types.ts +1 -1
- package/src/links/httpLink.ts +2 -2
- package/src/links/internals/contentTypes.ts +15 -0
- package/src/links/internals/httpUtils.ts +35 -0
- package/src/links/types.ts +6 -0
- package/src/links.ts +0 -1
- package/dist/links/httpFormDataLink.d.ts +0 -2
- package/dist/links/httpFormDataLink.d.ts.map +0 -1
- package/dist/links/httpFormDataLink.js +0 -31
- package/dist/links/httpFormDataLink.mjs +0 -29
- package/src/links/httpFormDataLink.ts +0 -29
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
|
-
"bundleSize":
|
|
3
|
-
"bundleOrigSize":
|
|
4
|
-
"bundleReduction":
|
|
2
|
+
"bundleSize": 47274,
|
|
3
|
+
"bundleOrigSize": 66451,
|
|
4
|
+
"bundleReduction": 28.86,
|
|
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.
|
|
16
|
+
"percent": 25.51,
|
|
17
17
|
"reduction": 11.68
|
|
18
18
|
},
|
|
19
19
|
{
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
],
|
|
26
26
|
"removedExports": [],
|
|
27
27
|
"dependents": [],
|
|
28
|
-
"percent": 11.
|
|
28
|
+
"percent": 11.73,
|
|
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.
|
|
42
|
+
"percent": 9.33,
|
|
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":
|
|
63
|
-
"origSize":
|
|
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":
|
|
81
|
-
"reduction":
|
|
65
|
+
"percent": 9.32,
|
|
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.48,
|
|
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.
|
|
95
|
+
"percent": 6.23,
|
|
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.
|
|
110
|
+
"percent": 4.86,
|
|
111
111
|
"reduction": 45.35
|
|
112
112
|
},
|
|
113
113
|
{
|
|
114
114
|
"id": "/src/links/httpLink.ts",
|
|
115
|
-
"size":
|
|
116
|
-
"origSize":
|
|
115
|
+
"size": 2170,
|
|
116
|
+
"origSize": 2755,
|
|
117
117
|
"renderedExports": [
|
|
118
118
|
"httpLinkFactory",
|
|
119
119
|
"httpLink"
|
|
120
120
|
],
|
|
121
121
|
"removedExports": [],
|
|
122
|
-
"dependents": [
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
"percent": 4.64,
|
|
126
|
-
"reduction": 21.21
|
|
122
|
+
"dependents": [],
|
|
123
|
+
"percent": 4.59,
|
|
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":
|
|
142
|
+
"percent": 3.95,
|
|
145
143
|
"reduction": 45.71
|
|
146
144
|
},
|
|
147
145
|
{
|
|
@@ -153,7 +151,7 @@
|
|
|
153
151
|
],
|
|
154
152
|
"removedExports": [],
|
|
155
153
|
"dependents": [],
|
|
156
|
-
"percent": 2.
|
|
154
|
+
"percent": 2.83,
|
|
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.
|
|
171
|
+
"percent": 2.55,
|
|
174
172
|
"reduction": 72.4
|
|
175
173
|
},
|
|
176
174
|
{
|
|
@@ -182,21 +180,9 @@
|
|
|
182
180
|
],
|
|
183
181
|
"removedExports": [],
|
|
184
182
|
"dependents": [],
|
|
185
|
-
"percent": 2.
|
|
183
|
+
"percent": 2.55,
|
|
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.
|
|
198
|
+
"percent": 1.46,
|
|
213
199
|
"reduction": 32.75
|
|
214
200
|
},
|
|
215
201
|
{
|
|
@@ -221,7 +207,7 @@
|
|
|
221
207
|
],
|
|
222
208
|
"removedExports": [],
|
|
223
209
|
"dependents": [],
|
|
224
|
-
"percent": 1.
|
|
210
|
+
"percent": 1.29,
|
|
225
211
|
"reduction": 44.95
|
|
226
212
|
},
|
|
227
213
|
{
|
|
@@ -235,7 +221,7 @@
|
|
|
235
221
|
"dependents": [
|
|
236
222
|
"/src/unstable-internals.ts"
|
|
237
223
|
],
|
|
238
|
-
"percent": 1.
|
|
224
|
+
"percent": 1.2,
|
|
239
225
|
"reduction": 66.75
|
|
240
226
|
},
|
|
241
227
|
{
|
|
@@ -249,7 +235,7 @@
|
|
|
249
235
|
"dependents": [
|
|
250
236
|
"/src/links/httpBatchStreamLink.ts"
|
|
251
237
|
],
|
|
252
|
-
"percent": 1.
|
|
238
|
+
"percent": 1.17,
|
|
253
239
|
"reduction": 12.78
|
|
254
240
|
},
|
|
255
241
|
{
|
|
@@ -263,7 +249,7 @@
|
|
|
263
249
|
"dependents": [
|
|
264
250
|
"/src/links/internals/httpUtils.ts"
|
|
265
251
|
],
|
|
266
|
-
"percent": 1.
|
|
252
|
+
"percent": 1.15,
|
|
267
253
|
"reduction": 23.66
|
|
268
254
|
},
|
|
269
255
|
{
|
|
@@ -278,9 +264,25 @@
|
|
|
278
264
|
"/src/index.ts",
|
|
279
265
|
"/src/links/internals/httpUtils.ts"
|
|
280
266
|
],
|
|
281
|
-
"percent": 0.
|
|
267
|
+
"percent": 0.91,
|
|
282
268
|
"reduction": 33.54
|
|
283
269
|
},
|
|
270
|
+
{
|
|
271
|
+
"id": "/src/links/internals/contentTypes.ts",
|
|
272
|
+
"size": 330,
|
|
273
|
+
"origSize": 389,
|
|
274
|
+
"renderedExports": [
|
|
275
|
+
"isOctetType",
|
|
276
|
+
"isFormData",
|
|
277
|
+
"isNonJsonSerializable"
|
|
278
|
+
],
|
|
279
|
+
"removedExports": [],
|
|
280
|
+
"dependents": [
|
|
281
|
+
"/src/links/internals/httpUtils.ts"
|
|
282
|
+
],
|
|
283
|
+
"percent": 0.7,
|
|
284
|
+
"reduction": 15.17
|
|
285
|
+
},
|
|
284
286
|
{
|
|
285
287
|
"id": "/src/createTRPCUntypedClient.ts",
|
|
286
288
|
"size": 100,
|
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":"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,EAAE,QAAQ,GAAG,
|
|
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,CAA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IAAI,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;CAC1B;AAED;;GAEG;AACH,MAAM,MAAM,aAAa,CAAC,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,
|
|
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"}
|
package/dist/links/httpLink.js
CHANGED
|
@@ -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.
|
|
59
|
+
requester: httpUtils.universalRequester
|
|
60
60
|
});
|
|
61
61
|
|
|
62
62
|
exports.httpLink = httpLink;
|
package/dist/links/httpLink.mjs
CHANGED
|
@@ -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,
|
|
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:
|
|
57
|
+
requester: universalRequester
|
|
58
58
|
});
|
|
59
59
|
|
|
60
60
|
export { httpLink, httpLinkFactory };
|
|
@@ -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 };
|
|
@@ -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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"httpUtils.d.ts","sourceRoot":"","sources":["../../../src/links/internals/httpUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,uBAAuB,EACvB,aAAa,EACb,YAAY,EACb,MAAM,0CAA0C,CAAC;AAGlD,OAAO,KAAK,EACV,oBAAoB,EACpB,4BAA4B,EAC5B,UAAU,EACV,gBAAgB,EAChB,aAAa,EACd,MAAM,uBAAuB,CAAC;AAE/B,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AAEnE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AACpE,OAAO,KAAK,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"httpUtils.d.ts","sourceRoot":"","sources":["../../../src/links/internals/httpUtils.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,YAAY,EACZ,uBAAuB,EACvB,aAAa,EACb,YAAY,EACb,MAAM,0CAA0C,CAAC;AAGlD,OAAO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
|
@@ -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 };
|
package/dist/links/types.d.ts
CHANGED
|
@@ -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;;GAE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uBAAuB,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC;AAE/E;;GAEG;AACH,MAAM,MAAM,uBAAuB,CACjC,WAAW,SAAS,qBAAqB,EACzC,OAAO,IACL,QAAQ,CAAC,uBAAuB,CAAC,OAAO,CAAC,EAAE,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC;AAE7E;;GAEG;AACH,MAAM,MAAM,aAAa,CACvB,WAAW,SAAS,qBAAqB,EACzC,MAAM,GAAG,OAAO,EAChB,OAAO,GAAG,OAAO,IACf,CAAC,IAAI,EAAE;IACT,EAAE,EAAE,SAAS,CAAC,MAAM,CAAC,CAAC;IACtB,IAAI,EAAE,CACJ,EAAE,EAAE,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
package/dist/links.d.ts.map
CHANGED
|
@@ -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
|
|
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.
|
|
3
|
+
"version": "11.0.0-rc.345+6e01a29cf",
|
|
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.
|
|
79
|
+
"@trpc/server": "11.0.0-rc.345+6e01a29cf"
|
|
80
80
|
},
|
|
81
81
|
"devDependencies": {
|
|
82
|
-
"@trpc/server": "11.0.0-rc.
|
|
82
|
+
"@trpc/server": "11.0.0-rc.345+6e01a29cf",
|
|
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": "
|
|
98
|
+
"gitHead": "6e01a29cf4343cc2a303c62753df3fd70d489123"
|
|
99
99
|
}
|
package/src/internals/types.ts
CHANGED
package/src/links/httpLink.ts
CHANGED
|
@@ -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:
|
|
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
|
+
}
|
|
@@ -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>;
|
package/src/links/types.ts
CHANGED
|
@@ -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
|
-
});
|