import { default as PQueue } from 'p-queue'; import { TypedEventTarget } from 'typescript-event-target'; export declare const UploadStatus: Readonly<{ /** The upload was initialized */ INITIALIZED: 0; /** The upload was scheduled but is not yet uploading */ SCHEDULED: 1; /** The upload itself is running */ UPLOADING: 2; /** Chunks are being assembled */ ASSEMBLING: 3; /** The upload finished successfully */ FINISHED: 4; /** The upload was cancelled by the user */ CANCELLED: 5; /** The upload failed */ FAILED: 6; }>; export type TUploadStatus = typeof UploadStatus[keyof typeof UploadStatus]; interface UploadEvents { finished: CustomEvent; progress: CustomEvent; } export interface IUpload extends TypedEventTarget { /** * The source of the upload */ readonly source: string; /** * Whether the upload is chunked or not */ readonly isChunked: boolean; /** * The total size of the upload in bytes */ readonly totalBytes: number; /** * Timestamp of when the upload started. * Will return `undefined` if the upload has not started yet. */ readonly startTime?: number; /** * The number of bytes that have been uploaded so far */ readonly uploadedBytes: number; /** * The current status of the upload */ readonly status: TUploadStatus; /** * The internal abort signal */ readonly signal: AbortSignal; /** * The children of this upload. * - For a file upload, this will be an empty array. * - For a folder upload, this will be the uploads of the children files and folders. */ readonly children: IUpload[]; /** * Cancels the upload */ cancel(): void; } export interface IUploadOptions { headers: Record; noChunking: boolean; retries: number; } export declare abstract class Upload extends TypedEventTarget implements Partial { #private; protected readonly options: IUploadOptions & CustomOpts; protected constructor(options: Partial & CustomOpts); /** * The destination of this upload. * This is *not* URL encoded, it is encoded when the upload requests are made. */ abstract source: string; get signal(): AbortSignal; /** * Move this upload to a new destination. * * This is needed when a parent folder is renamed while resolving conflicts, * as the child uploads are already initialized with the previous destination. * * @param source - The new destination of this upload */ rebase(source: string): void; /** * Cancels the upload */ cancel(): void; /** * Get the children of this upload. * For a file upload, this will be an empty array, for a folder upload, this will be the uploads of the children files and folders. */ get children(): IUpload[]; /** * Start the upload * * @param queue - The job queue. It is used to limit the number of concurrent upload jobs. */ abstract start(queue: PQueue): Promise; } export {};