aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/typings/models
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2019-08-20 19:05:31 +0200
committerChocobozzz <me@florianbigard.com>2019-08-20 19:23:10 +0200
commit1ca9f7c3f7afac2af4c4c25b98426731f7e789c6 (patch)
tree27fe65c4ea5e9250d2523033d5c65b315bfca23d /server/typings/models
parent0283eaac2a8e73006c66df3cf5bb9012e37450e5 (diff)
downloadPeerTube-1ca9f7c3f7afac2af4c4c25b98426731f7e789c6.tar.gz
PeerTube-1ca9f7c3f7afac2af4c4c25b98426731f7e789c6.tar.zst
PeerTube-1ca9f7c3f7afac2af4c4c25b98426731f7e789c6.zip
Type toFormattedJSON
Diffstat (limited to 'server/typings/models')
-rw-r--r--server/typings/models/account/account-blocklist.ts10
-rw-r--r--server/typings/models/account/account.ts21
-rw-r--r--server/typings/models/account/actor-follow.ts16
-rw-r--r--server/typings/models/account/actor.ts23
-rw-r--r--server/typings/models/account/avatar.ts8
-rw-r--r--server/typings/models/server/plugin.ts7
-rw-r--r--server/typings/models/server/server-blocklist.ts10
-rw-r--r--server/typings/models/server/server.ts10
-rw-r--r--server/typings/models/user/user-notification-setting.ts6
-rw-r--r--server/typings/models/user/user.ts25
-rw-r--r--server/typings/models/video/schedule-video-update.ts6
-rw-r--r--server/typings/models/video/video-abuse.ts10
-rw-r--r--server/typings/models/video/video-blacklist.ts9
-rw-r--r--server/typings/models/video/video-caption.ts14
-rw-r--r--server/typings/models/video/video-change-ownership.ts11
-rw-r--r--server/typings/models/video/video-channels.ts27
-rw-r--r--server/typings/models/video/video-comment.ts10
-rw-r--r--server/typings/models/video/video-import.ts11
-rw-r--r--server/typings/models/video/video-playlist-element.ts11
-rw-r--r--server/typings/models/video/video-playlist.ts14
-rw-r--r--server/typings/models/video/video-rate.ts9
-rw-r--r--server/typings/models/video/video.ts27
22 files changed, 260 insertions, 35 deletions
diff --git a/server/typings/models/account/account-blocklist.ts b/server/typings/models/account/account-blocklist.ts
index d20d97aa8..c9cb55332 100644
--- a/server/typings/models/account/account-blocklist.ts
+++ b/server/typings/models/account/account-blocklist.ts
@@ -1,6 +1,6 @@
1import { AccountBlocklistModel } from '../../../models/account/account-blocklist' 1import { AccountBlocklistModel } from '../../../models/account/account-blocklist'
2import { PickWith } from '../../utils' 2import { PickWith } from '../../utils'
3import { MAccountDefault } from './account' 3import { MAccountDefault, MAccountFormattable } from './account'
4 4
5type Use<K extends keyof AccountBlocklistModel, M> = PickWith<AccountBlocklistModel, K, M> 5type Use<K extends keyof AccountBlocklistModel, M> = PickWith<AccountBlocklistModel, K, M>
6 6
@@ -15,3 +15,11 @@ export type MAccountBlocklistId = Pick<AccountBlocklistModel, 'id'>
15export type MAccountBlocklistAccounts = MAccountBlocklist & 15export type MAccountBlocklistAccounts = MAccountBlocklist &
16 Use<'ByAccount', MAccountDefault> & 16 Use<'ByAccount', MAccountDefault> &
17 Use<'BlockedAccount', MAccountDefault> 17 Use<'BlockedAccount', MAccountDefault>
18
19// ############################################################################
20
21// Format for API or AP object
22
23export type MAccountBlocklistFormattable = Pick<MAccountBlocklist, 'createdAt'> &
24 Use<'ByAccount', MAccountFormattable> &
25 Use<'BlockedAccount', MAccountFormattable>
diff --git a/server/typings/models/account/account.ts b/server/typings/models/account/account.ts
index 9a8784e6b..33940517e 100644
--- a/server/typings/models/account/account.ts
+++ b/server/typings/models/account/account.ts
@@ -9,9 +9,11 @@ import {
9 MActorId, 9 MActorId,
10 MActorServer, 10 MActorServer,
11 MActorSummary, 11 MActorSummary,
12 MActorUrl 12 MActorSummaryFormattable,
13 MActorUrl,
14 MActorFormattable
13} from './actor' 15} from './actor'
14import { PickWith } from '../../utils' 16import { FunctionProperties, PickWith } from '../../utils'
15import { MAccountBlocklistId } from './account-blocklist' 17import { MAccountBlocklistId } from './account-blocklist'
16import { MChannelDefault } from '@server/typings/models' 18import { MChannelDefault } from '@server/typings/models'
17 19
@@ -67,7 +69,8 @@ export type MAccountServer = MAccount &
67 69
68// For API 70// For API
69 71
70export type MAccountSummary = Pick<MAccount, 'id' | 'name'> & 72export type MAccountSummary = FunctionProperties<MAccount> &
73 Pick<MAccount, 'id' | 'name'> &
71 Use<'Actor', MActorSummary> 74 Use<'Actor', MActorSummary>
72 75
73export type MAccountSummaryBlocks = MAccountSummary & 76export type MAccountSummaryBlocks = MAccountSummary &
@@ -75,3 +78,15 @@ export type MAccountSummaryBlocks = MAccountSummary &
75 78
76export type MAccountAPI = MAccount & 79export type MAccountAPI = MAccount &
77 Use<'Actor', MActorAPI> 80 Use<'Actor', MActorAPI>
81
82// ############################################################################
83
84// Format for API or AP object
85
86export type MAccountSummaryFormattable = FunctionProperties<MAccount> &
87 Pick<MAccount, 'id' | 'name'> &
88 Use<'Actor', MActorSummaryFormattable>
89
90export type MAccountFormattable = FunctionProperties<MAccount> &
91 Pick<MAccount, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'userId'> &
92 Use<'Actor', MActorFormattable>
diff --git a/server/typings/models/account/actor-follow.ts b/server/typings/models/account/actor-follow.ts
index 87050ac63..17a47b8df 100644
--- a/server/typings/models/account/actor-follow.ts
+++ b/server/typings/models/account/actor-follow.ts
@@ -3,14 +3,15 @@ import {
3 MActor, 3 MActor,
4 MActorAccount, 4 MActorAccount,
5 MActorAccountChannel, 5 MActorAccountChannel,
6 MActorChannel,
7 MActorChannelAccountActor, 6 MActorChannelAccountActor,
8 MActorDefault, 7 MActorDefault,
8 MActorFormattable,
9 MActorHost, 9 MActorHost,
10 MActorUsername 10 MActorUsername
11} from './actor' 11} from './actor'
12import { PickWith } from '../../utils' 12import { PickWith } from '../../utils'
13import { ActorModel } from '@server/models/activitypub/actor' 13import { ActorModel } from '@server/models/activitypub/actor'
14import { MChannelDefault } from '@server/typings/models'
14 15
15type Use<K extends keyof ActorFollowModel, M> = PickWith<ActorFollowModel, K, M> 16type Use<K extends keyof ActorFollowModel, M> = PickWith<ActorFollowModel, K, M>
16 17
@@ -43,9 +44,12 @@ export type MActorFollowFull = MActorFollow &
43 44
44// For subscriptions 45// For subscriptions
45 46
47type SubscriptionFollowing = MActorDefault &
48 PickWith<ActorModel, 'VideoChannel', MChannelDefault>
49
46export type MActorFollowActorsDefaultSubscription = MActorFollow & 50export type MActorFollowActorsDefaultSubscription = MActorFollow &
47 Use<'ActorFollower', MActorDefault> & 51 Use<'ActorFollower', MActorDefault> &
48 Use<'ActorFollowing', MActorDefault & MActorChannel> 52 Use<'ActorFollowing', SubscriptionFollowing>
49 53
50export type MActorFollowFollowingFullFollowerAccount = MActorFollow & 54export type MActorFollowFollowingFullFollowerAccount = MActorFollow &
51 Use<'ActorFollower', MActorAccount> & 55 Use<'ActorFollower', MActorAccount> &
@@ -53,3 +57,11 @@ export type MActorFollowFollowingFullFollowerAccount = MActorFollow &
53 57
54export type MActorFollowSubscriptions = MActorFollow & 58export type MActorFollowSubscriptions = MActorFollow &
55 Use<'ActorFollowing', MActorChannelAccountActor> 59 Use<'ActorFollowing', MActorChannelAccountActor>
60
61// ############################################################################
62
63// Format for API or AP object
64
65export type MActorFollowFormattable = Pick<MActorFollow, 'id' | 'score' | 'state' | 'createdAt' | 'updatedAt'> &
66 Use<'ActorFollower', MActorFormattable> &
67 Use<'ActorFollowing', MActorFormattable>
diff --git a/server/typings/models/account/actor.ts b/server/typings/models/account/actor.ts
index 7d99a433b..14ab2cd5b 100644
--- a/server/typings/models/account/actor.ts
+++ b/server/typings/models/account/actor.ts
@@ -1,8 +1,8 @@
1import { ActorModel } from '../../../models/activitypub/actor' 1import { ActorModel } from '../../../models/activitypub/actor'
2import { PickWith } from '../../utils' 2import { FunctionProperties, PickWith } from '../../utils'
3import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account' 3import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account'
4import { MServer, MServerHost, MServerHostBlocks } from '../server' 4import { MServer, MServerHost, MServerHostBlocks, MServerRedundancyAllowed } from '../server'
5import { MAvatar } from './avatar' 5import { MAvatar, MAvatarFormattable } from './avatar'
6import { MChannel, MChannelAccountActor, MChannelAccountDefault, MChannelId, MChannelIdActor } from '../video' 6import { MChannel, MChannelAccountActor, MChannelAccountDefault, MChannelId, MChannelIdActor } from '../video'
7 7
8type Use<K extends keyof ActorModel, M> = PickWith<ActorModel, K, M> 8type Use<K extends keyof ActorModel, M> = PickWith<ActorModel, K, M>
@@ -29,6 +29,7 @@ export type MActorLight = Omit<MActor, 'privateKey' | 'privateKey'>
29// Some association attributes 29// Some association attributes
30 30
31export type MActorHost = Use<'Server', MServerHost> 31export type MActorHost = Use<'Server', MServerHost>
32export type MActorRedundancyAllowed = Use<'Server', MServerRedundancyAllowed>
32 33
33export type MActorDefaultLight = MActorLight & 34export type MActorDefaultLight = MActorLight &
34 Use<'Server', MServerHost> & 35 Use<'Server', MServerHost> &
@@ -92,7 +93,8 @@ export type MActorFullActor = MActor &
92 93
93// API 94// API
94 95
95export type MActorSummary = Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> & 96export type MActorSummary = FunctionProperties<MActor> &
97 Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> &
96 Use<'Server', MServerHost> & 98 Use<'Server', MServerHost> &
97 Use<'Avatar', MAvatar> 99 Use<'Avatar', MAvatar>
98 100
@@ -101,3 +103,16 @@ export type MActorSummaryBlocks = MActorSummary &
101 103
102export type MActorAPI = Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' | 104export type MActorAPI = Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' |
103 'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'> 105 'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'>
106
107// ############################################################################
108
109// Format for API or AP object
110
111export type MActorSummaryFormattable = FunctionProperties<MActor> &
112 Pick<MActor, 'url' | 'preferredUsername'> &
113 Use<'Server', MServerHost> &
114 Use<'Avatar', MAvatarFormattable>
115
116export type MActorFormattable = MActorSummaryFormattable &
117 Pick<MActor, 'id' | 'followingCount' | 'followersCount' | 'createdAt' | 'updatedAt'> &
118 Use<'Server', MServer>
diff --git a/server/typings/models/account/avatar.ts b/server/typings/models/account/avatar.ts
index 257c48bfc..8af6cc787 100644
--- a/server/typings/models/account/avatar.ts
+++ b/server/typings/models/account/avatar.ts
@@ -1,3 +1,11 @@
1import { AvatarModel } from '../../../models/avatar/avatar' 1import { AvatarModel } from '../../../models/avatar/avatar'
2import { FunctionProperties } from '@server/typings/utils'
2 3
3export type MAvatar = AvatarModel 4export type MAvatar = AvatarModel
5
6// ############################################################################
7
8// Format for API or AP object
9
10export type MAvatarFormattable = FunctionProperties<MAvatar> &
11 Pick<MAvatar, 'filename' | 'createdAt' | 'updatedAt'>
diff --git a/server/typings/models/server/plugin.ts b/server/typings/models/server/plugin.ts
index b1e2e149d..94674c318 100644
--- a/server/typings/models/server/plugin.ts
+++ b/server/typings/models/server/plugin.ts
@@ -1,3 +1,10 @@
1import { PluginModel } from '@server/models/server/plugin' 1import { PluginModel } from '@server/models/server/plugin'
2 2
3export type MPlugin = PluginModel 3export type MPlugin = PluginModel
4
5// ############################################################################
6
7// Format for API or AP object
8
9export type MPluginFormattable = Pick<MPlugin, 'name' | 'type' | 'version' | 'latestVersion' | 'enabled' | 'uninstalled'
10 | 'peertubeEngine' | 'description' | 'homepage' | 'settings' | 'createdAt' | 'updatedAt'>
diff --git a/server/typings/models/server/server-blocklist.ts b/server/typings/models/server/server-blocklist.ts
index 0ca00b5c2..c81f604f5 100644
--- a/server/typings/models/server/server-blocklist.ts
+++ b/server/typings/models/server/server-blocklist.ts
@@ -1,6 +1,6 @@
1import { ServerBlocklistModel } from '@server/models/server/server-blocklist' 1import { ServerBlocklistModel } from '@server/models/server/server-blocklist'
2import { PickWith } from '@server/typings/utils' 2import { PickWith } from '@server/typings/utils'
3import { MAccountDefault, MServer } from '@server/typings/models' 3import { MAccountDefault, MAccountFormattable, MServer, MServerFormattable } from '@server/typings/models'
4 4
5type Use<K extends keyof ServerBlocklistModel, M> = PickWith<ServerBlocklistModel, K, M> 5type Use<K extends keyof ServerBlocklistModel, M> = PickWith<ServerBlocklistModel, K, M>
6 6
@@ -13,3 +13,11 @@ export type MServerBlocklist = Omit<ServerBlocklistModel, 'ByAccount' | 'Blocked
13export type MServerBlocklistAccountServer = MServerBlocklist & 13export type MServerBlocklistAccountServer = MServerBlocklist &
14 Use<'ByAccount', MAccountDefault> & 14 Use<'ByAccount', MAccountDefault> &
15 Use<'BlockedServer', MServer> 15 Use<'BlockedServer', MServer>
16
17// ############################################################################
18
19// Format for API or AP object
20
21export type MServerBlocklistFormattable = Pick<MServerBlocklist, 'createdAt'> &
22 Use<'ByAccount', MAccountFormattable> &
23 Use<'BlockedServer', MServerFormattable>
diff --git a/server/typings/models/server/server.ts b/server/typings/models/server/server.ts
index c059cff79..190cc0c28 100644
--- a/server/typings/models/server/server.ts
+++ b/server/typings/models/server/server.ts
@@ -1,5 +1,5 @@
1import { ServerModel } from '../../../models/server/server' 1import { ServerModel } from '../../../models/server/server'
2import { PickWith } from '../../utils' 2import { FunctionProperties, PickWith } from '../../utils'
3import { MAccountBlocklistId } from '../account' 3import { MAccountBlocklistId } from '../account'
4 4
5type Use<K extends keyof ServerModel, M> = PickWith<ServerModel, K, M> 5type Use<K extends keyof ServerModel, M> = PickWith<ServerModel, K, M>
@@ -11,6 +11,14 @@ export type MServer = Omit<ServerModel, 'Actors' | 'BlockedByAccounts'>
11// ############################################################################ 11// ############################################################################
12 12
13export type MServerHost = Pick<MServer, 'host'> 13export type MServerHost = Pick<MServer, 'host'>
14export type MServerRedundancyAllowed = Pick<MServer, 'redundancyAllowed'>
14 15
15export type MServerHostBlocks = MServerHost & 16export type MServerHostBlocks = MServerHost &
16 Use<'BlockedByAccounts', MAccountBlocklistId[]> 17 Use<'BlockedByAccounts', MAccountBlocklistId[]>
18
19// ############################################################################
20
21// Format for API or AP object
22
23export type MServerFormattable = FunctionProperties<MServer> &
24 Pick<MServer, 'host'>
diff --git a/server/typings/models/user/user-notification-setting.ts b/server/typings/models/user/user-notification-setting.ts
index 585d30a66..c674add1b 100644
--- a/server/typings/models/user/user-notification-setting.ts
+++ b/server/typings/models/user/user-notification-setting.ts
@@ -1,3 +1,9 @@
1import { UserNotificationSettingModel } from '@server/models/account/user-notification-setting' 1import { UserNotificationSettingModel } from '@server/models/account/user-notification-setting'
2 2
3export type MNotificationSetting = Omit<UserNotificationSettingModel, 'User'> 3export type MNotificationSetting = Omit<UserNotificationSettingModel, 'User'>
4
5// ############################################################################
6
7// Format for API or AP object
8
9export type MNotificationSettingFormattable = MNotificationSetting
diff --git a/server/typings/models/user/user.ts b/server/typings/models/user/user.ts
index 466cde33b..52d6d4a05 100644
--- a/server/typings/models/user/user.ts
+++ b/server/typings/models/user/user.ts
@@ -1,7 +1,17 @@
1import { UserModel } from '../../../models/account/user' 1import { UserModel } from '../../../models/account/user'
2import { PickWith } from '../../utils' 2import { PickWith, PickWithOpt } from '../../utils'
3import { MAccount, MAccountDefault, MAccountDefaultChannelDefault, MAccountId, MAccountIdActorId, MAccountUrl } from '../account' 3import {
4import { MNotificationSetting } from './user-notification-setting' 4 MAccount,
5 MAccountDefault,
6 MAccountDefaultChannelDefault,
7 MAccountFormattable,
8 MAccountId,
9 MAccountIdActorId,
10 MAccountUrl
11} from '../account'
12import { MNotificationSetting, MNotificationSettingFormattable } from './user-notification-setting'
13import { AccountModel } from '@server/models/account/account'
14import { MChannelFormattable } from '@server/typings/models'
5 15
6type Use<K extends keyof UserModel, M> = PickWith<UserModel, K, M> 16type Use<K extends keyof UserModel, M> = PickWith<UserModel, K, M>
7 17
@@ -11,6 +21,7 @@ export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoIm
11 21
12// ############################################################################ 22// ############################################################################
13 23
24export type MUserQuotaUsed = MUser & { videoQuotaUsed?: number, videoQuotaUsedDaily?: number }
14export type MUserId = Pick<UserModel, 'id'> 25export type MUserId = Pick<UserModel, 'id'>
15 26
16// ############################################################################ 27// ############################################################################
@@ -49,3 +60,11 @@ export type MUserNotifSettingAccount = MUser &
49export type MUserDefault = MUser & 60export type MUserDefault = MUser &
50 Use<'NotificationSetting', MNotificationSetting> & 61 Use<'NotificationSetting', MNotificationSetting> &
51 Use<'Account', MAccountDefault> 62 Use<'Account', MAccountDefault>
63
64// ############################################################################
65
66// Format for API or AP object
67
68export type MUserFormattable = MUserQuotaUsed &
69 Use<'Account', MAccountFormattable & PickWithOpt<AccountModel, 'VideoChannels', MChannelFormattable[]>> &
70 PickWithOpt<UserModel, 'NotificationSetting', MNotificationSettingFormattable>
diff --git a/server/typings/models/video/schedule-video-update.ts b/server/typings/models/video/schedule-video-update.ts
index 069705536..ada9af06e 100644
--- a/server/typings/models/video/schedule-video-update.ts
+++ b/server/typings/models/video/schedule-video-update.ts
@@ -1,3 +1,9 @@
1import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' 1import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update'
2 2
3export type MScheduleVideoUpdate = Omit<ScheduleVideoUpdateModel, 'Video'> 3export type MScheduleVideoUpdate = Omit<ScheduleVideoUpdateModel, 'Video'>
4
5// ############################################################################
6
7// Format for API or AP object
8
9export type MScheduleVideoUpdateFormattable = Pick<MScheduleVideoUpdate, 'updateAt' | 'privacy'>
diff --git a/server/typings/models/video/video-abuse.ts b/server/typings/models/video/video-abuse.ts
index 0474cac5b..e38c3f586 100644
--- a/server/typings/models/video/video-abuse.ts
+++ b/server/typings/models/video/video-abuse.ts
@@ -1,7 +1,7 @@
1import { VideoAbuseModel } from '../../../models/video/video-abuse' 1import { VideoAbuseModel } from '../../../models/video/video-abuse'
2import { PickWith } from '../../utils' 2import { PickWith } from '../../utils'
3import { MVideo } from './video' 3import { MVideo } from './video'
4import { MAccountDefault } from '../account' 4import { MAccountDefault, MAccountFormattable } from '../account'
5 5
6type Use<K extends keyof VideoAbuseModel, M> = PickWith<VideoAbuseModel, K, M> 6type Use<K extends keyof VideoAbuseModel, M> = PickWith<VideoAbuseModel, K, M>
7 7
@@ -21,3 +21,11 @@ export type MVideoAbuseAccountVideo = MVideoAbuse &
21 Pick<VideoAbuseModel, 'toActivityPubObject'> & 21 Pick<VideoAbuseModel, 'toActivityPubObject'> &
22 Use<'Video', MVideo> & 22 Use<'Video', MVideo> &
23 Use<'Account', MAccountDefault> 23 Use<'Account', MAccountDefault>
24
25// ############################################################################
26
27// Format for API or AP object
28
29export type MVideoAbuseFormattable = MVideoAbuse &
30 Use<'Account', MAccountFormattable> &
31 Use<'Video', Pick<MVideo, 'id' | 'uuid' | 'name'>>
diff --git a/server/typings/models/video/video-blacklist.ts b/server/typings/models/video/video-blacklist.ts
index cc539f95c..1dedfa37f 100644
--- a/server/typings/models/video/video-blacklist.ts
+++ b/server/typings/models/video/video-blacklist.ts
@@ -1,6 +1,6 @@
1import { VideoBlacklistModel } from '../../../models/video/video-blacklist' 1import { VideoBlacklistModel } from '../../../models/video/video-blacklist'
2import { PickWith } from '@server/typings/utils' 2import { PickWith } from '@server/typings/utils'
3import { MVideo } from '@server/typings/models' 3import { MVideo, MVideoFormattable } from '@server/typings/models'
4 4
5type Use<K extends keyof VideoBlacklistModel, M> = PickWith<VideoBlacklistModel, K, M> 5type Use<K extends keyof VideoBlacklistModel, M> = PickWith<VideoBlacklistModel, K, M>
6 6
@@ -15,3 +15,10 @@ export type MVideoBlacklistUnfederated = Pick<MVideoBlacklist, 'unfederated'>
15 15
16export type MVideoBlacklistVideo = MVideoBlacklist & 16export type MVideoBlacklistVideo = MVideoBlacklist &
17 Use<'Video', MVideo> 17 Use<'Video', MVideo>
18
19// ############################################################################
20
21// Format for API or AP object
22
23export type MVideoBlacklistFormattable = MVideoBlacklist &
24 Use<'Video', MVideoFormattable>
diff --git a/server/typings/models/video/video-caption.ts b/server/typings/models/video/video-caption.ts
index fe0e664c2..7cb2a2ad3 100644
--- a/server/typings/models/video/video-caption.ts
+++ b/server/typings/models/video/video-caption.ts
@@ -1,6 +1,6 @@
1import { VideoCaptionModel } from '../../../models/video/video-caption' 1import { VideoCaptionModel } from '../../../models/video/video-caption'
2import { PickWith } from '@server/typings/utils' 2import { FunctionProperties, PickWith } from '@server/typings/utils'
3import { VideoModel } from '@server/models/video/video' 3import { MVideo, MVideoUUID } from '@server/typings/models'
4 4
5type Use<K extends keyof VideoCaptionModel, M> = PickWith<VideoCaptionModel, K, M> 5type Use<K extends keyof VideoCaptionModel, M> = PickWith<VideoCaptionModel, K, M>
6 6
@@ -13,4 +13,12 @@ export type MVideoCaption = Omit<VideoCaptionModel, 'Video'>
13export type MVideoCaptionLanguage = Pick<MVideoCaption, 'language'> 13export type MVideoCaptionLanguage = Pick<MVideoCaption, 'language'>
14 14
15export type MVideoCaptionVideo = MVideoCaption & 15export type MVideoCaptionVideo = MVideoCaption &
16 Use<'Video', Pick<VideoModel, 'id' | 'remote' | 'uuid'>> 16 Use<'Video', Pick<MVideo, 'id' | 'remote' | 'uuid'>>
17
18// ############################################################################
19
20// Format for API or AP object
21
22export type MVideoCaptionFormattable = FunctionProperties<MVideoCaption> &
23 Pick<MVideoCaption, 'language'> &
24 Use<'Video', MVideoUUID>
diff --git a/server/typings/models/video/video-change-ownership.ts b/server/typings/models/video/video-change-ownership.ts
index 0410115c6..72634cdb2 100644
--- a/server/typings/models/video/video-change-ownership.ts
+++ b/server/typings/models/video/video-change-ownership.ts
@@ -1,6 +1,6 @@
1import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership' 1import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership'
2import { PickWith } from '@server/typings/utils' 2import { PickWith } from '@server/typings/utils'
3import { MAccountDefault, MVideoWithFileThumbnail } from '@server/typings/models' 3import { MAccountDefault, MAccountFormattable, MVideo, MVideoWithFileThumbnail } from '@server/typings/models'
4 4
5type Use<K extends keyof VideoChangeOwnershipModel, M> = PickWith<VideoChangeOwnershipModel, K, M> 5type Use<K extends keyof VideoChangeOwnershipModel, M> = PickWith<VideoChangeOwnershipModel, K, M>
6 6
@@ -12,3 +12,12 @@ export type MVideoChangeOwnershipFull = MVideoChangeOwnership &
12 Use<'Initiator', MAccountDefault> & 12 Use<'Initiator', MAccountDefault> &
13 Use<'NextOwner', MAccountDefault> & 13 Use<'NextOwner', MAccountDefault> &
14 Use<'Video', MVideoWithFileThumbnail> 14 Use<'Video', MVideoWithFileThumbnail>
15
16// ############################################################################
17
18// Format for API or AP object
19
20export type MVideoChangeOwnershipFormattable = Pick<MVideoChangeOwnership, 'id' | 'status' | 'createdAt'> &
21 Use<'Initiator', MAccountFormattable> &
22 Use<'NextOwner', MAccountFormattable> &
23 Use<'Video', Pick<MVideo, 'id' | 'uuid' | 'url' | 'name'>>
diff --git a/server/typings/models/video/video-channels.ts b/server/typings/models/video/video-channels.ts
index b6506ed9f..2be7dd7ed 100644
--- a/server/typings/models/video/video-channels.ts
+++ b/server/typings/models/video/video-channels.ts
@@ -1,19 +1,23 @@
1import { PickWith } from '../../utils' 1import { FunctionProperties, PickWith, PickWithOpt } from '../../utils'
2import { VideoChannelModel } from '../../../models/video/video-channel' 2import { VideoChannelModel } from '../../../models/video/video-channel'
3import { 3import {
4 MAccountActor, 4 MAccountActor,
5 MAccountAPI, 5 MAccountAPI,
6 MAccountDefault, 6 MAccountDefault,
7 MAccountFormattable,
7 MAccountLight, 8 MAccountLight,
8 MAccountSummaryBlocks, 9 MAccountSummaryBlocks,
10 MAccountSummaryFormattable,
9 MAccountUserId, 11 MAccountUserId,
10 MActor, 12 MActor,
11 MActorAccountChannelId, 13 MActorAccountChannelId,
12 MActorAPI, 14 MActorAPI,
13 MActorDefault, 15 MActorDefault,
14 MActorDefaultLight, 16 MActorDefaultLight,
17 MActorFormattable,
15 MActorLight, 18 MActorLight,
16 MActorSummary 19 MActorSummary,
20 MActorSummaryFormattable
17} from '../account' 21} from '../account'
18import { MVideo } from './video' 22import { MVideo } from './video'
19 23
@@ -86,7 +90,8 @@ export type MChannelActorAccountDefaultVideos = MChannel &
86 90
87// For API 91// For API
88 92
89export type MChannelSummary = Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> & 93export type MChannelSummary = FunctionProperties<MChannel> &
94 Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> &
90 Use<'Actor', MActorSummary> 95 Use<'Actor', MActorSummary>
91 96
92export type MChannelSummaryAccount = MChannelSummary & 97export type MChannelSummaryAccount = MChannelSummary &
@@ -95,3 +100,19 @@ export type MChannelSummaryAccount = MChannelSummary &
95export type MChannelAPI = MChannel & 100export type MChannelAPI = MChannel &
96 Use<'Actor', MActorAPI> & 101 Use<'Actor', MActorAPI> &
97 Use<'Account', MAccountAPI> 102 Use<'Account', MAccountAPI>
103
104// ############################################################################
105
106// Format for API or AP object
107
108export type MChannelSummaryFormattable = FunctionProperties<MChannel> &
109 Pick<MChannel, 'id' | 'name'> &
110 Use<'Actor', MActorSummaryFormattable>
111
112export type MChannelAccountSummaryFormattable = MChannelSummaryFormattable &
113 Use<'Account', MAccountSummaryFormattable>
114
115export type MChannelFormattable = FunctionProperties<MChannel> &
116 Pick<MChannel, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'support'> &
117 Use<'Actor', MActorFormattable> &
118 PickWithOpt<VideoChannelModel, 'Account', MAccountFormattable>
diff --git a/server/typings/models/video/video-comment.ts b/server/typings/models/video/video-comment.ts
index 187461213..e8bccba0f 100644
--- a/server/typings/models/video/video-comment.ts
+++ b/server/typings/models/video/video-comment.ts
@@ -1,6 +1,6 @@
1import { VideoCommentModel } from '../../../models/video/video-comment' 1import { VideoCommentModel } from '../../../models/video/video-comment'
2import { PickWith } from '../../utils' 2import { PickWith } from '../../utils'
3import { MAccountDefault } from '../account' 3import { MAccountDefault, MAccountFormattable } from '../account'
4import { MVideoAccountLight, MVideoFeed, MVideoIdUrl } from './video' 4import { MVideoAccountLight, MVideoFeed, MVideoIdUrl } from './video'
5 5
6type Use<K extends keyof VideoCommentModel, M> = PickWith<VideoCommentModel, K, M> 6type Use<K extends keyof VideoCommentModel, M> = PickWith<VideoCommentModel, K, M>
@@ -8,6 +8,7 @@ type Use<K extends keyof VideoCommentModel, M> = PickWith<VideoCommentModel, K,
8// ############################################################################ 8// ############################################################################
9 9
10export type MComment = Omit<VideoCommentModel, 'OriginVideoComment' | 'InReplyToVideoComment' | 'Video' | 'Account'> 10export type MComment = Omit<VideoCommentModel, 'OriginVideoComment' | 'InReplyToVideoComment' | 'Video' | 'Account'>
11export type MCommentTotalReplies = MComment & { totalReplies?: number }
11export type MCommentId = Pick<MComment, 'id'> 12export type MCommentId = Pick<MComment, 'id'>
12 13
13// ############################################################################ 14// ############################################################################
@@ -41,3 +42,10 @@ export type MCommentOwnerVideoFeed = MCommentOwner &
41// ############################################################################ 42// ############################################################################
42 43
43export type MCommentAPI = MComment & { totalReplies: number } 44export type MCommentAPI = MComment & { totalReplies: number }
45
46// ############################################################################
47
48// Format for API or AP object
49
50export type MCommentFormattable = MCommentTotalReplies &
51 Use<'Account', MAccountFormattable>
diff --git a/server/typings/models/video/video-import.ts b/server/typings/models/video/video-import.ts
index ada723713..c6a1c5b66 100644
--- a/server/typings/models/video/video-import.ts
+++ b/server/typings/models/video/video-import.ts
@@ -1,6 +1,6 @@
1import { VideoImportModel } from '@server/models/video/video-import' 1import { VideoImportModel } from '@server/models/video/video-import'
2import { PickWith } from '@server/typings/utils' 2import { PickWith, PickWithOpt } from '@server/typings/utils'
3import { MUser, MVideo, MVideoAccountLight, MVideoTag, MVideoThumbnail, MVideoWithFile } from '@server/typings/models' 3import { MUser, MVideo, MVideoAccountLight, MVideoFormattable, MVideoTag, MVideoThumbnail, MVideoWithFile } from '@server/typings/models'
4 4
5type Use<K extends keyof VideoImportModel, M> = PickWith<VideoImportModel, K, M> 5type Use<K extends keyof VideoImportModel, M> = PickWith<VideoImportModel, K, M>
6 6
@@ -22,3 +22,10 @@ export type MVideoImportDefault = MVideoImport &
22export type MVideoImportDefaultFiles = MVideoImport & 22export type MVideoImportDefaultFiles = MVideoImport &
23 Use<'User', MUser> & 23 Use<'User', MUser> &
24 Use<'Video', VideoAssociation & MVideoWithFile> 24 Use<'Video', VideoAssociation & MVideoWithFile>
25
26// ############################################################################
27
28// Format for API or AP object
29
30export type MVideoImportFormattable = MVideoImport &
31 PickWithOpt<VideoImportModel, 'Video', MVideoFormattable & MVideoTag>
diff --git a/server/typings/models/video/video-playlist-element.ts b/server/typings/models/video/video-playlist-element.ts
index 5a039d7b1..1c256fd25 100644
--- a/server/typings/models/video/video-playlist-element.ts
+++ b/server/typings/models/video/video-playlist-element.ts
@@ -1,6 +1,6 @@
1import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element' 1import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element'
2import { PickWith } from '@server/typings/utils' 2import { PickWith } from '@server/typings/utils'
3import { MVideoPlaylistPrivacy, MVideoThumbnail, MVideoUrl } from '@server/typings/models' 3import { MVideoFormattable, MVideoPlaylistPrivacy, MVideoThumbnail, MVideoUrl } from '@server/typings/models'
4 4
5type Use<K extends keyof VideoPlaylistElementModel, M> = PickWith<VideoPlaylistElementModel, K, M> 5type Use<K extends keyof VideoPlaylistElementModel, M> = PickWith<VideoPlaylistElementModel, K, M>
6 6
@@ -23,6 +23,13 @@ export type MVideoPlaylistVideoThumbnail = MVideoPlaylistElement &
23 23
24// For API 24// For API
25 25
26export type MVideoPlaylistAP = MVideoPlaylistElement & 26export type MVideoPlaylistElementAP = MVideoPlaylistElement &
27 Use<'Video', MVideoUrl> & 27 Use<'Video', MVideoUrl> &
28 Use<'VideoPlaylist', MVideoPlaylistPrivacy> 28 Use<'VideoPlaylist', MVideoPlaylistPrivacy>
29
30// ############################################################################
31
32// Format for API or AP object
33
34export type MVideoPlaylistElementFormattable = MVideoPlaylistElement &
35 Use<'Video', MVideoFormattable>
diff --git a/server/typings/models/video/video-playlist.ts b/server/typings/models/video/video-playlist.ts
index 633818405..a926106c5 100644
--- a/server/typings/models/video/video-playlist.ts
+++ b/server/typings/models/video/video-playlist.ts
@@ -1,8 +1,8 @@
1import { VideoPlaylistModel } from '../../../models/video/video-playlist' 1import { VideoPlaylistModel } from '../../../models/video/video-playlist'
2import { PickWith } from '../../utils' 2import { PickWith } from '../../utils'
3import { MAccount, MAccountDefault, MAccountSummary } from '../account' 3import { MAccount, MAccountDefault, MAccountSummary, MAccountSummaryFormattable } from '../account'
4import { MThumbnail } from './thumbnail' 4import { MThumbnail } from './thumbnail'
5import { MChannelDefault, MChannelSummary } from './video-channels' 5import { MChannelDefault, MChannelSummary, MChannelSummaryFormattable } from './video-channels'
6import { MVideoPlaylistElementLight } from '@server/typings/models/video/video-playlist-element' 6import { MVideoPlaylistElementLight } from '@server/typings/models/video/video-playlist-element'
7 7
8type Use<K extends keyof VideoPlaylistModel, M> = PickWith<VideoPlaylistModel, K, M> 8type Use<K extends keyof VideoPlaylistModel, M> = PickWith<VideoPlaylistModel, K, M>
@@ -16,7 +16,7 @@ export type MVideoPlaylist = Omit<VideoPlaylistModel, 'OwnerAccount' | 'VideoCha
16export type MVideoPlaylistId = Pick<MVideoPlaylist, 'id'> 16export type MVideoPlaylistId = Pick<MVideoPlaylist, 'id'>
17export type MVideoPlaylistPrivacy = Pick<MVideoPlaylist, 'privacy'> 17export type MVideoPlaylistPrivacy = Pick<MVideoPlaylist, 'privacy'>
18export type MVideoPlaylistUUID = Pick<MVideoPlaylist, 'uuid'> 18export type MVideoPlaylistUUID = Pick<MVideoPlaylist, 'uuid'>
19export type MVideoPlaylistVideosLength = MVideoPlaylist & { videosLength: number } 19export type MVideoPlaylistVideosLength = MVideoPlaylist & { videosLength?: number }
20 20
21// ############################################################################ 21// ############################################################################
22 22
@@ -78,3 +78,11 @@ export type MVideoPlaylistFullSummary = MVideoPlaylist &
78 Use<'Thumbnail', MThumbnail> & 78 Use<'Thumbnail', MThumbnail> &
79 Use<'OwnerAccount', MAccountSummary> & 79 Use<'OwnerAccount', MAccountSummary> &
80 Use<'VideoChannel', MChannelSummary> 80 Use<'VideoChannel', MChannelSummary>
81
82// ############################################################################
83
84// Format for API or AP object
85
86export type MVideoPlaylistFormattable = MVideoPlaylistVideosLength &
87 Use<'OwnerAccount', MAccountSummaryFormattable> &
88 Use<'VideoChannel', MChannelSummaryFormattable>
diff --git a/server/typings/models/video/video-rate.ts b/server/typings/models/video/video-rate.ts
index fc9329993..2ff8a625b 100644
--- a/server/typings/models/video/video-rate.ts
+++ b/server/typings/models/video/video-rate.ts
@@ -1,6 +1,6 @@
1import { AccountVideoRateModel } from '@server/models/account/account-video-rate' 1import { AccountVideoRateModel } from '@server/models/account/account-video-rate'
2import { PickWith } from '@server/typings/utils' 2import { PickWith } from '@server/typings/utils'
3import { MAccountAudience, MAccountUrl, MVideo } from '..' 3import { MAccountAudience, MAccountUrl, MVideo, MVideoFormattable } from '..'
4 4
5type Use<K extends keyof AccountVideoRateModel, M> = PickWith<AccountVideoRateModel, K, M> 5type Use<K extends keyof AccountVideoRateModel, M> = PickWith<AccountVideoRateModel, K, M>
6 6
@@ -14,3 +14,10 @@ export type MAccountVideoRateAccountUrl = MAccountVideoRate &
14export type MAccountVideoRateAccountVideo = MAccountVideoRate & 14export type MAccountVideoRateAccountVideo = MAccountVideoRate &
15 Use<'Account', MAccountAudience> & 15 Use<'Account', MAccountAudience> &
16 Use<'Video', MVideo> 16 Use<'Video', MVideo>
17
18// ############################################################################
19
20// Format for API or AP object
21
22export type MAccountVideoRateFormattable = Pick<MAccountVideoRate, 'type'> &
23 Use<'Video', MVideoFormattable>
diff --git a/server/typings/models/video/video.ts b/server/typings/models/video/video.ts
index 914eb7f57..bc6d56607 100644
--- a/server/typings/models/video/video.ts
+++ b/server/typings/models/video/video.ts
@@ -1,12 +1,19 @@
1import { VideoModel } from '../../../models/video/video' 1import { VideoModel } from '../../../models/video/video'
2import { PickWith, PickWithOpt } from '../../utils' 2import { PickWith, PickWithOpt } from '../../utils'
3import { MChannelAccountDefault, MChannelAccountLight, MChannelActor, MChannelUserId } from './video-channels' 3import {
4 MChannelAccountDefault,
5 MChannelAccountLight,
6 MChannelAccountSummaryFormattable,
7 MChannelActor,
8 MChannelFormattable,
9 MChannelUserId
10} from './video-channels'
4import { MTag } from './tag' 11import { MTag } from './tag'
5import { MVideoCaptionLanguage } from './video-caption' 12import { MVideoCaptionLanguage } from './video-caption'
6import { MStreamingPlaylist, MStreamingPlaylistRedundancies } from './video-streaming-playlist' 13import { MStreamingPlaylist, MStreamingPlaylistRedundancies } from './video-streaming-playlist'
7import { MVideoFile, MVideoFileRedundanciesOpt } from './video-file' 14import { MVideoFile, MVideoFileRedundanciesOpt } from './video-file'
8import { MThumbnail } from './thumbnail' 15import { MThumbnail } from './thumbnail'
9import { MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist' 16import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist'
10import { MScheduleVideoUpdate } from './schedule-video-update' 17import { MScheduleVideoUpdate } from './schedule-video-update'
11import { MUserVideoHistoryTime } from '../user/user-video-history' 18import { MUserVideoHistoryTime } from '../user/user-video-history'
12 19
@@ -144,3 +151,19 @@ export type MVideoForUser = MVideo &
144 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> & 151 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
145 Use<'VideoBlacklist', MVideoBlacklistLight> & 152 Use<'VideoBlacklist', MVideoBlacklistLight> &
146 Use<'Thumbnails', MThumbnail[]> 153 Use<'Thumbnails', MThumbnail[]>
154
155// ############################################################################
156
157// Format for API or AP object
158
159export type MVideoFormattable = MVideo &
160 PickWithOpt<VideoModel, 'UserVideoHistories', MUserVideoHistoryTime[]> &
161 Use<'VideoChannel', MChannelAccountSummaryFormattable> &
162 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', Pick<MScheduleVideoUpdate, 'updateAt' | 'privacy'>> &
163 PickWithOpt<VideoModel, 'VideoBlacklist', Pick<MVideoBlacklist, 'reason'>>
164
165export type MVideoFormattableDetails = MVideoFormattable &
166 Use<'VideoChannel', MChannelFormattable> &
167 Use<'Tags', MTag[]> &
168 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> &
169 Use<'VideoFiles', MVideoFileRedundanciesOpt[]>