@machinemetrics/mm-erp-sdk 0.1.8-beta.8 → 0.1.8
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 +2 -1
- package/dist/{config-qat9zgOl.js → config-cB7h4yvc.js} +2 -2
- package/dist/{config-qat9zgOl.js.map → config-cB7h4yvc.js.map} +1 -1
- package/dist/{connector-factory-C2czCs9v.js → connector-factory-CKm74_WZ.js} +2 -2
- package/dist/{connector-factory-C2czCs9v.js.map → connector-factory-CKm74_WZ.js.map} +1 -1
- package/dist/{hashed-cache-manager-CzyFSt2B.js → hashed-cache-manager-Ds-HksA0.js} +34 -4
- package/dist/hashed-cache-manager-Ds-HksA0.js.map +1 -0
- package/dist/{index-B9wo8pld.js → index-DTtmv8Iq.js} +16 -5
- package/dist/index-DTtmv8Iq.js.map +1 -0
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/{logger-Db8CkwR6.js → logger-CBDNtsMq.js} +62 -11
- package/dist/{logger-Db8CkwR6.js.map → logger-CBDNtsMq.js.map} +1 -1
- package/dist/mm-erp-sdk.js +256 -17
- package/dist/mm-erp-sdk.js.map +1 -1
- package/dist/services/data-sync-service/configuration-manager.d.ts +5 -0
- package/dist/services/data-sync-service/configuration-manager.d.ts.map +1 -1
- package/dist/services/data-sync-service/jobs/clean-up-expired-cache.js +4 -4
- package/dist/services/data-sync-service/jobs/from-erp.js +4 -4
- package/dist/services/data-sync-service/jobs/retry-failed-labor-tickets.js +3 -3
- package/dist/services/data-sync-service/jobs/run-migrations.js +1 -1
- package/dist/services/data-sync-service/jobs/to-erp.js +3 -3
- package/dist/services/psql-erp-service/configuration.d.ts +8 -0
- package/dist/services/psql-erp-service/configuration.d.ts.map +1 -0
- package/dist/services/psql-erp-service/index.d.ts +14 -0
- package/dist/services/psql-erp-service/index.d.ts.map +1 -0
- package/dist/services/psql-erp-service/internal/types/psql-types.d.ts +12 -0
- package/dist/services/psql-erp-service/internal/types/psql-types.d.ts.map +1 -0
- package/dist/services/psql-erp-service/psql-helpers.d.ts +32 -0
- package/dist/services/psql-erp-service/psql-helpers.d.ts.map +1 -0
- package/dist/services/psql-erp-service/psql-service.d.ts +50 -0
- package/dist/services/psql-erp-service/psql-service.d.ts.map +1 -0
- package/dist/services/reporting-service/logger.d.ts.map +1 -1
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/local-data-store/jobs-shared-data.d.ts +15 -1
- package/dist/utils/local-data-store/jobs-shared-data.d.ts.map +1 -1
- package/dist/utils/time-utils.d.ts +2 -1
- package/dist/utils/time-utils.d.ts.map +1 -1
- package/dist/utils/timezone.d.ts +6 -3
- package/dist/utils/timezone.d.ts.map +1 -1
- package/package.json +4 -1
- package/src/index.ts +31 -6
- package/src/services/data-sync-service/configuration-manager.ts +33 -0
- package/src/services/psql-erp-service/configuration.ts +7 -0
- package/src/services/psql-erp-service/index.ts +22 -0
- package/src/services/psql-erp-service/internal/types/psql-types.ts +13 -0
- package/src/services/psql-erp-service/psql-helpers.ts +114 -0
- package/src/services/psql-erp-service/psql-service.ts +247 -0
- package/src/services/reporting-service/logger.ts +73 -11
- package/src/utils/application-initializer.ts +1 -1
- package/src/utils/index.ts +4 -1
- package/src/utils/local-data-store/jobs-shared-data.ts +24 -1
- package/src/utils/time-utils.ts +11 -6
- package/src/utils/timezone.ts +9 -6
- package/dist/hashed-cache-manager-CzyFSt2B.js.map +0 -1
- package/dist/index-B9wo8pld.js.map +0 -1
|
@@ -17,6 +17,11 @@ export declare class CoreConfiguration {
|
|
|
17
17
|
readonly cacheExpirationCheckInterval: string;
|
|
18
18
|
private constructor();
|
|
19
19
|
static inst(): CoreConfiguration;
|
|
20
|
+
/**
|
|
21
|
+
* Returns a sanitized version of the configuration for safe logging.
|
|
22
|
+
* Masks sensitive fields like authentication tokens.
|
|
23
|
+
*/
|
|
24
|
+
toSafeLogObject(): Record<string, unknown>;
|
|
20
25
|
}
|
|
21
26
|
/**
|
|
22
27
|
* Helper function to get the SQL Server Configuration for collectors that use SQL Server to interact with the ERP
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"configuration-manager.d.ts","sourceRoot":"","sources":["../../../src/services/data-sync-service/configuration-manager.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAEvB,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AAEjF,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAoB;IAG3C,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,OAAO,EAAE,MAAM,CAAC;IAGhC,SAAgB,kBAAkB,EAAE,MAAM,CAAC;IAC3C,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAgB,cAAc,EAAE,MAAM,CAAC;IACvC,SAAgB,kBAAkB,EAAE,MAAM,CAAC;IAG3C,SAAgB,QAAQ,EAAE,MAAM,CAAC;IAGjC,SAAgB,iBAAiB,EAAE,MAAM,CAAC;IAG1C,SAAgB,eAAe,EAAE,MAAM,CAAC;IACxC,SAAgB,aAAa,EAAE,MAAM,CAAC;IACtC,SAAgB,yBAAyB,EAAE,MAAM,CAAC;IAClD,SAAgB,4BAA4B,EAAE,MAAM,CAAC;IAErD,OAAO;WA0DO,IAAI,IAAI,iBAAiB;
|
|
1
|
+
{"version":3,"file":"configuration-manager.d.ts","sourceRoot":"","sources":["../../../src/services/data-sync-service/configuration-manager.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAEvB,OAAO,EAAE,sBAAsB,EAAE,MAAM,yCAAyC,CAAC;AAEjF,qBAAa,iBAAiB;IAC5B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAoB;IAG3C,SAAgB,QAAQ,EAAE,MAAM,CAAC;IACjC,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,OAAO,EAAE,MAAM,CAAC;IAGhC,SAAgB,kBAAkB,EAAE,MAAM,CAAC;IAC3C,SAAgB,YAAY,EAAE,MAAM,CAAC;IACrC,SAAgB,cAAc,EAAE,MAAM,CAAC;IACvC,SAAgB,kBAAkB,EAAE,MAAM,CAAC;IAG3C,SAAgB,QAAQ,EAAE,MAAM,CAAC;IAGjC,SAAgB,iBAAiB,EAAE,MAAM,CAAC;IAG1C,SAAgB,eAAe,EAAE,MAAM,CAAC;IACxC,SAAgB,aAAa,EAAE,MAAM,CAAC;IACtC,SAAgB,yBAAyB,EAAE,MAAM,CAAC;IAClD,SAAgB,4BAA4B,EAAE,MAAM,CAAC;IAErD,OAAO;WA0DO,IAAI,IAAI,iBAAiB;IAOvC;;;OAGG;IACI,eAAe,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CA4BlD;AAED;;GAEG;AACH,eAAO,MAAM,yBAAyB,QAAO,sBAiB5C,CAAC;AAEF;;;GAGG;AACH,qBAAa,sBAAsB;aAEf,SAAS,EAAE,MAAM;aACjB,cAAc,EAAE,MAAM;aACtB,kBAAkB,EAAE,MAAM;aAC1B,oBAAoB,EAAE,MAAM;aAC5B,cAAc,EAAE,MAAM;aACtB,aAAa,EAAE,MAAM;gBALrB,SAAS,EAAE,MAAM,EAAE,kBAAkB;IACrC,cAAc,EAAE,MAAM,EAAE,qCAAqC;IAC7D,kBAAkB,EAAE,MAAM,EAAE,yCAAyC;IACrE,oBAAoB,EAAE,MAAM,EAAE,2BAA2B;IACzD,cAAc,EAAE,MAAM,EAAE,gBAAgB;IACxC,aAAa,GAAE,MAAU;CAE5C;AAED;;;;GAIG;AACH,eAAO,MAAM,yBAAyB,QAAO,sBAS5C,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "../../../config-
|
|
2
|
-
import { H as HashedCacheManager } from "../../../hashed-cache-manager-
|
|
3
|
-
import { S as SQLiteCoordinator } from "../../../index-
|
|
4
|
-
import { l as logger } from "../../../logger-
|
|
1
|
+
import "../../../config-cB7h4yvc.js";
|
|
2
|
+
import { H as HashedCacheManager } from "../../../hashed-cache-manager-Ds-HksA0.js";
|
|
3
|
+
import { S as SQLiteCoordinator } from "../../../index-DTtmv8Iq.js";
|
|
4
|
+
import { l as logger } from "../../../logger-CBDNtsMq.js";
|
|
5
5
|
logger.level = process.env.LOG_LEVEL || "info";
|
|
6
6
|
const main = async () => {
|
|
7
7
|
const cacheManager = new HashedCacheManager();
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import "../../../config-
|
|
2
|
-
import { l as logger } from "../../../logger-
|
|
3
|
-
import { S as SQLiteCoordinator } from "../../../index-
|
|
4
|
-
import { c as createConnectorFromPath } from "../../../connector-factory-
|
|
1
|
+
import "../../../config-cB7h4yvc.js";
|
|
2
|
+
import { l as logger } from "../../../logger-CBDNtsMq.js";
|
|
3
|
+
import { S as SQLiteCoordinator } from "../../../index-DTtmv8Iq.js";
|
|
4
|
+
import { c as createConnectorFromPath } from "../../../connector-factory-CKm74_WZ.js";
|
|
5
5
|
logger.level = process.env.LOG_LEVEL || "info";
|
|
6
6
|
const main = async () => {
|
|
7
7
|
try {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "../../../config-
|
|
2
|
-
import { l as logger } from "../../../logger-
|
|
3
|
-
import { c as createConnectorFromPath } from "../../../connector-factory-
|
|
1
|
+
import "../../../config-cB7h4yvc.js";
|
|
2
|
+
import { l as logger } from "../../../logger-CBDNtsMq.js";
|
|
3
|
+
import { c as createConnectorFromPath } from "../../../connector-factory-CKm74_WZ.js";
|
|
4
4
|
logger.level = process.env.LOG_LEVEL || "info";
|
|
5
5
|
const main = async () => {
|
|
6
6
|
try {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import knex from "knex";
|
|
2
|
-
import { l as logger } from "../../../logger-
|
|
2
|
+
import { l as logger } from "../../../logger-CBDNtsMq.js";
|
|
3
3
|
import { c as config } from "../../../knexfile-1qKKIORB.js";
|
|
4
4
|
logger.level = process.env.LOG_LEVEL || "info";
|
|
5
5
|
const db = knex(config.local);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import "../../../config-
|
|
2
|
-
import { l as logger } from "../../../logger-
|
|
3
|
-
import { c as createConnectorFromPath } from "../../../connector-factory-
|
|
1
|
+
import "../../../config-cB7h4yvc.js";
|
|
2
|
+
import { l as logger } from "../../../logger-CBDNtsMq.js";
|
|
3
|
+
import { c as createConnectorFromPath } from "../../../connector-factory-CKm74_WZ.js";
|
|
4
4
|
logger.level = process.env.LOG_LEVEL || "info";
|
|
5
5
|
const main = async () => {
|
|
6
6
|
try {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"configuration.d.ts","sourceRoot":"","sources":["../../../src/services/psql-erp-service/configuration.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { PsqlService } from "./psql-service";
|
|
2
|
+
/**
|
|
3
|
+
* A class to manage interactions with PSQL (Pervasive) databases via ODBC
|
|
4
|
+
*/
|
|
5
|
+
export { PsqlService };
|
|
6
|
+
/**
|
|
7
|
+
* Configuration interface for PSQL connections
|
|
8
|
+
*/
|
|
9
|
+
export type { PsqlConfiguration } from "./configuration";
|
|
10
|
+
/**
|
|
11
|
+
* Helper functions for PSQL data formatting
|
|
12
|
+
*/
|
|
13
|
+
export { formatPsqlDate, formatPsqlTime, combinePsqlDateTime, isPsqlDateEmpty, cleanPsqlCharField, } from "./psql-helpers";
|
|
14
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/services/psql-erp-service/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAE7C;;GAEG;AACH,OAAO,EAAE,WAAW,EAAE,CAAC;AAEvB;;GAEG;AACH,YAAY,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzD;;GAEG;AACH,OAAO,EACL,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,kBAAkB,GACnB,MAAM,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* PSQL-specific type definitions
|
|
3
|
+
*/
|
|
4
|
+
export interface OdbcError {
|
|
5
|
+
state: string;
|
|
6
|
+
message: string;
|
|
7
|
+
code?: number;
|
|
8
|
+
}
|
|
9
|
+
export interface OdbcErrorResponse extends Error {
|
|
10
|
+
odbcErrors?: OdbcError[];
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=psql-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"psql-types.d.ts","sourceRoot":"","sources":["../../../../../src/services/psql-erp-service/internal/types/psql-types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,SAAS;IACxB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,iBAAkB,SAAQ,KAAK;IAC9C,UAAU,CAAC,EAAE,SAAS,EAAE,CAAC;CAC1B"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions for PSQL/Pervasive database operations
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Formats a date from PSQL YYMMDD format to ISO date string
|
|
6
|
+
* @param psqlDate Date in YYMMDD format (e.g., "250105" for Jan 5, 2025)
|
|
7
|
+
* @returns ISO date string (e.g., "2025-01-05") or null if invalid
|
|
8
|
+
*/
|
|
9
|
+
export declare function formatPsqlDate(psqlDate: string): string | null;
|
|
10
|
+
/**
|
|
11
|
+
* Formats a time from PSQL HHMM format to HH:MM:SS
|
|
12
|
+
* @param psqlTime Time in HHMM format (e.g., "1430" for 2:30 PM)
|
|
13
|
+
* @returns Time string in HH:MM:SS format or null if invalid
|
|
14
|
+
*/
|
|
15
|
+
export declare function formatPsqlTime(psqlTime: string): string | null;
|
|
16
|
+
/**
|
|
17
|
+
* Combines PSQL date and time into ISO datetime string
|
|
18
|
+
* @param psqlDate Date in YYMMDD format
|
|
19
|
+
* @param psqlTime Time in HHMM format
|
|
20
|
+
* @returns ISO datetime string or null if invalid
|
|
21
|
+
*/
|
|
22
|
+
export declare function combinePsqlDateTime(psqlDate: string, psqlTime: string): string | null;
|
|
23
|
+
/**
|
|
24
|
+
* Helper to check if a PSQL date is "empty" (000000 or blank)
|
|
25
|
+
*/
|
|
26
|
+
export declare function isPsqlDateEmpty(psqlDate: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Clean and trim PSQL CHAR field (removes trailing spaces)
|
|
29
|
+
* PSQL CHAR fields are fixed-width and padded with spaces
|
|
30
|
+
*/
|
|
31
|
+
export declare function cleanPsqlCharField(value: string | null | undefined): string;
|
|
32
|
+
//# sourceMappingURL=psql-helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"psql-helpers.d.ts","sourceRoot":"","sources":["../../../src/services/psql-erp-service/psql-helpers.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA+B9D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CA4B9D;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CACjC,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,GACf,MAAM,GAAG,IAAI,CASf;AAED;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAEzD;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAK3E"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { PsqlConfiguration } from "./configuration";
|
|
2
|
+
import { ERPResponse } from "../../types/erp-types";
|
|
3
|
+
type PagingParams = {
|
|
4
|
+
limit?: number;
|
|
5
|
+
offset?: number;
|
|
6
|
+
};
|
|
7
|
+
export declare class PsqlService {
|
|
8
|
+
private config;
|
|
9
|
+
private static odbcModule;
|
|
10
|
+
private static odbcLoadError;
|
|
11
|
+
constructor(config: PsqlConfiguration);
|
|
12
|
+
/**
|
|
13
|
+
* Dynamically load the ODBC module with lazy initialization and caching
|
|
14
|
+
* @throws Error with helpful message if ODBC package is not installed
|
|
15
|
+
*/
|
|
16
|
+
private static getOdbc;
|
|
17
|
+
/**
|
|
18
|
+
* Build PSQL ODBC connection string
|
|
19
|
+
* CRITICAL: ServerName must use IP.PORT format (e.g., 10.4.0.11.1583)
|
|
20
|
+
*/
|
|
21
|
+
private buildConnectionString;
|
|
22
|
+
/**
|
|
23
|
+
* Execute a query and return the results
|
|
24
|
+
* Creates a fresh connection for each query to avoid handle corruption
|
|
25
|
+
*
|
|
26
|
+
* SECURITY WARNING: This method executes the provided SQL string as-is.
|
|
27
|
+
* - Parameter binding is NOT implemented; the `params` argument is currently ignored.
|
|
28
|
+
* - Never concatenate untrusted/user-supplied input into `query`.
|
|
29
|
+
* - Doing so can result in SQL injection vulnerabilities and data exposure.
|
|
30
|
+
* If dynamic values are required, ensure they are strictly validated/escaped
|
|
31
|
+
* or implement proper parameterized execution before accepting untrusted input.
|
|
32
|
+
*
|
|
33
|
+
* @param query The SQL query to execute
|
|
34
|
+
* @param params Query parameters (currently unused for PSQL read operations)
|
|
35
|
+
* @param paging Optional paging parameters
|
|
36
|
+
* @returns The entities fetched from the database, along with paging information
|
|
37
|
+
*/
|
|
38
|
+
executePreparedStatement(query: string, params?: Record<string, string>, paging?: PagingParams): Promise<ERPResponse | undefined>;
|
|
39
|
+
/**
|
|
40
|
+
* Transform ODBC result set to array of Record<string, string> instances.
|
|
41
|
+
* IMPORTANT: PSQL CHAR fields are often padded with spaces - we trim them
|
|
42
|
+
*/
|
|
43
|
+
static recordsetToRecords(recordset: any[]): Record<string, string>[];
|
|
44
|
+
/**
|
|
45
|
+
* Handle ODBC errors and provide meaningful messages
|
|
46
|
+
*/
|
|
47
|
+
private handleOdbcError;
|
|
48
|
+
}
|
|
49
|
+
export {};
|
|
50
|
+
//# sourceMappingURL=psql-service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"psql-service.d.ts","sourceRoot":"","sources":["../../../src/services/psql-erp-service/psql-service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACpD,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAIpD,KAAK,YAAY,GAAG;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAiBF,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAoB;IAClC,OAAO,CAAC,MAAM,CAAC,UAAU,CAA2B;IACpD,OAAO,CAAC,MAAM,CAAC,aAAa,CAAsB;gBAEtC,MAAM,EAAE,iBAAiB;IAIrC;;;OAGG;mBACkB,OAAO;IAsC5B;;;OAGG;IACH,OAAO,CAAC,qBAAqB;IAe7B;;;;;;;;;;;;;;;OAeG;IACU,wBAAwB,CACnC,KAAK,EAAE,MAAM,EACb,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,EACnC,MAAM,CAAC,EAAE,YAAY,GACpB,OAAO,CAAC,WAAW,GAAG,SAAS,CAAC;IA8EnC;;;OAGG;WACW,kBAAkB,CAAC,SAAS,EAAE,GAAG,EAAE,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE;IAkB5E;;OAEG;IACH,OAAO,CAAC,eAAe;CA4BxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/services/reporting-service/logger.ts"],"names":[],"mappings":"AA+DA,QAAA,MAAM,MAAM,0BAaV,CAAC;
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../../../src/services/reporting-service/logger.ts"],"names":[],"mappings":"AA+DA,QAAA,MAAM,MAAM,0BAaV,CAAC;AA0DH,eAAO,MAAM,eAAe,GAAI,UAAU,MAAM,EAAE,SAAS,MAAM,SAuChE,CAAC;AAKF,eAAe,MAAM,CAAC"}
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -27,7 +27,7 @@ export { BatchCacheManager } from "../services/caching-service/batch-cache-manag
|
|
|
27
27
|
export { StandardProcessDrivers } from "./standard-process-drivers/";
|
|
28
28
|
export type { WriteEntitiesToMMResult } from "./standard-process-drivers/";
|
|
29
29
|
export { MMBatchValidationError } from "./standard-process-drivers/";
|
|
30
|
-
export { getCachedTimezoneOffset } from "./local-data-store/jobs-shared-data";
|
|
30
|
+
export { getCachedTimezoneOffset, getCachedTimezoneName, } from "./local-data-store/jobs-shared-data";
|
|
31
31
|
export { getInitialLoadComplete, setInitialLoadComplete, } from "./local-data-store/jobs-shared-data";
|
|
32
32
|
/**
|
|
33
33
|
* ERP API utilities
|
|
@@ -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,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,
|
|
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,EACL,uBAAuB,EACvB,qBAAqB,GACtB,MAAM,qCAAqC,CAAC;AAG7C,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"}
|
|
@@ -10,12 +10,26 @@ export declare const readDatabaseLockState: () => Record<string, unknown>;
|
|
|
10
10
|
export declare const writeDatabaseLockState: (data: Record<string, unknown>) => void;
|
|
11
11
|
export declare const getInitialLoadComplete: () => boolean;
|
|
12
12
|
export declare const setInitialLoadComplete: (complete: boolean) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Gets the company's cached current timezone offset (e.g., -5)
|
|
15
|
+
* @returns The cached timezone offset or 0 if not found
|
|
16
|
+
*/
|
|
13
17
|
export declare const getCachedTimezoneOffset: () => number;
|
|
14
18
|
/**
|
|
15
|
-
* Sets the timezone offset in the cache
|
|
19
|
+
* Sets the company's current timezone offset in the cache
|
|
16
20
|
* @param offset The timezone offset in hours
|
|
17
21
|
*/
|
|
18
22
|
export declare const setTimezoneOffsetInCache: (offset: number) => void;
|
|
23
|
+
/**
|
|
24
|
+
* Gets the cached timezone name (e.g., "America/New_York")
|
|
25
|
+
* @returns The cached timezone name or null if not found
|
|
26
|
+
*/
|
|
27
|
+
export declare const getCachedTimezoneName: () => string | null;
|
|
28
|
+
/**
|
|
29
|
+
* Sets the timezone name in the cache
|
|
30
|
+
* @param timezone The timezone name (e.g., "America/New_York")
|
|
31
|
+
*/
|
|
32
|
+
export declare const setTimezoneNameInCache: (timezone: string) => void;
|
|
19
33
|
interface CachedToken {
|
|
20
34
|
token: string;
|
|
21
35
|
expiration: number | null;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"jobs-shared-data.d.ts","sourceRoot":"","sources":["../../../src/utils/local-data-store/jobs-shared-data.ts"],"names":[],"mappings":"AA6CA;;;GAGG;AACH,eAAO,MAAM,qBAAqB,QAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAE9D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GAAI,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,IAEtE,CAAC;AAGF,eAAO,MAAM,sBAAsB,QAAO,OAGzC,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,UAAU,OAAO,KAAG,IAI1D,CAAC;AAEF,eAAO,MAAM,uBAAuB,QAAO,MAG1C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,GAAI,QAAQ,MAAM,KAAG,IAIzD,CAAC;AAEF,UAAU,WAAW;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QAAO,WAAW,GAAG,IAGjD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,WAAW,WAAW,KAAG,IAIzD,CAAC"}
|
|
1
|
+
{"version":3,"file":"jobs-shared-data.d.ts","sourceRoot":"","sources":["../../../src/utils/local-data-store/jobs-shared-data.ts"],"names":[],"mappings":"AA6CA;;;GAGG;AACH,eAAO,MAAM,qBAAqB,QAAO,MAAM,CAAC,MAAM,EAAE,OAAO,CAE9D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GAAI,MAAM,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAG,IAEtE,CAAC;AAGF,eAAO,MAAM,sBAAsB,QAAO,OAGzC,CAAC;AAEF,eAAO,MAAM,sBAAsB,GAAI,UAAU,OAAO,KAAG,IAI1D,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,uBAAuB,QAAO,MAG1C,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,wBAAwB,GAAI,QAAQ,MAAM,KAAG,IAIzD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,QAAO,MAAM,GAAG,IAGjD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,sBAAsB,GAAI,UAAU,MAAM,KAAG,IAIzD,CAAC;AAEF,UAAU,WAAW;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QAAO,WAAW,GAAG,IAGjD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,GAAI,WAAW,WAAW,KAAG,IAIzD,CAAC"}
|
|
@@ -20,8 +20,9 @@ interface TimezoneOffsetParams {
|
|
|
20
20
|
retryIntervalMs: number;
|
|
21
21
|
}
|
|
22
22
|
/**
|
|
23
|
-
* Gets the timezone offset for the company and sets
|
|
23
|
+
* Gets the timezone offset and timezone name for the company and sets them in the cache
|
|
24
24
|
* The cached offset can be acquired from getCachedTimezoneOffset() in "./local-data-store/jobs-shared-data"
|
|
25
|
+
* The cached timezone name can be acquired from getCachedTimezoneName() in "./local-data-store/jobs-shared-data"
|
|
25
26
|
*
|
|
26
27
|
* @param params.maxRetries Maximum number of retry attempts
|
|
27
28
|
* @param params.retryIntervalMs Time to wait between retries in milliseconds
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"time-utils.d.ts","sourceRoot":"","sources":["../../src/utils/time-utils.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"time-utils.d.ts","sourceRoot":"","sources":["../../src/utils/time-utils.ts"],"names":[],"mappings":"AAWA;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAC5C,SAAS,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EACpC,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAClC,cAAc,EAAE,MAAM,GACrB,MAAM,CA2BR;AAED,eAAO,MAAM,eAAe,GAAI,WAAW,MAAM,GAAG,IAAI,kBASvD,CAAC;AAEF;;;;;;GAMG;AAEH,eAAO,MAAM,4BAA4B,GACvC,MAAM,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC5B,QAAQ,MAAM,EAAE,EAChB,gBAAgB,MAAM,KACrB,MAAM,CAAC,MAAM,EAAE,MAAM,CAcvB,CAAC;AAEF,UAAU,oBAAoB;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,eAAe,EAAE,MAAM,CAAC;CACzB;AAED;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,GACtC,SAAQ,oBAGP,KACA,OAAO,CAAC,IAAI,CA2Bd,CAAC"}
|
package/dist/utils/timezone.d.ts
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Gets the timezone offset in hours for the company's timezone
|
|
3
|
-
* @returns Promise<number> The timezone offset in hours
|
|
2
|
+
* Gets the timezone offset in hours and timezone name for the company's timezone
|
|
3
|
+
* @returns Promise<{ offset: number; timezone: string }> The timezone offset in hours and timezone name
|
|
4
4
|
* @throws Error if unable to fetch timezone information
|
|
5
5
|
*/
|
|
6
|
-
export declare const getTimezoneOffset: () => Promise<
|
|
6
|
+
export declare const getTimezoneOffset: () => Promise<{
|
|
7
|
+
offset: number;
|
|
8
|
+
timezone: string;
|
|
9
|
+
}>;
|
|
7
10
|
/**
|
|
8
11
|
* Converts a UTC/Zulu time to local time based on the provided timezone offset
|
|
9
12
|
* @param zuluTime The UTC/Zulu time to convert
|
|
@@ -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,
|
|
1
|
+
{"version":3,"file":"timezone.d.ts","sourceRoot":"","sources":["../../src/utils/timezone.ts"],"names":[],"mappings":"AAGA;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,QAAa,OAAO,CAAC;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAA;CAAE,CAgDtF,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
|
@@ -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.8
|
|
4
|
+
"version": "0.1.8",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "machinemetrics",
|
|
7
7
|
"main": "dist/mm-erp-sdk.js",
|
|
@@ -33,6 +33,9 @@
|
|
|
33
33
|
"xxhashjs": "^0.2.2",
|
|
34
34
|
"zod": "^3.24.1"
|
|
35
35
|
},
|
|
36
|
+
"optionalDependencies": {
|
|
37
|
+
"odbc": "^2.4.8"
|
|
38
|
+
},
|
|
36
39
|
"devDependencies": {
|
|
37
40
|
"@types/json-stable-stringify": "^1.1.0",
|
|
38
41
|
"@types/lodash": "^4.17.10",
|
package/src/index.ts
CHANGED
|
@@ -17,13 +17,13 @@ export type { ERPApiConfig } from "./services/erp-api-services/types";
|
|
|
17
17
|
// MM API client and types
|
|
18
18
|
export { MMApiClient } from "./services/mm-api-service";
|
|
19
19
|
export { MMReceiveLaborTicket } from "./services/mm-api-service";
|
|
20
|
-
export type {
|
|
20
|
+
export type {
|
|
21
21
|
MMReceiveLaborTicketReason,
|
|
22
22
|
MMReceiveLaborTicketWorkOrderOperation,
|
|
23
23
|
IToRESTApiObject,
|
|
24
24
|
} from "./services/mm-api-service";
|
|
25
25
|
|
|
26
|
-
export {
|
|
26
|
+
export {
|
|
27
27
|
MMSendPerson,
|
|
28
28
|
MMSendResource,
|
|
29
29
|
MMSendPart,
|
|
@@ -57,7 +57,11 @@ export { getInitialLoadComplete, setInitialLoadComplete } from "./utils";
|
|
|
57
57
|
// HTTP client factory and types for custom API integrations
|
|
58
58
|
export { HTTPClientFactory } from "./utils/http-client";
|
|
59
59
|
export { HTTPError } from "./utils/http-client";
|
|
60
|
-
export type {
|
|
60
|
+
export type {
|
|
61
|
+
HTTPResponse,
|
|
62
|
+
HTTPClient,
|
|
63
|
+
HTTPRequestConfig,
|
|
64
|
+
} from "./utils/http-client";
|
|
61
65
|
|
|
62
66
|
// Application initialization utilities
|
|
63
67
|
export { ApplicationInitializer } from "./utils/application-initializer";
|
|
@@ -72,12 +76,16 @@ export { logger } from "./services/reporting-service";
|
|
|
72
76
|
export type { IERPLaborTicketHandler } from "./types/erp-connector";
|
|
73
77
|
|
|
74
78
|
// Process drivers and utilities
|
|
75
|
-
export {
|
|
79
|
+
export {
|
|
80
|
+
StandardProcessDrivers,
|
|
81
|
+
getCachedTimezoneOffset,
|
|
82
|
+
getCachedTimezoneName,
|
|
83
|
+
} from "./utils";
|
|
76
84
|
export type { WriteEntitiesToMMResult } from "./utils";
|
|
77
85
|
export { MMBatchValidationError } from "./utils";
|
|
78
86
|
|
|
79
87
|
// API services
|
|
80
|
-
export type { APIResponse } from
|
|
88
|
+
export type { APIResponse } from "./services/erp-api-services/types";
|
|
81
89
|
export { RestAPIService } from "./services/erp-api-services/rest/rest-api-service";
|
|
82
90
|
export { ErrorHandler, GraphQLError } from "./services/erp-api-services/errors";
|
|
83
91
|
export type {
|
|
@@ -105,6 +113,17 @@ export {
|
|
|
105
113
|
} from "./services/sql-server-erp-service";
|
|
106
114
|
export type { SQLInput } from "./services/sql-server-erp-service";
|
|
107
115
|
|
|
116
|
+
// PSQL (Pervasive) services
|
|
117
|
+
export {
|
|
118
|
+
PsqlService,
|
|
119
|
+
formatPsqlDate,
|
|
120
|
+
formatPsqlTime,
|
|
121
|
+
combinePsqlDateTime,
|
|
122
|
+
isPsqlDateEmpty,
|
|
123
|
+
cleanPsqlCharField,
|
|
124
|
+
} from "./services/psql-erp-service";
|
|
125
|
+
export type { PsqlConfiguration } from "./services/psql-erp-service";
|
|
126
|
+
|
|
108
127
|
// Record tracking services
|
|
109
128
|
export { RecordTrackingManager } from "./services/caching-service/record-tracking-manager";
|
|
110
129
|
export type { RecordTrackingObject } from "./services/caching-service/record-tracking-manager";
|
|
@@ -113,4 +132,10 @@ export type { RecordTrackingObject } from "./services/caching-service/record-tra
|
|
|
113
132
|
export { default as knexDatabaseConfig } from "./knexfile";
|
|
114
133
|
|
|
115
134
|
// MM Connector Logging
|
|
116
|
-
export {
|
|
135
|
+
export {
|
|
136
|
+
MMConnectorLogger,
|
|
137
|
+
FileLogDeduper,
|
|
138
|
+
LogEntry,
|
|
139
|
+
type LogLevelString,
|
|
140
|
+
type LogResponse,
|
|
141
|
+
} from "./utils";
|
|
@@ -92,6 +92,39 @@ export class CoreConfiguration {
|
|
|
92
92
|
}
|
|
93
93
|
return CoreConfiguration.instance;
|
|
94
94
|
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Returns a sanitized version of the configuration for safe logging.
|
|
98
|
+
* Masks sensitive fields like authentication tokens.
|
|
99
|
+
*/
|
|
100
|
+
public toSafeLogObject(): Record<string, unknown> {
|
|
101
|
+
const maskSensitiveValue = (value: string): string => {
|
|
102
|
+
if (!value || value.length === 0) {
|
|
103
|
+
return "";
|
|
104
|
+
}
|
|
105
|
+
if (value.length < 6) {
|
|
106
|
+
return "********";
|
|
107
|
+
}
|
|
108
|
+
// Show first 3 and last 3 characters, mask the middle
|
|
109
|
+
return value.substring(0, 3) + "********" + value.substring(value.length - 3);
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
logLevel: this.logLevel,
|
|
114
|
+
erpSystem: this.erpSystem,
|
|
115
|
+
nodeEnv: this.nodeEnv,
|
|
116
|
+
mmERPSvcApiBaseUrl: this.mmERPSvcApiBaseUrl,
|
|
117
|
+
mmApiBaseUrl: this.mmApiBaseUrl,
|
|
118
|
+
mmApiAuthToken: maskSensitiveValue(this.mmApiAuthToken),
|
|
119
|
+
mmApiRetryAttempts: this.mmApiRetryAttempts,
|
|
120
|
+
cacheTTL: this.cacheTTL,
|
|
121
|
+
erpApiPagingLimit: this.erpApiPagingLimit,
|
|
122
|
+
fromErpInterval: this.fromErpInterval,
|
|
123
|
+
toErpInterval: this.toErpInterval,
|
|
124
|
+
retryLaborTicketsInterval: this.retryLaborTicketsInterval,
|
|
125
|
+
cacheExpirationCheckInterval: this.cacheExpirationCheckInterval,
|
|
126
|
+
};
|
|
127
|
+
}
|
|
95
128
|
}
|
|
96
129
|
|
|
97
130
|
/**
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { PsqlService } from "./psql-service";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* A class to manage interactions with PSQL (Pervasive) databases via ODBC
|
|
5
|
+
*/
|
|
6
|
+
export { PsqlService };
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Configuration interface for PSQL connections
|
|
10
|
+
*/
|
|
11
|
+
export type { PsqlConfiguration } from "./configuration";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Helper functions for PSQL data formatting
|
|
15
|
+
*/
|
|
16
|
+
export {
|
|
17
|
+
formatPsqlDate,
|
|
18
|
+
formatPsqlTime,
|
|
19
|
+
combinePsqlDateTime,
|
|
20
|
+
isPsqlDateEmpty,
|
|
21
|
+
cleanPsqlCharField,
|
|
22
|
+
} from "./psql-helpers";
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helper functions for PSQL/Pervasive database operations
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Formats a date from PSQL YYMMDD format to ISO date string
|
|
7
|
+
* @param psqlDate Date in YYMMDD format (e.g., "250105" for Jan 5, 2025)
|
|
8
|
+
* @returns ISO date string (e.g., "2025-01-05") or null if invalid
|
|
9
|
+
*/
|
|
10
|
+
export function formatPsqlDate(psqlDate: string): string | null {
|
|
11
|
+
if (!psqlDate || psqlDate.trim().length !== 6 || psqlDate === "000000") {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
try {
|
|
16
|
+
const year = parseInt(psqlDate.substring(0, 2), 10);
|
|
17
|
+
const month = parseInt(psqlDate.substring(2, 4), 10);
|
|
18
|
+
const day = parseInt(psqlDate.substring(4, 6), 10);
|
|
19
|
+
|
|
20
|
+
// Convert 2-digit year to 4-digit (assuming 2000s)
|
|
21
|
+
const fullYear = year + 2000;
|
|
22
|
+
|
|
23
|
+
// Basic validation
|
|
24
|
+
if (month < 1 || month > 12 || day < 1 || day > 31) {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const date = new Date(fullYear, month - 1, day);
|
|
29
|
+
// Validate that the constructed date matches the input values
|
|
30
|
+
if (
|
|
31
|
+
date.getFullYear() !== fullYear ||
|
|
32
|
+
date.getMonth() !== (month - 1) ||
|
|
33
|
+
date.getDate() !== day
|
|
34
|
+
) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
return date.toISOString().split("T")[0];
|
|
38
|
+
} catch (error) {
|
|
39
|
+
return null;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Formats a time from PSQL HHMM format to HH:MM:SS
|
|
45
|
+
* @param psqlTime Time in HHMM format (e.g., "1430" for 2:30 PM)
|
|
46
|
+
* @returns Time string in HH:MM:SS format or null if invalid
|
|
47
|
+
*/
|
|
48
|
+
export function formatPsqlTime(psqlTime: string): string | null {
|
|
49
|
+
if (!psqlTime) {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
const trimmed = psqlTime.trim();
|
|
53
|
+
if (trimmed.length !== 4) {
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
try {
|
|
57
|
+
const hours = parseInt(trimmed.substring(0, 2), 10);
|
|
58
|
+
const minutes = parseInt(trimmed.substring(2, 4), 10);
|
|
59
|
+
if (
|
|
60
|
+
isNaN(hours) ||
|
|
61
|
+
isNaN(minutes) ||
|
|
62
|
+
hours < 0 ||
|
|
63
|
+
hours > 23 ||
|
|
64
|
+
minutes < 0 ||
|
|
65
|
+
minutes > 59
|
|
66
|
+
) {
|
|
67
|
+
return null;
|
|
68
|
+
}
|
|
69
|
+
// Pad hours and minutes to 2 digits
|
|
70
|
+
const hoursStr = hours.toString().padStart(2, "0");
|
|
71
|
+
const minutesStr = minutes.toString().padStart(2, "0");
|
|
72
|
+
return `${hoursStr}:${minutesStr}:00`;
|
|
73
|
+
} catch (error) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Combines PSQL date and time into ISO datetime string
|
|
80
|
+
* @param psqlDate Date in YYMMDD format
|
|
81
|
+
* @param psqlTime Time in HHMM format
|
|
82
|
+
* @returns ISO datetime string or null if invalid
|
|
83
|
+
*/
|
|
84
|
+
export function combinePsqlDateTime(
|
|
85
|
+
psqlDate: string,
|
|
86
|
+
psqlTime: string
|
|
87
|
+
): string | null {
|
|
88
|
+
const date = formatPsqlDate(psqlDate);
|
|
89
|
+
const time = formatPsqlTime(psqlTime);
|
|
90
|
+
|
|
91
|
+
if (!date || !time) {
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return `${date}T${time}`;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Helper to check if a PSQL date is "empty" (000000 or blank)
|
|
100
|
+
*/
|
|
101
|
+
export function isPsqlDateEmpty(psqlDate: string): boolean {
|
|
102
|
+
return !psqlDate || psqlDate === "000000" || psqlDate.trim() === "";
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Clean and trim PSQL CHAR field (removes trailing spaces)
|
|
107
|
+
* PSQL CHAR fields are fixed-width and padded with spaces
|
|
108
|
+
*/
|
|
109
|
+
export function cleanPsqlCharField(value: string | null | undefined): string {
|
|
110
|
+
if (value === null || value === undefined) {
|
|
111
|
+
return "";
|
|
112
|
+
}
|
|
113
|
+
return String(value).trim();
|
|
114
|
+
}
|