]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - server/typings/models/user/user.ts
Merge branch 'release/1.4.0' into develop
[github/Chocobozzz/PeerTube.git] / server / typings / models / user / user.ts
CommitLineData
453e83ea 1import { UserModel } from '../../../models/account/user'
1ca9f7c3
C
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'
453e83ea 15
0283eaac
C
16type Use<K extends keyof UserModel, M> = PickWith<UserModel, K, M>
17
18// ############################################################################
19
453e83ea
C
20export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoImports' | 'OAuthTokens'>
21
0283eaac
C
22// ############################################################################
23
1ca9f7c3 24export type MUserQuotaUsed = MUser & { videoQuotaUsed?: number, videoQuotaUsedDaily?: number }
453e83ea
C
25export type MUserId = Pick<UserModel, 'id'>
26
0283eaac 27// ############################################################################
453e83ea 28
0283eaac
C
29// With account
30
31export type MUserAccountId = MUser &
32 Use<'Account', MAccountId>
33
34export type MUserAccountUrl = MUser &
35 Use<'Account', MAccountUrl & MAccountIdActorId>
453e83ea
C
36
37export type MUserAccount = MUser &
0283eaac 38 Use<'Account', MAccount>
453e83ea 39
0283eaac
C
40export type MUserAccountDefault = MUser &
41 Use<'Account', MAccountDefault>
453e83ea 42
0283eaac 43// With channel
453e83ea 44
0283eaac
C
45export type MUserNotifSettingChannelDefault = MUser &
46 Use<'NotificationSetting', MNotificationSetting> &
47 Use<'Account', MAccountDefaultChannelDefault>
453e83ea 48
0283eaac 49// With notification settings
453e83ea 50
0283eaac
C
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>
1ca9f7c3
C
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>