Stronger model typings
[oweals/peertube.git] / server / typings / models / video / video-channels.ts
1 import { FunctionProperties, PickWith } from '../../utils'
2 import { VideoChannelModel } from '../../../models/video/video-channel'
3 import {
4   MAccountActor,
5   MAccountAPI,
6   MAccountBlocks,
7   MAccountDefault,
8   MAccountLight,
9   MAccountUserId,
10   MActor,
11   MActorAccountChannelId,
12   MActorAPI,
13   MActorDefault,
14   MActorDefaultLight, MActorLight,
15   MActorSummary
16 } from '../account'
17 import { MVideo } from './video'
18
19 export type MChannelId = FunctionProperties<VideoChannelModel>
20 export type MChannelIdActor = MChannelId &
21   PickWith<VideoChannelModel, 'Actor', MActorAccountChannelId>
22
23 export type MChannel = Omit<VideoChannelModel, 'Actor' | 'Account' | 'Videos' | 'VideoPlaylists'>
24
25 export type MChannelUserId = Pick<MChannel, 'accountId'> &
26   PickWith<VideoChannelModel, 'Account', MAccountUserId>
27
28 // Default scope
29 export type MChannelDefault = MChannel &
30   PickWith<VideoChannelModel, 'Actor', MActorDefault>
31
32 export type MChannelLight = MChannel &
33   PickWith<VideoChannelModel, 'Actor', MActorDefaultLight>
34
35 export type MChannelAccountLight = MChannel &
36   PickWith<VideoChannelModel, 'Actor', MActorDefaultLight> &
37   PickWith<VideoChannelModel, 'Account', MAccountLight>
38
39 export type MChannelSummary = Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> &
40   PickWith<VideoChannelModel, 'Actor', MActorSummary>
41
42 export type MChannelSummaryAccount = MChannelSummary &
43   PickWith<VideoChannelModel, 'Account', MAccountBlocks>
44
45 export type MChannelAPI = MChannel &
46   PickWith<VideoChannelModel, 'Actor', MActorAPI> &
47   PickWith<VideoChannelModel, 'Account', MAccountAPI>
48
49 export type MChannelAccountActor = MChannel &
50   PickWith<VideoChannelModel, 'Account', MAccountActor>
51 export type MChannelAccountDefault = MChannelActor &
52   PickWith<VideoChannelModel, 'Account', MAccountDefault>
53
54 export type MChannelVideos = MChannel &
55   PickWith<VideoChannelModel, 'Videos', MVideo[]>
56
57 export type MChannelActor = MChannel &
58   PickWith<VideoChannelModel, 'Actor', MActor>
59 export type MChannelActorLight = MChannel &
60   PickWith<VideoChannelModel, 'Actor', MActorLight>
61 export type MChannelActorDefault = MChannel &
62   PickWith<VideoChannelModel, 'Actor', MActorDefault>
63
64 export type MChannelActorAccountActor = MChannelAccountActor & MChannelActor
65
66 export type MChannelActorAccountDefault = MChannel &
67   PickWith<VideoChannelModel, 'Actor', MActorDefault> &
68   PickWith<VideoChannelModel, 'Account', MAccountDefault>
69
70 export type MChannelActorAccountDefaultVideos = MChannelActorAccountDefault & MChannelVideos