import { FileUploadStatus } from './constants';

type Bytes = number;

export type FileUploadFileMeta<T = unknown> = {
  /** Autogenerated task id */
  taskId: string;
  /** An original file name on a user file system */
  filename: string;
  /** File size in bytes */
  size: Bytes;
} & (
  | {
      status: FileUploadStatus.Done;
      /** Any helpful information that was returned by the server, URL to an uploaded file, for example */
      result: T;
    }
  | {
      status: FileUploadStatus.Error;
      /** Error description that will display for a user */
      cause: string;
    }
  | {
      status: FileUploadStatus.Uploading;
      /** Uploaded bytes */
      uploaded: Bytes;
    }
);
