// R2 — Cartographie src/nodes/ ↔ workflow JSON (source de vérité : src/nodes/). // Utilisé par tools/n8n-extract.mjs (JSON → src) et tools/n8n-build.mjs (src → JSON). export const WORKFLOW_FILE = 'workflows/evcs-surplus-controller-v2.6.json'; export const SRC_DIR = 'src/nodes'; export const NODE_MAP = [ { file: 'INPUT_PARSE.js', node: 'INPUT_PARSE', kind: 'jsCode' }, { file: 'WINDOWS_SOURCEV2.js', node: 'WINDOWS_SOURCEV2', kind: 'jsCode' }, { file: 'BATTERY_CLOUD_LOCKS.js', node: 'BATTERY_CLOUD_LOCKS', kind: 'jsCode' }, { file: 'DECISION_ENGINEV2.js', node: 'DECISION_ENGINEV2', kind: 'jsCode' }, { file: 'HA_SERVICE_CALLS_OUTPUT.js', node: 'HA_SERVICE_CALLS_OUTPUT', kind: 'jsCode' }, { file: 'BUILD_ACTIONS.js', node: 'Build EVCS Surplus Controller V2.0 Actions', kind: 'jsCode' }, { file: 'HA_SNAPSHOT_TEMPLATE.json.tpl', node: 'HA Snapshot EVCS Surplus Controller V2.2', kind: 'template' }, ]; export function getCode(workflowNode, kind) { if (kind === 'jsCode') return workflowNode.parameters.jsCode; if (kind === 'template') { return workflowNode.parameters.bodyParameters.parameters.find(p => p.name === 'template').value; } throw new Error(`kind inconnu: ${kind}`); } export function setCode(workflowNode, kind, code) { if (kind === 'jsCode') { workflowNode.parameters.jsCode = code; return; } if (kind === 'template') { workflowNode.parameters.bodyParameters.parameters.find(p => p.name === 'template').value = code; return; } throw new Error(`kind inconnu: ${kind}`); }