ecc340e7b1
Dark mode: CSS custom properties + .dark class toggled via Redux/localStorage, with a theme toggle in the Header and Settings page. Foundation didn't exist yet despite prior assumption, so it was built from scratch. SQLite: new DB_ENGINE=mongo|sqlite env var selects the metadata backend at runtime (Mongo stays default, no behavior change unless opted in). File/thumbnail bytes continue to use the existing fs/S3 storage path. Implemented via a shared DB interface (dbTypes.ts) with parallel mongoDB/ and sqliteDB/ implementations, selected through dbFactory.ts, with JWT/encryption logic extracted into userCrypto.ts so both engines share it.
151 lines
4.5 KiB
TypeScript
151 lines
4.5 KiB
TypeScript
import { FileListQueryType } from "../types/file-types";
|
|
import { FolderListQueryType } from "../types/folder-types";
|
|
|
|
export interface IFileDB {
|
|
getPublicFile(fileID: string): Promise<any>;
|
|
getPublicInfo(fileID: string, tempToken: string): Promise<any>;
|
|
getFileInfo(fileID: string, userID: string): Promise<any>;
|
|
getQuickList(userID: string, limit: number): Promise<any[]>;
|
|
getList(
|
|
queryData: FileListQueryType,
|
|
sortBy: string,
|
|
limit: number
|
|
): Promise<any[]>;
|
|
getFileSearchList(
|
|
userID: string,
|
|
searchQuery: RegExp | string,
|
|
trashMode: boolean,
|
|
mediaMode: boolean
|
|
): Promise<any[]>;
|
|
getFileListByIncludedParent(
|
|
userID: string,
|
|
parentListString: string
|
|
): Promise<any[]>;
|
|
getFileListByOwner(userID: string): Promise<any[]>;
|
|
getFileListByParent(userID: string, parent: string): Promise<any[]>;
|
|
updateFileUploadedFile(
|
|
fileID: string,
|
|
userID: string,
|
|
parent: string,
|
|
parentList: string
|
|
): Promise<any>;
|
|
updateFolderUploadedFile(
|
|
fileID: string,
|
|
userID: string,
|
|
parent: string,
|
|
parentList: string
|
|
): Promise<any>;
|
|
setThumbnail(fileID: string, thumbnailID: string): Promise<any>;
|
|
removeOneTimePublicLink(fileID: string): Promise<any>;
|
|
removeLink(fileID: string, userID: string): Promise<any>;
|
|
makePublic(fileID: string, userID: string, token: string): Promise<any>;
|
|
makeOneTimePublic(
|
|
fileID: string,
|
|
userID: string,
|
|
token: string
|
|
): Promise<any>;
|
|
trashFile(
|
|
fileID: string,
|
|
parent: string,
|
|
parentList: string,
|
|
userID: string
|
|
): Promise<any>;
|
|
restoreFile(fileID: string, userID: string): Promise<any>;
|
|
removeTempToken(user: any, tempToken: string): Promise<any>;
|
|
trashFilesByParent(parentList: string, userID: string): Promise<any>;
|
|
restoreFilesByParent(parentList: string, userID: string): Promise<any>;
|
|
renameFile(fileID: string, userID: string, title: string): Promise<any>;
|
|
moveFile(
|
|
fileID: string,
|
|
userID: string,
|
|
parent: string,
|
|
parentList: string
|
|
): Promise<any>;
|
|
moveMultipleFiles(
|
|
userID: string,
|
|
currentParent: string,
|
|
newParent: string,
|
|
newParentList: string
|
|
): Promise<any>;
|
|
deleteFile(fileID: string, userID: string): Promise<any>;
|
|
createFile(data: { filename: string; uploadDate: string; length: number; metadata: any }): Promise<any>;
|
|
setVideoThumbnail(
|
|
fileID: string,
|
|
userID: string,
|
|
thumbnailID: string
|
|
): Promise<any>;
|
|
}
|
|
|
|
export interface IFolderDB {
|
|
getFolderSearchList(
|
|
userID: string,
|
|
searchQuery: RegExp | string,
|
|
trashMode: boolean
|
|
): Promise<any[]>;
|
|
getFolderInfo(folderID: string, userID: string): Promise<any>;
|
|
getFolderList(
|
|
queryData: FolderListQueryType,
|
|
sortBy: string
|
|
): Promise<any[]>;
|
|
getMoveFolderList(
|
|
userID: string,
|
|
parent?: string,
|
|
search?: string,
|
|
folderIDs?: string[]
|
|
): Promise<any[]>;
|
|
getFolderListByIncludedParent(
|
|
userID: string,
|
|
parent: string
|
|
): Promise<any[]>;
|
|
findAllFoldersByParent(parentID: string, userID: string): Promise<any[]>;
|
|
moveFolder(
|
|
folderID: string,
|
|
userID: string,
|
|
parent: string,
|
|
parentList: string[]
|
|
): Promise<any>;
|
|
renameFolder(folderID: string, userID: string, title: string): Promise<any>;
|
|
trashFoldersByParent(parentList: string[], userID: string): Promise<any>;
|
|
restoreFolder(folderID: string, userID: string): Promise<any>;
|
|
restoreFoldersByParent(parentList: string[], userID: string): Promise<any>;
|
|
trashFolder(folderID: string, userID: string): Promise<any>;
|
|
createFolder(folderData: {
|
|
name: string;
|
|
parent: string;
|
|
parentList: string[];
|
|
owner: string;
|
|
}): Promise<any>;
|
|
deleteFolder(folderID: string, userID: string): Promise<any>;
|
|
deleteFoldersByParentList(
|
|
parentList: string[],
|
|
userID: string
|
|
): Promise<any>;
|
|
deleteFoldersByOwner(userID: string): Promise<any>;
|
|
}
|
|
|
|
export interface IUserDB {
|
|
getUserInfo(userID: string): Promise<any>;
|
|
findByEmail(email: string): Promise<any>;
|
|
findByCreds(email: string, password: string): Promise<any>;
|
|
createUser(email: string, password: string): Promise<any>;
|
|
removeOldTokens(
|
|
userID: string,
|
|
uuid: string | undefined,
|
|
minusTime: number,
|
|
isTemp: boolean
|
|
): Promise<any>;
|
|
removeTempTokenByValue(userID: string, token: string): Promise<any>;
|
|
}
|
|
|
|
export interface IThumbnailDB {
|
|
getThumbnailInfo(userID: string, thumbnailID: string): Promise<any>;
|
|
removeThumbnail(userID: string, thumbnailID: any): Promise<any>;
|
|
createThumbnail(data: {
|
|
name: string;
|
|
owner: string;
|
|
IV: Buffer;
|
|
path?: string;
|
|
s3ID?: string;
|
|
}): Promise<any>;
|
|
}
|