1 import { FunctionProperties, PickWith, PickWithOpt } from '@shared/typescript-utils'
2 import { VideoChannelModel } from '../../../models/video/video-channel'
10 MAccountSummaryFormattable,
16 MActorAccountChannelId,
27 MActorSummaryFormattable,
30 import { MVideo } from './video'
32 type Use<K extends keyof VideoChannelModel, M> = PickWith<VideoChannelModel, K, M>
34 // ############################################################################
36 export type MChannel = Omit<VideoChannelModel, 'Actor' | 'Account' | 'Videos' | 'VideoPlaylists'>
38 // ############################################################################
40 export type MChannelId = Pick<MChannel, 'id'>
42 // ############################################################################
44 export type MChannelIdActor =
46 Use<'Actor', MActorAccountChannelId>
48 export type MChannelUserId =
49 Pick<MChannel, 'accountId'> &
50 Use<'Account', MAccountUserId>
52 export type MChannelActor =
56 export type MChannelUrl = Use<'Actor', MActorUrl>
59 export type MChannelDefault =
61 Use<'Actor', MActorDefault>
63 export type MChannelBannerDefault =
65 Use<'Actor', MActorDefaultBanner>
67 // ############################################################################
69 // Not all association attributes
71 export type MChannelActorLight =
73 Use<'Actor', MActorLight>
75 export type MChannelAccountLight =
77 Use<'Actor', MActorDefaultLight> &
78 Use<'Account', MAccountLight>
80 export type MChannelHost =
82 Use<'Actor', MActorHost>
84 export type MChannelHostOnly =
86 Use<'Actor', MActorHostOnly>
88 // ############################################################################
90 // Account associations
92 export type MChannelAccountActor =
94 Use<'Account', MAccountActor>
96 export type MChannelBannerAccountDefault =
98 Use<'Actor', MActorDefaultBanner> &
99 Use<'Account', MAccountDefault>
101 export type MChannelAccountDefault =
103 Use<'Actor', MActorDefault> &
104 Use<'Account', MAccountDefault>
106 // ############################################################################
108 // Videos associations
109 export type MChannelVideos =
111 Use<'Videos', MVideo[]>
113 // ############################################################################
117 export type MChannelSummary =
118 FunctionProperties<MChannel> &
119 Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> &
120 Use<'Actor', MActorSummary>
122 export type MChannelSummaryAccount =
124 Use<'Account', MAccountSummaryBlocks>
126 export type MChannelAPI =
128 Use<'Actor', MActorAPI> &
129 Use<'Account', MAccountAPI>
131 // ############################################################################
133 // Format for API or AP object
135 export type MChannelSummaryFormattable =
136 FunctionProperties<MChannel> &
137 Pick<MChannel, 'id' | 'name'> &
138 Use<'Actor', MActorSummaryFormattable>
140 export type MChannelAccountSummaryFormattable =
141 MChannelSummaryFormattable &
142 Use<'Account', MAccountSummaryFormattable>
144 export type MChannelFormattable =
145 FunctionProperties<MChannel> &
146 Pick<MChannel, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'support'> &
147 Use<'Actor', MActorFormattable> &
148 PickWithOpt<VideoChannelModel, 'Account', MAccountFormattable>
150 export type MChannelAP =
151 Pick<MChannel, 'name' | 'description' | 'support'> &
152 Use<'Actor', MActorAPChannel> &
153 Use<'Account', MAccountUrl>