]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/typings/models/video/video-channels.ts
Type toActivityPubObject functions
[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 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 = MChannelId &
39 Use<'Actor', MActorAccountChannelId>
40
41 export type MChannelUserId = Pick<MChannel, 'accountId'> &
42 Use<'Account', MAccountUserId>
43
44 export type MChannelActor = MChannel &
45 Use<'Actor', MActor>
46
47 export type MChannelUrl = Use<'Actor', MActorUrl>
48
49 // Default scope
50 export type MChannelDefault = MChannel &
51 Use<'Actor', MActorDefault>
52
53 // ############################################################################
54
55 // Not all association attributes
56
57 export type MChannelLight = MChannel &
58 Use<'Actor', MActorDefaultLight>
59
60 export type MChannelActorLight = MChannel &
61 Use<'Actor', MActorLight>
62
63 export type MChannelAccountLight = MChannel &
64 Use<'Actor', MActorDefaultLight> &
65 Use<'Account', MAccountLight>
66
67 // ############################################################################
68
69 // Account associations
70
71 export type MChannelAccountActor = MChannel &
72 Use<'Account', MAccountActor>
73
74 export type MChannelAccountDefault = MChannel &
75 Use<'Actor', MActorDefault> &
76 Use<'Account', MAccountDefault>
77
78 export type MChannelActorAccountActor = MChannel &
79 Use<'Account', MAccountActor> &
80 Use<'Actor', MActor>
81
82 // ############################################################################
83
84 // Videos associations
85 export type MChannelVideos = MChannel &
86 Use<'Videos', MVideo[]>
87
88 export type MChannelActorAccountDefaultVideos = MChannel &
89 Use<'Actor', MActorDefault> &
90 Use<'Account', MAccountDefault> &
91 Use<'Videos', MVideo[]>
92
93 // ############################################################################
94
95 // For API
96
97 export type MChannelSummary = FunctionProperties<MChannel> &
98 Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> &
99 Use<'Actor', MActorSummary>
100
101 export type MChannelSummaryAccount = MChannelSummary &
102 Use<'Account', MAccountSummaryBlocks>
103
104 export type MChannelAPI = MChannel &
105 Use<'Actor', MActorAPI> &
106 Use<'Account', MAccountAPI>
107
108 // ############################################################################
109
110 // Format for API or AP object
111
112 export type MChannelSummaryFormattable = FunctionProperties<MChannel> &
113 Pick<MChannel, 'id' | 'name'> &
114 Use<'Actor', MActorSummaryFormattable>
115
116 export type MChannelAccountSummaryFormattable = MChannelSummaryFormattable &
117 Use<'Account', MAccountSummaryFormattable>
118
119 export type MChannelFormattable = FunctionProperties<MChannel> &
120 Pick<MChannel, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'support'> &
121 Use<'Actor', MActorFormattable> &
122 PickWithOpt<VideoChannelModel, 'Account', MAccountFormattable>
123
124 export type MChannelAP = Pick<MChannel, 'name' | 'description' | 'support'> &
125 Use<'Actor', MActorAP> &
126 Use<'Account', MAccountUrl>