saveDemoFlow function infrastructure exported
Last updated: 2026-03-05T10:53:28.858Z
Location
Metrics
LOC: 18
Complexity: 4
Params: 1
Signature
saveDemoFlow(flow: FlowScript): : Promise<void>
Summary
Save (upsert) a demo flow. If ID exists, replaces; otherwise appends.
Source Code
export async function saveDemoFlow(flow: FlowScript): Promise<void> {
await updateStorageAtomically<FlowScript[]>(KEY, [], (current) => {
const idx = current.findIndex((f) => f.id === flow.id);
const next = [...current];
if (idx >= 0) {
next[idx] = flow;
} else {
if (next.length >= MAX_FLOWS) {
log.warn(`Max flows (${MAX_FLOWS}) reached — oldest flow removed`);
next.shift();
}
next.push(flow);
}
return next;
});
}