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