saveDemoFlow function infrastructure exported

Last updated: 2026-03-05T10:53:28.858Z

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;
  });
}

No outgoing dependencies.

Impact (Incoming)

graph LR saveDemoFlow["saveDemoFlow"] handle["handle"] makeFlow["makeFlow"] handle -->|uses| saveDemoFlow makeFlow -->|uses| saveDemoFlow style saveDemoFlow fill:#dbeafe,stroke:#2563eb,stroke-width:2px click saveDemoFlow "9e1045b40d770fef.html" click handle "3b3925f07e1ac5c3.html" click makeFlow "dbc7481d1e84d982.html"
SourceType
handle uses
makeFlow uses