| 33 | } |
| 34 | |
| 35 | function createPreset({ uid, title, prompt }) { |
| 36 | const db = sqliteClient.getDb(); |
| 37 | const id = require('crypto').randomUUID(); |
| 38 | const now = Math.floor(Date.now() / 1000); |
| 39 | const query = ` |
| 40 | INSERT INTO prompt_presets (id, uid, title, prompt, is_default, created_at, sync_state) |
| 41 | VALUES (?, ?, ?, ?, 0, ?, 'dirty') |
| 42 | `; |
| 43 | |
| 44 | try { |
| 45 | db.prepare(query).run(id, uid, title, prompt, now); |
| 46 | return { id }; |
| 47 | } catch (err) { |
| 48 | console.error('SQLite: Failed to create preset:', err); |
| 49 | throw err; |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | function updatePreset(id, { title, prompt }, uid) { |
| 54 | const db = sqliteClient.getDb(); |