UNPKG

@gsb-core/core

Version:

GSB core services and classes for platform-independent web applications

68 lines (67 loc) 2.33 kB
import { GsbFile, FileType } from '../../models/gsb-file.model'; export declare const DEFAULT_FOLDER_TYPE = FileType.Cloud_AWS; /** * Service for managing Files and Storage in the application */ export declare class GsbFileService { private static instance; private entityService; private ENTITY_NAME; constructor(); static getInstance(): GsbFileService; /** * Get file by ID * @param id The file ID * @returns The file or null if not found */ getFileById(id: string): Promise<GsbFile | null>; /** * Get files in a folder * @param folderId The parent folder ID (null or undefined for root) * @param page The page number (starting from 1) * @param pageSize The number of items per page * @returns An array of files and the total count */ getFiles(folderId?: string, page?: number, pageSize?: number): Promise<{ files: GsbFile[]; totalCount: number; }>; /** * Search for files * @param searchTerm The search term * @param page The page number (starting from 1) * @param pageSize The number of items per page * @returns An array of files and the total count */ searchFiles(searchTerm: string, page?: number, pageSize?: number): Promise<{ files: GsbFile[]; totalCount: number; }>; /** * Create a new folder * @param name The folder name * @param parentId The parent folder ID (optional) * @returns The created folder ID or null if failed */ createFolder(name: string, parentId?: string, parentPath?: string): Promise<string | null>; /** * Upload a file * @param file The file to upload * @param name The file name (optional, defaults to file.name) * @param parentId The parent folder ID (optional) * @returns The uploaded file ID or null if failed */ uploadFile(file: File, entity: GsbFile): Promise<GsbFile | null>; /** * Delete a file or folder * @param id The file or folder ID to delete * @returns True if deleted successfully, false otherwise */ deleteFile(id: string): Promise<boolean>; /** * Get file content * @param id The file ID * @returns The file content or null if failed */ getFileContent(id: string): Promise<Blob | null>; }