@mepkg/maxios 3.0.0 → 3.0.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/package.json +4 -4
- package/src/helpers.js +6 -7
- package/src/maxios.js +6 -6
- package/src/tls-client.js +11 -11
package/package.json
CHANGED
|
@@ -14,10 +14,10 @@
|
|
|
14
14
|
"test:watch": "node --test --watch 'tests/**/*.test.js'"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"axios": "1.
|
|
18
|
-
"es-toolkit": "^1.
|
|
17
|
+
"axios": "^1.18.1",
|
|
18
|
+
"es-toolkit": "^1.48.1",
|
|
19
19
|
"hpagent": "^1.2.0",
|
|
20
|
-
"melperjs": "^17.
|
|
20
|
+
"melperjs": "^17.2.0"
|
|
21
21
|
},
|
|
22
|
-
"version": "3.0.
|
|
22
|
+
"version": "3.0.1"
|
|
23
23
|
}
|
package/src/helpers.js
CHANGED
|
@@ -16,13 +16,6 @@ export function jsonMethod(throwOnError = false) {
|
|
|
16
16
|
|
|
17
17
|
export function attachJsonMethod(response) {
|
|
18
18
|
response.json = jsonMethod;
|
|
19
|
-
return response;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export function mergeResponseCookies(cookies, response) {
|
|
23
|
-
if (!cookies) return cookies;
|
|
24
|
-
const parsed = omitBy(cookiesFromResponse(response), isNil);
|
|
25
|
-
return {...cookies, ...parsed};
|
|
26
19
|
}
|
|
27
20
|
|
|
28
21
|
export function attachRequestCookies(cookies, request) {
|
|
@@ -32,4 +25,10 @@ export function attachRequestCookies(cookies, request) {
|
|
|
32
25
|
const header = cookiesToHeader(cookies);
|
|
33
26
|
header && (request.headers.cookie = header);
|
|
34
27
|
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function mergeResponseCookies(cookies, response) {
|
|
31
|
+
if (!cookies) return cookies;
|
|
32
|
+
const parsed = omitBy(cookiesFromResponse(response), isNil);
|
|
33
|
+
return {...cookies, ...parsed};
|
|
35
34
|
}
|
package/src/maxios.js
CHANGED
|
@@ -109,23 +109,23 @@ export class Maxios {
|
|
|
109
109
|
|
|
110
110
|
/**
|
|
111
111
|
* @param {string} url
|
|
112
|
+
* @param {*} [data]
|
|
112
113
|
* @param {import("axios").AxiosRequestConfig} [config]
|
|
113
114
|
* @returns {Promise<MaxiosResponse>}
|
|
114
115
|
*/
|
|
115
|
-
async
|
|
116
|
+
async patch(url, data = {}, config = {}) {
|
|
116
117
|
config.headers = omitBy(config.headers, isNil);
|
|
117
|
-
return /** @type {Promise<MaxiosResponse>} */ (this.client.
|
|
118
|
+
return /** @type {Promise<MaxiosResponse>} */ (this.client.patch(url, data, config));
|
|
118
119
|
}
|
|
119
120
|
|
|
120
121
|
/**
|
|
121
122
|
* @param {string} url
|
|
122
|
-
* @param {*} [data]
|
|
123
123
|
* @param {import("axios").AxiosRequestConfig} [config]
|
|
124
124
|
* @returns {Promise<MaxiosResponse>}
|
|
125
125
|
*/
|
|
126
|
-
async
|
|
126
|
+
async delete(url, config = {}) {
|
|
127
127
|
config.headers = omitBy(config.headers, isNil);
|
|
128
|
-
return /** @type {Promise<MaxiosResponse>} */ (this.client.
|
|
128
|
+
return /** @type {Promise<MaxiosResponse>} */ (this.client.delete(url, config));
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
/**
|
|
@@ -151,7 +151,7 @@ export class Maxios {
|
|
|
151
151
|
#attachFinalUrl = (response) => {
|
|
152
152
|
response.finalUrl = response?.request?.res?.responseUrl
|
|
153
153
|
|| (response?.config && this.client.getUri(response.config))
|
|
154
|
-
||
|
|
154
|
+
|| '';
|
|
155
155
|
}
|
|
156
156
|
|
|
157
157
|
}
|
package/src/tls-client.js
CHANGED
|
@@ -24,7 +24,12 @@ export class TlsClient {
|
|
|
24
24
|
responseBodyFormat = "text",
|
|
25
25
|
validateStatus = (status) => (status >= 200 && status <= 299) || (maxRedirects && status >= 300 && status <= 399)
|
|
26
26
|
} = {}) {
|
|
27
|
+
this.tlsServer = tlsServer;
|
|
28
|
+
if (!this.tlsServer.url) {
|
|
29
|
+
throw Exception("TLS Server URL is not defined");
|
|
30
|
+
}
|
|
27
31
|
this.proxy = proxy;
|
|
32
|
+
this.cookies = cookies;
|
|
28
33
|
this.config = {
|
|
29
34
|
timeout,
|
|
30
35
|
httpVersion,
|
|
@@ -35,11 +40,6 @@ export class TlsClient {
|
|
|
35
40
|
responseBodyFormat,
|
|
36
41
|
validateStatus
|
|
37
42
|
};
|
|
38
|
-
this.cookies = cookies;
|
|
39
|
-
this.tlsServer = tlsServer;
|
|
40
|
-
if (!this.tlsServer.url) {
|
|
41
|
-
throw Exception("TLS Server URL is not defined");
|
|
42
|
-
}
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
async request({
|
|
@@ -87,7 +87,7 @@ export class TlsClient {
|
|
|
87
87
|
"url": url,
|
|
88
88
|
"headers": headers || {},
|
|
89
89
|
"data": data || "",
|
|
90
|
-
"timeout": timeout
|
|
90
|
+
"timeout": timeout ?? this.config.timeout,
|
|
91
91
|
"httpVersion": httpVersion || this.config.httpVersion,
|
|
92
92
|
"proxy": proxy || this.proxy || undefined,
|
|
93
93
|
"impersonate": impersonate || this.config.impersonate,
|
|
@@ -150,16 +150,16 @@ export class TlsClient {
|
|
|
150
150
|
return this.request(config);
|
|
151
151
|
}
|
|
152
152
|
|
|
153
|
-
async
|
|
153
|
+
async patch(url, data, config = {}) {
|
|
154
154
|
config.url = url;
|
|
155
|
-
config.method = "
|
|
155
|
+
config.method = "PATCH";
|
|
156
|
+
config.data = data;
|
|
156
157
|
return this.request(config);
|
|
157
158
|
}
|
|
158
159
|
|
|
159
|
-
async
|
|
160
|
+
async delete(url, config = {}) {
|
|
160
161
|
config.url = url;
|
|
161
|
-
config.method = "
|
|
162
|
-
config.data = data;
|
|
162
|
+
config.method = "DELETE";
|
|
163
163
|
return this.request(config);
|
|
164
164
|
}
|
|
165
165
|
|