@machinemetrics/mm-erp-sdk 0.1.5-beta.0 → 0.1.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/README.md +1 -1
- package/dist/{config-2l5vnNkA.js → config-qat9zgOl.js} +6 -6
- package/dist/{config-2l5vnNkA.js.map → config-qat9zgOl.js.map} +1 -1
- package/dist/{connector-factory-CQ8e7Tae.js → connector-factory-C2czCs9v.js} +12 -3
- package/dist/connector-factory-C2czCs9v.js.map +1 -0
- package/dist/{hashed-cache-manager-Ci59eC75.js → hashed-cache-manager-CzyFSt2B.js} +5 -4
- package/dist/{hashed-cache-manager-Ci59eC75.js.map → hashed-cache-manager-CzyFSt2B.js.map} +1 -1
- package/dist/{index-CXbOvFyf.js → index-B9wo8pld.js} +7 -7
- package/dist/{index-CXbOvFyf.js.map → index-B9wo8pld.js.map} +1 -1
- package/dist/index.d.ts +14 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/{logger-QG73MndU.js → logger-Db8CkwR6.js} +929 -971
- package/dist/logger-Db8CkwR6.js.map +1 -0
- package/dist/mm-erp-sdk.js +417 -10
- package/dist/mm-erp-sdk.js.map +1 -1
- package/dist/services/data-sync-service/index.d.ts +1 -1
- package/dist/services/data-sync-service/index.d.ts.map +1 -1
- package/dist/services/data-sync-service/jobs/clean-up-expired-cache.d.ts +2 -0
- 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 +42 -41
- 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 +11 -5
- 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 +2 -0
- 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 +39 -40
- 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 +4 -3
- 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 +15 -5
- package/dist/services/data-sync-service/jobs/to-erp.js.map +1 -1
- package/dist/services/erp-api-services/index.d.ts +5 -1
- package/dist/services/erp-api-services/index.d.ts.map +1 -1
- package/dist/services/mm-api-service/index.d.ts +3 -2
- package/dist/services/mm-api-service/index.d.ts.map +1 -1
- package/dist/services/mm-api-service/mm-api-service.d.ts +20 -0
- package/dist/services/mm-api-service/mm-api-service.d.ts.map +1 -1
- package/dist/types/erp-types.d.ts +1 -2
- package/dist/types/erp-types.d.ts.map +1 -1
- package/dist/utils/connector-factory.d.ts.map +1 -1
- package/dist/utils/connector-log/log-deduper.d.ts +56 -0
- package/dist/utils/connector-log/log-deduper.d.ts.map +1 -0
- package/dist/utils/connector-log/mm-connector-logger-example.d.ts +1 -0
- package/dist/utils/connector-log/mm-connector-logger-example.d.ts.map +1 -0
- package/dist/utils/connector-log/mm-connector-logger.d.ts +74 -0
- package/dist/utils/connector-log/mm-connector-logger.d.ts.map +1 -0
- package/dist/utils/error-utils.d.ts +2 -0
- package/dist/utils/error-utils.d.ts.map +1 -0
- package/dist/utils/index.d.ts +11 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/standard-process-drivers/index.d.ts +2 -1
- package/dist/utils/standard-process-drivers/index.d.ts.map +1 -1
- package/dist/utils/timezone.d.ts +7 -0
- package/dist/utils/timezone.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +19 -5
- package/src/services/data-sync-service/index.ts +1 -4
- package/src/services/data-sync-service/jobs/clean-up-expired-cache.ts +19 -7
- package/src/services/data-sync-service/jobs/from-erp.ts +12 -5
- package/src/services/data-sync-service/jobs/retry-failed-labor-tickets.ts +15 -5
- package/src/services/data-sync-service/jobs/run-migrations.ts +5 -2
- package/src/services/data-sync-service/jobs/to-erp.ts +17 -5
- package/src/services/erp-api-services/index.ts +9 -1
- package/src/services/mm-api-service/index.ts +1 -1
- package/src/services/mm-api-service/mm-api-service.ts +28 -0
- package/src/types/erp-types.ts +0 -1
- package/src/utils/application-initializer.ts +1 -1
- package/src/utils/connector-factory.ts +14 -3
- package/src/utils/connector-log/log-deduper.ts +284 -0
- package/src/utils/connector-log/mm-connector-logger-example.ts +97 -0
- package/src/utils/connector-log/mm-connector-logger.ts +177 -0
- package/src/utils/error-utils.ts +18 -0
- package/src/utils/index.ts +12 -5
- package/src/utils/mm-labor-ticket-helpers.ts +2 -2
- package/src/utils/standard-process-drivers/index.ts +2 -4
- package/src/utils/timezone.ts +28 -0
- package/dist/connector-factory-CQ8e7Tae.js.map +0 -1
- package/dist/logger-QG73MndU.js.map +0 -1
|
@@ -0,0 +1,74 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -11,7 +11,7 @@ export { addNewFieldFromExternalSource, addNewFieldFromLookupField, } from "./da
|
|
|
11
11
|
* Timezone and time-related utilities
|
|
12
12
|
*/
|
|
13
13
|
export { getTimezoneOffsetAndPersist } from "./time-utils";
|
|
14
|
-
export { formatDateWithTZOffset, convertToLocalTime } from "./timezone";
|
|
14
|
+
export { formatDateWithTZOffset, convertToLocalTime, toISOWithOffset } from "./timezone";
|
|
15
15
|
export { applyTimezoneOffsetsToFields } from "./time-utils";
|
|
16
16
|
export * from "./time-utils";
|
|
17
17
|
/**
|
|
@@ -25,7 +25,8 @@ export { BatchCacheManager } from "../services/caching-service/batch-cache-manag
|
|
|
25
25
|
* Process and data transformation utilities
|
|
26
26
|
*/
|
|
27
27
|
export { StandardProcessDrivers } from "./standard-process-drivers/";
|
|
28
|
-
export type { WriteEntitiesToMMResult
|
|
28
|
+
export type { WriteEntitiesToMMResult } from "./standard-process-drivers/";
|
|
29
|
+
export { MMBatchValidationError } from "./standard-process-drivers/";
|
|
29
30
|
export { getCachedTimezoneOffset } from "./local-data-store/jobs-shared-data";
|
|
30
31
|
export { getInitialLoadComplete, setInitialLoadComplete, } from "./local-data-store/jobs-shared-data";
|
|
31
32
|
/**
|
|
@@ -38,10 +39,18 @@ export { getERPAPITypeFromEntity } from "./erp-type-from-entity";
|
|
|
38
39
|
* HTTP Client utilities
|
|
39
40
|
*/
|
|
40
41
|
export { HTTPClientFactory } from "./http-client";
|
|
42
|
+
export { HTTPError } from "./http-client";
|
|
43
|
+
export type { HTTPClient, HTTPRequestConfig, HTTPResponse } from "./http-client";
|
|
41
44
|
/**
|
|
42
45
|
* MM Labor Ticket utilities
|
|
43
46
|
*/
|
|
44
47
|
export * from "./mm-labor-ticket-helpers";
|
|
48
|
+
export { getErrorType } from './error-utils';
|
|
49
|
+
/**
|
|
50
|
+
* MM Connector Logger utilities
|
|
51
|
+
*/
|
|
52
|
+
export { MMConnectorLogger, LogEntry, type LogResponse, type LogLevelString } from './connector-log/mm-connector-logger';
|
|
53
|
+
export { FileLogDeduper } from './connector-log/log-deduper';
|
|
45
54
|
/**
|
|
46
55
|
* Application initializer
|
|
47
56
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EACL,6BAA6B,EAC7B,0BAA0B,GAC3B,MAAM,uBAAuB,CAAC;AAE/B;;GAEG;AACH,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAClE,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AACnD,OAAO,EACL,6BAA6B,EAC7B,0BAA0B,GAC3B,MAAM,uBAAuB,CAAC;AAE/B;;GAEG;AACH,OAAO,EAAE,2BAA2B,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AACzF,OAAO,EAAE,4BAA4B,EAAE,MAAM,cAAc,CAAC;AAC5D,cAAc,cAAc,CAAC;AAE7B;;GAEG;AACH,OAAO,EAAE,qBAAqB,EAAE,MAAM,qDAAqD,CAAC;AAC5F,YAAY,EAAE,oBAAoB,EAAE,MAAM,qDAAqD,CAAC;AAChG,OAAO,EAAE,kBAAkB,EAAE,MAAM,kDAAkD,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,iDAAiD,CAAC;AAEpF;;GAEG;AACH,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,YAAY,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AAC3E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAG9E,OAAO,EACL,sBAAsB,EACtB,sBAAsB,GACvB,MAAM,qCAAqC,CAAC;AAE7C;;GAEG;AACH,cAAc,oDAAoD,CAAC;AACnE,cAAc,oDAAoD,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAEjE;;GAEG;AACH,OAAO,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAEjF;;GAEG;AACH,cAAc,2BAA2B,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C;;GAEG;AACH,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,KAAK,WAAW,EAAE,KAAK,cAAc,EAAE,MAAM,qCAAqC,CAAC;AACzH,OAAO,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAE7D;;GAEG;AACH,cAAc,2BAA2B,CAAC;AAE1C;;GAEG;AACH,OAAO,EAAE,cAAc,EAAE,MAAM,sDAAsD,CAAC;AACtF,OAAO,EAAE,WAAW,EAAE,MAAM,2CAA2C,CAAC;AAExE;;GAEG;AACH,OAAO,EAAE,uBAAuB,EAAE,MAAM,qBAAqB,CAAC"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
export { StandardProcessDrivers } from "./standard-process-drivers";
|
|
2
|
-
export type { WriteEntitiesToMMResult
|
|
2
|
+
export type { WriteEntitiesToMMResult } from "./standard-process-drivers";
|
|
3
|
+
export { MMBatchValidationError } from "./standard-process-drivers";
|
|
3
4
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/standard-process-drivers/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,YAAY,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/utils/standard-process-drivers/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC;AACpE,YAAY,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,4BAA4B,CAAC"}
|
package/dist/utils/timezone.d.ts
CHANGED
|
@@ -18,4 +18,11 @@ export declare const convertToLocalTime: (zuluTime: string | Date | null | undef
|
|
|
18
18
|
* @returns The formatted date string in format: YYYY-MM-DDTHH:mm:ss+/-HH:MM
|
|
19
19
|
*/
|
|
20
20
|
export declare const formatDateWithTZOffset: (date: string | null | undefined, timezoneOffset: number) => string | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Formats a Date object as an ISO string with the specified timezone offset
|
|
23
|
+
* @param date The Date object to format (should be a Date that has been shifted by convertToLocalTime)
|
|
24
|
+
* @param timezoneOffset The timezone offset in hours
|
|
25
|
+
* @returns ISO string with offset in format: YYYY-MM-DDTHH:mm:ss.SSS±HH:MM
|
|
26
|
+
*/
|
|
27
|
+
export declare const toISOWithOffset: (date: Date, timezoneOffset: number) => string;
|
|
21
28
|
//# sourceMappingURL=timezone.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timezone.d.ts","sourceRoot":"","sources":["../../src/utils/timezone.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,QAAa,OAAO,CAAC,MAAM,CA6CxD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAC7B,UAAU,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,EAC1C,gBAAgB,MAAM,KACrB,IAAI,GAAG,SAIT,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GACjC,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,EAC/B,gBAAgB,MAAM,KACrB,MAAM,GAAG,SAgBX,CAAC"}
|
|
1
|
+
{"version":3,"file":"timezone.d.ts","sourceRoot":"","sources":["../../src/utils/timezone.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,QAAa,OAAO,CAAC,MAAM,CA6CxD,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,GAC7B,UAAU,MAAM,GAAG,IAAI,GAAG,IAAI,GAAG,SAAS,EAC1C,gBAAgB,MAAM,KACrB,IAAI,GAAG,SAIT,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,sBAAsB,GACjC,MAAM,MAAM,GAAG,IAAI,GAAG,SAAS,EAC/B,gBAAgB,MAAM,KACrB,MAAM,GAAG,SAgBX,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,eAAe,GAAI,MAAM,IAAI,EAAE,gBAAgB,MAAM,KAAG,MAoBpE,CAAC"}
|
package/package.json
CHANGED
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
|
|
12
|
+
export { 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";
|
|
19
20
|
export type {
|
|
20
|
-
MMReceiveLaborTicket,
|
|
21
21
|
MMReceiveLaborTicketReason,
|
|
22
22
|
MMReceiveLaborTicketWorkOrderOperation,
|
|
23
23
|
IToRESTApiObject,
|
|
@@ -48,6 +48,7 @@ export {
|
|
|
48
48
|
formatDateWithTZOffset,
|
|
49
49
|
applyTimezoneOffsetsToFields,
|
|
50
50
|
convertToLocalTime,
|
|
51
|
+
getErrorType,
|
|
51
52
|
} from "./utils";
|
|
52
53
|
|
|
53
54
|
// Local data store
|
|
@@ -55,7 +56,8 @@ export { getInitialLoadComplete, setInitialLoadComplete } from "./utils";
|
|
|
55
56
|
|
|
56
57
|
// HTTP client factory and types for custom API integrations
|
|
57
58
|
export { HTTPClientFactory } from "./utils/http-client";
|
|
58
|
-
export
|
|
59
|
+
export { HTTPError } from "./utils/http-client";
|
|
60
|
+
export type { HTTPResponse, HTTPClient, HTTPRequestConfig } from "./utils/http-client";
|
|
59
61
|
|
|
60
62
|
// Application initialization utilities
|
|
61
63
|
export { ApplicationInitializer } from "./utils/application-initializer";
|
|
@@ -71,11 +73,13 @@ export type { IERPLaborTicketHandler } from "./types/erp-connector";
|
|
|
71
73
|
|
|
72
74
|
// Process drivers and utilities
|
|
73
75
|
export { StandardProcessDrivers, getCachedTimezoneOffset } from "./utils";
|
|
74
|
-
export type {
|
|
76
|
+
export type { WriteEntitiesToMMResult } from "./utils";
|
|
77
|
+
export { MMBatchValidationError } from "./utils";
|
|
75
78
|
|
|
76
79
|
// API services
|
|
80
|
+
export type { APIResponse } from './services/erp-api-services/types';
|
|
77
81
|
export { RestAPIService } from "./services/erp-api-services/rest/rest-api-service";
|
|
78
|
-
export { ErrorHandler } from "./services/erp-api-services/errors";
|
|
82
|
+
export { ErrorHandler, GraphQLError } from "./services/erp-api-services/errors";
|
|
79
83
|
export type {
|
|
80
84
|
QueryParams,
|
|
81
85
|
PaginatedAPIResponse,
|
|
@@ -100,3 +104,13 @@ export {
|
|
|
100
104
|
SqlServerHelper,
|
|
101
105
|
} from "./services/sql-server-erp-service";
|
|
102
106
|
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,7 +8,4 @@ export { runDataSyncService } from "./data-sync-service";
|
|
|
8
8
|
*/
|
|
9
9
|
export { getSQLServerConfiguration } from "./configuration-manager";
|
|
10
10
|
|
|
11
|
-
export {
|
|
12
|
-
ErpApiConnectionParams,
|
|
13
|
-
getErpApiConnectionParams,
|
|
14
|
-
} from "./configuration-manager";
|
|
11
|
+
export { ErpApiConnectionParams, getErpApiConnectionParams } from "./configuration-manager";
|
|
@@ -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 {
|
|
@@ -29,13 +32,22 @@ const main = async () => {
|
|
|
29
32
|
}
|
|
30
33
|
};
|
|
31
34
|
|
|
32
|
-
//
|
|
33
|
-
|
|
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) {
|
|
34
45
|
// This is called when Bree runs this file as a worker
|
|
35
|
-
|
|
46
|
+
try {
|
|
36
47
|
await main();
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
module.exports = main;
|
|
48
|
+
} catch {
|
|
49
|
+
process.exitCode = 1; // prefer exitCode so stdout/stderr can flush
|
|
50
|
+
}
|
|
41
51
|
}
|
|
52
|
+
|
|
53
|
+
export default main;
|
|
@@ -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,8 +14,7 @@ const main = async () => {
|
|
|
11
14
|
|
|
12
15
|
// Get the connector path from the environment variable
|
|
13
16
|
const connectorPath = process.env.CONNECTOR_PATH;
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
|
|
16
18
|
if (!connectorPath) {
|
|
17
19
|
throw new Error("Connector path not provided in environment variables");
|
|
18
20
|
}
|
|
@@ -41,9 +43,14 @@ const main = async () => {
|
|
|
41
43
|
}
|
|
42
44
|
};
|
|
43
45
|
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
|
|
46
|
+
// Cross-platform module detection fix for Bree compatibility
|
|
47
|
+
// Windows: process.argv[1] uses backslashes, import.meta.url uses forward slashes
|
|
48
|
+
// Linux/Mac: both use forward slashes, so this normalization is safe
|
|
49
|
+
const normalizedArgv1 = process.argv[1].replace(/\\/g, '/');
|
|
50
|
+
const fileUrl = normalizedArgv1.startsWith('/') ?
|
|
51
|
+
`file://${normalizedArgv1}` : // Unix: file:// + /path = file:///path
|
|
52
|
+
`file:///${normalizedArgv1}`; // Windows: file:/// + C:/path = file:///C:/path
|
|
53
|
+
const isMainModule = import.meta.url === fileUrl;
|
|
47
54
|
|
|
48
55
|
if (isMainModule) {
|
|
49
56
|
// This is called when Bree runs this file as a worker
|
|
@@ -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');
|
|
@@ -34,13 +37,20 @@ const main = async () => {
|
|
|
34
37
|
}
|
|
35
38
|
};
|
|
36
39
|
|
|
37
|
-
//
|
|
38
|
-
|
|
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) {
|
|
39
50
|
// This is called when Bree runs this file as a worker
|
|
40
51
|
main().catch(() => {
|
|
41
52
|
process.exitCode = 1;
|
|
42
53
|
});
|
|
43
|
-
} else {
|
|
44
|
-
// Export for potential testing or direct usage
|
|
45
|
-
module.exports = main;
|
|
46
54
|
}
|
|
55
|
+
|
|
56
|
+
export default main;
|
|
@@ -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
|
|
|
@@ -12,7 +15,7 @@ export default async function runMigrations() {
|
|
|
12
15
|
logger.info("Migrations complete!");
|
|
13
16
|
} catch (error) {
|
|
14
17
|
logger.error("Error running migrations:", error);
|
|
15
|
-
process.
|
|
18
|
+
process.exitCode = 1;
|
|
16
19
|
} finally {
|
|
17
20
|
await db.destroy();
|
|
18
21
|
}
|
|
@@ -22,6 +25,6 @@ const isMainModule = import.meta.url === `file://${process.argv[1]}`;
|
|
|
22
25
|
if (isMainModule) {
|
|
23
26
|
runMigrations().catch(err => {
|
|
24
27
|
logger.error("Top-level error running migrations:", err);
|
|
25
|
-
process.
|
|
28
|
+
process.exitCode = 1;
|
|
26
29
|
});
|
|
27
30
|
}
|
|
@@ -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');
|
|
@@ -41,13 +44,22 @@ const main = async () => {
|
|
|
41
44
|
}
|
|
42
45
|
};
|
|
43
46
|
|
|
44
|
-
//
|
|
45
|
-
//
|
|
46
|
-
|
|
47
|
+
// Cross-platform module detection fix for Bree compatibility
|
|
48
|
+
// Windows: process.argv[1] uses backslashes, import.meta.url uses forward slashes
|
|
49
|
+
// Linux/Mac: both use forward slashes, so this normalization is safe
|
|
50
|
+
const normalizedArgv1 = process.argv[1].replace(/\\/g, '/');
|
|
51
|
+
const fileUrl = normalizedArgv1.startsWith('/') ?
|
|
52
|
+
`file://${normalizedArgv1}` : // Unix: file:// + /path = file:///path
|
|
53
|
+
`file:///${normalizedArgv1}`; // Windows: file:/// + C:/path = file:///C:/path
|
|
54
|
+
const isMainModule = import.meta.url === fileUrl;
|
|
55
|
+
|
|
47
56
|
if (isMainModule) {
|
|
48
57
|
// This is called when Bree runs this file as a worker
|
|
49
|
-
|
|
58
|
+
try {
|
|
59
|
+
await main();
|
|
60
|
+
} catch {
|
|
61
|
+
process.exitCode = 1; // prefer exitCode so stdout/stderr can flush
|
|
62
|
+
}
|
|
50
63
|
}
|
|
51
64
|
|
|
52
|
-
// Export for potential testing or direct usage (ES module default export)
|
|
53
65
|
export default main;
|
|
@@ -9,6 +9,14 @@ 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';
|
|
12
13
|
|
|
13
14
|
// OAuth Client
|
|
14
|
-
export { OAuthClient } from
|
|
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';
|
|
@@ -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";
|
|
55
56
|
export type {
|
|
56
|
-
MMReceiveLaborTicket,
|
|
57
57
|
MMReceiveLaborTicketReason,
|
|
58
58
|
MMReceiveLaborTicketWorkOrderOperation,
|
|
59
59
|
};
|
|
@@ -646,6 +646,34 @@ 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
|
+
|
|
649
677
|
async deleteFailedLaborTicketIds(
|
|
650
678
|
system: ERPType,
|
|
651
679
|
laborTicketRefs: string[]
|
package/src/types/erp-types.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { IERPConnector } from "../types/erp-connector";
|
|
2
2
|
import logger from "../services/reporting-service/logger";
|
|
3
|
+
import { pathToFileURL } from "url";
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Helper function to dynamically import and create connector instance from a file path
|
|
@@ -10,8 +11,18 @@ export const createConnectorFromPath = async (
|
|
|
10
11
|
connectorPath: string
|
|
11
12
|
): Promise<IERPConnector> => {
|
|
12
13
|
try {
|
|
13
|
-
//
|
|
14
|
-
const
|
|
14
|
+
// Some detailed debug logging to help with troubleshooting multi-platform connector paths
|
|
15
|
+
const pathParts = connectorPath.split('/');
|
|
16
|
+
const filename = pathParts[pathParts.length - 1];
|
|
17
|
+
|
|
18
|
+
logger.debug("createConnectorFromPath:", {
|
|
19
|
+
connectorPath,
|
|
20
|
+
pathParts,
|
|
21
|
+
filename,
|
|
22
|
+
finalImport: pathToFileURL(connectorPath).href,
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
const connectorModule = await import(pathToFileURL(connectorPath).href);
|
|
15
26
|
|
|
16
27
|
// Get the default export or named export
|
|
17
28
|
const ConnectorClass =
|
|
@@ -31,4 +42,4 @@ export const createConnectorFromPath = async (
|
|
|
31
42
|
);
|
|
32
43
|
throw error;
|
|
33
44
|
}
|
|
34
|
-
};
|
|
45
|
+
};
|