(id: string, index: number, patch: { name?: string; dataType?: DataType })
| 139 | /** Update an output's declaration (name/dataType). A dataType change retags the |
| 140 | * bundled expression's dataType but keeps the entered text. */ |
| 141 | export function updateOutput(id: string, index: number, patch: { name?: string; dataType?: DataType }): void { |
| 142 | mutate( |
| 143 | id, |
| 144 | (fn) => { |
| 145 | const existing = fn.outputs[index]; |
| 146 | if (!existing) return fn; |
| 147 | const dataType = patch.dataType ?? existing.dataType; |
| 148 | const next = [...fn.outputs]; |
| 149 | next[index] = { |
| 150 | ...existing, |
| 151 | ...patch, |
| 152 | dataType, |
| 153 | expression: patch.dataType ? { ...existing.expression, dataType } : existing.expression, |
| 154 | }; |
| 155 | return { ...fn, outputs: next }; |
| 156 | }, |
| 157 | true, |
| 158 | ); |
| 159 | } |
| 160 | |
| 161 | export function removeOutput(id: string, index: number): void { |
| 162 | mutate(id, (fn) => ({ ...fn, outputs: fn.outputs.filter((_, i) => i !== index) }), true); |
no test coverage detected