diff options
author | Chocobozzz <me@florianbigard.com> | 2019-08-15 11:53:26 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-08-19 17:26:35 +0200 |
commit | 453e83ea5d81d203ba34bc43cd5c2c750ba40568 (patch) | |
tree | 604e02f4343d13a4ba42e1fb7527ba6ab9111712 /server/typings/models/user | |
parent | 13176a07a95984a53cc59aec5217f2ce9806d1bc (diff) | |
download | PeerTube-453e83ea5d81d203ba34bc43cd5c2c750ba40568.tar.gz PeerTube-453e83ea5d81d203ba34bc43cd5c2c750ba40568.tar.zst PeerTube-453e83ea5d81d203ba34bc43cd5c2c750ba40568.zip |
Stronger model typings
Diffstat (limited to 'server/typings/models/user')
-rw-r--r-- | server/typings/models/user/index.d.ts | 3 | ||||
-rw-r--r-- | server/typings/models/user/user-notification-setting.ts | 3 | ||||
-rw-r--r-- | server/typings/models/user/user-notification.ts | 69 | ||||
-rw-r--r-- | server/typings/models/user/user-video-history.ts | 5 | ||||
-rw-r--r-- | server/typings/models/user/user.ts | 32 |
5 files changed, 112 insertions, 0 deletions
diff --git a/server/typings/models/user/index.d.ts b/server/typings/models/user/index.d.ts new file mode 100644 index 000000000..e3353d0b1 --- /dev/null +++ b/server/typings/models/user/index.d.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export * from './user' | ||
2 | export * from './user-notification' | ||
3 | 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 new file mode 100644 index 000000000..585d30a66 --- /dev/null +++ b/server/typings/models/user/user-notification-setting.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | import { UserNotificationSettingModel } from '@server/models/account/user-notification-setting' | ||
2 | |||
3 | export type MNotificationSetting = Omit<UserNotificationSettingModel, 'User'> | ||
diff --git a/server/typings/models/user/user-notification.ts b/server/typings/models/user/user-notification.ts new file mode 100644 index 000000000..b872c5dc5 --- /dev/null +++ b/server/typings/models/user/user-notification.ts | |||
@@ -0,0 +1,69 @@ | |||
1 | import { UserNotificationModel } from '../../../models/account/user-notification' | ||
2 | import { PickWith } 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 | export namespace UserNotificationIncludes { | ||
16 | export type VideoInclude = Pick<VideoModel, 'id' | 'uuid' | 'name'> | ||
17 | export type VideoIncludeChannel = VideoInclude & | ||
18 | PickWith<VideoModel, 'VideoChannel', VideoChannelIncludeActor> | ||
19 | |||
20 | export type ActorInclude = Pick<ActorModel, 'preferredUsername' | 'getHost'> & | ||
21 | PickWith<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>> & | ||
22 | PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>> | ||
23 | |||
24 | export type VideoChannelInclude = Pick<VideoChannelModel, 'id' | 'name' | 'getDisplayName'> | ||
25 | export type VideoChannelIncludeActor = VideoChannelInclude & | ||
26 | PickWith<VideoChannelModel, 'Actor', ActorInclude> | ||
27 | |||
28 | export type AccountInclude = Pick<AccountModel, 'id' | 'name' | 'getDisplayName'> | ||
29 | export type AccountIncludeActor = AccountInclude & | ||
30 | PickWith<AccountModel, 'Actor', ActorInclude> | ||
31 | |||
32 | export type VideoCommentInclude = Pick<VideoCommentModel, 'id' | 'originCommentId' | 'getThreadId'> & | ||
33 | PickWith<VideoCommentModel, 'Account', AccountIncludeActor> & | ||
34 | PickWith<VideoCommentModel, 'Video', VideoInclude> | ||
35 | |||
36 | export type VideoAbuseInclude = Pick<VideoAbuseModel, 'id'> & | ||
37 | PickWith<VideoAbuseModel, 'Video', VideoInclude> | ||
38 | |||
39 | export type VideoBlacklistInclude = Pick<VideoBlacklistModel, 'id'> & | ||
40 | PickWith<VideoAbuseModel, 'Video', VideoInclude> | ||
41 | |||
42 | export type VideoImportInclude = Pick<VideoImportModel, 'id' | 'magnetUri' | 'targetUrl' | 'torrentName'> & | ||
43 | PickWith<VideoImportModel, 'Video', VideoInclude> | ||
44 | |||
45 | export type ActorFollower = Pick<ActorModel, 'preferredUsername' | 'getHost'> & | ||
46 | PickWith<ActorModel, 'Account', AccountInclude> & | ||
47 | PickWith<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>> & | ||
48 | PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>> | ||
49 | |||
50 | export type ActorFollowing = Pick<ActorModel, 'preferredUsername'> & | ||
51 | PickWith<ActorModel, 'VideoChannel', VideoChannelInclude> & | ||
52 | PickWith<ActorModel, 'Account', AccountInclude> | ||
53 | |||
54 | export type ActorFollowInclude = Pick<ActorFollowModel, 'id' | 'state'> & | ||
55 | PickWith<ActorFollowModel, 'ActorFollower', ActorFollower> & | ||
56 | PickWith<ActorFollowModel, 'ActorFollowing', ActorFollowing> | ||
57 | } | ||
58 | |||
59 | export type UserNotificationModelOnly = Omit<UserNotificationModel, 'User' | 'Video' | 'Comment' | 'VideoAbuse' | 'VideoBlacklist' | | ||
60 | 'VideoImport' | 'Account' | 'ActorFollow'> | ||
61 | |||
62 | export type UserNotificationModelForApi = UserNotificationModelOnly & | ||
63 | PickWith<UserNotificationModel, 'Video', UserNotificationIncludes.VideoIncludeChannel> & | ||
64 | PickWith<UserNotificationModel, 'Comment', UserNotificationIncludes.VideoCommentInclude> & | ||
65 | PickWith<UserNotificationModel, 'VideoAbuse', UserNotificationIncludes.VideoAbuseInclude> & | ||
66 | PickWith<UserNotificationModel, 'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> & | ||
67 | PickWith<UserNotificationModel, 'VideoImport', UserNotificationIncludes.VideoImportInclude> & | ||
68 | PickWith<UserNotificationModel, 'ActorFollow', UserNotificationIncludes.ActorFollowInclude> & | ||
69 | PickWith<UserNotificationModel, '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 @@ | |||
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 new file mode 100644 index 000000000..b91eed8d9 --- /dev/null +++ b/server/typings/models/user/user.ts | |||
@@ -0,0 +1,32 @@ | |||
1 | import { UserModel } from '../../../models/account/user' | ||
2 | import { PickWith } from '../../utils' | ||
3 | import { MAccount, MAccountDefault, MAccountDefaultChannelDefault, MAccountId, MAccountIdActorId, MAccountUrl } from '../account' | ||
4 | import { MNotificationSetting } from './user-notification-setting' | ||
5 | |||
6 | export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoImports' | 'OAuthTokens'> | ||
7 | |||
8 | export type MUserId = Pick<UserModel, 'id'> | ||
9 | |||
10 | export type MUserWithNotificationSetting = MUser & | ||
11 | PickWith<UserModel, 'NotificationSetting', MNotificationSetting> | ||
12 | |||
13 | export type MUserAccountDefault = MUser & | ||
14 | PickWith<UserModel, 'Account', MAccountDefault> | ||
15 | |||
16 | export type MUserAccount = MUser & | ||
17 | PickWith<UserModel, 'Account', MAccount> | ||
18 | |||
19 | export type MUserAccountId = MUser & | ||
20 | PickWith<UserModel, 'Account', MAccountId> | ||
21 | |||
22 | export type MUserNotifSettingAccount = MUserWithNotificationSetting & MUserAccount | ||
23 | |||
24 | export type MUserDefault = MUser & | ||
25 | MUserWithNotificationSetting & | ||
26 | MUserAccountDefault | ||
27 | |||
28 | export type MUserChannel = MUserWithNotificationSetting & | ||
29 | PickWith<UserModel, 'Account', MAccountDefaultChannelDefault> | ||
30 | |||
31 | export type MUserAccountUrl = MUser & | ||
32 | PickWith<UserModel, 'Account', MAccountUrl & MAccountIdActorId> | ||