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