feature/IO-3357-Reynolds-and-Reynolds-DMS-API-Integration - Checkpoint

This commit is contained in:
Dave
2025-10-14 13:23:32 -04:00
parent 6bab792b5e
commit 5a9381ebdb
11 changed files with 754 additions and 911 deletions

View File

@@ -1,6 +1,11 @@
/**
* STAR-only constants for Reynolds & Reynolds (Rome/RCI)
* Used by rr-helpers.js to build and send SOAP requests.
*
* IMPORTANT:
* - Only rr-test.js should fall back to ENV for dealer/store/branch.
* - All runtime code (sockets/routes/jobs) must pass per-bodyshop
* values from the database (see rr-config.js#getRRConfigForBodyshop).
*/
exports.RR_NS = Object.freeze({
@@ -21,6 +26,8 @@ const RR_SOAP_HEADERS = {
"Content-Type": "text/xml; charset=utf-8",
SOAPAction: RR_STAR_SOAP_ACTION
};
// Export if other modules need default STAR headers
exports.RR_SOAP_HEADERS = RR_SOAP_HEADERS;
// All STAR-supported actions (mapped to Mustache templates)
exports.RR_ACTIONS = Object.freeze({
@@ -34,17 +41,37 @@ exports.RR_ACTIONS = Object.freeze({
UpdateRepairOrder: { template: "UpdateRepairOrder" }
});
// Base config loader (environment-driven)
/**
* Base config loader (environment-driven)
*
* ⚠️ Policy:
* - Only rr-test.js should rely on the ENV values for dealer/store/branch.
* - All other call sites must inject per-bodyshop values from DB.
*/
exports.getBaseRRConfig = function getBaseRRConfig() {
return {
baseUrl: process.env.RR_BASE_URL,
username: process.env.RR_USERNAME,
password: process.env.RR_PASSWORD,
ppsysId: process.env.RR_PPSYSID, // optional legacy identifier
// ❗ These are ONLY for rr-test.js fallback.
dealerNumber: process.env.RR_DEALER_NUMBER,
storeNumber: process.env.RR_STORE_NUMBER,
branchNumber: process.env.RR_BRANCH_NUMBER || "01",
wssePasswordType: process.env.RR_WSSE_PASSWORD_TYPE || "Text",
timeout: Number(process.env.RR_TIMEOUT_MS || 30000)
};
};
/**
* Normalize dealer/store/branch field names (camelCase vs snake_case).
* Safe to use in helpers to tolerate mixed callers during migration.
*/
exports.normalizeRRDealerFields = function normalizeRRDealerFields(cfg = {}) {
const dealerNumber = cfg.dealerNumber ?? cfg.dealer_number;
const storeNumber = cfg.storeNumber ?? cfg.store_number;
const branchNumber = cfg.branchNumber ?? cfg.branch_number;
return { dealerNumber, storeNumber, branchNumber };
};