diff options
Diffstat (limited to 'server/typings/models')
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 @@ | |||
1 | import { AccountBlocklistModel } from '../../../models/account/account-blocklist' | 1 | import { AccountBlocklistModel } from '../../../models/account/account-blocklist' |
2 | import { PickWith } from '../../utils' | 2 | import { PickWith } from '../../utils' |
3 | import { MAccountDefault } from './account' | 3 | import { MAccountDefault, MAccountFormattable } from './account' |
4 | 4 | ||
5 | type Use<K extends keyof AccountBlocklistModel, M> = PickWith<AccountBlocklistModel, K, M> | 5 | type Use<K extends keyof AccountBlocklistModel, M> = PickWith<AccountBlocklistModel, K, M> |
6 | 6 | ||
@@ -15,3 +15,11 @@ export type MAccountBlocklistId = Pick<AccountBlocklistModel, 'id'> | |||
15 | export type MAccountBlocklistAccounts = MAccountBlocklist & | 15 | export 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 | |||
23 | export 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' |
14 | import { PickWith } from '../../utils' | 16 | import { FunctionProperties, PickWith } from '../../utils' |
15 | import { MAccountBlocklistId } from './account-blocklist' | 17 | import { MAccountBlocklistId } from './account-blocklist' |
16 | import { MChannelDefault } from '@server/typings/models' | 18 | import { 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 | ||
70 | export type MAccountSummary = Pick<MAccount, 'id' | 'name'> & | 72 | export type MAccountSummary = FunctionProperties<MAccount> & |
73 | Pick<MAccount, 'id' | 'name'> & | ||
71 | Use<'Actor', MActorSummary> | 74 | Use<'Actor', MActorSummary> |
72 | 75 | ||
73 | export type MAccountSummaryBlocks = MAccountSummary & | 76 | export type MAccountSummaryBlocks = MAccountSummary & |
@@ -75,3 +78,15 @@ export type MAccountSummaryBlocks = MAccountSummary & | |||
75 | 78 | ||
76 | export type MAccountAPI = MAccount & | 79 | export type MAccountAPI = MAccount & |
77 | Use<'Actor', MActorAPI> | 80 | Use<'Actor', MActorAPI> |
81 | |||
82 | // ############################################################################ | ||
83 | |||
84 | // Format for API or AP object | ||
85 | |||
86 | export type MAccountSummaryFormattable = FunctionProperties<MAccount> & | ||
87 | Pick<MAccount, 'id' | 'name'> & | ||
88 | Use<'Actor', MActorSummaryFormattable> | ||
89 | |||
90 | export 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' |
12 | import { PickWith } from '../../utils' | 12 | import { PickWith } from '../../utils' |
13 | import { ActorModel } from '@server/models/activitypub/actor' | 13 | import { ActorModel } from '@server/models/activitypub/actor' |
14 | import { MChannelDefault } from '@server/typings/models' | ||
14 | 15 | ||
15 | type Use<K extends keyof ActorFollowModel, M> = PickWith<ActorFollowModel, K, M> | 16 | type 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 | ||
47 | type SubscriptionFollowing = MActorDefault & | ||
48 | PickWith<ActorModel, 'VideoChannel', MChannelDefault> | ||
49 | |||
46 | export type MActorFollowActorsDefaultSubscription = MActorFollow & | 50 | export type MActorFollowActorsDefaultSubscription = MActorFollow & |
47 | Use<'ActorFollower', MActorDefault> & | 51 | Use<'ActorFollower', MActorDefault> & |
48 | Use<'ActorFollowing', MActorDefault & MActorChannel> | 52 | Use<'ActorFollowing', SubscriptionFollowing> |
49 | 53 | ||
50 | export type MActorFollowFollowingFullFollowerAccount = MActorFollow & | 54 | export type MActorFollowFollowingFullFollowerAccount = MActorFollow & |
51 | Use<'ActorFollower', MActorAccount> & | 55 | Use<'ActorFollower', MActorAccount> & |
@@ -53,3 +57,11 @@ export type MActorFollowFollowingFullFollowerAccount = MActorFollow & | |||
53 | 57 | ||
54 | export type MActorFollowSubscriptions = MActorFollow & | 58 | export type MActorFollowSubscriptions = MActorFollow & |
55 | Use<'ActorFollowing', MActorChannelAccountActor> | 59 | Use<'ActorFollowing', MActorChannelAccountActor> |
60 | |||
61 | // ############################################################################ | ||
62 | |||
63 | // Format for API or AP object | ||
64 | |||
65 | export 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 @@ | |||
1 | import { ActorModel } from '../../../models/activitypub/actor' | 1 | import { ActorModel } from '../../../models/activitypub/actor' |
2 | import { PickWith } from '../../utils' | 2 | import { FunctionProperties, PickWith } from '../../utils' |
3 | import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account' | 3 | import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account' |
4 | import { MServer, MServerHost, MServerHostBlocks } from '../server' | 4 | import { MServer, MServerHost, MServerHostBlocks, MServerRedundancyAllowed } from '../server' |
5 | import { MAvatar } from './avatar' | 5 | import { MAvatar, MAvatarFormattable } from './avatar' |
6 | import { MChannel, MChannelAccountActor, MChannelAccountDefault, MChannelId, MChannelIdActor } from '../video' | 6 | import { MChannel, MChannelAccountActor, MChannelAccountDefault, MChannelId, MChannelIdActor } from '../video' |
7 | 7 | ||
8 | type Use<K extends keyof ActorModel, M> = PickWith<ActorModel, K, M> | 8 | type 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 | ||
31 | export type MActorHost = Use<'Server', MServerHost> | 31 | export type MActorHost = Use<'Server', MServerHost> |
32 | export type MActorRedundancyAllowed = Use<'Server', MServerRedundancyAllowed> | ||
32 | 33 | ||
33 | export type MActorDefaultLight = MActorLight & | 34 | export 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 | ||
95 | export type MActorSummary = Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> & | 96 | export 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 | ||
102 | export type MActorAPI = Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' | | 104 | export 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 | |||
111 | export type MActorSummaryFormattable = FunctionProperties<MActor> & | ||
112 | Pick<MActor, 'url' | 'preferredUsername'> & | ||
113 | Use<'Server', MServerHost> & | ||
114 | Use<'Avatar', MAvatarFormattable> | ||
115 | |||
116 | export 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 @@ | |||
1 | import { AvatarModel } from '../../../models/avatar/avatar' | 1 | import { AvatarModel } from '../../../models/avatar/avatar' |
2 | import { FunctionProperties } from '@server/typings/utils' | ||
2 | 3 | ||
3 | export type MAvatar = AvatarModel | 4 | export type MAvatar = AvatarModel |
5 | |||
6 | // ############################################################################ | ||
7 | |||
8 | // Format for API or AP object | ||
9 | |||
10 | export 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 @@ | |||
1 | import { PluginModel } from '@server/models/server/plugin' | 1 | import { PluginModel } from '@server/models/server/plugin' |
2 | 2 | ||
3 | export type MPlugin = PluginModel | 3 | export type MPlugin = PluginModel |
4 | |||
5 | // ############################################################################ | ||
6 | |||
7 | // Format for API or AP object | ||
8 | |||
9 | export 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 @@ | |||
1 | import { ServerBlocklistModel } from '@server/models/server/server-blocklist' | 1 | import { ServerBlocklistModel } from '@server/models/server/server-blocklist' |
2 | import { PickWith } from '@server/typings/utils' | 2 | import { PickWith } from '@server/typings/utils' |
3 | import { MAccountDefault, MServer } from '@server/typings/models' | 3 | import { MAccountDefault, MAccountFormattable, MServer, MServerFormattable } from '@server/typings/models' |
4 | 4 | ||
5 | type Use<K extends keyof ServerBlocklistModel, M> = PickWith<ServerBlocklistModel, K, M> | 5 | type Use<K extends keyof ServerBlocklistModel, M> = PickWith<ServerBlocklistModel, K, M> |
6 | 6 | ||
@@ -13,3 +13,11 @@ export type MServerBlocklist = Omit<ServerBlocklistModel, 'ByAccount' | 'Blocked | |||
13 | export type MServerBlocklistAccountServer = MServerBlocklist & | 13 | export 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 | |||
21 | export 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 @@ | |||
1 | import { ServerModel } from '../../../models/server/server' | 1 | import { ServerModel } from '../../../models/server/server' |
2 | import { PickWith } from '../../utils' | 2 | import { FunctionProperties, PickWith } from '../../utils' |
3 | import { MAccountBlocklistId } from '../account' | 3 | import { MAccountBlocklistId } from '../account' |
4 | 4 | ||
5 | type Use<K extends keyof ServerModel, M> = PickWith<ServerModel, K, M> | 5 | type 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 | ||
13 | export type MServerHost = Pick<MServer, 'host'> | 13 | export type MServerHost = Pick<MServer, 'host'> |
14 | export type MServerRedundancyAllowed = Pick<MServer, 'redundancyAllowed'> | ||
14 | 15 | ||
15 | export type MServerHostBlocks = MServerHost & | 16 | export type MServerHostBlocks = MServerHost & |
16 | Use<'BlockedByAccounts', MAccountBlocklistId[]> | 17 | Use<'BlockedByAccounts', MAccountBlocklistId[]> |
18 | |||
19 | // ############################################################################ | ||
20 | |||
21 | // Format for API or AP object | ||
22 | |||
23 | export 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 @@ | |||
1 | import { UserNotificationSettingModel } from '@server/models/account/user-notification-setting' | 1 | import { UserNotificationSettingModel } from '@server/models/account/user-notification-setting' |
2 | 2 | ||
3 | export type MNotificationSetting = Omit<UserNotificationSettingModel, 'User'> | 3 | export type MNotificationSetting = Omit<UserNotificationSettingModel, 'User'> |
4 | |||
5 | // ############################################################################ | ||
6 | |||
7 | // Format for API or AP object | ||
8 | |||
9 | export 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 @@ | |||
1 | import { UserModel } from '../../../models/account/user' | 1 | import { UserModel } from '../../../models/account/user' |
2 | import { PickWith } from '../../utils' | 2 | import { PickWith, PickWithOpt } from '../../utils' |
3 | import { MAccount, MAccountDefault, MAccountDefaultChannelDefault, MAccountId, MAccountIdActorId, MAccountUrl } from '../account' | 3 | import { |
4 | import { MNotificationSetting } from './user-notification-setting' | 4 | MAccount, |
5 | MAccountDefault, | ||
6 | MAccountDefaultChannelDefault, | ||
7 | MAccountFormattable, | ||
8 | MAccountId, | ||
9 | MAccountIdActorId, | ||
10 | MAccountUrl | ||
11 | } from '../account' | ||
12 | import { MNotificationSetting, MNotificationSettingFormattable } from './user-notification-setting' | ||
13 | import { AccountModel } from '@server/models/account/account' | ||
14 | import { MChannelFormattable } from '@server/typings/models' | ||
5 | 15 | ||
6 | type Use<K extends keyof UserModel, M> = PickWith<UserModel, K, M> | 16 | type 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 | ||
24 | export type MUserQuotaUsed = MUser & { videoQuotaUsed?: number, videoQuotaUsedDaily?: number } | ||
14 | export type MUserId = Pick<UserModel, 'id'> | 25 | export type MUserId = Pick<UserModel, 'id'> |
15 | 26 | ||
16 | // ############################################################################ | 27 | // ############################################################################ |
@@ -49,3 +60,11 @@ export type MUserNotifSettingAccount = MUser & | |||
49 | export type MUserDefault = MUser & | 60 | export 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 | |||
68 | export 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 @@ | |||
1 | import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' | 1 | import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' |
2 | 2 | ||
3 | export type MScheduleVideoUpdate = Omit<ScheduleVideoUpdateModel, 'Video'> | 3 | export type MScheduleVideoUpdate = Omit<ScheduleVideoUpdateModel, 'Video'> |
4 | |||
5 | // ############################################################################ | ||
6 | |||
7 | // Format for API or AP object | ||
8 | |||
9 | export 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 @@ | |||
1 | import { VideoAbuseModel } from '../../../models/video/video-abuse' | 1 | import { VideoAbuseModel } from '../../../models/video/video-abuse' |
2 | import { PickWith } from '../../utils' | 2 | import { PickWith } from '../../utils' |
3 | import { MVideo } from './video' | 3 | import { MVideo } from './video' |
4 | import { MAccountDefault } from '../account' | 4 | import { MAccountDefault, MAccountFormattable } from '../account' |
5 | 5 | ||
6 | type Use<K extends keyof VideoAbuseModel, M> = PickWith<VideoAbuseModel, K, M> | 6 | type 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 | |||
29 | export 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 @@ | |||
1 | import { VideoBlacklistModel } from '../../../models/video/video-blacklist' | 1 | import { VideoBlacklistModel } from '../../../models/video/video-blacklist' |
2 | import { PickWith } from '@server/typings/utils' | 2 | import { PickWith } from '@server/typings/utils' |
3 | import { MVideo } from '@server/typings/models' | 3 | import { MVideo, MVideoFormattable } from '@server/typings/models' |
4 | 4 | ||
5 | type Use<K extends keyof VideoBlacklistModel, M> = PickWith<VideoBlacklistModel, K, M> | 5 | type Use<K extends keyof VideoBlacklistModel, M> = PickWith<VideoBlacklistModel, K, M> |
6 | 6 | ||
@@ -15,3 +15,10 @@ export type MVideoBlacklistUnfederated = Pick<MVideoBlacklist, 'unfederated'> | |||
15 | 15 | ||
16 | export type MVideoBlacklistVideo = MVideoBlacklist & | 16 | export type MVideoBlacklistVideo = MVideoBlacklist & |
17 | Use<'Video', MVideo> | 17 | Use<'Video', MVideo> |
18 | |||
19 | // ############################################################################ | ||
20 | |||
21 | // Format for API or AP object | ||
22 | |||
23 | export 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 @@ | |||
1 | import { VideoCaptionModel } from '../../../models/video/video-caption' | 1 | import { VideoCaptionModel } from '../../../models/video/video-caption' |
2 | import { PickWith } from '@server/typings/utils' | 2 | import { FunctionProperties, PickWith } from '@server/typings/utils' |
3 | import { VideoModel } from '@server/models/video/video' | 3 | import { MVideo, MVideoUUID } from '@server/typings/models' |
4 | 4 | ||
5 | type Use<K extends keyof VideoCaptionModel, M> = PickWith<VideoCaptionModel, K, M> | 5 | type Use<K extends keyof VideoCaptionModel, M> = PickWith<VideoCaptionModel, K, M> |
6 | 6 | ||
@@ -13,4 +13,12 @@ export type MVideoCaption = Omit<VideoCaptionModel, 'Video'> | |||
13 | export type MVideoCaptionLanguage = Pick<MVideoCaption, 'language'> | 13 | export type MVideoCaptionLanguage = Pick<MVideoCaption, 'language'> |
14 | 14 | ||
15 | export type MVideoCaptionVideo = MVideoCaption & | 15 | export 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 | |||
22 | export 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 @@ | |||
1 | import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership' | 1 | import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership' |
2 | import { PickWith } from '@server/typings/utils' | 2 | import { PickWith } from '@server/typings/utils' |
3 | import { MAccountDefault, MVideoWithFileThumbnail } from '@server/typings/models' | 3 | import { MAccountDefault, MAccountFormattable, MVideo, MVideoWithFileThumbnail } from '@server/typings/models' |
4 | 4 | ||
5 | type Use<K extends keyof VideoChangeOwnershipModel, M> = PickWith<VideoChangeOwnershipModel, K, M> | 5 | type 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 | |||
20 | export 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 @@ | |||
1 | import { PickWith } from '../../utils' | 1 | import { FunctionProperties, PickWith, PickWithOpt } from '../../utils' |
2 | import { VideoChannelModel } from '../../../models/video/video-channel' | 2 | import { VideoChannelModel } from '../../../models/video/video-channel' |
3 | import { | 3 | import { |
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' |
18 | import { MVideo } from './video' | 22 | import { MVideo } from './video' |
19 | 23 | ||
@@ -86,7 +90,8 @@ export type MChannelActorAccountDefaultVideos = MChannel & | |||
86 | 90 | ||
87 | // For API | 91 | // For API |
88 | 92 | ||
89 | export type MChannelSummary = Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> & | 93 | export type MChannelSummary = FunctionProperties<MChannel> & |
94 | Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> & | ||
90 | Use<'Actor', MActorSummary> | 95 | Use<'Actor', MActorSummary> |
91 | 96 | ||
92 | export type MChannelSummaryAccount = MChannelSummary & | 97 | export type MChannelSummaryAccount = MChannelSummary & |
@@ -95,3 +100,19 @@ export type MChannelSummaryAccount = MChannelSummary & | |||
95 | export type MChannelAPI = MChannel & | 100 | export 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 | |||
108 | export type MChannelSummaryFormattable = FunctionProperties<MChannel> & | ||
109 | Pick<MChannel, 'id' | 'name'> & | ||
110 | Use<'Actor', MActorSummaryFormattable> | ||
111 | |||
112 | export type MChannelAccountSummaryFormattable = MChannelSummaryFormattable & | ||
113 | Use<'Account', MAccountSummaryFormattable> | ||
114 | |||
115 | export 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 @@ | |||
1 | import { VideoCommentModel } from '../../../models/video/video-comment' | 1 | import { VideoCommentModel } from '../../../models/video/video-comment' |
2 | import { PickWith } from '../../utils' | 2 | import { PickWith } from '../../utils' |
3 | import { MAccountDefault } from '../account' | 3 | import { MAccountDefault, MAccountFormattable } from '../account' |
4 | import { MVideoAccountLight, MVideoFeed, MVideoIdUrl } from './video' | 4 | import { MVideoAccountLight, MVideoFeed, MVideoIdUrl } from './video' |
5 | 5 | ||
6 | type Use<K extends keyof VideoCommentModel, M> = PickWith<VideoCommentModel, K, M> | 6 | type 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 | ||
10 | export type MComment = Omit<VideoCommentModel, 'OriginVideoComment' | 'InReplyToVideoComment' | 'Video' | 'Account'> | 10 | export type MComment = Omit<VideoCommentModel, 'OriginVideoComment' | 'InReplyToVideoComment' | 'Video' | 'Account'> |
11 | export type MCommentTotalReplies = MComment & { totalReplies?: number } | ||
11 | export type MCommentId = Pick<MComment, 'id'> | 12 | export type MCommentId = Pick<MComment, 'id'> |
12 | 13 | ||
13 | // ############################################################################ | 14 | // ############################################################################ |
@@ -41,3 +42,10 @@ export type MCommentOwnerVideoFeed = MCommentOwner & | |||
41 | // ############################################################################ | 42 | // ############################################################################ |
42 | 43 | ||
43 | export type MCommentAPI = MComment & { totalReplies: number } | 44 | export type MCommentAPI = MComment & { totalReplies: number } |
45 | |||
46 | // ############################################################################ | ||
47 | |||
48 | // Format for API or AP object | ||
49 | |||
50 | export 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 @@ | |||
1 | import { VideoImportModel } from '@server/models/video/video-import' | 1 | import { VideoImportModel } from '@server/models/video/video-import' |
2 | import { PickWith } from '@server/typings/utils' | 2 | import { PickWith, PickWithOpt } from '@server/typings/utils' |
3 | import { MUser, MVideo, MVideoAccountLight, MVideoTag, MVideoThumbnail, MVideoWithFile } from '@server/typings/models' | 3 | import { MUser, MVideo, MVideoAccountLight, MVideoFormattable, MVideoTag, MVideoThumbnail, MVideoWithFile } from '@server/typings/models' |
4 | 4 | ||
5 | type Use<K extends keyof VideoImportModel, M> = PickWith<VideoImportModel, K, M> | 5 | type Use<K extends keyof VideoImportModel, M> = PickWith<VideoImportModel, K, M> |
6 | 6 | ||
@@ -22,3 +22,10 @@ export type MVideoImportDefault = MVideoImport & | |||
22 | export type MVideoImportDefaultFiles = MVideoImport & | 22 | export 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 | |||
30 | export 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 @@ | |||
1 | import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element' | 1 | import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element' |
2 | import { PickWith } from '@server/typings/utils' | 2 | import { PickWith } from '@server/typings/utils' |
3 | import { MVideoPlaylistPrivacy, MVideoThumbnail, MVideoUrl } from '@server/typings/models' | 3 | import { MVideoFormattable, MVideoPlaylistPrivacy, MVideoThumbnail, MVideoUrl } from '@server/typings/models' |
4 | 4 | ||
5 | type Use<K extends keyof VideoPlaylistElementModel, M> = PickWith<VideoPlaylistElementModel, K, M> | 5 | type 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 | ||
26 | export type MVideoPlaylistAP = MVideoPlaylistElement & | 26 | export 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 | |||
34 | export 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 @@ | |||
1 | import { VideoPlaylistModel } from '../../../models/video/video-playlist' | 1 | import { VideoPlaylistModel } from '../../../models/video/video-playlist' |
2 | import { PickWith } from '../../utils' | 2 | import { PickWith } from '../../utils' |
3 | import { MAccount, MAccountDefault, MAccountSummary } from '../account' | 3 | import { MAccount, MAccountDefault, MAccountSummary, MAccountSummaryFormattable } from '../account' |
4 | import { MThumbnail } from './thumbnail' | 4 | import { MThumbnail } from './thumbnail' |
5 | import { MChannelDefault, MChannelSummary } from './video-channels' | 5 | import { MChannelDefault, MChannelSummary, MChannelSummaryFormattable } from './video-channels' |
6 | import { MVideoPlaylistElementLight } from '@server/typings/models/video/video-playlist-element' | 6 | import { MVideoPlaylistElementLight } from '@server/typings/models/video/video-playlist-element' |
7 | 7 | ||
8 | type Use<K extends keyof VideoPlaylistModel, M> = PickWith<VideoPlaylistModel, K, M> | 8 | type Use<K extends keyof VideoPlaylistModel, M> = PickWith<VideoPlaylistModel, K, M> |
@@ -16,7 +16,7 @@ export type MVideoPlaylist = Omit<VideoPlaylistModel, 'OwnerAccount' | 'VideoCha | |||
16 | export type MVideoPlaylistId = Pick<MVideoPlaylist, 'id'> | 16 | export type MVideoPlaylistId = Pick<MVideoPlaylist, 'id'> |
17 | export type MVideoPlaylistPrivacy = Pick<MVideoPlaylist, 'privacy'> | 17 | export type MVideoPlaylistPrivacy = Pick<MVideoPlaylist, 'privacy'> |
18 | export type MVideoPlaylistUUID = Pick<MVideoPlaylist, 'uuid'> | 18 | export type MVideoPlaylistUUID = Pick<MVideoPlaylist, 'uuid'> |
19 | export type MVideoPlaylistVideosLength = MVideoPlaylist & { videosLength: number } | 19 | export 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 | |||
86 | export 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 @@ | |||
1 | import { AccountVideoRateModel } from '@server/models/account/account-video-rate' | 1 | import { AccountVideoRateModel } from '@server/models/account/account-video-rate' |
2 | import { PickWith } from '@server/typings/utils' | 2 | import { PickWith } from '@server/typings/utils' |
3 | import { MAccountAudience, MAccountUrl, MVideo } from '..' | 3 | import { MAccountAudience, MAccountUrl, MVideo, MVideoFormattable } from '..' |
4 | 4 | ||
5 | type Use<K extends keyof AccountVideoRateModel, M> = PickWith<AccountVideoRateModel, K, M> | 5 | type Use<K extends keyof AccountVideoRateModel, M> = PickWith<AccountVideoRateModel, K, M> |
6 | 6 | ||
@@ -14,3 +14,10 @@ export type MAccountVideoRateAccountUrl = MAccountVideoRate & | |||
14 | export type MAccountVideoRateAccountVideo = MAccountVideoRate & | 14 | export 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 | |||
22 | export 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 @@ | |||
1 | import { VideoModel } from '../../../models/video/video' | 1 | import { VideoModel } from '../../../models/video/video' |
2 | import { PickWith, PickWithOpt } from '../../utils' | 2 | import { PickWith, PickWithOpt } from '../../utils' |
3 | import { MChannelAccountDefault, MChannelAccountLight, MChannelActor, MChannelUserId } from './video-channels' | 3 | import { |
4 | MChannelAccountDefault, | ||
5 | MChannelAccountLight, | ||
6 | MChannelAccountSummaryFormattable, | ||
7 | MChannelActor, | ||
8 | MChannelFormattable, | ||
9 | MChannelUserId | ||
10 | } from './video-channels' | ||
4 | import { MTag } from './tag' | 11 | import { MTag } from './tag' |
5 | import { MVideoCaptionLanguage } from './video-caption' | 12 | import { MVideoCaptionLanguage } from './video-caption' |
6 | import { MStreamingPlaylist, MStreamingPlaylistRedundancies } from './video-streaming-playlist' | 13 | import { MStreamingPlaylist, MStreamingPlaylistRedundancies } from './video-streaming-playlist' |
7 | import { MVideoFile, MVideoFileRedundanciesOpt } from './video-file' | 14 | import { MVideoFile, MVideoFileRedundanciesOpt } from './video-file' |
8 | import { MThumbnail } from './thumbnail' | 15 | import { MThumbnail } from './thumbnail' |
9 | import { MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist' | 16 | import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist' |
10 | import { MScheduleVideoUpdate } from './schedule-video-update' | 17 | import { MScheduleVideoUpdate } from './schedule-video-update' |
11 | import { MUserVideoHistoryTime } from '../user/user-video-history' | 18 | import { 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 | |||
159 | export 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 | |||
165 | export type MVideoFormattableDetails = MVideoFormattable & | ||
166 | Use<'VideoChannel', MChannelFormattable> & | ||
167 | Use<'Tags', MTag[]> & | ||
168 | Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> & | ||
169 | Use<'VideoFiles', MVideoFileRedundanciesOpt[]> | ||