/** * Database Interface – abstract DB layer for Web CAD */ export interface DBProject { id: string; name: string; description: string | null; owner_id: string; folder_id: string | null; created_at: string; updated_at: string; } export interface DBProjectFolder { id: string; name: string; parent_id: string | null; owner_id: string; created_at: string; } export interface DBDrawing { id: string; project_id: string; name: string; data_json: string; created_at: string; updated_at: string; } export interface DBLayer { id: string; drawing_id: string; name: string; visible: number; locked: number; color: string; line_type: string; transparency: number; sort_order: number; parent_id: string | null; } export interface DBElement { id: string; drawing_id: string; layer_id: string; type: string; x: number; y: number; width: number; height: number; properties_json: string; created_at: string; } export interface DBBlock { id: string; drawing_id: string; name: string; description: string | null; category: string; elements_json: string; thumbnail: string | null; } export interface DBSetting { key: string; value: string; updated_at: string; } export interface DBUser { id: string; email: string; password_hash: string; name: string; role: string; created_at: string; updated_at: string; } export interface DBSession { token: string; user_id: string; expires_at: number; created_at: string; } export interface DBNotification { id: string; user_id: string; type: string; title: string; message: string; read: number; created_at: string; } export interface DBProjectShare { id: string; project_id: string; shared_with_email: string; shared_by: string; permission: string; share_token: string | null; created_at: string; } export interface DBGlobalBlockFolder { id: string; name: string; parent_id: string | null; created_at: string; } export interface DBGlobalBlock { id: string; folder_id: string | null; name: string; block_data: string; svg_data: string | null; is_favorite: boolean; created_at: string; updated_at: string; } export interface DatabaseInterface { init(): Promise; close(): void; // Users getUser(id: string): DBUser | null; getUserByEmail(email: string): DBUser | null; createUser(data: Partial): DBUser; updateUser(id: string, data: Partial): DBUser | null; deleteUser(id: string): boolean; listUsers(): DBUser[]; // Projects listProjects(ownerId?: string, folderId?: string | null): DBProject[]; getProject(id: string): DBProject | null; createProject(data: Partial): DBProject; updateProject(id: string, data: Partial): DBProject | null; deleteProject(id: string): boolean; moveProjectToFolder(projectId: string, folderId: string | null): DBProject | null; // Project Folders listProjectFolders(ownerId: string): DBProjectFolder[]; getProjectFolder(id: string): DBProjectFolder | null; createProjectFolder(data: Partial): DBProjectFolder; updateProjectFolder(id: string, data: Partial): DBProjectFolder | null; deleteProjectFolder(id: string): boolean; // Drawings listDrawings(projectId: string): DBDrawing[]; getDrawing(id: string): DBDrawing | null; createDrawing(data: Partial): DBDrawing; updateDrawing(id: string, data: Partial): DBDrawing | null; deleteDrawing(id: string): boolean; // Layers listLayers(drawingId: string): DBLayer[]; createLayer(data: Partial): DBLayer; updateLayer(id: string, data: Partial): DBLayer | null; deleteLayer(id: string): boolean; // Elements listElements(drawingId: string): DBElement[]; createElement(data: Partial): DBElement; updateElement(id: string, data: Partial): DBElement | null; deleteElement(id: string): boolean; // Blocks listBlocks(drawingId: string): DBBlock[]; createBlock(data: Partial): DBBlock; updateBlock(id: string, data: Partial): DBBlock | null; deleteBlock(id: string): boolean; // Settings getSetting(key: string): DBSetting | null; setSetting(key: string, value: string): void; // Sessions createSession(data: Partial): DBSession; getSession(token: string): DBSession | null; deleteSession(token: string): boolean; deleteExpiredSessions(): void; // Notifications listNotifications(userId: string): DBNotification[]; getNotification(id: string): DBNotification | null; createNotification(data: Partial): DBNotification; markNotificationRead(id: string): boolean; deleteNotification(id: string): boolean; // Project Shares listProjectShares(projectId: string): DBProjectShare[]; getProjectShare(id: string): DBProjectShare | null; createProjectShare(data: Partial): DBProjectShare; deleteProjectShare(id: string): boolean; // Global Block Folders listGlobalFolders(parentId?: string | null): DBGlobalBlockFolder[]; getGlobalFolder(id: string): DBGlobalBlockFolder | null; createGlobalFolder(data: Partial): DBGlobalBlockFolder; updateGlobalFolder(id: string, data: Partial): DBGlobalBlockFolder | null; deleteGlobalFolder(id: string): boolean; // Global Blocks listGlobalBlocks(folderId?: string | null): DBGlobalBlock[]; getGlobalBlock(id: string): DBGlobalBlock | null; createGlobalBlock(data: Partial): DBGlobalBlock; updateGlobalBlock(id: string, data: Partial): DBGlobalBlock | null; deleteGlobalBlock(id: string): boolean; // Guests (Task E6) listGuests(drawingId: string): DBGuest[]; getGuest(id: string): DBGuest | null; createGuest(data: Partial): DBGuest; updateGuest(id: string, data: Partial): DBGuest | null; deleteGuest(id: string): boolean; } // ─── Guests (Task E6) ────────────────────────────────── export interface DBGuest { id: string; drawing_id: string; name: string; email?: string; category: string; // 'standard' | 'vip' | 'staff' seat_element_id?: string; // Verknüpfung zu einem chair-Element notes?: string; created_at: string; }