Remove DataService and OfflineDataService, refactor book and character operations to use streamlined handlers in LocalSystem
- Delete `data.service.ts` and `offline-data.service.ts`, consolidating functionality into `LocalSystem`. - Refactor book, character, and conversation operations to adopt unified, multilingual, and session-enabled IPC handlers in `LocalSystem`. - Simplify redundant legacy methods, enhancing maintainability and consistency.
This commit is contained in:
47
electron.d.ts
vendored
47
electron.d.ts
vendored
@@ -1,27 +1,38 @@
|
||||
/**
|
||||
* TypeScript declarations for window.electron API
|
||||
* Must match exactly with electron/preload.ts
|
||||
*
|
||||
* Usage:
|
||||
* - Use invoke<T>(channel, ...args) for all IPC calls
|
||||
* - Shortcuts are provided for common operations (tokens, lang, encryption)
|
||||
*/
|
||||
export interface IElectronAPI {
|
||||
// Platform info
|
||||
platform: NodeJS.Platform;
|
||||
|
||||
// Generic invoke method - use this for all IPC calls
|
||||
invoke: <T = any>(channel: string, ...args: any[]) => Promise<T>;
|
||||
|
||||
// Token management (shortcuts for convenience)
|
||||
getToken: () => Promise<string | null>;
|
||||
setToken: (token: string) => Promise<boolean>;
|
||||
removeToken: () => Promise<boolean>;
|
||||
loginSuccess: (token: string) => void;
|
||||
setToken: (token: string) => Promise<void>;
|
||||
removeToken: () => Promise<void>;
|
||||
|
||||
// Language management (shortcuts for convenience)
|
||||
getLang: () => Promise<'fr' | 'en'>;
|
||||
setLang: (lang: 'fr' | 'en') => Promise<void>;
|
||||
|
||||
// Auth events (one-way communication)
|
||||
loginSuccess: (token: string, userId: string) => void;
|
||||
logout: () => void;
|
||||
|
||||
// Database operations
|
||||
generateEncryptionKey: (userId: string) => Promise<{ success: boolean; key?: string; error?: string }>;
|
||||
// Encryption key management (shortcuts for convenience)
|
||||
generateEncryptionKey: (userId: string) => Promise<string>;
|
||||
getUserEncryptionKey: (userId: string) => Promise<string | null>;
|
||||
setUserEncryptionKey: (userId: string, encryptionKey: string) => Promise<boolean>;
|
||||
dbInitialize: (userId: string, encryptionKey: string) => Promise<{ success: boolean; error?: string }>;
|
||||
dbGetBooks: () => Promise<{ success: boolean; data?: any[]; error?: string }>;
|
||||
dbGetBook: (bookId: string) => Promise<{ success: boolean; data?: any; error?: string }>;
|
||||
dbSaveBook: (book: any, authorId?: string) => Promise<{ success: boolean; error?: string }>;
|
||||
dbDeleteBook: (bookId: string) => Promise<{ success: boolean; error?: string }>;
|
||||
dbSaveChapter: (chapter: any, bookId: string, contentId?: string) => Promise<{ success: boolean; error?: string }>;
|
||||
dbGetCharacters: (bookId: string) => Promise<{ success: boolean; data?: any[]; error?: string }>;
|
||||
dbSaveCharacter: (character: any, bookId: string) => Promise<{ success: boolean; error?: string }>;
|
||||
dbGetConversations: (bookId: string) => Promise<{ success: boolean; data?: any[]; error?: string }>;
|
||||
dbSaveConversation: (conversation: any, bookId: string) => Promise<{ success: boolean; error?: string }>;
|
||||
dbGetSyncStatus: () => Promise<{ success: boolean; data?: any[]; error?: string }>;
|
||||
dbGetPendingChanges: (limit?: number) => Promise<{ success: boolean; data?: any[]; error?: string }>;
|
||||
setUserEncryptionKey: (userId: string, encryptionKey: string) => Promise<void>;
|
||||
|
||||
// Database initialization (shortcut for convenience)
|
||||
dbInitialize: (userId: string, encryptionKey: string) => Promise<boolean>;
|
||||
}
|
||||
|
||||
declare global {
|
||||
|
||||
Reference in New Issue
Block a user