Remove uneccessary details to link titles
[oweals/peertube.git] / server / typings / models / video / video.ts
index 914eb7f577d011440cc7d33b18a090da7b34b8ba..022a9566d50d3f8267df2af29566c504f8cf5a54 100644 (file)
@@ -1,12 +1,24 @@
 import { VideoModel } from '../../../models/video/video'
 import { PickWith, PickWithOpt } from '../../utils'
-import { MChannelAccountDefault, MChannelAccountLight, MChannelActor, MChannelUserId } from './video-channels'
+import {
+  MChannelAccountDefault,
+  MChannelAccountLight,
+  MChannelAccountSummaryFormattable,
+  MChannelActor,
+  MChannelFormattable,
+  MChannelUserId
+} from './video-channels'
 import { MTag } from './tag'
-import { MVideoCaptionLanguage } from './video-caption'
-import { MStreamingPlaylist, MStreamingPlaylistRedundancies } from './video-streaming-playlist'
-import { MVideoFile, MVideoFileRedundanciesOpt } from './video-file'
+import { MVideoCaptionLanguage, MVideoCaptionLanguageUrl } from './video-caption'
+import {
+  MStreamingPlaylistFiles,
+  MStreamingPlaylistRedundancies,
+  MStreamingPlaylistRedundanciesAll,
+  MStreamingPlaylistRedundanciesOpt
+} from './video-streaming-playlist'
+import { MVideoFile, MVideoFileRedundanciesAll, MVideoFileRedundanciesOpt } from './video-file'
 import { MThumbnail } from './thumbnail'
