@machinemetrics/mm-erp-sdk 0.1.4-beta.3 → 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.
@@ -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 +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;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;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
  }
@@ -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// 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
+ {"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,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-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 "retry-failed-labor-tickets" online');
@@ -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;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;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
  }
@@ -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// 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;"}
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.3",
4
+ "version": "0.1.4-beta.4",
5
5
  "license": "MIT",
6
6
  "author": "machinemetrics",
7
7
  "main": "dist/mm-erp-sdk.js",
@@ -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");
@@ -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");
@@ -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;"}