diff options
author | Chocobozzz <me@florianbigard.com> | 2020-06-18 10:45:25 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-06-18 10:46:27 +0200 |
commit | 26d6bf6533023326fa017812cf31bbe20c752d36 (patch) | |
tree | 9c4e3ecdc344420190f17d429bdf05d78fae7a8c /server/types/models/video/video-comment.ts | |
parent | d6d951ddc0c492f3261065b5dcb4df0534d252fc (diff) | |
download | PeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.tar.gz PeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.tar.zst PeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.zip |
Split types and typings
Diffstat (limited to 'server/types/models/video/video-comment.ts')
-rw-r--r-- | server/types/models/video/video-comment.ts | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/server/types/models/video/video-comment.ts b/server/types/models/video/video-comment.ts new file mode 100644 index 000000000..d6e0b66f5 --- /dev/null +++ b/server/types/models/video/video-comment.ts | |||
@@ -0,0 +1,66 @@ | |||
1 | import { VideoCommentModel } from '../../../models/video/video-comment' | ||
2 | import { PickWith, PickWithOpt } from '../../utils' | ||
3 | import { MAccountDefault, MAccountFormattable, MAccountUrl } 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 = | ||
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 MCommentAP = | ||
63 | MComment & | ||
64 | Use<'Account', MAccountUrl> & | ||
65 | PickWithOpt<VideoCommentModel, 'Video', MVideoUrl> & | ||
66 | PickWithOpt<VideoCommentModel, 'InReplyToVideoComment', MCommentUrl> | ||