UppyFile.ts 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. import type { FileProgress } from './FileProgress'
  2. export type Meta = Record<string, unknown>
  3. export type Body = Record<string, unknown>
  4. export type InternalMetadata = { name: string; type?: string }
  5. export interface UppyFile<M extends Meta, B extends Body> {
  6. data: Blob | File
  7. error?: string | null
  8. extension: string
  9. id: string
  10. isPaused?: boolean
  11. isRestored?: boolean
  12. isRemote: boolean
  13. isGhost: boolean
  14. meta: InternalMetadata & M
  15. name: string
  16. preview?: string
  17. progress: FileProgress
  18. missingRequiredMetaFields?: string[]
  19. remote?: {
  20. body?: Record<string, unknown>
  21. companionUrl: string
  22. host?: string
  23. provider?: string
  24. providerName?: string
  25. requestClientId: string
  26. url: string
  27. }
  28. serverToken?: string | null
  29. size: number | null
  30. source?: string
  31. type: string
  32. uploadURL?: string
  33. response?: {
  34. body?: B
  35. status: number
  36. bytesUploaded?: number
  37. uploadURL?: string
  38. }
  39. }
  40. // The user facing type for UppyFile used in uppy.addFile() and uppy.setOptions()
  41. export type MinimalRequiredUppyFile<M extends Meta, B extends Body> = Required<
  42. Pick<UppyFile<M, B>, 'name' | 'data'>
  43. > &
  44. Partial<
  45. Omit<UppyFile<M, B>, 'name' | 'data' | 'meta'>
  46. // We want to omit the 'meta' from UppyFile because of internal metadata
  47. // (see InternalMetadata in `UppyFile.ts`), as when adding a new file
  48. // that is not required.
  49. > & { meta?: M }