@trayio/axios 2.10.0 → 2.11.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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AxiosHttpClient.d.ts","sourceRoot":"","sources":["../../src/http/AxiosHttpClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"AxiosHttpClient.d.ts","sourceRoot":"","sources":["../../src/http/AxiosHttpClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,kBAAkB,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAC7D,OAAO,EAEN,UAAU,EACV,WAAW,EAEX,YAAY,EAEZ,MAAM,2BAA2B,CAAC;AAGnC,OAAO,QAAQ,GAAG,QAAQ,WAAW,CAAC,CAAC;AACvC,OAAO,EAAQ,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAK9D,qBAAa,eAAgB,YAAW,UAAU;IAEhD,OAAO,CAAC,QAAQ,CAAC,WAAW;gBAAX,WAAW,GAAE,WAAqC;IAGpE,OAAO,CACN,MAAM,EAAE,UAAU,EAClB,GAAG,EAAE,MAAM,EACX,OAAO,EAAE,WAAW,GAClB,EAAE,CAAC,UAAU,CAAC,KAAK,EAAE,YAAY,CAAC;IAkFrC,OAAO,CAAC,wBAAwB;IAchC,OAAO,CAAC,2BAA2B;IAUnC,YAAY,aAAc,QAAQ,cAAc,OAAO,MAAM,EAAE,MAAM,CAAC,cAKpE;CACF"}
|
|
@@ -1,34 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
4
|
};
|
|
28
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
6
|
exports.AxiosHttpClient = void 0;
|
|
30
|
-
const TE = __importStar(require("fp-ts/TaskEither"));
|
|
31
|
-
const function_1 = require("fp-ts/function");
|
|
32
7
|
const Http_1 = require("@trayio/commons/http/Http");
|
|
33
8
|
const Task_1 = require("@trayio/commons/task/Task");
|
|
34
9
|
const axios_1 = __importDefault(require("axios"));
|
|
@@ -60,31 +35,33 @@ class AxiosHttpClient {
|
|
|
60
35
|
const finalUrl = Object.entries(request.pathParams).reduce((acc, [key, value]) => acc.replace(`:${key}`, encodeURIComponent(value)), url);
|
|
61
36
|
const headers = Object.entries(request.headers).reduce((acc, [key, value]) => {
|
|
62
37
|
const newValue = typeof value === 'string' ? value : value.join(', ');
|
|
63
|
-
return Object.assign(Object.assign({}, acc), { [key]: newValue });
|
|
38
|
+
return Object.assign(Object.assign({}, acc), { [key.toLowerCase()]: newValue });
|
|
64
39
|
}, {});
|
|
65
40
|
let axiosConfig;
|
|
66
41
|
if (headers['content-type'] &&
|
|
67
42
|
headers['content-type'].includes(Http_1.HttpContentType.MultipartRequestBody)) {
|
|
68
43
|
const formData = new FormData();
|
|
69
44
|
this.appendFields(formData)(request.body.fields);
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
45
|
+
const { files } = request.body;
|
|
46
|
+
Object.keys(files).forEach((key) => {
|
|
47
|
+
var _a;
|
|
48
|
+
const file = files[key];
|
|
49
|
+
formData.append(key, file.content, {
|
|
50
|
+
filename: (_a = file.metadata.name) !== null && _a !== void 0 ? _a : file.key,
|
|
51
|
+
contentType: file.metadata.contentType,
|
|
75
52
|
});
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
53
|
+
});
|
|
54
|
+
axiosConfig = {
|
|
55
|
+
url: finalUrl,
|
|
56
|
+
method: method.toString(),
|
|
57
|
+
data: formData,
|
|
58
|
+
responseType: 'stream',
|
|
59
|
+
headers,
|
|
60
|
+
params: request.queryString,
|
|
61
|
+
};
|
|
62
|
+
return (0, Task_1.createTaskEitherFromPromiseWithSimpleError)(() => (0, axios_1.default)(axiosConfig)
|
|
63
|
+
.then(this.axiosResponseToHttpResponse)
|
|
64
|
+
.catch(this.axiosErrorToHttpResponse.bind(this)));
|
|
88
65
|
}
|
|
89
66
|
axiosConfig = {
|
|
90
67
|
url: finalUrl,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@trayio/axios",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.11.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": "2.
|
|
17
|
+
"@trayio/commons": "2.11.1",
|
|
18
18
|
"axios": "1.6.0",
|
|
19
19
|
"form-data": "4.0.0"
|
|
20
20
|
},
|