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