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