import { default as PQueue } from 'p-queue'; import { IUpload, IUploadOptions, TUploadStatus, Upload } from './Upload.ts'; import { Directory as FileTree } from '../utils/fileTree.ts'; /** * Callback type for conflict resolution when uploading a folder tree. * * The callback receives the nodes in the current folder and the current path to upload to, * it should return a mapping of nodes that should be uploaded (e.g. after resolving conflicts by renaming or selecting which files to upload). * In case the upload should be cancelled, it should return `false`. * The returned mapping allowes to resolve conflicts by renaming files or folders before upload, * the key is the original name of the node and the value is the name to upload it as. * * @param nodes - The nodes to upload (list of filenames) * @param currentPath - The current path to upload to * @return A promise that resolves to a map of nodes that should be uploaded or false if the upload should be cancelled */ export type ConflictsCallback = (nodes: string[], currentPath: string) => Promise>; interface IUploadFileTreeOptions { /** The callback to handle conflicts */ callback?: ConflictsCallback; } /** * A class representing a single file to be uploaded */ export declare class UploadFileTree extends Upload implements IUpload { #private; /** Whether we need to check for conflicts or not (newly created parent folders = no conflict resolution needed) */ protected needConflictResolution: boolean; source: string; status: TUploadStatus; startTime?: number; totalBytes: number; uploadedBytes: number; constructor(destination: string, directory: FileTree, options?: Partial); get isChunked(): boolean; get children(): IUpload[]; /** * Move this upload - and all already initialized descendants - to a new destination. * * The whole tree is initialized upfront, so renaming a directory while resolving * conflicts also needs to re-base all of its children. * * @param source - The new destination of this upload */ rebase(source: string): void; /** * Set up all child uploads for this upload tree. */ initialize(): (Upload & IUpload)[]; start(queue: PQueue): Promise; } export {};