@machinemetrics/mm-erp-sdk 0.1.4-beta.6 → 0.1.5-beta.0

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 (75) hide show
  1. package/dist/{config-WKwu1mMo.js → config-2l5vnNkA.js} +6 -6
  2. package/dist/{config-WKwu1mMo.js.map → config-2l5vnNkA.js.map} +1 -1
  3. package/dist/connector-factory-CQ8e7Tae.js +21 -0
  4. package/dist/connector-factory-CQ8e7Tae.js.map +1 -0
  5. package/dist/{hashed-cache-manager-CtDhFqj6.js → hashed-cache-manager-Ci59eC75.js} +4 -5
  6. package/dist/{hashed-cache-manager-CtDhFqj6.js.map → hashed-cache-manager-Ci59eC75.js.map} +1 -1
  7. package/dist/{index-aci_wdcn.js → index-CXbOvFyf.js} +7 -7
  8. package/dist/{index-aci_wdcn.js.map → index-CXbOvFyf.js.map} +1 -1
  9. package/dist/index.d.ts +6 -14
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/{logger-hqtl8hFM.js → logger-QG73MndU.js} +6 -6
  12. package/dist/{logger-hqtl8hFM.js.map → logger-QG73MndU.js.map} +1 -1
  13. package/dist/mm-erp-sdk.js +8 -396
  14. package/dist/mm-erp-sdk.js.map +1 -1
  15. package/dist/services/data-sync-service/index.d.ts +1 -1
  16. package/dist/services/data-sync-service/index.d.ts.map +1 -1
  17. package/dist/services/data-sync-service/jobs/clean-up-expired-cache.d.ts +0 -2
  18. package/dist/services/data-sync-service/jobs/clean-up-expired-cache.d.ts.map +1 -1
  19. package/dist/services/data-sync-service/jobs/clean-up-expired-cache.js +42 -41
  20. package/dist/services/data-sync-service/jobs/clean-up-expired-cache.js.map +1 -1
  21. package/dist/services/data-sync-service/jobs/from-erp.d.ts.map +1 -1
  22. package/dist/services/data-sync-service/jobs/from-erp.js +10 -17
  23. package/dist/services/data-sync-service/jobs/from-erp.js.map +1 -1
  24. package/dist/services/data-sync-service/jobs/retry-failed-labor-tickets.d.ts +0 -2
  25. package/dist/services/data-sync-service/jobs/retry-failed-labor-tickets.d.ts.map +1 -1
  26. package/dist/services/data-sync-service/jobs/retry-failed-labor-tickets.js +40 -39
  27. package/dist/services/data-sync-service/jobs/retry-failed-labor-tickets.js.map +1 -1
  28. package/dist/services/data-sync-service/jobs/run-migrations.d.ts.map +1 -1
  29. package/dist/services/data-sync-service/jobs/run-migrations.js +1 -2
  30. package/dist/services/data-sync-service/jobs/run-migrations.js.map +1 -1
  31. package/dist/services/data-sync-service/jobs/to-erp.d.ts.map +1 -1
  32. package/dist/services/data-sync-service/jobs/to-erp.js +5 -16
  33. package/dist/services/data-sync-service/jobs/to-erp.js.map +1 -1
  34. package/dist/services/erp-api-services/index.d.ts +1 -5
  35. package/dist/services/erp-api-services/index.d.ts.map +1 -1
  36. package/dist/services/mm-api-service/index.d.ts +2 -3
  37. package/dist/services/mm-api-service/index.d.ts.map +1 -1
  38. package/dist/services/mm-api-service/mm-api-service.d.ts +0 -20
  39. package/dist/services/mm-api-service/mm-api-service.d.ts.map +1 -1
  40. package/dist/types/erp-types.d.ts +2 -1
  41. package/dist/types/erp-types.d.ts.map +1 -1
  42. package/dist/utils/connector-factory.d.ts.map +1 -1
  43. package/dist/utils/index.d.ts +1 -10
  44. package/dist/utils/index.d.ts.map +1 -1
  45. package/dist/utils/standard-process-drivers/index.d.ts +1 -2
  46. package/dist/utils/standard-process-drivers/index.d.ts.map +1 -1
  47. package/package.json +1 -1
  48. package/src/index.ts +5 -19
  49. package/src/services/data-sync-service/index.ts +4 -1
  50. package/src/services/data-sync-service/jobs/clean-up-expired-cache.ts +8 -18
  51. package/src/services/data-sync-service/jobs/from-erp.ts +9 -19
  52. package/src/services/data-sync-service/jobs/retry-failed-labor-tickets.ts +6 -16
  53. package/src/services/data-sync-service/jobs/run-migrations.ts +0 -3
  54. package/src/services/data-sync-service/jobs/to-erp.ts +5 -20
  55. package/src/services/erp-api-services/index.ts +1 -9
  56. package/src/services/mm-api-service/index.ts +1 -1
  57. package/src/services/mm-api-service/mm-api-service.ts +0 -28
  58. package/src/types/erp-types.ts +1 -0
  59. package/src/utils/connector-factory.ts +2 -17
  60. package/src/utils/index.ts +4 -11
  61. package/src/utils/standard-process-drivers/index.ts +4 -2
  62. package/dist/connector-factory-13bvmpQB.js +0 -30
  63. package/dist/connector-factory-13bvmpQB.js.map +0 -1
  64. package/dist/utils/connector-log/log-deduper.d.ts +0 -56
  65. package/dist/utils/connector-log/log-deduper.d.ts.map +0 -1
  66. package/dist/utils/connector-log/mm-connector-logger-example.d.ts +0 -1
  67. package/dist/utils/connector-log/mm-connector-logger-example.d.ts.map +0 -1
  68. package/dist/utils/connector-log/mm-connector-logger.d.ts +0 -74
  69. package/dist/utils/connector-log/mm-connector-logger.d.ts.map +0 -1
  70. package/dist/utils/error-utils.d.ts +0 -2
  71. package/dist/utils/error-utils.d.ts.map +0 -1
  72. package/src/utils/connector-log/log-deduper.ts +0 -282
  73. package/src/utils/connector-log/mm-connector-logger-example.ts +0 -97
  74. package/src/utils/connector-log/mm-connector-logger.ts +0 -177
  75. package/src/utils/error-utils.ts +0 -18
