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