2026-06-26 10:50:24 +02:00
|
|
|
|
/**
|
|
|
|
|
|
* Database Interface – abstract DB layer for Web CAD
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
export interface DBProject {
|
|
|
|
|
|
id: string;
|
|
|
|
|
|
name: string;
|
|
|
|
|
|
description: string | null;
|
|
|
|
|
|
owner_id: string;
|
2026-07-04 16:43:55 +02:00
|
|
|
|
folder_id: string | null;
|
2026-06-26 10:50:24 +02:00
|
|
|
|
created_at: string;
|
|
|
|
|
|
updated_at: string;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-04 16:43:55 +02:00
|
|
|
|
export interface DBProjectFolder {
|
|
|
|
|
|
id: string;
|
|
|
|
|
|
name: string;
|
|
|
|
|
|
parent_id: string | null;
|
|
|
|
|
|
owner_id: string;
|
|
|
|
|
|
created_at: string;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-26 10:50:24 +02:00
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-26 14:55:38 +02:00
|
|
|
|
export interface DBSession {
|
|
|
|
|
|
token: string;
|
|
|
|
|
|
user_id: string;
|
|
|
|
|
|
expires_at: number;
|
|
|
|
|
|
created_at: string;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-04 16:08:51 +02:00
|
|
|
|
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;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-07-04 16:43:55 +02:00
|
|
|
|
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;
|
|
|
|
|
|
created_at: string;
|
|
|
|
|
|
updated_at: string;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-06-26 10:50:24 +02:00
|
|
|
|
export interface DatabaseInterface {
|
|
|
|
|
|
init(): Promise<void>;
|
|
|
|
|
|
close(): void;
|
|
|
|
|
|
|
|
|
|
|
|
// Users
|
|
|
|
|
|
getUser(id: string): DBUser | null;
|
|
|
|
|
|
getUserByEmail(email: string): DBUser | null;
|
|
|
|
|
|
createUser(data: Partial<DBUser>): DBUser;
|
|
|
|
|
|
updateUser(id: string, data: Partial<DBUser>): DBUser | null;
|
|
|
|
|
|
deleteUser(id: string): boolean;
|
|
|
|
|
|
listUsers(): DBUser[];
|
|
|
|
|
|
|
|
|
|
|
|
// Projects
|
2026-07-04 16:43:55 +02:00
|
|
|
|
listProjects(ownerId?: string, folderId?: string | null): DBProject[];
|
2026-06-26 10:50:24 +02:00
|
|
|
|
getProject(id: string): DBProject | null;
|
|
|
|
|
|
createProject(data: Partial<DBProject>): DBProject;
|
|
|
|
|
|
updateProject(id: string, data: Partial<DBProject>): DBProject | null;
|
|
|
|
|
|
deleteProject(id: string): boolean;
|
2026-07-04 16:43:55 +02:00
|
|
|
|
moveProjectToFolder(projectId: string, folderId: string | null): DBProject | null;
|
|
|
|
|
|
|
|
|
|
|
|
// Project Folders
|
|
|
|
|
|
listProjectFolders(ownerId: string): DBProjectFolder[];
|
|
|
|
|
|
getProjectFolder(id: string): DBProjectFolder | null;
|
|
|
|
|
|
createProjectFolder(data: Partial<DBProjectFolder>): DBProjectFolder;
|
|
|
|
|
|
updateProjectFolder(id: string, data: Partial<DBProjectFolder>): DBProjectFolder | null;
|
|
|
|
|
|
deleteProjectFolder(id: string): boolean;
|
2026-06-26 10:50:24 +02:00
|
|
|
|
|
|
|
|
|
|
// Drawings
|
|
|
|
|
|
listDrawings(projectId: string): DBDrawing[];
|
|
|
|
|
|
getDrawing(id: string): DBDrawing | null;
|
|
|
|
|
|
createDrawing(data: Partial<DBDrawing>): DBDrawing;
|
|
|
|
|
|
updateDrawing(id: string, data: Partial<DBDrawing>): DBDrawing | null;
|
|
|
|
|
|
deleteDrawing(id: string): boolean;
|
|
|
|
|
|
|
|
|
|
|
|
// Layers
|
|
|
|
|
|
listLayers(drawingId: string): DBLayer[];
|
|
|
|
|
|
createLayer(data: Partial<DBLayer>): DBLayer;
|
|
|
|
|
|
updateLayer(id: string, data: Partial<DBLayer>): DBLayer | null;
|
|
|
|
|
|
deleteLayer(id: string): boolean;
|
|
|
|
|
|
|
|
|
|
|
|
// Elements
|
|
|
|
|
|
listElements(drawingId: string): DBElement[];
|
|
|
|
|
|
createElement(data: Partial<DBElement>): DBElement;
|
|
|
|
|
|
updateElement(id: string, data: Partial<DBElement>): DBElement | null;
|
|
|
|
|
|
deleteElement(id: string): boolean;
|
|
|
|
|
|
|
|
|
|
|
|
// Blocks
|
|
|
|
|
|
listBlocks(drawingId: string): DBBlock[];
|
|
|
|
|
|
createBlock(data: Partial<DBBlock>): DBBlock;
|
|
|
|
|
|
updateBlock(id: string, data: Partial<DBBlock>): DBBlock | null;
|
|
|
|
|
|
deleteBlock(id: string): boolean;
|
|
|
|
|
|
|
|
|
|
|
|
// Settings
|
|
|
|
|
|
getSetting(key: string): DBSetting | null;
|
|
|
|
|
|
setSetting(key: string, value: string): void;
|
2026-06-26 14:55:38 +02:00
|
|
|
|
|
|
|
|
|
|
// Sessions
|
|
|
|
|
|
createSession(data: Partial<DBSession>): DBSession;
|
|
|
|
|
|
getSession(token: string): DBSession | null;
|
|
|
|
|
|
deleteSession(token: string): boolean;
|
|
|
|
|
|
deleteExpiredSessions(): void;
|
2026-07-04 16:08:51 +02:00
|
|
|
|
|
|
|
|
|
|
// Notifications
|
|
|
|
|
|
listNotifications(userId: string): DBNotification[];
|
|
|
|
|
|
getNotification(id: string): DBNotification | null;
|
|
|
|
|
|
createNotification(data: Partial<DBNotification>): DBNotification;
|
|
|
|
|
|
markNotificationRead(id: string): boolean;
|
|
|
|
|
|
deleteNotification(id: string): boolean;
|
|
|
|
|
|
|
|
|
|
|
|
// Project Shares
|
|
|
|
|
|
listProjectShares(projectId: string): DBProjectShare[];
|
|
|
|
|
|
getProjectShare(id: string): DBProjectShare | null;
|
|
|
|
|
|
createProjectShare(data: Partial<DBProjectShare>): DBProjectShare;
|
|
|
|
|
|
deleteProjectShare(id: string): boolean;
|
2026-07-04 16:43:55 +02:00
|
|
|
|
|
|
|
|
|
|
// Global Block Folders
|
|
|
|
|
|
listGlobalFolders(parentId?: string | null): DBGlobalBlockFolder[];
|
|
|
|
|
|
getGlobalFolder(id: string): DBGlobalBlockFolder | null;
|
|
|
|
|
|
createGlobalFolder(data: Partial<DBGlobalBlockFolder>): DBGlobalBlockFolder;
|
|
|
|
|
|
updateGlobalFolder(id: string, data: Partial<DBGlobalBlockFolder>): DBGlobalBlockFolder | null;
|
|
|
|
|
|
deleteGlobalFolder(id: string): boolean;
|
|
|
|
|
|
|
|
|
|
|
|
// Global Blocks
|
|
|
|
|
|
listGlobalBlocks(folderId?: string | null): DBGlobalBlock[];
|
|
|
|
|
|
getGlobalBlock(id: string): DBGlobalBlock | null;
|
|
|
|
|
|
createGlobalBlock(data: Partial<DBGlobalBlock>): DBGlobalBlock;
|
|
|
|
|
|
updateGlobalBlock(id: string, data: Partial<DBGlobalBlock>): DBGlobalBlock | null;
|
|
|
|
|
|
deleteGlobalBlock(id: string): boolean;
|
2026-06-26 10:50:24 +02:00
|
|
|
|
}
|