diff options
author | Chocobozzz <me@florianbigard.com> | 2019-08-20 13:52:49 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-08-20 14:53:42 +0200 |
commit | 0283eaac2a8e73006c66df3cf5bb9012e37450e5 (patch) | |
tree | 1fb73aeef57f984a77f47828ade23c6365ce8eb0 /server/typings/models/video/video-playlist.ts | |
parent | 96ca24f00e5ae5471dee9ee596489fe50af2b46f (diff) | |
download | PeerTube-0283eaac2a8e73006c66df3cf5bb9012e37450e5.tar.gz PeerTube-0283eaac2a8e73006c66df3cf5bb9012e37450e5.tar.zst PeerTube-0283eaac2a8e73006c66df3cf5bb9012e37450e5.zip |
Cleanup model types
Diffstat (limited to 'server/typings/models/video/video-playlist.ts')
-rw-r--r-- | server/typings/models/video/video-playlist.ts | 70 |
1 files changed, 54 insertions, 16 deletions
diff --git a/server/typings/models/video/video-playlist.ts b/server/typings/models/video/video-playlist.ts index 825b3391c..633818405 100644 --- a/server/typings/models/video/video-playlist.ts +++ b/server/typings/models/video/video-playlist.ts | |||
@@ -5,38 +5,76 @@ import { MThumbnail } from './thumbnail' | |||
5 | import { MChannelDefault, MChannelSummary } from './video-channels' | 5 | import { MChannelDefault, MChannelSummary } from './video-channels' |
6 | import { MVideoPlaylistElementLight } from '@server/typings/models/video/video-playlist-element' | 6 | import { MVideoPlaylistElementLight } from '@server/typings/models/video/video-playlist-element' |
7 | 7 | ||
8 | type Use<K extends keyof VideoPlaylistModel, M> = PickWith<VideoPlaylistModel, K, M> | ||
9 | |||
10 | // ############################################################################ | ||
11 | |||
8 | export type MVideoPlaylist = Omit<VideoPlaylistModel, 'OwnerAccount' | 'VideoChannel' | 'VideoPlaylistElements' | 'Thumbnail'> | 12 | export type MVideoPlaylist = Omit<VideoPlaylistModel, 'OwnerAccount' | 'VideoChannel' | 'VideoPlaylistElements' | 'Thumbnail'> |
13 | |||
14 | // ############################################################################ | ||
15 | |||
9 | export type MVideoPlaylistId = Pick<MVideoPlaylist, 'id'> | 16 | export type MVideoPlaylistId = Pick<MVideoPlaylist, 'id'> |
10 | export type MVideoPlaylistPrivacy = Pick<MVideoPlaylist, 'privacy'> | 17 | export type MVideoPlaylistPrivacy = Pick<MVideoPlaylist, 'privacy'> |
18 | export type MVideoPlaylistUUID = Pick<MVideoPlaylist, 'uuid'> | ||
19 | export type MVideoPlaylistVideosLength = MVideoPlaylist & { videosLength: number } | ||
20 | |||
21 | // ############################################################################ | ||
22 | |||
23 | // With elements | ||
11 | 24 | ||
12 | export type MVideoPlaylistWithElements = MVideoPlaylist & | 25 | export type MVideoPlaylistWithElements = MVideoPlaylist & |
13 | PickWith<VideoPlaylistModel, 'VideoPlaylistElements', MVideoPlaylistElementLight[]> | 26 | Use<'VideoPlaylistElements', MVideoPlaylistElementLight[]> |
14 | export type MVideoPlaylistIdWithElements = MVideoPlaylistId & MVideoPlaylistWithElements | ||
15 | 27 | ||
16 | export type MVideoPlaylistUUID = Pick<MVideoPlaylist, 'uuid'> | 28 | export type MVideoPlaylistIdWithElements = MVideoPlaylistId & |
29 | Use<'VideoPlaylistElements', MVideoPlaylistElementLight[]> | ||
30 | |||
31 | // ############################################################################ | ||
32 | |||
33 | // With account | ||
17 | 34 | ||
18 | export type MVideoPlaylistOwner = MVideoPlaylist & | 35 | export type MVideoPlaylistOwner = MVideoPlaylist & |
19 | PickWith<VideoPlaylistModel, 'OwnerAccount', MAccount> | 36 | Use<'OwnerAccount', MAccount> |
20 | 37 | ||
21 | export type MVideoPlaylistOwnerDefault = MVideoPlaylist & | 38 | export type MVideoPlaylistOwnerDefault = MVideoPlaylist & |
22 | PickWith<VideoPlaylistModel, 'OwnerAccount', MAccountDefault> | 39 | Use<'OwnerAccount', MAccountDefault> |
40 | |||
41 | // ############################################################################ | ||
42 | |||
43 | // With thumbnail | ||
23 | 44 | ||
24 | export type MVideoPlaylistThumbnail = MVideoPlaylist & | 45 | export type MVideoPlaylistThumbnail = MVideoPlaylist & |
25 | PickWith<VideoPlaylistModel, 'Thumbnail', MThumbnail> | 46 | Use<'Thumbnail', MThumbnail> |
26 | 47 | ||
27 | export type MVideoPlaylistAccountThumbnail = MVideoPlaylistOwnerDefault & | 48 | export type MVideoPlaylistAccountThumbnail = MVideoPlaylist & |
28 | PickWith<VideoPlaylistModel, 'Thumbnail', MThumbnail> | 49 | Use<'OwnerAccount', MAccountDefault> & |
50 | Use<'Thumbnail', MThumbnail> | ||
29 | 51 | ||
30 | export type MVideoPlaylistAccountChannelSummary = MVideoPlaylist & | 52 | // ############################################################################ |
31 | PickWith<VideoPlaylistModel, 'OwnerAccount', MAccountSummary> & | 53 | |
32 | PickWith<VideoPlaylistModel, 'VideoChannel', MChannelSummary> | 54 | // With channel |
33 | 55 | ||
34 | export type MVideoPlaylistAccountChannelDefault = MVideoPlaylist & | 56 | export type MVideoPlaylistAccountChannelDefault = MVideoPlaylist & |
35 | PickWith<VideoPlaylistModel, 'OwnerAccount', MAccountDefault> & | 57 | Use<'OwnerAccount', MAccountDefault> & |
36 | PickWith<VideoPlaylistModel, 'VideoChannel', MChannelDefault> | 58 | Use<'VideoChannel', MChannelDefault> |
37 | 59 | ||
38 | export type MVideoPlaylistVideosLength = MVideoPlaylist & { videosLength: number } | 60 | // ############################################################################ |
39 | 61 | ||
40 | export type MVideoPlaylistFullSummary = MVideoPlaylistAccountChannelSummary & MVideoPlaylistThumbnail | 62 | // With all associations |
63 | |||
64 | export type MVideoPlaylistFull = MVideoPlaylist & | ||
65 | Use<'OwnerAccount', MAccountDefault> & | ||
66 | Use<'VideoChannel', MChannelDefault> & | ||
67 | Use<'Thumbnail', MThumbnail> | ||
68 | |||
69 | // ############################################################################ | ||
70 | |||
71 | // For API | ||
72 | |||
73 | export type MVideoPlaylistAccountChannelSummary = MVideoPlaylist & | ||
74 | Use<'OwnerAccount', MAccountSummary> & | ||
75 | Use<'VideoChannel', MChannelSummary> | ||
41 | 76 | ||
42 | export type MVideoPlaylistFull = MVideoPlaylist & MVideoPlaylistThumbnail & MVideoPlaylistAccountChannelDefault | 77 | export type MVideoPlaylistFullSummary = MVideoPlaylist & |
78 | Use<'Thumbnail', MThumbnail> & | ||
79 | Use<'OwnerAccount', MAccountSummary> & | ||
80 | Use<'VideoChannel', MChannelSummary> | ||