Type toFormattedJSON
[oweals/peertube.git] / server / typings / models / video / video-comment.ts
1 import { VideoCommentModel } from '../../../models/video/video-comment'
2 import { PickWith } from '../../utils'
3 import { MAccountDefault, MAccountFormattable } from '../account'
4 import { MVideoAccountLight, MVideoFeed, MVideoIdUrl } 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
14 // ############################################################################
15
16 export type MCommentOwner = MComment &
17   Use<'Account', MAccountDefault>
18
19 export type MCommentVideo = MComment &
20   Use<'Video', MVideoAccountLight>
21
22 export type MCommentReply = MComment &
23   Use<'InReplyToVideoComment', MComment>
24
25 export type MCommentOwnerVideo = MComment &
26   Use<'Account', MAccountDefault> &
27   Use<'Video', MVideoAccountLight>
28
29 export type MCommentOwnerVideoReply = MComment &
30   Use<'Account', MAccountDefault> &
31   Use<'Video', MVideoAccountLight> &
32   Use<'InReplyToVideoComment', MComment>
33
34 export type MCommentOwnerReplyVideoLight = MComment &
35   Use<'Account', MAccountDefault> &
36   Use<'InReplyToVideoComment', MComment> &
37   Use<'Video', MVideoIdUrl>
38
39 export type MCommentOwnerVideoFeed = MCommentOwner &
40   Use<'Video', MVideoFeed>
41
42 // ############################################################################
43
44 export type MCommentAPI = MComment & { totalReplies: number }
45
46 // ############################################################################
47
48 // Format for API or AP object
49
50 export type MCommentFormattable = MCommentTotalReplies &
51   Use<'Account', MAccountFormattable>