1 import { FunctionProperties, PickWith, PickWithOpt } from '../../utils'
2 import { VideoChannelModel } from '../../../models/video/video-channel'
10 MAccountSummaryFormattable,
14 MActorAccountChannelId,
22 MActorSummaryFormattable, MActorUrl
24 import { MVideo } from './video'
26 type Use<K extends keyof VideoChannelModel, M> = PickWith<VideoChannelModel, K, M>
28 // ############################################################################
30 export type MChannel = Omit<VideoChannelModel, 'Actor' | 'Account' | 'Videos' | 'VideoPlaylists'>
32 // ############################################################################
34 export type MChannelId = Pick<MChannel, 'id'>
36 // ############################################################################
38 export type MChannelIdActor = MChannelId &
39 Use<'Actor', MActorAccountChannelId>
41 export type MChannelUserId = Pick<MChannel, 'accountId'> &
42 Use<'Account', MAccountUserId>
44 export type MChannelActor = MChannel &
47 export type MChannelUrl = Use<'Actor', MActorUrl>
50 export type MChannelDefault = MChannel &
51 Use<'Actor', MActorDefault>
53 // ############################################################################
55 // Not all association attributes
57 export type MChannelLight = MChannel &
58 Use<'Actor', MActorDefaultLight>
60 export type MChannelActorLight = MChannel &
61 Use<'Actor', MActorLight>
63 export type MChannelAccountLight = MChannel &
64 Use<'Actor', MActorDefaultLight> &
65 Use<'Account', MAccountLight>
67 // ############################################################################
69 // Account associations
71 export type MChannelAccountActor = MChannel &
72 Use<'Account', MAccountActor>
74 export type MChannelAccountDefault = MChannel &
75 Use<'Actor', MActorDefault> &
76 Use<'Account', MAccountDefault>
78 export type MChannelActorAccountActor = MChannel &
79 Use<'Account', MAccountActor> &
82 // ############################################################################
84 // Videos associations
85 export type MChannelVideos = MChannel &
86 Use<'Videos', MVideo[]>
88 export type MChannelActorAccountDefaultVideos = MChannel &
89 Use<'Actor', MActorDefault> &
90 Use<'Account', MAccountDefault> &
91 Use<'Videos', MVideo[]>
93 // ############################################################################
97 export type MChannelSummary = FunctionProperties<MChannel> &
98 Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> &
99 Use<'Actor', MActorSummary>
101 export type MChannelSummaryAccount = MChannelSummary &
102 Use<'Account', MAccountSummaryBlocks>
104 export type MChannelAPI = MChannel &
105 Use<'Actor', MActorAPI> &
106 Use<'Account', MAccountAPI>
108 // ############################################################################
110 // Format for API or AP object
112 export type MChannelSummaryFormattable = FunctionProperties<MChannel> &
113 Pick<MChannel, 'id' | 'name'> &
114 Use<'Actor', MActorSummaryFormattable>
116 export type MChannelAccountSummaryFormattable = MChannelSummaryFormattable &
117 Use<'Account', MAccountSummaryFormattable>
119 export type MChannelFormattable = FunctionProperties<MChannel> &
120 Pick<MChannel, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'support'> &
121 Use<'Actor', MActorFormattable> &
122 PickWithOpt<VideoChannelModel, 'Account', MAccountFormattable>
124 export type MChannelAP = Pick<MChannel, 'name' | 'description' | 'support'> &
125 Use<'Actor', MActorAP> &
126 Use<'Account', MAccountUrl>