import { DownloadContext } from '../../context';
import { IEventHub } from '../../events';
import { ChunkedDownloadFile, DownloadFile, DownloadFileState } from '../../models';
import { IDownloadFilesRepository } from '../../repositories';
import { ILocker, ILogger } from '../../utilities';
import { DownloadDatabase, IDbChunkedDownloadFile, IDbDownloadChunk, IDbDownloadFile } from './DownloadDatabase';

export declare function mapDbToDownloadFile(data: IDbDownloadFile): DownloadFile;
export declare function mapDownloadFileToDb(data: DownloadFile): Omit<IDbDownloadFile, 'createDate'>;
export declare function mapDbToChunkedDownloadFile(data: IDbChunkedDownloadFile, file: IDbDownloadFile, inProgressChunks: IDbDownloadChunk[], inProgressChunksLimit: number): ChunkedDownloadFile;
export declare function mapChunkedDownloadFileToDb(data: ChunkedDownloadFile): IDbChunkedDownloadFile;
export declare class DownloadFilesRepository implements IDownloadFilesRepository {
    private eventHub;
    private logger;
    private locker;
    private context;
    private db;
    constructor(eventHub: IEventHub, logger: ILogger, locker: ILocker, context: DownloadContext, db: DownloadDatabase);
    /**
     * Get first file ready for download
     *
     * @returns DownloadFile. NULL if no file is ready.
     */
    getNextToDownload(): Promise<DownloadFile | null>;
    /**
     * Get first file waiting for server processing
     *
     * @returns DownloadFile. NULL if no file is waiting.
     */
    getNextWaiting(): Promise<DownloadFile | null>;
    /**
     * Get all files in a transaction that are waiting for server processing
     * @param transactionID
     * @returns
     */
    getAllWaitingInTransaction(transactionID: string): Promise<never[] | DownloadFile[]>;
    /**
     * Get all files in a transaction that are waiting for server processing
     * @param transactionID
     * @returns
     */
    getAllInTransaction(transactionID: string, state?: DownloadFileState): Promise<never[] | DownloadFile[]>;
    /**
     * Get first file ready for assembling
     *
     * @returns DownloadFile. NULL if no file is ready.
     */
    getNextAssembling(): Promise<DownloadFile | null>;
    /**
     * Get file with specific ID
     *
     * @param id File ID
     * @returns DownloadFile. NULL if file does not exist.
     */
    get(id: string): Promise<DownloadFile | null>;
    /**
     * Get multiple files with list of IDs
     *
     * @param ids File IDs
     * @returns DownloadFile[]
     */
    getAll(ids: string[]): Promise<never[] | DownloadFile[]>;
    /**
     * Get multiple files with state
     *
     * @param state File State
     * @returns DownloadFile[]
     */
    getAllWithState(state: DownloadFileState): Promise<never[] | DownloadFile[]>;
    /**
     * Get chunked file with specific ID
     *
     * @param id File ID
     * @returns ChunkedDownloadFile. NULL if file does not exist.
     */
    getChunked(id: string): Promise<ChunkedDownloadFile | null>;
    /**
     * Save file into DB
     *
     * @param file DownloadFile
     * @returns boolean. True if save succeeded. False otherwise
     */
    save(file: DownloadFile): Promise<boolean>;
    /**
     * Save chunked file into DB
     *
     * @param file ChunkedDownloadFile
     * @returns boolean. True if save succeeded. False otherwise
     */
    saveChunked(file: ChunkedDownloadFile): Promise<boolean>;
    /**
     * Save multiple files into DB
     *
     * @param files DownloadFile[]
     * @returns boolean. True if save succeeded. False otherwise
     */
    saveAll(files: DownloadFile[]): Promise<boolean>;
    /**
     * Delete file from DB
     *
     * @param id string
     * @returns boolean. True if delete succeeded. False otherwise
     */
    delete(id: string): Promise<boolean>;
    /**
     * Delete chunked file from DB
     *
     * @param id string
     * @returns boolean. True if delete succeeded. False otherwise
     */
    deleteChunked(id: string): Promise<boolean>;
    /**
     * Delete multiple chunked files from DB
     *
     * @param ids string[]
     * @returns boolean. True if all deleted. False otherwise
     */
    deleteChunkedAll(ids: string[]): Promise<boolean>;
}
