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