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