1 import { FunctionProperties, PickWith, PickWithOpt } from '../../utils'
2 import { VideoChannelModel } from '../../../models/video/video-channel'
10 MAccountSummaryFormattable,
13 MActorAccountChannelId,
20 MActorSummaryFormattable
22 import { MVideo } from './video'
24 type Use<K extends keyof VideoChannelModel, M> = PickWith<VideoChannelModel, K, M>
26 // ############################################################################
28 export type MChannel = Omit<VideoChannelModel, 'Actor' | 'Account' | 'Videos' | 'VideoPlaylists'>
30 // ############################################################################
32 export type MChannelId = Pick<MChannel, 'id'>
34 // ############################################################################
36 export type MChannelIdActor = MChannelId &
37 Use<'Actor', MActorAccountChannelId>
39 export type MChannelUserId = Pick<MChannel, 'accountId'> &
40 Use<'Account', MAccountUserId>
42 export type MChannelActor = MChannel &
46 export type MChannelDefault = MChannel &
47 Use<'Actor', MActorDefault>
49 // ############################################################################
51 // Not all association attributes
53 export type MChannelLight = MChannel &
54 Use<'Actor', MActorDefaultLight>
56 export type MChannelActorLight = MChannel &
57 Use<'Actor', MActorLight>
59 export type MChannelAccountLight = MChannel &
60 Use<'Actor', MActorDefaultLight> &
61 Use<'Account', MAccountLight>
63 // ############################################################################
65 // Account associations
67 export type MChannelAccountActor = MChannel &
68 Use<'Account', MAccountActor>
70 export type MChannelAccountDefault = MChannel &
71 Use<'Actor', MActorDefault> &
72 Use<'Account', MAccountDefault>
74 export type MChannelActorAccountActor = MChannel &
75 Use<'Account', MAccountActor> &
78 // ############################################################################
80 // Videos associations
81 export type MChannelVideos = MChannel &
82 Use<'Videos', MVideo[]>
84 export type MChannelActorAccountDefaultVideos = MChannel &
85 Use<'Actor', MActorDefault> &
86 Use<'Account', MAccountDefault> &
87 Use<'Videos', MVideo[]>
89 // ############################################################################
93 export type MChannelSummary = FunctionProperties<MChannel> &
94 Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> &
95 Use<'Actor', MActorSummary>
97 export type MChannelSummaryAccount = MChannelSummary &
98 Use<'Account', MAccountSummaryBlocks>
100 export type MChannelAPI = MChannel &
101 Use<'Actor', MActorAPI> &
102 Use<'Account', MAccountAPI>
104 // ############################################################################
106 // Format for API or AP object
108 export type MChannelSummaryFormattable = FunctionProperties<MChannel> &
109 Pick<MChannel, 'id' | 'name'> &
110 Use<'Actor', MActorSummaryFormattable>
112 export type MChannelAccountSummaryFormattable = MChannelSummaryFormattable &
113 Use<'Account', MAccountSummaryFormattable>
115 export type MChannelFormattable = FunctionProperties<MChannel> &
116 Pick<MChannel, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'support'> &
117 Use<'Actor', MActorFormattable> &
118 PickWithOpt<VideoChannelModel, 'Account', MAccountFormattable>