@machinemetrics/mm-erp-sdk 0.1.8-beta.7 → 0.1.8-beta.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{config-152LkbTv.js → config-cB7h4yvc.js} +2 -2
- package/dist/{config-152LkbTv.js.map → config-cB7h4yvc.js.map} +1 -1
- package/dist/{connector-factory-wivcyMhC.js → connector-factory-CKm74_WZ.js} +2 -2
- package/dist/{connector-factory-wivcyMhC.js.map → connector-factory-CKm74_WZ.js.map} +1 -1
- package/dist/{hashed-cache-manager-BnviJzB7.js → hashed-cache-manager-B1hPBNnF.js} +4 -4
- package/dist/{hashed-cache-manager-BnviJzB7.js.map → hashed-cache-manager-B1hPBNnF.js.map} +1 -1
- package/dist/{index-DNqHWa8F.js → index-DCgheVjV.js} +2 -2
- package/dist/{index-DNqHWa8F.js.map → index-DCgheVjV.js.map} +1 -1
- package/dist/index.d.ts +3 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/{logger-HAWySEbs.js → logger-CBDNtsMq.js} +18 -39
- package/dist/{logger-HAWySEbs.js.map → logger-CBDNtsMq.js.map} +1 -1
- package/dist/mm-erp-sdk.js +6 -223
- package/dist/mm-erp-sdk.js.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.d.ts.map +1 -1
- package/dist/services/data-sync-service/jobs/to-erp.js +3 -3
- package/dist/services/data-sync-service/jobs/to-erp.js.map +1 -1
- package/dist/services/reporting-service/logger.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/package.json +1 -4
- package/src/index.ts +5 -26
- package/src/services/data-sync-service/jobs/to-erp.ts +1 -2
- package/src/services/reporting-service/logger.ts +21 -42
- package/src/types/erp-types.ts +0 -1
- package/dist/services/psql-erp-service/configuration.d.ts +0 -10
- package/dist/services/psql-erp-service/configuration.d.ts.map +0 -1
- package/dist/services/psql-erp-service/index.d.ts +0 -14
- package/dist/services/psql-erp-service/index.d.ts.map +0 -1
- package/dist/services/psql-erp-service/internal/types/psql-types.d.ts +0 -12
- package/dist/services/psql-erp-service/internal/types/psql-types.d.ts.map +0 -1
- package/dist/services/psql-erp-service/psql-helpers.d.ts +0 -32
- package/dist/services/psql-erp-service/psql-helpers.d.ts.map +0 -1
- package/dist/services/psql-erp-service/psql-service.d.ts +0 -43
- package/dist/services/psql-erp-service/psql-service.d.ts.map +0 -1
- package/src/services/psql-erp-service/configuration.ts +0 -9
- package/src/services/psql-erp-service/index.ts +0 -22
- package/src/services/psql-erp-service/internal/types/psql-types.ts +0 -13
- package/src/services/psql-erp-service/psql-helpers.ts +0 -90
- package/src/services/psql-erp-service/psql-service.ts +0 -240
|
@@ -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-B1hPBNnF.js";
|
|
3
|
+
import { S as SQLiteCoordinator } from "../../../index-DCgheVjV.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-DCgheVjV.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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-erp.d.ts","sourceRoot":"","sources":["../../../../src/services/data-sync-service/jobs/to-erp.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"to-erp.d.ts","sourceRoot":"","sources":["../../../../src/services/data-sync-service/jobs/to-erp.ts"],"names":[],"mappings":"AAAA,OAAO,eAAe,CAAC;AAQvB,QAAA,MAAM,IAAI,qBAoCT,CAAC;AAoBF,eAAe,IAAI,CAAC"}
|
|
@@ -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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"to-erp.js","sources":["../../../../src/services/data-sync-service/jobs/to-erp.ts"],"sourcesContent":["import \"dotenv/config\";\n\nimport logger from \"
|
|
1
|
+
{"version":3,"file":"to-erp.js","sources":["../../../../src/services/data-sync-service/jobs/to-erp.ts"],"sourcesContent":["import \"dotenv/config\";\n\nimport logger from \"../../reporting-service/logger\";\nimport { createConnectorFromPath } from \"../../../utils/connector-factory\";\n\n// Configure the logger with the correct log level\nlogger.level = process.env.LOG_LEVEL || \"info\";\n\nconst main = async () => {\n try {\n logger.info('Worker for job \"to-erp\" online');\n logger.info(\"==========Starting to-erp job cycle==========\");\n\n // Get the connector path from the environment variable\n const connectorPath = process.env.CONNECTOR_PATH;\n\n if (!connectorPath) {\n throw new Error(\"Connector path not provided in environment variables\");\n }\n\n // Create a new connector instance for this job\n const connector = await createConnectorFromPath(connectorPath);\n\n await connector.syncToERP();\n await connector.syncToERPCompleted();\n\n logger.info(\"==========Completed to-erp job cycle==========\");\n } catch (error) {\n const errorDetails = {\n message: error instanceof Error ? error.message : String(error),\n stack: error instanceof Error ? error.stack : undefined,\n name: error instanceof Error ? error.name : undefined,\n ...(error && typeof error === \"object\" ? error : {}), // Include all enumerable properties if it's an object\n };\n logger.error('Worker for job \"to-erp\" had an error', {\n error: errorDetails,\n connectorPath: process.env.CONNECTOR_PATH,\n });\n\n // Also log to console for immediate visibility\n console.error(\"to-erp job error:\", error);\n\n throw error; // Rethrow so Bree can handle it properly\n }\n};\n\n// Cross-platform module detection fix for Bree compatibility\n// Windows: process.argv[1] uses backslashes, import.meta.url uses forward slashes\n// Linux/Mac: both use forward slashes, so this normalization is safe\nconst normalizedArgv1 = process.argv[1].replace(/\\\\/g, '/');\nconst fileUrl = normalizedArgv1.startsWith('/') ? \n `file://${normalizedArgv1}` : // Unix: file:// + /path = file:///path\n `file:///${normalizedArgv1}`; // Windows: file:/// + C:/path = file:///C:/path\nconst isMainModule = import.meta.url === fileUrl;\n\nif (isMainModule) {\n // This is called when Bree runs this file as a worker\n try {\n await main();\n } catch {\n process.exitCode = 1; // prefer exitCode so stdout/stderr can flush\n }\n}\n\nexport default main;\n"],"names":[],"mappings":";;;AAMA,OAAO,QAAQ,QAAQ,IAAI,aAAa;AAExC,MAAM,OAAO,YAAY;AACvB,MAAI;AACF,WAAO,KAAK,gCAAgC;AAC5C,WAAO,KAAK,+CAA+C;AAG3D,UAAM,gBAAgB,QAAQ,IAAI;AAElC,QAAI,CAAC,eAAe;AAClB,YAAM,IAAI,MAAM,sDAAsD;AAAA,IACxE;AAGA,UAAM,YAAY,MAAM,wBAAwB,aAAa;AAE7D,UAAM,UAAU,UAAA;AAChB,UAAM,UAAU,mBAAA;AAEhB,WAAO,KAAK,gDAAgD;AAAA,EAC9D,SAAS,OAAO;AACd,UAAM,eAAe;AAAA,MACnB,SAAS,iBAAiB,QAAQ,MAAM,UAAU,OAAO,KAAK;AAAA,MAC9D,OAAO,iBAAiB,QAAQ,MAAM,QAAQ;AAAA,MAC9C,MAAM,iBAAiB,QAAQ,MAAM,OAAO;AAAA,MAC5C,GAAI,SAAS,OAAO,UAAU,WAAW,QAAQ,CAAA;AAAA;AAAA,IAAC;AAEpD,WAAO,MAAM,wCAAwC;AAAA,MACnD,OAAO;AAAA,MACP,eAAe,QAAQ,IAAI;AAAA,IAAA,CAC5B;AAGD,YAAQ,MAAM,qBAAqB,KAAK;AAExC,UAAM;AAAA,EACR;AACF;AAKA,MAAM,kBAAkB,QAAQ,KAAK,CAAC,EAAE,QAAQ,OAAO,GAAG;AAC1D,MAAM,UAAU,gBAAgB,WAAW,GAAG,IAC5C,UAAU,eAAe;AAAA;AAAA,EACzB,WAAW,eAAe;AAAA;AAC5B,MAAM,eAAe,YAAY,QAAQ;AAEzC,IAAI,cAAc;AAEhB,MAAI;AACF,UAAM,KAAA;AAAA,EACR,QAAQ;AACN,YAAQ,WAAW;AAAA,EACrB;AACF;"}
|
|
@@ -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"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"erp-types.d.ts","sourceRoot":"","sources":["../../src/types/erp-types.ts"],"names":[],"mappings":"AACA,oBAAY,OAAO;IACjB,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,QAAQ,aAAa;
|
|
1
|
+
{"version":3,"file":"erp-types.d.ts","sourceRoot":"","sources":["../../src/types/erp-types.ts"],"names":[],"mappings":"AACA,oBAAY,OAAO;IACjB,OAAO,YAAY;IACnB,IAAI,SAAS;IACb,QAAQ,aAAa;IACrB,SAAS,cAAc;IACvB,OAAO,YAAY;IACnB,QAAQ,aAAa;IACrB,QAAQ,aAAa;CACtB;AAED,oBAAY,UAAU;IACpB,SAAS,IAAA;IACT,KAAK,IAAA;IACL,cAAc,IAAA;IACd,WAAW,IAAA;IACX,qBAAqB,IAAA;IACrB,OAAO,IAAA;IACP,OAAO,IAAA;IACP,aAAa,IAAA;CAEd;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,GAAG,SAAS,CAAC;IAC7B,YAAY,EAAE,MAAM,GAAG,SAAS,CAAC;IACjC,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,CAAC;IAC/B,MAAM,EAAE,aAAa,CAAC;CACvB;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,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-beta.
|
|
4
|
+
"version": "0.1.8-beta.9",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "machinemetrics",
|
|
7
7
|
"main": "dist/mm-erp-sdk.js",
|
|
@@ -33,9 +33,6 @@
|
|
|
33
33
|
"xxhashjs": "^0.2.2",
|
|
34
34
|
"zod": "^3.24.1"
|
|
35
35
|
},
|
|
36
|
-
"optionalDependencies": {
|
|
37
|
-
"odbc": "^2.4.8"
|
|
38
|
-
},
|
|
39
36
|
"devDependencies": {
|
|
40
37
|
"@types/json-stable-stringify": "^1.1.0",
|
|
41
38
|
"@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,11 +57,7 @@ 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 {
|
|
61
|
-
HTTPResponse,
|
|
62
|
-
HTTPClient,
|
|
63
|
-
HTTPRequestConfig,
|
|
64
|
-
} from "./utils/http-client";
|
|
60
|
+
export type { HTTPResponse, HTTPClient, HTTPRequestConfig } from "./utils/http-client";
|
|
65
61
|
|
|
66
62
|
// Application initialization utilities
|
|
67
63
|
export { ApplicationInitializer } from "./utils/application-initializer";
|
|
@@ -81,7 +77,7 @@ export type { WriteEntitiesToMMResult } from "./utils";
|
|
|
81
77
|
export { MMBatchValidationError } from "./utils";
|
|
82
78
|
|
|
83
79
|
// API services
|
|
84
|
-
export type { APIResponse } from
|
|
80
|
+
export type { APIResponse } from './services/erp-api-services/types';
|
|
85
81
|
export { RestAPIService } from "./services/erp-api-services/rest/rest-api-service";
|
|
86
82
|
export { ErrorHandler, GraphQLError } from "./services/erp-api-services/errors";
|
|
87
83
|
export type {
|
|
@@ -109,17 +105,6 @@ export {
|
|
|
109
105
|
} from "./services/sql-server-erp-service";
|
|
110
106
|
export type { SQLInput } from "./services/sql-server-erp-service";
|
|
111
107
|
|
|
112
|
-
// PSQL (Pervasive) services
|
|
113
|
-
export {
|
|
114
|
-
PsqlService,
|
|
115
|
-
formatPsqlDate,
|
|
116
|
-
formatPsqlTime,
|
|
117
|
-
combinePsqlDateTime,
|
|
118
|
-
isPsqlDateEmpty,
|
|
119
|
-
cleanPsqlCharField,
|
|
120
|
-
} from "./services/psql-erp-service";
|
|
121
|
-
export type { PsqlConfiguration } from "./services/psql-erp-service";
|
|
122
|
-
|
|
123
108
|
// Record tracking services
|
|
124
109
|
export { RecordTrackingManager } from "./services/caching-service/record-tracking-manager";
|
|
125
110
|
export type { RecordTrackingObject } from "./services/caching-service/record-tracking-manager";
|
|
@@ -128,10 +113,4 @@ export type { RecordTrackingObject } from "./services/caching-service/record-tra
|
|
|
128
113
|
export { default as knexDatabaseConfig } from "./knexfile";
|
|
129
114
|
|
|
130
115
|
// MM Connector Logging
|
|
131
|
-
export {
|
|
132
|
-
MMConnectorLogger,
|
|
133
|
-
FileLogDeduper,
|
|
134
|
-
LogEntry,
|
|
135
|
-
type LogLevelString,
|
|
136
|
-
type LogResponse,
|
|
137
|
-
} from "./utils";
|
|
116
|
+
export { MMConnectorLogger, FileLogDeduper, LogEntry, type LogLevelString, type LogResponse } from './utils';
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import "dotenv/config";
|
|
2
2
|
|
|
3
|
-
import logger from "
|
|
4
|
-
import { SQLiteCoordinator } from "../../sqlite-service";
|
|
3
|
+
import logger from "../../reporting-service/logger";
|
|
5
4
|
import { createConnectorFromPath } from "../../../utils/connector-factory";
|
|
6
5
|
|
|
7
6
|
// Configure the logger with the correct log level
|
|
@@ -98,56 +98,35 @@ function attachRotateMitigation(
|
|
|
98
98
|
transport.on("rotate", (_old: string, _new: string) => {
|
|
99
99
|
if (isRefreshing) return;
|
|
100
100
|
isRefreshing = true;
|
|
101
|
-
|
|
101
|
+
let removalTimer: NodeJS.Timeout | null = null;
|
|
102
102
|
|
|
103
|
-
|
|
104
|
-
let timeout: NodeJS.Timeout | null = setTimeout(() => {
|
|
105
|
-
(logger as any).silent = false;
|
|
106
|
-
isRefreshing = false;
|
|
107
|
-
console.warn(
|
|
108
|
-
'[logger] Refresh timeout: resuming logging after 10s without "new" event.'
|
|
109
|
-
);
|
|
110
|
-
}, REFRESH_TIMEOUT_MS);
|
|
111
|
-
|
|
112
|
-
// Close and clear existing file transports
|
|
113
|
-
const existing = (logger.transports || []).filter(
|
|
114
|
-
(t: any) => t instanceof DailyRotateFile
|
|
115
|
-
);
|
|
116
|
-
for (const t of existing) {
|
|
117
|
-
const s = (t as any).logStream;
|
|
118
|
-
if (s && typeof s.end === "function") {
|
|
119
|
-
try {
|
|
120
|
-
s.end();
|
|
121
|
-
} catch {}
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
logger.clear();
|
|
125
|
-
|
|
126
|
-
// Create replacement, attach mitigation for future rotations
|
|
103
|
+
// Create replacement first to avoid any logging gap
|
|
127
104
|
const next = createFileTransport();
|
|
105
|
+
// When the new file is created, remove the old transport
|
|
128
106
|
next.on("new", () => {
|
|
129
|
-
if (
|
|
130
|
-
clearTimeout(
|
|
131
|
-
|
|
107
|
+
if (removalTimer) {
|
|
108
|
+
clearTimeout(removalTimer);
|
|
109
|
+
removalTimer = null;
|
|
132
110
|
}
|
|
133
|
-
|
|
111
|
+
try {
|
|
112
|
+
logger.remove(transport);
|
|
113
|
+
} catch {}
|
|
134
114
|
isRefreshing = false;
|
|
135
115
|
});
|
|
136
116
|
attachRotateMitigation(next, opts);
|
|
137
|
-
|
|
138
117
|
logger.add(next);
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
118
|
+
|
|
119
|
+
// Fallback: if the "new" event doesn't fire, remove the old transport after a grace period
|
|
120
|
+
const REMOVAL_GRACE_MS = 30000;
|
|
121
|
+
removalTimer = setTimeout(() => {
|
|
122
|
+
try {
|
|
123
|
+
logger.remove(transport);
|
|
124
|
+
} catch {}
|
|
125
|
+
isRefreshing = false;
|
|
126
|
+
removalTimer = null;
|
|
127
|
+
}, REMOVAL_GRACE_MS);
|
|
128
|
+
|
|
129
|
+
// Keep console and other transports intact; do not silence or clear
|
|
151
130
|
logger.level = logLevel;
|
|
152
131
|
});
|
|
153
132
|
}
|
package/src/types/erp-types.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
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;IACjB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB"}
|
|
@@ -1,14 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,12 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,32 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,CAuB9D;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAY9D;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"}
|
|
@@ -1,43 +0,0 @@
|
|
|
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
|
-
* @param query The SQL query to execute
|
|
27
|
-
* @param params Query parameters (currently unused for PSQL read operations)
|
|
28
|
-
* @param paging Optional paging parameters
|
|
29
|
-
* @returns The entities fetched from the database, along with paging information
|
|
30
|
-
*/
|
|
31
|
-
executePreparedStatement(query: string, params?: Record<string, string>, paging?: PagingParams): Promise<ERPResponse | undefined>;
|
|
32
|
-
/**
|
|
33
|
-
* Transform ODBC result set to array of Record<string, string> instances.
|
|
34
|
-
* IMPORTANT: PSQL CHAR fields are often padded with spaces - we trim them
|
|
35
|
-
*/
|
|
36
|
-
static recordsetToRecords(recordset: any[]): Record<string, string>[];
|
|
37
|
-
/**
|
|
38
|
-
* Handle ODBC errors and provide meaningful messages
|
|
39
|
-
*/
|
|
40
|
-
private handleOdbcError;
|
|
41
|
-
}
|
|
42
|
-
export {};
|
|
43
|
-
//# sourceMappingURL=psql-service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
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;;;;;;;;OAQG;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,22 +0,0 @@
|
|
|
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";
|
|
@@ -1,90 +0,0 @@
|
|
|
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 === "000000" || psqlDate.trim() === "") {
|
|
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
|
-
return date.toISOString().split("T")[0];
|
|
30
|
-
} catch (error) {
|
|
31
|
-
return null;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Formats a time from PSQL HHMM format to HH:MM:SS
|
|
37
|
-
* @param psqlTime Time in HHMM format (e.g., "1430" for 2:30 PM)
|
|
38
|
-
* @returns Time string in HH:MM:SS format or null if invalid
|
|
39
|
-
*/
|
|
40
|
-
export function formatPsqlTime(psqlTime: string): string | null {
|
|
41
|
-
if (!psqlTime || psqlTime.trim() === "") {
|
|
42
|
-
return null;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
const hours = psqlTime.substring(0, 2);
|
|
47
|
-
const minutes = psqlTime.substring(2, 4);
|
|
48
|
-
return `${hours}:${minutes}:00`;
|
|
49
|
-
} catch (error) {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* Combines PSQL date and time into ISO datetime string
|
|
56
|
-
* @param psqlDate Date in YYMMDD format
|
|
57
|
-
* @param psqlTime Time in HHMM format
|
|
58
|
-
* @returns ISO datetime string or null if invalid
|
|
59
|
-
*/
|
|
60
|
-
export function combinePsqlDateTime(
|
|
61
|
-
psqlDate: string,
|
|
62
|
-
psqlTime: string
|
|
63
|
-
): string | null {
|
|
64
|
-
const date = formatPsqlDate(psqlDate);
|
|
65
|
-
const time = formatPsqlTime(psqlTime);
|
|
66
|
-
|
|
67
|
-
if (!date || !time) {
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
return `${date}T${time}`;
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Helper to check if a PSQL date is "empty" (000000 or blank)
|
|
76
|
-
*/
|
|
77
|
-
export function isPsqlDateEmpty(psqlDate: string): boolean {
|
|
78
|
-
return !psqlDate || psqlDate === "000000" || psqlDate.trim() === "";
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* Clean and trim PSQL CHAR field (removes trailing spaces)
|
|
83
|
-
* PSQL CHAR fields are fixed-width and padded with spaces
|
|
84
|
-
*/
|
|
85
|
-
export function cleanPsqlCharField(value: string | null | undefined): string {
|
|
86
|
-
if (value === null || value === undefined) {
|
|
87
|
-
return "";
|
|
88
|
-
}
|
|
89
|
-
return String(value).trim();
|
|
90
|
-
}
|