donobu
Version:
Create browser automations with an LLM agent and replay them as Playwright scripts.
35 lines • 1.36 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.GptConfigsPersistenceSqlite = void 0;
const GptConfigNotFoundException_1 = require("../exceptions/GptConfigNotFoundException");
class GptConfigsPersistenceSqlite {
constructor(db) {
this.db = db;
}
static async create(db) {
return new GptConfigsPersistenceSqlite(db);
}
async set(name, config) {
const stmt = this.db.prepare('INSERT OR REPLACE INTO gpt_configs (name, config) VALUES (?, ?)');
stmt.run(name, JSON.stringify(config));
}
async get(name) {
const stmt = this.db.prepare('SELECT config FROM gpt_configs WHERE name = ?');
const row = stmt.get(name);
if (!row) {
throw new GptConfigNotFoundException_1.GptConfigNotFoundException(name);
}
return JSON.parse(row.config);
}
async getAll() {
const stmt = this.db.prepare('SELECT name, config FROM gpt_configs');
const rows = stmt.all();
return new Map(rows.map((row) => [row.name, JSON.parse(row.config)]));
}
async delete(name) {
const stmt = this.db.prepare('DELETE FROM gpt_configs WHERE name = ?');
stmt.run(name);
}
}
exports.GptConfigsPersistenceSqlite = GptConfigsPersistenceSqlite;
//# sourceMappingURL=GptConfigsPersistenceSqlite.js.map