package/src/index.ts CHANGED
@@ -9,15 +9,15 @@ export { ERPType, ERPObjType } from "./types/erp-types";
9
9
  export type { ERPPagination, ERPResponse, ERPObject } from "./types/erp-types";
10
10
 
11
11
  // Configuration interfaces
12
- export { ErpApiConnectionParams } from "./services/data-sync-service/configuration-manager";
12
+ export type { ErpApiConnectionParams } from "./services/data-sync-service/configuration-manager";
13
13
  export { getErpApiConnectionParams } from "./services/data-sync-service/configuration-manager";
14
14
  export { buildLogicalCondition } from "./services/erp-api-services/rest/get-query-params";
15
15
  export type { ERPApiConfig } from "./services/erp-api-services/types";
16
16
 
17
17
  // MM API client and types
18
18
  export { MMApiClient } from "./services/mm-api-service";
19
- export { MMReceiveLaborTicket } from "./services/mm-api-service";
20
19
  export type {
20
+ MMReceiveLaborTicket,
21
21
  MMReceiveLaborTicketReason,
22
22
  MMReceiveLaborTicketWorkOrderOperation,
23
23
  IToRESTApiObject,
@@ -48,7 +48,6 @@ export {
48
48
  formatDateWithTZOffset,
49
49
  applyTimezoneOffsetsToFields,
50
50
  convertToLocalTime,
51
- getErrorType,
52
51
  } from "./utils";
53
52
 
54
53
  // Local data store
@@ -56,8 +55,7 @@ export { getInitialLoadComplete, setInitialLoadComplete } from "./utils";
56
55
 
57
56
  // HTTP client factory and types for custom API integrations
58
57
  export { HTTPClientFactory } from "./utils/http-client";
59
- export { HTTPError } from "./utils/http-client";
60
- export type { HTTPResponse, HTTPClient, HTTPRequestConfig } from "./utils/http-client";
58
+ export type { HTTPResponse } from "./utils/http-client";
61
59
 
62
60
  // Application initialization utilities
63
61
  export { ApplicationInitializer } from "./utils/application-initializer";
@@ -73,13 +71,11 @@ export type { IERPLaborTicketHandler } from "./types/erp-connector";
73
71
 
74
72
  // Process drivers and utilities
75
73
  export { StandardProcessDrivers, getCachedTimezoneOffset } from "./utils";
76
- export type { WriteEntitiesToMMResult } from "./utils";
77
- export { MMBatchValidationError } from "./utils";
74
+ export type { WriteEntitiesToMMResult, MMBatchValidationError } from "./utils";
78
75
 
79
76
  // API services
80
- export type { APIResponse } from './services/erp-api-services/types';
81
77
  export { RestAPIService } from "./services/erp-api-services/rest/rest-api-service";
82
- export { ErrorHandler, GraphQLError } from "./services/erp-api-services/errors";
78
+ export { ErrorHandler } from "./services/erp-api-services/errors";
83
79
  export type {
84
80
  QueryParams,
85
81
  PaginatedAPIResponse,
@@ -104,13 +100,3 @@ export {
104
100
  SqlServerHelper,
105
101
  } from "./services/sql-server-erp-service";
106
102
  export type { SQLInput } from "./services/sql-server-erp-service";
107
-
108
- // Record tracking services
109
- export { RecordTrackingManager } from "./services/caching-service/record-tracking-manager";
110
- export type { RecordTrackingObject } from "./services/caching-service/record-tracking-manager";
111
-
112
- // Knex services
113
- export { default as knexDatabaseConfig } from "./knexfile";
114
-
115
- // MM Connector Logging
116
- export { MMConnectorLogger, FileLogDeduper, LogEntry, type LogLevelString, type LogResponse } from './utils';
@@ -8,4 +8,7 @@ export { runDataSyncService } from "./data-sync-service";
8
8
  */
9
9
  export { getSQLServerConfiguration } from "./configuration-manager";
10
10
 
11
- export { ErpApiConnectionParams, getErpApiConnectionParams } from "./configuration-manager";
11
+ export {
12
+ ErpApiConnectionParams,
13
+ getErpApiConnectionParams,
14
+ } from "./configuration-manager";
@@ -3,9 +3,6 @@ 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
-
9
6
  const main = async () => {
10
7
  const cacheManager = new HashedCacheManager();
11
8
  try {
@@ -32,20 +29,13 @@ const main = async () => {
32
29
  }
33
30
  };
34
31
 
35
- // Cross-platform module detection fix for Bree compatibility
36
- // Windows: process.argv[1] uses backslashes, import.meta.url uses forward slashes
37
- // Linux/Mac: both use forward slashes, so this normalization is safe
38
- const normalizedArgv1 = process.argv[1].replace(/\\/g, '/');
39
- const fileUrl = normalizedArgv1.startsWith('/') ?
40
- `file://${normalizedArgv1}` : // Unix: file:// + /path = file:///path
41
- `file:///${normalizedArgv1}`; // Windows: file:/// + C:/path = file:///C:/path
42
- const isMainModule = import.meta.url === fileUrl;
43
-
44
- if (isMainModule) {
32
+ // For Bree compatibility - check if this is running as a worker
33
+ if (require.main === module) {
45
34
  // This is called when Bree runs this file as a worker
46
- main().catch(() => {
47
- process.exit(1);
48
- });
35
+ (async () => {
36
+ await main();
37
+ })();
38
+ } else {
39
+ // Export for potential testing or direct usage
40
+ module.exports = main;
49
41
  }
50
-
51
- export default main;
@@ -4,9 +4,6 @@ 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
-
10
7
  const main = async () => {
11
8
  try {
12
9
  logger.info('Worker for job "from-erp" online');
@@ -14,11 +11,7 @@ const main = async () => {
14
11
 
15
12
  // Get the connector path from the environment variable
16
13
  const connectorPath = process.env.CONNECTOR_PATH;
17
-
18
- // Add debug logging
19
- logger.debug(`from-erp job: Received CONNECTOR_PATH: ${connectorPath}`);
20
- logger.debug(`from-erp job: CONNECTOR_PATH type: ${typeof connectorPath}`);
21
- logger.debug(`from-erp job: CONNECTOR_PATH length: ${connectorPath?.length}`);
14
+
22
15
 
23
16
  if (!connectorPath) {
24
17
  throw new Error("Connector path not provided in environment variables");
@@ -48,20 +41,17 @@ const main = async () => {
48
41
  }
49
42
  };
50
43
 
51
- // Cross-platform module detection fix for Bree compatibility
52
- // Windows: process.argv[1] uses backslashes, import.meta.url uses forward slashes
53
- // Linux/Mac: both use forward slashes, so this normalization is safe
54
- const normalizedArgv1 = process.argv[1].replace(/\\/g, '/');
55
- const fileUrl = normalizedArgv1.startsWith('/') ?
56
- `file://${normalizedArgv1}` : // Unix: file:// + /path = file:///path
57
- `file:///${normalizedArgv1}`; // Windows: file:/// + C:/path = file:///C:/path
58
- const isMainModule = import.meta.url === fileUrl;
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]}`;
59
47
 
60
48
  if (isMainModule) {
61
49
  // This is called when Bree runs this file as a worker
62
- main().catch(() => {
63
- process.exit(1);
64
- });
50
+ try {
51
+ await main();
52
+ } catch {
53
+ process.exitCode = 1; // prefer exitCode so stdout/stderr can flush
54
+ }
65
55
  }
66
56
 
67
57
  export default main;
@@ -3,9 +3,6 @@ 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
-
9
6
  const main = async () => {
10
7
  try {
11
8
  logger.info('Worker for job "retry-failed-labor-tickets" online');
@@ -37,20 +34,13 @@ const main = async () => {
37
34
  }
38
35
  };
39
36
 
40
- // Cross-platform module detection fix for Bree compatibility
41
- // Windows: process.argv[1] uses backslashes, import.meta.url uses forward slashes
42
- // Linux/Mac: both use forward slashes, so this normalization is safe
43
- const normalizedArgv1 = process.argv[1].replace(/\\/g, '/');
44
- const fileUrl = normalizedArgv1.startsWith('/') ?
45
- `file://${normalizedArgv1}` : // Unix: file:// + /path = file:///path
46
- `file:///${normalizedArgv1}`; // Windows: file:/// + C:/path = file:///C:/path
47
- const isMainModule = import.meta.url === fileUrl;
48
-
49
- if (isMainModule) {
37
+ // For Bree compatibility - check if this is running as a worker
38
+ if (require.main === module) {
50
39
  // This is called when Bree runs this file as a worker
51
40
  main().catch(() => {
52
- process.exit(1);
41
+ process.exitCode = 1;
53
42
  });
43
+ } else {
44
+ // Export for potential testing or direct usage
45
+ module.exports = main;
54
46
  }
55
-
56
- export default main;
@@ -2,9 +2,6 @@ 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
-
8
5
  // MLW TODO Consider the location of knexfile
9
6
  const db: Knex = knex(config.local);
10
7
 
@@ -3,9 +3,6 @@ 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
-
9
6
  const main = async () => {
10
7
  try {
11
8
  logger.info('Worker for job "to-erp" online');
@@ -13,11 +10,6 @@ const main = async () => {
13
10
 
14
11
  // Get the connector path from the environment variable
15
12
  const connectorPath = process.env.CONNECTOR_PATH;
16
-
17
- // Add debug logging
18
- logger.debug(`to-erp job: Received CONNECTOR_PATH: ${connectorPath}`);
19
- logger.debug(`to-erp job: CONNECTOR_PATH type: ${typeof connectorPath}`);
20
- logger.debug(`to-erp job: CONNECTOR_PATH length: ${connectorPath?.length}`);
21
13
 
22
14
  if (!connectorPath) {
23
15
  throw new Error("Connector path not provided in environment variables");
@@ -49,20 +41,13 @@ const main = async () => {
49
41
  }
50
42
  };
51
43
 
52
- // Cross-platform module detection fix for Bree compatibility
53
- // Windows: process.argv[1] uses backslashes, import.meta.url uses forward slashes
54
- // Linux/Mac: both use forward slashes, so this normalization is safe
55
- const normalizedArgv1 = process.argv[1].replace(/\\/g, '/');
56
- const fileUrl = normalizedArgv1.startsWith('/') ?
57
- `file://${normalizedArgv1}` : // Unix: file:// + /path = file:///path
58
- `file:///${normalizedArgv1}`; // Windows: file:/// + C:/path = file:///C:/path
59
- const isMainModule = import.meta.url === fileUrl;
60
-
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]}`;
61
47
  if (isMainModule) {
62
48
  // This is called when Bree runs this file as a worker
63
- main().catch(() => {
64
- process.exit(1);
65
- });
49
+ main();
66
50
  }
67
51
 
52
+ // Export for potential testing or direct usage (ES module default export)
68
53
  export default main;
@@ -9,14 +9,6 @@ export type { QueryParams } from "./rest/get-query-params";
9
9
 
10
10
  // GraphQL Service
11
11
  export { GraphQLService } from "./graphql/graphql-service";
12
- export type { GraphQLServerError } from './graphql/types';
13
12
 
14
13
  // OAuth Client
15
- export { OAuthClient } from './oauth-client';
16
- export type { OAuthConfig } from './oauth-client';
17
-
18
- // API Response
19
- export type { APIResponse } from './types';
20
-
21
- // Error classes
22
- export { ErrorHandler, GraphQLError } from './errors';
14
+ export { OAuthClient } from "./oauth-client";
@@ -52,8 +52,8 @@ export type {
52
52
  /**
53
53
  * Types related of labor tickets received from the MM API
54
54
  */
55
- export { MMReceiveLaborTicket } from "./types/receive-types";
56
55
  export type {
56
+ MMReceiveLaborTicket,
57
57
  MMReceiveLaborTicketReason,
58
58
  MMReceiveLaborTicketWorkOrderOperation,
59
59
  };
@@ -646,34 +646,6 @@ export class MMApiClient {
646
646
  );
647
647
  }
648
648
 
649
- /**
650
- * Send connector logs to the MM API
651
- * @param logEntry Single log entry to send
652
- * @returns Promise with the API response
653
- */
654
- async sendConnectorLog(logEntry: { source: string; level: string; message: string }): Promise<MMApiBaseResponse> {
655
- return await this.postData(
656
- '/connector/logs',
657
- logEntry,
658
- {},
659
- { baseUrl: UrlBase.ApiBase }
660
- );
661
- }
662
-
663
- /**
664
- * Send bulk connector logs to the MM API
665
- * @param logs Array of log entries to send
666
- * @returns Promise with the API response
667
- */
668
- async sendBulkConnectorLogs(logs: { source: string; level: string; message: string }[]): Promise<MMApiBaseResponse> {
669
- return await this.postData(
670
- '/connector/logs',
671
- { logs },
672
- {},
673
- { baseUrl: UrlBase.ApiBase }
674
- );
675
- }
676
-
677
649
  async deleteFailedLaborTicketIds(
678
650
  system: ERPType,
679
651
  laborTicketRefs: string[]
@@ -7,6 +7,7 @@ export enum ERPType {
7
7
  PROSHOP = "PROSHOP",
8
8
  SYTELINE = "SYTELINE",
9
9
  TEMPLATE = "TEMPLATE",
10
+ GLOBALSHOP = "GLOBALSHOP",
10
11
  }
11
12
 
12
13
  export enum ERPObjType {
@@ -1,6 +1,5 @@
1
1
  import { IERPConnector } from "../types/erp-connector";
2
2
  import logger from "../services/reporting-service/logger";
3
- import { pathToFileURL } from "url";
4
3
 
5
4
  /**
6
5
  * Helper function to dynamically import and create connector instance from a file path
@@ -11,22 +10,8 @@ export const createConnectorFromPath = async (
11
10
  connectorPath: string
12
11
  ): Promise<IERPConnector> => {
13
12
  try {
14
- // Add detailed debug logging
15
- logger.debug(`createConnectorFromPath: Received connector path: ${connectorPath}`);
16
- logger.debug(`createConnectorFromPath: Path type: ${typeof connectorPath}`);
17
- logger.debug(`createConnectorFromPath: Path length: ${connectorPath.length}`);
18
-
19
- // Log the path components
20
- const pathParts = connectorPath.split('/');
21
- logger.debug(`createConnectorFromPath: Path parts: ${JSON.stringify(pathParts)}`);
22
-
23
- // Log the filename specifically
24
- const filename = pathParts[pathParts.length - 1];
25
- logger.debug(`createConnectorFromPath: Filename: ${filename}`);
26
-
27
13
  // Dynamic import the connector module
28
- logger.debug(`createConnectorFromPath: Attempting to import: ${pathToFileURL(connectorPath).href}`);
29
- const connectorModule = await import(pathToFileURL(connectorPath).href);
14
+ const connectorModule = await import(connectorPath);
30
15
 
31
16
  // Get the default export or named export
32
17
  const ConnectorClass =
@@ -46,4 +31,4 @@ export const createConnectorFromPath = async (
46
31
  );
47
32
  throw error;
48
33
  }
49
- };
34
+ };
@@ -31,8 +31,10 @@ export { BatchCacheManager } from "../services/caching-service/batch-cache-manag
31
31
  * Process and data transformation utilities
32
32
  */
33
33
  export { StandardProcessDrivers } from "./standard-process-drivers/";
34
- export type { WriteEntitiesToMMResult } from "./standard-process-drivers/";
35
- export { MMBatchValidationError } from "./standard-process-drivers/";
34
+ export type {
35
+ WriteEntitiesToMMResult,
36
+ MMBatchValidationError,
37
+ } from "./standard-process-drivers/";
36
38
  export { getCachedTimezoneOffset } from "./local-data-store/jobs-shared-data";
37
39
 
38
40
  // Local data store
@@ -52,20 +54,11 @@ export { getERPAPITypeFromEntity } from "./erp-type-from-entity";
52
54
  * HTTP Client utilities
53
55
  */
54
56
  export { HTTPClientFactory } from "./http-client";
55
- export { HTTPError } from "./http-client";
56
- export type { HTTPClient, HTTPRequestConfig, HTTPResponse } from "./http-client";
57
57
 
58
58
  /**
59
59
  * MM Labor Ticket utilities
60
60
  */
61
61
  export * from "./mm-labor-ticket-helpers";
62
- export { getErrorType } from './error-utils';
63
-
64
- /**
65
- * MM Connector Logger utilities
66
- */
67
- export { MMConnectorLogger, LogEntry, type LogResponse, type LogLevelString } from './connector-log/mm-connector-logger';
68
- export { FileLogDeduper } from './connector-log/log-deduper';
69
62
 
70
63
  /**
71
64
  * Application initializer
@@ -1,4 +1,6 @@
1
1
  // Public exports for standard-process-drivers
2
2
  export { StandardProcessDrivers } from "./standard-process-drivers";
3
- export type { WriteEntitiesToMMResult } from "./standard-process-drivers";
4
- export { MMBatchValidationError } from "./standard-process-drivers";
3
+ export type {
4
+ WriteEntitiesToMMResult,
5
+ MMBatchValidationError,
6
+ } from "./standard-process-drivers";
@@ -1,30 +0,0 @@
1
- import { l as logger } from "./logger-hqtl8hFM.js";
2
- import { pathToFileURL } from "url";
3
- const createConnectorFromPath = async (connectorPath) => {
4
- try {
5
- logger.debug(`createConnectorFromPath: Received connector path: ${connectorPath}`);
6
- logger.debug(`createConnectorFromPath: Path type: ${typeof connectorPath}`);
7
- logger.debug(`createConnectorFromPath: Path length: ${connectorPath.length}`);
8
- const pathParts = connectorPath.split("/");
9
- logger.debug(`createConnectorFromPath: Path parts: ${JSON.stringify(pathParts)}`);
10
- const filename = pathParts[pathParts.length - 1];
11
- logger.debug(`createConnectorFromPath: Filename: ${filename}`);
12
- logger.debug(`createConnectorFromPath: Attempting to import: ${pathToFileURL(connectorPath).href}`);
13
- const connectorModule = await import(pathToFileURL(connectorPath).href);
14
- const ConnectorClass = connectorModule.default || connectorModule[Object.keys(connectorModule)[0]];
15
- if (!ConnectorClass) {
16
- throw new Error(`No connector class found in module: ${connectorPath}`);
17
- }
18
- return new ConnectorClass();
19
- } catch (error) {
20
- logger.error(
21
- `Failed to create connector instance from path: ${connectorPath}`,
22
- { error }
23
- );
24
- throw error;
25
- }
26
- };
27
- export {
28
- createConnectorFromPath as c
29
- };
30
- //# sourceMappingURL=connector-factory-13bvmpQB.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"connector-factory-13bvmpQB.js","sources":["../src/utils/connector-factory.ts"],"sourcesContent":["import { IERPConnector } from \"../types/erp-connector\";\nimport logger from \"../services/reporting-service/logger\";\nimport { pathToFileURL } from \"url\";\n\n/**\n * Helper function to dynamically import and create connector instance from a file path\n * @param connectorPath - The file path to the connector module\n * @returns A new instance of the IERPConnector\n */\nexport const createConnectorFromPath = async (\n connectorPath: string\n): Promise<IERPConnector> => {\n try {\n // Add detailed debug logging\n logger.debug(`createConnectorFromPath: Received connector path: ${connectorPath}`);\n logger.debug(`createConnectorFromPath: Path type: ${typeof connectorPath}`);\n logger.debug(`createConnectorFromPath: Path length: ${connectorPath.length}`);\n \n // Log the path components\n const pathParts = connectorPath.split('/');\n logger.debug(`createConnectorFromPath: Path parts: ${JSON.stringify(pathParts)}`);\n \n // Log the filename specifically\n const filename = pathParts[pathParts.length - 1];\n logger.debug(`createConnectorFromPath: Filename: ${filename}`);\n \n // Dynamic import the connector module\n logger.debug(`createConnectorFromPath: Attempting to import: ${pathToFileURL(connectorPath).href}`);\n const connectorModule = await import(pathToFileURL(connectorPath).href);\n\n // Get the default export or named export\n const ConnectorClass =\n connectorModule.default ||\n connectorModule[Object.keys(connectorModule)[0]];\n\n if (!ConnectorClass) {\n throw new Error(`No connector class found in module: ${connectorPath}`);\n }\n\n // Create new instance of the connector\n return new ConnectorClass();\n } catch (error) {\n logger.error(\n `Failed to create connector instance from path: ${connectorPath}`,\n { error }\n );\n throw error;\n }\n};"],"names":[],"mappings":";;AASO,MAAM,0BAA0B,OACrC,kBAC2B;AAC3B,MAAI;AAEF,WAAO,MAAM,qDAAqD,aAAa,EAAE;AACjF,WAAO,MAAM,uCAAuC,OAAO,aAAa,EAAE;AAC1E,WAAO,MAAM,yCAAyC,cAAc,MAAM,EAAE;AAG5E,UAAM,YAAY,cAAc,MAAM,GAAG;AACzC,WAAO,MAAM,wCAAwC,KAAK,UAAU,SAAS,CAAC,EAAE;AAGhF,UAAM,WAAW,UAAU,UAAU,SAAS,CAAC;AAC/C,WAAO,MAAM,sCAAsC,QAAQ,EAAE;AAG7D,WAAO,MAAM,kDAAkD,cAAc,aAAa,EAAE,IAAI,EAAE;AAClG,UAAM,kBAAkB,MAAM,OAAO,cAAc,aAAa,EAAE;AAGlE,UAAM,iBACJ,gBAAgB,WAChB,gBAAgB,OAAO,KAAK,eAAe,EAAE,CAAC,CAAC;AAEjD,QAAI,CAAC,gBAAgB;AACnB,YAAM,IAAI,MAAM,uCAAuC,aAAa,EAAE;AAAA,IACxE;AAGA,WAAO,IAAI,eAAA;AAAA,EACb,SAAS,OAAO;AACd,WAAO;AAAA,MACL,kDAAkD,aAAa;AAAA,MAC/D,EAAE,MAAA;AAAA,IAAM;AAEV,UAAM;AAAA,EACR;AACF;"}
@@ -1,56 +0,0 @@
1
- import type { LogEntry } from './mm-connector-logger';
2
- /**
3
- * Implement a custom LogDeduper or use the provided FileLogDeduper
4
- */
5
- export interface LogDeduper {
6
- decide(entry: LogEntry, now: number): Promise<string | null>;
7
- onSuccess(entry: LogEntry, now: number): Promise<void>;
8
- retryFailedTransmissions?(send: (entry: LogEntry, message: string) => Promise<void>): Promise<void>;
9
- }
10
- /**
11
- * FileLogDeduper implements the LogDeduper interface to deduplicate
12
- * logs by storing them in a file; this allows deduping across jobs.
13
- */
14
- export declare class FileLogDeduper implements LogDeduper {
15
- private readonly storeFilePath;
16
- private readonly windowMs;
17
- private readonly ttlMs;
18
- private readonly sweepIntervalMs;
19
- private lastSweepTsMs;
20
- private readonly DEFAULT_WINDOW_TEN_MINS;
21
- private readonly DEFAULT_TTL_ONE_HOUR;
22
- private readonly DEFAULT_SWEEP_INTERVAL_FIVE_MINS;
23
- private readonly DEFAULT_STORE_FILE_PATH;
24
- /**
25
- * Ctor.
26
- * @param storeFilePath: The path to the file where the deduplication store is stored; recommended is to use the default
27
- * @param windowSeconds: Suppression window. Duplicates within this period are suppressed.
28
- * @param ttlSeconds: Eviction TTL. Store entries for keys inactive beyond this are removed. Enforced to be ≥ windowSeconds.
29
- * @param sweepIntervalSeconds: Efficiency parameter. How often (min interval) to run opportunistic eviction; retry always sweeps
30
- * The sweep is lazy, used only when the store is accessed
31
- */
32
- constructor({ storeFilePath, windowSeconds, ttlSeconds, sweepIntervalSeconds }?: {
33
- storeFilePath?: string;
34
- windowSeconds?: number;
35
- ttlSeconds?: number;
36
- sweepIntervalSeconds?: number;
37
- });
38
- /**
39
- * Deduplication gating function
40
- * Returns the formatted message to send, or null to suppress
41
- * Decision is based on the dedupeKey and the time of the entry
42
- */
43
- decide(entry: LogEntry, now: number): Promise<string | null>;
44
- onSuccess(entry: LogEntry, now: number): Promise<void>;
45
- retryFailedTransmissions(send: (entry: LogEntry, message: string) => Promise<void>): Promise<void>;
46
- private ensureStoreFileExists;
47
- private readStore;
48
- private writeStore;
49
- private formatMessage;
50
- private withLock;
51
- /**
52
- * Evict expired entries from the store based on the TTL and the key's last transmitted time
53
- */
54
- private evictExpiredInStore;
55
- }
56
- //# sourceMappingURL=log-deduper.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"log-deduper.d.ts","sourceRoot":"","sources":["../../../src/utils/connector-log/log-deduper.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,QAAQ,EAAkB,MAAM,uBAAuB,CAAC;AAEtE;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC7D,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IACvD,wBAAwB,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CACrG;AAkBD;;;GAGG;AACH,qBAAa,cAAe,YAAW,UAAU;IAC/C,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAS;IACvC,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;IAClC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAS;IAC/B,OAAO,CAAC,QAAQ,CAAC,eAAe,CAAS;IACzC,OAAO,CAAC,aAAa,CAAS;IAE9B,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAAO;IAC/C,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAQ;IAC7C,OAAO,CAAC,QAAQ,CAAC,gCAAgC,CAAO;IACxD,OAAO,CAAC,QAAQ,CAAC,uBAAuB,CAA+C;IAEvF;;;;;;;OAOG;gBACS,EACV,aAA4C,EAC5C,aAA4C,EAC5C,UAAsC,EACtC,oBAA4D,EAC7D,GAAG;QACF,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,oBAAoB,CAAC,EAAE,MAAM,CAAC;KAC1B;IAWN;;;;MAIE;IACI,MAAM,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IA4D5D,SAAS,CAAC,KAAK,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAqBtD,wBAAwB,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAyCxG,OAAO,CAAC,qBAAqB;IAU7B,OAAO,CAAC,SAAS;IAUjB,OAAO,CAAC,UAAU;IAQlB,OAAO,CAAC,aAAa;YAUP,QAAQ;IA2BtB;;OAEG;IACH,OAAO,CAAC,mBAAmB;CAW5B"}
@@ -1 +0,0 @@
1
- //# sourceMappingURL=mm-connector-logger-example.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mm-connector-logger-example.d.ts","sourceRoot":"","sources":["../../../src/utils/connector-log/mm-connector-logger-example.ts"],"names":[],"mappings":""}
@@ -1,74 +0,0 @@
1
- import type { LogDeduper } from './log-deduper';
2
- export type LogLevelString = 'info' | 'warn' | 'error';
3
- /**
4
- * dedupeKey - key used to deduplicate log entries when a LogDeduper is injected into the MMConnectorLogger
5
- *
6
- * A recommended practice is to use a meaningful unique identifier for this log entry type.
7
- * Examples: SyncFromERPCompleted
8
- * SyncFromERPError:HTTPError
9
- */
10
- export declare class LogEntry {
11
- level: LogLevelString;
12
- message: string;
13
- dedupeKey: string;
14
- eventTime: number;
15
- constructor(params: {
16
- level: LogLevelString;
17
- message: string;
18
- dedupeKey: string;
19
- });
20
- }
21
- /**
22
- * The response from the MM connector logging API
23
- */
24
- export interface LogResponse {
25
- message: string;
26
- processed?: number;
27
- }
28
- /**
29
- * MM Connector Logger for sending progress and error updates to the MM cloud
30
- *
31
- * This class provides helper methods to send individual logs to the
32
- * MM connector logging API, providing support for validation, retries, and error handling
33
- * according to the API specification.
34
- *
35
- * By injecting a LogDeduper, the log entries are deduplicated across jobs over a specified time window
36
- */
37
- export declare class MMConnectorLogger {
38
- private readonly MAX_MSG_LEN;
39
- private mmApiClient;
40
- private readonly deduper?;
41
- private readonly source;
42
- constructor(source: string, deduper?: LogDeduper);
43
- /**
44
- * Send a single log entry to the MM cloud with deduplication.
45
- *
46
- * The deduplication is handled by the injected LogDeduper.
47
- * If no deduper is injected, the log entry is sent without deduplication.
48
- *
49
- * The standard deduper, FileLogDeduper, stores the deduplication state in a file,
50
- * allowing deduplication across jobs,
51
- *
52
- * @param logEntry - The log entry to send
53
- * @returns Promise resolving to the API response or null if suppressed
54
- * @throws HTTPError if the request fails or Error if the log entry is invalid
55
- */
56
- sendLog(logEntry: LogEntry): Promise<LogResponse | null>;
57
- /**
58
- * @throws Error if validation fails
59
- */
60
- private validateLogEntry;
61
- /**
62
- * Retry all failed transmissions silently
63
- * This method attempts to retry all messages that failed to transmit
64
- * and removes them from the failed list if successful, else leaves them for the client to retry
65
- *
66
- * Expected usage is by a client to call this as part of its own retry mechanism
67
- */
68
- retryFailedTransmissions(): Promise<void>;
69
- /**
70
- * Clean up resources
71
- */
72
- destroy(): Promise<void>;
73
- }
74
- //# sourceMappingURL=mm-connector-logger.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mm-connector-logger.d.ts","sourceRoot":"","sources":["../../../src/utils/connector-log/mm-connector-logger.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAEhD,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;AAEvD;;;;;;GAMG;AACH,qBAAa,QAAQ;IACnB,KAAK,EAAE,cAAc,CAAC;IACtB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;gBAEN,MAAM,EAAE;QAAE,KAAK,EAAE,cAAc,CAAC;QAAC,OAAO,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAC;CAMjF;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAaD;;;;;;;;GAQG;AACH,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,QAAQ,CAAC,WAAW,CAAQ;IAEpC,OAAO,CAAC,WAAW,CAAc;IACjC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAa;IACtC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAS;gBAEpB,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,UAAU;IAYhD;;;;;;;;;;;;OAYG;IACG,OAAO,CAAC,QAAQ,EAAE,QAAQ,GAAG,OAAO,CAAC,WAAW,GAAG,IAAI,CAAC;IAsC9D;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAsBxB;;;;;;OAMG;IACG,wBAAwB,IAAI,OAAO,CAAC,IAAI,CAAC;IAa/C;;OAEG;IACG,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAG/B"}
@@ -1,2 +0,0 @@
1
- export declare function getErrorType(error: unknown): string;
2
- //# sourceMappingURL=error-utils.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error-utils.d.ts","sourceRoot":"","sources":["../../src/utils/error-utils.ts"],"names":[],"mappings":"AAQA,wBAAgB,YAAY,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CASnD"}