1 import { FunctionProperties, PickWith, PickWithOpt } from '@shared/core-utils'
2 import { VideoChannelModel } from '../../../models/video/video-channel'
10 MAccountSummaryFormattable,
16 MActorAccountChannelId,
26 MActorSummaryFormattable,
29 import { MVideo } from './video'
31 type Use<K extends keyof VideoChannelModel, M> = PickWith<VideoChannelModel, K, M>
33 // ############################################################################
35 export type MChannel = Omit<VideoChannelModel, 'Actor' | 'Account' | 'Videos' | 'VideoPlaylists'>
37 // ############################################################################
39 export type MChannelId = Pick<MChannel, 'id'>
41 // ############################################################################
43 export type MChannelIdActor =
45 Use<'Actor', MActorAccountChannelId>
47 export type MChannelUserId =
48 Pick<MChannel, 'accountId'> &
49 Use<'Account', MAccountUserId>
51 export type MChannelActor =
55 export type MChannelUrl = Use<'Actor', MActorUrl>
58 export type MChannelDefault =
60 Use<'Actor', MActorDefault>
62 export type MChannelBannerDefault =
64 Use<'Actor', MActorDefaultBanner>
66 // ############################################################################
68 // Not all association attributes
70 export type MChannelActorLight =
72 Use<'Actor', MActorLight>
74 export type MChannelAccountLight =
76 Use<'Actor', MActorDefaultLight> &
77 Use<'Account', MAccountLight>
79 export type MChannelHost =
81 Use<'Actor', MActorHost>
83 // ############################################################################
85 // Account associations
87 export type MChannelAccountActor =
89 Use<'Account', MAccountActor>
91 export type MChannelBannerAccountDefault =
93 Use<'Actor', MActorDefaultBanner> &
94 Use<'Account', MAccountDefault>
96 export type MChannelAccountDefault =
98 Use<'Actor', MActorDefault> &
99 Use<'Account', MAccountDefault>
101 // ############################################################################
103 // Videos associations
104 export type MChannelVideos =
106 Use<'Videos', MVideo[]>
108 // ############################################################################
112 export type MChannelSummary =
113 FunctionProperties<MChannel> &
114 Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> &
115 Use<'Actor', MActorSummary>
117 export type MChannelSummaryAccount =
119 Use<'Account', MAccountSummaryBlocks>
121 export type MChannelAPI =
123 Use<'Actor', MActorAPI> &
124 Use<'Account', MAccountAPI>
126 // ############################################################################
128 // Format for API or AP object
130 export type MChannelSummaryFormattable =
131 FunctionProperties<MChannel> &
132 Pick<MChannel, 'id' | 'name'> &
133 Use<'Actor', MActorSummaryFormattable>
135 export type MChannelAccountSummaryFormattable =
136 MChannelSummaryFormattable &
137 Use<'Account', MAccountSummaryFormattable>
139 export type MChannelFormattable =
140 FunctionProperties<MChannel> &
141 Pick<MChannel, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'support'> &
142 Use<'Actor', MActorFormattable> &
143 PickWithOpt<VideoChannelModel, 'Account', MAccountFormattable>
145 export type MChannelAP =
146 Pick<MChannel, 'name' | 'description' | 'support'> &
147 Use<'Actor', MActorAPChannel> &
148 Use<'Account', MAccountUrl>