@vroskus/library-api 1.1.1 → 1.1.2
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 +29 -1
- package/package.json +5 -5
package/dist/index.js
CHANGED
|
@@ -60,6 +60,34 @@ const defaultRetryDelay = 3000;
|
|
|
60
60
|
const defaultRetryQuantity = 3;
|
|
61
61
|
const defaultRetryIncrementor = 1;
|
|
62
62
|
const zeroValue = 0;
|
|
63
|
+
const isRecord = (obj) => {
|
|
64
|
+
if (obj === null || typeof obj !== 'object') {
|
|
65
|
+
return false;
|
|
66
|
+
}
|
|
67
|
+
if (Array.isArray(obj)) {
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
if (Object.getOwnPropertySymbols(obj).length > zeroValue) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
return true;
|
|
74
|
+
};
|
|
75
|
+
const parseRequestData = (value) => {
|
|
76
|
+
if (typeof value === 'string') {
|
|
77
|
+
try {
|
|
78
|
+
return JSON.parse(value);
|
|
79
|
+
}
|
|
80
|
+
catch (_e) {
|
|
81
|
+
if (_e) {
|
|
82
|
+
return Object.fromEntries(new URLSearchParams(value));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
if (isRecord(value) === true) {
|
|
87
|
+
return value;
|
|
88
|
+
}
|
|
89
|
+
return undefined;
|
|
90
|
+
};
|
|
63
91
|
class ApiService {
|
|
64
92
|
constructor({ apiUrl, headers, httpsAgent, interceptors, timeout, }) {
|
|
65
93
|
_ApiService_instances.add(this);
|
|
@@ -172,7 +200,7 @@ _ApiService_unauthenticatedHandler = new WeakMap(), _ApiService_requestContextLi
|
|
|
172
200
|
const responseContext = {
|
|
173
201
|
Duration: endTimestamp - startTimestamp,
|
|
174
202
|
Method: `${(config.method || 'Unknown').toUpperCase()}`,
|
|
175
|
-
RequestData:
|
|
203
|
+
RequestData: parseRequestData(config.data),
|
|
176
204
|
RequestHeaders: config.headers,
|
|
177
205
|
RequestId: requestId,
|
|
178
206
|
RequestParams: config.params,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vroskus/library-api",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"description": "Api",
|
|
5
5
|
"author": "Vilius Roškus <vilius@regattas.eu>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -52,10 +52,10 @@
|
|
|
52
52
|
],
|
|
53
53
|
"coverageThreshold": {
|
|
54
54
|
"global": {
|
|
55
|
-
"branches":
|
|
56
|
-
"functions":
|
|
57
|
-
"lines":
|
|
58
|
-
"statements": 79.
|
|
55
|
+
"branches": 58.82,
|
|
56
|
+
"functions": 78.37,
|
|
57
|
+
"lines": 86.25,
|
|
58
|
+
"statements": 79.47
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
}
|