PeerTube/server/types/models/video/video-comment.ts

72 lines
2.2 KiB
TypeScript
Raw Normal View History

import { PickWith, PickWithOpt } from '@shared/typescript-utils'
2020-11-13 16:38:23 +01:00
import { VideoCommentModel } from '../../../models/video/video-comment'
import { MAccountDefault, MAccountFormattable, MAccountUrl } from '../account'
2020-11-13 16:38:23 +01:00
import { MVideo, MVideoAccountLight, MVideoFeed, MVideoIdUrl, MVideoUrl } from './video'
2019-08-20 13:52:49 +02:00
type Use<K extends keyof VideoCommentModel, M> = PickWith<VideoCommentModel, K, M>
// ############################################################################
2019-08-15 11:53:26 +02:00
export type MComment = Omit<VideoCommentModel, 'OriginVideoComment' | 'InReplyToVideoComment' | 'Video' | 'Account'>
2019-08-20 19:05:31 +02:00
export type MCommentTotalReplies = MComment & { totalReplies?: number }
2019-08-15 11:53:26 +02:00
export type MCommentId = Pick<MComment, 'id'>
2019-08-21 14:31:57 +02:00
export type MCommentUrl = Pick<MComment, 'url'>
2019-08-15 11:53:26 +02:00
2019-08-20 13:52:49 +02:00
// ############################################################################
2019-08-15 11:53:26 +02:00
2020-01-31 16:56:52 +01:00
export type MCommentOwner =
MComment &
2019-08-20 13:52:49 +02:00
Use<'Account', MAccountDefault>
2019-08-15 11:53:26 +02:00
2020-01-31 16:56:52 +01:00
export type MCommentVideo =
MComment &
2019-08-20 13:52:49 +02:00
Use<'Video', MVideoAccountLight>
2019-08-15 11:53:26 +02:00
2020-01-31 16:56:52 +01:00
export type MCommentReply =
MComment &
2019-08-20 13:52:49 +02:00
Use<'InReplyToVideoComment', MComment>
2020-01-31 16:56:52 +01:00
export type MCommentOwnerVideo =
MComment &
2019-08-20 13:52:49 +02:00
Use<'Account', MAccountDefault> &
Use<'Video', MVideoAccountLight>
2019-08-15 11:53:26 +02:00
2020-01-31 16:56:52 +01:00
export type MCommentOwnerVideoReply =
MComment &
2019-08-20 13:52:49 +02:00
Use<'Account', MAccountDefault> &
Use<'Video', MVideoAccountLight> &
Use<'InReplyToVideoComment', MComment>
2019-08-15 11:53:26 +02:00
2020-01-31 16:56:52 +01:00
export type MCommentOwnerReplyVideoLight =
MComment &
2019-08-20 13:52:49 +02:00
Use<'Account', MAccountDefault> &
Use<'InReplyToVideoComment', MComment> &
Use<'Video', MVideoIdUrl>
2019-08-15 11:53:26 +02:00
2020-01-31 16:56:52 +01:00
export type MCommentOwnerVideoFeed =
MCommentOwner &
2019-08-20 13:52:49 +02:00
Use<'Video', MVideoFeed>
// ############################################################################
export type MCommentAPI = MComment & { totalReplies: number }
2019-08-20 19:05:31 +02:00
// ############################################################################
// Format for API or AP object
2020-01-31 16:56:52 +01:00
export type MCommentFormattable =
MCommentTotalReplies &
2019-08-20 19:05:31 +02:00
Use<'Account', MAccountFormattable>
2019-08-21 14:31:57 +02:00
2020-11-13 16:38:23 +01:00
export type MCommentAdminFormattable =
MComment &
Use<'Account', MAccountFormattable> &
Use<'Video', MVideo>
2020-01-31 16:56:52 +01:00
export type MCommentAP =
MComment &
2019-08-21 14:31:57 +02:00
Use<'Account', MAccountUrl> &
PickWithOpt<VideoCommentModel, 'Video', MVideoUrl> &
PickWithOpt<VideoCommentModel, 'InReplyToVideoComment', MCommentUrl>