export class VizService {
    db;
    constructor(db) {
        this.db = db;
    }
    create(topicId, title, steps) {
        const stepsJson = JSON.stringify(steps);
        const result = this.db.raw
            .prepare('INSERT INTO visualizations (topic_id, title, steps_json) VALUES (?, ?, ?) RETURNING id')
            .get(topicId, title, stepsJson);
        return this.db.raw
            .prepare('SELECT * FROM visualizations WHERE id = ?')
            .get(result.id);
    }
    listForTopic(topicId) {
        return this.db.raw
            .prepare('SELECT * FROM visualizations WHERE topic_id = ? ORDER BY created_at DESC, id DESC')
            .all(topicId);
    }
}
//# sourceMappingURL=viz.js.map