(dbPath: string = QODEX_TXN_DB, blobsDir: string = QODEX_BLOBS_DIR)
| 280 | return this.ops; |
| 281 | } |
| 282 | |
| 283 | private ensureOpen(): void { |
| 284 | if (this.status !== 'open') { |
| 285 | throw new Error(`Transaction ${this.id} is ${this.status}`); |
| 286 | } |
| 287 | } |
| 288 | |
| 289 | private autoSummary(): string { |
| 290 | const first = this.ops.slice(0, 3).map(o => `${o.operation} ${path.basename(o.path)}`).join(', '); |
| 291 | return first + (this.ops.length > 3 ? ` +${this.ops.length - 3} more` : ''); |
| 292 | } |
| 293 | } |
| 294 | |
| 295 | export class TransactionJournal { |
| 296 | readonly db: Database.Database; |
| 297 | private blobsDir: string; |
| 298 | private writeStmt: Database.Statement; |
| 299 | private incrementStmt: Database.Statement; |
| 300 | private getNextIdStmt: Database.Statement; |
| 301 | private markRolledBackStmt: Database.Statement; |
| 302 | |
| 303 | constructor(dbPath: string = QODEX_TXN_DB, blobsDir: string = QODEX_BLOBS_DIR) { |
| 304 | this.db = openDatabase(dbPath); |
| 305 | this.db.exec(SCHEMA); |
| 306 | |
| 307 | // Idempotent migrations: add columns if upgrading from v0.1.0 |
| 308 | const existingCols = this.db.prepare("PRAGMA table_info(transactions)").all() as Array<{ name: string }>; |
| 309 | const colNames = new Set(existingCols.map(c => c.name)); |
nothing calls this directly
no test coverage detected