diff options
Diffstat (limited to 'server/typings/models/video/video-channels.ts')
-rw-r--r-- | server/typings/models/video/video-channels.ts | 95 |
1 files changed, 61 insertions, 34 deletions
diff --git a/server/typings/models/video/video-channels.ts b/server/typings/models/video/video-channels.ts index e10bd6842..b6506ed9f 100644 --- a/server/typings/models/video/video-channels.ts +++ b/server/typings/models/video/video-channels.ts | |||
@@ -1,70 +1,97 @@ | |||
1 | import { FunctionProperties, PickWith } from '../../utils' | 1 | import { PickWith } from '../../utils' |
2 | import { VideoChannelModel } from '../../../models/video/video-channel' | 2 | import { VideoChannelModel } from '../../../models/video/video-channel' |
3 | import { | 3 | import { |
4 | MAccountActor, | 4 | MAccountActor, |
5 | MAccountAPI, | 5 | MAccountAPI, |
6 | MAccountBlocks, | ||
7 | MAccountDefault, | 6 | MAccountDefault, |
8 | MAccountLight, | 7 | MAccountLight, |
8 | MAccountSummaryBlocks, | ||
9 | MAccountUserId, | 9 | MAccountUserId, |
10 | MActor, | 10 | MActor, |
11 | MActorAccountChannelId, | 11 | MActorAccountChannelId, |
12 | MActorAPI, | 12 | MActorAPI, |
13 | MActorDefault, | 13 | MActorDefault, |
14 | MActorDefaultLight, MActorLight, | 14 | MActorDefaultLight, |
15 | MActorLight, | ||
15 | MActorSummary | 16 | MActorSummary |
16 | } from '../account' | 17 | } from '../account' |
17 | import { MVideo } from './video' | 18 | import { MVideo } from './video' |
18 | 19 | ||
19 | export type MChannelId = FunctionProperties<VideoChannelModel> | 20 | type Use<K extends keyof VideoChannelModel, M> = PickWith<VideoChannelModel, K, M> |
20 | export type MChannelIdActor = MChannelId & | 21 | |
21 | PickWith<VideoChannelModel, 'Actor', MActorAccountChannelId> | 22 | // ############################################################################ |
22 | 23 | ||
23 | export type MChannel = Omit<VideoChannelModel, 'Actor' | 'Account' | 'Videos' | 'VideoPlaylists'> | 24 | export type MChannel = Omit<VideoChannelModel, 'Actor' | 'Account' | 'Videos' | 'VideoPlaylists'> |
24 | 25 | ||
26 | // ############################################################################ | ||
27 | |||
28 | export type MChannelId = Pick<MChannel, 'id'> | ||
29 | |||
30 | // ############################################################################ | ||
31 | |||
32 | export type MChannelIdActor = MChannelId & | ||
33 | Use<'Actor', MActorAccountChannelId> | ||
34 | |||
25 | export type MChannelUserId = Pick<MChannel, 'accountId'> & | 35 | export type MChannelUserId = Pick<MChannel, 'accountId'> & |
26 | PickWith<VideoChannelModel, 'Account', MAccountUserId> | 36 | Use<'Account', MAccountUserId> |
37 | |||
38 | export type MChannelActor = MChannel & | ||
39 | Use<'Actor', MActor> | ||
27 | 40 | ||
28 | // Default scope | 41 | // Default scope |
29 | export type MChannelDefault = MChannel & | 42 | export type MChannelDefault = MChannel & |
30 | PickWith<VideoChannelModel, 'Actor', MActorDefault> | 43 | Use<'Actor', MActorDefault> |
44 | |||
45 | // ############################################################################ | ||
46 | |||
47 | // Not all association attributes | ||
31 | 48 | ||
32 | export type MChannelLight = MChannel & | 49 | export type MChannelLight = MChannel & |
33 | PickWith<VideoChannelModel, 'Actor', MActorDefaultLight> | 50 | Use<'Actor', MActorDefaultLight> |
34 | 51 | ||
35 | export type MChannelAccountLight = MChannel & | 52 | export type MChannelActorLight = MChannel & |
36 | PickWith<VideoChannelModel, 'Actor', MActorDefaultLight> & | 53 | Use<'Actor', MActorLight> |
37 | PickWith<VideoChannelModel, 'Account', MAccountLight> | ||
38 | 54 | ||
39 | export type MChannelSummary = Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> & | 55 | export type MChannelAccountLight = MChannel & |
40 | PickWith<VideoChannelModel, 'Actor', MActorSummary> | 56 | Use<'Actor', MActorDefaultLight> & |
57 | Use<'Account', MAccountLight> | ||
41 | 58 | ||
42 | export type MChannelSummaryAccount = MChannelSummary & | 59 | // ############################################################################ |
43 | PickWith<VideoChannelModel, 'Account', MAccountBlocks> | ||
44 | 60 | ||
45 | export type MChannelAPI = MChannel & | 61 | // Account associations |
46 | PickWith<VideoChannelModel, 'Actor', MActorAPI> & | ||
47 | PickWith<VideoChannelModel, 'Account', MAccountAPI> | ||
48 | 62 | ||
49 | export type MChannelAccountActor = MChannel & | 63 | export type MChannelAccountActor = MChannel & |
50 | PickWith<VideoChannelModel, 'Account', MAccountActor> | 64 | Use<'Account', MAccountActor> |
51 | export type MChannelAccountDefault = MChannelActor & | 65 | |
52 | PickWith<VideoChannelModel, 'Account', MAccountDefault> | 66 | export type MChannelAccountDefault = MChannel & |
67 | Use<'Actor', MActorDefault> & | ||
68 | Use<'Account', MAccountDefault> | ||
53 | 69 | ||
70 | export type MChannelActorAccountActor = MChannel & | ||
71 | Use<'Account', MAccountActor> & | ||
72 | Use<'Actor', MActor> | ||
73 | |||
74 | // ############################################################################ | ||
75 | |||
76 | // Videos associations | ||
54 | export type MChannelVideos = MChannel & | 77 | export type MChannelVideos = MChannel & |
55 | PickWith<VideoChannelModel, 'Videos', MVideo[]> | 78 | Use<'Videos', MVideo[]> |
56 | 79 | ||
57 | export type MChannelActor = MChannel & | 80 | export type MChannelActorAccountDefaultVideos = MChannel & |
58 | PickWith<VideoChannelModel, 'Actor', MActor> | 81 | Use<'Actor', MActorDefault> & |
59 | export type MChannelActorLight = MChannel & | 82 | Use<'Account', MAccountDefault> & |
60 | PickWith<VideoChannelModel, 'Actor', MActorLight> | 83 | Use<'Videos', MVideo[]> |
61 | export type MChannelActorDefault = MChannel & | 84 | |
62 | PickWith<VideoChannelModel, 'Actor', MActorDefault> | 85 | // ############################################################################ |
86 | |||
87 | // For API | ||
63 | 88 | ||
64 | export type MChannelActorAccountActor = MChannelAccountActor & MChannelActor | 89 | export type MChannelSummary = Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> & |
90 | Use<'Actor', MActorSummary> | ||
65 | 91 | ||
66 | export type MChannelActorAccountDefault = MChannel & | 92 | export type MChannelSummaryAccount = MChannelSummary & |
67 | PickWith<VideoChannelModel, 'Actor', MActorDefault> & | 93 | Use<'Account', MAccountSummaryBlocks> |
68 | PickWith<VideoChannelModel, 'Account', MAccountDefault> | ||
69 | 94 | ||
70 | export type MChannelActorAccountDefaultVideos = MChannelActorAccountDefault & MChannelVideos | 95 | export type MChannelAPI = MChannel & |
96 | Use<'Actor', MActorAPI> & | ||
97 | Use<'Account', MAccountAPI> | ||