1 import { FunctionProperties, PickWith, PickWithOpt } from '@shared/core-utils'
2 import { VideoChannelModel } from '../../../models/video/video-channel'
10 MAccountSummaryFormattable,
14 MActorAccountChannelId,
23 MActorSummaryFormattable, MActorUrl
25 import { MVideo } from './video'
27 type Use<K extends keyof VideoChannelModel, M> = PickWith<VideoChannelModel, K, M>
29 // ############################################################################
31 export type MChannel = Omit<VideoChannelModel, 'Actor' | 'Account' | 'Videos' | 'VideoPlaylists'>
33 // ############################################################################
35 export type MChannelId = Pick<MChannel, 'id'>
37 // ############################################################################
39 export type MChannelIdActor =
41 Use<'Actor', MActorAccountChannelId>
43 export type MChannelUserId =
44 Pick<MChannel, 'accountId'> &
45 Use<'Account', MAccountUserId>
47 export type MChannelActor =
51 export type MChannelUrl = Use<'Actor', MActorUrl>
54 export type MChannelDefault =
56 Use<'Actor', MActorDefault>
58 // ############################################################################
60 // Not all association attributes
62 export type MChannelLight =
64 Use<'Actor', MActorDefaultLight>
66 export type MChannelActorLight =
68 Use<'Actor', MActorLight>
70 export type MChannelAccountLight =
72 Use<'Actor', MActorDefaultLight> &
73 Use<'Account', MAccountLight>
75 export type MChannelHost =
77 Use<'Actor', MActorHost>
79 // ############################################################################
81 // Account associations
83 export type MChannelAccountActor =
85 Use<'Account', MAccountActor>
87 export type MChannelAccountDefault =
89 Use<'Actor', MActorDefault> &
90 Use<'Account', MAccountDefault>
92 export type MChannelActorAccountActor =
94 Use<'Account', MAccountActor> &
97 // ############################################################################
99 // Videos associations
100 export type MChannelVideos =
102 Use<'Videos', MVideo[]>
104 export type MChannelActorAccountDefaultVideos =
106 Use<'Actor', MActorDefault> &
107 Use<'Account', MAccountDefault> &
108 Use<'Videos', MVideo[]>
110 // ############################################################################
114 export type MChannelSummary =
115 FunctionProperties<MChannel> &
116 Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> &
117 Use<'Actor', MActorSummary>
119 export type MChannelSummaryAccount =
121 Use<'Account', MAccountSummaryBlocks>
123 export type MChannelAPI =
125 Use<'Actor', MActorAPI> &
126 Use<'Account', MAccountAPI>
128 // ############################################################################
130 // Format for API or AP object
132 export type MChannelSummaryFormattable =
133 FunctionProperties<MChannel> &
134 Pick<MChannel, 'id' | 'name'> &
135 Use<'Actor', MActorSummaryFormattable>
137 export type MChannelAccountSummaryFormattable =
138 MChannelSummaryFormattable &
139 Use<'Account', MAccountSummaryFormattable>
141 export type MChannelFormattable =
142 FunctionProperties<MChannel> &
143 Pick<MChannel, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'support'> &
144 Use<'Actor', MActorFormattable> &
145 PickWithOpt<VideoChannelModel, 'Account', MAccountFormattable>
147 export type MChannelAP =
148 Pick<MChannel, 'name' | 'description' | 'support'> &
149 Use<'Actor', MActorAP> &
150 Use<'Account', MAccountUrl>