- Add comprehensive IPC handlers for database operations like books, chapters, characters, and conversations. - Implement local database initialization and user data encryption. - Update preload script paths for consistent environment handling. - Modify `page.tsx` to initialize local database within Electron environment. - Add new dependencies including `node-sqlite3-wasm` and `electron-rebuild`.
34 lines
1.8 KiB
TypeScript
34 lines
1.8 KiB
TypeScript
export interface IElectronAPI {
|
|
platform: NodeJS.Platform;
|
|
getToken: () => Promise<string | null>;
|
|
setToken: (token: string) => Promise<boolean>;
|
|
removeToken: () => Promise<boolean>;
|
|
loginSuccess: (token: string) => void;
|
|
logout: () => void;
|
|
|
|
// Database operations
|
|
generateEncryptionKey: (userId: string) => Promise<{ success: boolean; key?: string; error?: 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 }>;
|
|
}
|
|
|
|
declare global {
|
|
interface Window {
|
|
electron: IElectronAPI;
|
|
}
|
|
}
|
|
|
|
export {};
|