Type toActivityPubObject functions
[oweals/peertube.git] / server / typings / models / video / video-comment.ts
1 import { VideoCommentModel } from '../../../models/video/video-comment'
2 import { PickWith, PickWithOpt } from '../../utils'
3 import { MAccountDefault, MAccountFormattable, MAccountUrl, MActorUrl } from '../account'
4 import { MVideoAccountLight, MVideoFeed, MVideoIdUrl, MVideoUrl } from './video'
5
6 type Use<K extends keyof VideoCommentModel, M> = PickWith<VideoCommentModel, K, M>
7
8 // ############################################################################
9
10 export type MComment = Omit<VideoCommentModel, 'OriginVideoComment' | 'InReplyToVideoComment' | 'Video' | 'Account'>
11 export type MCommentTotalReplies = MComment & { totalReplies?: number }
12 export type MCommentId = Pick<MComment, 'id'>
13 export type MCommentUrl = Pick<MComment, 'url'>
14
15 // ############################################################################
16
17 export type MCommentOwner = MComment &
18   Use<'Account', MAccountDefault>
19
20 export type MCommentVideo = MComment &
21   Use<'Video', MVideoAccountLight>
22
23 export type MCommentReply = MComment &
24   Use<'InReplyToVideoComment', MComment>
25
26 export type MCommentOwnerVideo = MComment &
27   Use<'Account', MAccountDefault> &
28   Use<'Video', MVideoAccountLight>
29
30 export type MCommentOwnerVideoReply = MComment &
31   Use<'Account', MAccountDefault> &
32   Use<'Video', MVideoAccountLight> &
33   Use<'InReplyToVideoComment', MComment>
34
35 export type MCommentOwnerReplyVideoLight = MComment &
36   Use<'Account', MAccountDefault> &
37   Use<'InReplyToVideoComment', MComment> &
38   Use<'Video', MVideoIdUrl>
39
40 export type MCommentOwnerVideoFeed = MCommentOwner &
41   Use<'Video', MVideoFeed>
42
43 // ############################################################################
44
45 export type MCommentAPI = MComment & { totalReplies: number }
46
47 // ############################################################################
48
49 // Format for API or AP object
50
51 export type MCommentFormattable = MCommentTotalReplies &
52   Use<'Account', MAccountFormattable>
53
54 export type MCommentAP = MComment &
55   Use<'Account', MAccountUrl> &
56   PickWithOpt<VideoCommentModel, 'Video', MVideoUrl> &
57   PickWithOpt<VideoCommentModel, 'InReplyToVideoComment', MCommentUrl>