saveForm function infrastructure exported ✓ 100.0%
Last updated: 2026-03-01T23:25:47.133Z
Metrics
LOC: 18
Complexity: 3
Params: 1
Coverage: 100.0% (7/7 lines, 5x executed)
Signature
saveForm(form: SavedForm): : Promise<void>
Summary
Saves a form template (upsert). Updates timestamps appropriately.
Tags
#@param form - The saved form to persist
Source Code
export async function saveForm(form: SavedForm): Promise<void> {
await updateStorageAtomically(
STORAGE_KEYS.SAVED_FORMS,
[] as SavedForm[],
(forms) => {
const next = [...forms];
const existingIndex = next.findIndex((f) => f.id === form.id);
if (existingIndex >= 0) {
next[existingIndex] = { ...form, updatedAt: Date.now() };
} else {
next.push({ ...form, createdAt: Date.now(), updatedAt: Date.now() });
}
return next;
},
);
}
Dependencies (Outgoing)
| Target | Type |
|---|---|
| updateStorageAtomically | calls |
Impact (Incoming)
| Source | Type |
|---|---|
| FillableElement | uses |
| handle | uses |