aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/types
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-06-18 10:45:25 +0200
committerChocobozzz <me@florianbigard.com>2020-06-18 10:46:27 +0200
commit26d6bf6533023326fa017812cf31bbe20c752d36 (patch)
tree9c4e3ecdc344420190f17d429bdf05d78fae7a8c /server/types
parentd6d951ddc0c492f3261065b5dcb4df0534d252fc (diff)
downloadPeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.tar.gz
PeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.tar.zst
PeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.zip
Split types and typings
Diffstat (limited to 'server/types')
-rw-r--r--server/types/activitypub-processor.model.ts9
-rw-r--r--server/types/models/account/account-blocklist.ts27
-rw-r--r--server/types/models/account/account.ts109
-rw-r--r--server/types/models/account/actor-follow.ts70
-rw-r--r--server/types/models/account/actor.ts139
-rw-r--r--server/types/models/account/avatar.ts12
-rw-r--r--server/types/models/account/index.ts5
-rw-r--r--server/types/models/index.ts5
-rw-r--r--server/types/models/oauth/index.ts2
-rw-r--r--server/types/models/oauth/oauth-client.ts3
-rw-r--r--server/types/models/oauth/oauth-token.ts14
-rw-r--r--server/types/models/server/index.ts3
-rw-r--r--server/types/models/server/plugin.ts11
-rw-r--r--server/types/models/server/server-blocklist.ts26
-rw-r--r--server/types/models/server/server.ts26
-rw-r--r--server/types/models/user/index.ts4
-rw-r--r--server/types/models/user/user-notification-setting.ts9
-rw-r--r--server/types/models/user/user-notification.ts92
-rw-r--r--server/types/models/user/user-video-history.ts5
-rw-r--r--server/types/models/user/user.ts89
-rw-r--r--server/types/models/video/index.ts18
-rw-r--r--server/types/models/video/schedule-video-update.ts19
-rw-r--r--server/types/models/video/tag.ts3
-rw-r--r--server/types/models/video/thumbnail.ts3
-rw-r--r--server/types/models/video/video-abuse.ts35
-rw-r--r--server/types/models/video/video-blacklist.ts30
-rw-r--r--server/types/models/video/video-caption.ts27
-rw-r--r--server/types/models/video/video-change-ownership.ts26
-rw-r--r--server/types/models/video/video-channels.ts145
-rw-r--r--server/types/models/video/video-comment.ts66
-rw-r--r--server/types/models/video/video-file.ts43
-rw-r--r--server/types/models/video/video-import.ts36
-rw-r--r--server/types/models/video/video-playlist-element.ts39
-rw-r--r--server/types/models/video/video-playlist.ts104
-rw-r--r--server/types/models/video/video-rate.ts27
-rw-r--r--server/types/models/video/video-redundancy.ts43
-rw-r--r--server/types/models/video/video-share.ts19
-rw-r--r--server/types/models/video/video-streaming-playlist.ts43
-rw-r--r--server/types/models/video/video.ts211
-rw-r--r--server/types/sequelize.ts18
-rw-r--r--server/types/utils.ts24
41 files changed, 1639 insertions, 0 deletions
diff --git a/server/types/activitypub-processor.model.ts b/server/types/activitypub-processor.model.ts
new file mode 100644
index 000000000..7ed3a65b1
--- /dev/null
+++ b/server/types/activitypub-processor.model.ts
@@ -0,0 +1,9 @@
1import { Activity } from '../../shared/models/activitypub'
2import { MActorDefault, MActorSignature } from './models'
3
4export type APProcessorOptions<T extends Activity> = {
5 activity: T
6 byActor: MActorSignature
7 inboxActor?: MActorDefault
8 fromFetch?: boolean
9}
diff --git a/server/types/models/account/account-blocklist.ts b/server/types/models/account/account-blocklist.ts
new file mode 100644
index 000000000..0d8bf11bd
--- /dev/null
+++ b/server/types/models/account/account-blocklist.ts
@@ -0,0 +1,27 @@
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 =
16 MAccountBlocklist &
17 Use<'ByAccount', MAccountDefault> &
18 Use<'BlockedAccount', MAccountDefault>
19
20// ############################################################################
21
22// Format for API or AP object
23
24export type MAccountBlocklistFormattable =
25 Pick<MAccountBlocklist, 'createdAt'> &
26 Use<'ByAccount', MAccountFormattable> &
27 Use<'BlockedAccount', MAccountFormattable>
diff --git a/server/types/models/account/account.ts b/server/types/models/account/account.ts
new file mode 100644
index 000000000..7b826ee04
--- /dev/null
+++ b/server/types/models/account/account.ts
@@ -0,0 +1,109 @@
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 '../video/video-channels'
19
20type Use<K extends keyof AccountModel, M> = PickWith<AccountModel, K, M>
21
22// ############################################################################
23
24export type MAccount =
25 Omit<AccountModel, 'Actor' | 'User' | 'Application' | 'VideoChannels' | 'VideoPlaylists' |
26 'VideoComments' | 'BlockedAccounts'>
27
28// ############################################################################
29
30// Only some attributes
31export type MAccountId = Pick<MAccount, 'id'>
32export type MAccountUserId = Pick<MAccount, 'userId'>
33
34// Only some Actor attributes
35export type MAccountUrl = Use<'Actor', MActorUrl>
36export type MAccountAudience = Use<'Actor', MActorAudience>
37
38export type MAccountIdActor =
39 MAccountId &
40 Use<'Actor', MActor>
41
42export type MAccountIdActorId =
43 MAccountId &
44 Use<'Actor', MActorId>
45
46// ############################################################################
47
48// Default scope
49export type MAccountDefault =
50 MAccount &
51 Use<'Actor', MActorDefault>
52
53// Default with default association scopes
54export type MAccountDefaultChannelDefault =
55 MAccount &
56 Use<'Actor', MActorDefault> &
57 Use<'VideoChannels', MChannelDefault[]>
58
59// We don't need some actors attributes
60export type MAccountLight =
61 MAccount &
62 Use<'Actor', MActorDefaultLight>
63
64// ############################################################################
65
66// Full actor
67export type MAccountActor =
68 MAccount &
69 Use<'Actor', MActor>
70
71// Full actor with server
72export type MAccountServer =
73 MAccount &
74 Use<'Actor', MActorServer>
75
76// ############################################################################
77
78// For API
79
80export type MAccountSummary =
81 FunctionProperties<MAccount> &
82 Pick<MAccount, 'id' | 'name'> &
83 Use<'Actor', MActorSummary>
84
85export type MAccountSummaryBlocks =
86 MAccountSummary &
87 Use<'BlockedAccounts', MAccountBlocklistId[]>
88
89export type MAccountAPI =
90 MAccount &
91 Use<'Actor', MActorAPI>
92
93// ############################################################################
94
95// Format for API or AP object
96
97export type MAccountSummaryFormattable =
98 FunctionProperties<MAccount> &
99 Pick<MAccount, 'id' | 'name'> &
100 Use<'Actor', MActorSummaryFormattable>
101
102export type MAccountFormattable =
103 FunctionProperties<MAccount> &
104 Pick<MAccount, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'userId'> &
105 Use<'Actor', MActorFormattable>
106
107export type MAccountAP =
108 Pick<MAccount, 'name' | 'description'> &
109 Use<'Actor', MActorAP>
diff --git a/server/types/models/account/actor-follow.ts b/server/types/models/account/actor-follow.ts
new file mode 100644
index 000000000..5d0c03c8d
--- /dev/null
+++ b/server/types/models/account/actor-follow.ts
@@ -0,0 +1,70 @@
1import { ActorFollowModel } from '../../../models/activitypub/actor-follow'
2import {
3 MActor,
4 MActorChannelAccountActor,
5 MActorDefault,
6 MActorDefaultAccountChannel,
7 MActorFormattable,
8 MActorHost,
9 MActorUsername
10} from './actor'
11import { PickWith } from '../../utils'
12import { ActorModel } from '@server/models/activitypub/actor'
13import { MChannelDefault } from '../video/video-channels'
14
15type Use<K extends keyof ActorFollowModel, M> = PickWith<ActorFollowModel, K, M>
16
17// ############################################################################
18
19export type MActorFollow = Omit<ActorFollowModel, 'ActorFollower' | 'ActorFollowing'>
20
21// ############################################################################
22
23export type MActorFollowFollowingHost =
24 MActorFollow &
25 Use<'ActorFollowing', MActorUsername & MActorHost>
26
27// ############################################################################
28
29// With actors or actors default
30
31export type MActorFollowActors =
32 MActorFollow &
33 Use<'ActorFollower', MActor> &
34 Use<'ActorFollowing', MActor>
35
36export type MActorFollowActorsDefault =
37 MActorFollow &
38 Use<'ActorFollower', MActorDefault> &
39 Use<'ActorFollowing', MActorDefault>
40
41export type MActorFollowFull =
42 MActorFollow &
43 Use<'ActorFollower', MActorDefaultAccountChannel> &
44 Use<'ActorFollowing', MActorDefaultAccountChannel>
45
46// ############################################################################
47
48// For subscriptions
49
50type SubscriptionFollowing =
51 MActorDefault &
52 PickWith<ActorModel, 'VideoChannel', MChannelDefault>
53
54export type MActorFollowActorsDefaultSubscription =
55 MActorFollow &
56 Use<'ActorFollower', MActorDefault> &
57 Use<'ActorFollowing', SubscriptionFollowing>
58
59export type MActorFollowSubscriptions =
60 MActorFollow &
61 Use<'ActorFollowing', MActorChannelAccountActor>
62
63// ############################################################################
64
65// Format for API or AP object
66
67export type MActorFollowFormattable =
68 Pick<MActorFollow, 'id' | 'score' | 'state' | 'createdAt' | 'updatedAt'> &
69 Use<'ActorFollower', MActorFormattable> &
70 Use<'ActorFollowing', MActorFormattable>
diff --git a/server/types/models/account/actor.ts b/server/types/models/account/actor.ts
new file mode 100644
index 000000000..1160e84cb
--- /dev/null
+++ b/server/types/models/account/actor.ts
@@ -0,0 +1,139 @@
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 MActorWithInboxes = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl' | 'getSharedInbox'>
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 =
35 MActorLight &
36 Use<'Server', MServerHost> &
37 Use<'Avatar', MAvatar>
38
39export type MActorAccountId =
40 MActor &
41 Use<'Account', MAccountId>
42export type MActorAccountIdActor =
43 MActor &
44 Use<'Account', MAccountIdActor>
45
46export type MActorChannelId =
47 MActor &
48 Use<'VideoChannel', MChannelId>
49export type MActorChannelIdActor =
50 MActor &
51 Use<'VideoChannel', MChannelIdActor>
52
53export type MActorAccountChannelId = MActorAccountId & MActorChannelId
54export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor
55
56// ############################################################################
57
58// Include raw account/channel/server
59
60export type MActorAccount =
61 MActor &
62 Use<'Account', MAccount>
63
64export type MActorChannel =
65 MActor &
66 Use<'VideoChannel', MChannel>
67
68export type MActorDefaultAccountChannel = MActorDefault & MActorAccount & MActorChannel
69
70export type MActorServer =
71 MActor &
72 Use<'Server', MServer>
73
74// ############################################################################
75
76// Complex actor associations
77
78export type MActorDefault =
79 MActor &
80 Use<'Server', MServer> &
81 Use<'Avatar', MAvatar>
82
83// Actor with channel that is associated to an account and its actor
84// Actor -> VideoChannel -> Account -> Actor
85export type MActorChannelAccountActor =
86 MActor &
87 Use<'VideoChannel', MChannelAccountActor>
88
89export type MActorFull =
90 MActor &
91 Use<'Server', MServer> &
92 Use<'Avatar', MAvatar> &
93 Use<'Account', MAccount> &
94 Use<'VideoChannel', MChannelAccountActor>
95
96// Same than ActorFull, but the account and the channel have their actor
97export type MActorFullActor =
98 MActor &
99 Use<'Server', MServer> &
100 Use<'Avatar', MAvatar> &
101 Use<'Account', MAccountDefault> &
102 Use<'VideoChannel', MChannelAccountDefault>
103
104// ############################################################################
105
106// API
107
108export type MActorSummary =
109 FunctionProperties<MActor> &
110 Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> &
111 Use<'Server', MServerHost> &
112 Use<'Avatar', MAvatar>
113
114export type MActorSummaryBlocks =
115 MActorSummary &
116 Use<'Server', MServerHostBlocks>
117
118export type MActorAPI =
119 Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' |
120 'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'>
121
122// ############################################################################
123
124// Format for API or AP object
125
126export type MActorSummaryFormattable =
127 FunctionProperties<MActor> &
128 Pick<MActor, 'url' | 'preferredUsername'> &
129 Use<'Server', MServerHost> &
130 Use<'Avatar', MAvatarFormattable>
131
132export type MActorFormattable =
133 MActorSummaryFormattable &
134 Pick<MActor, 'id' | 'followingCount' | 'followersCount' | 'createdAt' | 'updatedAt'> &
135 Use<'Server', MServerHost & Partial<Pick<MServer, 'redundancyAllowed'>>>
136
137export type MActorAP =
138 MActor &
139 Use<'Avatar', MAvatar>
diff --git a/server/types/models/account/avatar.ts b/server/types/models/account/avatar.ts
new file mode 100644
index 000000000..6eba59ee4
--- /dev/null
+++ b/server/types/models/account/avatar.ts
@@ -0,0 +1,12 @@
1import { AvatarModel } from '../../../models/avatar/avatar'
2import { FunctionProperties } from '@server/types/utils'
3
4export type MAvatar = AvatarModel
5
6// ############################################################################
7
8// Format for API or AP object
9
10export type MAvatarFormattable =
11 FunctionProperties<MAvatar> &
12 Pick<MAvatar, 'filename' | 'createdAt' | 'updatedAt'>
diff --git a/server/types/models/account/index.ts b/server/types/models/account/index.ts
new file mode 100644
index 000000000..513c09c40
--- /dev/null
+++ b/server/types/models/account/index.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/types/models/index.ts b/server/types/models/index.ts
new file mode 100644
index 000000000..78b4948ce
--- /dev/null
+++ b/server/types/models/index.ts
@@ -0,0 +1,5 @@
1export * from './account'
2export * from './oauth'
3export * from './server'
4export * from './user'
5export * from './video'
diff --git a/server/types/models/oauth/index.ts b/server/types/models/oauth/index.ts
new file mode 100644
index 000000000..36b7ea8ca
--- /dev/null
+++ b/server/types/models/oauth/index.ts
@@ -0,0 +1,2 @@
1export * from './oauth-client'
2export * from './oauth-token'
diff --git a/server/types/models/oauth/oauth-client.ts b/server/types/models/oauth/oauth-client.ts
new file mode 100644
index 000000000..904a07863
--- /dev/null
+++ b/server/types/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/types/models/oauth/oauth-token.ts b/server/types/models/oauth/oauth-token.ts
new file mode 100644
index 000000000..396cf6429
--- /dev/null
+++ b/server/types/models/oauth/oauth-token.ts
@@ -0,0 +1,14 @@
1import { OAuthTokenModel } from '@server/models/oauth/oauth-token'
2import { PickWith } from '@server/types/utils'
3import { MUserAccountUrl } from '../user/user'
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 =
12 MOAuthToken &
13 Use<'User', MUserAccountUrl> &
14 { user?: MUserAccountUrl }
diff --git a/server/types/models/server/index.ts b/server/types/models/server/index.ts
new file mode 100644
index 000000000..c853795ad
--- /dev/null
+++ b/server/types/models/server/index.ts
@@ -0,0 +1,3 @@
1export * from './plugin'
2export * from './server'
3export * from './server-blocklist'
diff --git a/server/types/models/server/plugin.ts b/server/types/models/server/plugin.ts
new file mode 100644
index 000000000..83eb83794
--- /dev/null
+++ b/server/types/models/server/plugin.ts
@@ -0,0 +1,11 @@
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 =
10 Pick<MPlugin, 'name' | 'type' | 'version' | 'latestVersion' | 'enabled' | 'uninstalled'
11 | 'peertubeEngine' | 'description' | 'homepage' | 'settings' | 'createdAt' | 'updatedAt'>
diff --git a/server/types/models/server/server-blocklist.ts b/server/types/models/server/server-blocklist.ts
new file mode 100644
index 000000000..cfbf3b73a
--- /dev/null
+++ b/server/types/models/server/server-blocklist.ts
@@ -0,0 +1,26 @@
1import { ServerBlocklistModel } from '@server/models/server/server-blocklist'
2import { PickWith } from '@server/types/utils'
3import { MAccountDefault, MAccountFormattable } from '../account/account'
4import { MServer, MServerFormattable } from './server'
5
6type Use<K extends keyof ServerBlocklistModel, M> = PickWith<ServerBlocklistModel, K, M>
7
8// ############################################################################
9
10export type MServerBlocklist = Omit<ServerBlocklistModel, 'ByAccount' | 'BlockedServer'>
11
12// ############################################################################
13
14export type MServerBlocklistAccountServer =
15 MServerBlocklist &
16 Use<'ByAccount', MAccountDefault> &
17 Use<'BlockedServer', MServer>
18
19// ############################################################################
20
21// Format for API or AP object
22
23export type MServerBlocklistFormattable =
24 Pick<MServerBlocklist, 'createdAt'> &
25 Use<'ByAccount', MAccountFormattable> &
26 Use<'BlockedServer', MServerFormattable>
diff --git a/server/types/models/server/server.ts b/server/types/models/server/server.ts
new file mode 100644
index 000000000..b35e55aeb
--- /dev/null
+++ b/server/types/models/server/server.ts
@@ -0,0 +1,26 @@
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 =
17 MServerHost &
18 Use<'BlockedByAccounts', MAccountBlocklistId[]>
19
20// ############################################################################
21
22// Format for API or AP object
23
24export type MServerFormattable =
25 FunctionProperties<MServer> &
26 Pick<MServer, 'host'>
diff --git a/server/types/models/user/index.ts b/server/types/models/user/index.ts
new file mode 100644
index 000000000..6657b2128
--- /dev/null
+++ b/server/types/models/user/index.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/types/models/user/user-notification-setting.ts b/server/types/models/user/user-notification-setting.ts
new file mode 100644
index 000000000..c674add1b
--- /dev/null
+++ b/server/types/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/types/models/user/user-notification.ts b/server/types/models/user/user-notification.ts
new file mode 100644
index 000000000..2080360e1
--- /dev/null
+++ b/server/types/models/user/user-notification.ts
@@ -0,0 +1,92 @@
1import { UserNotificationModel } from '../../../models/account/user-notification'
2import { PickWith, PickWithOpt } 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 module UserNotificationIncludes {
20
21 export type VideoInclude = Pick<VideoModel, 'id' | 'uuid' | 'name'>
22 export type VideoIncludeChannel =
23 VideoInclude &
24 PickWith<VideoModel, 'VideoChannel', VideoChannelIncludeActor>
25
26 export type ActorInclude =
27 Pick<ActorModel, 'preferredUsername' | 'getHost'> &
28 PickWith<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>> &
29 PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>>
30
31 export type VideoChannelInclude = Pick<VideoChannelModel, 'id' | 'name' | 'getDisplayName'>
32 export type VideoChannelIncludeActor =
33 VideoChannelInclude &
34 PickWith<VideoChannelModel, 'Actor', ActorInclude>
35
36 export type AccountInclude = Pick<AccountModel, 'id' | 'name' | 'getDisplayName'>
37 export type AccountIncludeActor =
38 AccountInclude &
39 PickWith<AccountModel, 'Actor', ActorInclude>
40
41 export type VideoCommentInclude =
42 Pick<VideoCommentModel, 'id' | 'originCommentId' | 'getThreadId'> &
43 PickWith<VideoCommentModel, 'Account', AccountIncludeActor> &
44 PickWith<VideoCommentModel, 'Video', VideoInclude>
45
46 export type VideoAbuseInclude =
47 Pick<VideoAbuseModel, 'id'> &
48 PickWith<VideoAbuseModel, 'Video', VideoInclude>
49
50 export type VideoBlacklistInclude =
51 Pick<VideoBlacklistModel, 'id'> &
52 PickWith<VideoAbuseModel, 'Video', VideoInclude>
53
54 export type VideoImportInclude =
55 Pick<VideoImportModel, 'id' | 'magnetUri' | 'targetUrl' | 'torrentName'> &
56 PickWith<VideoImportModel, 'Video', VideoInclude>
57
58 export type ActorFollower =
59 Pick<ActorModel, 'preferredUsername' | 'getHost'> &
60 PickWith<ActorModel, 'Account', AccountInclude> &
61 PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>> &
62 PickWithOpt<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>>
63
64 export type ActorFollowing =
65 Pick<ActorModel, 'preferredUsername' | 'type' | 'getHost'> &
66 PickWith<ActorModel, 'VideoChannel', VideoChannelInclude> &
67 PickWith<ActorModel, 'Account', AccountInclude> &
68 PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>>
69
70 export type ActorFollowInclude =
71 Pick<ActorFollowModel, 'id' | 'state'> &
72 PickWith<ActorFollowModel, 'ActorFollower', ActorFollower> &
73 PickWith<ActorFollowModel, 'ActorFollowing', ActorFollowing>
74}
75
76// ############################################################################
77
78export type MUserNotification =
79 Omit<UserNotificationModel, 'User' | 'Video' | 'Comment' | 'VideoAbuse' | 'VideoBlacklist' |
80 'VideoImport' | 'Account' | 'ActorFollow'>
81
82// ############################################################################
83
84export type UserNotificationModelForApi =
85 MUserNotification &
86 Use<'Video', UserNotificationIncludes.VideoIncludeChannel> &
87 Use<'Comment', UserNotificationIncludes.VideoCommentInclude> &
88 Use<'VideoAbuse', UserNotificationIncludes.VideoAbuseInclude> &
89 Use<'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> &
90 Use<'VideoImport', UserNotificationIncludes.VideoImportInclude> &
91 Use<'ActorFollow', UserNotificationIncludes.ActorFollowInclude> &
92 Use<'Account', UserNotificationIncludes.AccountIncludeActor>
diff --git a/server/types/models/user/user-video-history.ts b/server/types/models/user/user-video-history.ts
new file mode 100644
index 000000000..62673ab1b
--- /dev/null
+++ b/server/types/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/types/models/user/user.ts b/server/types/models/user/user.ts
new file mode 100644
index 000000000..7938ea288
--- /dev/null
+++ b/server/types/models/user/user.ts
@@ -0,0 +1,89 @@
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 '../video/video-channels'
15import { MVideoPlaylist } from '@server/types/models'
16
17type Use<K extends keyof UserModel, M> = PickWith<UserModel, K, M>
18
19// ############################################################################
20
21export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoImports' | 'OAuthTokens'>
22
23// ############################################################################
24
25export type MUserQuotaUsed = MUser & { videoQuotaUsed?: number, videoQuotaUsedDaily?: number }
26export type MUserId = Pick<UserModel, 'id'>
27
28// ############################################################################
29
30// With account
31
32export type MUserAccountId =
33 MUser &
34 Use<'Account', MAccountId>
35
36export type MUserAccountUrl =
37 MUser &
38 Use<'Account', MAccountUrl & MAccountIdActorId>
39
40export type MUserAccount =
41 MUser &
42 Use<'Account', MAccount>
43
44export type MUserAccountDefault =
45 MUser &
46 Use<'Account', MAccountDefault>
47
48// With channel
49
50export type MUserNotifSettingChannelDefault =
51 MUser &
52 Use<'NotificationSetting', MNotificationSetting> &
53 Use<'Account', MAccountDefaultChannelDefault>
54
55// With notification settings
56
57export type MUserWithNotificationSetting =
58 MUser &
59 Use<'NotificationSetting', MNotificationSetting>
60
61export type MUserNotifSettingAccount =
62 MUser &
63 Use<'NotificationSetting', MNotificationSetting> &
64 Use<'Account', MAccount>
65
66// Default scope
67
68export type MUserDefault =
69 MUser &
70 Use<'NotificationSetting', MNotificationSetting> &
71 Use<'Account', MAccountDefault>
72
73// ############################################################################
74
75// Format for API or AP object
76
77type MAccountWithChannels = MAccountFormattable & PickWithOpt<AccountModel, 'VideoChannels', MChannelFormattable[]>
78type MAccountWithChannelsAndSpecialPlaylists =
79 MAccountWithChannels &
80 PickWithOpt<AccountModel, 'VideoPlaylists', MVideoPlaylist[]>
81
82export type MUserFormattable =
83 MUserQuotaUsed &
84 Use<'Account', MAccountWithChannels> &
85 PickWithOpt<UserModel, 'NotificationSetting', MNotificationSettingFormattable>
86
87export type MMyUserFormattable =
88 MUserFormattable &
89 Use<'Account', MAccountWithChannelsAndSpecialPlaylists>
diff --git a/server/types/models/video/index.ts b/server/types/models/video/index.ts
new file mode 100644
index 000000000..bd69c8a4b
--- /dev/null
+++ b/server/types/models/video/index.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/types/models/video/schedule-video-update.ts b/server/types/models/video/schedule-video-update.ts
new file mode 100644
index 000000000..6336fdabe
--- /dev/null
+++ b/server/types/models/video/schedule-video-update.ts
@@ -0,0 +1,19 @@
1import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update'
2import { PickWith } from '@server/types/utils'
3import { MVideoAPWithoutCaption, MVideoWithBlacklistLight } from './video'
4
5type Use<K extends keyof ScheduleVideoUpdateModel, M> = PickWith<ScheduleVideoUpdateModel, K, M>
6
7// ############################################################################
8
9export type MScheduleVideoUpdate = Omit<ScheduleVideoUpdateModel, 'Video'>
10
11// ############################################################################
12
13export type MScheduleVideoUpdateVideoAll =
14 MScheduleVideoUpdate &
15 Use<'Video', MVideoAPWithoutCaption & MVideoWithBlacklistLight>
16
17// Format for API or AP object
18
19export type MScheduleVideoUpdateFormattable = Pick<MScheduleVideoUpdate, 'updateAt' | 'privacy'>
diff --git a/server/types/models/video/tag.ts b/server/types/models/video/tag.ts
new file mode 100644
index 000000000..64a68873e
--- /dev/null
+++ b/server/types/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/types/models/video/thumbnail.ts b/server/types/models/video/thumbnail.ts
new file mode 100644
index 000000000..c03ba55ac
--- /dev/null
+++ b/server/types/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/types/models/video/video-abuse.ts b/server/types/models/video/video-abuse.ts
new file mode 100644
index 000000000..d60f05e4c
--- /dev/null
+++ b/server/types/models/video/video-abuse.ts
@@ -0,0 +1,35 @@
1import { VideoAbuseModel } from '../../../models/video/video-abuse'
2import { PickWith } from '../../utils'
3import { MVideoAccountLightBlacklistAllFiles, 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 =
17 MVideoAbuse &
18 Pick<VideoAbuseModel, 'toActivityPubObject'> &
19 Use<'Video', MVideo>
20
21export type MVideoAbuseAccountVideo =
22 MVideoAbuse &
23 Pick<VideoAbuseModel, 'toActivityPubObject'> &
24 Use<'Video', MVideoAccountLightBlacklistAllFiles> &
25 Use<'Account', MAccountDefault>
26
27// ############################################################################
28
29// Format for API or AP object
30
31export type MVideoAbuseFormattable =
32 MVideoAbuse &
33 Use<'Account', MAccountFormattable> &
34 Use<'Video', Pick<MVideoAccountLightBlacklistAllFiles,
35 'id' | 'uuid' | 'name' | 'nsfw' | 'getMiniatureStaticPath' | 'isBlacklisted' | 'VideoChannel'>>
diff --git a/server/types/models/video/video-blacklist.ts b/server/types/models/video/video-blacklist.ts
new file mode 100644
index 000000000..08e59284a
--- /dev/null
+++ b/server/types/models/video/video-blacklist.ts
@@ -0,0 +1,30 @@
1import { VideoBlacklistModel } from '../../../models/video/video-blacklist'
2import { PickWith } from '@server/types/utils'
3import { MVideo, MVideoFormattable } from './video'
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 MVideoBlacklistLightVideo =
17 MVideoBlacklistLight &
18 Use<'Video', MVideo>
19
20export type MVideoBlacklistVideo =
21 MVideoBlacklist &
22 Use<'Video', MVideo>
23
24// ############################################################################
25
26// Format for API or AP object
27
28export type MVideoBlacklistFormattable =
29 MVideoBlacklist &
30 Use<'Video', MVideoFormattable>
diff --git a/server/types/models/video/video-caption.ts b/server/types/models/video/video-caption.ts
new file mode 100644
index 000000000..9bb067001
--- /dev/null
+++ b/server/types/models/video/video-caption.ts
@@ -0,0 +1,27 @@
1import { VideoCaptionModel } from '../../../models/video/video-caption'
2import { FunctionProperties, PickWith } from '@server/types/utils'
3import { MVideo, MVideoUUID } from './video'
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'>
14export type MVideoCaptionLanguageUrl = Pick<MVideoCaption, 'language' | 'fileUrl' | 'getFileUrl'>
15
16export type MVideoCaptionVideo =
17 MVideoCaption &
18 Use<'Video', Pick<MVideo, 'id' | 'remote' | 'uuid'>>
19
20// ############################################################################
21
22// Format for API or AP object
23
24export type MVideoCaptionFormattable =
25 FunctionProperties<MVideoCaption> &
26 Pick<MVideoCaption, 'language'> &
27 Use<'Video', MVideoUUID>
diff --git a/server/types/models/video/video-change-ownership.ts b/server/types/models/video/video-change-ownership.ts
new file mode 100644
index 000000000..7421e081e
--- /dev/null
+++ b/server/types/models/video/video-change-ownership.ts
@@ -0,0 +1,26 @@
1import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership'
2import { PickWith } from '@server/types/utils'
3import { MAccountDefault, MAccountFormattable } from '../account/account'
4import { MVideo, MVideoWithAllFiles } from './video'
5
6type Use<K extends keyof VideoChangeOwnershipModel, M> = PickWith<VideoChangeOwnershipModel, K, M>
7
8// ############################################################################
9
10export type MVideoChangeOwnership = Omit<VideoChangeOwnershipModel, 'Initiator' | 'NextOwner' | 'Video'>
11
12export type MVideoChangeOwnershipFull =
13 MVideoChangeOwnership &
14 Use<'Initiator', MAccountDefault> &
15 Use<'NextOwner', MAccountDefault> &
16 Use<'Video', MVideoWithAllFiles>
17
18// ############################################################################
19
20// Format for API or AP object
21
22export type MVideoChangeOwnershipFormattable =
23 Pick<MVideoChangeOwnership, 'id' | 'status' | 'createdAt'> &
24 Use<'Initiator', MAccountFormattable> &
25 Use<'NextOwner', MAccountFormattable> &
26 Use<'Video', Pick<MVideo, 'id' | 'uuid' | 'url' | 'name'>>
diff --git a/server/types/models/video/video-channels.ts b/server/types/models/video/video-channels.ts
new file mode 100644
index 000000000..50f7c2d8a
--- /dev/null
+++ b/server/types/models/video/video-channels.ts
@@ -0,0 +1,145 @@
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 =
39 MChannelId &
40 Use<'Actor', MActorAccountChannelId>
41
42export type MChannelUserId =
43 Pick<MChannel, 'accountId'> &
44 Use<'Account', MAccountUserId>
45
46export type MChannelActor =
47 MChannel &
48 Use<'Actor', MActor>
49
50export type MChannelUrl = Use<'Actor', MActorUrl>
51
52// Default scope
53export type MChannelDefault =
54 MChannel &
55 Use<'Actor', MActorDefault>
56
57// ############################################################################
58
59// Not all association attributes
60
61export type MChannelLight =
62 MChannel &
63 Use<'Actor', MActorDefaultLight>
64
65export type MChannelActorLight =
66 MChannel &
67 Use<'Actor', MActorLight>
68
69export type MChannelAccountLight =
70 MChannel &
71 Use<'Actor', MActorDefaultLight> &
72 Use<'Account', MAccountLight>
73
74// ############################################################################
75
76// Account associations
77
78export type MChannelAccountActor =
79 MChannel &
80 Use<'Account', MAccountActor>
81
82export type MChannelAccountDefault =
83 MChannel &
84 Use<'Actor', MActorDefault> &
85 Use<'Account', MAccountDefault>
86
87export type MChannelActorAccountActor =
88 MChannel &
89 Use<'Account', MAccountActor> &
90 Use<'Actor', MActor>
91
92// ############################################################################
93
94// Videos associations
95export type MChannelVideos =
96 MChannel &
97 Use<'Videos', MVideo[]>
98
99export type MChannelActorAccountDefaultVideos =
100 MChannel &
101 Use<'Actor', MActorDefault> &
102 Use<'Account', MAccountDefault> &
103 Use<'Videos', MVideo[]>
104
105// ############################################################################
106
107// For API
108
109export type MChannelSummary =
110 FunctionProperties<MChannel> &
111 Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> &
112 Use<'Actor', MActorSummary>
113
114export type MChannelSummaryAccount =
115 MChannelSummary &
116 Use<'Account', MAccountSummaryBlocks>
117
118export type MChannelAPI =
119 MChannel &
120 Use<'Actor', MActorAPI> &
121 Use<'Account', MAccountAPI>
122
123// ############################################################################
124
125// Format for API or AP object
126
127export type MChannelSummaryFormattable =
128 FunctionProperties<MChannel> &
129 Pick<MChannel, 'id' | 'name'> &
130 Use<'Actor', MActorSummaryFormattable>
131
132export type MChannelAccountSummaryFormattable =
133 MChannelSummaryFormattable &
134 Use<'Account', MAccountSummaryFormattable>
135
136export type MChannelFormattable =
137 FunctionProperties<MChannel> &
138 Pick<MChannel, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'support'> &
139 Use<'Actor', MActorFormattable> &
140 PickWithOpt<VideoChannelModel, 'Account', MAccountFormattable>
141
142export type MChannelAP =
143 Pick<MChannel, 'name' | 'description' | 'support'> &
144 Use<'Actor', MActorAP> &
145 Use<'Account', MAccountUrl>
diff --git a/server/types/models/video/video-comment.ts b/server/types/models/video/video-comment.ts
new file mode 100644
index 000000000..d6e0b66f5
--- /dev/null
+++ b/server/types/models/video/video-comment.ts
@@ -0,0 +1,66 @@
1import { VideoCommentModel } from '../../../models/video/video-comment'
2import { PickWith, PickWithOpt } from '../../utils'
3import { MAccountDefault, MAccountFormattable, MAccountUrl } 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 =
18 MComment &
19 Use<'Account', MAccountDefault>
20
21export type MCommentVideo =
22 MComment &
23 Use<'Video', MVideoAccountLight>
24
25export type MCommentReply =
26 MComment &
27 Use<'InReplyToVideoComment', MComment>
28
29export type MCommentOwnerVideo =
30 MComment &
31 Use<'Account', MAccountDefault> &
32 Use<'Video', MVideoAccountLight>
33
34export type MCommentOwnerVideoReply =
35 MComment &
36 Use<'Account', MAccountDefault> &
37 Use<'Video', MVideoAccountLight> &
38 Use<'InReplyToVideoComment', MComment>
39
40export type MCommentOwnerReplyVideoLight =
41 MComment &
42 Use<'Account', MAccountDefault> &
43 Use<'InReplyToVideoComment', MComment> &
44 Use<'Video', MVideoIdUrl>
45
46export type MCommentOwnerVideoFeed =
47 MCommentOwner &
48 Use<'Video', MVideoFeed>
49
50// ############################################################################
51
52export type MCommentAPI = MComment & { totalReplies: number }
53
54// ############################################################################
55
56// Format for API or AP object
57
58export type MCommentFormattable =
59 MCommentTotalReplies &
60 Use<'Account', MAccountFormattable>
61
62export type MCommentAP =
63 MComment &
64 Use<'Account', MAccountUrl> &
65 PickWithOpt<VideoCommentModel, 'Video', MVideoUrl> &
66 PickWithOpt<VideoCommentModel, 'InReplyToVideoComment', MCommentUrl>
diff --git a/server/types/models/video/video-file.ts b/server/types/models/video/video-file.ts
new file mode 100644
index 000000000..3fcaca78f
--- /dev/null
+++ b/server/types/models/video/video-file.ts
@@ -0,0 +1,43 @@
1import { VideoFileModel } from '../../../models/video/video-file'
2import { PickWith, PickWithOpt } from '../../utils'
3import { MVideo, MVideoUUID } from './video'
4import { MVideoRedundancy, MVideoRedundancyFileUrl } from './video-redundancy'
5import { MStreamingPlaylistVideo, MStreamingPlaylist } from './video-streaming-playlist'
6
7type Use<K extends keyof VideoFileModel, M> = PickWith<VideoFileModel, K, M>
8
9// ############################################################################
10
11export type MVideoFile = Omit<VideoFileModel, 'Video' | 'RedundancyVideos' | 'VideoStreamingPlaylist'>
12
13export type MVideoFileVideo =
14 MVideoFile &
15 Use<'Video', MVideo>
16
17export type MVideoFileStreamingPlaylist =
18 MVideoFile &
19 Use<'VideoStreamingPlaylist', MStreamingPlaylist>
20
21export type MVideoFileStreamingPlaylistVideo =
22 MVideoFile &
23 Use<'VideoStreamingPlaylist', MStreamingPlaylistVideo>
24
25export type MVideoFileVideoUUID =
26 MVideoFile &
27 Use<'Video', MVideoUUID>
28
29export type MVideoFileRedundanciesAll =
30 MVideoFile &
31 PickWithOpt<VideoFileModel, 'RedundancyVideos', MVideoRedundancy[]>
32
33export type MVideoFileRedundanciesOpt =
34 MVideoFile &
35 PickWithOpt<VideoFileModel, 'RedundancyVideos', MVideoRedundancyFileUrl[]>
36
37export function isStreamingPlaylistFile (file: any): file is MVideoFileStreamingPlaylist {
38 return !!file.videoStreamingPlaylistId
39}
40
41export function isWebtorrentFile (file: any): file is MVideoFileVideo {
42 return !!file.videoId
43}
diff --git a/server/types/models/video/video-import.ts b/server/types/models/video/video-import.ts
new file mode 100644
index 000000000..f1385877e
--- /dev/null
+++ b/server/types/models/video/video-import.ts
@@ -0,0 +1,36 @@
1import { VideoImportModel } from '@server/models/video/video-import'
2import { PickWith, PickWithOpt } from '@server/types/utils'
3import { MVideo, MVideoAccountLight, MVideoFormattable, MVideoTag, MVideoThumbnail, MVideoWithFile } from './video'
4import { MUser } from '../user/user'
5
6type Use<K extends keyof VideoImportModel, M> = PickWith<VideoImportModel, K, M>
7
8// ############################################################################
9
10export type MVideoImport = Omit<VideoImportModel, 'User' | 'Video'>
11
12export type MVideoImportVideo =
13 MVideoImport &
14 Use<'Video', MVideo>
15
16// ############################################################################
17
18type VideoAssociation = MVideoTag & MVideoAccountLight & MVideoThumbnail
19
20export type MVideoImportDefault =
21 MVideoImport &
22 Use<'User', MUser> &
23 Use<'Video', VideoAssociation>
24
25export type MVideoImportDefaultFiles =
26 MVideoImport &
27 Use<'User', MUser> &
28 Use<'Video', VideoAssociation & MVideoWithFile>
29
30// ############################################################################
31
32// Format for API or AP object
33
34export type MVideoImportFormattable =
35 MVideoImport &
36 PickWithOpt<VideoImportModel, 'Video', MVideoFormattable & MVideoTag>
diff --git a/server/types/models/video/video-playlist-element.ts b/server/types/models/video/video-playlist-element.ts
new file mode 100644
index 000000000..c50992da7
--- /dev/null
+++ b/server/types/models/video/video-playlist-element.ts
@@ -0,0 +1,39 @@
1import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element'
2import { PickWith } from '@server/types/utils'
3import { MVideoFormattable, MVideoThumbnail, MVideoUrl } from './video'
4import { MVideoPlaylistPrivacy } from './video-playlist'
5
6type Use<K extends keyof VideoPlaylistElementModel, M> = PickWith<VideoPlaylistElementModel, K, M>
7
8// ############################################################################
9
10export type MVideoPlaylistElement = Omit<VideoPlaylistElementModel, 'VideoPlaylist' | 'Video'>
11
12// ############################################################################
13
14export type MVideoPlaylistElementId = Pick<MVideoPlaylistElement, 'id'>
15
16export type MVideoPlaylistElementLight = Pick<MVideoPlaylistElement, 'id' | 'videoId' | 'startTimestamp' | 'stopTimestamp'>
17
18// ############################################################################
19
20export type MVideoPlaylistVideoThumbnail =
21 MVideoPlaylistElement &
22 Use<'Video', MVideoThumbnail>
23
24export type MVideoPlaylistElementVideoUrlPlaylistPrivacy =
25 MVideoPlaylistElement &
26 Use<'Video', MVideoUrl> &
27 Use<'VideoPlaylist', MVideoPlaylistPrivacy>
28
29// ############################################################################
30
31// Format for API or AP object
32
33export type MVideoPlaylistElementFormattable =
34 MVideoPlaylistElement &
35 Use<'Video', MVideoFormattable>
36
37export type MVideoPlaylistElementAP =
38 MVideoPlaylistElement &
39 Use<'Video', MVideoUrl>
diff --git a/server/types/models/video/video-playlist.ts b/server/types/models/video/video-playlist.ts
new file mode 100644
index 000000000..b504d1664
--- /dev/null
+++ b/server/types/models/video/video-playlist.ts
@@ -0,0 +1,104 @@
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/types/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 =
26 MVideoPlaylist &
27 Use<'VideoPlaylistElements', MVideoPlaylistElementLight[]>
28
29export type MVideoPlaylistIdWithElements =
30 MVideoPlaylistId &
31 Use<'VideoPlaylistElements', MVideoPlaylistElementLight[]>
32
33// ############################################################################
34
35// With account
36
37export type MVideoPlaylistOwner =
38 MVideoPlaylist &
39 Use<'OwnerAccount', MAccount>
40
41export type MVideoPlaylistOwnerDefault =
42 MVideoPlaylist &
43 Use<'OwnerAccount', MAccountDefault>
44
45// ############################################################################
46
47// With thumbnail
48
49export type MVideoPlaylistThumbnail =
50 MVideoPlaylist &
51 Use<'Thumbnail', MThumbnail>
52
53export type MVideoPlaylistAccountThumbnail =
54 MVideoPlaylist &
55 Use<'OwnerAccount', MAccountDefault> &
56 Use<'Thumbnail', MThumbnail>
57
58// ############################################################################
59
60// With channel
61
62export type MVideoPlaylistAccountChannelDefault =
63 MVideoPlaylist &
64 Use<'OwnerAccount', MAccountDefault> &
65 Use<'VideoChannel', MChannelDefault>
66
67// ############################################################################
68
69// With all associations
70
71export type MVideoPlaylistFull =
72 MVideoPlaylist &
73 Use<'OwnerAccount', MAccountDefault> &
74 Use<'VideoChannel', MChannelDefault> &
75 Use<'Thumbnail', MThumbnail>
76
77// ############################################################################
78
79// For API
80
81export type MVideoPlaylistAccountChannelSummary =
82 MVideoPlaylist &
83 Use<'OwnerAccount', MAccountSummary> &
84 Use<'VideoChannel', MChannelSummary>
85
86export type MVideoPlaylistFullSummary =
87 MVideoPlaylist &
88 Use<'Thumbnail', MThumbnail> &
89 Use<'OwnerAccount', MAccountSummary> &
90 Use<'VideoChannel', MChannelSummary>
91
92// ############################################################################
93
94// Format for API or AP object
95
96export type MVideoPlaylistFormattable =
97 MVideoPlaylistVideosLength &
98 Use<'OwnerAccount', MAccountSummaryFormattable> &
99 Use<'VideoChannel', MChannelSummaryFormattable>
100
101export type MVideoPlaylistAP =
102 MVideoPlaylist &
103 Use<'Thumbnail', MThumbnail> &
104 Use<'VideoChannel', MChannelUrl>
diff --git a/server/types/models/video/video-rate.ts b/server/types/models/video/video-rate.ts
new file mode 100644
index 000000000..a7682ef31
--- /dev/null
+++ b/server/types/models/video/video-rate.ts
@@ -0,0 +1,27 @@
1import { AccountVideoRateModel } from '@server/models/account/account-video-rate'
2import { PickWith } from '@server/types/utils'
3import { MAccountAudience, MAccountUrl } from '../account/account'
4import { MVideo, MVideoFormattable } from './video'
5
6type Use<K extends keyof AccountVideoRateModel, M> = PickWith<AccountVideoRateModel, K, M>
7
8// ############################################################################
9
10export type MAccountVideoRate = Omit<AccountVideoRateModel, 'Video' | 'Account'>
11
12export type MAccountVideoRateAccountUrl =
13 MAccountVideoRate &
14 Use<'Account', MAccountUrl>
15
16export type MAccountVideoRateAccountVideo =
17 MAccountVideoRate &
18 Use<'Account', MAccountAudience> &
19 Use<'Video', MVideo>
20
21// ############################################################################
22
23// Format for API or AP object
24
25export type MAccountVideoRateFormattable =
26 Pick<MAccountVideoRate, 'type'> &
27 Use<'Video', MVideoFormattable>
diff --git a/server/types/models/video/video-redundancy.ts b/server/types/models/video/video-redundancy.ts
new file mode 100644
index 000000000..7c7d52035
--- /dev/null
+++ b/server/types/models/video/video-redundancy.ts
@@ -0,0 +1,43 @@
1import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy'
2import { PickWith, PickWithOpt } from '@server/types/utils'
3import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist'
4import { VideoFileModel } from '@server/models/video/video-file'
5import { MVideoFile, MVideoFileVideo } from './video-file'
6import { MStreamingPlaylistVideo } from './video-streaming-playlist'
7import { MVideoUrl } from './video'
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 =
20 MVideoRedundancy &
21 Use<'VideoFile', MVideoFile>
22
23export type MVideoRedundancyFileVideo =
24 MVideoRedundancy &
25 Use<'VideoFile', MVideoFileVideo>
26
27export type MVideoRedundancyStreamingPlaylistVideo =
28 MVideoRedundancy &
29 Use<'VideoStreamingPlaylist', MStreamingPlaylistVideo>
30
31export type MVideoRedundancyVideo =
32 MVideoRedundancy &
33 Use<'VideoFile', MVideoFileVideo> &
34 Use<'VideoStreamingPlaylist', MStreamingPlaylistVideo>
35
36// ############################################################################
37
38// Format for API or AP object
39
40export type MVideoRedundancyAP =
41 MVideoRedundancy &
42 PickWithOpt<VideoRedundancyModel, 'VideoFile', MVideoFile & PickWith<VideoFileModel, 'Video', MVideoUrl>> &
43 PickWithOpt<VideoRedundancyModel, 'VideoStreamingPlaylist', PickWith<VideoStreamingPlaylistModel, 'Video', MVideoUrl>>
diff --git a/server/types/models/video/video-share.ts b/server/types/models/video/video-share.ts
new file mode 100644
index 000000000..50ca75d26
--- /dev/null
+++ b/server/types/models/video/video-share.ts
@@ -0,0 +1,19 @@
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 =
13 MVideoShare &
14 Use<'Actor', MActorDefault>
15
16export type MVideoShareFull =
17 MVideoShare &
18 Use<'Actor', MActorDefault> &
19 Use<'Video', MVideo>
diff --git a/server/types/models/video/video-streaming-playlist.ts b/server/types/models/video/video-streaming-playlist.ts
new file mode 100644
index 000000000..3f54aa560
--- /dev/null
+++ b/server/types/models/video/video-streaming-playlist.ts
@@ -0,0 +1,43 @@
1import { VideoStreamingPlaylistModel } from '../../../models/video/video-streaming-playlist'
2import { PickWith, PickWithOpt } from '../../utils'
3import { MVideoRedundancyFileUrl, MVideoRedundancy } from './video-redundancy'
4import { MVideo } from './video'
5import { MVideoFile } from './video-file'
6
7type Use<K extends keyof VideoStreamingPlaylistModel, M> = PickWith<VideoStreamingPlaylistModel, K, M>
8
9// ############################################################################
10
11export type MStreamingPlaylist = Omit<VideoStreamingPlaylistModel, 'Video' | 'RedundancyVideos' | 'VideoFiles'>
12
13export type MStreamingPlaylistFiles =
14 MStreamingPlaylist &
15 Use<'VideoFiles', MVideoFile[]>
16
17export type MStreamingPlaylistVideo =
18 MStreamingPlaylist &
19 Use<'Video', MVideo>
20
21export type MStreamingPlaylistFilesVideo =
22 MStreamingPlaylist &
23 Use<'VideoFiles', MVideoFile[]> &
24 Use<'Video', MVideo>
25
26export type MStreamingPlaylistRedundanciesAll =
27 MStreamingPlaylist &
28 Use<'VideoFiles', MVideoFile[]> &
29 Use<'RedundancyVideos', MVideoRedundancy[]>
30
31export type MStreamingPlaylistRedundancies =
32 MStreamingPlaylist &
33 Use<'VideoFiles', MVideoFile[]> &
34 Use<'RedundancyVideos', MVideoRedundancyFileUrl[]>
35
36export type MStreamingPlaylistRedundanciesOpt =
37 MStreamingPlaylist &
38 Use<'VideoFiles', MVideoFile[]> &
39 PickWithOpt<VideoStreamingPlaylistModel, 'RedundancyVideos', MVideoRedundancyFileUrl[]>
40
41export function isStreamingPlaylist (value: MVideo | MStreamingPlaylistVideo): value is MStreamingPlaylistVideo {
42 return !!(value as MStreamingPlaylist).playlistUrl
43}
diff --git a/server/types/models/video/video.ts b/server/types/models/video/video.ts
new file mode 100644
index 000000000..022a9566d
--- /dev/null
+++ b/server/types/models/video/video.ts
@@ -0,0 +1,211 @@
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, MVideoCaptionLanguageUrl } from './video-caption'
13import {
14 MStreamingPlaylistFiles,
15 MStreamingPlaylistRedundancies,
16 MStreamingPlaylistRedundanciesAll,
17 MStreamingPlaylistRedundanciesOpt
18} from './video-streaming-playlist'
19import { MVideoFile, MVideoFileRedundanciesAll, MVideoFileRedundanciesOpt } from './video-file'
20import { MThumbnail } from './thumbnail'
21import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist'
22import { MScheduleVideoUpdate } from './schedule-video-update'
23import { MUserVideoHistoryTime } from '../user/user-video-history'
24
25type Use<K extends keyof VideoModel, M> = PickWith<VideoModel, K, M>
26
27// ############################################################################
28
29export type MVideo =
30 Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' |
31 'VideoFiles' | 'VideoStreamingPlaylists' | 'VideoShares' | 'AccountVideoRates' | 'VideoComments' | 'VideoViews' | 'UserVideoHistories' |
32 'ScheduleVideoUpdate' | 'VideoBlacklist' | 'VideoImport' | 'VideoCaptions'>
33
34// ############################################################################
35
36export type MVideoId = Pick<MVideo, 'id'>
37export type MVideoUrl = Pick<MVideo, 'url'>
38export type MVideoUUID = Pick<MVideo, 'uuid'>
39
40export type MVideoImmutable = Pick<MVideo, 'id' | 'url' | 'uuid' | 'remote' | 'isOwned'>
41export type MVideoIdUrl = MVideoId & MVideoUrl
42export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'>
43
44// ############################################################################
45
46// Video raw associations: schedules, video files, tags, thumbnails, captions, streaming playlists
47
48// "With" to not confuse with the VideoFile model
49export type MVideoWithFile =
50 MVideo &
51 Use<'VideoFiles', MVideoFile[]> &
52 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
53
54export type MVideoThumbnail =
55 MVideo &
56 Use<'Thumbnails', MThumbnail[]>
57
58export type MVideoIdThumbnail =
59 MVideoId &
60 Use<'Thumbnails', MThumbnail[]>
61
62export type MVideoWithFileThumbnail =
63 MVideo &
64 Use<'VideoFiles', MVideoFile[]> &
65 Use<'Thumbnails', MThumbnail[]>
66
67export type MVideoThumbnailBlacklist =
68 MVideo &
69 Use<'Thumbnails', MThumbnail[]> &
70 Use<'VideoBlacklist', MVideoBlacklistLight>
71
72export type MVideoTag =
73 MVideo &
74 Use<'Tags', MTag[]>
75
76export type MVideoWithSchedule =
77 MVideo &
78 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate>
79
80export type MVideoWithCaptions =
81 MVideo &
82 Use<'VideoCaptions', MVideoCaptionLanguage[]>
83
84export type MVideoWithStreamingPlaylist =
85 MVideo &
86 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
87
88// ############################################################################
89
90// Associations with not all their attributes
91
92export type MVideoUserHistory =
93 MVideo &
94 Use<'UserVideoHistories', MUserVideoHistoryTime[]>
95
96export type MVideoWithBlacklistLight =
97 MVideo &
98 Use<'VideoBlacklist', MVideoBlacklistLight>
99
100export type MVideoAccountLight =
101 MVideo &
102 Use<'VideoChannel', MChannelAccountLight>
103
104export type MVideoWithRights =
105 MVideo &
106 Use<'VideoBlacklist', MVideoBlacklistLight> &
107 Use<'Thumbnails', MThumbnail[]> &
108 Use<'VideoChannel', MChannelUserId>
109
110// ############################################################################
111
112// All files with some additional associations
113
114export type MVideoWithAllFiles =
115 MVideo &
116 Use<'VideoFiles', MVideoFile[]> &
117 Use<'Thumbnails', MThumbnail[]> &
118 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
119
120export type MVideoAccountLightBlacklistAllFiles =
121 MVideo &
122 Use<'VideoFiles', MVideoFile[]> &
123 Use<'Thumbnails', MThumbnail[]> &
124 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> &
125 Use<'VideoChannel', MChannelAccountLight> &
126 Use<'VideoBlacklist', MVideoBlacklistLight>
127
128// ############################################################################
129
130// With account
131
132export type MVideoAccountDefault =
133 MVideo &
134 Use<'VideoChannel', MChannelAccountDefault>
135
136export type MVideoThumbnailAccountDefault =
137 MVideo &
138 Use<'Thumbnails', MThumbnail[]> &
139 Use<'VideoChannel', MChannelAccountDefault>
140
141export type MVideoWithChannelActor =
142 MVideo &
143 Use<'VideoChannel', MChannelActor>
144
145export type MVideoFullLight =
146 MVideo &
147 Use<'Thumbnails', MThumbnail[]> &
148 Use<'VideoBlacklist', MVideoBlacklistLight> &
149 Use<'Tags', MTag[]> &
150 Use<'VideoChannel', MChannelAccountLight> &
151 Use<'UserVideoHistories', MUserVideoHistoryTime[]> &
152 Use<'VideoFiles', MVideoFile[]> &
153 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
154 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]>
155
156// ############################################################################
157
158// API
159
160export type MVideoAP =
161 MVideo &
162 Use<'Tags', MTag[]> &
163 Use<'VideoChannel', MChannelAccountLight> &
164 Use<'VideoStreamingPlaylists', MStreamingPlaylistFiles[]> &
165 Use<'VideoCaptions', MVideoCaptionLanguageUrl[]> &
166 Use<'VideoBlacklist', MVideoBlacklistUnfederated> &
167 Use<'VideoFiles', MVideoFileRedundanciesOpt[]> &
168 Use<'Thumbnails', MThumbnail[]>
169
170export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'>
171
172export type MVideoDetails =
173 MVideo &
174 Use<'VideoBlacklist', MVideoBlacklistLight> &
175 Use<'Tags', MTag[]> &
176 Use<'VideoChannel', MChannelAccountLight> &
177 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
178 Use<'Thumbnails', MThumbnail[]> &
179 Use<'UserVideoHistories', MUserVideoHistoryTime[]> &
180 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> &
181 Use<'VideoFiles', MVideoFileRedundanciesOpt[]>
182
183export type MVideoForUser =
184 MVideo &
185 Use<'VideoChannel', MChannelAccountDefault> &
186 Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> &
187 Use<'VideoBlacklist', MVideoBlacklistLight> &
188 Use<'Thumbnails', MThumbnail[]>
189
190export type MVideoForRedundancyAPI =
191 MVideo &
192 Use<'VideoFiles', MVideoFileRedundanciesAll[]> &
193 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesAll[]>
194
195// ############################################################################
196
197// Format for API or AP object
198
199export type MVideoFormattable =
200 MVideo &
201 PickWithOpt<VideoModel, 'UserVideoHistories', MUserVideoHistoryTime[]> &
202 Use<'VideoChannel', MChannelAccountSummaryFormattable> &
203 PickWithOpt<VideoModel, 'ScheduleVideoUpdate', Pick<MScheduleVideoUpdate, 'updateAt' | 'privacy'>> &
204 PickWithOpt<VideoModel, 'VideoBlacklist', Pick<MVideoBlacklist, 'reason'>>
205
206export type MVideoFormattableDetails =
207 MVideoFormattable &
208 Use<'VideoChannel', MChannelFormattable> &
209 Use<'Tags', MTag[]> &
210 Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesOpt[]> &
211 Use<'VideoFiles', MVideoFileRedundanciesOpt[]>
diff --git a/server/types/sequelize.ts b/server/types/sequelize.ts
new file mode 100644
index 000000000..9cd83612d
--- /dev/null
+++ b/server/types/sequelize.ts
@@ -0,0 +1,18 @@
1import { Model } from 'sequelize-typescript'
2
3// Thanks to sequelize-typescript: https://github.com/RobinBuschmann/sequelize-typescript
4
5export type Diff<T extends string | symbol | number, U extends string | symbol | number> =
6 ({ [P in T]: P } & { [P in U]: never } & { [ x: string ]: never })[T]
7
8export type Omit<T, K extends keyof T> = { [P in Diff<keyof T, K>]: T[P] }
9
10export type RecursivePartial<T> = { [P in keyof T]?: RecursivePartial<T[P]> }
11
12export type FilteredModelAttributes<T extends Model<T>> = RecursivePartial<Omit<T, keyof Model<any>>> & {
13 id?: number | any
14 createdAt?: Date | any
15 updatedAt?: Date | any
16 deletedAt?: Date | any
17 version?: number | any
18}
diff --git a/server/types/utils.ts b/server/types/utils.ts
new file mode 100644
index 000000000..55500d8c4
--- /dev/null
+++ b/server/types/utils.ts
@@ -0,0 +1,24 @@
1/* eslint-disable @typescript-eslint/array-type */
2
3export type FunctionPropertyNames<T> = {
4 [K in keyof T]: T[K] extends Function ? K : never
5}[keyof T]
6
7export type FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>>
8
9export type PickWith<T, KT extends keyof T, V> = {
10 [P in KT]: T[P] extends V ? V : never
11}
12
13export type PickWithOpt<T, KT extends keyof T, V> = {
14 [P in KT]?: T[P] extends V ? V : never
15}
16
17// https://github.com/krzkaczor/ts-essentials Rocks!
18export type DeepPartial<T> = {
19 [P in keyof T]?: T[P] extends Array<infer U>
20 ? Array<DeepPartial<U>>
21 : T[P] extends ReadonlyArray<infer U>
22 ? ReadonlyArray<DeepPartial<U>>
23 : DeepPartial<T[P]>
24}