]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/types/models/video/video-comment.ts
Move typescript utils in its own directory
[github/Chocobozzz/PeerTube.git] / server / types / models / video / video-comment.ts
1 import { PickWith, PickWithOpt } from '@shared/typescript-utils'
2 import { VideoCommentModel } from '../../../models/video/video-comment'
3 import { MAccountDefault, MAccountFormattable, MAccountUrl } from '../account'
4 import { MVideo, 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 =
18 MComment &
19 Use<'Account', MAccountDefault>
20
21 export type MCommentVideo =
22 MComment &
23 Use<'Video', MVideoAccountLight>
24
25 export type MCommentReply =
26 MComment &
27 Use<'InReplyToVideoComment', MComment>
28
29 export type MCommentOwnerVideo =
30 MComment &
31 Use<'Account', MAccountDefault> &
32 Use<'Video', MVideoAccountLight>
33
34 export type MCommentOwnerVideoReply =
35 MComment &
36 Use<'Account', MAccountDefault> &
37 Use<'Video', MVideoAccountLight> &
38 Use<'InReplyToVideoComment', MComment>
39
40 export type MCommentOwnerReplyVideoLight =
41 MComment &
42 Use<'Account', MAccountDefault> &
43 Use<'InReplyToVideoComment', MComment> &
44 Use<'Video', MVideoIdUrl>
45
46 export type MCommentOwnerVideoFeed =
47 MCommentOwner &
48 Use<'Video', MVideoFeed>
49
50 // ############################################################################
51
52 export type MCommentAPI = MComment & { totalReplies: number }
53
54 // ############################################################################
55
56 // Format for API or AP object
57
58 export type MCommentFormattable =
59 MCommentTotalReplies &
60 Use<'Account', MAccountFormattable>
61
62 export type MCommentAdminFormattable =
63 MComment &
64 Use<'Account', MAccountFormattable> &
65 Use<'Video', MVideo>
66
67 export type MCommentAP =
68 MComment &
69 Use<'Account', MAccountUrl> &
70 PickWithOpt<VideoCommentModel, 'Video', MVideoUrl> &
71 PickWithOpt<VideoCommentModel, 'InReplyToVideoComment', MCommentUrl>