Extract base config schema to eliminate duplication across nodes #1

Closed
opened 2026-03-11 13:53:59 +00:00 by vps1_gitea_admin · 1 comment

Problem

Every node duplicates the same general/logging/asset config structure in both JSON defaults and _loadConfig() methods. 6 nodes have JSON configs, 2 (reactor/settler) build configs manually.

Solution

Create a base config schema that all nodes inherit from. Each node only defines its domain-specific fields.

Files affected

  • generalFunctions/src/configs/*.json (all 8)
  • All nodeClass.js _loadConfig() methods
  • generalFunctions/src/configs/index.js (ConfigManager)

Acceptance criteria

  • Base schema defines general, logging, functionality, asset sections
  • Node configs only contain domain-specific overrides
  • ConfigManager merges base + node + UI config automatically
  • All existing tests still pass
## Problem Every node duplicates the same general/logging/asset config structure in both JSON defaults and _loadConfig() methods. 6 nodes have JSON configs, 2 (reactor/settler) build configs manually. ## Solution Create a base config schema that all nodes inherit from. Each node only defines its domain-specific fields. ## Files affected - generalFunctions/src/configs/*.json (all 8) - All nodeClass.js _loadConfig() methods - generalFunctions/src/configs/index.js (ConfigManager) ## Acceptance criteria - [ ] Base schema defines general, logging, functionality, asset sections - [ ] Node configs only contain domain-specific overrides - [ ] ConfigManager merges base + node + UI config automatically - [ ] All existing tests still pass
vps1_gitea_admin added the P0-architecture label 2026-03-11 13:53:59 +00:00
Author
Owner

Completed

Changes

  1. baseConfig.json - Shared schema defining general/logging/functionality/asset sections
  2. ConfigManager.buildConfig(nodeName, uiConfig, nodeId, domainConfig) - New method that builds runtime config from UI inputs + domain-specific overrides
  3. All 8 nodeClass files migrated - measurement, pumpingStation, machineGroupControl, valveGroupControl, valve, rotatingMachine, settler, reactor

Before (each node ~25 lines of duplicated config construction)

this.config = {
  general: { name: ..., id: node.id, unit: ..., logging: { ... } },
  asset: { uuid: ..., tagCode: ..., supplier: ..., ... },
  functionality: { positionVsParent: ... },
  // domain-specific...
};

After (1-3 lines per node)

const cfgMgr = new configManager();
this.config = cfgMgr.buildConfig(this.name, uiConfig, node.id, {
  // only domain-specific sections
});

Test results

  • 0 lint errors, 71 warnings
  • 219 tests passing (72 Jest + 23 node:test + 124 legacy)
## Completed ### Changes 1. **`baseConfig.json`** - Shared schema defining general/logging/functionality/asset sections 2. **`ConfigManager.buildConfig(nodeName, uiConfig, nodeId, domainConfig)`** - New method that builds runtime config from UI inputs + domain-specific overrides 3. **All 8 nodeClass files migrated** - measurement, pumpingStation, machineGroupControl, valveGroupControl, valve, rotatingMachine, settler, reactor ### Before (each node ~25 lines of duplicated config construction) ```js this.config = { general: { name: ..., id: node.id, unit: ..., logging: { ... } }, asset: { uuid: ..., tagCode: ..., supplier: ..., ... }, functionality: { positionVsParent: ... }, // domain-specific... }; ``` ### After (1-3 lines per node) ```js const cfgMgr = new configManager(); this.config = cfgMgr.buildConfig(this.name, uiConfig, node.id, { // only domain-specific sections }); ``` ### Test results - 0 lint errors, 71 warnings - 219 tests passing (72 Jest + 23 node:test + 124 legacy)
Sign in to join this conversation.