@machinemetrics/mm-erp-sdk 0.1.4-beta.1 → 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.
Files changed (23) hide show
  1. package/dist/index.d.ts +3 -0
  2. package/dist/index.d.ts.map +1 -1
  3. package/dist/mm-erp-sdk.js +2 -0
  4. package/dist/services/data-sync-service/jobs/clean-up-expired-cache.d.ts +2 -0
  5. package/dist/services/data-sync-service/jobs/clean-up-expired-cache.d.ts.map +1 -1
  6. package/dist/services/data-sync-service/jobs/clean-up-expired-cache.js +36 -38
  7. package/dist/services/data-sync-service/jobs/clean-up-expired-cache.js.map +1 -1
  8. package/dist/services/data-sync-service/jobs/from-erp.d.ts.map +1 -1
  9. package/dist/services/data-sync-service/jobs/from-erp.js +9 -6
  10. package/dist/services/data-sync-service/jobs/from-erp.js.map +1 -1
  11. package/dist/services/data-sync-service/jobs/retry-failed-labor-tickets.d.ts +2 -0
  12. package/dist/services/data-sync-service/jobs/retry-failed-labor-tickets.d.ts.map +1 -1
  13. package/dist/services/data-sync-service/jobs/retry-failed-labor-tickets.js +35 -37
  14. package/dist/services/data-sync-service/jobs/retry-failed-labor-tickets.js.map +1 -1
  15. package/dist/services/data-sync-service/jobs/to-erp.d.ts.map +1 -1
  16. package/dist/services/data-sync-service/jobs/to-erp.js +9 -2
  17. package/dist/services/data-sync-service/jobs/to-erp.js.map +1 -1
  18. package/package.json +1 -1
  19. package/src/index.ts +7 -0
  20. package/src/services/data-sync-service/jobs/clean-up-expired-cache.ts +15 -8
  21. package/src/services/data-sync-service/jobs/from-erp.ts +11 -8
  22. package/src/services/data-sync-service/jobs/retry-failed-labor-tickets.ts +13 -6
  23. package/src/services/data-sync-service/jobs/to-erp.ts +12 -5
package/dist/index.d.ts CHANGED
@@ -38,5 +38,8 @@ export { BatchCacheManager } from "./services/caching-service/batch-cache-manage
38
38
  export { CoreConfiguration, getSQLServerConfiguration, } from "./services/data-sync-service/configuration-manager";
39
39
  export { SqlServerService, SqlServerHelper, } from "./services/sql-server-erp-service";
40
40
  export type { SQLInput } from "./services/sql-server-erp-service";
41
+ export { RecordTrackingManager } from "./services/caching-service/record-tracking-manager";
42
+ export type { RecordTrackingObject } from "./services/caching-service/record-tracking-manager";
43
+ export { default as knexDatabaseConfig } from "./knexfile";
41
44
  export { MMConnectorLogger, FileLogDeduper, LogEntry, type LogLevelString, type LogResponse } from './utils';
