diff options
author | Chocobozzz <me@florianbigard.com> | 2020-06-18 10:45:25 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-06-18 10:46:27 +0200 |
commit | 26d6bf6533023326fa017812cf31bbe20c752d36 (patch) | |
tree | 9c4e3ecdc344420190f17d429bdf05d78fae7a8c /server/typings/models/user | |
parent | d6d951ddc0c492f3261065b5dcb4df0534d252fc (diff) | |
download | PeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.tar.gz PeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.tar.zst PeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.zip |
Split types and typings
Diffstat (limited to 'server/typings/models/user')
-rw-r--r-- | server/typings/models/user/index.ts | 4 | ||||
-rw-r--r-- | server/typings/models/user/user-notification-setting.ts | 9 | ||||
-rw-r--r-- | server/typings/models/user/user-notification.ts | 92 | ||||
-rw-r--r-- | server/typings/models/user/user-video-history.ts | 5 | ||||
-rw-r--r-- | server/typings/models/user/user.ts | 89 |
5 files changed, 0 insertions, 199 deletions
diff --git a/server/typings/models/user/index.ts b/server/typings/models/user/index.ts deleted file mode 100644 index 6657b2128..000000000 --- a/server/typings/models/user/index.ts +++ /dev/null | |||
@@ -1,4 +0,0 @@ | |||
1 | export * from './user' | ||
2 | export * from './user-notification' | ||
3 | export * from './user-notification-setting' | ||
4 | export * from './user-video-history' | ||
diff --git a/server/typings/models/user/user-notification-setting.ts b/server/typings/models/user/user-notification-setting.ts deleted file mode 100644 index c674add1b..000000000 --- a/server/typings/models/user/user-notification-setting.ts +++ /dev/null | |||
@@ -1,9 +0,0 @@ | |||
1 | import { UserNotificationSettingModel } from '@server/models/account/user-notification-setting' | ||
2 | |||
3 | export type MNotificationSetting = Omit<UserNotificationSettingModel, 'User'> | ||
4 | |||
5 | // ############################################################################ | ||
6 | |||
7 | // Format for API or AP object | ||
8 | |||
9 | export type MNotificationSettingFormattable = MNotificationSetting | ||
diff --git a/server/typings/models/user/user-notification.ts b/server/typings/models/user/user-notification.ts deleted file mode 100644 index 2080360e1..000000000 --- a/server/typings/models/user/user-notification.ts +++ /dev/null | |||
@@ -1,92 +0,0 @@ | |||
1 | import { UserNotificationModel } from '../../../models/account/user-notification' | ||
2 | import { PickWith, PickWithOpt } from '../../utils' | ||
3 | import { VideoModel } from '../../../models/video/video' | ||
4 | import { ActorModel } from '../../../models/activitypub/actor' | ||
5 | import { ServerModel } from '../../../models/server/server' | ||
6 | import { AvatarModel } from '../../../models/avatar/avatar' | ||
7 | import { VideoChannelModel } from '../../../models/video/video-channel' | ||
8 | import { AccountModel } from '../../../models/account/account' | ||
9 | import { VideoCommentModel } from '../../../models/video/video-comment' | ||
10 | import { VideoAbuseModel } from '../../../models/video/video-abuse' | ||
11 | import { VideoBlacklistModel } from '../../../models/video/video-blacklist' | ||
12 | import { VideoImportModel } from '../../../models/video/video-import' | ||
13 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | ||
14 | |||
15 | type Use<K extends keyof UserNotificationModel, M> = PickWith<UserNotificationModel, K, M> | ||
16 | |||
17 | // ############################################################################ | ||
18 | |||
19 | export 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 | |||
78 | export type MUserNotification = | ||
79 | Omit<UserNotificationModel, 'User' | 'Video' | 'Comment' | 'VideoAbuse' | 'VideoBlacklist' | | ||
80 | 'VideoImport' | 'Account' | 'ActorFollow'> | ||
81 | |||
82 | // ############################################################################ | ||
83 | |||
84 | export 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/typings/models/user/user-video-history.ts b/server/typings/models/user/user-video-history.ts deleted file mode 100644 index 62673ab1b..000000000 --- a/server/typings/models/user/user-video-history.ts +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | import { UserVideoHistoryModel } from '../../../models/account/user-video-history' | ||
2 | |||
3 | export type MUserVideoHistory = Omit<UserVideoHistoryModel, 'Video' | 'User'> | ||
4 | |||
5 | export type MUserVideoHistoryTime = Pick<MUserVideoHistory, 'currentTime'> | ||
diff --git a/server/typings/models/user/user.ts b/server/typings/models/user/user.ts deleted file mode 100644 index 31cf075ef..000000000 --- a/server/typings/models/user/user.ts +++ /dev/null | |||
@@ -1,89 +0,0 @@ | |||
1 | import { UserModel } from '../../../models/account/user' | ||
2 | import { PickWith, PickWithOpt } from '../../utils' | ||
3 | import { | ||
4 | MAccount, | ||
5 | MAccountDefault, | ||
6 | MAccountDefaultChannelDefault, | ||
7 | MAccountFormattable, | ||
8 | MAccountId, | ||
9 | MAccountIdActorId, | ||
10 | MAccountUrl | ||
11 | } from '../account' | ||
12 | import { MNotificationSetting, MNotificationSettingFormattable } from './user-notification-setting' | ||
13 | import { AccountModel } from '@server/models/account/account' | ||
14 | import { MChannelFormattable } from '../video/video-channels' | ||
15 | import { MVideoPlaylist } from '@server/typings/models' | ||
16 | |||
17 | type Use<K extends keyof UserModel, M> = PickWith<UserModel, K, M> | ||
18 | |||
19 | // ############################################################################ | ||
20 | |||
21 | export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoImports' | 'OAuthTokens'> | ||
22 | |||
23 | // ############################################################################ | ||
24 | |||
25 | export type MUserQuotaUsed = MUser & { videoQuotaUsed?: number, videoQuotaUsedDaily?: number } | ||
26 | export type MUserId = Pick<UserModel, 'id'> | ||
27 | |||
28 | // ############################################################################ | ||
29 | |||
30 | // With account | ||
31 | |||
32 | export type MUserAccountId = | ||
33 | MUser & | ||
34 | Use<'Account', MAccountId> | ||
35 | |||
36 | export type MUserAccountUrl = | ||
37 | MUser & | ||
38 | Use<'Account', MAccountUrl & MAccountIdActorId> | ||
39 | |||
40 | export type MUserAccount = | ||
41 | MUser & | ||
42 | Use<'Account', MAccount> | ||
43 | |||
44 | export type MUserAccountDefault = | ||
45 | MUser & | ||
46 | Use<'Account', MAccountDefault> | ||
47 | |||
48 | // With channel | ||
49 | |||
50 | export type MUserNotifSettingChannelDefault = | ||
51 | MUser & | ||
52 | Use<'NotificationSetting', MNotificationSetting> & | ||
53 | Use<'Account', MAccountDefaultChannelDefault> | ||
54 | |||
55 | // With notification settings | ||
56 | |||
57 | export type MUserWithNotificationSetting = | ||
58 | MUser & | ||
59 | Use<'NotificationSetting', MNotificationSetting> | ||
60 | |||
61 | export type MUserNotifSettingAccount = | ||
62 | MUser & | ||
63 | Use<'NotificationSetting', MNotificationSetting> & | ||
64 | Use<'Account', MAccount> | ||
65 | |||
66 | // Default scope | ||
67 | |||
68 | export type MUserDefault = | ||
69 | MUser & | ||
70 | Use<'NotificationSetting', MNotificationSetting> & | ||
71 | Use<'Account', MAccountDefault> | ||
72 | |||
73 | // ############################################################################ | ||
74 | |||
75 | // Format for API or AP object | ||
76 | |||
77 | type MAccountWithChannels = MAccountFormattable & PickWithOpt<AccountModel, 'VideoChannels', MChannelFormattable[]> | ||
78 | type MAccountWithChannelsAndSpecialPlaylists = | ||
79 | MAccountWithChannels & | ||
80 | PickWithOpt<AccountModel, 'VideoPlaylists', MVideoPlaylist[]> | ||
81 | |||
82 | export type MUserFormattable = | ||
83 | MUserQuotaUsed & | ||
84 | Use<'Account', MAccountWithChannels> & | ||
85 | PickWithOpt<UserModel, 'NotificationSetting', MNotificationSettingFormattable> | ||
86 | |||
87 | export type MMyUserFormattable = | ||
88 | MUserFormattable & | ||
89 | Use<'Account', MAccountWithChannelsAndSpecialPlaylists> | ||