@vulog/aima-client 1.1.36 → 1.1.38
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/index.js +4 -3
- package/dist/index.mjs +4 -3
- package/package.json +3 -3
- package/src/CurlHelper.ts +1 -1
- package/src/getClient.ts +6 -2
package/dist/index.js
CHANGED
|
@@ -78,7 +78,7 @@ var CurlHelper = class {
|
|
|
78
78
|
if (this.request.baseURL) {
|
|
79
79
|
const baseUrl = this.request.baseURL;
|
|
80
80
|
const { url } = this.request;
|
|
81
|
-
const finalUrl = `${baseUrl}/${url}`;
|
|
81
|
+
const finalUrl = url.startsWith("http") ? url : `${baseUrl}/${url}`;
|
|
82
82
|
return finalUrl.replace(/\/{2,}/g, "/").replace("http:/", "http://").replace("https:/", "https://");
|
|
83
83
|
}
|
|
84
84
|
return this.request.url;
|
|
@@ -280,8 +280,9 @@ var getClient = (options) => {
|
|
|
280
280
|
if (options.logResponse) {
|
|
281
281
|
const finalUrl = new CurlHelper(response.config).getBuiltURL();
|
|
282
282
|
const { data, headers } = response;
|
|
283
|
-
|
|
284
|
-
|
|
283
|
+
const dataLog = response.config.responseType !== "arraybuffer" && response.config.responseType !== "blob" ? data : "ArrayBuffer or blob";
|
|
284
|
+
if (options.onLog) options.onLog({ finalUrl, data: dataLog, headers, message: "getClient > Response" });
|
|
285
|
+
else console.log({ finalUrl, data: dataLog, headers, message: "getClient > Response" });
|
|
285
286
|
}
|
|
286
287
|
return response;
|
|
287
288
|
},
|
package/dist/index.mjs
CHANGED
|
@@ -42,7 +42,7 @@ var CurlHelper = class {
|
|
|
42
42
|
if (this.request.baseURL) {
|
|
43
43
|
const baseUrl = this.request.baseURL;
|
|
44
44
|
const { url } = this.request;
|
|
45
|
-
const finalUrl = `${baseUrl}/${url}`;
|
|
45
|
+
const finalUrl = url.startsWith("http") ? url : `${baseUrl}/${url}`;
|
|
46
46
|
return finalUrl.replace(/\/{2,}/g, "/").replace("http:/", "http://").replace("https:/", "https://");
|
|
47
47
|
}
|
|
48
48
|
return this.request.url;
|
|
@@ -244,8 +244,9 @@ var getClient = (options) => {
|
|
|
244
244
|
if (options.logResponse) {
|
|
245
245
|
const finalUrl = new CurlHelper(response.config).getBuiltURL();
|
|
246
246
|
const { data, headers } = response;
|
|
247
|
-
|
|
248
|
-
|
|
247
|
+
const dataLog = response.config.responseType !== "arraybuffer" && response.config.responseType !== "blob" ? data : "ArrayBuffer or blob";
|
|
248
|
+
if (options.onLog) options.onLog({ finalUrl, data: dataLog, headers, message: "getClient > Response" });
|
|
249
|
+
else console.log({ finalUrl, data: dataLog, headers, message: "getClient > Response" });
|
|
249
250
|
}
|
|
250
251
|
return response;
|
|
251
252
|
},
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vulog/aima-client",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.38",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/index.mjs",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
"author": "Vulog",
|
|
21
21
|
"license": "ISC",
|
|
22
22
|
"peerDependencies": {
|
|
23
|
-
"axios": "^1.
|
|
24
|
-
"es-toolkit": "^1.
|
|
23
|
+
"axios": "^1.8.4",
|
|
24
|
+
"es-toolkit": "^1.33.0",
|
|
25
25
|
"lru-cache": "^11.0.2"
|
|
26
26
|
},
|
|
27
27
|
"description": ""
|
package/src/CurlHelper.ts
CHANGED
|
@@ -59,7 +59,7 @@ export class CurlHelper {
|
|
|
59
59
|
if (this.request.baseURL) {
|
|
60
60
|
const baseUrl = this.request.baseURL;
|
|
61
61
|
const { url } = this.request;
|
|
62
|
-
const finalUrl = `${baseUrl}/${url}`;
|
|
62
|
+
const finalUrl = url.startsWith('http') ? url : `${baseUrl}/${url}`;
|
|
63
63
|
return finalUrl
|
|
64
64
|
.replace(/\/{2,}/g, '/')
|
|
65
65
|
.replace('http:/', 'http://')
|
package/src/getClient.ts
CHANGED
|
@@ -203,9 +203,13 @@ const getClient = (options: ClientOptions): Client => {
|
|
|
203
203
|
if (options.logResponse) {
|
|
204
204
|
const finalUrl = new CurlHelper(response.config).getBuiltURL();
|
|
205
205
|
const { data, headers } = response;
|
|
206
|
-
|
|
206
|
+
const dataLog =
|
|
207
|
+
response.config.responseType !== 'arraybuffer' && response.config.responseType !== 'blob'
|
|
208
|
+
? data
|
|
209
|
+
: 'ArrayBuffer or blob';
|
|
210
|
+
if (options.onLog) options.onLog({ finalUrl, data: dataLog, headers, message: 'getClient > Response' });
|
|
207
211
|
// eslint-disable-next-line no-console
|
|
208
|
-
else console.log({ finalUrl, data, headers, message: 'getClient > Response' });
|
|
212
|
+
else console.log({ finalUrl, data: dataLog, headers, message: 'getClient > Response' });
|
|
209
213
|
}
|
|
210
214
|
return response;
|
|
211
215
|
},
|