import type { FileProgress } from './FileProgress.js' export type Meta = Record export type Body = Record export interface InternalMetadata { name: string type?: string relativePath?: string } // for better readability instead of using Record export type UppyFileId = string interface UppyFileBase { error?: string | null extension: string id: UppyFileId isPaused?: boolean isRestored?: boolean isGhost: boolean meta: InternalMetadata & M name: string preview?: string progress: FileProgress missingRequiredMetaFields?: string[] serverToken?: string | null size: number | null source?: string type: string uploadURL?: string response?: { body?: B status: number bytesUploaded?: number uploadURL?: string } } export interface LocalUppyFile extends UppyFileBase { isRemote: false data: Blob | File | undefined } export interface LocalUppyFileNonGhost extends UppyFileBase { isRemote: false isGhost: false data: Blob | File } export interface RemoteUppyFile extends UppyFileBase { data: { size: number | null } isRemote: true remote: { body?: Record companionUrl: string host?: string provider?: string providerName?: string requestClientId: string url: string } } export type UppyFile = | LocalUppyFile | RemoteUppyFile // TODO use this type in more places, so we don't have to check for data not being null/undefined everywhere /** * For when you know the file is not a ghost, and data is definitely present. */ export type UppyFileNonGhost = | LocalUppyFileNonGhost | RemoteUppyFile /* * The user facing type for UppyFile used in uppy.addFile() and uppy.setOptions() */ export type MinimalRequiredUppyFile = Required< Pick, 'name'> > & { data: NonNullable['data']> } & Partial< Omit, 'name' | 'meta' | 'data'> // We want to omit the 'meta' from UppyFile because of internal metadata // (see InternalMetadata in `UppyFile.js`), as when adding a new file // that is not required. > & { meta?: M }