@machinemetrics/mm-erp-sdk 0.1.4-beta.3 → 0.1.4-beta.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/connector-factory-OMijBGQX.js +29 -0
- package/dist/connector-factory-OMijBGQX.js.map +1 -0
- package/dist/mm-erp-sdk.js +1 -1
- package/dist/services/data-sync-service/jobs/clean-up-expired-cache.d.ts.map +1 -1
- package/dist/services/data-sync-service/jobs/clean-up-expired-cache.js +1 -0
- package/dist/services/data-sync-service/jobs/clean-up-expired-cache.js.map +1 -1
- package/dist/services/data-sync-service/jobs/from-erp.d.ts.map +1 -1
- package/dist/services/data-sync-service/jobs/from-erp.js +5 -1
- package/dist/services/data-sync-service/jobs/from-erp.js.map +1 -1
- package/dist/services/data-sync-service/jobs/retry-failed-labor-tickets.d.ts.map +1 -1
- package/dist/services/data-sync-service/jobs/retry-failed-labor-tickets.js +2 -1
- package/dist/services/data-sync-service/jobs/retry-failed-labor-tickets.js.map +1 -1
- package/dist/services/data-sync-service/jobs/run-migrations.d.ts.map +1 -1
- package/dist/services/data-sync-service/jobs/run-migrations.js +1 -0
- package/dist/services/data-sync-service/jobs/run-migrations.js.map +1 -1
- package/dist/services/data-sync-service/jobs/to-erp.d.ts.map +1 -1
- package/dist/services/data-sync-service/jobs/to-erp.js +5 -1
- package/dist/services/data-sync-service/jobs/to-erp.js.map +1 -1
- package/dist/utils/connector-factory.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/services/data-sync-service/jobs/clean-up-expired-cache.ts +3 -0
- package/src/services/data-sync-service/jobs/from-erp.ts +8 -1
- package/src/services/data-sync-service/jobs/retry-failed-labor-tickets.ts +3 -0
- package/src/services/data-sync-service/jobs/run-migrations.ts +3 -0
- package/src/services/data-sync-service/jobs/to-erp.ts +8 -0
- package/src/utils/connector-factory.ts +15 -1
- package/dist/connector-factory-DFv3ex0X.js +0 -21
- 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;"}
|
package/dist/mm-erp-sdk.js
CHANGED
|
@@ -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-
|
|
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":"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;AAQvB,QAAA,MAAM,IAAI,qBAwBT,CAAC;AAkBF,eAAe,IAAI,CAAC"}
|
|
@@ -2,6 +2,7 @@ import "../../../config-WKwu1mMo.js";
|
|
|
2
2
|
import { H as HashedCacheManager } from "../../../hashed-cache-manager-CtDhFqj6.js";
|
|
3
3
|
import { S as SQLiteCoordinator } from "../../../index-aci_wdcn.js";
|
|
4
4
|
import { l as logger } from "../../../logger-hqtl8hFM.js";
|
|
5
|
+
logger.level = process.env.LOG_LEVEL || "info";
|
|
5
6
|
const main = async () => {
|
|
6
7
|
const cacheManager = new HashedCacheManager();
|
|
7
8
|
try {
|
|
@@ -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// 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":";;;;
|
|
1
|
+
{"version":3,"file":"clean-up-expired-cache.js","sources":["../../../../src/services/data-sync-service/jobs/clean-up-expired-cache.ts"],"sourcesContent":["import \"dotenv/config\";\nimport { HashedCacheManager } from \"../../caching-service/hashed-cache-manager\";\nimport { SQLiteCoordinator } from \"../../sqlite-service\";\nimport logger from \"../../../services/reporting-service/logger\";\n\n// Configure the logger with the correct log level\nlogger.level = process.env.LOG_LEVEL || \"info\";\n\nconst main = async () => {\n const cacheManager = new HashedCacheManager();\n try {\n logger.info('Worker for job \"clean-up-expired-cache\" online');\n logger.info(\n \"==========Starting clean-up-expired-cache job cycle==========\"\n );\n\n await SQLiteCoordinator.executeWithLock(\"clean-up-cache\", async () => {\n await cacheManager.removeExpiredObjects();\n });\n\n logger.info(\n \"==========Completed clean-up-expired-cache job cycle==========\"\n );\n } catch (error) {\n logger.error('Worker for job \"clean-up-expired-cache\" had an error', {\n err: error,\n });\n throw error; // Rethrow so Bree can handle it properly\n } finally {\n await cacheManager.destroy();\n logger.info(`==========Completed clean-up-expired-cache job==========`);\n }\n};\n\n// Cross-platform module detection fix for Bree compatibility\n// Windows: process.argv[1] uses backslashes, import.meta.url uses forward slashes\n// Linux/Mac: both use forward slashes, so this normalization is safe\nconst normalizedArgv1 = process.argv[1].replace(/\\\\/g, '/');\nconst fileUrl = normalizedArgv1.startsWith('/') ? \n `file://${normalizedArgv1}` : // Unix: file:// + /path = file:///path\n `file:///${normalizedArgv1}`; // Windows: file:/// + C:/path = file:///C:/path\nconst isMainModule = import.meta.url === fileUrl;\n\nif (isMainModule) {\n // This is called when Bree runs this file as a worker\n main().catch(() => {\n process.exit(1);\n });\n}\n\nexport default main;\n"],"names":[],"mappings":";;;;AAMA,OAAO,QAAQ,QAAQ,IAAI,aAAa;AAExC,MAAM,OAAO,YAAY;AACvB,QAAM,eAAe,IAAI,mBAAA;AACzB,MAAI;AACF,WAAO,KAAK,gDAAgD;AAC5D,WAAO;AAAA,MACL;AAAA,IAAA;AAGF,UAAM,kBAAkB,gBAAgB,kBAAkB,YAAY;AACpE,YAAM,aAAa,qBAAA;AAAA,IACrB,CAAC;AAED,WAAO;AAAA,MACL;AAAA,IAAA;AAAA,EAEJ,SAAS,OAAO;AACd,WAAO,MAAM,wDAAwD;AAAA,MACnE,KAAK;AAAA,IAAA,CACN;AACD,UAAM;AAAA,EACR,UAAA;AACE,UAAM,aAAa,QAAA;AACnB,WAAO,KAAK,0DAA0D;AAAA,EACxE;AACF;AAKA,MAAM,kBAAkB,QAAQ,KAAK,CAAC,EAAE,QAAQ,OAAO,GAAG;AAC1D,MAAM,UAAU,gBAAgB,WAAW,GAAG,IAC5C,UAAU,eAAe;AAAA;AAAA,EACzB,WAAW,eAAe;AAAA;AAC5B,MAAM,eAAe,YAAY,QAAQ;AAEzC,IAAI,cAAc;AAEhB,OAAA,EAAO,MAAM,MAAM;AACjB,YAAQ,KAAK,CAAC;AAAA,EAChB,CAAC;AACH;"}
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"from-erp.d.ts","sourceRoot":"","sources":["../../../../src/services/data-sync-service/jobs/from-erp.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AASvB,QAAA,MAAM,IAAI,qBAuCT,CAAC;AAkBF,eAAe,IAAI,CAAC"}
|
|
@@ -1,12 +1,16 @@
|
|
|
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-
|
|
4
|
+
import { c as createConnectorFromPath } from "../../../connector-factory-OMijBGQX.js";
|
|
5
|
+
logger.level = process.env.LOG_LEVEL || "info";
|
|
5
6
|
const main = async () => {
|
|
6
7
|
try {
|
|
7
8
|
logger.info('Worker for job "from-erp" online');
|
|
8
9
|
logger.info("==========Starting from-erp job cycle==========");
|
|
9
10
|
const connectorPath = process.env.CONNECTOR_PATH;
|
|
11
|
+
logger.debug(`from-erp job: Received CONNECTOR_PATH: ${connectorPath}`);
|
|
12
|
+
logger.debug(`from-erp job: CONNECTOR_PATH type: ${typeof connectorPath}`);
|
|
13
|
+
logger.debug(`from-erp job: CONNECTOR_PATH length: ${connectorPath?.length}`);
|
|
10
14
|
if (!connectorPath) {
|
|
11
15
|
throw new Error("Connector path not provided in environment variables");
|
|
12
16
|
}
|
|
@@ -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":";;;;
|
|
1
|
+
{"version":3,"file":"from-erp.js","sources":["../../../../src/services/data-sync-service/jobs/from-erp.ts"],"sourcesContent":["import \"dotenv/config\";\n\nimport logger from \"../../../services/reporting-service/logger\";\nimport { SQLiteCoordinator } from \"../../sqlite-service\";\nimport { createConnectorFromPath } from \"../../../utils/connector-factory\";\n\n// Configure the logger with the correct log level\nlogger.level = process.env.LOG_LEVEL || \"info\";\n\nconst main = async () => {\n try {\n logger.info('Worker for job \"from-erp\" online');\n logger.info(\"==========Starting from-erp job cycle==========\");\n\n // Get the connector path from the environment variable\n const connectorPath = process.env.CONNECTOR_PATH;\n \n // Add debug logging\n logger.debug(`from-erp job: Received CONNECTOR_PATH: ${connectorPath}`);\n logger.debug(`from-erp job: CONNECTOR_PATH type: ${typeof connectorPath}`);\n logger.debug(`from-erp job: CONNECTOR_PATH length: ${connectorPath?.length}`);\n\n if (!connectorPath) {\n throw new Error(\"Connector path not provided in environment variables\");\n }\n\n // Create a new connector instance for this job\n const connector = await createConnectorFromPath(connectorPath);\n\n await SQLiteCoordinator.executeWithLock(\"from-erp\", async () => {\n await connector.syncFromERP();\n });\n\n await connector.syncFromERPCompleted();\n logger.info(\"==========Completed from-erp job cycle==========\");\n } catch (error) {\n const errorDetails = {\n message: error instanceof Error ? error.message : String(error),\n stack: error instanceof Error ? error.stack : undefined,\n name: error instanceof Error ? error.name : undefined,\n ...(error && typeof error === \"object\" ? error : {}), // Include all enumerable properties if it's an object\n };\n logger.error('Worker for job \"from-erp\" had an error', {\n error: errorDetails,\n });\n\n throw error; // Rethrow so Bree can handle it properly\n }\n};\n\n// Cross-platform module detection fix for Bree compatibility\n// Windows: process.argv[1] uses backslashes, import.meta.url uses forward slashes\n// Linux/Mac: both use forward slashes, so this normalization is safe\nconst normalizedArgv1 = process.argv[1].replace(/\\\\/g, '/');\nconst fileUrl = normalizedArgv1.startsWith('/') ? \n `file://${normalizedArgv1}` : // Unix: file:// + /path = file:///path\n `file:///${normalizedArgv1}`; // Windows: file:/// + C:/path = file:///C:/path\nconst isMainModule = import.meta.url === fileUrl;\n\nif (isMainModule) {\n // This is called when Bree runs this file as a worker\n main().catch(() => {\n process.exit(1);\n });\n}\n\nexport default main;"],"names":[],"mappings":";;;;AAOA,OAAO,QAAQ,QAAQ,IAAI,aAAa;AAExC,MAAM,OAAO,YAAY;AACvB,MAAI;AACF,WAAO,KAAK,kCAAkC;AAC9C,WAAO,KAAK,iDAAiD;AAG7D,UAAM,gBAAgB,QAAQ,IAAI;AAGlC,WAAO,MAAM,0CAA0C,aAAa,EAAE;AACtE,WAAO,MAAM,sCAAsC,OAAO,aAAa,EAAE;AACzE,WAAO,MAAM,wCAAwC,eAAe,MAAM,EAAE;AAE5E,QAAI,CAAC,eAAe;AAClB,YAAM,IAAI,MAAM,sDAAsD;AAAA,IACxE;AAGA,UAAM,YAAY,MAAM,wBAAwB,aAAa;AAE7D,UAAM,kBAAkB,gBAAgB,YAAY,YAAY;AAC9D,YAAM,UAAU,YAAA;AAAA,IAClB,CAAC;AAED,UAAM,UAAU,qBAAA;AAChB,WAAO,KAAK,kDAAkD;AAAA,EAChE,SAAS,OAAO;AACd,UAAM,eAAe;AAAA,MACnB,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,MAC9D,OAAO,iBAAiB,QAAQ,MAAM,QAAQ;AAAA,MAC9C,MAAM,iBAAiB,QAAQ,MAAM,OAAO;AAAA,MAC5C,GAAI,SAAS,OAAO,UAAU,WAAW,QAAQ,CAAA;AAAA;AAAA,IAAC;AAEpD,WAAO,MAAM,0CAA0C;AAAA,MACrD,OAAO;AAAA,IAAA,CACR;AAED,UAAM;AAAA,EACR;AACF;AAKA,MAAM,kBAAkB,QAAQ,KAAK,CAAC,EAAE,QAAQ,OAAO,GAAG;AAC1D,MAAM,UAAU,gBAAgB,WAAW,GAAG,IAC5C,UAAU,eAAe;AAAA;AAAA,EACzB,WAAW,eAAe;AAAA;AAC5B,MAAM,eAAe,YAAY,QAAQ;AAEzC,IAAI,cAAc;AAEhB,OAAA,EAAO,MAAM,MAAM;AACjB,YAAQ,KAAK,CAAC;AAAA,EAChB,CAAC;AACH;"}
|
|
@@ -1 +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;AAQvB,QAAA,MAAM,IAAI,qBA6BT,CAAC;AAkBF,eAAe,IAAI,CAAC"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "../../../config-WKwu1mMo.js";
|
|
2
2
|
import { l as logger } from "../../../logger-hqtl8hFM.js";
|
|
3
|
-
import { c as createConnectorFromPath } from "../../../connector-factory-
|
|
3
|
+
import { c as createConnectorFromPath } from "../../../connector-factory-OMijBGQX.js";
|
|
4
|
+
logger.level = process.env.LOG_LEVEL || "info";
|
|
4
5
|
const main = async () => {
|
|
5
6
|
try {
|
|
6
7
|
logger.info('Worker for job "retry-failed-labor-tickets" online');
|
|
@@ -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// 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":";;;
|
|
1
|
+
{"version":3,"file":"retry-failed-labor-tickets.js","sources":["../../../../src/services/data-sync-service/jobs/retry-failed-labor-tickets.ts"],"sourcesContent":["import \"dotenv/config\";\n\nimport logger from \"../../../services/reporting-service/logger\";\nimport { createConnectorFromPath } from \"../../../utils/connector-factory\";\n\n// Configure the logger with the correct log level\nlogger.level = process.env.LOG_LEVEL || \"info\";\n\nconst main = async () => {\n try {\n logger.info('Worker for job \"retry-failed-labor-tickets\" online');\n logger.info(\n \"==========Starting retry-failed-labor-tickets job cycle==========\"\n );\n\n // Get the connector path from the environment variable\n const connectorPath = process.env.CONNECTOR_PATH;\n\n if (!connectorPath) {\n throw new Error(\"Connector path not provided in environment variables\");\n }\n\n // Create a new connector instance for this job\n const connector = await createConnectorFromPath(connectorPath);\n\n await connector.retryFailedLaborTickets();\n await connector.retryFailedLaborTicketsCompleted();\n\n logger.info(\n \"==========Completed retry-failed-labor-tickets job cycle==========\"\n );\n } catch (error) {\n logger.error('Worker for job \"retry-failed-labor-tickets\" had an error', {\n err: error,\n });\n throw error; // Rethrow so Bree can handle it properly\n }\n};\n\n// Cross-platform module detection fix for Bree compatibility\n// Windows: process.argv[1] uses backslashes, import.meta.url uses forward slashes\n// Linux/Mac: both use forward slashes, so this normalization is safe\nconst normalizedArgv1 = process.argv[1].replace(/\\\\/g, '/');\nconst fileUrl = normalizedArgv1.startsWith('/') ? \n `file://${normalizedArgv1}` : // Unix: file:// + /path = file:///path\n `file:///${normalizedArgv1}`; // Windows: file:/// + C:/path = file:///C:/path\nconst isMainModule = import.meta.url === fileUrl;\n\nif (isMainModule) {\n // This is called when Bree runs this file as a worker\n main().catch(() => {\n process.exit(1);\n });\n}\n\nexport default main;\n"],"names":[],"mappings":";;;AAMA,OAAO,QAAQ,QAAQ,IAAI,aAAa;AAExC,MAAM,OAAO,YAAY;AACvB,MAAI;AACF,WAAO,KAAK,oDAAoD;AAChE,WAAO;AAAA,MACL;AAAA,IAAA;AAIF,UAAM,gBAAgB,QAAQ,IAAI;AAElC,QAAI,CAAC,eAAe;AAClB,YAAM,IAAI,MAAM,sDAAsD;AAAA,IACxE;AAGA,UAAM,YAAY,MAAM,wBAAwB,aAAa;AAE7D,UAAM,UAAU,wBAAA;AAChB,UAAM,UAAU,iCAAA;AAEhB,WAAO;AAAA,MACL;AAAA,IAAA;AAAA,EAEJ,SAAS,OAAO;AACd,WAAO,MAAM,4DAA4D;AAAA,MACvE,KAAK;AAAA,IAAA,CACN;AACD,UAAM;AAAA,EACR;AACF;AAKA,MAAM,kBAAkB,QAAQ,KAAK,CAAC,EAAE,QAAQ,OAAO,GAAG;AAC1D,MAAM,UAAU,gBAAgB,WAAW,GAAG,IAC5C,UAAU,eAAe;AAAA;AAAA,EACzB,WAAW,eAAe;AAAA;AAC5B,MAAM,eAAe,YAAY,QAAQ;AAEzC,IAAI,cAAc;AAEhB,OAAA,EAAO,MAAM,MAAM;AACjB,YAAQ,KAAK,CAAC;AAAA,EAChB,CAAC;AACH;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-migrations.d.ts","sourceRoot":"","sources":["../../../../src/services/data-sync-service/jobs/run-migrations.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"run-migrations.d.ts","sourceRoot":"","sources":["../../../../src/services/data-sync-service/jobs/run-migrations.ts"],"names":[],"mappings":"AAUA,wBAA8B,aAAa,kBAW1C"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import knex from "knex";
|
|
2
2
|
import { l as logger } from "../../../logger-hqtl8hFM.js";
|
|
3
3
|
import { c as config } from "../../../knexfile-1qKKIORB.js";
|
|
4
|
+
logger.level = process.env.LOG_LEVEL || "info";
|
|
4
5
|
const db = knex(config.local);
|
|
5
6
|
async function runMigrations() {
|
|
6
7
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run-migrations.js","sources":["../../../../src/services/data-sync-service/jobs/run-migrations.ts"],"sourcesContent":["import knex, { Knex } from \"knex\";\nimport logger from \"../../reporting-service/logger\";\nimport config from \"../../../knexfile\";\n\n// MLW TODO Consider the location of knexfile\nconst db: Knex = knex(config.local);\n\nexport default async function runMigrations() {\n try {\n logger.info(\"Running migrations...\");\n await db.migrate.latest();\n logger.info(\"Migrations complete!\");\n } catch (error) {\n logger.error(\"Error running migrations:\", error);\n process.exit(1);\n } finally {\n await db.destroy();\n }\n}\n\nconst isMainModule = import.meta.url === `file://${process.argv[1]}`;\nif (isMainModule) {\n runMigrations().catch(err => {\n logger.error(\"Top-level error running migrations:\", err);\n process.exit(1);\n });\n}\n"],"names":[],"mappings":";;;AAKA,MAAM,KAAW,KAAK,OAAO,KAAK;AAElC,eAA8B,gBAAgB;AAC5C,MAAI;AACF,WAAO,KAAK,uBAAuB;AACnC,UAAM,GAAG,QAAQ,OAAA;AACjB,WAAO,KAAK,sBAAsB;AAAA,EACpC,SAAS,OAAO;AACd,WAAO,MAAM,6BAA6B,KAAK;AAC/C,YAAQ,KAAK,CAAC;AAAA,EAChB,UAAA;AACE,UAAM,GAAG,QAAA;AAAA,EACX;AACF;AAEA,MAAM,eAAe,YAAY,QAAQ,UAAU,QAAQ,KAAK,CAAC,CAAC;AAClE,IAAI,cAAc;AAChB,gBAAA,EAAgB,MAAM,CAAA,QAAO;AAC3B,WAAO,MAAM,uCAAuC,GAAG;AACvD,YAAQ,KAAK,CAAC;AAAA,EAChB,CAAC;AACH;"}
|
|
1
|
+
{"version":3,"file":"run-migrations.js","sources":["../../../../src/services/data-sync-service/jobs/run-migrations.ts"],"sourcesContent":["import knex, { Knex } from \"knex\";\nimport logger from \"../../reporting-service/logger\";\nimport config from \"../../../knexfile\";\n\n// Configure the logger with the correct log level\nlogger.level = process.env.LOG_LEVEL || \"info\";\n\n// MLW TODO Consider the location of knexfile\nconst db: Knex = knex(config.local);\n\nexport default async function runMigrations() {\n try {\n logger.info(\"Running migrations...\");\n await db.migrate.latest();\n logger.info(\"Migrations complete!\");\n } catch (error) {\n logger.error(\"Error running migrations:\", error);\n process.exit(1);\n } finally {\n await db.destroy();\n }\n}\n\nconst isMainModule = import.meta.url === `file://${process.argv[1]}`;\nif (isMainModule) {\n runMigrations().catch(err => {\n logger.error(\"Top-level error running migrations:\", err);\n process.exit(1);\n });\n}\n"],"names":[],"mappings":";;;AAKA,OAAO,QAAQ,QAAQ,IAAI,aAAa;AAGxC,MAAM,KAAW,KAAK,OAAO,KAAK;AAElC,eAA8B,gBAAgB;AAC5C,MAAI;AACF,WAAO,KAAK,uBAAuB;AACnC,UAAM,GAAG,QAAQ,OAAA;AACjB,WAAO,KAAK,sBAAsB;AAAA,EACpC,SAAS,OAAO;AACd,WAAO,MAAM,6BAA6B,KAAK;AAC/C,YAAQ,KAAK,CAAC;AAAA,EAChB,UAAA;AACE,UAAM,GAAG,QAAA;AAAA,EACX;AACF;AAEA,MAAM,eAAe,YAAY,QAAQ,UAAU,QAAQ,KAAK,CAAC,CAAC;AAClE,IAAI,cAAc;AAChB,gBAAA,EAAgB,MAAM,CAAA,QAAO;AAC3B,WAAO,MAAM,uCAAuC,GAAG;AACvD,YAAQ,KAAK,CAAC;AAAA,EAChB,CAAC;AACH;"}
|
|
@@ -1 +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;
|
|
1
|
+
{"version":3,"file":"to-erp.d.ts","sourceRoot":"","sources":["../../../../src/services/data-sync-service/jobs/to-erp.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAQvB,QAAA,MAAM,IAAI,qBAyCT,CAAC;AAkBF,eAAe,IAAI,CAAC"}
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import "../../../config-WKwu1mMo.js";
|
|
2
2
|
import { l as logger } from "../../../logger-hqtl8hFM.js";
|
|
3
|
-
import { c as createConnectorFromPath } from "../../../connector-factory-
|
|
3
|
+
import { c as createConnectorFromPath } from "../../../connector-factory-OMijBGQX.js";
|
|
4
|
+
logger.level = process.env.LOG_LEVEL || "info";
|
|
4
5
|
const main = async () => {
|
|
5
6
|
try {
|
|
6
7
|
logger.info('Worker for job "to-erp" online');
|
|
7
8
|
logger.info("==========Starting to-erp job cycle==========");
|
|
8
9
|
const connectorPath = process.env.CONNECTOR_PATH;
|
|
10
|
+
logger.debug(`to-erp job: Received CONNECTOR_PATH: ${connectorPath}`);
|
|
11
|
+
logger.debug(`to-erp job: CONNECTOR_PATH type: ${typeof connectorPath}`);
|
|
12
|
+
logger.debug(`to-erp job: CONNECTOR_PATH length: ${connectorPath?.length}`);
|
|
9
13
|
if (!connectorPath) {
|
|
10
14
|
throw new Error("Connector path not provided in environment variables");
|
|
11
15
|
}
|
|
@@ -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":";;;
|
|
1
|
+
{"version":3,"file":"to-erp.js","sources":["../../../../src/services/data-sync-service/jobs/to-erp.ts"],"sourcesContent":["import \"dotenv/config\";\n\nimport logger from \"../../reporting-service/logger\";\nimport { createConnectorFromPath } from \"../../../utils/connector-factory\";\n\n// Configure the logger with the correct log level\nlogger.level = process.env.LOG_LEVEL || \"info\";\n\nconst main = async () => {\n try {\n logger.info('Worker for job \"to-erp\" online');\n logger.info(\"==========Starting to-erp job cycle==========\");\n\n // Get the connector path from the environment variable\n const connectorPath = process.env.CONNECTOR_PATH;\n \n // Add debug logging\n logger.debug(`to-erp job: Received CONNECTOR_PATH: ${connectorPath}`);\n logger.debug(`to-erp job: CONNECTOR_PATH type: ${typeof connectorPath}`);\n logger.debug(`to-erp job: CONNECTOR_PATH length: ${connectorPath?.length}`);\n\n if (!connectorPath) {\n throw new Error(\"Connector path not provided in environment variables\");\n }\n\n // Create a new connector instance for this job\n const connector = await createConnectorFromPath(connectorPath);\n\n await connector.syncToERP();\n await connector.syncToERPCompleted();\n\n logger.info(\"==========Completed to-erp job cycle==========\");\n } catch (error) {\n const errorDetails = {\n message: error instanceof Error ? error.message : String(error),\n stack: error instanceof Error ? error.stack : undefined,\n name: error instanceof Error ? error.name : undefined,\n ...(error && typeof error === \"object\" ? error : {}), // Include all enumerable properties if it's an object\n };\n logger.error('Worker for job \"to-erp\" had an error', {\n error: errorDetails,\n connectorPath: process.env.CONNECTOR_PATH,\n });\n\n // Also log to console for immediate visibility\n console.error(\"to-erp job error:\", error);\n\n throw error; // Rethrow so Bree can handle it properly\n }\n};\n\n// Cross-platform module detection fix for Bree compatibility\n// Windows: process.argv[1] uses backslashes, import.meta.url uses forward slashes\n// Linux/Mac: both use forward slashes, so this normalization is safe\nconst normalizedArgv1 = process.argv[1].replace(/\\\\/g, '/');\nconst fileUrl = normalizedArgv1.startsWith('/') ? \n `file://${normalizedArgv1}` : // Unix: file:// + /path = file:///path\n `file:///${normalizedArgv1}`; // Windows: file:/// + C:/path = file:///C:/path\nconst isMainModule = import.meta.url === fileUrl;\n\nif (isMainModule) {\n // This is called when Bree runs this file as a worker\n main().catch(() => {\n process.exit(1);\n });\n}\n\nexport default main;\n"],"names":[],"mappings":";;;AAMA,OAAO,QAAQ,QAAQ,IAAI,aAAa;AAExC,MAAM,OAAO,YAAY;AACvB,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,
|
|
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.
|
|
4
|
+
"version": "0.1.4-beta.5",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "machinemetrics",
|
|
7
7
|
"main": "dist/mm-erp-sdk.js",
|
|
@@ -3,6 +3,9 @@ import { HashedCacheManager } from "../../caching-service/hashed-cache-manager";
|
|
|
3
3
|
import { SQLiteCoordinator } from "../../sqlite-service";
|
|
4
4
|
import logger from "../../../services/reporting-service/logger";
|
|
5
5
|
|
|
6
|
+
// Configure the logger with the correct log level
|
|
7
|
+
logger.level = process.env.LOG_LEVEL || "info";
|
|
8
|
+
|
|
6
9
|
const main = async () => {
|
|
7
10
|
const cacheManager = new HashedCacheManager();
|
|
8
11
|
try {
|
|
@@ -4,6 +4,9 @@ import logger from "../../../services/reporting-service/logger";
|
|
|
4
4
|
import { SQLiteCoordinator } from "../../sqlite-service";
|
|
5
5
|
import { createConnectorFromPath } from "../../../utils/connector-factory";
|
|
6
6
|
|
|
7
|
+
// Configure the logger with the correct log level
|
|
8
|
+
logger.level = process.env.LOG_LEVEL || "info";
|
|
9
|
+
|
|
7
10
|
const main = async () => {
|
|
8
11
|
try {
|
|
9
12
|
logger.info('Worker for job "from-erp" online');
|
|
@@ -11,7 +14,11 @@ const main = async () => {
|
|
|
11
14
|
|
|
12
15
|
// Get the connector path from the environment variable
|
|
13
16
|
const connectorPath = process.env.CONNECTOR_PATH;
|
|
14
|
-
|
|
17
|
+
|
|
18
|
+
// Add debug logging
|
|
19
|
+
logger.debug(`from-erp job: Received CONNECTOR_PATH: ${connectorPath}`);
|
|
20
|
+
logger.debug(`from-erp job: CONNECTOR_PATH type: ${typeof connectorPath}`);
|
|
21
|
+
logger.debug(`from-erp job: CONNECTOR_PATH length: ${connectorPath?.length}`);
|
|
15
22
|
|
|
16
23
|
if (!connectorPath) {
|
|
17
24
|
throw new Error("Connector path not provided in environment variables");
|
|
@@ -3,6 +3,9 @@ import "dotenv/config";
|
|
|
3
3
|
import logger from "../../../services/reporting-service/logger";
|
|
4
4
|
import { createConnectorFromPath } from "../../../utils/connector-factory";
|
|
5
5
|
|
|
6
|
+
// Configure the logger with the correct log level
|
|
7
|
+
logger.level = process.env.LOG_LEVEL || "info";
|
|
8
|
+
|
|
6
9
|
const main = async () => {
|
|
7
10
|
try {
|
|
8
11
|
logger.info('Worker for job "retry-failed-labor-tickets" online');
|
|
@@ -2,6 +2,9 @@ import knex, { Knex } from "knex";
|
|
|
2
2
|
import logger from "../../reporting-service/logger";
|
|
3
3
|
import config from "../../../knexfile";
|
|
4
4
|
|
|
5
|
+
// Configure the logger with the correct log level
|
|
6
|
+
logger.level = process.env.LOG_LEVEL || "info";
|
|
7
|
+
|
|
5
8
|
// MLW TODO Consider the location of knexfile
|
|
6
9
|
const db: Knex = knex(config.local);
|
|
7
10
|
|
|
@@ -3,6 +3,9 @@ import "dotenv/config";
|
|
|
3
3
|
import logger from "../../reporting-service/logger";
|
|
4
4
|
import { createConnectorFromPath } from "../../../utils/connector-factory";
|
|
5
5
|
|
|
6
|
+
// Configure the logger with the correct log level
|
|
7
|
+
logger.level = process.env.LOG_LEVEL || "info";
|
|
8
|
+
|
|
6
9
|
const main = async () => {
|
|
7
10
|
try {
|
|
8
11
|
logger.info('Worker for job "to-erp" online');
|
|
@@ -10,6 +13,11 @@ const main = async () => {
|
|
|
10
13
|
|
|
11
14
|
// Get the connector path from the environment variable
|
|
12
15
|
const connectorPath = process.env.CONNECTOR_PATH;
|
|
16
|
+
|
|
17
|
+
// Add debug logging
|
|
18
|
+
logger.debug(`to-erp job: Received CONNECTOR_PATH: ${connectorPath}`);
|
|
19
|
+
logger.debug(`to-erp job: CONNECTOR_PATH type: ${typeof connectorPath}`);
|
|
20
|
+
logger.debug(`to-erp job: CONNECTOR_PATH length: ${connectorPath?.length}`);
|
|
13
21
|
|
|
14
22
|
if (!connectorPath) {
|
|
15
23
|
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;"}
|