@machinemetrics/mm-erp-sdk 0.1.4-beta.2 → 0.1.4-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/services/data-sync-service/jobs/clean-up-expired-cache.d.ts +2 -0
- package/dist/services/data-sync-service/jobs/clean-up-expired-cache.d.ts.map +1 -1
- package/dist/services/data-sync-service/jobs/clean-up-expired-cache.js +36 -38
- package/dist/services/data-sync-service/jobs/clean-up-expired-cache.js.map +1 -1
- package/dist/services/data-sync-service/jobs/from-erp.d.ts.map +1 -1
- package/dist/services/data-sync-service/jobs/from-erp.js +9 -6
- package/dist/services/data-sync-service/jobs/from-erp.js.map +1 -1
- package/dist/services/data-sync-service/jobs/retry-failed-labor-tickets.d.ts +2 -0
- package/dist/services/data-sync-service/jobs/retry-failed-labor-tickets.d.ts.map +1 -1
- package/dist/services/data-sync-service/jobs/retry-failed-labor-tickets.js +35 -37
- package/dist/services/data-sync-service/jobs/retry-failed-labor-tickets.js.map +1 -1
- package/dist/services/data-sync-service/jobs/to-erp.d.ts.map +1 -1
- package/dist/services/data-sync-service/jobs/to-erp.js +9 -2
- package/dist/services/data-sync-service/jobs/to-erp.js.map +1 -1
- package/package.json +1 -1
- package/src/services/data-sync-service/jobs/clean-up-expired-cache.ts +15 -8
- package/src/services/data-sync-service/jobs/from-erp.ts +11 -8
- package/src/services/data-sync-service/jobs/retry-failed-labor-tickets.ts +13 -6
- package/src/services/data-sync-service/jobs/to-erp.ts +12 -5
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clean-up-expired-cache.d.ts","sourceRoot":"","sources":["../../../../src/services/data-sync-service/jobs/clean-up-expired-cache.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"clean-up-expired-cache.d.ts","sourceRoot":"","sources":["../../../../src/services/data-sync-service/jobs/clean-up-expired-cache.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAKvB,QAAA,MAAM,IAAI,qBAwBT,CAAC;AAkBF,eAAe,IAAI,CAAC"}
|
|
@@ -1,44 +1,42 @@
|
|
|
1
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
|
-
};
|
|
5
1
|
import "../../../config-WKwu1mMo.js";
|
|
6
2
|
import { H as HashedCacheManager } from "../../../hashed-cache-manager-CtDhFqj6.js";
|
|
7
3
|
import { S as SQLiteCoordinator } from "../../../index-aci_wdcn.js";
|
|
8
4
|
import { l as logger } from "../../../logger-hqtl8hFM.js";
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
await cacheManager.destroy();
|
|
31
|
-
logger.info(`==========Completed clean-up-expired-cache job==========`);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
if (require.main === module) {
|
|
35
|
-
(async () => {
|
|
36
|
-
await main();
|
|
37
|
-
})();
|
|
38
|
-
} else {
|
|
39
|
-
module.exports = main;
|
|
40
|
-
}
|
|
5
|
+
const main = async () => {
|
|
6
|
+
const cacheManager = new HashedCacheManager();
|
|
7
|
+
try {
|
|
8
|
+
logger.info('Worker for job "clean-up-expired-cache" online');
|
|
9
|
+
logger.info(
|
|
10
|
+
"==========Starting clean-up-expired-cache job cycle=========="
|
|
11
|
+
);
|
|
12
|
+
await SQLiteCoordinator.executeWithLock("clean-up-cache", async () => {
|
|
13
|
+
await cacheManager.removeExpiredObjects();
|
|
14
|
+
});
|
|
15
|
+
logger.info(
|
|
16
|
+
"==========Completed clean-up-expired-cache job cycle=========="
|
|
17
|
+
);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
logger.error('Worker for job "clean-up-expired-cache" had an error', {
|
|
20
|
+
err: error
|
|
21
|
+
});
|
|
22
|
+
throw error;
|
|
23
|
+
} finally {
|
|
24
|
+
await cacheManager.destroy();
|
|
25
|
+
logger.info(`==========Completed clean-up-expired-cache job==========`);
|
|
41
26
|
}
|
|
42
|
-
}
|
|
43
|
-
|
|
27
|
+
};
|
|
28
|
+
const normalizedArgv1 = process.argv[1].replace(/\\/g, "/");
|
|
29
|
+
const fileUrl = normalizedArgv1.startsWith("/") ? `file://${normalizedArgv1}` : (
|
|
30
|
+
// Unix: file:// + /path = file:///path
|
|
31
|
+
`file:///${normalizedArgv1}`
|
|
32
|
+
);
|
|
33
|
+
const isMainModule = import.meta.url === fileUrl;
|
|
34
|
+
if (isMainModule) {
|
|
35
|
+
main().catch(() => {
|
|
36
|
+
process.exit(1);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
export {
|
|
40
|
+
main as default
|
|
41
|
+
};
|
|
44
42
|
//# sourceMappingURL=clean-up-expired-cache.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"clean-up-expired-cache.js","sources":["../../../../src/services/data-sync-service/jobs/clean-up-expired-cache.ts"],"sourcesContent":["import \"dotenv/config\";\nimport { HashedCacheManager } from \"../../caching-service/hashed-cache-manager\";\nimport { SQLiteCoordinator } from \"../../sqlite-service\";\nimport logger from \"../../../services/reporting-service/logger\";\n\nconst main = async () => {\n const cacheManager = new HashedCacheManager();\n try {\n logger.info('Worker for job \"clean-up-expired-cache\" online');\n logger.info(\n \"==========Starting clean-up-expired-cache job cycle==========\"\n );\n\n await SQLiteCoordinator.executeWithLock(\"clean-up-cache\", async () => {\n await cacheManager.removeExpiredObjects();\n });\n\n logger.info(\n \"==========Completed clean-up-expired-cache job cycle==========\"\n );\n } catch (error) {\n logger.error('Worker for job \"clean-up-expired-cache\" had an error', {\n err: error,\n });\n throw error; // Rethrow so Bree can handle it properly\n } finally {\n await cacheManager.destroy();\n logger.info(`==========Completed clean-up-expired-cache job==========`);\n }\n};\n\n//
|
|
1
|
+
{"version":3,"file":"clean-up-expired-cache.js","sources":["../../../../src/services/data-sync-service/jobs/clean-up-expired-cache.ts"],"sourcesContent":["import \"dotenv/config\";\nimport { HashedCacheManager } from \"../../caching-service/hashed-cache-manager\";\nimport { SQLiteCoordinator } from \"../../sqlite-service\";\nimport logger from \"../../../services/reporting-service/logger\";\n\nconst main = async () => {\n const cacheManager = new HashedCacheManager();\n try {\n logger.info('Worker for job \"clean-up-expired-cache\" online');\n logger.info(\n \"==========Starting clean-up-expired-cache job cycle==========\"\n );\n\n await SQLiteCoordinator.executeWithLock(\"clean-up-cache\", async () => {\n await cacheManager.removeExpiredObjects();\n });\n\n logger.info(\n \"==========Completed clean-up-expired-cache job cycle==========\"\n );\n } catch (error) {\n logger.error('Worker for job \"clean-up-expired-cache\" had an error', {\n err: error,\n });\n throw error; // Rethrow so Bree can handle it properly\n } finally {\n await cacheManager.destroy();\n logger.info(`==========Completed clean-up-expired-cache job==========`);\n }\n};\n\n// Cross-platform module detection fix for Bree compatibility\n// Windows: process.argv[1] uses backslashes, import.meta.url uses forward slashes\n// Linux/Mac: both use forward slashes, so this normalization is safe\nconst normalizedArgv1 = process.argv[1].replace(/\\\\/g, '/');\nconst fileUrl = normalizedArgv1.startsWith('/') ? \n `file://${normalizedArgv1}` : // Unix: file:// + /path = file:///path\n `file:///${normalizedArgv1}`; // Windows: file:/// + C:/path = file:///C:/path\nconst isMainModule = import.meta.url === fileUrl;\n\nif (isMainModule) {\n // This is called when Bree runs this file as a worker\n main().catch(() => {\n process.exit(1);\n });\n}\n\nexport default main;\n"],"names":[],"mappings":";;;;AAKA,MAAM,OAAO,YAAY;AACvB,QAAM,eAAe,IAAI,mBAAA;AACzB,MAAI;AACF,WAAO,KAAK,gDAAgD;AAC5D,WAAO;AAAA,MACL;AAAA,IAAA;AAGF,UAAM,kBAAkB,gBAAgB,kBAAkB,YAAY;AACpE,YAAM,aAAa,qBAAA;AAAA,IACrB,CAAC;AAED,WAAO;AAAA,MACL;AAAA,IAAA;AAAA,EAEJ,SAAS,OAAO;AACd,WAAO,MAAM,wDAAwD;AAAA,MACnE,KAAK;AAAA,IAAA,CACN;AACD,UAAM;AAAA,EACR,UAAA;AACE,UAAM,aAAa,QAAA;AACnB,WAAO,KAAK,0DAA0D;AAAA,EACxE;AACF;AAKA,MAAM,kBAAkB,QAAQ,KAAK,CAAC,EAAE,QAAQ,OAAO,GAAG;AAC1D,MAAM,UAAU,gBAAgB,WAAW,GAAG,IAC5C,UAAU,eAAe;AAAA;AAAA,EACzB,WAAW,eAAe;AAAA;AAC5B,MAAM,eAAe,YAAY,QAAQ;AAEzC,IAAI,cAAc;AAEhB,OAAA,EAAO,MAAM,MAAM;AACjB,YAAQ,KAAK,CAAC;AAAA,EAChB,CAAC;AACH;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"from-erp.d.ts","sourceRoot":"","sources":["../../../../src/services/data-sync-service/jobs/from-erp.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAMvB,QAAA,MAAM,IAAI,qBAmCT,CAAC;
|
|
1
|
+
{"version":3,"file":"from-erp.d.ts","sourceRoot":"","sources":["../../../../src/services/data-sync-service/jobs/from-erp.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAMvB,QAAA,MAAM,IAAI,qBAmCT,CAAC;AAkBF,eAAe,IAAI,CAAC"}
|
|
@@ -30,13 +30,16 @@ const main = async () => {
|
|
|
30
30
|
throw error;
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
-
const
|
|
33
|
+
const normalizedArgv1 = process.argv[1].replace(/\\/g, "/");
|
|
34
|
+
const fileUrl = normalizedArgv1.startsWith("/") ? `file://${normalizedArgv1}` : (
|
|
35
|
+
// Unix: file:// + /path = file:///path
|
|
36
|
+
`file:///${normalizedArgv1}`
|
|
37
|
+
);
|
|
38
|
+
const isMainModule = import.meta.url === fileUrl;
|
|
34
39
|
if (isMainModule) {
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
}
|
|
38
|
-
process.exitCode = 1;
|
|
39
|
-
}
|
|
40
|
+
main().catch(() => {
|
|
41
|
+
process.exit(1);
|
|
42
|
+
});
|
|
40
43
|
}
|
|
41
44
|
export {
|
|
42
45
|
main as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"from-erp.js","sources":["../../../../src/services/data-sync-service/jobs/from-erp.ts"],"sourcesContent":["import \"dotenv/config\";\n\nimport logger from \"../../../services/reporting-service/logger\";\nimport { SQLiteCoordinator } from \"../../sqlite-service\";\nimport { createConnectorFromPath } from \"../../../utils/connector-factory\";\n\nconst main = async () => {\n try {\n logger.info('Worker for job \"from-erp\" online');\n logger.info(\"==========Starting from-erp job cycle==========\");\n\n // Get the connector path from the environment variable\n const connectorPath = process.env.CONNECTOR_PATH;\n\n\n if (!connectorPath) {\n throw new Error(\"Connector path not provided in environment variables\");\n }\n\n // Create a new connector instance for this job\n const connector = await createConnectorFromPath(connectorPath);\n\n await SQLiteCoordinator.executeWithLock(\"from-erp\", async () => {\n await connector.syncFromERP();\n });\n\n await connector.syncFromERPCompleted();\n logger.info(\"==========Completed from-erp job cycle==========\");\n } catch (error) {\n const errorDetails = {\n message: error instanceof Error ? error.message : String(error),\n stack: error instanceof Error ? error.stack : undefined,\n name: error instanceof Error ? error.name : undefined,\n ...(error && typeof error === \"object\" ? error : {}), // Include all enumerable properties if it's an object\n };\n logger.error('Worker for job \"from-erp\" had an error', {\n error: errorDetails,\n });\n\n throw error; // Rethrow so Bree can handle it properly\n }\n};\n\n//
|
|
1
|
+
{"version":3,"file":"from-erp.js","sources":["../../../../src/services/data-sync-service/jobs/from-erp.ts"],"sourcesContent":["import \"dotenv/config\";\n\nimport logger from \"../../../services/reporting-service/logger\";\nimport { SQLiteCoordinator } from \"../../sqlite-service\";\nimport { createConnectorFromPath } from \"../../../utils/connector-factory\";\n\nconst main = async () => {\n try {\n logger.info('Worker for job \"from-erp\" online');\n logger.info(\"==========Starting from-erp job cycle==========\");\n\n // Get the connector path from the environment variable\n const connectorPath = process.env.CONNECTOR_PATH;\n\n\n if (!connectorPath) {\n throw new Error(\"Connector path not provided in environment variables\");\n }\n\n // Create a new connector instance for this job\n const connector = await createConnectorFromPath(connectorPath);\n\n await SQLiteCoordinator.executeWithLock(\"from-erp\", async () => {\n await connector.syncFromERP();\n });\n\n await connector.syncFromERPCompleted();\n logger.info(\"==========Completed from-erp job cycle==========\");\n } catch (error) {\n const errorDetails = {\n message: error instanceof Error ? error.message : String(error),\n stack: error instanceof Error ? error.stack : undefined,\n name: error instanceof Error ? error.name : undefined,\n ...(error && typeof error === \"object\" ? error : {}), // Include all enumerable properties if it's an object\n };\n logger.error('Worker for job \"from-erp\" had an error', {\n error: errorDetails,\n });\n\n throw error; // Rethrow so Bree can handle it properly\n }\n};\n\n// Cross-platform module detection fix for Bree compatibility\n// Windows: process.argv[1] uses backslashes, import.meta.url uses forward slashes\n// Linux/Mac: both use forward slashes, so this normalization is safe\nconst normalizedArgv1 = process.argv[1].replace(/\\\\/g, '/');\nconst fileUrl = normalizedArgv1.startsWith('/') ? \n `file://${normalizedArgv1}` : // Unix: file:// + /path = file:///path\n `file:///${normalizedArgv1}`; // Windows: file:/// + C:/path = file:///C:/path\nconst isMainModule = import.meta.url === fileUrl;\n\nif (isMainModule) {\n // This is called when Bree runs this file as a worker\n main().catch(() => {\n process.exit(1);\n });\n}\n\nexport default main;"],"names":[],"mappings":";;;;AAMA,MAAM,OAAO,YAAY;AACvB,MAAI;AACF,WAAO,KAAK,kCAAkC;AAC9C,WAAO,KAAK,iDAAiD;AAG7D,UAAM,gBAAgB,QAAQ,IAAI;AAGlC,QAAI,CAAC,eAAe;AAClB,YAAM,IAAI,MAAM,sDAAsD;AAAA,IACxE;AAGA,UAAM,YAAY,MAAM,wBAAwB,aAAa;AAE7D,UAAM,kBAAkB,gBAAgB,YAAY,YAAY;AAC9D,YAAM,UAAU,YAAA;AAAA,IAClB,CAAC;AAED,UAAM,UAAU,qBAAA;AAChB,WAAO,KAAK,kDAAkD;AAAA,EAChE,SAAS,OAAO;AACd,UAAM,eAAe;AAAA,MACnB,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,MAC9D,OAAO,iBAAiB,QAAQ,MAAM,QAAQ;AAAA,MAC9C,MAAM,iBAAiB,QAAQ,MAAM,OAAO;AAAA,MAC5C,GAAI,SAAS,OAAO,UAAU,WAAW,QAAQ,CAAA;AAAA;AAAA,IAAC;AAEpD,WAAO,MAAM,0CAA0C;AAAA,MACrD,OAAO;AAAA,IAAA,CACR;AAED,UAAM;AAAA,EACR;AACF;AAKA,MAAM,kBAAkB,QAAQ,KAAK,CAAC,EAAE,QAAQ,OAAO,GAAG;AAC1D,MAAM,UAAU,gBAAgB,WAAW,GAAG,IAC5C,UAAU,eAAe;AAAA;AAAA,EACzB,WAAW,eAAe;AAAA;AAC5B,MAAM,eAAe,YAAY,QAAQ;AAEzC,IAAI,cAAc;AAEhB,OAAA,EAAO,MAAM,MAAM;AACjB,YAAQ,KAAK,CAAC;AAAA,EAChB,CAAC;AACH;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry-failed-labor-tickets.d.ts","sourceRoot":"","sources":["../../../../src/services/data-sync-service/jobs/retry-failed-labor-tickets.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC"}
|
|
1
|
+
{"version":3,"file":"retry-failed-labor-tickets.d.ts","sourceRoot":"","sources":["../../../../src/services/data-sync-service/jobs/retry-failed-labor-tickets.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAKvB,QAAA,MAAM,IAAI,qBA6BT,CAAC;AAkBF,eAAe,IAAI,CAAC"}
|
|
@@ -1,43 +1,41 @@
|
|
|
1
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
2
|
-
var __commonJS = (cb, mod) => function __require() {
|
|
3
|
-
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
4
|
-
};
|
|
5
1
|
import "../../../config-WKwu1mMo.js";
|
|
6
2
|
import { l as logger } from "../../../logger-hqtl8hFM.js";
|
|
7
3
|
import { c as createConnectorFromPath } from "../../../connector-factory-DFv3ex0X.js";
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
if (!connectorPath) {
|
|
18
|
-
throw new Error("Connector path not provided in environment variables");
|
|
19
|
-
}
|
|
20
|
-
const connector = await createConnectorFromPath(connectorPath);
|
|
21
|
-
await connector.retryFailedLaborTickets();
|
|
22
|
-
await connector.retryFailedLaborTicketsCompleted();
|
|
23
|
-
logger.info(
|
|
24
|
-
"==========Completed retry-failed-labor-tickets job cycle=========="
|
|
25
|
-
);
|
|
26
|
-
} catch (error) {
|
|
27
|
-
logger.error('Worker for job "retry-failed-labor-tickets" had an error', {
|
|
28
|
-
err: error
|
|
29
|
-
});
|
|
30
|
-
throw error;
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
if (require.main === module) {
|
|
34
|
-
main().catch(() => {
|
|
35
|
-
process.exitCode = 1;
|
|
36
|
-
});
|
|
37
|
-
} else {
|
|
38
|
-
module.exports = main;
|
|
4
|
+
const main = async () => {
|
|
5
|
+
try {
|
|
6
|
+
logger.info('Worker for job "retry-failed-labor-tickets" online');
|
|
7
|
+
logger.info(
|
|
8
|
+
"==========Starting retry-failed-labor-tickets job cycle=========="
|
|
9
|
+
);
|
|
10
|
+
const connectorPath = process.env.CONNECTOR_PATH;
|
|
11
|
+
if (!connectorPath) {
|
|
12
|
+
throw new Error("Connector path not provided in environment variables");
|
|
39
13
|
}
|
|
14
|
+
const connector = await createConnectorFromPath(connectorPath);
|
|
15
|
+
await connector.retryFailedLaborTickets();
|
|
16
|
+
await connector.retryFailedLaborTicketsCompleted();
|
|
17
|
+
logger.info(
|
|
18
|
+
"==========Completed retry-failed-labor-tickets job cycle=========="
|
|
19
|
+
);
|
|
20
|
+
} catch (error) {
|
|
21
|
+
logger.error('Worker for job "retry-failed-labor-tickets" had an error', {
|
|
22
|
+
err: error
|
|
23
|
+
});
|
|
24
|
+
throw error;
|
|
40
25
|
}
|
|
41
|
-
}
|
|
42
|
-
|
|
26
|
+
};
|
|
27
|
+
const normalizedArgv1 = process.argv[1].replace(/\\/g, "/");
|
|
28
|
+
const fileUrl = normalizedArgv1.startsWith("/") ? `file://${normalizedArgv1}` : (
|
|
29
|
+
// Unix: file:// + /path = file:///path
|
|
30
|
+
`file:///${normalizedArgv1}`
|
|
31
|
+
);
|
|
32
|
+
const isMainModule = import.meta.url === fileUrl;
|
|
33
|
+
if (isMainModule) {
|
|
34
|
+
main().catch(() => {
|
|
35
|
+
process.exit(1);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
export {
|
|
39
|
+
main as default
|
|
40
|
+
};
|
|
43
41
|
//# sourceMappingURL=retry-failed-labor-tickets.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"retry-failed-labor-tickets.js","sources":["../../../../src/services/data-sync-service/jobs/retry-failed-labor-tickets.ts"],"sourcesContent":["import \"dotenv/config\";\n\nimport logger from \"../../../services/reporting-service/logger\";\nimport { createConnectorFromPath } from \"../../../utils/connector-factory\";\n\nconst main = async () => {\n try {\n logger.info('Worker for job \"retry-failed-labor-tickets\" online');\n logger.info(\n \"==========Starting retry-failed-labor-tickets job cycle==========\"\n );\n\n // Get the connector path from the environment variable\n const connectorPath = process.env.CONNECTOR_PATH;\n\n if (!connectorPath) {\n throw new Error(\"Connector path not provided in environment variables\");\n }\n\n // Create a new connector instance for this job\n const connector = await createConnectorFromPath(connectorPath);\n\n await connector.retryFailedLaborTickets();\n await connector.retryFailedLaborTicketsCompleted();\n\n logger.info(\n \"==========Completed retry-failed-labor-tickets job cycle==========\"\n );\n } catch (error) {\n logger.error('Worker for job \"retry-failed-labor-tickets\" had an error', {\n err: error,\n });\n throw error; // Rethrow so Bree can handle it properly\n }\n};\n\n//
|
|
1
|
+
{"version":3,"file":"retry-failed-labor-tickets.js","sources":["../../../../src/services/data-sync-service/jobs/retry-failed-labor-tickets.ts"],"sourcesContent":["import \"dotenv/config\";\n\nimport logger from \"../../../services/reporting-service/logger\";\nimport { createConnectorFromPath } from \"../../../utils/connector-factory\";\n\nconst main = async () => {\n try {\n logger.info('Worker for job \"retry-failed-labor-tickets\" online');\n logger.info(\n \"==========Starting retry-failed-labor-tickets job cycle==========\"\n );\n\n // Get the connector path from the environment variable\n const connectorPath = process.env.CONNECTOR_PATH;\n\n if (!connectorPath) {\n throw new Error(\"Connector path not provided in environment variables\");\n }\n\n // Create a new connector instance for this job\n const connector = await createConnectorFromPath(connectorPath);\n\n await connector.retryFailedLaborTickets();\n await connector.retryFailedLaborTicketsCompleted();\n\n logger.info(\n \"==========Completed retry-failed-labor-tickets job cycle==========\"\n );\n } catch (error) {\n logger.error('Worker for job \"retry-failed-labor-tickets\" had an error', {\n err: error,\n });\n throw error; // Rethrow so Bree can handle it properly\n }\n};\n\n// Cross-platform module detection fix for Bree compatibility\n// Windows: process.argv[1] uses backslashes, import.meta.url uses forward slashes\n// Linux/Mac: both use forward slashes, so this normalization is safe\nconst normalizedArgv1 = process.argv[1].replace(/\\\\/g, '/');\nconst fileUrl = normalizedArgv1.startsWith('/') ? \n `file://${normalizedArgv1}` : // Unix: file:// + /path = file:///path\n `file:///${normalizedArgv1}`; // Windows: file:/// + C:/path = file:///C:/path\nconst isMainModule = import.meta.url === fileUrl;\n\nif (isMainModule) {\n // This is called when Bree runs this file as a worker\n main().catch(() => {\n process.exit(1);\n });\n}\n\nexport default main;\n"],"names":[],"mappings":";;;AAKA,MAAM,OAAO,YAAY;AACvB,MAAI;AACF,WAAO,KAAK,oDAAoD;AAChE,WAAO;AAAA,MACL;AAAA,IAAA;AAIF,UAAM,gBAAgB,QAAQ,IAAI;AAElC,QAAI,CAAC,eAAe;AAClB,YAAM,IAAI,MAAM,sDAAsD;AAAA,IACxE;AAGA,UAAM,YAAY,MAAM,wBAAwB,aAAa;AAE7D,UAAM,UAAU,wBAAA;AAChB,UAAM,UAAU,iCAAA;AAEhB,WAAO;AAAA,MACL;AAAA,IAAA;AAAA,EAEJ,SAAS,OAAO;AACd,WAAO,MAAM,4DAA4D;AAAA,MACvE,KAAK;AAAA,IAAA,CACN;AACD,UAAM;AAAA,EACR;AACF;AAKA,MAAM,kBAAkB,QAAQ,KAAK,CAAC,EAAE,QAAQ,OAAO,GAAG;AAC1D,MAAM,UAAU,gBAAgB,WAAW,GAAG,IAC5C,UAAU,eAAe;AAAA;AAAA,EACzB,WAAW,eAAe;AAAA;AAC5B,MAAM,eAAe,YAAY,QAAQ;AAEzC,IAAI,cAAc;AAEhB,OAAA,EAAO,MAAM,MAAM;AACjB,YAAQ,KAAK,CAAC;AAAA,EAChB,CAAC;AACH;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-erp.d.ts","sourceRoot":"","sources":["../../../../src/services/data-sync-service/jobs/to-erp.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAKvB,QAAA,MAAM,IAAI,qBAoCT,CAAC;
|
|
1
|
+
{"version":3,"file":"to-erp.d.ts","sourceRoot":"","sources":["../../../../src/services/data-sync-service/jobs/to-erp.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAKvB,QAAA,MAAM,IAAI,qBAoCT,CAAC;AAkBF,eAAe,IAAI,CAAC"}
|
|
@@ -29,9 +29,16 @@ const main = async () => {
|
|
|
29
29
|
throw error;
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
|
-
const
|
|
32
|
+
const normalizedArgv1 = process.argv[1].replace(/\\/g, "/");
|
|
33
|
+
const fileUrl = normalizedArgv1.startsWith("/") ? `file://${normalizedArgv1}` : (
|
|
34
|
+
// Unix: file:// + /path = file:///path
|
|
35
|
+
`file:///${normalizedArgv1}`
|
|
36
|
+
);
|
|
37
|
+
const isMainModule = import.meta.url === fileUrl;
|
|
33
38
|
if (isMainModule) {
|
|
34
|
-
main()
|
|
39
|
+
main().catch(() => {
|
|
40
|
+
process.exit(1);
|
|
41
|
+
});
|
|
35
42
|
}
|
|
36
43
|
export {
|
|
37
44
|
main as default
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-erp.js","sources":["../../../../src/services/data-sync-service/jobs/to-erp.ts"],"sourcesContent":["import \"dotenv/config\";\n\nimport logger from \"../../reporting-service/logger\";\nimport { createConnectorFromPath } from \"../../../utils/connector-factory\";\n\nconst main = async () => {\n try {\n logger.info('Worker for job \"to-erp\" online');\n logger.info(\"==========Starting to-erp job cycle==========\");\n\n // Get the connector path from the environment variable\n const connectorPath = process.env.CONNECTOR_PATH;\n\n if (!connectorPath) {\n throw new Error(\"Connector path not provided in environment variables\");\n }\n\n // Create a new connector instance for this job\n const connector = await createConnectorFromPath(connectorPath);\n\n await connector.syncToERP();\n await connector.syncToERPCompleted();\n\n logger.info(\"==========Completed to-erp job cycle==========\");\n } catch (error) {\n const errorDetails = {\n message: error instanceof Error ? error.message : String(error),\n stack: error instanceof Error ? error.stack : undefined,\n name: error instanceof Error ? error.name : undefined,\n ...(error && typeof error === \"object\" ? error : {}), // Include all enumerable properties if it's an object\n };\n logger.error('Worker for job \"to-erp\" had an error', {\n error: errorDetails,\n connectorPath: process.env.CONNECTOR_PATH,\n });\n\n // Also log to console for immediate visibility\n console.error(\"to-erp job error:\", error);\n\n throw error; // Rethrow so Bree can handle it properly\n }\n};\n\n//
|
|
1
|
+
{"version":3,"file":"to-erp.js","sources":["../../../../src/services/data-sync-service/jobs/to-erp.ts"],"sourcesContent":["import \"dotenv/config\";\n\nimport logger from \"../../reporting-service/logger\";\nimport { createConnectorFromPath } from \"../../../utils/connector-factory\";\n\nconst main = async () => {\n try {\n logger.info('Worker for job \"to-erp\" online');\n logger.info(\"==========Starting to-erp job cycle==========\");\n\n // Get the connector path from the environment variable\n const connectorPath = process.env.CONNECTOR_PATH;\n\n if (!connectorPath) {\n throw new Error(\"Connector path not provided in environment variables\");\n }\n\n // Create a new connector instance for this job\n const connector = await createConnectorFromPath(connectorPath);\n\n await connector.syncToERP();\n await connector.syncToERPCompleted();\n\n logger.info(\"==========Completed to-erp job cycle==========\");\n } catch (error) {\n const errorDetails = {\n message: error instanceof Error ? error.message : String(error),\n stack: error instanceof Error ? error.stack : undefined,\n name: error instanceof Error ? error.name : undefined,\n ...(error && typeof error === \"object\" ? error : {}), // Include all enumerable properties if it's an object\n };\n logger.error('Worker for job \"to-erp\" had an error', {\n error: errorDetails,\n connectorPath: process.env.CONNECTOR_PATH,\n });\n\n // Also log to console for immediate visibility\n console.error(\"to-erp job error:\", error);\n\n throw error; // Rethrow so Bree can handle it properly\n }\n};\n\n// Cross-platform module detection fix for Bree compatibility\n// Windows: process.argv[1] uses backslashes, import.meta.url uses forward slashes\n// Linux/Mac: both use forward slashes, so this normalization is safe\nconst normalizedArgv1 = process.argv[1].replace(/\\\\/g, '/');\nconst fileUrl = normalizedArgv1.startsWith('/') ? \n `file://${normalizedArgv1}` : // Unix: file:// + /path = file:///path\n `file:///${normalizedArgv1}`; // Windows: file:/// + C:/path = file:///C:/path\nconst isMainModule = import.meta.url === fileUrl;\n\nif (isMainModule) {\n // This is called when Bree runs this file as a worker\n main().catch(() => {\n process.exit(1);\n });\n}\n\nexport default main;\n"],"names":[],"mappings":";;;AAKA,MAAM,OAAO,YAAY;AACvB,MAAI;AACF,WAAO,KAAK,gCAAgC;AAC5C,WAAO,KAAK,+CAA+C;AAG3D,UAAM,gBAAgB,QAAQ,IAAI;AAElC,QAAI,CAAC,eAAe;AAClB,YAAM,IAAI,MAAM,sDAAsD;AAAA,IACxE;AAGA,UAAM,YAAY,MAAM,wBAAwB,aAAa;AAE7D,UAAM,UAAU,UAAA;AAChB,UAAM,UAAU,mBAAA;AAEhB,WAAO,KAAK,gDAAgD;AAAA,EAC9D,SAAS,OAAO;AACd,UAAM,eAAe;AAAA,MACnB,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,MAC9D,OAAO,iBAAiB,QAAQ,MAAM,QAAQ;AAAA,MAC9C,MAAM,iBAAiB,QAAQ,MAAM,OAAO;AAAA,MAC5C,GAAI,SAAS,OAAO,UAAU,WAAW,QAAQ,CAAA;AAAA;AAAA,IAAC;AAEpD,WAAO,MAAM,wCAAwC;AAAA,MACnD,OAAO;AAAA,MACP,eAAe,QAAQ,IAAI;AAAA,IAAA,CAC5B;AAGD,YAAQ,MAAM,qBAAqB,KAAK;AAExC,UAAM;AAAA,EACR;AACF;AAKA,MAAM,kBAAkB,QAAQ,KAAK,CAAC,EAAE,QAAQ,OAAO,GAAG;AAC1D,MAAM,UAAU,gBAAgB,WAAW,GAAG,IAC5C,UAAU,eAAe;AAAA;AAAA,EACzB,WAAW,eAAe;AAAA;AAC5B,MAAM,eAAe,YAAY,QAAQ;AAEzC,IAAI,cAAc;AAEhB,OAAA,EAAO,MAAM,MAAM;AACjB,YAAQ,KAAK,CAAC;AAAA,EAChB,CAAC;AACH;"}
|
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.4-beta.
|
|
4
|
+
"version": "0.1.4-beta.3",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "machinemetrics",
|
|
7
7
|
"main": "dist/mm-erp-sdk.js",
|
|
@@ -29,13 +29,20 @@ const main = async () => {
|
|
|
29
29
|
}
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
//
|
|
33
|
-
|
|
32
|
+
// Cross-platform module detection fix for Bree compatibility
|
|
33
|
+
// Windows: process.argv[1] uses backslashes, import.meta.url uses forward slashes
|
|
34
|
+
// Linux/Mac: both use forward slashes, so this normalization is safe
|
|
35
|
+
const normalizedArgv1 = process.argv[1].replace(/\\/g, '/');
|
|
36
|
+
const fileUrl = normalizedArgv1.startsWith('/') ?
|
|
37
|
+
`file://${normalizedArgv1}` : // Unix: file:// + /path = file:///path
|
|
38
|
+
`file:///${normalizedArgv1}`; // Windows: file:/// + C:/path = file:///C:/path
|
|
39
|
+
const isMainModule = import.meta.url === fileUrl;
|
|
40
|
+
|
|
41
|
+
if (isMainModule) {
|
|
34
42
|
// This is called when Bree runs this file as a worker
|
|
35
|
-
(
|
|
36
|
-
|
|
37
|
-
})
|
|
38
|
-
} else {
|
|
39
|
-
// Export for potential testing or direct usage
|
|
40
|
-
module.exports = main;
|
|
43
|
+
main().catch(() => {
|
|
44
|
+
process.exit(1);
|
|
45
|
+
});
|
|
41
46
|
}
|
|
47
|
+
|
|
48
|
+
export default main;
|
|
@@ -41,17 +41,20 @@ const main = async () => {
|
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
|
|
44
|
+
// Cross-platform module detection fix for Bree compatibility
|
|
45
|
+
// Windows: process.argv[1] uses backslashes, import.meta.url uses forward slashes
|
|
46
|
+
// Linux/Mac: both use forward slashes, so this normalization is safe
|
|
47
|
+
const normalizedArgv1 = process.argv[1].replace(/\\/g, '/');
|
|
48
|
+
const fileUrl = normalizedArgv1.startsWith('/') ?
|
|
49
|
+
`file://${normalizedArgv1}` : // Unix: file:// + /path = file:///path
|
|
50
|
+
`file:///${normalizedArgv1}`; // Windows: file:/// + C:/path = file:///C:/path
|
|
51
|
+
const isMainModule = import.meta.url === fileUrl;
|
|
47
52
|
|
|
48
53
|
if (isMainModule) {
|
|
49
54
|
// This is called when Bree runs this file as a worker
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
}
|
|
53
|
-
process.exitCode = 1; // prefer exitCode so stdout/stderr can flush
|
|
54
|
-
}
|
|
55
|
+
main().catch(() => {
|
|
56
|
+
process.exit(1);
|
|
57
|
+
});
|
|
55
58
|
}
|
|
56
59
|
|
|
57
60
|
export default main;
|
|
@@ -34,13 +34,20 @@ const main = async () => {
|
|
|
34
34
|
}
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
//
|
|
38
|
-
|
|
37
|
+
// Cross-platform module detection fix for Bree compatibility
|
|
38
|
+
// Windows: process.argv[1] uses backslashes, import.meta.url uses forward slashes
|
|
39
|
+
// Linux/Mac: both use forward slashes, so this normalization is safe
|
|
40
|
+
const normalizedArgv1 = process.argv[1].replace(/\\/g, '/');
|
|
41
|
+
const fileUrl = normalizedArgv1.startsWith('/') ?
|
|
42
|
+
`file://${normalizedArgv1}` : // Unix: file:// + /path = file:///path
|
|
43
|
+
`file:///${normalizedArgv1}`; // Windows: file:/// + C:/path = file:///C:/path
|
|
44
|
+
const isMainModule = import.meta.url === fileUrl;
|
|
45
|
+
|
|
46
|
+
if (isMainModule) {
|
|
39
47
|
// This is called when Bree runs this file as a worker
|
|
40
48
|
main().catch(() => {
|
|
41
|
-
process.
|
|
49
|
+
process.exit(1);
|
|
42
50
|
});
|
|
43
|
-
} else {
|
|
44
|
-
// Export for potential testing or direct usage
|
|
45
|
-
module.exports = main;
|
|
46
51
|
}
|
|
52
|
+
|
|
53
|
+
export default main;
|
|
@@ -41,13 +41,20 @@ const main = async () => {
|
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
43
|
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
|
|
44
|
+
// Cross-platform module detection fix for Bree compatibility
|
|
45
|
+
// Windows: process.argv[1] uses backslashes, import.meta.url uses forward slashes
|
|
46
|
+
// Linux/Mac: both use forward slashes, so this normalization is safe
|
|
47
|
+
const normalizedArgv1 = process.argv[1].replace(/\\/g, '/');
|
|
48
|
+
const fileUrl = normalizedArgv1.startsWith('/') ?
|
|
49
|
+
`file://${normalizedArgv1}` : // Unix: file:// + /path = file:///path
|
|
50
|
+
`file:///${normalizedArgv1}`; // Windows: file:/// + C:/path = file:///C:/path
|
|
51
|
+
const isMainModule = import.meta.url === fileUrl;
|
|
52
|
+
|
|
47
53
|
if (isMainModule) {
|
|
48
54
|
// This is called when Bree runs this file as a worker
|
|
49
|
-
main()
|
|
55
|
+
main().catch(() => {
|
|
56
|
+
process.exit(1);
|
|
57
|
+
});
|
|
50
58
|
}
|
|
51
59
|
|
|
52
|
-
// Export for potential testing or direct usage (ES module default export)
|
|
53
60
|
export default main;
|