diff options
author | Chocobozzz <me@florianbigard.com> | 2020-06-18 10:45:25 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-06-18 10:46:27 +0200 |
commit | 26d6bf6533023326fa017812cf31bbe20c752d36 (patch) | |
tree | 9c4e3ecdc344420190f17d429bdf05d78fae7a8c /server/types/models/video/video-playlist.ts | |
parent | d6d951ddc0c492f3261065b5dcb4df0534d252fc (diff) | |
download | PeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.tar.gz PeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.tar.zst PeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.zip |
Split types and typings
Diffstat (limited to 'server/types/models/video/video-playlist.ts')
-rw-r--r-- | server/types/models/video/video-playlist.ts | 104 |
1 files changed, 104 insertions, 0 deletions
diff --git a/server/types/models/video/video-playlist.ts b/server/types/models/video/video-playlist.ts new file mode 100644 index 000000000..b504d1664 --- /dev/null +++ b/server/types/models/video/video-playlist.ts | |||
@@ -0,0 +1,104 @@ | |||
1 | import { VideoPlaylistModel } from '../../../models/video/video-playlist' | ||
2 | import { PickWith } from '../../utils' | ||
3 | import { MAccount, MAccountDefault, MAccountSummary, MAccountSummaryFormattable } from '../account' | ||
4 | import { MThumbnail } from './thumbnail' | ||
5 | import { MChannelDefault, MChannelSummary, MChannelSummaryFormattable, MChannelUrl } from './video-channels' | ||
6 | import { MVideoPlaylistElementLight } from '@server/types/models/video/video-playlist-element' | ||
7 | |||
8 | type Use<K extends keyof VideoPlaylistModel, M> = PickWith<VideoPlaylistModel, K, M> | ||
9 | |||
10 | // ############################################################################ | ||
11 | |||
12 | export type MVideoPlaylist = Omit<VideoPlaylistModel, 'OwnerAccount' | 'VideoChannel' | 'VideoPlaylistElements' | 'Thumbnail'> | ||
13 | |||
14 | // ############################################################################ | ||
15 | |||
16 | export type MVideoPlaylistId = Pick<MVideoPlaylist, 'id'> | ||
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 | ||
24 | |||
25 | export type MVideoPlaylistWithElements = | ||
26 | MVideoPlaylist & | ||
27 | Use<'VideoPlaylistElements', MVideoPlaylistElementLight[]> | ||
28 | |||
29 | export type MVideoPlaylistIdWithElements = | ||
30 | MVideoPlaylistId & | ||
31 | Use<'VideoPlaylistElements', MVideoPlaylistElementLight[]> | ||
32 | |||
33 | // ############################################################################ | ||
34 | |||
35 | // With account | ||
36 | |||
37 | export type MVideoPlaylistOwner = | ||
38 | MVideoPlaylist & | ||
39 | Use<'OwnerAccount', MAccount> | ||
40 | |||
41 | export type MVideoPlaylistOwnerDefault = | ||
42 | MVideoPlaylist & | ||
43 | Use<'OwnerAccount', MAccountDefault> | ||
44 | |||
45 | // ############################################################################ | ||
46 | |||
47 | // With thumbnail | ||
48 | |||
49 | export type MVideoPlaylistThumbnail = | ||
50 | MVideoPlaylist & | ||
51 | Use<'Thumbnail', MThumbnail> | ||
52 | |||
53 | export type MVideoPlaylistAccountThumbnail = | ||
54 | MVideoPlaylist & | ||
55 | Use<'OwnerAccount', MAccountDefault> & | ||
56 | Use<'Thumbnail', MThumbnail> | ||
57 | |||
58 | // ############################################################################ | ||
59 | |||
60 | // With channel | ||
61 | |||
62 | export type MVideoPlaylistAccountChannelDefault = | ||
63 | MVideoPlaylist & | ||
64 | Use<'OwnerAccount', MAccountDefault> & | ||
65 | Use<'VideoChannel', MChannelDefault> | ||
66 | |||
67 | // ############################################################################ | ||
68 | |||
69 | // With all associations | ||
70 | |||
71 | export type MVideoPlaylistFull = | ||
72 | MVideoPlaylist & | ||
73 | Use<'OwnerAccount', MAccountDefault> & | ||
74 | Use<'VideoChannel', MChannelDefault> & | ||
75 | Use<'Thumbnail', MThumbnail> | ||
76 | |||
77 | // ############################################################################ | ||
78 | |||
79 | // For API | ||
80 | |||
81 | export type MVideoPlaylistAccountChannelSummary = | ||
82 | MVideoPlaylist & | ||
83 | Use<'OwnerAccount', MAccountSummary> & | ||
84 | Use<'VideoChannel', MChannelSummary> | ||
85 | |||
86 | export type MVideoPlaylistFullSummary = | ||
87 | MVideoPlaylist & | ||
88 | Use<'Thumbnail', MThumbnail> & | ||
89 | Use<'OwnerAccount', MAccountSummary> & | ||
90 | Use<'VideoChannel', MChannelSummary> | ||
91 | |||
92 | // ############################################################################ | ||
93 | |||
94 | // Format for API or AP object | ||
95 | |||
96 | export type MVideoPlaylistFormattable = | ||
97 | MVideoPlaylistVideosLength & | ||
98 | Use<'OwnerAccount', MAccountSummaryFormattable> & | ||
99 | Use<'VideoChannel', MChannelSummaryFormattable> | ||
100 | |||
101 | export type MVideoPlaylistAP = | ||
102 | MVideoPlaylist & | ||
103 | Use<'Thumbnail', MThumbnail> & | ||
104 | Use<'VideoChannel', MChannelUrl> | ||