42
45
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,YAAY,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACxD,YAAY,EAAE,aAAa,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAG/E,OAAO,EAAE,sBAAsB,EAAE,MAAM,oDAAoD,CAAC;AAC5F,OAAO,EAAE,yBAAyB,EAAE,MAAM,oDAAoD,CAAC;AAC/F,OAAO,EAAE,qBAAqB,EAAE,MAAM,mDAAmD,CAAC;AAC1F,YAAY,EAAE,YAAY,EAAE,MAAM,mCAAmC,CAAC;AAGtE,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AACjE,YAAY,EACV,0BAA0B,EAC1B,sCAAsC,EACtC,gBAAgB,GACjB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EACL,YAAY,EACZ,cAAc,EACd,UAAU,EACV,mBAAmB,EACnB,eAAe,EACf,wBAAwB,EACxB,YAAY,EACZ,iBAAiB,GAClB,MAAM,2BAA2B,CAAC;AAEnC,YAAY,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGtE,OAAO,EACL,aAAa,EACb,sBAAsB,EACtB,wBAAwB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iB,EAAE,MAAM,gDAAgD,CAAC;AAGnF,OAAO,EACL,iBAAiB,EACjB,yBAAyB,GAC1B,MAAM,oDAAoD,CAAC;AAG5D,OAAO,EACL,gBAAgB,EAChB,eAAe,GAChB,MAAM,mCAAmC,CAAC;AAC3C,YAAY,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAGlE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oDAAoD,CAAC;AAC3F,YAAY,EAAE,oBAAoB,EAAE,MAAM,oDAAoD,CAAC;AAG/F,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAG3D,OAAO,EAAE,iBAAiB,EAAE,cAAc,EAAE,QAAQ,EAAE,KAAK,cAAc,EAAE,KAAK,WAAW,EAAE,MAAM,SAAS,CAAC"}
@@ -3990,6 +3990,7 @@ export {
3990
3990
  MMSendWorkOrder,
3991
3991
  MMSendWorkOrderOperation,
3992
3992
  OAuthClient,
3993
+ RecordTrackingManager,
3993
3994
  RestAPIService,
3994
3995
  SqlServerHelper,
3995
3996
  SqlServerService,
@@ -4008,6 +4009,7 @@ export {
4008
4009
  getPayloadWithoutIDField,
4009
4010
  a as getSQLServerConfiguration,
4010
4011
  getUniqueRows,
4012
+ config as knexDatabaseConfig,
4011
4013
  logger,
4012
4014
  removeExtraneousFields,
4013
4015
  runDataSyncService,
@@ -1,2 +1,4 @@
1
1
  import "dotenv/config";
2
+ declare const main: () => Promise<void>;
3
+ export default main;
2
4
  //# sourceMappingURL=clean-up-expired-cache.d.ts.map
@@ -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
- var require_clean_up_expired_cache = __commonJS({
10
- "services/data-sync-service/jobs/clean-up-expired-cache.js"(exports, module) {
11
- const main = async () => {
12
- const cacheManager = new HashedCacheManager();
13
- try {
14
- logger.info('Worker for job "clean-up-expired-cache" online');
15
- logger.info(
16
- "==========Starting clean-up-expired-cache job cycle=========="
17
- );
18
- await SQLiteCoordinator.executeWithLock("clean-up-cache", async () => {
19
- await cacheManager.removeExpiredObjects();
20
- });
21
- logger.info(
22
- "==========Completed clean-up-expired-cache job cycle=========="
23
- );
24
- } catch (error) {
25
- logger.error('Worker for job "clean-up-expired-cache" had an error', {
26
- err: error
27
- });
28
- throw error;
29
- } finally {
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
- export default require_clean_up_expired_cache();
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// For Bree compatibility - check if this is running as a worker\nif (require.main === module) {\n // This is called when Bree runs this file as a worker\n (async () => {\n await main();\n })();\n} else {\n // Export for potential testing or direct usage\n module.exports = main;\n}\n"],"names":[],"mappings":";;;;;;;;;;AAKA,UAAM,OAAO,YAAY;AACvB,YAAM,eAAe,IAAI,mBAAA;AACzB,UAAI;AACF,eAAO,KAAK,gDAAgD;AAC5D,eAAO;AAAA,UACL;AAAA,QAAA;AAGF,cAAM,kBAAkB,gBAAgB,kBAAkB,YAAY;AACpE,gBAAM,aAAa,qBAAA;AAAA,QACrB,CAAC;AAED,eAAO;AAAA,UACL;AAAA,QAAA;AAAA,MAEJ,SAAS,OAAO;AACd,eAAO,MAAM,wDAAwD;AAAA,UACnE,KAAK;AAAA,QAAA,CACN;AACD,cAAM;AAAA,MACR,UAAA;AACE,cAAM,aAAa,QAAA;AACnB,eAAO,KAAK,0DAA0D;AAAA,MACxE;AAAA,IACF;AAGA,QAAI,QAAQ,SAAS,QAAQ;AAE3B,OAAC,YAAY;AACX,cAAM,KAAA;AAAA,MACR,GAAA;AAAA,IACF,OAAO;AAEL,aAAO,UAAU;AAAA,IACnB;AAAA;AAAA;"}
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;AAeF,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;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 isMainModule = import.meta.url === `file://${process.argv[1]}`;
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
- try {
36
- await main();
37
- } catch {
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// For Bree compatibility - check if this is running as a worker\n// In ES modules, we need to check import.meta.url instead of require.main\nconst isMainModule = import.meta.url === `file://${process.argv[1]}`;\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":";;;;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;AAIA,MAAM,eAAe,YAAY,QAAQ,UAAU,QAAQ,KAAK,CAAC,CAAC;AAElE,IAAI,cAAc;AAEhB,MAAI;AACF,UAAM,KAAA;AAAA,EACR,QAAQ;AACN,YAAQ,WAAW;AAAA,EACrB;AACF;"}
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,2 +1,4 @@
1
1
  import "dotenv/config";
2
+ declare const main: () => Promise<void>;
3
+ export default main;
2
4
  //# sourceMappingURL=retry-failed-labor-tickets.d.ts.map
@@ -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
- var require_retry_failed_labor_tickets = __commonJS({
9
- "services/data-sync-service/jobs/retry-failed-labor-tickets.js"(exports, module) {
10
- const main = async () => {
11
- try {
12
- logger.info('Worker for job "retry-failed-labor-tickets" online');
13
- logger.info(
14
- "==========Starting retry-failed-labor-tickets job cycle=========="
15
- );
16
- const connectorPath = process.env.CONNECTOR_PATH;
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
- export default require_retry_failed_labor_tickets();
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// For Bree compatibility - check if this is running as a worker\nif (require.main === module) {\n // This is called when Bree runs this file as a worker\n main().catch(() => {\n process.exitCode = 1;\n });\n} else {\n // Export for potential testing or direct usage\n module.exports = main;\n}\n"],"names":[],"mappings":";;;;;;;;;AAKA,UAAM,OAAO,YAAY;AACvB,UAAI;AACF,eAAO,KAAK,oDAAoD;AAChE,eAAO;AAAA,UACL;AAAA,QAAA;AAIF,cAAM,gBAAgB,QAAQ,IAAI;AAElC,YAAI,CAAC,eAAe;AAClB,gBAAM,IAAI,MAAM,sDAAsD;AAAA,QACxE;AAGA,cAAM,YAAY,MAAM,wBAAwB,aAAa;AAE7D,cAAM,UAAU,wBAAA;AAChB,cAAM,UAAU,iCAAA;AAEhB,eAAO;AAAA,UACL;AAAA,QAAA;AAAA,MAEJ,SAAS,OAAO;AACd,eAAO,MAAM,4DAA4D;AAAA,UACvE,KAAK;AAAA,QAAA,CACN;AACD,cAAM;AAAA,MACR;AAAA,IACF;AAGA,QAAI,QAAQ,SAAS,QAAQ;AAE3B,WAAA,EAAO,MAAM,MAAM;AACjB,gBAAQ,WAAW;AAAA,MACrB,CAAC;AAAA,IACH,OAAO;AAEL,aAAO,UAAU;AAAA,IACnB;AAAA;AAAA;"}
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;AAWF,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;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 isMainModule = import.meta.url === `file://${process.argv[1]}`;
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// For Bree compatibility - check if this is running as a worker\n// In ES modules, we need to check import.meta.url instead of require.main\nconst isMainModule = import.meta.url === `file://${process.argv[1]}`;\nif (isMainModule) {\n // This is called when Bree runs this file as a worker\n main();\n}\n\n// Export for potential testing or direct usage (ES module default export)\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;AAIA,MAAM,eAAe,YAAY,QAAQ,UAAU,QAAQ,KAAK,CAAC,CAAC;AAClE,IAAI,cAAc;AAEhB,OAAA;AACF;"}
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.1",
4
+ "version": "0.1.4-beta.3",
5
5
  "license": "MIT",
6
6
  "author": "machinemetrics",
7
7
  "main": "dist/mm-erp-sdk.js",
package/src/index.ts CHANGED
@@ -105,5 +105,12 @@ export {
105
105
  } from "./services/sql-server-erp-service";
106
106
  export type { SQLInput } from "./services/sql-server-erp-service";
107
107
 
108
+ // Record tracking services
109
+ export { RecordTrackingManager } from "./services/caching-service/record-tracking-manager";
110
+ export type { RecordTrackingObject } from "./services/caching-service/record-tracking-manager";
111
+
112
+ // Knex services
113
+ export { default as knexDatabaseConfig } from "./knexfile";
114
+
108
115
  // MM Connector Logging
109
116
  export { MMConnectorLogger, FileLogDeduper, LogEntry, type LogLevelString, type LogResponse } from './utils';
@@ -29,13 +29,20 @@ const main = async () => {
29
29
  }
30
30
  };
31
31
 
32
- // For Bree compatibility - check if this is running as a worker
33
- if (require.main === module) {
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
- (async () => {
36
- await main();
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
- // For Bree compatibility - check if this is running as a worker
45
- // In ES modules, we need to check import.meta.url instead of require.main
46
- const isMainModule = import.meta.url === `file://${process.argv[1]}`;
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
- try {
51
- await main();
52
- } catch {
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
- // For Bree compatibility - check if this is running as a worker
38
- if (require.main === module) {
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.exitCode = 1;
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
- // For Bree compatibility - check if this is running as a worker
45
- // In ES modules, we need to check import.meta.url instead of require.main
46
- const isMainModule = import.meta.url === `file://${process.argv[1]}`;
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;