@machinemetrics/mm-erp-sdk 0.1.1-beta.2 → 0.1.1-beta.3
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/mm-erp-sdk.js +12 -7
- package/dist/mm-erp-sdk.js.map +1 -1
- package/package.json +1 -1
- package/src/utils/http-client.ts +14 -7
package/dist/mm-erp-sdk.js
CHANGED
|
@@ -143,18 +143,23 @@ class AxiosClient {
|
|
|
143
143
|
data: config2.data,
|
|
144
144
|
params: config2.params
|
|
145
145
|
};
|
|
146
|
-
logger.
|
|
146
|
+
logger.info("HTTP request starting", {
|
|
147
147
|
url: config2.url,
|
|
148
148
|
method: config2.method,
|
|
149
149
|
baseURL: this.client.defaults.baseURL,
|
|
150
150
|
retryAttempts: this.retryAttempts
|
|
151
151
|
});
|
|
152
|
+
console.log("=== FULL URL DEBUG ===");
|
|
153
|
+
console.log("baseURL:", this.client.defaults.baseURL);
|
|
154
|
+
console.log("relative url:", config2.url);
|
|
155
|
+
console.log("full constructed URL:", (this.client.defaults.baseURL || "") + config2.url);
|
|
156
|
+
console.log("method:", config2.method);
|
|
152
157
|
let lastError;
|
|
153
158
|
for (let attempt = 0; attempt <= this.retryAttempts; attempt++) {
|
|
154
159
|
try {
|
|
155
|
-
logger.
|
|
160
|
+
logger.info(`HTTP request attempt ${attempt + 1}/${this.retryAttempts + 1}`);
|
|
156
161
|
const response = await this.client.request(axiosConfig);
|
|
157
|
-
logger.
|
|
162
|
+
logger.info("HTTP request succeeded", { status: response.status });
|
|
158
163
|
return {
|
|
159
164
|
data: response.data,
|
|
160
165
|
status: response.status,
|
|
@@ -162,7 +167,7 @@ class AxiosClient {
|
|
|
162
167
|
};
|
|
163
168
|
} catch (error) {
|
|
164
169
|
lastError = error;
|
|
165
|
-
logger.
|
|
170
|
+
logger.info(`HTTP request attempt ${attempt + 1} failed`, {
|
|
166
171
|
errorType: typeof error,
|
|
167
172
|
errorConstructor: error?.constructor?.name,
|
|
168
173
|
isAxiosError: error instanceof AxiosError,
|
|
@@ -171,19 +176,19 @@ class AxiosClient {
|
|
|
171
176
|
status: error?.response?.status
|
|
172
177
|
});
|
|
173
178
|
if (error instanceof AxiosError && error.response?.status && error.response.status >= 400 && error.response.status < 500) {
|
|
174
|
-
logger.
|
|
179
|
+
logger.info("Not retrying due to 4xx client error");
|
|
175
180
|
break;
|
|
176
181
|
}
|
|
177
182
|
if (attempt < this.retryAttempts) {
|
|
178
183
|
const waitTime = Math.pow(2, attempt) * 1e3;
|
|
179
|
-
logger.
|
|
184
|
+
logger.info(`Waiting ${waitTime}ms before retry`);
|
|
180
185
|
await new Promise(
|
|
181
186
|
(resolve) => setTimeout(resolve, Math.pow(2, attempt) * 1e3)
|
|
182
187
|
);
|
|
183
188
|
}
|
|
184
189
|
}
|
|
185
190
|
}
|
|
186
|
-
logger.
|
|
191
|
+
logger.info("HTTP request failed after all retries, throwing error");
|
|
187
192
|
throw this.handleError(lastError, config2);
|
|
188
193
|
}
|
|
189
194
|
handleError(error, requestConfig) {
|