]>
Commit | Line | Data |
---|---|---|
1ca9f7c3 | 1 | import { FunctionProperties, PickWith, PickWithOpt } from '../../utils' |
453e83ea C |
2 | import { VideoChannelModel } from '../../../models/video/video-channel' |
3 | import { | |
4 | MAccountActor, | |
5 | MAccountAPI, | |
453e83ea | 6 | MAccountDefault, |
1ca9f7c3 | 7 | MAccountFormattable, |
453e83ea | 8 | MAccountLight, |
0283eaac | 9 | MAccountSummaryBlocks, |
1ca9f7c3 | 10 | MAccountSummaryFormattable, |
b5fecbf4 | 11 | MAccountUrl, |
453e83ea C |
12 | MAccountUserId, |
13 | MActor, | |
14 | MActorAccountChannelId, | |
b5fecbf4 | 15 | MActorAP, |
453e83ea C |
16 | MActorAPI, |
17 | MActorDefault, | |
0283eaac | 18 | MActorDefaultLight, |
1ca9f7c3 | 19 | MActorFormattable, |
0283eaac | 20 | MActorLight, |
1ca9f7c3 | 21 | MActorSummary, |
b5fecbf4 | 22 | MActorSummaryFormattable, MActorUrl |
453e83ea C |
23 | } from '../account' |
24 | import { MVideo } from './video' | |
25 | ||
0283eaac C |
26 | type Use<K extends keyof VideoChannelModel, M> = PickWith<VideoChannelModel, K, M> |
27 | ||
28 | // ############################################################################ | |
453e83ea C |
29 | |
30 | export type MChannel = Omit<VideoChannelModel, 'Actor' | 'Account' | 'Videos' | 'VideoPlaylists'> | |
31 | ||
0283eaac C |
32 | // ############################################################################ |
33 | ||
34 | export type MChannelId = Pick<MChannel, 'id'> | |
35 | ||
36 | // ############################################################################ | |
37 | ||
38 | export type MChannelIdActor = MChannelId & | |
39 | Use<'Actor', MActorAccountChannelId> | |
40 | ||
453e83ea | 41 | export type MChannelUserId = Pick<MChannel, 'accountId'> & |
0283eaac C |
42 | Use<'Account', MAccountUserId> |
43 | ||
44 | export type MChannelActor = MChannel & | |
45 | Use<'Actor', MActor> | |
453e83ea | 46 | |
b5fecbf4 C |
47 | export type MChannelUrl = Use<'Actor', MActorUrl> |
48 | ||
453e83ea C |
49 | // Default scope |
50 | export type MChannelDefault = MChannel & | |
0283eaac C |
51 | Use<'Actor', MActorDefault> |
52 | ||
53 | // ############################################################################ | |
54 | ||
55 | // Not all association attributes | |
453e83ea C |
56 | |
57 | export type MChannelLight = MChannel & | |
0283eaac | 58 | Use<'Actor', MActorDefaultLight> |
453e83ea | 59 | |
0283eaac C |
60 | export type MChannelActorLight = MChannel & |
61 | Use<'Actor', MActorLight> | |
453e83ea | 62 | |
0283eaac C |
63 | export type MChannelAccountLight = MChannel & |
64 | Use<'Actor', MActorDefaultLight> & | |
65 | Use<'Account', MAccountLight> | |
453e83ea | 66 | |
0283eaac | 67 | // ############################################################################ |
453e83ea | 68 | |
0283eaac | 69 | // Account associations |
453e83ea C |
70 | |
71 | export type MChannelAccountActor = MChannel & | |
0283eaac C |
72 | Use<'Account', MAccountActor> |
73 | ||
74 | export type MChannelAccountDefault = MChannel & | |
75 | Use<'Actor', MActorDefault> & | |
76 | Use<'Account', MAccountDefault> | |
453e83ea | 77 | |
0283eaac C |
78 | export type MChannelActorAccountActor = MChannel & |
79 | Use<'Account', MAccountActor> & | |
80 | Use<'Actor', MActor> | |
81 | ||
82 | // ############################################################################ | |
83 | ||
84 | // Videos associations | |
453e83ea | 85 | export type MChannelVideos = MChannel & |
0283eaac | 86 | Use<'Videos', MVideo[]> |
453e83ea | 87 | |
0283eaac C |
88 | export type MChannelActorAccountDefaultVideos = MChannel & |
89 | Use<'Actor', MActorDefault> & | |
90 | Use<'Account', MAccountDefault> & | |
91 | Use<'Videos', MVideo[]> | |
92 | ||
93 | // ############################################################################ | |
94 | ||
95 | // For API | |
453e83ea | 96 | |
1ca9f7c3 C |
97 | export type MChannelSummary = FunctionProperties<MChannel> & |
98 | Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> & | |
0283eaac | 99 | Use<'Actor', MActorSummary> |
453e83ea | 100 | |
0283eaac C |
101 | export type MChannelSummaryAccount = MChannelSummary & |
102 | Use<'Account', MAccountSummaryBlocks> | |
453e83ea | 103 | |
0283eaac C |
104 | export type MChannelAPI = MChannel & |
105 | Use<'Actor', MActorAPI> & | |
106 | Use<'Account', MAccountAPI> | |
1ca9f7c3 C |
107 | |
108 | // ############################################################################ | |
109 | ||
110 | // Format for API or AP object | |
111 | ||
112 | export type MChannelSummaryFormattable = FunctionProperties<MChannel> & | |
113 | Pick<MChannel, 'id' | 'name'> & | |
114 | Use<'Actor', MActorSummaryFormattable> | |
115 | ||
116 | export type MChannelAccountSummaryFormattable = MChannelSummaryFormattable & | |
117 | Use<'Account', MAccountSummaryFormattable> | |
118 | ||
119 | export type MChannelFormattable = FunctionProperties<MChannel> & | |
120 | Pick<MChannel, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'support'> & | |
121 | Use<'Actor', MActorFormattable> & | |
122 | PickWithOpt<VideoChannelModel, 'Account', MAccountFormattable> | |
b5fecbf4 C |
123 | |
124 | export type MChannelAP = Pick<MChannel, 'name' | 'description' | 'support'> & | |
125 | Use<'Actor', MActorAP> & | |
126 | Use<'Account', MAccountUrl> |