]>
Commit | Line | Data |
---|---|---|
67ed6552 | 1 | import { FunctionProperties, PickWith, PickWithOpt } from '@shared/core-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 | ||
a1587156 C |
38 | export type MChannelIdActor = |
39 | MChannelId & | |
0283eaac C |
40 | Use<'Actor', MActorAccountChannelId> |
41 | ||
a1587156 C |
42 | export type MChannelUserId = |
43 | Pick<MChannel, 'accountId'> & | |
0283eaac C |
44 | Use<'Account', MAccountUserId> |
45 | ||
a1587156 C |
46 | export type MChannelActor = |
47 | MChannel & | |
0283eaac | 48 | Use<'Actor', MActor> |
453e83ea | 49 | |
b5fecbf4 C |
50 | export type MChannelUrl = Use<'Actor', MActorUrl> |
51 | ||
453e83ea | 52 | // Default scope |
a1587156 C |
53 | export type MChannelDefault = |
54 | MChannel & | |
0283eaac C |
55 | Use<'Actor', MActorDefault> |
56 | ||
57 | // ############################################################################ | |
58 | ||
59 | // Not all association attributes | |
453e83ea | 60 | |
a1587156 C |
61 | export type MChannelLight = |
62 | MChannel & | |
0283eaac | 63 | Use<'Actor', MActorDefaultLight> |
453e83ea | 64 | |
a1587156 C |
65 | export type MChannelActorLight = |
66 | MChannel & | |
0283eaac | 67 | Use<'Actor', MActorLight> |
453e83ea | 68 | |
a1587156 C |
69 | export type MChannelAccountLight = |
70 | MChannel & | |
0283eaac C |
71 | Use<'Actor', MActorDefaultLight> & |
72 | Use<'Account', MAccountLight> | |
453e83ea | 73 | |
0283eaac | 74 | // ############################################################################ |
453e83ea | 75 | |
0283eaac | 76 | // Account associations |
453e83ea | 77 | |
a1587156 C |
78 | export type MChannelAccountActor = |
79 | MChannel & | |
0283eaac C |
80 | Use<'Account', MAccountActor> |
81 | ||
a1587156 C |
82 | export type MChannelAccountDefault = |
83 | MChannel & | |
0283eaac C |
84 | Use<'Actor', MActorDefault> & |
85 | Use<'Account', MAccountDefault> | |
453e83ea | 86 | |
a1587156 C |
87 | export type MChannelActorAccountActor = |
88 | MChannel & | |
0283eaac C |
89 | Use<'Account', MAccountActor> & |
90 | Use<'Actor', MActor> | |
91 | ||
92 | // ############################################################################ | |
93 | ||
94 | // Videos associations | |
a1587156 C |
95 | export type MChannelVideos = |
96 | MChannel & | |
0283eaac | 97 | Use<'Videos', MVideo[]> |
453e83ea | 98 | |
a1587156 C |
99 | export type MChannelActorAccountDefaultVideos = |
100 | MChannel & | |
0283eaac C |
101 | Use<'Actor', MActorDefault> & |
102 | Use<'Account', MAccountDefault> & | |
103 | Use<'Videos', MVideo[]> | |
104 | ||
105 | // ############################################################################ | |
106 | ||
107 | // For API | |
453e83ea | 108 | |
a1587156 C |
109 | export type MChannelSummary = |
110 | FunctionProperties<MChannel> & | |
1ca9f7c3 | 111 | Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> & |
0283eaac | 112 | Use<'Actor', MActorSummary> |
453e83ea | 113 | |
a1587156 C |
114 | export type MChannelSummaryAccount = |
115 | MChannelSummary & | |
0283eaac | 116 | Use<'Account', MAccountSummaryBlocks> |
453e83ea | 117 | |
a1587156 C |
118 | export type MChannelAPI = |
119 | MChannel & | |
0283eaac C |
120 | Use<'Actor', MActorAPI> & |
121 | Use<'Account', MAccountAPI> | |
1ca9f7c3 C |
122 | |
123 | // ############################################################################ | |
124 | ||
125 | // Format for API or AP object | |
126 | ||
a1587156 C |
127 | export type MChannelSummaryFormattable = |
128 | FunctionProperties<MChannel> & | |
1ca9f7c3 C |
129 | Pick<MChannel, 'id' | 'name'> & |
130 | Use<'Actor', MActorSummaryFormattable> | |
131 | ||
a1587156 C |
132 | export type MChannelAccountSummaryFormattable = |
133 | MChannelSummaryFormattable & | |
1ca9f7c3 C |
134 | Use<'Account', MAccountSummaryFormattable> |
135 | ||
a1587156 C |
136 | export type MChannelFormattable = |
137 | FunctionProperties<MChannel> & | |
1ca9f7c3 C |
138 | Pick<MChannel, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'support'> & |
139 | Use<'Actor', MActorFormattable> & | |
140 | PickWithOpt<VideoChannelModel, 'Account', MAccountFormattable> | |
b5fecbf4 | 141 | |
a1587156 C |
142 | export type MChannelAP = |
143 | Pick<MChannel, 'name' | 'description' | 'support'> & | |
b5fecbf4 C |
144 | Use<'Actor', MActorAP> & |
145 | Use<'Account', MAccountUrl> |