@machinemetrics/mm-erp-sdk 0.1.4-beta.2 → 0.1.4-beta.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (26) hide show
  1. package/dist/connector-factory-OMijBGQX.js +29 -0
  2. package/dist/connector-factory-OMijBGQX.js.map +1 -0
  3. package/dist/mm-erp-sdk.js +1 -1
  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 +13 -7
  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 +36 -38
  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 +13 -3
  17. package/dist/services/data-sync-service/jobs/to-erp.js.map +1 -1
  18. package/dist/utils/connector-factory.d.ts.map +1 -1
  19. package/package.json +1 -1
  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 +16 -9
  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 +17 -5
  24. package/src/utils/connector-factory.ts +15 -1
  25. package/dist/connector-factory-DFv3ex0X.js +0 -21
  26. package/dist/connector-factory-DFv3ex0X.js.map +0 -1
@@ -0,0 +1,29 @@
1
+ import { l as logger } from "./logger-hqtl8hFM.js";
2
+ const createConnectorFromPath = async (connectorPath) => {
3
+ try {
4
+ logger.debug(`createConnectorFromPath: Received connector path: ${connectorPath}`);
5
+ logger.debug(`createConnectorFromPath: Path type: ${typeof connectorPath}`);
6
+ logger.debug(`createConnectorFromPath: Path length: ${connectorPath.length}`);
7
+ const pathParts = connectorPath.split("/");
8
+ logger.debug(`createConnectorFromPath: Path parts: ${JSON.stringify(pathParts)}`);
9
+ const filename = pathParts[pathParts.length - 1];
10
+ logger.debug(`createConnectorFromPath: Filename: ${filename}`);
11
+ logger.debug(`createConnectorFromPath: Attempting to import: ${connectorPath}`);
12
+ const connectorModule = await import(connectorPath);
13
+ const ConnectorClass = connectorModule.default || connectorModule[Object.keys(connectorModule)[0]];
14
+ if (!ConnectorClass) {
15
+ throw new Error(`No connector class found in module: ${connectorPath}`);
16
+ }
17
+ return new ConnectorClass();
18
+ } catch (error) {
19
+ logger.error(
20
+ `Failed to create connector instance from path: ${connectorPath}`,
21
+ { error }
22
+ );
23
+ throw error;
24
+ }
25
+ };
26
+ export {
27
+ createConnectorFromPath as c
28
+ };
29
+ //# sourceMappingURL=connector-factory-OMijBGQX.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"connector-factory-OMijBGQX.js","sources":["../src/utils/connector-factory.ts"],"sourcesContent":["import { IERPConnector } from \"../types/erp-connector\";\nimport logger from \"../services/reporting-service/logger\";\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: ${connectorPath}`);\n const connectorModule = await import(connectorPath);\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":";AAQO,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,aAAa,EAAE;AAC9E,UAAM,kBAAkB,MAAM,OAAO;AAGrC,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;"}
@@ -8,7 +8,7 @@ import knex from "knex";
8
8
  import { c as config } from "./knexfile-1qKKIORB.js";
9
9
  import fs from "fs";
10
10
  import path from "path";
11
- import "./connector-factory-DFv3ex0X.js";
11
+ import "./connector-factory-OMijBGQX.js";
12
12
  import Bree from "bree";
13
13
  import Graceful from "@ladjs/graceful";
14
14
  import { fileURLToPath } from "url";
