(db: Database, name = 'Untitled design')
| 159 | } |
| 160 | |
| 161 | export function createDesign(db: Database, name = 'Untitled design'): Design { |
| 162 | return mutateStore(db, (data) => { |
| 163 | const now = nowIso(); |
| 164 | const design: Design = { |
| 165 | schemaVersion: 1, |
| 166 | id: crypto.randomUUID(), |
| 167 | name, |
| 168 | createdAt: now, |
| 169 | updatedAt: now, |
| 170 | thumbnailText: null, |
| 171 | deletedAt: null, |
| 172 | workspacePath: null, |
| 173 | }; |
| 174 | data.designs.push(design); |
| 175 | return design; |
| 176 | }); |
| 177 | } |
| 178 | |
| 179 | export function getDesign(db: Database, id: string): Design | null { |
| 180 | return readStore(db).designs.find((design) => design.id === id) ?? null; |
no test coverage detected