Implement foundational vault data models, service, and shared UI components.

This commit is contained in:
Александр Ебаклаков
2026-03-21 22:53:46 +03:00
parent ce6e025d0e
commit d9c148367a
15 changed files with 577 additions and 2 deletions

View File

@@ -0,0 +1,33 @@
import { Account } from './account.model';
import { AccountVisitor } from './visitor.interface';
export class CsvExportVisitor implements AccountVisitor {
private rows: string[] = [];
constructor() {
// Add CSV header
this.rows.push('Service,Login,Password,Notes,UpdatedAt');
}
visitAccount(account: Account): void {
const data = account.decryptedData || {};
const service = this.escapeCsv(account.serviceName);
const login = this.escapeCsv(data['login'] || '');
const password = this.escapeCsv(data['password'] || '');
const notes = this.escapeCsv(data['notes'] || '');
const updatedAt = account.updatedAt.toISOString();
this.rows.push(`${service},${login},${password},${notes},${updatedAt}`);
}
getCsv(): string {
return this.rows.join('\n');
}
private escapeCsv(value: string): string {
if (value.includes(',') || value.includes('"') || value.includes('\n')) {
return `"${value.replace(/"/g, '""')}"`;
}
return value;
}
}