@trayio/axios 3.8.1-beta → 3.9.1
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/http/AxiosHttpClient.js +12 -9
- package/package.json +2 -2
|
@@ -11,14 +11,9 @@ const FormData = require("form-data");
|
|
|
11
11
|
const NodeFsFileStorage_1 = require("@trayio/commons/file/NodeFsFileStorage");
|
|
12
12
|
const BufferExtensions_1 = require("@trayio/commons/buffer/BufferExtensions");
|
|
13
13
|
class AxiosHttpClient {
|
|
14
|
+
fileStorage;
|
|
14
15
|
constructor(fileStorage = new NodeFsFileStorage_1.NodeFsFileStorage()) {
|
|
15
16
|
this.fileStorage = fileStorage;
|
|
16
|
-
this.appendFields = (formData) => (fields) => {
|
|
17
|
-
Object.entries(fields).forEach(([key, value]) => {
|
|
18
|
-
formData.append(key, value);
|
|
19
|
-
});
|
|
20
|
-
return formData;
|
|
21
|
-
};
|
|
22
17
|
}
|
|
23
18
|
execute(method, url, request) {
|
|
24
19
|
/*
|
|
@@ -35,7 +30,10 @@ class AxiosHttpClient {
|
|
|
35
30
|
const finalUrl = Object.entries(request.pathParams).reduce((acc, [key, value]) => acc.replace(`:${key}`, encodeURIComponent(value)), url);
|
|
36
31
|
const headers = Object.entries(request.headers).reduce((acc, [key, value]) => {
|
|
37
32
|
const newValue = typeof value === 'string' ? value : value.join(', ');
|
|
38
|
-
return
|
|
33
|
+
return {
|
|
34
|
+
...acc,
|
|
35
|
+
[key.toLowerCase()]: newValue,
|
|
36
|
+
};
|
|
39
37
|
}, {});
|
|
40
38
|
let axiosConfig;
|
|
41
39
|
if (headers['content-type'] &&
|
|
@@ -44,10 +42,9 @@ class AxiosHttpClient {
|
|
|
44
42
|
this.appendFields(formData)(request.body.fields);
|
|
45
43
|
const { files } = request.body;
|
|
46
44
|
Object.keys(files).forEach((key) => {
|
|
47
|
-
var _a;
|
|
48
45
|
const file = files[key];
|
|
49
46
|
formData.append(key, file.content, {
|
|
50
|
-
filename:
|
|
47
|
+
filename: file.metadata.name ?? file.key,
|
|
51
48
|
contentType: file.metadata.contentType,
|
|
52
49
|
});
|
|
53
50
|
});
|
|
@@ -92,5 +89,11 @@ class AxiosHttpClient {
|
|
|
92
89
|
body: axiosResponse.data,
|
|
93
90
|
};
|
|
94
91
|
}
|
|
92
|
+
appendFields = (formData) => (fields) => {
|
|
93
|
+
Object.entries(fields).forEach(([key, value]) => {
|
|
94
|
+
formData.append(key, value);
|
|
95
|
+
});
|
|
96
|
+
return formData;
|
|
97
|
+
};
|
|
95
98
|
}
|
|
96
99
|
exports.AxiosHttpClient = AxiosHttpClient;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trayio/axios",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.9.1",
|
|
4
4
|
"description": "Axios extensions and implementations",
|
|
5
5
|
"exports": {
|
|
6
6
|
"./*": "./dist/*.js"
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@trayio/commons": "3.
|
|
17
|
+
"@trayio/commons": "3.9.1",
|
|
18
18
|
"axios": "1.6.0",
|
|
19
19
|
"form-data": "4.0.0"
|
|
20
20
|
},
|