(componentNode: NodeDataSchema, existingData: NodeData)
| 28 | * Port of updateOutdatedNodeData() from packages/ui/src/utils/genericHelper.js:233-351. |
| 29 | */ |
| 30 | export function upgradeNodeData(componentNode: NodeDataSchema, existingData: NodeData): NodeData { |
| 31 | const upgraded = initNode(componentNode, existingData.id, true) |
| 32 | |
| 33 | if (existingData.credential) { |
| 34 | upgraded.credential = existingData.credential |
| 35 | } |
| 36 | |
| 37 | if (existingData.inputs && upgraded.inputs) { |
| 38 | // Preserve matching inputs; also carry over *Config keys (loadConfig accordion side-channel |
| 39 | // values not present in the inputParams schema directly). |
| 40 | for (const key of Object.keys(existingData.inputs)) { |
| 41 | if (key in upgraded.inputs || key.endsWith('Config')) { |
| 42 | upgraded.inputs[key] = existingData.inputs[key] |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 | |
| 47 | upgraded.label = existingData.label |
| 48 | |
| 49 | return upgraded |
| 50 | } |
no test coverage detected