@axiom-lattice/local-stores 3.0.2 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -2168,8 +2168,34 @@ var LocalEvalStore = class {
2168
2168
  return this.getProjectById(tenantId, id);
2169
2169
  }
2170
2170
  async deleteProject(tenantId, id) {
2171
- const result = this.db.prepare(`DELETE FROM lt_eval_projects WHERE tenant_id = ? AND id = ?`).run(tenantId, id);
2172
- return result.changes > 0;
2171
+ const db = this.db.getRawDb();
2172
+ db.run("BEGIN TRANSACTION");
2173
+ try {
2174
+ db.run(
2175
+ `DELETE FROM lt_eval_run_results
2176
+ WHERE run_id IN (
2177
+ SELECT id FROM lt_eval_runs WHERE tenant_id = ? AND project_id = ?
2178
+ )`,
2179
+ [tenantId, id]
2180
+ );
2181
+ db.run(
2182
+ `DELETE FROM lt_eval_cases
2183
+ WHERE tenant_id = ? AND suite_id IN (
2184
+ SELECT id FROM lt_eval_suites WHERE tenant_id = ? AND project_id = ?
2185
+ )`,
2186
+ [tenantId, tenantId, id]
2187
+ );
2188
+ db.run(`DELETE FROM lt_eval_runs WHERE tenant_id = ? AND project_id = ?`, [tenantId, id]);
2189
+ db.run(`DELETE FROM lt_eval_suites WHERE tenant_id = ? AND project_id = ?`, [tenantId, id]);
2190
+ db.run(`DELETE FROM lt_eval_projects WHERE tenant_id = ? AND id = ?`, [tenantId, id]);
2191
+ const deleted = db.getRowsModified() > 0;
2192
+ db.run("COMMIT");
2193
+ this.db.save();
2194
+ return deleted;
2195
+ } catch (error) {
2196
+ db.run("ROLLBACK");
2197
+ throw error;
2198
+ }
2173
2199
  }
2174
2200
  // -------------------------------------------------------------------------
2175
2201
  // Suites