MCPcopy Create free account
hub / github.com/ForestHubAI/edge-agents / updateOutput

Function updateOutput

ts/workflow-builder/src/utils/functionOperations.ts:141–159  ·  view source on GitHub ↗
(id: string, index: number, patch: { name?: string; dataType?: DataType })

Source from the content-addressed store, hash-verified

139/** Update an output's declaration (name/dataType). A dataType change retags the
140 * bundled expression's dataType but keeps the entered text. */
141export 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
161export function removeOutput(id: string, index: number): void {
162 mutate(id, (fn) => ({ ...fn, outputs: fn.outputs.filter((_, i) => i !== index) }), true);

Callers 1

FunctionConfigPanelFunction · 0.90

Calls 1

mutateFunction · 0.85

Tested by

no test coverage detected