video.ts 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175
  1. import { VideoModel } from '../../../models/video/video'
  2. import { PickWith, PickWithOpt } from '../../utils'
  3. import {
  4. MChannelAccountDefault,
  5. MChannelAccountLight,
  6. MChannelAccountSummaryFormattable,
  7. MChannelActor,
  8. MChannelFormattable,
  9. MChannelUserId
  10. } from './video-channels'
  11. import { MTag } from './tag'
  12. import { MVideoCaptionLanguage } from './video-caption'
  13. import { MStreamingPlaylistFiles, MStreamingPlaylistRedundancies, MStreamingPlaylistRedundanciesOpt } from './video-streaming-playlist'
  14. import { MVideoFile, MVideoFileRedundanciesOpt } from './video-file'
  15. import { MThumbnail } from './thumbnail'
  16. import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist'
  17. import { MScheduleVideoUpdate } from './schedule-video-update'
  18. import { MUserVideoHistoryTime } from '../user/user-video-history'
  19. type Use<K extends keyof VideoModel, M> = PickWith<VideoModel, K, M>
  20. // ############################################################################
  21. export type MVideo = Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' |
  22. 'VideoFiles' | 'VideoStreamingPlaylists' | 'VideoShares' | 'AccountVideoRates' | 'VideoComments' | 'VideoViews' | 'UserVideoHistories' |
  23. 'ScheduleVideoUpdate' | 'VideoBlacklist' | 'VideoImport' | 'VideoCaptions'>
  24. // ############################################################################
  25. export type MVideoId = Pick<MVideo, 'id'>
  26. export type MVideoUrl = Pick<MVideo, 'url'>
  27. export type MVideoUUID = Pick<MVideo, 'uuid'>
  28. export type MVideoIdUrl = MVideoId & MVideoUrl
  29. export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'>
  30. // ############################################################################
  31. // Video raw associations: schedules, video files, tags, thumbnails, captions, streaming playlists
  32. // "With" to not confuse with the VideoFile model
  33. export type MVideoWithFile = MVideo &
  34. Use<'VideoFiles', MVideoFile[]> &
  35. Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
  36. export type MVideoThumbnail = MVideo &
  37. Use<'Thumbnails', MThumbnail[]>
  38. export type MVideoIdThumbnail = MVideoId &
  39. Use<'Thumbnails', MThumbnail[]>
  40. export type MVideoWithFileThumbnail = MVideo &
  41. Use<'VideoFiles', MVideoFile[]> &
  42. Use<'Thumbnails', MThumbnail[]>
  43. export type MVideoThumbnailBlacklist = MVideo &
  44. Use<'Thumbnails', MThumbnail[]> &
  45. Use<'VideoBlacklist', MVideoBlacklistLight>
  46. export type MVideoTag = MVideo &
  47. Use<'Tags', MTag[]>
  48. export type MVideoWithSchedule = MVideo &
  49. PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate>
  50. export type MVideoWithCaptions = MVideo &
  51. Use<'VideoCaptions', MVideoCaptionLanguage[]>
  52. export type MVideoWithStreamingPlaylist = MVideo &
  53. Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
  54. // ############################################################################
  55. // Associations with not all their attributes
  56. export type MVideoUserHistory = MVideo &
  57. Use<'UserVideoHistories', MUserVideoHistoryTime[]>
  58. export type MVideoWithBlacklistLight = MVideo &
  59. Use<'VideoBlacklist', MVideoBlacklistLight>
  60. export type MVideoAccountLight = MVideo &
  61. Use<'VideoChannel', MChannelAccountLight>
  62. export type MVideoWithRights = MVideo &
  63. Use<'VideoBlacklist', MVideoBlacklistLight> &
  64. Use<'Thumbnails', MThumbnail[]> &
  65. Use<'VideoChannel', MChannelUserId>
  66. // ############################################################################
  67. // All files with some additional associations
  68. export type MVideoWithAllFiles = MVideo &
  69. Use<'VideoFiles', MVideoFile[]> &
  70. Use<'Thumbnails', MThumbnail[]> &
  71. Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
  72. export type MVideoAccountLightBlacklistAllFiles = MVideo &
  73. Use<'VideoFiles', MVideoFile[]> &
  74. Use<'Thumbnails', MThumbnail[]> &
  75. Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> &
  76. Use<'VideoChannel', MChannelAccountLight> &
  77. Use<'VideoBlacklist', MVideoBlacklistLight>
  78. // ############################################################################
  79. // With account
  80. export type MVideoAccountDefault = MVideo &
  81. Use<'VideoChannel', MChannelAccountDefault>
  82. export type MVideoThumbnailAccountDefault = MVideo &
  83. Use<'Thumbnails', MThumbnail[]> &
  84. Use<'VideoChannel', MChannelAccountDefault>
  85. export type MVideoWithChannelActor = MVideo &
  86. Use<'VideoChannel', MChannelActor>
  87. export type MVideoFullLight = MVideo &
  88. Use<'Thumbnails', MThumbnail[]> &
  89. Use<'VideoBlacklist', MVideoBlacklistLight> &
  90. Use<'Tags', MTag[]> &
  91. Use<'VideoChannel', MChannelAccountLight> &
  92. Use<'UserVideoHistories', MUserVideoHistoryTime[]> &
  93. Use<'VideoFiles', MVideoFile[]> &
  94. Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
  95. Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
  96. // ############################################################################
  97. // API
  98. export type MVideoAP = MVideo &
  99. Use<'Tags', MTag[]> &
  100. Use<'VideoChannel', MChannelAccountLight> &
  101. Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> &
  102. Use<'VideoCaptions', MVideoCaptionLanguage[]> &
  103. Use<'VideoBlacklist', MVideoBlacklistUnfederated> &
  104. Use<'VideoFiles', MVideoFileRedundanciesOpt[]> &
  105. Use<'Thumbnails', MThumbnail[]>
  106. export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'>
  107. export type MVideoDetails = MVideo &
  108. Use<'VideoBlacklist', MVideoBlacklistLight> &
  109. Use<'Tags', MTag[]> &
  110. Use<'VideoChannel', MChannelAccountLight> &
  111. Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
  112. Use<'Thumbnails', MThumbnail[]> &
  113. Use<'UserVideoHistories', MUserVideoHistoryTime[]> &
  114. Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> &
  115. Use<'VideoFiles', MVideoFileRedundanciesOpt[]>
  116. export type MVideoForUser = MVideo &
  117. Use<'VideoChannel', MChannelAccountDefault> &
  118. Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
  119. Use<'VideoBlacklist', MVideoBlacklistLight> &
  120. Use<'Thumbnails', MThumbnail[]>
  121. // ############################################################################
  122. // Format for API or AP object
  123. export type MVideoFormattable = MVideo &
  124. PickWithOpt<VideoModel, 'UserVideoHistories', MUserVideoHistoryTime[]> &
  125. Use<'VideoChannel', MChannelAccountSummaryFormattable> &
  126. PickWithOpt<VideoModel, 'ScheduleVideoUpdate', Pick<MScheduleVideoUpdate, 'updateAt' | 'privacy'>> &
  127. PickWithOpt<VideoModel, 'VideoBlacklist', Pick<MVideoBlacklist, 'reason'>>
  128. export type MVideoFormattableDetails = MVideoFormattable &
  129. Use<'VideoChannel', MChannelFormattable> &
  130. Use<'Tags', MTag[]> &
  131. Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesOpt[]> &
  132. Use<'VideoFiles', MVideoFileRedundanciesOpt[]>