#!/usr/bin/env node /** * Fix asset selection in demo-flow.json so editor dropdowns correctly * pre-select the configured supplier/type/model when a node is opened. * * Issues fixed: * 1. Pump nodes: supplier "Hidrostal" → "hidrostal" (matches machine.json id) * 2. demo_meas_flow: assetType "flow-electromagnetic" → "flow" (matches measurement.json type id) */ const fs = require('fs'); const path = require('path'); const flowPath = path.join(__dirname, '..', 'docker', 'demo-flow.json'); const flow = JSON.parse(fs.readFileSync(flowPath, 'utf8')); let changes = 0; flow.forEach(node => { // Fix 1: Pump supplier id mismatch if (node.type === 'rotatingMachine' && node.supplier === 'Hidrostal') { node.supplier = 'hidrostal'; changes++; console.log(`Fixed pump ${node.id}: supplier "Hidrostal" → "hidrostal"`); } // Fix 2: Standardize flow measurement assetType if (node.type === 'measurement' && node.assetType === 'flow-electromagnetic') { node.assetType = 'flow'; changes++; console.log(`Fixed ${node.id}: assetType "flow-electromagnetic" → "flow"`); } }); fs.writeFileSync(flowPath, JSON.stringify(flow, null, 2) + '\n'); console.log(`\nDone. ${changes} node(s) updated.`);