donobu
Version:
Create browser automations with an LLM agent and replay them as Playwright scripts.
58 lines • 1.84 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.EnvPersistenceSqlite = void 0;
/**
* SQLite-backed implementation of {@link EnvPersistence}.
*
* Stores flow environment data in the `environment_data` table (columns:
* `name TEXT PRIMARY KEY`, `value TEXT NOT NULL`). Used as the `"LOCAL"`
* persistence layer when present in `PERSISTENCE_PRIORITY`.
*/
class EnvPersistenceSqlite {
constructor(db) {
this.db = db;
}
static async create(db) {
return new EnvPersistenceSqlite(db);
}
async setEnvironmentDatum(key, value) {
if (!key) {
throw new Error('Key cannot be empty');
}
const stmt = this.db.prepare('INSERT OR REPLACE INTO environment_data (name, value) VALUES (?, ?)');
stmt.run(key, value);
}
async deleteEnvironmentDatum(key) {
if (!key) {
return; // No-op if key is empty
}
const stmt = this.db.prepare('DELETE FROM environment_data WHERE name = ?');
stmt.run(key);
}
async getEnvironmentDatum(key) {
if (!key) {
return undefined;
}
const stmt = this.db.prepare('SELECT value FROM environment_data WHERE name = ?');
const row = stmt.get(key);
return row ? row.value : undefined;
}
/**
* Get all environment data.
*/
async getEnvironmentData() {
const result = {};
const stmt = this.db.prepare('SELECT name, value FROM environment_data');
const rows = stmt.all();
for (const row of rows) {
result[row.name] = row.value;
}
return result;
}
// Database management
close() {
this.db.close();
}
}
exports.EnvPersistenceSqlite = EnvPersistenceSqlite;
//# sourceMappingURL=EnvPersistenceSqlite.js.map