@@ -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,qBAuCT,CAAC;AAkBF,eAAe,IAAI,CAAC"}
@@ -1,12 +1,15 @@
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-DFv3ex0X.js";
4
+ import { c as createConnectorFromPath } from "../../../connector-factory-OMijBGQX.js";
5
5
  const main = async () => {
6
6
  try {
7
7
  logger.info('Worker for job "from-erp" online');
8
8
  logger.info("==========Starting from-erp job cycle==========");
9
9
  const connectorPath = process.env.CONNECTOR_PATH;
10
+ logger.debug(`from-erp job: Received CONNECTOR_PATH: ${connectorPath}`);
11
+ logger.debug(`from-erp job: CONNECTOR_PATH type: ${typeof connectorPath}`);
12
+ logger.debug(`from-erp job: CONNECTOR_PATH length: ${connectorPath?.length}`);
10
13
  if (!connectorPath) {
11
14
  throw new Error("Connector path not provided in environment variables");
12
15
  }
@@ -30,13 +33,16 @@ const main = async () => {
30
33
  throw error;
31
34
  }
32
35
  };
33
- const isMainModule = import.meta.url === `file://${process.argv[1]}`;
36
+ const normalizedArgv1 = process.argv[1].replace(/\\/g, "/");
37
+ const fileUrl = normalizedArgv1.startsWith("/") ? `file://${normalizedArgv1}` : (
38
+ // Unix: file:// + /path = file:///path
39
+ `file:///${normalizedArgv1}`
40
+ );
41
+ const isMainModule = import.meta.url === fileUrl;
34
42
  if (isMainModule) {
35
- try {
36
- await main();
37
- } catch {
38
- process.exitCode = 1;
39
- }
43
+ main().catch(() => {
44
+ process.exit(1);
45
+ });
40
46
  }
41
47
  export {
42
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\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 // 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":";;;;AAMA,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,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
- 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;
3
+ import { c as createConnectorFromPath } from "../../../connector-factory-OMijBGQX.js";
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,qBAyCT,CAAC;AAkBF,eAAe,IAAI,CAAC"}
@@ -1,11 +1,14 @@
1
1
  import "../../../config-WKwu1mMo.js";
2
2
  import { l as logger } from "../../../logger-hqtl8hFM.js";
3
- import { c as createConnectorFromPath } from "../../../connector-factory-DFv3ex0X.js";
3
+ import { c as createConnectorFromPath } from "../../../connector-factory-OMijBGQX.js";
4
4
  const main = async () => {
5
5
  try {
6
6
  logger.info('Worker for job "to-erp" online');
7
7
  logger.info("==========Starting to-erp job cycle==========");
8
8
  const connectorPath = process.env.CONNECTOR_PATH;
9
+ logger.debug(`to-erp job: Received CONNECTOR_PATH: ${connectorPath}`);
10
+ logger.debug(`to-erp job: CONNECTOR_PATH type: ${typeof connectorPath}`);
11
+ logger.debug(`to-erp job: CONNECTOR_PATH length: ${connectorPath?.length}`);
9
12
  if (!connectorPath) {
10
13
  throw new Error("Connector path not provided in environment variables");
11
14
  }
@@ -29,9 +32,16 @@ const main = async () => {
29
32
  throw error;
30
33
  }
31
34
  };
32
- const isMainModule = import.meta.url === `file://${process.argv[1]}`;
35
+ const normalizedArgv1 = process.argv[1].replace(/\\/g, "/");
36
+ const fileUrl = normalizedArgv1.startsWith("/") ? `file://${normalizedArgv1}` : (
37
+ // Unix: file:// + /path = file:///path
38
+ `file:///${normalizedArgv1}`
39
+ );
40
+ const isMainModule = import.meta.url === fileUrl;
33
41
  if (isMainModule) {
34
- main();
42
+ main().catch(() => {
43
+ process.exit(1);
44
+ });
35
45
  }
36
46
  export {
37
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\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 // 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":";;;AAKA,MAAM,OAAO,YAAY;AACvB,MAAI;AACF,WAAO,KAAK,gCAAgC;AAC5C,WAAO,KAAK,+CAA+C;AAG3D,UAAM,gBAAgB,QAAQ,IAAI;AAGlC,WAAO,MAAM,wCAAwC,aAAa,EAAE;AACpE,WAAO,MAAM,oCAAoC,OAAO,aAAa,EAAE;AACvE,WAAO,MAAM,sCAAsC,eAAe,MAAM,EAAE;AAE1E,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;"}
@@ -1 +1 @@
1
- {"version":3,"file":"connector-factory.d.ts","sourceRoot":"","sources":["../../src/utils/connector-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAClC,eAAe,MAAM,KACpB,OAAO,CAAC,aAAa,CAuBvB,CAAC"}
1
+ {"version":3,"file":"connector-factory.d.ts","sourceRoot":"","sources":["../../src/utils/connector-factory.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AAGvD;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,GAClC,eAAe,MAAM,KACpB,OAAO,CAAC,aAAa,CAqCvB,CAAC"}
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.2",
4
+ "version": "0.1.4-beta.4",
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
- // 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;
@@ -11,7 +11,11 @@ const main = async () => {
11
11
 
12
12
  // Get the connector path from the environment variable
13
13
  const connectorPath = process.env.CONNECTOR_PATH;
14
-
14
+
15
+ // Add debug logging
16
+ logger.debug(`from-erp job: Received CONNECTOR_PATH: ${connectorPath}`);
17
+ logger.debug(`from-erp job: CONNECTOR_PATH type: ${typeof connectorPath}`);
18
+ logger.debug(`from-erp job: CONNECTOR_PATH length: ${connectorPath?.length}`);
15
19
 
16
20
  if (!connectorPath) {
17
21
  throw new Error("Connector path not provided in environment variables");
@@ -41,17 +45,20 @@ const main = async () => {
41
45
  }
42
46
  };
43
47
 
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]}`;
48
+ // Cross-platform module detection fix for Bree compatibility
49
+ // Windows: process.argv[1] uses backslashes, import.meta.url uses forward slashes
50
+ // Linux/Mac: both use forward slashes, so this normalization is safe
51
+ const normalizedArgv1 = process.argv[1].replace(/\\/g, '/');
52
+ const fileUrl = normalizedArgv1.startsWith('/') ?
53
+ `file://${normalizedArgv1}` : // Unix: file:// + /path = file:///path
54
+ `file:///${normalizedArgv1}`; // Windows: file:/// + C:/path = file:///C:/path
55
+ const isMainModule = import.meta.url === fileUrl;
47
56
 
48
57
  if (isMainModule) {
49
58
  // 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
- }
59
+ main().catch(() => {
60
+ process.exit(1);
61
+ });
55
62
  }
56
63
 
57
64
  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;
@@ -10,6 +10,11 @@ const main = async () => {
10
10
 
11
11
  // Get the connector path from the environment variable
12
12
  const connectorPath = process.env.CONNECTOR_PATH;
13
+
14
+ // Add debug logging
15
+ logger.debug(`to-erp job: Received CONNECTOR_PATH: ${connectorPath}`);
16
+ logger.debug(`to-erp job: CONNECTOR_PATH type: ${typeof connectorPath}`);
17
+ logger.debug(`to-erp job: CONNECTOR_PATH length: ${connectorPath?.length}`);
13
18
 
14
19
  if (!connectorPath) {
15
20
  throw new Error("Connector path not provided in environment variables");
@@ -41,13 +46,20 @@ const main = async () => {
41
46
  }
42
47
  };
43
48
 
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]}`;
49
+ // Cross-platform module detection fix for Bree compatibility
50
+ // Windows: process.argv[1] uses backslashes, import.meta.url uses forward slashes
51
+ // Linux/Mac: both use forward slashes, so this normalization is safe
52
+ const normalizedArgv1 = process.argv[1].replace(/\\/g, '/');
53
+ const fileUrl = normalizedArgv1.startsWith('/') ?
54
+ `file://${normalizedArgv1}` : // Unix: file:// + /path = file:///path
55
+ `file:///${normalizedArgv1}`; // Windows: file:/// + C:/path = file:///C:/path
56
+ const isMainModule = import.meta.url === fileUrl;
57
+
47
58
  if (isMainModule) {
48
59
  // This is called when Bree runs this file as a worker
49
- main();
60
+ main().catch(() => {
61
+ process.exit(1);
62
+ });
50
63
  }
51
64
 
52
- // Export for potential testing or direct usage (ES module default export)
53
65
  export default main;
@@ -10,7 +10,21 @@ export const createConnectorFromPath = async (
10
10
  connectorPath: string
11
11
  ): Promise<IERPConnector> => {
12
12
  try {
13
+ // Add detailed debug logging
14
+ logger.debug(`createConnectorFromPath: Received connector path: ${connectorPath}`);
15
+ logger.debug(`createConnectorFromPath: Path type: ${typeof connectorPath}`);
16
+ logger.debug(`createConnectorFromPath: Path length: ${connectorPath.length}`);
17
+
18
+ // Log the path components
19
+ const pathParts = connectorPath.split('/');
20
+ logger.debug(`createConnectorFromPath: Path parts: ${JSON.stringify(pathParts)}`);
21
+
22
+ // Log the filename specifically
23
+ const filename = pathParts[pathParts.length - 1];
24
+ logger.debug(`createConnectorFromPath: Filename: ${filename}`);
25
+
13
26
  // Dynamic import the connector module
27
+ logger.debug(`createConnectorFromPath: Attempting to import: ${connectorPath}`);
14
28
  const connectorModule = await import(connectorPath);
15
29
 
16
30
  // Get the default export or named export
@@ -31,4 +45,4 @@ export const createConnectorFromPath = async (
31
45
  );
32
46
  throw error;
33
47
  }
34
- };
48
+ };
@@ -1,21 +0,0 @@
1
- import { l as logger } from "./logger-hqtl8hFM.js";
2
- const createConnectorFromPath = async (connectorPath) => {
3
- try {
4
- const connectorModule = await import(connectorPath);
5
- const ConnectorClass = connectorModule.default || connectorModule[Object.keys(connectorModule)[0]];
6
- if (!ConnectorClass) {
7
- throw new Error(`No connector class found in module: ${connectorPath}`);
8
- }
9
- return new ConnectorClass();
10
- } catch (error) {
11
- logger.error(
12
- `Failed to create connector instance from path: ${connectorPath}`,
13
- { error }
14
- );
15
- throw error;
16
- }
17
- };
18
- export {
19
- createConnectorFromPath as c
20
- };
21
- //# sourceMappingURL=connector-factory-DFv3ex0X.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connector-factory-DFv3ex0X.js","sources":["../src/utils/connector-factory.ts"],"sourcesContent":["import { IERPConnector } from \"../types/erp-connector\";\nimport logger from \"../services/reporting-service/logger\";\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 // Dynamic import the connector module\n const connectorModule = await import(connectorPath);\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};\n"],"names":[],"mappings":";AAQO,MAAM,0BAA0B,OACrC,kBAC2B;AAC3B,MAAI;AAEF,UAAM,kBAAkB,MAAM,OAAO;AAGrC,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;"}