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