@machinemetrics/mm-erp-sdk 0.1.1-beta.2 → 0.1.1-beta.4
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/{hashed-cache-manager-Ci9X3GAB.js → hashed-cache-manager-DkDox9wX.js} +5 -1
- package/dist/{hashed-cache-manager-Ci9X3GAB.js.map → hashed-cache-manager-DkDox9wX.js.map} +1 -1
- package/dist/mm-erp-sdk.js +19 -9
- package/dist/mm-erp-sdk.js.map +1 -1
- package/dist/services/data-sync-service/configuration-manager.d.ts.map +1 -1
- package/dist/services/data-sync-service/jobs/clean-up-expired-cache.js +1 -1
- package/dist/services/mm-api-service/token-mgr.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/services/data-sync-service/configuration-manager.ts +4 -0
- package/src/services/mm-api-service/token-mgr.ts +5 -0
- package/src/utils/http-client.ts +14 -7
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration-manager.d.ts","sourceRoot":"","sources":["../../../src/services/data-sync-service/configuration-manager.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAEvB,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AAEjF,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAoB;IAG3C,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,OAAO,EAAE,MAAM,CAAC;IAGhC,SAAgB,kBAAkB,EAAE,MAAM,CAAC;IAC3C,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAgB,cAAc,EAAE,MAAM,CAAC;IACvC,SAAgB,kBAAkB,EAAE,MAAM,CAAC;IAG3C,SAAgB,QAAQ,EAAE,MAAM,CAAC;IAGjC,SAAgB,sBAAsB,EAAE,MAAM,CAAC;IAC/C,SAAgB,iBAAiB,EAAE,MAAM,CAAC;IAG1C,SAAgB,eAAe,EAAE,MAAM,CAAC;IACxC,SAAgB,aAAa,EAAE,MAAM,CAAC;IACtC,SAAgB,yBAAyB,EAAE,MAAM,CAAC;IAClD,SAAgB,4BAA4B,EAAE,MAAM,CAAC;IAErD,OAAO;
|
|
1
|
+
{"version":3,"file":"configuration-manager.d.ts","sourceRoot":"","sources":["../../../src/services/data-sync-service/configuration-manager.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAEvB,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AAEjF,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAoB;IAG3C,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,OAAO,EAAE,MAAM,CAAC;IAGhC,SAAgB,kBAAkB,EAAE,MAAM,CAAC;IAC3C,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAgB,cAAc,EAAE,MAAM,CAAC;IACvC,SAAgB,kBAAkB,EAAE,MAAM,CAAC;IAG3C,SAAgB,QAAQ,EAAE,MAAM,CAAC;IAGjC,SAAgB,sBAAsB,EAAE,MAAM,CAAC;IAC/C,SAAgB,iBAAiB,EAAE,MAAM,CAAC;IAG1C,SAAgB,eAAe,EAAE,MAAM,CAAC;IACxC,SAAgB,aAAa,EAAE,MAAM,CAAC;IACtC,SAAgB,yBAAyB,EAAE,MAAM,CAAC;IAClD,SAAgB,4BAA4B,EAAE,MAAM,CAAC;IAErD,OAAO;WAkEO,IAAI,IAAI,iBAAiB;CAMxC;AAED;;GAEG;AACH,eAAO,MAAM,yBAAyB,QAAO,sBAiB5C,CAAC;AAEF;;;GAGG;AACH,qBAAa,sBAAsB;aAEf,SAAS,EAAE,MAAM;aACjB,cAAc,EAAE,MAAM;aACtB,kBAAkB,EAAE,MAAM;aAC1B,oBAAoB,EAAE,MAAM;aAC5B,cAAc,EAAE,MAAM;aACtB,aAAa,EAAE,MAAM;gBALrB,SAAS,EAAE,MAAM,EAAE,kBAAkB;IACrC,cAAc,EAAE,MAAM,EAAE,qCAAqC;IAC7D,kBAAkB,EAAE,MAAM,EAAE,yCAAyC;IACrE,oBAAoB,EAAE,MAAM,EAAE,2BAA2B;IACzD,cAAc,EAAE,MAAM,EAAE,gBAAgB;IACxC,aAAa,GAAE,MAAU;CAE5C;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,QAAO,sBAS5C,CAAC"}
|
|
@@ -3,7 +3,7 @@ var __commonJS = (cb, mod) => function __require() {
|
|
|
3
3
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
4
|
};
|
|
5
5
|
import "../../../config-2l5vnNkA.js";
|
|
6
|
-
import { H as HashedCacheManager } from "../../../hashed-cache-manager-
|
|
6
|
+
import { H as HashedCacheManager } from "../../../hashed-cache-manager-DkDox9wX.js";
|
|
7
7
|
import { S as SQLiteCoordinator } from "../../../index-Cn9ccxOO.js";
|
|
8
8
|
import { l as logger } from "../../../logger-QG73MndU.js";
|
|
9
9
|
var require_clean_up_expired_cache = __commonJS({
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"token-mgr.d.ts","sourceRoot":"","sources":["../../../src/services/mm-api-service/token-mgr.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,eAAe,CAAc;IACrC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,GAAG,CAAa;;
|
|
1
|
+
{"version":3,"file":"token-mgr.d.ts","sourceRoot":"","sources":["../../../src/services/mm-api-service/token-mgr.ts"],"names":[],"mappings":"AAQA;;;;GAIG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,eAAe,CAAc;IACrC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,GAAG,CAAa;;IAqBxB;;;OAGG;IACH,OAAO,CAAC,cAAc;IAatB;;;;OAIG;IACH,OAAO,CAAC,kBAAkB;IA2B1B;;;OAGG;IACU,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;IA4BxC;;OAEG;IACI,eAAe,IAAI,IAAI;CAK/B"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@machinemetrics/mm-erp-sdk",
|
|
3
3
|
"description": "A library for syncing data between MachineMetrics and ERP systems",
|
|
4
|
-
"version": "0.1.1-beta.
|
|
4
|
+
"version": "0.1.1-beta.4",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "machinemetrics",
|
|
7
7
|
"main": "dist/mm-erp-sdk.js",
|
|
@@ -43,7 +43,11 @@ export class CoreConfiguration {
|
|
|
43
43
|
/**
|
|
44
44
|
* MM REST API URL (typically https://api.machinemetrics.com)
|
|
45
45
|
*/
|
|
46
|
+
console.log("=== CONFIG DEBUG ===");
|
|
47
|
+
console.log("MM_MAPPING_AUTH_SERVICE_URL env var:", process.env.MM_MAPPING_AUTH_SERVICE_URL);
|
|
46
48
|
this.mmApiBaseUrl = process.env.MM_MAPPING_AUTH_SERVICE_URL || "";
|
|
49
|
+
console.log("mmApiBaseUrl set to:", this.mmApiBaseUrl);
|
|
50
|
+
console.log("=== END CONFIG DEBUG ===");
|
|
47
51
|
|
|
48
52
|
/**
|
|
49
53
|
* Company Auth Token
|
|
@@ -24,7 +24,12 @@ export class MMTokenManager {
|
|
|
24
24
|
? new Date(cached.expiration)
|
|
25
25
|
: null;
|
|
26
26
|
const config = CoreConfiguration.inst();
|
|
27
|
+
console.log("=== MMTOKEN MANAGER DEBUG ===");
|
|
28
|
+
console.log("config.mmApiBaseUrl:", config.mmApiBaseUrl);
|
|
29
|
+
console.log("config object keys:", Object.keys(config));
|
|
27
30
|
this.baseUrl = config.mmApiBaseUrl;
|
|
31
|
+
console.log("this.baseUrl set to:", this.baseUrl);
|
|
32
|
+
console.log("=== END MMTOKEN MANAGER DEBUG ===");
|
|
28
33
|
this.api = HTTPClientFactory.getInstance({
|
|
29
34
|
baseUrl: this.baseUrl,
|
|
30
35
|
retryAttempts: config.mmApiRetryAttempts,
|
package/src/utils/http-client.ts
CHANGED
|
@@ -80,19 +80,26 @@ class AxiosClient implements HTTPClient {
|
|
|
80
80
|
params: config.params,
|
|
81
81
|
};
|
|
82
82
|
|
|
83
|
-
logger.
|
|
83
|
+
logger.info("HTTP request starting", {
|
|
84
84
|
url: config.url,
|
|
85
85
|
method: config.method,
|
|
86
86
|
baseURL: this.client.defaults.baseURL,
|
|
87
87
|
retryAttempts: this.retryAttempts
|
|
88
88
|
});
|
|
89
|
+
|
|
90
|
+
// Extra console.log for debugging
|
|
91
|
+
console.log("=== FULL URL DEBUG ===");
|
|
92
|
+
console.log("baseURL:", this.client.defaults.baseURL);
|
|
93
|
+
console.log("relative url:", config.url);
|
|
94
|
+
console.log("full constructed URL:", (this.client.defaults.baseURL || "") + config.url);
|
|
95
|
+
console.log("method:", config.method);
|
|
89
96
|
|
|
90
97
|
let lastError: unknown;
|
|
91
98
|
for (let attempt = 0; attempt <= this.retryAttempts; attempt++) {
|
|
92
99
|
try {
|
|
93
|
-
logger.
|
|
100
|
+
logger.info(`HTTP request attempt ${attempt + 1}/${this.retryAttempts + 1}`);
|
|
94
101
|
const response = await this.client.request<T>(axiosConfig);
|
|
95
|
-
logger.
|
|
102
|
+
logger.info("HTTP request succeeded", { status: response.status });
|
|
96
103
|
return {
|
|
97
104
|
data: response.data,
|
|
98
105
|
status: response.status,
|
|
@@ -100,7 +107,7 @@ class AxiosClient implements HTTPClient {
|
|
|
100
107
|
};
|
|
101
108
|
} catch (error) {
|
|
102
109
|
lastError = error;
|
|
103
|
-
logger.
|
|
110
|
+
logger.info(`HTTP request attempt ${attempt + 1} failed`, {
|
|
104
111
|
errorType: typeof error,
|
|
105
112
|
errorConstructor: error?.constructor?.name,
|
|
106
113
|
isAxiosError: error instanceof AxiosError,
|
|
@@ -116,13 +123,13 @@ class AxiosClient implements HTTPClient {
|
|
|
116
123
|
error.response.status >= 400 &&
|
|
117
124
|
error.response.status < 500
|
|
118
125
|
) {
|
|
119
|
-
logger.
|
|
126
|
+
logger.info("Not retrying due to 4xx client error");
|
|
120
127
|
break;
|
|
121
128
|
}
|
|
122
129
|
// If this was the last attempt, don't wait
|
|
123
130
|
if (attempt < this.retryAttempts) {
|
|
124
131
|
const waitTime = Math.pow(2, attempt) * 1000;
|
|
125
|
-
logger.
|
|
132
|
+
logger.info(`Waiting ${waitTime}ms before retry`);
|
|
126
133
|
// Exponential backoff: wait 2^attempt * 1000ms
|
|
127
134
|
await new Promise((resolve) =>
|
|
128
135
|
setTimeout(resolve, Math.pow(2, attempt) * 1000)
|
|
@@ -130,7 +137,7 @@ class AxiosClient implements HTTPClient {
|
|
|
130
137
|
}
|
|
131
138
|
}
|
|
132
139
|
}
|
|
133
|
-
logger.
|
|
140
|
+
logger.info("HTTP request failed after all retries, throwing error");
|
|
134
141
|
throw this.handleError(lastError, config);
|
|
135
142
|
}
|
|
136
143
|
|