]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/typings/models/video/video-channels.ts
Type toFormattedJSON
[github/Chocobozzz/PeerTube.git] / server / typings / models / video / video-channels.ts
1 import { FunctionProperties, PickWith, PickWithOpt } from '../../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 MAccountUserId,
12 MActor,
13 MActorAccountChannelId,
14 MActorAPI,
15 MActorDefault,
16 MActorDefaultLight,
17 MActorFormattable,
18 MActorLight,
19 MActorSummary,
20 MActorSummaryFormattable
21 } from '../account'
22 import { MVideo } from './video'
23
24 type Use<K extends keyof VideoChannelModel, M> = PickWith<VideoChannelModel, K, M>
25
26 // ############################################################################
27
28 export type MChannel = Omit<VideoChannelModel, 'Actor' | 'Account' | 'Videos' | 'VideoPlaylists'>
29
30 // ############################################################################
31
32 export type MChannelId = Pick<MChannel, 'id'>
33
34 // ############################################################################
35
36 export type MChannelIdActor = MChannelId &
37 Use<'Actor', MActorAccountChannelId>
38
39 export type MChannelUserId = Pick<MChannel, 'accountId'> &
40 Use<'Account', MAccountUserId>
41
42 export type MChannelActor = MChannel &
43 Use<'Actor', MActor>
44
45 // Default scope
46 export type MChannelDefault = MChannel &
47 Use<'Actor', MActorDefault>
48
49 // ############################################################################
50
51 // Not all association attributes
52
53 export type MChannelLight = MChannel &
54 Use<'Actor', MActorDefaultLight>
55
56 export type MChannelActorLight = MChannel &
57 Use<'Actor', MActorLight>
58
59 export type MChannelAccountLight = MChannel &
60 Use<'Actor', MActorDefaultLight> &
61 Use<'Account', MAccountLight>
62
63 // ############################################################################
64
65 // Account associations
66
67 export type MChannelAccountActor = MChannel &
68 Use<'Account', MAccountActor>
69
70 export type MChannelAccountDefault = MChannel &
71 Use<'Actor', MActorDefault> &
72 Use<'Account', MAccountDefault>
73
74 export type MChannelActorAccountActor = MChannel &
75 Use<'Account', MAccountActor> &
76 Use<'Actor', MActor>
77
78 // ############################################################################
79
80 // Videos associations
81 export type MChannelVideos = MChannel &
82 Use<'Videos', MVideo[]>
83
84 export type MChannelActorAccountDefaultVideos = MChannel &
85 Use<'Actor', MActorDefault> &
86 Use<'Account', MAccountDefault> &
87 Use<'Videos', MVideo[]>
88
89 // ############################################################################
90
91 // For API
92
93 export type MChannelSummary = FunctionProperties<MChannel> &
94 Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> &
95 Use<'Actor', MActorSummary>
96
97 export type MChannelSummaryAccount = MChannelSummary &
98 Use<'Account', MAccountSummaryBlocks>
99
100 export type MChannelAPI = MChannel &
101 Use<'Actor', MActorAPI> &
102 Use<'Account', MAccountAPI>
103
104 // ############################################################################
105
106 // Format for API or AP object
107
108 export type MChannelSummaryFormattable = FunctionProperties<MChannel> &
109 Pick<MChannel, 'id' | 'name'> &
110 Use<'Actor', MActorSummaryFormattable>
111
112 export type MChannelAccountSummaryFormattable = MChannelSummaryFormattable &
113 Use<'Account', MAccountSummaryFormattable>
114
115 export type MChannelFormattable = FunctionProperties<MChannel> &
116 Pick<MChannel, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'support'> &
117 Use<'Actor', MActorFormattable> &
118 PickWithOpt<VideoChannelModel, 'Account', MAccountFormattable>