mirror of
https://github.com/siteboon/claudecodeui.git
synced 2026-05-01 18:28:38 +00:00
- Implemented githubTokensDb for managing GitHub tokens with CRUD operations. - Created otificationPreferencesDb to handle user notification preferences. - Added projectsDb for project path management and related operations. - Introduced pushSubscriptionsDb for managing browser push subscriptions. - Developed scanStateDb to track the last scanned timestamp. - Established sessionsDb for session management with CRUD functionalities. - Created userDb for user management, including authentication and onboarding. - Implemented apidKeysDb for storing and managing VAPID keys. feat(database): define schema for new database tables - Added SQL schema definitions for users, API keys, user credentials, notification preferences, VAPID keys, push subscriptions, projects, sessions, scan state, and app configuration. - Included necessary indexes for performance optimization. refactor(shared): enhance type definitions and utility functions - Updated shared types and interfaces for improved clarity and consistency. - Added new types for credential management and provider-specific operations. - Refined utility functions for better error handling and message normalization.
42 lines
1.2 KiB
TypeScript
42 lines
1.2 KiB
TypeScript
import { getConnection } from '@/modules/database/connection.js';
|
|
|
|
type ScanStateRow = {
|
|
last_scanned_at: string;
|
|
};
|
|
|
|
export const scanStateDb = {
|
|
getLastScannedAt() {
|
|
const db = getConnection();
|
|
|
|
const row = db
|
|
.prepare(`SELECT last_scanned_at FROM scan_state WHERE id = 1`)
|
|
.get() as ScanStateRow;
|
|
|
|
if (!row) {
|
|
return null; // Before any scan, the row is undefined.
|
|
}
|
|
|
|
let lastScannedDate: Date | null = null;
|
|
const lastScannedStr = row.last_scanned_at;
|
|
|
|
if (lastScannedStr) {
|
|
// SQLite CURRENT_TIMESTAMP returns UTC in "YYYY-MM-DD HH:MM:SS" format.
|
|
// Replace space with 'T' and append 'Z' to parse reliably in JS across all platforms.
|
|
lastScannedDate = new Date(lastScannedStr.replace(' ', 'T') + 'Z');
|
|
}
|
|
|
|
return lastScannedDate;
|
|
},
|
|
|
|
updateLastScannedAt() {
|
|
const db = getConnection();
|
|
|
|
db.prepare(`
|
|
INSERT INTO scan_state (id, last_scanned_at)
|
|
VALUES (1, CURRENT_TIMESTAMP)
|
|
ON CONFLICT (id)
|
|
DO UPDATE SET last_scanned_at = CURRENT_TIMESTAMP
|
|
`).run();
|
|
}
|
|
};
|