import Uppy, { BasePlugin, UnknownPlugin, UppyFile } from '@uppy/core'; import { TusOptions } from '@uppy/tus'; import { XHRUploadOptions } from '@uppy/xhr-upload'; import { Language } from 'vue3-gettext'; import { Resource } from '@opencloud-eu/web-client'; import { Body, MinimalRequiredUppyFile } from '@uppy/utils'; type UppyServiceTopics = 'uploadStarted' | 'uploadCancelled' | 'uploadCompleted' | 'uploadSuccess' | 'uploadError' | 'filesSelected' | 'progress' | 'addedForUpload' | 'upload-progress' | 'drag-over' | 'drag-out' | 'drop'; export type uppyHeaders = { [name: string]: string | number; }; export type UploadResult = { successful: OcUppyFile[]; failed: OcUppyFile[]; uploadID?: string; }; interface UppyServiceOptions { language: Language; } export type OcUppyMeta = { name?: string; mtime?: number; spaceId: string; spaceName: string; driveAlias: string; driveType: string; currentFolder: string; currentFolderId?: string; fileId?: string; uppyId?: string; relativeFolder: string; relativePath: string; tusEndpoint: string; uploadId: string; topLevelFolderId?: string; routeName?: string; routeDriveAliasAndItem?: string; routeShareId?: string; isFolder: boolean; }; export type OcUppyBody = Body; export declare const TUS_ALLOWED_META_FIELDS: (keyof OcUppyMeta)[]; export type OcUppyFile = UppyFile; type OcUppyPlugin = typeof BasePlugin; export type OcMinimalUppyFile = MinimalRequiredUppyFile; export type OcTusOptions = TusOptions; /** `OmitFirstArg` is the type of the returned value of `someArray.slice(1)`. */ type OmitFirstArg = T extends [any, ...infer U] ? U : never; export declare class UppyService { uppy: Uppy; uploadInputs: HTMLInputElement[]; uploadFolderMap: Record; constructor({ language }: UppyServiceOptions); getRelativeFilePath: (file: OcUppyFile) => string | undefined; addPlugin(Plugin: T, ...args: OmitFirstArg>): void; removePlugin(plugin: UnknownPlugin): void; getPlugin = UnknownPlugin>(name: string): T | undefined; useTus({ chunkSize, overridePatchMethod, uploadDataDuringCreation, onBeforeRequest, headers }: TusOptions): void; useXhr({ headers, timeout, endpoint }: XHRUploadOptions): void; tusActive(): boolean; useDropTarget({ targetSelector }: { targetSelector: string; }): void; removeDropTarget(): void; subscribe(topic: UppyServiceTopics, callback: (data?: T) => void): string; unsubscribe(topic: UppyServiceTopics, token: string): void; publish(topic: UppyServiceTopics, data?: unknown): void; private setUpEvents; registerUploadInput(el: HTMLInputElement): void; removeUploadInput(el: HTMLInputElement): void; generateUploadId(uppyFile: OcUppyFile): string; log(message: unknown, type?: 'error' | 'warning'): void; addFiles(files: OcMinimalUppyFile[] | File[]): void; uploadFiles(): Promise>; retryAllUploads(): Promise>; pauseAllUploads(): void; resumeAllUploads(): void; cancelAllUploads(): void; removeFailedFiles(): void; getCurrentUploads(): Record; isRemoteUploadInProgress(): boolean; clearInputs(): void; /** * Set a specific upload folder for an upload. The HandleUpload plugin * checks, if a specific folder has been specified as upload destination. * If not, it falls back to the current folder. * The uploadId needs to be set within the meta object of the upload files * for the plugin to connect an upload to its destination folder. **/ setUploadFolder(uploadId: string, folder: Resource): void; removeUploadFolder(uploadId: string): void; } export {};