aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/typings
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-08-15 11:53:26 +0200
committerChocobozzz <me@florianbigard.com>2019-08-19 17:26:35 +0200
commit453e83ea5d81d203ba34bc43cd5c2c750ba40568 (patch)
tree604e02f4343d13a4ba42e1fb7527ba6ab9111712 /server/typings
parent13176a07a95984a53cc59aec5217f2ce9806d1bc (diff)
downloadPeerTube-453e83ea5d81d203ba34bc43cd5c2c750ba40568.tar.gz
PeerTube-453e83ea5d81d203ba34bc43cd5c2c750ba40568.tar.zst
PeerTube-453e83ea5d81d203ba34bc43cd5c2c750ba40568.zip
Stronger model typings
Diffstat (limited to 'server/typings')
-rw-r--r--server/typings/activitypub-processor.model.ts7
-rw-r--r--server/typings/express.ts123
-rw-r--r--server/typings/models/account/account-blocklist.ts11
-rw-r--r--server/typings/models/account/account.ts56
-rw-r--r--server/typings/models/account/actor-follow.ts27
-rw-r--r--server/typings/models/account/actor.ts74
-rw-r--r--server/typings/models/account/avatar.ts3
-rw-r--r--server/typings/models/account/index.d.ts5
-rw-r--r--server/typings/models/actor-follow.ts8
-rw-r--r--server/typings/models/actor.ts22
-rw-r--r--server/typings/models/index.d.ts5
-rw-r--r--server/typings/models/oauth/oauth-client.ts3
-rw-r--r--server/typings/models/oauth/oauth-token.ts9
-rw-r--r--server/typings/models/server/index.d.ts3
-rw-r--r--server/typings/models/server/plugin.ts3
-rw-r--r--server/typings/models/server/server-blocklist.ts9
-rw-r--r--server/typings/models/server/server.ts10
-rw-r--r--server/typings/models/user/index.d.ts3
-rw-r--r--server/typings/models/user/user-notification-setting.ts3
-rw-r--r--server/typings/models/user/user-notification.ts69
-rw-r--r--server/typings/models/user/user-video-history.ts5
-rw-r--r--server/typings/models/user/user.ts32
-rw-r--r--server/typings/models/video-share.ts3
-rw-r--r--server/typings/models/video/index.d.ts14
-rw-r--r--server/typings/models/video/schedule-video-update.ts3
-rw-r--r--server/typings/models/video/tag.ts3
-rw-r--r--server/typings/models/video/thumbnail.ts3
-rw-r--r--server/typings/models/video/video-abuse.ts15
-rw-r--r--server/typings/models/video/video-blacklist.ts11
-rw-r--r--server/typings/models/video/video-caption.ts10
-rw-r--r--server/typings/models/video/video-change-ownership.ts10
-rw-r--r--server/typings/models/video/video-channels.ts70
-rw-r--r--server/typings/models/video/video-comment.ts29
-rw-r--r--server/typings/models/video/video-file.ts15
-rw-r--r--server/typings/models/video/video-import.ts15
-rw-r--r--server/typings/models/video/video-playlist-element.ts15
-rw-r--r--server/typings/models/video/video-playlist.ts42
-rw-r--r--server/typings/models/video/video-rate.ts12
-rw-r--r--server/typings/models/video/video-redundancy.ts18
-rw-r--r--server/typings/models/video/video-share.ts12
-rw-r--r--server/typings/models/video/video-streaming-playlist.ts12
-rw-r--r--server/typings/models/video/video.ts103
-rw-r--r--server/typings/utils.ts14
43 files changed, 825 insertions, 94 deletions
diff --git a/server/typings/activitypub-processor.model.ts b/server/typings/activitypub-processor.model.ts
index 37b2859de..7ed3a65b1 100644
--- a/server/typings/activitypub-processor.model.ts
+++ b/server/typings/activitypub-processor.model.ts
@@ -1,10 +1,9 @@
1import { Activity } from '../../shared/models/activitypub' 1import { Activity } from '../../shared/models/activitypub'
2import { ActorModel } from '../models/activitypub/actor' 2import { MActorDefault, MActorSignature } from './models'
3import { SignatureActorModel } from './models'
4 3
5export type APProcessorOptions<T extends Activity> = { 4export type APProcessorOptions<T extends Activity> = {
6 activity: T 5 activity: T
7 byActor: SignatureActorModel 6 byActor: MActorSignature
8 inboxActor?: ActorModel 7 inboxActor?: MActorDefault
9 fromFetch?: boolean 8 fromFetch?: boolean
10} 9}
diff --git a/server/typings/express.ts b/server/typings/express.ts
index f7da55ab0..260091461 100644
--- a/server/typings/express.ts
+++ b/server/typings/express.ts
@@ -1,89 +1,102 @@
1import { VideoChannelModel } from '../models/video/video-channel'
2import { VideoPlaylistModel } from '../models/video/video-playlist'
3import { VideoPlaylistElementModel } from '../models/video/video-playlist-element'
4import { UserModel } from '../models/account/user'
5import { VideoModel } from '../models/video/video'
6import { AccountModel } from '../models/account/account'
7import { VideoChangeOwnershipModel } from '../models/video/video-change-ownership'
8import { ActorModel } from '../models/activitypub/actor'
9import { VideoCommentModel } from '../models/video/video-comment'
10import { VideoShareModel } from '../models/video/video-share'
11import { AccountVideoRateModel } from '../models/account/account-video-rate'
12import { ActorFollowModel } from '../models/activitypub/actor-follow'
13import { ServerModel } from '../models/server/server'
14import { VideoFileModel } from '../models/video/video-file'
15import { VideoRedundancyModel } from '../models/redundancy/video-redundancy'
16import { ServerBlocklistModel } from '../models/server/server-blocklist'
17import { AccountBlocklistModel } from '../models/account/account-blocklist'
18import { VideoImportModel } from '../models/video/video-import'
19import { VideoAbuseModel } from '../models/video/video-abuse'
20import { VideoBlacklistModel } from '../models/video/video-blacklist'
21import { VideoCaptionModel } from '../models/video/video-caption'
22import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist'
23import { RegisteredPlugin } from '../lib/plugins/plugin-manager' 1import { RegisteredPlugin } from '../lib/plugins/plugin-manager'
24import { PluginModel } from '../models/server/plugin' 2import {
25import { SignatureActorModel } from './models' 3 MAccountDefault,
4 MActorAccountChannelId,
5 MActorFollowActorsDefault,
6 MActorFollowActorsDefaultSubscription,
7 MActorFull,
8 MChannelActorAccountDefault,
9 MComment,
10 MCommentOwnerVideoReply,
11 MUserDefault,
12 MVideoAbuse,
13 MVideoBlacklist,
14 MVideoCaptionVideo,
15 MVideoFullLight,
16 MVideoIdThumbnail,
17 MVideoRedundancyVideo,
18 MVideoShareActor,
19 MVideoThumbnail,
20 MVideoWithRights
21} from './models'
22import { MVideoPlaylistFull, MVideoPlaylistFullSummary } from './models/video/video-playlist'
23import { MVideoImportDefault } from '@server/typings/models/video/video-import'
24import { MAccountBlocklist, MStreamingPlaylist, MVideoFile } from '@server/typings/models'
25import { MVideoPlaylistElement } from '@server/typings/models/video/video-playlist-element'
26import { MAccountVideoRateAccountVideo } from '@server/typings/models/video/video-rate'
27import { MVideoChangeOwnershipFull } from './models/video/video-change-ownership'
28import { MPlugin, MServer } from '@server/typings/models/server'
29import { MServerBlocklist } from './models/server/server-blocklist'
30import { MOAuthTokenUser } from '@server/typings/models/oauth/oauth-token'
26 31
27declare module 'express' { 32declare module 'express' {
28 33
29 interface Response { 34 interface Response {
35
30 locals: { 36 locals: {
31 video?: VideoModel 37 videoAll?: MVideoFullLight
32 videoShare?: VideoShareModel 38 onlyVideo?: MVideoThumbnail
33 videoFile?: VideoFileModel 39 onlyVideoWithRights?: MVideoWithRights
40 videoId?: MVideoIdThumbnail
41
42 videoShare?: MVideoShareActor
43
44 videoFile?: MVideoFile
45
46 videoImport?: MVideoImportDefault
47
48 videoBlacklist?: MVideoBlacklist
49
50 videoCaption?: MVideoCaptionVideo
51
52 videoAbuse?: MVideoAbuse
34 53
35 videoImport?: VideoImportModel 54 videoStreamingPlaylist?: MStreamingPlaylist
36 55
37 videoBlacklist?: VideoBlacklistModel 56 videoChannel?: MChannelActorAccountDefault
38 57
39 videoCaption?: VideoCaptionModel 58 videoPlaylistFull?: MVideoPlaylistFull
59 videoPlaylistSummary?: MVideoPlaylistFullSummary
40 60
41 videoAbuse?: VideoAbuseModel 61 videoPlaylistElement?: MVideoPlaylistElement
42 62
43 videoStreamingPlaylist?: VideoStreamingPlaylistModel 63 accountVideoRate?: MAccountVideoRateAccountVideo
44 64
45 videoChannel?: VideoChannelModel 65 videoCommentFull?: MCommentOwnerVideoReply
66 videoCommentThread?: MComment
46 67
47 videoPlaylist?: VideoPlaylistModel 68 follow?: MActorFollowActorsDefault
48 videoPlaylistElement?: VideoPlaylistElementModel 69 subscription?: MActorFollowActorsDefaultSubscription
49 70
50 accountVideoRate?: AccountVideoRateModel 71 nextOwner?: MAccountDefault
72 videoChangeOwnership?: MVideoChangeOwnershipFull
51 73
52 videoComment?: VideoCommentModel 74 account?: MAccountDefault
53 videoCommentThread?: VideoCommentModel
54 75
55 follow?: ActorFollowModel 76 actorFull?: MActorFull
56 subscription?: ActorFollowModel
57 77
58 nextOwner?: AccountModel 78 user?: MUserDefault
59 videoChangeOwnership?: VideoChangeOwnershipModel
60 account?: AccountModel
61 actor?: ActorModel
62 user?: UserModel
63 79
64 server?: ServerModel 80 server?: MServer
65 81
66 videoRedundancy?: VideoRedundancyModel 82 videoRedundancy?: MVideoRedundancyVideo
67 83
68 accountBlock?: AccountBlocklistModel 84 accountBlock?: MAccountBlocklist
69 serverBlock?: ServerBlocklistModel 85 serverBlock?: MServerBlocklist
70 86
71 oauth?: { 87 oauth?: {
72 token: { 88 token: MOAuthTokenUser
73 User: UserModel
74 user: UserModel
75 }
76 } 89 }
77 90
78 signature?: { 91 signature?: {
79 actor: SignatureActorModel 92 actor: MActorAccountChannelId
80 } 93 }
81 94
82 authenticated?: boolean 95 authenticated?: boolean
83 96
84 registeredPlugin?: RegisteredPlugin 97 registeredPlugin?: RegisteredPlugin
85 98
86 plugin?: PluginModel 99 plugin?: MPlugin
87 } 100 }
88 } 101 }
89} 102}
diff --git a/server/typings/models/account/account-blocklist.ts b/server/typings/models/account/account-blocklist.ts
new file mode 100644
index 000000000..6d1771de8
--- /dev/null
+++ b/server/typings/models/account/account-blocklist.ts
@@ -0,0 +1,11 @@
1import { AccountBlocklistModel } from '../../../models/account/account-blocklist'
2import { PickWith } from '../../utils'
3import { MAccountDefault } from './account'
4
5export type MAccountBlocklist = Omit<AccountBlocklistModel, 'ByAccount' | 'BlockedAccount'>
6
7export type MAccountBlocklistId = Pick<AccountBlocklistModel, 'id'>
8
9export type MAccountBlocklistAccounts = MAccountBlocklist &
10 PickWith<AccountBlocklistModel, 'ByAccount', MAccountDefault> &
11 PickWith<AccountBlocklistModel, 'BlockedAccount', MAccountDefault>
diff --git a/server/typings/models/account/account.ts b/server/typings/models/account/account.ts
new file mode 100644
index 000000000..f3646d510
--- /dev/null
+++ b/server/typings/models/account/account.ts
@@ -0,0 +1,56 @@
1import { AccountModel } from '../../../models/account/account'
2import {
3 MActor,
4 MActorAccountChannelId,
5 MActorAPI,
6 MActorAudience,
7 MActorDefault,
8 MActorDefaultLight, MActorId,
9 MActorServer,
10 MActorSummary,
11 MActorUrl
12} from './actor'
13import { PickWith } from '../../utils'
14import { MAccountBlocklistId } from './account-blocklist'
15import { MChannelDefault } from '@server/typings/models'
16
17export type MAccountId = Pick<AccountModel, 'id'>
18export type MAccountIdActor = MAccountId &
19 PickWith<AccountModel, 'Actor', MActorAccountChannelId>
20export type MAccountIdActorId = MAccountId &
21 PickWith<AccountModel, 'Actor', MActorId>
22
23export type MAccount = Omit<AccountModel, 'Actor' | 'User' | 'Application' | 'VideoChannels' | 'VideoPlaylists' |
24 'VideoComments' | 'BlockedAccounts'>
25
26// Default scope
27export type MAccountDefault = MAccount &
28 PickWith<AccountModel, 'Actor', MActorDefault>
29
30export type MAccountDefaultChannelDefault = MAccountDefault &
31 PickWith<AccountModel, 'VideoChannels', MChannelDefault[]>
32
33export type MAccountLight = MAccount &
34 PickWith<AccountModel, 'Actor', MActorDefaultLight>
35
36export type MAccountUserId = Pick<MAccount, 'userId'>
37
38export type MAccountActor = MAccount &
39 PickWith<AccountModel, 'Actor', MActor>
40export type MAccountServer = MAccountActor &
41 PickWith<AccountModel, 'Actor', MActorServer>
42
43export type MAccountActorDefault = MAccount &
44 PickWith<AccountModel, 'Actor', MActorDefault>
45
46export type MAccountSummary = Pick<MAccount, 'id' | 'name'> &
47 PickWith<AccountModel, 'Actor', MActorSummary>
48
49export type MAccountBlocks = MAccountSummary &
50 PickWith<AccountModel, 'BlockedAccounts', MAccountBlocklistId[]>
51
52export type MAccountAPI = MAccountDefault &
53 PickWith<AccountModel, 'Actor', MActorAPI>
54
55export type MAccountUrl = PickWith<AccountModel, 'Actor', MActorUrl>
56export type MAccountAudience = PickWith<AccountModel, 'Actor', MActorAudience>
diff --git a/server/typings/models/account/actor-follow.ts b/server/typings/models/account/actor-follow.ts
new file mode 100644
index 000000000..96c53d857
--- /dev/null
+++ b/server/typings/models/account/actor-follow.ts
@@ -0,0 +1,27 @@
1import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
2import { MActor, MActorAccountChannel, MActorChannel, MActorChannelAccount, MActorDefault, MActorHost, MActorUsername } from './actor'
3import { PickWith } from '../../utils'
4
5export type MActorFollow = Omit<ActorFollowModel, 'ActorFollower' | 'ActorFollowing'>
6
7export type MActorFollowActors = MActorFollow &
8 PickWith<ActorFollowModel, 'ActorFollower', MActor> &
9 PickWith<ActorFollowModel, 'ActorFollowing', MActor>
10
11export type MActorFollowActorsDefault = MActorFollow &
12 PickWith<ActorFollowModel, 'ActorFollower', MActorDefault> &
13 PickWith<ActorFollowModel, 'ActorFollowing', MActorDefault>
14
15export type MActorFollowActorsDefaultSubscription = MActorFollow &
16 PickWith<ActorFollowModel, 'ActorFollower', MActorDefault> &
17 PickWith<ActorFollowModel, 'ActorFollowing', MActorDefault & MActorChannel>
18
19export type MActorFollowFull = MActorFollow &
20 PickWith<ActorFollowModel, 'ActorFollower', MActorAccountChannel> &
21 PickWith<ActorFollowModel, 'ActorFollowing', MActorAccountChannel>
22
23export type MActorFollowFollowingHost = MActorFollow &
24 PickWith<ActorFollowModel, 'ActorFollowing', MActorUsername & MActorHost>
25
26export type MActorFollowSubscriptions = MActorFollow &
27 PickWith<ActorFollowModel, 'ActorFollowing', MActorChannelAccount>
diff --git a/server/typings/models/account/actor.ts b/server/typings/models/account/actor.ts
new file mode 100644
index 000000000..f3e752a98
--- /dev/null
+++ b/server/typings/models/account/actor.ts
@@ -0,0 +1,74 @@
1import { ActorModel } from '../../../models/activitypub/actor'
2import { PickWith } from '../../utils'
3import { MAccount, MAccountActorDefault, MAccountId, MAccountIdActor } from './account'
4import { MServerHost, MServerHostBlocks, MServer } from '../server'
5import { MAvatar } from './avatar'
6import { MChannel, MChannelAccountActor, MChannelActorAccountDefault, MChannelId, MChannelIdActor } from '../video'
7
8export type MActor = Omit<ActorModel, 'Account' | 'VideoChannel' | 'ActorFollowing' | 'Avatar' | 'ActorFollowers' | 'Server'>
9
10export type MActorUrl = Pick<MActor, 'url'>
11export type MActorId = Pick<MActor, 'id'>
12export type MActorUsername = Pick<MActor, 'preferredUsername'>
13export type MActorHost = PickWith<ActorModel, 'Server', MServerHost>
14
15export type MActorFollowersUrl = Pick<MActor, 'followersUrl'>
16export type MActorAudience = MActorUrl & MActorFollowersUrl
17
18export type MActorLight = Omit<MActor, 'privateKey' | 'privateKey'>
19
20export type MActorDefaultLight = MActorLight &
21 MActorHost &
22 PickWith<ActorModel, 'Avatar', MAvatar>
23
24export type MActorAccountId = MActor &
25 PickWith<ActorModel, 'Account', MAccountId>
26export type MActorAccountIdActor = MActor &
27 PickWith<ActorModel, 'Account', MAccountIdActor>
28
29export type MActorChannelId = MActor &
30 PickWith<ActorModel, 'VideoChannel', MChannelId>
31export type MActorChannelIdActor = MActor &
32 PickWith<ActorModel, 'VideoChannel', MChannelIdActor>
33
34export type MActorAccountChannelId = MActorAccountId & MActorChannelId
35export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor
36
37export type MActorAccount = MActor &
38 PickWith<ActorModel, 'Account', MAccount>
39
40export type MActorChannel = MActor &
41 PickWith<ActorModel, 'VideoChannel', MChannel>
42
43export type MActorAccountChannel = MActorAccount & MActorChannel
44
45export type MActorChannelAccount = MActor &
46 PickWith<ActorModel, 'VideoChannel', MChannelAccountActor>
47
48export type MActorServer = MActor &
49 PickWith<ActorModel, 'Server', MServer>
50
51export type MActorDefault = MActorServer &
52 PickWith<ActorModel, 'Avatar', MAvatar>
53
54export type MActorFull = MActorDefault &
55 PickWith<ActorModel, 'Account', MAccount> &
56 PickWith<ActorModel, 'VideoChannel', MChannelAccountActor>
57
58export type MActorFullActor = MActorDefault &
59 PickWith<ActorModel, 'Account', MAccountActorDefault> &
60 PickWith<ActorModel, 'VideoChannel', MChannelActorAccountDefault>
61
62export type MActorSummary = Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> &
63 MActorHost &
64 PickWith<ActorModel, 'Avatar', MAvatar>
65
66export type MActorSummaryBlocks = Omit<MActorSummary, 'Server'> &
67 PickWith<ActorModel, 'Server', MServerHostBlocks>
68
69export type MActorFollowerException = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl'>
70
71export type MActorAPI = Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' |
72 'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'>
73
74export type MActorSignature = MActorAccountChannelId
diff --git a/server/typings/models/account/avatar.ts b/server/typings/models/account/avatar.ts
new file mode 100644
index 000000000..257c48bfc
--- /dev/null
+++ b/server/typings/models/account/avatar.ts
@@ -0,0 +1,3 @@
1import { AvatarModel } from '../../../models/avatar/avatar'
2
3export type MAvatar = AvatarModel
diff --git a/server/typings/models/account/index.d.ts b/server/typings/models/account/index.d.ts
new file mode 100644
index 000000000..513c09c40
--- /dev/null
+++ b/server/typings/models/account/index.d.ts
@@ -0,0 +1,5 @@
1export * from './account'
2export * from './account-blocklist'
3export * from './actor'
4export * from './actor-follow'
5export * from './avatar'
diff --git a/server/typings/models/actor-follow.ts b/server/typings/models/actor-follow.ts
deleted file mode 100644
index 952ef877b..000000000
--- a/server/typings/models/actor-follow.ts
+++ /dev/null
@@ -1,8 +0,0 @@
1import { ActorFollowModel } from '../../models/activitypub/actor-follow'
2import { ActorModelOnly } from './actor'
3
4export type ActorFollowModelOnly = Omit<ActorFollowModel, 'ActorFollower' | 'ActorFollowing'>
5export type ActorFollowModelLight = ActorFollowModelOnly & {
6 ActorFollower: ActorModelOnly
7 ActorFollowing: ActorModelOnly
8}
diff --git a/server/typings/models/actor.ts b/server/typings/models/actor.ts
deleted file mode 100644
index 2656c7b66..000000000
--- a/server/typings/models/actor.ts
+++ /dev/null
@@ -1,22 +0,0 @@
1import { ActorModel } from '../../models/activitypub/actor'
2import { VideoChannelModel } from '../../models/video/video-channel'
3import { AccountModel } from '../../models/account/account'
4import { FunctionProperties } from '../utils'
5
6export type VideoChannelModelId = FunctionProperties<VideoChannelModel>
7export type AccountModelId = FunctionProperties<AccountModel> | Pick<AccountModel, 'id'>
8
9export type VideoChannelModelIdActor = VideoChannelModelId & Pick<VideoChannelModel, 'Actor'>
10export type AccountModelIdActor = AccountModelId & Pick<AccountModel, 'Actor'>
11
12export type ActorModelUrl = Pick<ActorModel, 'url'>
13export type ActorModelOnly = Omit<ActorModel, 'Account' | 'VideoChannel' | 'ActorFollowing' | 'Avatar' | 'ActorFollowers' | 'Server'>
14export type ActorModelId = Pick<ActorModelOnly, 'id'>
15
16export type SignatureActorModel = ActorModelOnly & {
17 VideoChannel: VideoChannelModelIdActor
18
19 Account: AccountModelIdActor
20}
21
22export type ActorFollowerException = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl'>
diff --git a/server/typings/models/index.d.ts b/server/typings/models/index.d.ts
index c90656965..39e82e4a8 100644
--- a/server/typings/models/index.d.ts
+++ b/server/typings/models/index.d.ts
@@ -1 +1,4 @@
1export * from './actor' 1export * from './account'
2export * from './server'
3export * from './user'
4export * from './video'
diff --git a/server/typings/models/oauth/oauth-client.ts b/server/typings/models/oauth/oauth-client.ts
new file mode 100644
index 000000000..904a07863
--- /dev/null
+++ b/server/typings/models/oauth/oauth-client.ts
@@ -0,0 +1,3 @@
1import { OAuthClientModel } from '@server/models/oauth/oauth-client'
2
3export type MOAuthClient = Omit<OAuthClientModel, 'OAuthTokens'>
diff --git a/server/typings/models/oauth/oauth-token.ts b/server/typings/models/oauth/oauth-token.ts
new file mode 100644
index 000000000..105ea3df3
--- /dev/null
+++ b/server/typings/models/oauth/oauth-token.ts
@@ -0,0 +1,9 @@
1import { OAuthTokenModel } from '@server/models/oauth/oauth-token'
2import { PickWith } from '@server/typings/utils'
3import { MUserAccountUrl } from '@server/typings/models'
4
5export type MOAuthToken = Omit<OAuthTokenModel, 'User' | 'OAuthClients'>
6
7export type MOAuthTokenUser = MOAuthToken &
8 PickWith<OAuthTokenModel, 'User', MUserAccountUrl> &
9 { user?: MUserAccountUrl }
diff --git a/server/typings/models/server/index.d.ts b/server/typings/models/server/index.d.ts
new file mode 100644
index 000000000..c853795ad
--- /dev/null
+++ b/server/typings/models/server/index.d.ts
@@ -0,0 +1,3 @@
1export * from './plugin'
2export * from './server'
3export * from './server-blocklist'
diff --git a/server/typings/models/server/plugin.ts b/server/typings/models/server/plugin.ts
new file mode 100644
index 000000000..b1e2e149d
--- /dev/null
+++ b/server/typings/models/server/plugin.ts
@@ -0,0 +1,3 @@
1import { PluginModel } from '@server/models/server/plugin'
2
3export type MPlugin = PluginModel
diff --git a/server/typings/models/server/server-blocklist.ts b/server/typings/models/server/server-blocklist.ts
new file mode 100644
index 000000000..38065f382
--- /dev/null
+++ b/server/typings/models/server/server-blocklist.ts
@@ -0,0 +1,9 @@
1import { ServerBlocklistModel } from '@server/models/server/server-blocklist'
2import { PickWith } from '@server/typings/utils'
3import { MAccountDefault, MServer } from '@server/typings/models'
4
5export type MServerBlocklist = Omit<ServerBlocklistModel, 'ByAccount' | 'BlockedServer'>
6
7export type MServerBlocklistAccountServer = MServerBlocklist &
8 PickWith<ServerBlocklistModel, 'ByAccount', MAccountDefault> &
9 PickWith<ServerBlocklistModel, 'BlockedServer', MServer>
diff --git a/server/typings/models/server/server.ts b/server/typings/models/server/server.ts
new file mode 100644
index 000000000..6be7bf9bb
--- /dev/null
+++ b/server/typings/models/server/server.ts
@@ -0,0 +1,10 @@
1import { ServerModel } from '../../../models/server/server'
2import { PickWith } from '../../utils'
3import { MAccountBlocklistId } from '../account'
4
5export type MServer = Omit<ServerModel, 'Actors' | 'BlockedByAccounts'>
6
7export type MServerHost = Pick<MServer, 'host'>
8
9export type MServerHostBlocks = MServerHost &
10 PickWith<ServerModel, 'BlockedByAccounts', MAccountBlocklistId[]>
diff --git a/server/typings/models/user/index.d.ts b/server/typings/models/user/index.d.ts
new file mode 100644
index 000000000..e3353d0b1
--- /dev/null
+++ b/server/typings/models/user/index.d.ts
@@ -0,0 +1,3 @@
1export * from './user'
2export * from './user-notification'
3export * from './user-video-history'
diff --git a/server/typings/models/user/user-notification-setting.ts b/server/typings/models/user/user-notification-setting.ts
new file mode 100644
index 000000000..585d30a66
--- /dev/null
+++ b/server/typings/models/user/user-notification-setting.ts
@@ -0,0 +1,3 @@
1import { UserNotificationSettingModel } from '@server/models/account/user-notification-setting'
2
3export type MNotificationSetting = Omit<UserNotificationSettingModel, 'User'>
diff --git a/server/typings/models/user/user-notification.ts b/server/typings/models/user/user-notification.ts
new file mode 100644
index 000000000..b872c5dc5
--- /dev/null
+++ b/server/typings/models/user/user-notification.ts
@@ -0,0 +1,69 @@
1import { UserNotificationModel } from '../../../models/account/user-notification'
2import { PickWith } from '../../utils'
3import { VideoModel } from '../../../models/video/video'
4import { ActorModel } from '../../../models/activitypub/actor'
5import { ServerModel } from '../../../models/server/server'
6import { AvatarModel } from '../../../models/avatar/avatar'
7import { VideoChannelModel } from '../../../models/video/video-channel'
8import { AccountModel } from '../../../models/account/account'
9import { VideoCommentModel } from '../../../models/video/video-comment'
10import { VideoAbuseModel } from '../../../models/video/video-abuse'
11import { VideoBlacklistModel } from '../../../models/video/video-blacklist'
12import { VideoImportModel } from '../../../models/video/video-import'
13import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
14
15export namespace UserNotificationIncludes {
16 export type VideoInclude = Pick<VideoModel, 'id' | 'uuid' | 'name'>
17 export type VideoIncludeChannel = VideoInclude &
18 PickWith<VideoModel, 'VideoChannel', VideoChannelIncludeActor>
19
20 export type ActorInclude = Pick<ActorModel, 'preferredUsername' | 'getHost'> &
21 PickWith<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>> &
22 PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>>
23
24 export type VideoChannelInclude = Pick<VideoChannelModel, 'id' | 'name' | 'getDisplayName'>
25 export type VideoChannelIncludeActor = VideoChannelInclude &
26 PickWith<VideoChannelModel, 'Actor', ActorInclude>
27
28 export type AccountInclude = Pick<AccountModel, 'id' | 'name' | 'getDisplayName'>
29 export type AccountIncludeActor = AccountInclude &
30 PickWith<AccountModel, 'Actor', ActorInclude>
31
32 export type VideoCommentInclude = Pick<VideoCommentModel, 'id' | 'originCommentId' | 'getThreadId'> &
33 PickWith<VideoCommentModel, 'Account', AccountIncludeActor> &
34 PickWith<VideoCommentModel, 'Video', VideoInclude>
35
36 export type VideoAbuseInclude = Pick<VideoAbuseModel, 'id'> &
37 PickWith<VideoAbuseModel, 'Video', VideoInclude>
38
39 export type VideoBlacklistInclude = Pick<VideoBlacklistModel, 'id'> &
40 PickWith<VideoAbuseModel, 'Video', VideoInclude>
41
42 export type VideoImportInclude = Pick<VideoImportModel, 'id' | 'magnetUri' | 'targetUrl' | 'torrentName'> &
43 PickWith<VideoImportModel, 'Video', VideoInclude>
44
45 export type ActorFollower = Pick<ActorModel, 'preferredUsername' | 'getHost'> &
46 PickWith<ActorModel, 'Account', AccountInclude> &
47 PickWith<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>> &
48 PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>>
49
50 export type ActorFollowing = Pick<ActorModel, 'preferredUsername'> &
51 PickWith<ActorModel, 'VideoChannel', VideoChannelInclude> &
52 PickWith<ActorModel, 'Account', AccountInclude>
53
54 export type ActorFollowInclude = Pick<ActorFollowModel, 'id' | 'state'> &
55 PickWith<ActorFollowModel, 'ActorFollower', ActorFollower> &
56 PickWith<ActorFollowModel, 'ActorFollowing', ActorFollowing>
57}
58
59export type UserNotificationModelOnly = Omit<UserNotificationModel, 'User' | 'Video' | 'Comment' | 'VideoAbuse' | 'VideoBlacklist' |
60 'VideoImport' | 'Account' | 'ActorFollow'>
61
62export type UserNotificationModelForApi = UserNotificationModelOnly &
63 PickWith<UserNotificationModel, 'Video', UserNotificationIncludes.VideoIncludeChannel> &
64 PickWith<UserNotificationModel, 'Comment', UserNotificationIncludes.VideoCommentInclude> &
65 PickWith<UserNotificationModel, 'VideoAbuse', UserNotificationIncludes.VideoAbuseInclude> &
66 PickWith<UserNotificationModel, 'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> &
67 PickWith<UserNotificationModel, 'VideoImport', UserNotificationIncludes.VideoImportInclude> &
68 PickWith<UserNotificationModel, 'ActorFollow', UserNotificationIncludes.ActorFollowInclude> &
69 PickWith<UserNotificationModel, 'Account', UserNotificationIncludes.AccountIncludeActor>
diff --git a/server/typings/models/user/user-video-history.ts b/server/typings/models/user/user-video-history.ts
new file mode 100644
index 000000000..62673ab1b
--- /dev/null
+++ b/server/typings/models/user/user-video-history.ts
@@ -0,0 +1,5 @@
1import { UserVideoHistoryModel } from '../../../models/account/user-video-history'
2
3export type MUserVideoHistory = Omit<UserVideoHistoryModel, 'Video' | 'User'>
4
5export type MUserVideoHistoryTime = Pick<MUserVideoHistory, 'currentTime'>
diff --git a/server/typings/models/user/user.ts b/server/typings/models/user/user.ts
new file mode 100644
index 000000000..b91eed8d9
--- /dev/null
+++ b/server/typings/models/user/user.ts
@@ -0,0 +1,32 @@
1import { UserModel } from '../../../models/account/user'
2import { PickWith } from '../../utils'
3import { MAccount, MAccountDefault, MAccountDefaultChannelDefault, MAccountId, MAccountIdActorId, MAccountUrl } from '../account'
4import { MNotificationSetting } from './user-notification-setting'
5
6export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoImports' | 'OAuthTokens'>
7
8export type MUserId = Pick<UserModel, 'id'>
9
10export type MUserWithNotificationSetting = MUser &
11 PickWith<UserModel, 'NotificationSetting', MNotificationSetting>
12
13export type MUserAccountDefault = MUser &
14 PickWith<UserModel, 'Account', MAccountDefault>
15
16export type MUserAccount = MUser &
17 PickWith<UserModel, 'Account', MAccount>
18
19export type MUserAccountId = MUser &
20 PickWith<UserModel, 'Account', MAccountId>
21
22export type MUserNotifSettingAccount = MUserWithNotificationSetting & MUserAccount
23
24export type MUserDefault = MUser &
25 MUserWithNotificationSetting &
26 MUserAccountDefault
27
28export type MUserChannel = MUserWithNotificationSetting &
29 PickWith<UserModel, 'Account', MAccountDefaultChannelDefault>
30
31export type MUserAccountUrl = MUser &
32 PickWith<UserModel, 'Account', MAccountUrl & MAccountIdActorId>
diff --git a/server/typings/models/video-share.ts b/server/typings/models/video-share.ts
deleted file mode 100644
index 1406749d2..000000000
--- a/server/typings/models/video-share.ts
+++ /dev/null
@@ -1,3 +0,0 @@
1import { VideoShareModel } from '../../models/video/video-share'
2
3export type VideoShareModelOnly = Omit<VideoShareModel, 'Actor' | 'Video'>
diff --git a/server/typings/models/video/index.d.ts b/server/typings/models/video/index.d.ts
new file mode 100644
index 000000000..528e9d274
--- /dev/null
+++ b/server/typings/models/video/index.d.ts
@@ -0,0 +1,14 @@
1export * from './schedule-video-update'
2export * from './tag'
3export * from './thumbnail'
4export * from './video'
5export * from './video-abuse'
6export * from './video-blacklist'
7export * from './video-caption'
8export * from './video-channels'
9export * from './video-comment'
10export * from './video-file'
11export * from './video-playlist'
12export * from './video-redundancy'
13export * from './video-share'
14export * from './video-streaming-playlist'
diff --git a/server/typings/models/video/schedule-video-update.ts b/server/typings/models/video/schedule-video-update.ts
new file mode 100644
index 000000000..069705536
--- /dev/null
+++ b/server/typings/models/video/schedule-video-update.ts
@@ -0,0 +1,3 @@
1import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update'
2
3export type MScheduleVideoUpdate = Omit<ScheduleVideoUpdateModel, 'Video'>
diff --git a/server/typings/models/video/tag.ts b/server/typings/models/video/tag.ts
new file mode 100644
index 000000000..64a68873e
--- /dev/null
+++ b/server/typings/models/video/tag.ts
@@ -0,0 +1,3 @@
1import { TagModel } from '../../../models/video/tag'
2
3export type MTag = Omit<TagModel, 'Videos'>
diff --git a/server/typings/models/video/thumbnail.ts b/server/typings/models/video/thumbnail.ts
new file mode 100644
index 000000000..c03ba55ac
--- /dev/null
+++ b/server/typings/models/video/thumbnail.ts
@@ -0,0 +1,3 @@
1import { ThumbnailModel } from '../../../models/video/thumbnail'
2
3export type MThumbnail = Omit<ThumbnailModel, 'Video' | 'VideoPlaylist'>
diff --git a/server/typings/models/video/video-abuse.ts b/server/typings/models/video/video-abuse.ts
new file mode 100644
index 000000000..1667ae55a
--- /dev/null
+++ b/server/typings/models/video/video-abuse.ts
@@ -0,0 +1,15 @@
1import { VideoAbuseModel } from '../../../models/video/video-abuse'
2import { PickWith } from '../../utils'
3import { MVideo } from './video'
4import { MAccountDefault } from '../account'
5
6export type MVideoAbuse = Omit<VideoAbuseModel, 'Account' | 'Video' | 'toActivityPubObject'>
7
8export type MVideoAbuseId = Pick<VideoAbuseModel, 'id'>
9
10export type MVideoAbuseVideo = MVideoAbuse &
11 Pick<VideoAbuseModel, 'toActivityPubObject'> &
12 PickWith<VideoAbuseModel, 'Video', MVideo>
13
14export type MVideoAbuseAccountVideo = MVideoAbuseVideo &
15 PickWith<VideoAbuseModel, 'Account', MAccountDefault>
diff --git a/server/typings/models/video/video-blacklist.ts b/server/typings/models/video/video-blacklist.ts
new file mode 100644
index 000000000..9242b357d
--- /dev/null
+++ b/server/typings/models/video/video-blacklist.ts
@@ -0,0 +1,11 @@
1import { VideoBlacklistModel } from '../../../models/video/video-blacklist'
2import { PickWith } from '@server/typings/utils'
3import { MVideo } from '@server/typings/models'
4
5export type MVideoBlacklist = Omit<VideoBlacklistModel, 'Video'>
6
7export type MVideoBlacklistLight = Pick<MVideoBlacklist, 'id' | 'reason' | 'unfederated'>
8export type MVideoBlacklistUnfederated = Pick<MVideoBlacklist, 'unfederated'>
9
10export type MVideoBlacklistVideo = MVideoBlacklist &
11 PickWith<VideoBlacklistModel, 'Video', MVideo>
diff --git a/server/typings/models/video/video-caption.ts b/server/typings/models/video/video-caption.ts
new file mode 100644
index 000000000..16d8b7392
--- /dev/null
+++ b/server/typings/models/video/video-caption.ts
@@ -0,0 +1,10 @@
1import { VideoCaptionModel } from '../../../models/video/video-caption'
2import { PickWith } from '@server/typings/utils'
3import { VideoModel } from '@server/models/video/video'
4
5export type MVideoCaption = Omit<VideoCaptionModel, 'Video'>
6
7export type MVideoCaptionLanguage = Pick<MVideoCaption, 'language'>
8
9export type MVideoCaptionVideo = MVideoCaption &
10 PickWith<VideoCaptionModel, 'Video', Pick<VideoModel, 'id' | 'remote' | 'uuid'>>
diff --git a/server/typings/models/video/video-change-ownership.ts b/server/typings/models/video/video-change-ownership.ts
new file mode 100644
index 000000000..718515e2d
--- /dev/null
+++ b/server/typings/models/video/video-change-ownership.ts
@@ -0,0 +1,10 @@
1import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership'
2import { PickWith } from '@server/typings/utils'
3import { MAccountDefault, MVideoWithFileThumbnail } from '@server/typings/models'
4
5export type MVideoChangeOwnership = Omit<VideoChangeOwnershipModel, 'Initiator' | 'NextOwner' | 'Video'>
6
7export type MVideoChangeOwnershipFull = MVideoChangeOwnership &
8 PickWith<VideoChangeOwnershipModel, 'Initiator', MAccountDefault> &
9 PickWith<VideoChangeOwnershipModel, 'NextOwner', MAccountDefault> &
10 PickWith<VideoChangeOwnershipModel, 'Video', MVideoWithFileThumbnail>
diff --git a/server/typings/models/video/video-channels.ts b/server/typings/models/video/video-channels.ts
new file mode 100644
index 000000000..e10bd6842
--- /dev/null
+++ b/server/typings/models/video/video-channels.ts
@@ -0,0 +1,70 @@
1import { FunctionProperties, PickWith } from '../../utils'
2import { VideoChannelModel } from '../../../models/video/video-channel'
3import {
4 MAccountActor,
5 MAccountAPI,
6 MAccountBlocks,
7 MAccountDefault,
8 MAccountLight,
9 MAccountUserId,
10 MActor,
11 MActorAccountChannelId,
12 MActorAPI,
13 MActorDefault,
14 MActorDefaultLight, MActorLight,
15 MActorSummary
16} from '../account'
17import { MVideo } from './video'
18
19export type MChannelId = FunctionProperties<VideoChannelModel>
20export type MChannelIdActor = MChannelId &
21 PickWith<VideoChannelModel, 'Actor', MActorAccountChannelId>
22
23export type MChannel = Omit<VideoChannelModel, 'Actor' | 'Account' | 'Videos' | 'VideoPlaylists'>
24
25export type MChannelUserId = Pick<MChannel, 'accountId'> &
26 PickWith<VideoChannelModel, 'Account', MAccountUserId>
27
28// Default scope
29export type MChannelDefault = MChannel &
30 PickWith<VideoChannelModel, 'Actor', MActorDefault>
31
32export type MChannelLight = MChannel &
33 PickWith<VideoChannelModel, 'Actor', MActorDefaultLight>
34
35export type MChannelAccountLight = MChannel &
36 PickWith<VideoChannelModel, 'Actor', MActorDefaultLight> &
37 PickWith<VideoChannelModel, 'Account', MAccountLight>
38
39export type MChannelSummary = Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> &
40 PickWith<VideoChannelModel, 'Actor', MActorSummary>
41
42export type MChannelSummaryAccount = MChannelSummary &
43 PickWith<VideoChannelModel, 'Account', MAccountBlocks>
44
45export type MChannelAPI = MChannel &
46 PickWith<VideoChannelModel, 'Actor', MActorAPI> &
47 PickWith<VideoChannelModel, 'Account', MAccountAPI>
48
49export type MChannelAccountActor = MChannel &
50 PickWith<VideoChannelModel, 'Account', MAccountActor>
51export type MChannelAccountDefault = MChannelActor &
52 PickWith<VideoChannelModel, 'Account', MAccountDefault>
53
54export type MChannelVideos = MChannel &
55 PickWith<VideoChannelModel, 'Videos', MVideo[]>
56
57export type MChannelActor = MChannel &
58 PickWith<VideoChannelModel, 'Actor', MActor>
59export type MChannelActorLight = MChannel &
60 PickWith<VideoChannelModel, 'Actor', MActorLight>
61export type MChannelActorDefault = MChannel &
62 PickWith<VideoChannelModel, 'Actor', MActorDefault>
63
64export type MChannelActorAccountActor = MChannelAccountActor & MChannelActor
65
66export type MChannelActorAccountDefault = MChannel &
67 PickWith<VideoChannelModel, 'Actor', MActorDefault> &
68 PickWith<VideoChannelModel, 'Account', MAccountDefault>
69
70export type MChannelActorAccountDefaultVideos = MChannelActorAccountDefault & MChannelVideos
diff --git a/server/typings/models/video/video-comment.ts b/server/typings/models/video/video-comment.ts
new file mode 100644
index 000000000..675613804
--- /dev/null
+++ b/server/typings/models/video/video-comment.ts
@@ -0,0 +1,29 @@
1import { VideoCommentModel } from '../../../models/video/video-comment'
2import { PickWith } from '../../utils'
3import { MAccountDefault } from '../account'
4import { MVideoAccountDefault, MVideoAccountLight, MVideoFeed, MVideoIdUrl } from './video'
5
6export type MComment = Omit<VideoCommentModel, 'OriginVideoComment' | 'InReplyToVideoComment' | 'Video' | 'Account'>
7export type MCommentId = Pick<MComment, 'id'>
8
9export type MCommentAPI = MComment & { totalReplies: number }
10
11export type MCommentOwner = MComment &
12 PickWith<VideoCommentModel, 'Account', MAccountDefault>
13
14export type MCommentVideo = MComment &
15 PickWith<VideoCommentModel, 'Video', MVideoAccountLight>
16
17export type MCommentReply = MComment &
18 PickWith<VideoCommentModel, 'InReplyToVideoComment', MComment>
19
20export type MCommentOwnerReply = MCommentOwner & MCommentReply
21export type MCommentOwnerVideo = MCommentOwner & MCommentVideo
22export type MCommentReplyVideo = MCommentReply & MCommentVideo
23export type MCommentOwnerVideoReply = MCommentOwnerVideo & MCommentReply
24
25export type MCommentOwnerReplyVideoLight = MCommentOwnerReply &
26 PickWith<VideoCommentModel, 'Video', MVideoIdUrl>
27
28export type MCommentOwnerVideoFeed = MCommentOwner &
29 PickWith<VideoCommentModel, 'Video', MVideoFeed>
diff --git a/server/typings/models/video/video-file.ts b/server/typings/models/video/video-file.ts
new file mode 100644
index 000000000..afa659d1f
--- /dev/null
+++ b/server/typings/models/video/video-file.ts
@@ -0,0 +1,15 @@
1import { VideoFileModel } from '../../../models/video/video-file'
2import { PickWith, PickWithOpt } from '../../utils'
3import { MVideo, MVideoUUID } from './video'
4import { MVideoRedundancyFileUrl } from './video-redundancy'
5
6export type MVideoFile = Omit<VideoFileModel, 'Video' | 'RedundancyVideos'>
7
8export type MVideoFileVideo = MVideoFile &
9 PickWith<VideoFileModel, 'Video', MVideo>
10
11export type MVideoFileVideoUUID = MVideoFile &
12 PickWith<VideoFileModel, 'Video', MVideoUUID>
13
14export type MVideoFileRedundanciesOpt = MVideoFile &
15 PickWithOpt<VideoFileModel, 'RedundancyVideos', MVideoRedundancyFileUrl[]>
diff --git a/server/typings/models/video/video-import.ts b/server/typings/models/video/video-import.ts
new file mode 100644
index 000000000..51be900d6
--- /dev/null
+++ b/server/typings/models/video/video-import.ts
@@ -0,0 +1,15 @@
1import { VideoImportModel } from '@server/models/video/video-import'
2import { PickWith } from '@server/typings/utils'
3import { MUser, MVideo, MVideoAccountLight, MVideoTag, MVideoThumbnail, MVideoWithFile } from '@server/typings/models'
4
5export type MVideoImport = Omit<VideoImportModel, 'User' | 'Video'>
6
7export type MVideoImportDefault = MVideoImport &
8 PickWith<VideoImportModel, 'User', MUser> &
9 PickWith<VideoImportModel, 'Video', MVideoTag & MVideoAccountLight & MVideoThumbnail>
10
11export type MVideoImportDefaultFiles = MVideoImportDefault &
12 PickWith<VideoImportModel, 'Video', MVideoTag & MVideoAccountLight & MVideoThumbnail & MVideoWithFile>
13
14export type MVideoImportVideo = MVideoImport &
15 PickWith<VideoImportModel, 'Video', MVideo>
diff --git a/server/typings/models/video/video-playlist-element.ts b/server/typings/models/video/video-playlist-element.ts
new file mode 100644
index 000000000..d1b8a18a0
--- /dev/null
+++ b/server/typings/models/video/video-playlist-element.ts
@@ -0,0 +1,15 @@
1import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element'
2import { PickWith } from '@server/typings/utils'
3import { MVideoPlaylistPrivacy, MVideoThumbnail, MVideoUrl } from '@server/typings/models'
4
5export type MVideoPlaylistElement = Omit<VideoPlaylistElementModel, 'VideoPlaylist' | 'Video'>
6export type MVideoPlaylistElementId = Pick<MVideoPlaylistElement, 'id'>
7
8export type MVideoPlaylistElementLight = Pick<MVideoPlaylistElement, 'id' | 'videoId' | 'startTimestamp' | 'stopTimestamp'>
9
10export type MVideoPlaylistVideoThumbnail = MVideoPlaylistElement &
11 PickWith<VideoPlaylistElementModel, 'Video', MVideoThumbnail>
12
13export type MVideoPlaylistAP = MVideoPlaylistElement &
14 PickWith<VideoPlaylistElementModel, 'Video', MVideoUrl> &
15 PickWith<VideoPlaylistElementModel, 'VideoPlaylist', MVideoPlaylistPrivacy>
diff --git a/server/typings/models/video/video-playlist.ts b/server/typings/models/video/video-playlist.ts
new file mode 100644
index 000000000..825b3391c
--- /dev/null
+++ b/server/typings/models/video/video-playlist.ts
@@ -0,0 +1,42 @@
1import { VideoPlaylistModel } from '../../../models/video/video-playlist'
2import { PickWith } from '../../utils'
3import { MAccount, MAccountDefault, MAccountSummary } from '../account'
4import { MThumbnail } from './thumbnail'
5import { MChannelDefault, MChannelSummary } from './video-channels'
6import { MVideoPlaylistElementLight } from '@server/typings/models/video/video-playlist-element'
7
8export type MVideoPlaylist = Omit<VideoPlaylistModel, 'OwnerAccount' | 'VideoChannel' | 'VideoPlaylistElements' | 'Thumbnail'>
9export type MVideoPlaylistId = Pick<MVideoPlaylist, 'id'>
10export type MVideoPlaylistPrivacy = Pick<MVideoPlaylist, 'privacy'>
11
12export type MVideoPlaylistWithElements = MVideoPlaylist &
13 PickWith<VideoPlaylistModel, 'VideoPlaylistElements', MVideoPlaylistElementLight[]>
14export type MVideoPlaylistIdWithElements = MVideoPlaylistId & MVideoPlaylistWithElements
15
16export type MVideoPlaylistUUID = Pick<MVideoPlaylist, 'uuid'>
17
18export type MVideoPlaylistOwner = MVideoPlaylist &
19 PickWith<VideoPlaylistModel, 'OwnerAccount', MAccount>
20
21export type MVideoPlaylistOwnerDefault = MVideoPlaylist &
22 PickWith<VideoPlaylistModel, 'OwnerAccount', MAccountDefault>
23
24export type MVideoPlaylistThumbnail = MVideoPlaylist &
25 PickWith<VideoPlaylistModel, 'Thumbnail', MThumbnail>
26
27export type MVideoPlaylistAccountThumbnail = MVideoPlaylistOwnerDefault &
28 PickWith<VideoPlaylistModel, 'Thumbnail', MThumbnail>
29
30export type MVideoPlaylistAccountChannelSummary = MVideoPlaylist &
31 PickWith<VideoPlaylistModel, 'OwnerAccount', MAccountSummary> &
32 PickWith<VideoPlaylistModel, 'VideoChannel', MChannelSummary>
33
34export type MVideoPlaylistAccountChannelDefault = MVideoPlaylist &
35 PickWith<VideoPlaylistModel, 'OwnerAccount', MAccountDefault> &
36 PickWith<VideoPlaylistModel, 'VideoChannel', MChannelDefault>
37
38export type MVideoPlaylistVideosLength = MVideoPlaylist & { videosLength: number }
39
40export type MVideoPlaylistFullSummary = MVideoPlaylistAccountChannelSummary & MVideoPlaylistThumbnail
41
42export type MVideoPlaylistFull = MVideoPlaylist & MVideoPlaylistThumbnail & MVideoPlaylistAccountChannelDefault
diff --git a/server/typings/models/video/video-rate.ts b/server/typings/models/video/video-rate.ts
new file mode 100644
index 000000000..6eefe6362
--- /dev/null
+++ b/server/typings/models/video/video-rate.ts
@@ -0,0 +1,12 @@
1import { AccountVideoRateModel } from '@server/models/account/account-video-rate'
2import { PickWith } from '@server/typings/utils'
3import { MAccountAudience, MAccountUrl, MVideo } from '..'
4
5export type MAccountVideoRate = Omit<AccountVideoRateModel, 'Video' | 'Account'>
6
7export type MAccountVideoRateAccountUrl = MAccountVideoRate &
8 PickWith<AccountVideoRateModel, 'Account', MAccountUrl>
9
10export type MAccountVideoRateAccountVideo = MAccountVideoRate &
11 PickWith<AccountVideoRateModel, 'Account', MAccountAudience> &
12 PickWith<AccountVideoRateModel, 'Video', MVideo>
diff --git a/server/typings/models/video/video-redundancy.ts b/server/typings/models/video/video-redundancy.ts
new file mode 100644
index 000000000..ec61bfb68
--- /dev/null
+++ b/server/typings/models/video/video-redundancy.ts
@@ -0,0 +1,18 @@
1import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy'
2import { PickWith } from '@server/typings/utils'
3import { MStreamingPlaylistVideo, MVideoFile, MVideoFileVideo } from '@server/typings/models'
4
5export type MVideoRedundancy = Omit<VideoRedundancyModel, 'VideoFile' | 'VideoStreamingPlaylist' | 'Actor'>
6
7export type MVideoRedundancyFileUrl = Pick<MVideoRedundancy, 'fileUrl'>
8
9export type MVideoRedundancyFile = MVideoRedundancy &
10 PickWith<VideoRedundancyModel, 'VideoFile', MVideoFile>
11
12export type MVideoRedundancyFileVideo = MVideoRedundancy &
13 PickWith<VideoRedundancyModel, 'VideoFile', MVideoFileVideo>
14
15export type MVideoRedundancyStreamingPlaylistVideo = MVideoRedundancy &
16 PickWith<VideoRedundancyModel, 'VideoStreamingPlaylist', MStreamingPlaylistVideo>
17
18export type MVideoRedundancyVideo = MVideoRedundancyFileVideo | MVideoRedundancyStreamingPlaylistVideo
diff --git a/server/typings/models/video/video-share.ts b/server/typings/models/video/video-share.ts
new file mode 100644
index 000000000..7e8cb8b61
--- /dev/null
+++ b/server/typings/models/video/video-share.ts
@@ -0,0 +1,12 @@
1import { VideoShareModel } from '../../../models/video/video-share'
2import { PickWith } from '../../utils'
3import { MActorDefault } from '../account'
4import { MVideo } from './video'
5
6export type MVideoShare = Omit<VideoShareModel, 'Actor' | 'Video'>
7
8export type MVideoShareActor = MVideoShare &
9 PickWith<VideoShareModel, 'Actor', MActorDefault>
10
11export type MVideoShareFull = MVideoShareActor &
12 PickWith<VideoShareModel, 'Video', MVideo>
diff --git a/server/typings/models/video/video-streaming-playlist.ts b/server/typings/models/video/video-streaming-playlist.ts
new file mode 100644
index 000000000..5b6310771
--- /dev/null
+++ b/server/typings/models/video/video-streaming-playlist.ts
@@ -0,0 +1,12 @@
1import { VideoStreamingPlaylistModel } from '../../../models/video/video-streaming-playlist'
2import { PickWith } from '../../utils'
3import { MVideoRedundancyFileUrl } from './video-redundancy'
4import { MVideo } from '@server/typings/models'
5
6export type MStreamingPlaylist = Omit<VideoStreamingPlaylistModel, 'Video' | 'RedundancyVideos'>
7
8export type MStreamingPlaylistVideo = MStreamingPlaylist &
9 PickWith<VideoStreamingPlaylistModel, 'Video', MVideo>
10
11export type MStreamingPlaylistRedundancies = MStreamingPlaylist &
12 PickWith<VideoStreamingPlaylistModel, 'RedundancyVideos', MVideoRedundancyFileUrl[]>
diff --git a/server/typings/models/video/video.ts b/server/typings/models/video/video.ts
new file mode 100644
index 000000000..0ffd0c302
--- /dev/null
+++ b/server/typings/models/video/video.ts
@@ -0,0 +1,103 @@
1import { VideoModel } from '../../../models/video/video'
2import { PickWith, PickWithOpt } from '../../utils'
3import { MChannelAccountLight, MChannelActor, MChannelActorAccountDefault, MChannelUserId } from './video-channels'
4import { MTag } from './tag'
5import { MVideoCaptionLanguage } from './video-caption'
6import { MStreamingPlaylist, MStreamingPlaylistRedundancies } from './video-streaming-playlist'
7import { MVideoFile, MVideoFileRedundanciesOpt } from './video-file'
8import { MThumbnail } from './thumbnail'
9import { MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist'
10import { MScheduleVideoUpdate } from './schedule-video-update'
11import { MUserVideoHistoryTime } from '../user/user-video-history'
12
13export type MVideo = Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' |
14 'VideoFiles' | 'VideoStreamingPlaylists' | 'VideoShares' | 'AccountVideoRates' | 'VideoComments' | 'VideoViews' | 'UserVideoHistories' |
15 'ScheduleVideoUpdate' | 'VideoBlacklist' | 'VideoImport' | 'VideoCaptions'>
16
17export type MVideoId = Pick<MVideo, 'id'>
18export type MVideoUrl = Pick<MVideo, 'url'>
19export type MVideoUUID = Pick<MVideo, 'uuid'>
20
21export type MVideoIdUrl = MVideoId & MVideoUrl
22export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'>
23
24export type MVideoWithFile = MVideo &
25 PickWith<VideoModel, 'VideoFiles', MVideoFile[]>
26
27export type MVideoThumbnail = MVideo &
28 PickWith<VideoModel, 'Thumbnails', MThumbnail[]>
29export type MVideoIdThumbnail = MVideoThumbnail & MVideoId
30
31export type MVideoTag = MVideo &
32 PickWith<VideoModel, 'Tags', MTag[]>
33
34export type MVideoWithSchedule = MVideo &
35 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate>
36
37export type MVideoWithFileThumbnail = MVideoWithFile & MVideoThumbnail
38
39export type MVideoUser = MVideo &
40 PickWith<VideoModel, 'VideoChannel', MChannelUserId>
41
42export type MVideoWithCaptions = MVideo &
43 PickWith<VideoModel, 'VideoCaptions', MVideoCaptionLanguage[]>
44
45export type MVideoWithBlacklistLight = MVideo &
46 PickWith<VideoModel, 'VideoBlacklist', MVideoBlacklistLight>
47
48export type MVideoAccountLight = MVideo &
49 PickWith<VideoModel, 'VideoChannel', MChannelAccountLight>
50
51export type MVideoWithRights = MVideoWithBlacklistLight & MVideoThumbnail & MVideoUser
52
53export type MVideoWithStreamingPlaylist = MVideo &
54 PickWith<VideoModel, 'VideoStreamingPlaylists', MStreamingPlaylist[]>
55
56export type MVideoWithAllFiles = MVideoWithFileThumbnail & MVideoWithStreamingPlaylist
57
58export type MVideoAccountAllFiles = MVideoWithAllFiles & MVideoAccountLight & MVideoWithBlacklistLight
59export type MVideoAccountAllFilesCaptions = MVideoAccountAllFiles & MVideoWithCaptions
60
61export type MVideoUserHistory = MVideo &
62 PickWith<VideoModel, 'UserVideoHistories', MUserVideoHistoryTime[]>
63
64export type MVideoWithBlacklistThumbnailScheduled = MVideoWithSchedule & MVideoWithBlacklistLight & MVideoWithFileThumbnail
65
66export type MVideoAccountDefault = MVideo &
67 PickWith<VideoModel, 'VideoChannel', MChannelActorAccountDefault>
68
69export type MVideoThumbnailAccountDefault = MVideoThumbnail &
70 PickWith<VideoModel, 'VideoChannel', MChannelActorAccountDefault>
71
72export type MVideoWithChannelActor = MVideo &
73 PickWith<VideoModel, 'VideoChannel', MChannelActor>
74
75export type MVideoFullLight = MVideoThumbnail &
76 MVideoWithBlacklistLight &
77 MVideoTag &
78 MVideoAccountLight &
79 MVideoUserHistory &
80 MVideoWithFile &
81 MVideoWithSchedule &
82 MVideoWithStreamingPlaylist &
83 MVideoUserHistory
84
85export type MVideoAP = MVideo &
86 MVideoTag &
87 MVideoAccountLight &
88 MVideoWithStreamingPlaylist &
89 MVideoWithCaptions &
90 PickWith<VideoModel, 'VideoBlacklist', MVideoBlacklistUnfederated> &
91 PickWith<VideoModel, 'VideoFiles', MVideoFileRedundanciesOpt[]>
92
93export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'>
94
95export type MVideoDetails = MVideo &
96 MVideoWithBlacklistLight &
97 MVideoTag &
98 MVideoAccountLight &
99 MVideoWithSchedule &
100 MVideoThumbnail &
101 MVideoUserHistory &
102 PickWith<VideoModel, 'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> &
103 PickWith<VideoModel, 'VideoFiles', MVideoFileRedundanciesOpt[]>
diff --git a/server/typings/utils.ts b/server/typings/utils.ts
index a86b05be2..ed0fca3d1 100644
--- a/server/typings/utils.ts
+++ b/server/typings/utils.ts
@@ -1,3 +1,15 @@
1export type FunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? K : never }[keyof T] 1export type FunctionPropertyNames<T> = {
2 [K in keyof T]: T[K] extends Function ? K : never
3}[keyof T]
2 4
3export type FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>> 5export type FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>>
6
7export type ValueOf <T, KT extends keyof T> = T[KT]
8
9export type PickWith<T, KT extends keyof T, V> = {
10 [P in KT]: T[P] extends V ? V : never
11}
12
13export type PickWithOpt<T, KT extends keyof T, V> = {
14 [P in KT]?: T[P] extends V ? V : never
15}