@machinemetrics/mm-erp-sdk 0.1.4-beta.6 → 0.1.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.
Files changed (30) hide show
  1. package/README.md +1 -1
  2. package/dist/{connector-factory-13bvmpQB.js → connector-factory-DHmMYsRs.js} +7 -7
  3. package/dist/connector-factory-DHmMYsRs.js.map +1 -0
  4. package/dist/mm-erp-sdk.js +5 -3
  5. package/dist/mm-erp-sdk.js.map +1 -1
  6. package/dist/services/data-sync-service/jobs/clean-up-expired-cache.d.ts.map +1 -1
  7. package/dist/services/data-sync-service/jobs/clean-up-expired-cache.js +5 -3
  8. package/dist/services/data-sync-service/jobs/clean-up-expired-cache.js.map +1 -1
  9. package/dist/services/data-sync-service/jobs/from-erp.d.ts.map +1 -1
  10. package/dist/services/data-sync-service/jobs/from-erp.js +6 -7
  11. package/dist/services/data-sync-service/jobs/from-erp.js.map +1 -1
  12. package/dist/services/data-sync-service/jobs/retry-failed-labor-tickets.js +2 -2
  13. package/dist/services/data-sync-service/jobs/retry-failed-labor-tickets.js.map +1 -1
  14. package/dist/services/data-sync-service/jobs/run-migrations.js +2 -2
  15. package/dist/services/data-sync-service/jobs/run-migrations.js.map +1 -1
  16. package/dist/services/data-sync-service/jobs/to-erp.d.ts.map +1 -1
  17. package/dist/services/data-sync-service/jobs/to-erp.js +6 -7
  18. package/dist/services/data-sync-service/jobs/to-erp.js.map +1 -1
  19. package/dist/utils/connector-factory.d.ts.map +1 -1
  20. package/dist/utils/connector-log/log-deduper.d.ts.map +1 -1
  21. package/package.json +1 -1
  22. package/src/services/data-sync-service/jobs/clean-up-expired-cache.ts +5 -3
  23. package/src/services/data-sync-service/jobs/from-erp.ts +6 -9
  24. package/src/services/data-sync-service/jobs/retry-failed-labor-tickets.ts +1 -1
  25. package/src/services/data-sync-service/jobs/run-migrations.ts +2 -2
  26. package/src/services/data-sync-service/jobs/to-erp.ts +5 -8
  27. package/src/utils/application-initializer.ts +1 -1
  28. package/src/utils/connector-factory.ts +9 -13
  29. package/src/utils/connector-log/log-deduper.ts +3 -1
  30. package/dist/connector-factory-13bvmpQB.js.map +0 -1
@@ -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;AAQvB,QAAA,MAAM,IAAI,qBAwBT,CAAC;AAkBF,eAAe,IAAI,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;AAQvB,QAAA,MAAM,IAAI,qBAwBT,CAAC;AAoBF,eAAe,IAAI,CAAC"}
@@ -33,9 +33,11 @@ const fileUrl = normalizedArgv1.startsWith("/") ? `file://${normalizedArgv1}` :
33
33
  );
34
34
  const isMainModule = import.meta.url === fileUrl;
35
35
  if (isMainModule) {
36
- main().catch(() => {
37
- process.exit(1);
38
- });
36
+ try {
37
+ await main();
38
+ } catch {
39
+ process.exitCode = 1;
40
+ }
39
41
  }
40
42
  export {
41
43
  main as default
@@ -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\n// Configure the logger with the correct log level\nlogger.level = process.env.LOG_LEVEL || \"info\";\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":";;;;AAMA,OAAO,QAAQ,QAAQ,IAAI,aAAa;AAExC,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
+ {"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\n// Configure the logger with the correct log level\nlogger.level = process.env.LOG_LEVEL || \"info\";\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 try {\n await main();\n } catch {\n process.exitCode = 1; // prefer exitCode so stdout/stderr can flush\n }\n}\n\nexport default main;\n"],"names":[],"mappings":";;;;AAMA,OAAO,QAAQ,QAAQ,IAAI,aAAa;AAExC,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,MAAI;AACF,UAAM,KAAA;AAAA,EACR,QAAQ;AACN,YAAQ,WAAW;AAAA,EACrB;AACF;"}
@@ -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;AASvB,QAAA,MAAM,IAAI,qBAuCT,CAAC;AAkBF,eAAe,IAAI,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;AASvB,QAAA,MAAM,IAAI,qBAkCT,CAAC;AAoBF,eAAe,IAAI,CAAC"}
@@ -1,16 +1,13 @@
1
1
  import "../../../config-WKwu1mMo.js";