-import { MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist'
+import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist'
 import { MScheduleVideoUpdate } from './schedule-video-update'
 import { MUserVideoHistoryTime } from '../user/user-video-history'
 
@@ -14,7 +26,8 @@ type Use<K extends keyof VideoModel, M> = PickWith<VideoModel, K, M>
 
 // ############################################################################
 
-export type MVideo = Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' |
+export type MVideo =
+  Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' |
   'VideoFiles' | 'VideoStreamingPlaylists' | 'VideoShares' | 'AccountVideoRates' | 'VideoComments' | 'VideoViews' | 'UserVideoHistories' |
   'ScheduleVideoUpdate' | 'VideoBlacklist' | 'VideoImport' | 'VideoCaptions'>
 
@@ -24,6 +37,7 @@ export type MVideoId = Pick<MVideo, 'id'>
 export type MVideoUrl = Pick<MVideo, 'url'>
 export type MVideoUUID = Pick<MVideo, 'uuid'>
 
+export type MVideoImmutable = Pick<MVideo, 'id' | 'url' | 'uuid' | 'remote' | 'isOwned'>
 export type MVideoIdUrl = MVideoId & MVideoUrl
 export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'>
 
@@ -32,45 +46,63 @@ export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'>
 // Video raw associations: schedules, video files, tags, thumbnails, captions, streaming playlists
 
 // "With" to not confuse with the VideoFile model
-export type MVideoWithFile = MVideo &
-  Use<'VideoFiles', MVideoFile[]>
+export type MVideoWithFile =
+  MVideo &
+  Use<'VideoFiles', MVideoFile[]> &
+  Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
 
-export type MVideoThumbnail = MVideo &
+export type MVideoThumbnail =
+  MVideo &
   Use<'Thumbnails', MThumbnail[]>
 
-export type MVideoIdThumbnail = MVideoId &
+export type MVideoIdThumbnail =
+  MVideoId &
   Use<'Thumbnails', MThumbnail[]>
 
-export type MVideoWithFileThumbnail = MVideo &
+export type MVideoWithFileThumbnail =
+  MVideo &
   Use<'VideoFiles', MVideoFile[]> &
   Use<'Thumbnails', MThumbnail[]>
 
-export type MVideoTag = MVideo &
+export type MVideoThumbnailBlacklist =
+  MVideo &
+  Use<'Thumbnails', MThumbnail[]> &
+  Use<'VideoBlacklist', MVideoBlacklistLight>
+
+export type MVideoTag =
+  MVideo &
   Use<'Tags', MTag[]>
 
-export type MVideoWithSchedule = MVideo &
+export type MVideoWithSchedule =
+  MVideo &
   PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate>
 
-export type MVideoWithCaptions = MVideo &
+export type MVideoWithCaptions =
+  MVideo &
   Use<'VideoCaptions', MVideoCaptionLanguage[]>
 
-export type MVideoWithStreamingPlaylist = MVideo &
-  Use<'VideoStreamingPlaylists', MStreamingPlaylist[]>
+export type MVideoWithStreamingPlaylist =
+  MVideo &
+  Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
 
 // ############################################################################
 
 // Associations with not all their attributes
 
-export type MVideoUserHistory = MVideo &
+export type MVideoUserHistory =
+  MVideo &
   Use<'UserVideoHistories', MUserVideoHistoryTime[]>
 
-export type MVideoWithBlacklistLight = MVideo &
+export type MVideoWithBlacklistLight =
+  MVideo &
   Use<'VideoBlacklist', MVideoBlacklistLight>
 
-export type MVideoAccountLight = MVideo &
+export type MVideoAccountLight =
+  MVideo &
   Use<'VideoChannel', MChannelAccountLight>
 
-export type MVideoWithRights = MVideo &
+export type MVideoWithRights =
+  MVideo &
   Use<'VideoBlacklist', MVideoBlacklistLight> &
   Use<'Thumbnails', MThumbnail[]> &
   Use<'VideoChannel', MChannelUserId>
@@ -79,15 +111,17 @@ export type MVideoWithRights = MVideo &
 
 // All files with some additional associations
 
-export type MVideoWithAllFiles = MVideo &
+export type MVideoWithAllFiles =
+  MVideo &
   Use<'VideoFiles', MVideoFile[]> &
   Use<'Thumbnails', MThumbnail[]> &
-  Use<'VideoStreamingPlaylists', MStreamingPlaylist[]>
+  Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
 
-export type MVideoAccountLightBlacklistAllFiles = MVideo &
+export type MVideoAccountLightBlacklistAllFiles =
+  MVideo &
   Use<'VideoFiles', MVideoFile[]> &
   Use<'Thumbnails', MThumbnail[]> &
-  Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> &
+  Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> &
   Use<'VideoChannel', MChannelAccountLight> &
   Use<'VideoBlacklist', MVideoBlacklistLight>
 
@@ -95,17 +129,21 @@ export type MVideoAccountLightBlacklistAllFiles = MVideo &
 
 // With account
 
-export type MVideoAccountDefault = MVideo &
+export type MVideoAccountDefault =
+  MVideo &
   Use<'VideoChannel', MChannelAccountDefault>
 
-export type MVideoThumbnailAccountDefault = MVideo &
+export type MVideoThumbnailAccountDefault =
+  MVideo &
   Use<'Thumbnails', MThumbnail[]> &
   Use<'VideoChannel', MChannelAccountDefault>
 
-export type MVideoWithChannelActor = MVideo &
+export type MVideoWithChannelActor =
+  MVideo &
   Use<'VideoChannel', MChannelActor>
 
-export type MVideoFullLight = MVideo &
+export type MVideoFullLight =
+  MVideo &
   Use<'Thumbnails', MThumbnail[]> &
   Use<'VideoBlacklist', MVideoBlacklistLight> &
   Use<'Tags', MTag[]> &
@@ -113,23 +151,26 @@ export type MVideoFullLight = MVideo &
   Use<'UserVideoHistories', MUserVideoHistoryTime[]> &
   Use<'VideoFiles', MVideoFile[]> &
   Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
-  Use<'VideoStreamingPlaylists', MStreamingPlaylist[]>
+  Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
 
 // ############################################################################
 
 // API
 
-export type MVideoAP = MVideo &
+export type MVideoAP =
+  MVideo &
   Use<'Tags', MTag[]> &
   Use<'VideoChannel', MChannelAccountLight> &
-  Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> &
-  Use<'VideoCaptions', MVideoCaptionLanguage[]> &
+  Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> &
+  Use<'VideoCaptions', MVideoCaptionLanguageUrl[]> &
   Use<'VideoBlacklist', MVideoBlacklistUnfederated> &
-  Use<'VideoFiles', MVideoFileRedundanciesOpt[]>
+  Use<'VideoFiles', MVideoFileRedundanciesOpt[]> &
+  Use<'Thumbnails', MThumbnail[]>
 
 export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'>
 
-export type MVideoDetails = MVideo &
+export type MVideoDetails =
+  MVideo &
   Use<'VideoBlacklist', MVideoBlacklistLight> &
   Use<'Tags', MTag[]> &
   Use<'VideoChannel', MChannelAccountLight> &
@@ -139,8 +180,32 @@ export type MVideoDetails = MVideo &
   Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> &
   Use<'VideoFiles', MVideoFileRedundanciesOpt[]>
 
-export type MVideoForUser = MVideo &
+export type MVideoForUser =
+  MVideo &
   Use<'VideoChannel', MChannelAccountDefault> &
   Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
   Use<'VideoBlacklist', MVideoBlacklistLight> &
   Use<'Thumbnails', MThumbnail[]>
+
+export type MVideoForRedundancyAPI =
+  MVideo &
+  Use<'VideoFiles', MVideoFileRedundanciesAll[]> &
+  Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesAll[]>
+
+// ############################################################################
+
+// Format for API or AP object
+
+export type MVideoFormattable =
+  MVideo &
+  PickWithOpt<VideoModel, 'UserVideoHistories', MUserVideoHistoryTime[]> &
+  Use<'VideoChannel', MChannelAccountSummaryFormattable> &
+  PickWithOpt<VideoModel, 'ScheduleVideoUpdate', Pick<MScheduleVideoUpdate, 'updateAt' | 'privacy'>> &
+  PickWithOpt<VideoModel, 'VideoBlacklist', Pick<MVideoBlacklist, 'reason'>>
+
+export type MVideoFormattableDetails =
+  MVideoFormattable &
+  Use<'VideoChannel', MChannelFormattable> &
+  Use<'Tags', MTag[]> &
+  Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesOpt[]> &
+  Use<'VideoFiles', MVideoFileRedundanciesOpt[]>