aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/typings/models
diff options
context:
space:
mode:
Diffstat (limited to 'server/typings/models')
-rw-r--r--server/typings/models/account/account-blocklist.ts25
-rw-r--r--server/typings/models/account/account.ts95
-rw-r--r--server/typings/models/account/actor-follow.ts67
-rw-r--r--server/typings/models/account/actor.ts121
-rw-r--r--server/typings/models/account/avatar.ts11
-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.ts6
-rw-r--r--server/typings/models/oauth/index.d.ts2
-rw-r--r--server/typings/models/oauth/oauth-client.ts3
-rw-r--r--server/typings/models/oauth/oauth-token.ts13
-rw-r--r--server/typings/models/server/index.d.ts3
-rw-r--r--server/typings/models/server/plugin.ts10
-rw-r--r--server/typings/models/server/server-blocklist.ts23
-rw-r--r--server/typings/models/server/server.ts24
-rw-r--r--server/typings/models/user/index.d.ts4
-rw-r--r--server/typings/models/user/user-notification-setting.ts9
-rw-r--r--server/typings/models/user/user-notification.ts77
-rw-r--r--server/typings/models/user/user-video-history.ts5
-rw-r--r--server/typings/models/user/user.ts70
-rw-r--r--server/typings/models/video-share.ts3
-rw-r--r--server/typings/models/video/index.d.ts18
-rw-r--r--server/typings/models/video/schedule-video-update.ts9
-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.ts31
-rw-r--r--server/typings/models/video/video-blacklist.ts24
-rw-r--r--server/typings/models/video/video-caption.ts24
-rw-r--r--server/typings/models/video/video-change-ownership.ts23
-rw-r--r--server/typings/models/video/video-channels.ts126
-rw-r--r--server/typings/models/video/video-comment.ts57
-rw-r--r--server/typings/models/video/video-file.ts19
-rw-r--r--server/typings/models/video/video-import.ts31
-rw-r--r--server/typings/models/video/video-playlist-element.ts34
-rw-r--r--server/typings/models/video/video-playlist.ts92
-rw-r--r--server/typings/models/video/video-rate.ts23
-rw-r--r--server/typings/models/video/video-redundancy.ts38
-rw-r--r--server/typings/models/video/video-share.ts17
-rw-r--r--server/typings/models/video/video-streaming-playlist.ts19
-rw-r--r--server/typings/models/video/video.ts169
41 files changed, 1332 insertions, 34 deletions
diff --git a/server/typings/models/account/account-blocklist.ts b/server/typings/models/account/account-blocklist.ts
new file mode 100644
index 000000000..c9cb55332
--- /dev/null
+++ b/server/typings/models/account/account-blocklist.ts
@@ -0,0 +1,25 @@
1import { AccountBlocklistModel } from '../../../models/account/account-blocklist'
2import { PickWith } from '../../utils'
3import { MAccountDefault, MAccountFormattable } from './account'
4
5type Use<K extends keyof AccountBlocklistModel, M> = PickWith<AccountBlocklistModel, K, M>
6
7// ############################################################################
8
9export type MAccountBlocklist = Omit<AccountBlocklistModel, 'ByAccount' | 'BlockedAccount'>
10
11// ############################################################################
12
13export type MAccountBlocklistId = Pick<AccountBlocklistModel, 'id'>
14
15export type MAccountBlocklistAccounts = MAccountBlocklist &
16 Use<'ByAccount', 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
new file mode 100644
index 000000000..ec78fece8
--- /dev/null
+++ b/server/typings/models/account/account.ts
@@ -0,0 +1,95 @@
1import { AccountModel } from '../../../models/account/account'
2import {
3 MActor,
4 MActorAP,
5 MActorAPI,
6 MActorAudience,
7 MActorDefault,
8 MActorDefaultLight,
9 MActorFormattable,
10 MActorId,
11 MActorServer,
12 MActorSummary,
13 MActorSummaryFormattable,
14 MActorUrl
15} from './actor'
16import { FunctionProperties, PickWith } from '../../utils'
17import { MAccountBlocklistId } from './account-blocklist'
18import { MChannelDefault } from '@server/typings/models'
19
20type Use<K extends keyof AccountModel, M> = PickWith<AccountModel, K, M>
21
22// ############################################################################
23
24export type MAccount = Omit<AccountModel, 'Actor' | 'User' | 'Application' | 'VideoChannels' | 'VideoPlaylists' |
25 'VideoComments' | 'BlockedAccounts'>
26
27// ############################################################################
28
29// Only some attributes
30export type MAccountId = Pick<MAccount, 'id'>
31export type MAccountUserId = Pick<MAccount, 'userId'>
32
33// Only some Actor attributes
34export type MAccountUrl = Use<'Actor', MActorUrl>
35export type MAccountAudience = Use<'Actor', MActorAudience>
36
37export type MAccountIdActor = MAccountId &
38 Use<'Actor', MActor>
39
40export type MAccountIdActorId = MAccountId &
41 Use<'Actor', MActorId>
42
43// ############################################################################
44
45// Default scope
46export type MAccountDefault = MAccount &
47 Use<'Actor', MActorDefault>
48
49// Default with default association scopes
50export type MAccountDefaultChannelDefault = MAccount &
51 Use<'Actor', MActorDefault> &
52 Use<'VideoChannels', MChannelDefault[]>
53
54// We don't need some actors attributes
55export type MAccountLight = MAccount &
56 Use<'Actor', MActorDefaultLight>
57
58// ############################################################################
59
60// Full actor
61export type MAccountActor = MAccount &
62 Use<'Actor', MActor>
63
64// Full actor with server
65export type MAccountServer = MAccount &
66 Use<'Actor', MActorServer>
67
68// ############################################################################
69
70// For API
71
72export type MAccountSummary = FunctionProperties<MAccount> &
73 Pick<MAccount, 'id' | 'name'> &
74 Use<'Actor', MActorSummary>
75
76export type MAccountSummaryBlocks = MAccountSummary &
77 Use<'BlockedAccounts', MAccountBlocklistId[]>
78
79export type MAccountAPI = MAccount &
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>
93
94export type MAccountAP = Pick<MAccount, 'name' | 'description'> &
95 Use<'Actor', MActorAP>
diff --git a/server/typings/models/account/actor-follow.ts b/server/typings/models/account/actor-follow.ts
new file mode 100644
index 000000000..17a47b8df
--- /dev/null
+++ b/server/typings/models/account/actor-follow.ts
@@ -0,0 +1,67 @@
1import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
2import {
3 MActor,
4 MActorAccount,
5 MActorAccountChannel,
6 MActorChannelAccountActor,
7 MActorDefault,
8 MActorFormattable,
9 MActorHost,
10 MActorUsername
11} from './actor'
12import { PickWith } from '../../utils'
13import { ActorModel } from '@server/models/activitypub/actor'
14import { MChannelDefault } from '@server/typings/models'
15
16type Use<K extends keyof ActorFollowModel, M> = PickWith<ActorFollowModel, K, M>
17
18// ############################################################################
19
20export type MActorFollow = Omit<ActorFollowModel, 'ActorFollower' | 'ActorFollowing'>
21
22// ############################################################################
23
24export type MActorFollowFollowingHost = MActorFollow &
25 Use<'ActorFollowing', MActorUsername & MActorHost>
26
27// ############################################################################
28
29// With actors or actors default
30
31export type MActorFollowActors = MActorFollow &
32 Use<'ActorFollower', MActor> &
33 Use<'ActorFollowing', MActor>
34
35export type MActorFollowActorsDefault = MActorFollow &
36 Use<'ActorFollower', MActorDefault> &
37 Use<'ActorFollowing', MActorDefault>
38
39export type MActorFollowFull = MActorFollow &
40 Use<'ActorFollower', MActorAccountChannel> &
41 Use<'ActorFollowing', MActorAccountChannel>
42
43// ############################################################################
44
45// For subscriptions
46
47type SubscriptionFollowing = MActorDefault &
48 PickWith<ActorModel, 'VideoChannel', MChannelDefault>
49
50export type MActorFollowActorsDefaultSubscription = MActorFollow &
51 Use<'ActorFollower', MActorDefault> &
52 Use<'ActorFollowing', SubscriptionFollowing>
53
54export type MActorFollowFollowingFullFollowerAccount = MActorFollow &
55 Use<'ActorFollower', MActorAccount> &
56 Use<'ActorFollowing', MActorAccountChannel>
57
58export type MActorFollowSubscriptions = MActorFollow &
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
new file mode 100644
index 000000000..d4bcac4a3
--- /dev/null
+++ b/server/typings/models/account/actor.ts
@@ -0,0 +1,121 @@
1import { ActorModel } from '../../../models/activitypub/actor'
2import { FunctionProperties, PickWith, PickWithOpt } from '../../utils'
3import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account'
4import { MServer, MServerHost, MServerHostBlocks, MServerRedundancyAllowed } from '../server'
5import { MAvatar, MAvatarFormattable } from './avatar'
6import { MChannel, MChannelAccountActor, MChannelAccountDefault, MChannelId, MChannelIdActor } from '../video'
7
8type Use<K extends keyof ActorModel, M> = PickWith<ActorModel, K, M>
9
10// ############################################################################
11
12export type MActor = Omit<ActorModel, 'Account' | 'VideoChannel' | 'ActorFollowing' | 'Avatar' | 'ActorFollowers' | 'Server'>
13
14// ############################################################################
15
16export type MActorUrl = Pick<MActor, 'url'>
17export type MActorId = Pick<MActor, 'id'>
18export type MActorUsername = Pick<MActor, 'preferredUsername'>
19
20export type MActorFollowersUrl = Pick<MActor, 'followersUrl'>
21export type MActorAudience = MActorUrl & MActorFollowersUrl
22export type MActorFollowerException = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl'>
23export type MActorSignature = MActorAccountChannelId
24
25export type MActorLight = Omit<MActor, 'privateKey' | 'privateKey'>
26
27// ############################################################################
28
29// Some association attributes
30
31export type MActorHost = Use<'Server', MServerHost>
32export type MActorRedundancyAllowedOpt = PickWithOpt<ActorModel, 'Server', MServerRedundancyAllowed>
33
34export type MActorDefaultLight = MActorLight &
35 Use<'Server', MServerHost> &
36 Use<'Avatar', MAvatar>
37
38export type MActorAccountId = MActor &
39 Use<'Account', MAccountId>
40export type MActorAccountIdActor = MActor &
41 Use<'Account', MAccountIdActor>
42
43export type MActorChannelId = MActor &
44 Use<'VideoChannel', MChannelId>
45export type MActorChannelIdActor = MActor &
46 Use<'VideoChannel', MChannelIdActor>
47
48export type MActorAccountChannelId = MActorAccountId & MActorChannelId
49export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor
50
51// ############################################################################
52
53// Include raw account/channel/server
54
55export type MActorAccount = MActor &
56 Use<'Account', MAccount>
57
58export type MActorChannel = MActor &
59 Use<'VideoChannel', MChannel>
60
61export type MActorAccountChannel = MActorAccount & MActorChannel
62
63export type MActorServer = MActor &
64 Use<'Server', MServer>
65
66// ############################################################################
67
68// Complex actor associations
69
70export type MActorDefault = MActor &
71 Use<'Server', MServer> &
72 Use<'Avatar', MAvatar>
73
74// Actor with channel that is associated to an account and its actor
75// Actor -> VideoChannel -> Account -> Actor
76export type MActorChannelAccountActor = MActor &
77 Use<'VideoChannel', MChannelAccountActor>
78
79export type MActorFull = MActor &
80 Use<'Server', MServer> &
81 Use<'Avatar', MAvatar> &
82 Use<'Account', MAccount> &
83 Use<'VideoChannel', MChannelAccountActor>
84
85// Same than ActorFull, but the account and the channel have their actor
86export type MActorFullActor = MActor &
87 Use<'Server', MServer> &
88 Use<'Avatar', MAvatar> &
89 Use<'Account', MAccountDefault> &
90 Use<'VideoChannel', MChannelAccountDefault>
91
92// ############################################################################
93
94// API
95
96export type MActorSummary = FunctionProperties<MActor> &
97 Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> &
98 Use<'Server', MServerHost> &
99 Use<'Avatar', MAvatar>
100
101export type MActorSummaryBlocks = MActorSummary &
102 Use<'Server', MServerHostBlocks>
103
104export type MActorAPI = Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' |
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', MServerHost & Partial<Pick<MServer, 'redundancyAllowed'>>>
119
120export type MActorAP = MActor &
121 Use<'Avatar', MAvatar>
diff --git a/server/typings/models/account/avatar.ts b/server/typings/models/account/avatar.ts
new file mode 100644
index 000000000..8af6cc787
--- /dev/null
+++ b/server/typings/models/account/avatar.ts
@@ -0,0 +1,11 @@
1import { AvatarModel } from '../../../models/avatar/avatar'
2import { FunctionProperties } from '@server/typings/utils'
3
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/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..78b4948ce 100644
--- a/server/typings/models/index.d.ts
+++ b/server/typings/models/index.d.ts
@@ -1 +1,5 @@
1export * from './actor' 1export * from './account'
2export * from './oauth'
3export * from './server'
4export * from './user'
5export * from './video'
diff --git a/server/typings/models/oauth/index.d.ts b/server/typings/models/oauth/index.d.ts
new file mode 100644
index 000000000..36b7ea8ca
--- /dev/null
+++ b/server/typings/models/oauth/index.d.ts
@@ -0,0 +1,2 @@
1export * from './oauth-client'
2export * from './oauth-token'
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..af3412925
--- /dev/null
+++ b/server/typings/models/oauth/oauth-token.ts
@@ -0,0 +1,13 @@
1import { OAuthTokenModel } from '@server/models/oauth/oauth-token'
2import { PickWith } from '@server/typings/utils'
3import { MUserAccountUrl } from '@server/typings/models'
4
5type Use<K extends keyof OAuthTokenModel, M> = PickWith<OAuthTokenModel, K, M>
6
7// ############################################################################
8
9export type MOAuthToken = Omit<OAuthTokenModel, 'User' | 'OAuthClients'>
10
11export type MOAuthTokenUser = MOAuthToken &
12 Use<'User', MUserAccountUrl> &
13 { 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..94674c318
--- /dev/null
+++ b/server/typings/models/server/plugin.ts
@@ -0,0 +1,10 @@
1import { PluginModel } from '@server/models/server/plugin'
2
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
new file mode 100644
index 000000000..c81f604f5
--- /dev/null
+++ b/server/typings/models/server/server-blocklist.ts
@@ -0,0 +1,23 @@
1import { ServerBlocklistModel } from '@server/models/server/server-blocklist'
2import { PickWith } from '@server/typings/utils'
3import { MAccountDefault, MAccountFormattable, MServer, MServerFormattable } from '@server/typings/models'
4
5type Use<K extends keyof ServerBlocklistModel, M> = PickWith<ServerBlocklistModel, K, M>
6
7// ############################################################################
8
9export type MServerBlocklist = Omit<ServerBlocklistModel, 'ByAccount' | 'BlockedServer'>
10
11// ############################################################################
12
13export type MServerBlocklistAccountServer = MServerBlocklist &
14 Use<'ByAccount', MAccountDefault> &
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
new file mode 100644
index 000000000..190cc0c28
--- /dev/null
+++ b/server/typings/models/server/server.ts
@@ -0,0 +1,24 @@
1import { ServerModel } from '../../../models/server/server'
2import { FunctionProperties, PickWith } from '../../utils'
3import { MAccountBlocklistId } from '../account'
4
5type Use<K extends keyof ServerModel, M> = PickWith<ServerModel, K, M>
6
7// ############################################################################
8
9export type MServer = Omit<ServerModel, 'Actors' | 'BlockedByAccounts'>
10
11// ############################################################################
12
13export type MServerHost = Pick<MServer, 'host'>
14export type MServerRedundancyAllowed = Pick<MServer, 'redundancyAllowed'>
15
16export type MServerHostBlocks = MServerHost &
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/index.d.ts b/server/typings/models/user/index.d.ts
new file mode 100644
index 000000000..6657b2128
--- /dev/null
+++ b/server/typings/models/user/index.d.ts
@@ -0,0 +1,4 @@
1export * from './user'
2export * from './user-notification'
3export * from './user-notification-setting'
4export * 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..c674add1b
--- /dev/null
+++ b/server/typings/models/user/user-notification-setting.ts
@@ -0,0 +1,9 @@
1import { UserNotificationSettingModel } from '@server/models/account/user-notification-setting'
2
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-notification.ts b/server/typings/models/user/user-notification.ts
new file mode 100644
index 000000000..f9daf5eb2
--- /dev/null
+++ b/server/typings/models/user/user-notification.ts
@@ -0,0 +1,77 @@
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
15type Use<K extends keyof UserNotificationModel, M> = PickWith<UserNotificationModel, K, M>
16
17// ############################################################################
18
19export namespace UserNotificationIncludes {
20 export type VideoInclude = Pick<VideoModel, 'id' | 'uuid' | 'name'>
21 export type VideoIncludeChannel = VideoInclude &
22 PickWith<VideoModel, 'VideoChannel', VideoChannelIncludeActor>
23
24 export type ActorInclude = Pick<ActorModel, 'preferredUsername' | 'getHost'> &
25 PickWith<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>> &
26 PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>>
27
28 export type VideoChannelInclude = Pick<VideoChannelModel, 'id' | 'name' | 'getDisplayName'>
29 export type VideoChannelIncludeActor = VideoChannelInclude &
30 PickWith<VideoChannelModel, 'Actor', ActorInclude>
31
32 export type AccountInclude = Pick<AccountModel, 'id' | 'name' | 'getDisplayName'>
33 export type AccountIncludeActor = AccountInclude &
34 PickWith<AccountModel, 'Actor', ActorInclude>
35
36 export type VideoCommentInclude = Pick<VideoCommentModel, 'id' | 'originCommentId' | 'getThreadId'> &
37 PickWith<VideoCommentModel, 'Account', AccountIncludeActor> &
38 PickWith<VideoCommentModel, 'Video', VideoInclude>
39
40 export type VideoAbuseInclude = Pick<VideoAbuseModel, 'id'> &
41 PickWith<VideoAbuseModel, 'Video', VideoInclude>
42
43 export type VideoBlacklistInclude = Pick<VideoBlacklistModel, 'id'> &
44 PickWith<VideoAbuseModel, 'Video', VideoInclude>
45
46 export type VideoImportInclude = Pick<VideoImportModel, 'id' | 'magnetUri' | 'targetUrl' | 'torrentName'> &
47 PickWith<VideoImportModel, 'Video', VideoInclude>
48
49 export type ActorFollower = Pick<ActorModel, 'preferredUsername' | 'getHost'> &
50 PickWith<ActorModel, 'Account', AccountInclude> &
51 PickWith<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>> &
52 PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>>
53
54 export type ActorFollowing = Pick<ActorModel, 'preferredUsername'> &
55 PickWith<ActorModel, 'VideoChannel', VideoChannelInclude> &
56 PickWith<ActorModel, 'Account', AccountInclude>
57
58 export type ActorFollowInclude = Pick<ActorFollowModel, 'id' | 'state'> &
59 PickWith<ActorFollowModel, 'ActorFollower', ActorFollower> &
60 PickWith<ActorFollowModel, 'ActorFollowing', ActorFollowing>
61}
62
63// ############################################################################
64
65export type MUserNotification = Omit<UserNotificationModel, 'User' | 'Video' | 'Comment' | 'VideoAbuse' | 'VideoBlacklist' |
66 'VideoImport' | 'Account' | 'ActorFollow'>
67
68// ############################################################################
69
70export type UserNotificationModelForApi = MUserNotification &
71 Use<'Video', UserNotificationIncludes.VideoIncludeChannel> &
72 Use<'Comment', UserNotificationIncludes.VideoCommentInclude> &
73 Use<'VideoAbuse', UserNotificationIncludes.VideoAbuseInclude> &
74 Use<'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> &
75 Use<'VideoImport', UserNotificationIncludes.VideoImportInclude> &
76 Use<'ActorFollow', UserNotificationIncludes.ActorFollowInclude> &
77 Use<'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..52d6d4a05
--- /dev/null
+++ b/server/typings/models/user/user.ts
@@ -0,0 +1,70 @@
1import { UserModel } from '../../../models/account/user'
2import { PickWith, PickWithOpt } from '../../utils'
3import {
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'
15
16type Use<K extends keyof UserModel, M> = PickWith<UserModel, K, M>
17
18// ############################################################################
19
20export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoImports' | 'OAuthTokens'>
21
22// ############################################################################
23
24export type MUserQuotaUsed = MUser & { videoQuotaUsed?: number, videoQuotaUsedDaily?: number }
25export type MUserId = Pick<UserModel, 'id'>
26
27// ############################################################################
28
29// With account
30
31export type MUserAccountId = MUser &
32 Use<'Account', MAccountId>
33
34export type MUserAccountUrl = MUser &
35 Use<'Account', MAccountUrl & MAccountIdActorId>
36
37export type MUserAccount = MUser &
38 Use<'Account', MAccount>
39
40export type MUserAccountDefault = MUser &
41 Use<'Account', MAccountDefault>
42
43// With channel
44
45export type MUserNotifSettingChannelDefault = MUser &
46 Use<'NotificationSetting', MNotificationSetting> &
47 Use<'Account', MAccountDefaultChannelDefault>
48
49// With notification settings
50
51export type MUserWithNotificationSetting = MUser &
52 Use<'NotificationSetting', MNotificationSetting>
53
54export type MUserNotifSettingAccount = MUser &
55 Use<'NotificationSetting', MNotificationSetting> &
56 Use<'Account', MAccount>
57
58// Default scope
59
60export type MUserDefault = MUser &
61 Use<'NotificationSetting', MNotificationSetting> &
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-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..bd69c8a4b
--- /dev/null
+++ b/server/typings/models/video/index.d.ts
@@ -0,0 +1,18 @@
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-change-ownership'
9export * from './video-channels'
10export * from './video-comment'
11export * from './video-file'
12export * from './video-import'
13export * from './video-playlist'
14export * from './video-playlist-element'
15export * from './video-rate'
16export * from './video-redundancy'
17export * from './video-share'
18export * 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..ada9af06e
--- /dev/null
+++ b/server/typings/models/video/schedule-video-update.ts
@@ -0,0 +1,9 @@
1import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update'
2
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/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..e38c3f586
--- /dev/null
+++ b/server/typings/models/video/video-abuse.ts
@@ -0,0 +1,31 @@
1import { VideoAbuseModel } from '../../../models/video/video-abuse'
2import { PickWith } from '../../utils'
3import { MVideo } from './video'
4import { MAccountDefault, MAccountFormattable } from '../account'
5
6type Use<K extends keyof VideoAbuseModel, M> = PickWith<VideoAbuseModel, K, M>
7
8// ############################################################################
9
10export type MVideoAbuse = Omit<VideoAbuseModel, 'Account' | 'Video' | 'toActivityPubObject'>
11
12// ############################################################################
13
14export type MVideoAbuseId = Pick<VideoAbuseModel, 'id'>
15
16export type MVideoAbuseVideo = MVideoAbuse &
17 Pick<VideoAbuseModel, 'toActivityPubObject'> &
18 Use<'Video', MVideo>
19
20export type MVideoAbuseAccountVideo = MVideoAbuse &
21 Pick<VideoAbuseModel, 'toActivityPubObject'> &
22 Use<'Video', MVideo> &
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
new file mode 100644
index 000000000..1dedfa37f
--- /dev/null
+++ b/server/typings/models/video/video-blacklist.ts
@@ -0,0 +1,24 @@
1import { VideoBlacklistModel } from '../../../models/video/video-blacklist'
2import { PickWith } from '@server/typings/utils'
3import { MVideo, MVideoFormattable } from '@server/typings/models'
4
5type Use<K extends keyof VideoBlacklistModel, M> = PickWith<VideoBlacklistModel, K, M>
6
7// ############################################################################
8
9export type MVideoBlacklist = Omit<VideoBlacklistModel, 'Video'>
10
11export type MVideoBlacklistLight = Pick<MVideoBlacklist, 'id' | 'reason' | 'unfederated'>
12export type MVideoBlacklistUnfederated = Pick<MVideoBlacklist, 'unfederated'>
13
14// ############################################################################
15
16export type MVideoBlacklistVideo = MVideoBlacklist &
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
new file mode 100644
index 000000000..7cb2a2ad3
--- /dev/null
+++ b/server/typings/models/video/video-caption.ts
@@ -0,0 +1,24 @@
1import { VideoCaptionModel } from '../../../models/video/video-caption'
2import { FunctionProperties, PickWith } from '@server/typings/utils'
3import { MVideo, MVideoUUID } from '@server/typings/models'
4
5type Use<K extends keyof VideoCaptionModel, M> = PickWith<VideoCaptionModel, K, M>
6
7// ############################################################################
8
9export type MVideoCaption = Omit<VideoCaptionModel, 'Video'>
10
11// ############################################################################
12
13export type MVideoCaptionLanguage = Pick<MVideoCaption, 'language'>
14
15export type MVideoCaptionVideo = MVideoCaption &
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
new file mode 100644
index 000000000..72634cdb2
--- /dev/null
+++ b/server/typings/models/video/video-change-ownership.ts
@@ -0,0 +1,23 @@
1import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership'
2import { PickWith } from '@server/typings/utils'
3import { MAccountDefault, MAccountFormattable, MVideo, MVideoWithFileThumbnail } from '@server/typings/models'
4
5type Use<K extends keyof VideoChangeOwnershipModel, M> = PickWith<VideoChangeOwnershipModel, K, M>
6
7// ############################################################################
8
9export type MVideoChangeOwnership = Omit<VideoChangeOwnershipModel, 'Initiator' | 'NextOwner' | 'Video'>
10
11export type MVideoChangeOwnershipFull = MVideoChangeOwnership &
12 Use<'Initiator', MAccountDefault> &
13 Use<'NextOwner', MAccountDefault> &
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
new file mode 100644
index 000000000..292d0ac95
--- /dev/null
+++ b/server/typings/models/video/video-channels.ts
@@ -0,0 +1,126 @@
1import { FunctionProperties, PickWith, PickWithOpt } from '../../utils'
2import { VideoChannelModel } from '../../../models/video/video-channel'
3import {
4 MAccountActor,
5 MAccountAPI,
6 MAccountDefault,
7 MAccountFormattable,
8 MAccountLight,
9 MAccountSummaryBlocks,
10 MAccountSummaryFormattable,
11 MAccountUrl,
12 MAccountUserId,
13 MActor,
14 MActorAccountChannelId,
15 MActorAP,
16 MActorAPI,
17 MActorDefault,
18 MActorDefaultLight,
19 MActorFormattable,
20 MActorLight,
21 MActorSummary,
22 MActorSummaryFormattable, MActorUrl
23} from '../account'
24import { MVideo } from './video'
25
26type Use<K extends keyof VideoChannelModel, M> = PickWith<VideoChannelModel, K, M>
27
28// ############################################################################
29
30export type MChannel = Omit<VideoChannelModel, 'Actor' | 'Account' | 'Videos' | 'VideoPlaylists'>
31
32// ############################################################################
33
34export type MChannelId = Pick<MChannel, 'id'>
35
36// ############################################################################
37
38export type MChannelIdActor = MChannelId &
39 Use<'Actor', MActorAccountChannelId>
40
41export type MChannelUserId = Pick<MChannel, 'accountId'> &
42 Use<'Account', MAccountUserId>
43
44export type MChannelActor = MChannel &
45 Use<'Actor', MActor>
46
47export type MChannelUrl = Use<'Actor', MActorUrl>
48
49// Default scope
50export type MChannelDefault = MChannel &
51 Use<'Actor', MActorDefault>
52
53// ############################################################################
54
55// Not all association attributes
56
57export type MChannelLight = MChannel &
58 Use<'Actor', MActorDefaultLight>
59
60export type MChannelActorLight = MChannel &
61 Use<'Actor', MActorLight>
62
63export type MChannelAccountLight = MChannel &
64 Use<'Actor', MActorDefaultLight> &
65 Use<'Account', MAccountLight>
66
67// ############################################################################
68
69// Account associations
70
71export type MChannelAccountActor = MChannel &
72 Use<'Account', MAccountActor>
73
74export type MChannelAccountDefault = MChannel &
75 Use<'Actor', MActorDefault> &
76 Use<'Account', MAccountDefault>
77
78export type MChannelActorAccountActor = MChannel &
79 Use<'Account', MAccountActor> &
80 Use<'Actor', MActor>
81
82// ############################################################################
83
84// Videos associations
85export type MChannelVideos = MChannel &
86 Use<'Videos', MVideo[]>
87
88export type MChannelActorAccountDefaultVideos = MChannel &
89 Use<'Actor', MActorDefault> &
90 Use<'Account', MAccountDefault> &
91 Use<'Videos', MVideo[]>
92
93// ############################################################################
94
95// For API
96
97export type MChannelSummary = FunctionProperties<MChannel> &
98 Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> &
99 Use<'Actor', MActorSummary>
100
101export type MChannelSummaryAccount = MChannelSummary &
102 Use<'Account', MAccountSummaryBlocks>
103
104export type MChannelAPI = MChannel &
105 Use<'Actor', MActorAPI> &
106 Use<'Account', MAccountAPI>
107
108// ############################################################################
109
110// Format for API or AP object
111
112export type MChannelSummaryFormattable = FunctionProperties<MChannel> &
113 Pick<MChannel, 'id' | 'name'> &
114 Use<'Actor', MActorSummaryFormattable>
115
116export type MChannelAccountSummaryFormattable = MChannelSummaryFormattable &
117 Use<'Account', MAccountSummaryFormattable>
118
119export type MChannelFormattable = FunctionProperties<MChannel> &
120 Pick<MChannel, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'support'> &
121 Use<'Actor', MActorFormattable> &
122 PickWithOpt<VideoChannelModel, 'Account', MAccountFormattable>
123
124export type MChannelAP = Pick<MChannel, 'name' | 'description' | 'support'> &
125 Use<'Actor', MActorAP> &
126 Use<'Account', MAccountUrl>
diff --git a/server/typings/models/video/video-comment.ts b/server/typings/models/video/video-comment.ts
new file mode 100644
index 000000000..4fd1c29e8
--- /dev/null
+++ b/server/typings/models/video/video-comment.ts
@@ -0,0 +1,57 @@
1import { VideoCommentModel } from '../../../models/video/video-comment'
2import { PickWith, PickWithOpt } from '../../utils'
3import { MAccountDefault, MAccountFormattable, MAccountUrl, MActorUrl } from '../account'
4import { MVideoAccountLight, MVideoFeed, MVideoIdUrl, MVideoUrl } from './video'
5
6type Use<K extends keyof VideoCommentModel, M> = PickWith<VideoCommentModel, K, M>
7
8// ############################################################################
9
10export type MComment = Omit<VideoCommentModel, 'OriginVideoComment' | 'InReplyToVideoComment' | 'Video' | 'Account'>
11export type MCommentTotalReplies = MComment & { totalReplies?: number }
12export type MCommentId = Pick<MComment, 'id'>
13export type MCommentUrl = Pick<MComment, 'url'>
14
15// ############################################################################
16
17export type MCommentOwner = MComment &
18 Use<'Account', MAccountDefault>
19
20export type MCommentVideo = MComment &
21 Use<'Video', MVideoAccountLight>
22
23export type MCommentReply = MComment &
24 Use<'InReplyToVideoComment', MComment>
25
26export type MCommentOwnerVideo = MComment &
27 Use<'Account', MAccountDefault> &
28 Use<'Video', MVideoAccountLight>
29
30export type MCommentOwnerVideoReply = MComment &
31 Use<'Account', MAccountDefault> &
32 Use<'Video', MVideoAccountLight> &
33 Use<'InReplyToVideoComment', MComment>
34
35export type MCommentOwnerReplyVideoLight = MComment &
36 Use<'Account', MAccountDefault> &
37 Use<'InReplyToVideoComment', MComment> &
38 Use<'Video', MVideoIdUrl>
39
40export type MCommentOwnerVideoFeed = MCommentOwner &
41 Use<'Video', MVideoFeed>
42
43// ############################################################################
44
45export type MCommentAPI = MComment & { totalReplies: number }
46
47// ############################################################################
48
49// Format for API or AP object
50
51export type MCommentFormattable = MCommentTotalReplies &
52 Use<'Account', MAccountFormattable>
53
54export type MCommentAP = MComment &
55 Use<'Account', MAccountUrl> &
56 PickWithOpt<VideoCommentModel, 'Video', MVideoUrl> &
57 PickWithOpt<VideoCommentModel, 'InReplyToVideoComment', MCommentUrl>
diff --git a/server/typings/models/video/video-file.ts b/server/typings/models/video/video-file.ts
new file mode 100644
index 000000000..484351a8d
--- /dev/null
+++ b/server/typings/models/video/video-file.ts
@@ -0,0 +1,19 @@
1import { VideoFileModel } from '../../../models/video/video-file'
2import { PickWith, PickWithOpt } from '../../utils'
3import { MVideo, MVideoUUID } from './video'
4import { MVideoRedundancyFileUrl } from './video-redundancy'
5
6type Use<K extends keyof VideoFileModel, M> = PickWith<VideoFileModel, K, M>
7
8// ############################################################################
9
10export type MVideoFile = Omit<VideoFileModel, 'Video' | 'RedundancyVideos'>
11
12export type MVideoFileVideo = MVideoFile &
13 Use<'Video', MVideo>
14
15export type MVideoFileVideoUUID = MVideoFile &
16 Use<'Video', MVideoUUID>
17
18export type MVideoFileRedundanciesOpt = MVideoFile &
19 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..c6a1c5b66
--- /dev/null
+++ b/server/typings/models/video/video-import.ts
@@ -0,0 +1,31 @@
1import { VideoImportModel } from '@server/models/video/video-import'
2import { PickWith, PickWithOpt } from '@server/typings/utils'
3import { MUser, MVideo, MVideoAccountLight, MVideoFormattable, MVideoTag, MVideoThumbnail, MVideoWithFile } from '@server/typings/models'
4
5type Use<K extends keyof VideoImportModel, M> = PickWith<VideoImportModel, K, M>
6
7// ############################################################################
8
9export type MVideoImport = Omit<VideoImportModel, 'User' | 'Video'>
10
11export type MVideoImportVideo = MVideoImport &
12 Use<'Video', MVideo>
13
14// ############################################################################
15
16type VideoAssociation = MVideoTag & MVideoAccountLight & MVideoThumbnail
17
18export type MVideoImportDefault = MVideoImport &
19 Use<'User', MUser> &
20 Use<'Video', VideoAssociation>
21
22export type MVideoImportDefaultFiles = MVideoImport &
23 Use<'User', MUser> &
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
new file mode 100644
index 000000000..7b1b993ce
--- /dev/null
+++ b/server/typings/models/video/video-playlist-element.ts
@@ -0,0 +1,34 @@
1import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element'
2import { PickWith } from '@server/typings/utils'
3import { MVideoFormattable, MVideoPlaylistPrivacy, MVideoThumbnail, MVideoUrl } from '@server/typings/models'
4
5type Use<K extends keyof VideoPlaylistElementModel, M> = PickWith<VideoPlaylistElementModel, K, M>
6
7// ############################################################################
8
9export type MVideoPlaylistElement = Omit<VideoPlaylistElementModel, 'VideoPlaylist' | 'Video'>
10
11// ############################################################################
12
13export type MVideoPlaylistElementId = Pick<MVideoPlaylistElement, 'id'>
14
15export type MVideoPlaylistElementLight = Pick<MVideoPlaylistElement, 'id' | 'videoId' | 'startTimestamp' | 'stopTimestamp'>
16
17// ############################################################################
18
19export type MVideoPlaylistVideoThumbnail = MVideoPlaylistElement &
20 Use<'Video', MVideoThumbnail>
21
22export type MVideoPlaylistElementVideoUrlPlaylistPrivacy = MVideoPlaylistElement &
23 Use<'Video', MVideoUrl> &
24 Use<'VideoPlaylist', MVideoPlaylistPrivacy>
25
26// ############################################################################
27
28// Format for API or AP object
29
30export type MVideoPlaylistElementFormattable = MVideoPlaylistElement &
31 Use<'Video', MVideoFormattable>
32
33export type MVideoPlaylistElementAP = MVideoPlaylistElement &
34 Use<'Video', MVideoUrl>
diff --git a/server/typings/models/video/video-playlist.ts b/server/typings/models/video/video-playlist.ts
new file mode 100644
index 000000000..a40c7aca9
--- /dev/null
+++ b/server/typings/models/video/video-playlist.ts
@@ -0,0 +1,92 @@
1import { VideoPlaylistModel } from '../../../models/video/video-playlist'
2import { PickWith } from '../../utils'
3import { MAccount, MAccountDefault, MAccountSummary, MAccountSummaryFormattable } from '../account'
4import { MThumbnail } from './thumbnail'
5import { MChannelDefault, MChannelSummary, MChannelSummaryFormattable, MChannelUrl } from './video-channels'
6import { MVideoPlaylistElementLight } from '@server/typings/models/video/video-playlist-element'
7
8type Use<K extends keyof VideoPlaylistModel, M> = PickWith<VideoPlaylistModel, K, M>
9
10// ############################################################################
11
12export type MVideoPlaylist = Omit<VideoPlaylistModel, 'OwnerAccount' | 'VideoChannel' | 'VideoPlaylistElements' | 'Thumbnail'>
13
14// ############################################################################
15
16export type MVideoPlaylistId = Pick<MVideoPlaylist, 'id'>
17export type MVideoPlaylistPrivacy = Pick<MVideoPlaylist, 'privacy'>
18export type MVideoPlaylistUUID = Pick<MVideoPlaylist, 'uuid'>
19export type MVideoPlaylistVideosLength = MVideoPlaylist & { videosLength?: number }
20
21// ############################################################################
22
23// With elements
24
25export type MVideoPlaylistWithElements = MVideoPlaylist &
26 Use<'VideoPlaylistElements', MVideoPlaylistElementLight[]>
27
28export type MVideoPlaylistIdWithElements = MVideoPlaylistId &
29 Use<'VideoPlaylistElements', MVideoPlaylistElementLight[]>
30
31// ############################################################################
32
33// With account
34
35export type MVideoPlaylistOwner = MVideoPlaylist &
36 Use<'OwnerAccount', MAccount>
37
38export type MVideoPlaylistOwnerDefault = MVideoPlaylist &
39 Use<'OwnerAccount', MAccountDefault>
40
41// ############################################################################
42
43// With thumbnail
44
45export type MVideoPlaylistThumbnail = MVideoPlaylist &
46 Use<'Thumbnail', MThumbnail>
47
48export type MVideoPlaylistAccountThumbnail = MVideoPlaylist &
49 Use<'OwnerAccount', MAccountDefault> &
50 Use<'Thumbnail', MThumbnail>
51
52// ############################################################################
53
54// With channel
55
56export type MVideoPlaylistAccountChannelDefault = MVideoPlaylist &
57 Use<'OwnerAccount', MAccountDefault> &
58 Use<'VideoChannel', MChannelDefault>
59
60// ############################################################################
61
62// With all associations
63
64export type MVideoPlaylistFull = MVideoPlaylist &
65 Use<'OwnerAccount', MAccountDefault> &
66 Use<'VideoChannel', MChannelDefault> &
67 Use<'Thumbnail', MThumbnail>
68
69// ############################################################################
70
71// For API
72
73export type MVideoPlaylistAccountChannelSummary = MVideoPlaylist &
74 Use<'OwnerAccount', MAccountSummary> &
75 Use<'VideoChannel', MChannelSummary>
76
77export type MVideoPlaylistFullSummary = MVideoPlaylist &
78 Use<'Thumbnail', MThumbnail> &
79 Use<'OwnerAccount', MAccountSummary> &
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>
89
90export type MVideoPlaylistAP = MVideoPlaylist &
91 Use<'Thumbnail', MThumbnail> &
92 Use<'VideoChannel', MChannelUrl>
diff --git a/server/typings/models/video/video-rate.ts b/server/typings/models/video/video-rate.ts
new file mode 100644
index 000000000..2ff8a625b
--- /dev/null
+++ b/server/typings/models/video/video-rate.ts
@@ -0,0 +1,23 @@
1import { AccountVideoRateModel } from '@server/models/account/account-video-rate'
2import { PickWith } from '@server/typings/utils'
3import { MAccountAudience, MAccountUrl, MVideo, MVideoFormattable } from '..'
4
5type Use<K extends keyof AccountVideoRateModel, M> = PickWith<AccountVideoRateModel, K, M>
6
7// ############################################################################
8
9export type MAccountVideoRate = Omit<AccountVideoRateModel, 'Video' | 'Account'>
10
11export type MAccountVideoRateAccountUrl = MAccountVideoRate &
12 Use<'Account', MAccountUrl>
13
14export type MAccountVideoRateAccountVideo = MAccountVideoRate &
15 Use<'Account', MAccountAudience> &
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-redundancy.ts b/server/typings/models/video/video-redundancy.ts
new file mode 100644
index 000000000..f3846afd7
--- /dev/null
+++ b/server/typings/models/video/video-redundancy.ts
@@ -0,0 +1,38 @@
1import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy'
2import { PickWith, PickWithOpt } from '@server/typings/utils'
3import { MStreamingPlaylistVideo, MVideoFile, MVideoFileVideo, MVideoUrl } from '@server/typings/models'
4import { VideoStreamingPlaylist } from '../../../../shared/models/videos/video-streaming-playlist.model'
5import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist'
6import { VideoFile } from '../../../../shared/models/videos'
7import { VideoFileModel } from '@server/models/video/video-file'
8
9type Use<K extends keyof VideoRedundancyModel, M> = PickWith<VideoRedundancyModel, K, M>
10
11// ############################################################################
12
13export type MVideoRedundancy = Omit<VideoRedundancyModel, 'VideoFile' | 'VideoStreamingPlaylist' | 'Actor'>
14
15export type MVideoRedundancyFileUrl = Pick<MVideoRedundancy, 'fileUrl'>
16
17// ############################################################################
18
19export type MVideoRedundancyFile = MVideoRedundancy &
20 Use<'VideoFile', MVideoFile>
21
22export type MVideoRedundancyFileVideo = MVideoRedundancy &
23 Use<'VideoFile', MVideoFileVideo>
24
25export type MVideoRedundancyStreamingPlaylistVideo = MVideoRedundancy &
26 Use<'VideoStreamingPlaylist', MStreamingPlaylistVideo>
27
28export type MVideoRedundancyVideo = MVideoRedundancy &
29 Use<'VideoFile', MVideoFileVideo> &
30 Use<'VideoStreamingPlaylist', MStreamingPlaylistVideo>
31
32// ############################################################################
33
34// Format for API or AP object
35
36export type MVideoRedundancyAP = MVideoRedundancy &
37 PickWithOpt<VideoRedundancyModel, 'VideoFile', MVideoFile & PickWith<VideoFileModel, 'Video', MVideoUrl>> &
38 PickWithOpt<VideoRedundancyModel, 'VideoStreamingPlaylist', PickWith<VideoStreamingPlaylistModel, 'Video', MVideoUrl>>
diff --git a/server/typings/models/video/video-share.ts b/server/typings/models/video/video-share.ts
new file mode 100644
index 000000000..a7a90beeb
--- /dev/null
+++ b/server/typings/models/video/video-share.ts
@@ -0,0 +1,17 @@
1import { VideoShareModel } from '../../../models/video/video-share'
2import { PickWith } from '../../utils'
3import { MActorDefault } from '../account'
4import { MVideo } from './video'
5
6type Use<K extends keyof VideoShareModel, M> = PickWith<VideoShareModel, K, M>
7
8// ############################################################################
9
10export type MVideoShare = Omit<VideoShareModel, 'Actor' | 'Video'>
11
12export type MVideoShareActor = MVideoShare &
13 Use<'Actor', MActorDefault>
14
15export type MVideoShareFull = MVideoShare &
16 Use<'Actor', MActorDefault> &
17 Use<'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..79696bcff
--- /dev/null
+++ b/server/typings/models/video/video-streaming-playlist.ts
@@ -0,0 +1,19 @@
1import { VideoStreamingPlaylistModel } from '../../../models/video/video-streaming-playlist'
2import { PickWith, PickWithOpt } from '../../utils'
3import { MVideoRedundancyFileUrl } from './video-redundancy'
4import { MVideo, MVideoUrl } from '@server/typings/models'
5
6type Use<K extends keyof VideoStreamingPlaylistModel, M> = PickWith<VideoStreamingPlaylistModel, K, M>
7
8// ############################################################################
9
10export type MStreamingPlaylist = Omit<VideoStreamingPlaylistModel, 'Video' | 'RedundancyVideos'>
11
12export type MStreamingPlaylistVideo = MStreamingPlaylist &
13 Use<'Video', MVideo>
14
15export type MStreamingPlaylistRedundancies = MStreamingPlaylist &
16 Use<'RedundancyVideos', MVideoRedundancyFileUrl[]>
17
18export type MStreamingPlaylistRedundanciesOpt = MStreamingPlaylist &
19 PickWithOpt<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..be32d4617
--- /dev/null
+++ b/server/typings/models/video/video.ts
@@ -0,0 +1,169 @@
1import { VideoModel } from '../../../models/video/video'
2import { PickWith, PickWithOpt } from '../../utils'
3import {
4 MChannelAccountDefault,
5 MChannelAccountLight,
6 MChannelAccountSummaryFormattable,
7 MChannelActor,
8 MChannelFormattable,
9 MChannelUserId
10} from './video-channels'
11import { MTag } from './tag'
12import { MVideoCaptionLanguage } from './video-caption'
13import { MStreamingPlaylist, MStreamingPlaylistRedundancies, MStreamingPlaylistRedundanciesOpt } from './video-streaming-playlist'
14import { MVideoFile, MVideoFileRedundanciesOpt } from './video-file'
15import { MThumbnail } from './thumbnail'
16import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist'
17import { MScheduleVideoUpdate } from './schedule-video-update'
18import { MUserVideoHistoryTime } from '../user/user-video-history'
19
20type Use<K extends keyof VideoModel, M> = PickWith<VideoModel, K, M>
21
22// ############################################################################
23
24export type MVideo = Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' |
25 'VideoFiles' | 'VideoStreamingPlaylists' | 'VideoShares' | 'AccountVideoRates' | 'VideoComments' | 'VideoViews' | 'UserVideoHistories' |
26 'ScheduleVideoUpdate' | 'VideoBlacklist' | 'VideoImport' | 'VideoCaptions'>
27
28// ############################################################################
29
30export type MVideoId = Pick<MVideo, 'id'>
31export type MVideoUrl = Pick<MVideo, 'url'>
32export type MVideoUUID = Pick<MVideo, 'uuid'>
33
34export type MVideoIdUrl = MVideoId & MVideoUrl
35export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'>
36
37// ############################################################################
38
39// Video raw associations: schedules, video files, tags, thumbnails, captions, streaming playlists
40
41// "With" to not confuse with the VideoFile model
42export type MVideoWithFile = MVideo &
43 Use<'VideoFiles', MVideoFile[]>
44
45export type MVideoThumbnail = MVideo &
46 Use<'Thumbnails', MThumbnail[]>
47
48export type MVideoIdThumbnail = MVideoId &
49 Use<'Thumbnails', MThumbnail[]>
50
51export type MVideoWithFileThumbnail = MVideo &
52 Use<'VideoFiles', MVideoFile[]> &
53 Use<'Thumbnails', MThumbnail[]>
54
55export type MVideoTag = MVideo &
56 Use<'Tags', MTag[]>
57
58export type MVideoWithSchedule = MVideo &
59 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate>
60
61export type MVideoWithCaptions = MVideo &
62 Use<'VideoCaptions', MVideoCaptionLanguage[]>
63
64export type MVideoWithStreamingPlaylist = MVideo &
65 Use<'VideoStreamingPlaylists', MStreamingPlaylist[]>
66
67// ############################################################################
68
69// Associations with not all their attributes
70
71export type MVideoUserHistory = MVideo &
72 Use<'UserVideoHistories', MUserVideoHistoryTime[]>
73
74export type MVideoWithBlacklistLight = MVideo &
75 Use<'VideoBlacklist', MVideoBlacklistLight>
76
77export type MVideoAccountLight = MVideo &
78 Use<'VideoChannel', MChannelAccountLight>
79
80export type MVideoWithRights = MVideo &
81 Use<'VideoBlacklist', MVideoBlacklistLight> &
82 Use<'Thumbnails', MThumbnail[]> &
83 Use<'VideoChannel', MChannelUserId>
84
85// ############################################################################
86
87// All files with some additional associations
88
89export type MVideoWithAllFiles = MVideo &
90 Use<'VideoFiles', MVideoFile[]> &
91 Use<'Thumbnails', MThumbnail[]> &
92 Use<'VideoStreamingPlaylists', MStreamingPlaylist[]>
93
94export type MVideoAccountLightBlacklistAllFiles = MVideo &
95 Use<'VideoFiles', MVideoFile[]> &
96 Use<'Thumbnails', MThumbnail[]> &
97 Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> &
98 Use<'VideoChannel', MChannelAccountLight> &
99 Use<'VideoBlacklist', MVideoBlacklistLight>
100
101// ############################################################################
102
103// With account
104
105export type MVideoAccountDefault = MVideo &
106 Use<'VideoChannel', MChannelAccountDefault>
107
108export type MVideoThumbnailAccountDefault = MVideo &
109 Use<'Thumbnails', MThumbnail[]> &
110 Use<'VideoChannel', MChannelAccountDefault>
111
112export type MVideoWithChannelActor = MVideo &
113 Use<'VideoChannel', MChannelActor>
114
115export type MVideoFullLight = MVideo &
116 Use<'Thumbnails', MThumbnail[]> &
117 Use<'VideoBlacklist', MVideoBlacklistLight> &
118 Use<'Tags', MTag[]> &
119 Use<'VideoChannel', MChannelAccountLight> &
120 Use<'UserVideoHistories', MUserVideoHistoryTime[]> &
121 Use<'VideoFiles', MVideoFile[]> &
122 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
123 Use<'VideoStreamingPlaylists', MStreamingPlaylist[]>
124
125// ############################################################################
126
127// API
128
129export type MVideoAP = MVideo &
130 Use<'Tags', MTag[]> &
131 Use<'VideoChannel', MChannelAccountLight> &
132 Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> &
133 Use<'VideoCaptions', MVideoCaptionLanguage[]> &
134 Use<'VideoBlacklist', MVideoBlacklistUnfederated> &
135 Use<'VideoFiles', MVideoFileRedundanciesOpt[]>
136
137export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'>
138
139export type MVideoDetails = MVideo &
140 Use<'VideoBlacklist', MVideoBlacklistLight> &
141 Use<'Tags', MTag[]> &
142 Use<'VideoChannel', MChannelAccountLight> &
143 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
144 Use<'Thumbnails', MThumbnail[]> &
145 Use<'UserVideoHistories', MUserVideoHistoryTime[]> &
146 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> &
147 Use<'VideoFiles', MVideoFileRedundanciesOpt[]>
148
149export type MVideoForUser = MVideo &
150 Use<'VideoChannel', MChannelAccountDefault> &
151 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
152 Use<'VideoBlacklist', MVideoBlacklistLight> &
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', MStreamingPlaylistRedundanciesOpt[]> &
169 Use<'VideoFiles', MVideoFileRedundanciesOpt[]>