2
2
  import { l as logger } from "../../../logger-hqtl8hFM.js";
3
3
  import { S as SQLiteCoordinator } from "../../../index-aci_wdcn.js";
4
- import { c as createConnectorFromPath } from "../../../connector-factory-13bvmpQB.js";
4
+ import { c as createConnectorFromPath } from "../../../connector-factory-DHmMYsRs.js";
5
5
  logger.level = process.env.LOG_LEVEL || "info";
6
6
  const main = async () => {
7
7
  try {
8
8
  logger.info('Worker for job "from-erp" online');
9
9
  logger.info("==========Starting from-erp job cycle==========");
10
10
  const connectorPath = process.env.CONNECTOR_PATH;
11
- logger.debug(`from-erp job: Received CONNECTOR_PATH: ${connectorPath}`);
12
- logger.debug(`from-erp job: CONNECTOR_PATH type: ${typeof connectorPath}`);
13
- logger.debug(`from-erp job: CONNECTOR_PATH length: ${connectorPath?.length}`);
14
11
  if (!connectorPath) {
15
12
  throw new Error("Connector path not provided in environment variables");
16
13
  }
@@ -41,9 +38,11 @@ const fileUrl = normalizedArgv1.startsWith("/") ? `file://${normalizedArgv1}` :
41
38
  );
42
39
  const isMainModule = import.meta.url === fileUrl;
43
40
  if (isMainModule) {
44
- main().catch(() => {
45
- process.exit(1);
46
- });
41
+ try {
42
+ await main();
43
+ } catch {
44
+ process.exitCode = 1;
45
+ }
47
46
  }
48
47
  export {
49
48
  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\n// Configure the logger with the correct log level\nlogger.level = process.env.LOG_LEVEL || \"info\";\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 // Add debug logging\n logger.debug(`from-erp job: Received CONNECTOR_PATH: ${connectorPath}`);\n logger.debug(`from-erp job: CONNECTOR_PATH type: ${typeof connectorPath}`);\n logger.debug(`from-erp job: CONNECTOR_PATH length: ${connectorPath?.length}`);\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":";;;;AAOA,OAAO,QAAQ,QAAQ,IAAI,aAAa;AAExC,MAAM,OAAO,YAAY;AACvB,MAAI;AACF,WAAO,KAAK,kCAAkC;AAC9C,WAAO,KAAK,iDAAiD;AAG7D,UAAM,gBAAgB,QAAQ,IAAI;AAGlC,WAAO,MAAM,0CAA0C,aAAa,EAAE;AACtE,WAAO,MAAM,sCAAsC,OAAO,aAAa,EAAE;AACzE,WAAO,MAAM,wCAAwC,eAAe,MAAM,EAAE;AAE5E,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
+ {"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\n// Configure the logger with the correct log level\nlogger.level = process.env.LOG_LEVEL || \"info\";\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 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 try {\n await main();\n } catch {\n process.exitCode = 1; // prefer exitCode so stdout/stderr can flush\n }\n}\n\nexport default main;"],"names":[],"mappings":";;;;AAOA,OAAO,QAAQ,QAAQ,IAAI,aAAa;AAExC,MAAM,OAAO,YAAY;AACvB,MAAI;AACF,WAAO,KAAK,kCAAkC;AAC9C,WAAO,KAAK,iDAAiD;AAG7D,UAAM,gBAAgB,QAAQ,IAAI;AAElC,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,MAAI;AACF,UAAM,KAAA;AAAA,EACR,QAAQ;AACN,YAAQ,WAAW;AAAA,EACrB;AACF;"}
@@ -1,6 +1,6 @@
1
1
  import "../../../config-WKwu1mMo.js";
2
2
  import { l as logger } from "../../../logger-hqtl8hFM.js";
3
- import { c as createConnectorFromPath } from "../../../connector-factory-13bvmpQB.js";
3
+ import { c as createConnectorFromPath } from "../../../connector-factory-DHmMYsRs.js";
4
4
  logger.level = process.env.LOG_LEVEL || "info";
5
5
  const main = async () => {
6
6
  try {
@@ -33,7 +33,7 @@ const fileUrl = normalizedArgv1.startsWith("/") ? `file://${normalizedArgv1}` :
33
33
  const isMainModule = import.meta.url === fileUrl;
34
34
  if (isMainModule) {
35
35
  main().catch(() => {
36
- process.exit(1);
36
+ process.exitCode = 1;
37
37
  });
38
38
  }
39
39
  export {
@@ -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\n// Configure the logger with the correct log level\nlogger.level = process.env.LOG_LEVEL || \"info\";\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":";;;AAMA,OAAO,QAAQ,QAAQ,IAAI,aAAa;AAExC,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
+ {"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\n// Configure the logger with the correct log level\nlogger.level = process.env.LOG_LEVEL || \"info\";\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.exitCode = 1;\n });\n}\n\nexport default main;\n"],"names":[],"mappings":";;;AAMA,OAAO,QAAQ,QAAQ,IAAI,aAAa;AAExC,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,WAAW;AAAA,EACrB,CAAC;AACH;"}
@@ -10,7 +10,7 @@ async function runMigrations() {
10
10
  logger.info("Migrations complete!");
11
11
  } catch (error) {
12
12
  logger.error("Error running migrations:", error);
13
- process.exit(1);
13
+ process.exitCode = 1;
14
14
  } finally {
15
15
  await db.destroy();
16
16
  }
@@ -19,7 +19,7 @@ const isMainModule = import.meta.url === `file://${process.argv[1]}`;
19
19
  if (isMainModule) {
20
20
  runMigrations().catch((err) => {
21
21
  logger.error("Top-level error running migrations:", err);
22
- process.exit(1);
22
+ process.exitCode = 1;
23
23
  });
24
24
  }
25
25
  export {
@@ -1 +1 @@
1
- {"version":3,"file":"run-migrations.js","sources":["../../../../src/services/data-sync-service/jobs/run-migrations.ts"],"sourcesContent":["import knex, { Knex } from \"knex\";\nimport logger from \"../../reporting-service/logger\";\nimport config from \"../../../knexfile\";\n\n// Configure the logger with the correct log level\nlogger.level = process.env.LOG_LEVEL || \"info\";\n\n// MLW TODO Consider the location of knexfile\nconst db: Knex = knex(config.local);\n\nexport default async function runMigrations() {\n try {\n logger.info(\"Running migrations...\");\n await db.migrate.latest();\n logger.info(\"Migrations complete!\");\n } catch (error) {\n logger.error(\"Error running migrations:\", error);\n process.exit(1);\n } finally {\n await db.destroy();\n }\n}\n\nconst isMainModule = import.meta.url === `file://${process.argv[1]}`;\nif (isMainModule) {\n runMigrations().catch(err => {\n logger.error(\"Top-level error running migrations:\", err);\n process.exit(1);\n });\n}\n"],"names":[],"mappings":";;;AAKA,OAAO,QAAQ,QAAQ,IAAI,aAAa;AAGxC,MAAM,KAAW,KAAK,OAAO,KAAK;AAElC,eAA8B,gBAAgB;AAC5C,MAAI;AACF,WAAO,KAAK,uBAAuB;AACnC,UAAM,GAAG,QAAQ,OAAA;AACjB,WAAO,KAAK,sBAAsB;AAAA,EACpC,SAAS,OAAO;AACd,WAAO,MAAM,6BAA6B,KAAK;AAC/C,YAAQ,KAAK,CAAC;AAAA,EAChB,UAAA;AACE,UAAM,GAAG,QAAA;AAAA,EACX;AACF;AAEA,MAAM,eAAe,YAAY,QAAQ,UAAU,QAAQ,KAAK,CAAC,CAAC;AAClE,IAAI,cAAc;AAChB,gBAAA,EAAgB,MAAM,CAAA,QAAO;AAC3B,WAAO,MAAM,uCAAuC,GAAG;AACvD,YAAQ,KAAK,CAAC;AAAA,EAChB,CAAC;AACH;"}
1
+ {"version":3,"file":"run-migrations.js","sources":["../../../../src/services/data-sync-service/jobs/run-migrations.ts"],"sourcesContent":["import knex, { Knex } from \"knex\";\nimport logger from \"../../reporting-service/logger\";\nimport config from \"../../../knexfile\";\n\n// Configure the logger with the correct log level\nlogger.level = process.env.LOG_LEVEL || \"info\";\n\n// MLW TODO Consider the location of knexfile\nconst db: Knex = knex(config.local);\n\nexport default async function runMigrations() {\n try {\n logger.info(\"Running migrations...\");\n await db.migrate.latest();\n logger.info(\"Migrations complete!\");\n } catch (error) {\n logger.error(\"Error running migrations:\", error);\n process.exitCode = 1;\n } finally {\n await db.destroy();\n }\n}\n\nconst isMainModule = import.meta.url === `file://${process.argv[1]}`;\nif (isMainModule) {\n runMigrations().catch(err => {\n logger.error(\"Top-level error running migrations:\", err);\n process.exitCode = 1;\n });\n}\n"],"names":[],"mappings":";;;AAKA,OAAO,QAAQ,QAAQ,IAAI,aAAa;AAGxC,MAAM,KAAW,KAAK,OAAO,KAAK;AAElC,eAA8B,gBAAgB;AAC5C,MAAI;AACF,WAAO,KAAK,uBAAuB;AACnC,UAAM,GAAG,QAAQ,OAAA;AACjB,WAAO,KAAK,sBAAsB;AAAA,EACpC,SAAS,OAAO;AACd,WAAO,MAAM,6BAA6B,KAAK;AAC/C,YAAQ,WAAW;AAAA,EACrB,UAAA;AACE,UAAM,GAAG,QAAA;AAAA,EACX;AACF;AAEA,MAAM,eAAe,YAAY,QAAQ,UAAU,QAAQ,KAAK,CAAC,CAAC;AAClE,IAAI,cAAc;AAChB,gBAAA,EAAgB,MAAM,CAAA,QAAO;AAC3B,WAAO,MAAM,uCAAuC,GAAG;AACvD,YAAQ,WAAW;AAAA,EACrB,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;AAQvB,QAAA,MAAM,IAAI,qBAyCT,CAAC;AAkBF,eAAe,IAAI,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;AAQvB,QAAA,MAAM,IAAI,qBAoCT,CAAC;AAoBF,eAAe,IAAI,CAAC"}
@@ -1,15 +1,12 @@
1
1
  import "../../../config-WKwu1mMo.js";
2
2
  import { l as logger } from "../../../logger-hqtl8hFM.js";
3
- import { c as createConnectorFromPath } from "../../../connector-factory-13bvmpQB.js";
3
+ import { c as createConnectorFromPath } from "../../../connector-factory-DHmMYsRs.js";
4
4
  logger.level = process.env.LOG_LEVEL || "info";
5
5
  const main = async () => {
6
6
  try {
7
7
  logger.info('Worker for job "to-erp" online');
8
8
  logger.info("==========Starting to-erp job cycle==========");
9
9
  const connectorPath = process.env.CONNECTOR_PATH;
10
- logger.debug(`to-erp job: Received CONNECTOR_PATH: ${connectorPath}`);
11
- logger.debug(`to-erp job: CONNECTOR_PATH type: ${typeof connectorPath}`);
12
- logger.debug(`to-erp job: CONNECTOR_PATH length: ${connectorPath?.length}`);
13
10
  if (!connectorPath) {
14
11
  throw new Error("Connector path not provided in environment variables");
15
12
  }
@@ -40,9 +37,11 @@ const fileUrl = normalizedArgv1.startsWith("/") ? `file://${normalizedArgv1}` :
40
37
  );
41
38
  const isMainModule = import.meta.url === fileUrl;
42
39
  if (isMainModule) {
43
- main().catch(() => {
44
- process.exit(1);
45
- });
40
+ try {
41
+ await main();
42
+ } catch {
43
+ process.exitCode = 1;
44
+ }
46
45
  }
47
46
  export {
48
47
  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\n// Configure the logger with the correct log level\nlogger.level = process.env.LOG_LEVEL || \"info\";\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 // Add debug logging\n logger.debug(`to-erp job: Received CONNECTOR_PATH: ${connectorPath}`);\n logger.debug(`to-erp job: CONNECTOR_PATH type: ${typeof connectorPath}`);\n logger.debug(`to-erp job: CONNECTOR_PATH length: ${connectorPath?.length}`);\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":";;;AAMA,OAAO,QAAQ,QAAQ,IAAI,aAAa;AAExC,MAAM,OAAO,YAAY;AACvB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../../reporting-service/logger\";\nimport { createConnectorFromPath } from \"../../../utils/connector-factory\";\n\n// Configure the logger with the correct log level\nlogger.level = process.env.LOG_LEVEL || \"info\";\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 try {\n await main();\n } catch {\n process.exitCode = 1; // prefer exitCode so stdout/stderr can flush\n }\n}\n\nexport default main;\n"],"names":[],"mappings":";;;AAMA,OAAO,QAAQ,QAAQ,IAAI,aAAa;AAExC,MAAM,OAAO,YAAY;AACvB,MAAI;AACF,WAAO,KAAK,gCAAgC;AAC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-factory.d.ts","sourceRoot":"","sources":["../../src/utils/connector-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAIvD;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAClC,eAAe,MAAM,KACpB,OAAO,CAAC,aAAa,CAiCvB,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"log-deduper.d.ts","sourceRoot":"","sources":["../../../src/utils/connector-log/log-deduper.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAkB,MAAM,uBAAuB,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC7D,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,wBAAwB,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrG;AAkBD;;;GAGG;AACH,qBAAa,cAAe,YAAW,UAAU;IAC/C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,aAAa,CAAS;IAE9B,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAO;IAC/C,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAQ;IAC7C,OAAO,CAAC,QAAQ,CAAC,gCAAgC,CAAO;IACxD,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAA+C;IAEvF;;;;;;;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,QAAQ;IA2BtB;;OAEG;IACH,OAAO,CAAC,mBAAmB;CAW5B"}
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.6",
4
+ "version": "0.1.4",
5
5
  "license": "MIT",
6
6
  "author": "machinemetrics",
7
7
  "main": "dist/mm-erp-sdk.js",
@@ -43,9 +43,11 @@ const isMainModule = import.meta.url === fileUrl;
43
43
 
44
44
  if (isMainModule) {
45
45
  // This is called when Bree runs this file as a worker
46
- main().catch(() => {
47
- process.exit(1);
48
- });
46
+ try {
47
+ await main();
48
+ } catch {
49
+ process.exitCode = 1; // prefer exitCode so stdout/stderr can flush
50
+ }
49
51
  }
50
52
 
51
53
  export default main;
@@ -14,12 +14,7 @@ const main = async () => {
14
14
 
15
15
  // Get the connector path from the environment variable
16
16
  const connectorPath = process.env.CONNECTOR_PATH;
17
-
18
- // Add debug logging
19
- logger.debug(`from-erp job: Received CONNECTOR_PATH: ${connectorPath}`);
20
- logger.debug(`from-erp job: CONNECTOR_PATH type: ${typeof connectorPath}`);
21
- logger.debug(`from-erp job: CONNECTOR_PATH length: ${connectorPath?.length}`);
22
-
17
+
23
18
  if (!connectorPath) {
24
19
  throw new Error("Connector path not provided in environment variables");
25
20
  }
@@ -59,9 +54,11 @@ const isMainModule = import.meta.url === fileUrl;
59
54
 
60
55
  if (isMainModule) {
61
56
  // This is called when Bree runs this file as a worker
62
- main().catch(() => {
63
- process.exit(1);
64
- });
57
+ try {
58
+ await main();
59
+ } catch {
60
+ process.exitCode = 1; // prefer exitCode so stdout/stderr can flush
61
+ }
65
62
  }
66
63
 
67
64
  export default main;
@@ -49,7 +49,7 @@ const isMainModule = import.meta.url === fileUrl;
49
49
  if (isMainModule) {
50
50
  // This is called when Bree runs this file as a worker
51
51
  main().catch(() => {
52
- process.exit(1);
52
+ process.exitCode = 1;
53
53
  });
54
54
  }
55
55
 
@@ -15,7 +15,7 @@ export default async function runMigrations() {
15
15
  logger.info("Migrations complete!");
16
16
  } catch (error) {
17
17
  logger.error("Error running migrations:", error);
18
- process.exit(1);
18
+ process.exitCode = 1;
19
19
  } finally {
20
20
  await db.destroy();
21
21
  }
@@ -25,6 +25,6 @@ const isMainModule = import.meta.url === `file://${process.argv[1]}`;
25
25
  if (isMainModule) {
26
26
  runMigrations().catch(err => {
27
27
  logger.error("Top-level error running migrations:", err);
28
- process.exit(1);
28
+ process.exitCode = 1;
29
29
  });
30
30
  }
@@ -13,11 +13,6 @@ const main = async () => {
13
13
 
14
14
  // Get the connector path from the environment variable
15
15
  const connectorPath = process.env.CONNECTOR_PATH;
16
-
17
- // Add debug logging
18
- logger.debug(`to-erp job: Received CONNECTOR_PATH: ${connectorPath}`);
19
- logger.debug(`to-erp job: CONNECTOR_PATH type: ${typeof connectorPath}`);
20
- logger.debug(`to-erp job: CONNECTOR_PATH length: ${connectorPath?.length}`);
21
16
 
22
17
  if (!connectorPath) {
23
18
  throw new Error("Connector path not provided in environment variables");
@@ -60,9 +55,11 @@ const isMainModule = import.meta.url === fileUrl;
60
55
 
61
56
  if (isMainModule) {
62
57
  // This is called when Bree runs this file as a worker
63
- main().catch(() => {
64
- process.exit(1);
65
- });
58
+ try {
59
+ await main();
60
+ } catch {
61
+ process.exitCode = 1; // prefer exitCode so stdout/stderr can flush
62
+ }
66
63
  }
67
64
 
68
65
  export default main;
@@ -41,7 +41,7 @@ export class ApplicationInitializer {
41
41
  );
42
42
  } catch (error) {
43
43
  logger.error("Critical initialization failure. Exiting.", error);
44
- process.exit(1);
44
+ process.exitCode = 1;
45
45
  }
46
46
  }
47
47
 
@@ -11,21 +11,17 @@ export const createConnectorFromPath = async (
11
11
  connectorPath: string
12
12
  ): Promise<IERPConnector> => {
13
13
  try {
14
- // Add detailed debug logging
15
- logger.debug(`createConnectorFromPath: Received connector path: ${connectorPath}`);
16
- logger.debug(`createConnectorFromPath: Path type: ${typeof connectorPath}`);
17
- logger.debug(`createConnectorFromPath: Path length: ${connectorPath.length}`);
18
-
19
- // Log the path components
14
+ // Some detailed debug logging to help with troubleshooting multi-platform connector paths
20
15
  const pathParts = connectorPath.split('/');
21
- logger.debug(`createConnectorFromPath: Path parts: ${JSON.stringify(pathParts)}`);
22
-
23
- // Log the filename specifically
24
16
  const filename = pathParts[pathParts.length - 1];
25
- logger.debug(`createConnectorFromPath: Filename: ${filename}`);
26
-
27
- // Dynamic import the connector module
28
- logger.debug(`createConnectorFromPath: Attempting to import: ${pathToFileURL(connectorPath).href}`);
17
+
18
+ logger.debug("createConnectorFromPath:", {
19
+ connectorPath,
20
+ pathParts,
21
+ filename,
22
+ finalImport: pathToFileURL(connectorPath).href,
23
+ });
24
+
29
25
  const connectorModule = await import(pathToFileURL(connectorPath).href);
30
26
 
31
27
  // Get the default export or named export
@@ -102,6 +102,7 @@ export class FileLogDeduper implements LogDeduper {
102
102
  store[key] = {
103
103
  ...existing,
104
104
  suppressedCount: existing.suppressedCount + 1,
105
+ firstUnsentEventTs: existing.suppressedCount === 0 ? (entry.eventTime ?? now) : existing.firstUnsentEventTs,
105
106
  lastEventTs: entry.eventTime ?? now,
106
107
  level: entry.level,
107
108
  message: entry.message
@@ -111,10 +112,11 @@ export class FileLogDeduper implements LogDeduper {
111
112
  }
112
113
 
113
114
  // Outside window: allow, include timestamp and prior suppression count
114
- const messageToSend = this.formatMessage(entry.message, entry.eventTime ?? now, existing.suppressedCount);
115
+ const messageToSend = this.formatMessage(entry.message, entry.eventTime ?? now, existing.suppressedCount, existing.firstUnsentEventTs);
115
116
  store[key] = {
116
117
  ...existing,
117
118
  suppressedCount: 0,
119
+ firstUnsentEventTs: 0,
118
120
  lastEventTs: entry.eventTime ?? now,
119
121
  level: entry.level,
120
122
  message: entry.message
@@ -1 +0,0 @@
1
- {"version":3,"file":"connector-factory-13bvmpQB.js","sources":["../src/utils/connector-factory.ts"],"sourcesContent":["import { IERPConnector } from \"../types/erp-connector\";\nimport logger from \"../services/reporting-service/logger\";\nimport { pathToFileURL } from \"url\";\n\n/**\n * Helper function to dynamically import and create connector instance from a file path\n * @param connectorPath - The file path to the connector module\n * @returns A new instance of the IERPConnector\n */\nexport const createConnectorFromPath = async (\n connectorPath: string\n): Promise<IERPConnector> => {\n try {\n // Add detailed debug logging\n logger.debug(`createConnectorFromPath: Received connector path: ${connectorPath}`);\n logger.debug(`createConnectorFromPath: Path type: ${typeof connectorPath}`);\n logger.debug(`createConnectorFromPath: Path length: ${connectorPath.length}`);\n \n // Log the path components\n const pathParts = connectorPath.split('/');\n logger.debug(`createConnectorFromPath: Path parts: ${JSON.stringify(pathParts)}`);\n \n // Log the filename specifically\n const filename = pathParts[pathParts.length - 1];\n logger.debug(`createConnectorFromPath: Filename: ${filename}`);\n \n // Dynamic import the connector module\n logger.debug(`createConnectorFromPath: Attempting to import: ${pathToFileURL(connectorPath).href}`);\n const connectorModule = await import(pathToFileURL(connectorPath).href);\n\n // Get the default export or named export\n const ConnectorClass =\n connectorModule.default ||\n connectorModule[Object.keys(connectorModule)[0]];\n\n if (!ConnectorClass) {\n throw new Error(`No connector class found in module: ${connectorPath}`);\n }\n\n // Create new instance of the connector\n return new ConnectorClass();\n } catch (error) {\n logger.error(\n `Failed to create connector instance from path: ${connectorPath}`,\n { error }\n );\n throw error;\n }\n};"],"names":[],"mappings":";;AASO,MAAM,0BAA0B,OACrC,kBAC2B;AAC3B,MAAI;AAEF,WAAO,MAAM,qDAAqD,aAAa,EAAE;AACjF,WAAO,MAAM,uCAAuC,OAAO,aAAa,EAAE;AAC1E,WAAO,MAAM,yCAAyC,cAAc,MAAM,EAAE;AAG5E,UAAM,YAAY,cAAc,MAAM,GAAG;AACzC,WAAO,MAAM,wCAAwC,KAAK,UAAU,SAAS,CAAC,EAAE;AAGhF,UAAM,WAAW,UAAU,UAAU,SAAS,CAAC;AAC/C,WAAO,MAAM,sCAAsC,QAAQ,EAAE;AAG7D,WAAO,MAAM,kDAAkD,cAAc,aAAa,EAAE,IAAI,EAAE;AAClG,UAAM,kBAAkB,MAAM,OAAO,cAAc,aAAa,EAAE;AAGlE,UAAM,iBACJ,gBAAgB,WAChB,gBAAgB,OAAO,KAAK,eAAe,EAAE,CAAC,CAAC;AAEjD,QAAI,CAAC,gBAAgB;AACnB,YAAM,IAAI,MAAM,uCAAuC,aAAa,EAAE;AAAA,IACxE;AAGA,WAAO,IAAI,eAAA;AAAA,EACb,SAAS,OAAO;AACd,WAAO;AAAA,MACL,kDAAkD,aAAa;AAAA,MAC/D,EAAE,MAAA;AAAA,IAAM;AAEV,UAAM;AAAA,EACR;AACF;"}