From 0283eaac2a8e73006c66df3cf5bb9012e37450e5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 20 Aug 2019 13:52:49 +0200 Subject: Cleanup model types --- server/typings/models/account/account-blocklist.ts | 10 +- server/typings/models/account/account.ts | 69 ++++++---- server/typings/models/account/actor-follow.ts | 56 ++++++-- server/typings/models/account/actor.ts | 93 +++++++++----- server/typings/models/index.d.ts | 1 + server/typings/models/oauth/index.d.ts | 2 + server/typings/models/oauth/oauth-token.ts | 6 +- server/typings/models/server/server-blocklist.ts | 10 +- server/typings/models/server/server.ts | 8 +- server/typings/models/user/index.d.ts | 1 + server/typings/models/user/user-notification.ts | 26 ++-- server/typings/models/user/user.ts | 49 ++++--- server/typings/models/video/index.d.ts | 4 + server/typings/models/video/video-abuse.ts | 14 +- server/typings/models/video/video-blacklist.ts | 8 +- server/typings/models/video/video-caption.ts | 8 +- .../typings/models/video/video-change-ownership.ts | 10 +- server/typings/models/video/video-channels.ts | 95 +++++++++----- server/typings/models/video/video-comment.ts | 38 ++++-- server/typings/models/video/video-file.ts | 8 +- server/typings/models/video/video-import.ts | 23 +++- .../typings/models/video/video-playlist-element.ts | 19 ++- server/typings/models/video/video-playlist.ts | 70 +++++++--- server/typings/models/video/video-rate.ts | 10 +- server/typings/models/video/video-redundancy.ts | 16 ++- server/typings/models/video/video-share.ts | 11 +- .../models/video/video-streaming-playlist.ts | 8 +- server/typings/models/video/video.ts | 141 ++++++++++++++------- 28 files changed, 571 insertions(+), 243 deletions(-) create mode 100644 server/typings/models/oauth/index.d.ts (limited to 'server/typings/models') diff --git a/server/typings/models/account/account-blocklist.ts b/server/typings/models/account/account-blocklist.ts index 6d1771de8..d20d97aa8 100644 --- a/server/typings/models/account/account-blocklist.ts +++ b/server/typings/models/account/account-blocklist.ts @@ -2,10 +2,16 @@ import { AccountBlocklistModel } from '../../../models/account/account-blocklist import { PickWith } from '../../utils' import { MAccountDefault } from './account' +type Use = PickWith + +// ############################################################################ + export type MAccountBlocklist = Omit +// ############################################################################ + export type MAccountBlocklistId = Pick export type MAccountBlocklistAccounts = MAccountBlocklist & - PickWith & - PickWith + Use<'ByAccount', MAccountDefault> & + Use<'BlockedAccount', MAccountDefault> diff --git a/server/typings/models/account/account.ts b/server/typings/models/account/account.ts index f3646d510..9a8784e6b 100644 --- a/server/typings/models/account/account.ts +++ b/server/typings/models/account/account.ts @@ -5,7 +5,8 @@ import { MActorAPI, MActorAudience, MActorDefault, - MActorDefaultLight, MActorId, + MActorDefaultLight, + MActorId, MActorServer, MActorSummary, MActorUrl @@ -14,43 +15,63 @@ import { PickWith } from '../../utils' import { MAccountBlocklistId } from './account-blocklist' import { MChannelDefault } from '@server/typings/models' -export type MAccountId = Pick -export type MAccountIdActor = MAccountId & - PickWith -export type MAccountIdActorId = MAccountId & - PickWith +type Use = PickWith + +// ############################################################################ export type MAccount = Omit +// ############################################################################ + +// Only some attributes +export type MAccountId = Pick +export type MAccountUserId = Pick + +// Only some Actor attributes +export type MAccountUrl = Use<'Actor', MActorUrl> +export type MAccountAudience = Use<'Actor', MActorAudience> + +export type MAccountIdActor = MAccountId & + Use<'Actor', MActorAccountChannelId> + +export type MAccountIdActorId = MAccountId & + Use<'Actor', MActorId> + +// ############################################################################ + // Default scope export type MAccountDefault = MAccount & - PickWith + Use<'Actor', MActorDefault> -export type MAccountDefaultChannelDefault = MAccountDefault & - PickWith +// Default with default association scopes +export type MAccountDefaultChannelDefault = MAccount & + Use<'Actor', MActorDefault> & + Use<'VideoChannels', MChannelDefault[]> +// We don't need some actors attributes export type MAccountLight = MAccount & - PickWith + Use<'Actor', MActorDefaultLight> -export type MAccountUserId = Pick +// ############################################################################ +// Full actor export type MAccountActor = MAccount & - PickWith -export type MAccountServer = MAccountActor & - PickWith + Use<'Actor', MActor> -export type MAccountActorDefault = MAccount & - PickWith +// Full actor with server +export type MAccountServer = MAccount & + Use<'Actor', MActorServer> -export type MAccountSummary = Pick & - PickWith +// ############################################################################ -export type MAccountBlocks = MAccountSummary & - PickWith +// For API + +export type MAccountSummary = Pick & + Use<'Actor', MActorSummary> -export type MAccountAPI = MAccountDefault & - PickWith +export type MAccountSummaryBlocks = MAccountSummary & + Use<'BlockedAccounts', MAccountBlocklistId[]> -export type MAccountUrl = PickWith -export type MAccountAudience = PickWith +export type MAccountAPI = MAccount & + Use<'Actor', MActorAPI> diff --git a/server/typings/models/account/actor-follow.ts b/server/typings/models/account/actor-follow.ts index 96c53d857..87050ac63 100644 --- a/server/typings/models/account/actor-follow.ts +++ b/server/typings/models/account/actor-follow.ts @@ -1,27 +1,55 @@ import { ActorFollowModel } from '../../../models/activitypub/actor-follow' -import { MActor, MActorAccountChannel, MActorChannel, MActorChannelAccount, MActorDefault, MActorHost, MActorUsername } from './actor' +import { + MActor, + MActorAccount, + MActorAccountChannel, + MActorChannel, + MActorChannelAccountActor, + MActorDefault, + MActorHost, + MActorUsername +} from './actor' import { PickWith } from '../../utils' +import { ActorModel } from '@server/models/activitypub/actor' + +type Use = PickWith + +// ############################################################################ export type MActorFollow = Omit +// ############################################################################ + +export type MActorFollowFollowingHost = MActorFollow & + Use<'ActorFollowing', MActorUsername & MActorHost> + +// ############################################################################ + +// With actors or actors default + export type MActorFollowActors = MActorFollow & - PickWith & - PickWith + Use<'ActorFollower', MActor> & + Use<'ActorFollowing', MActor> export type MActorFollowActorsDefault = MActorFollow & - PickWith & - PickWith - -export type MActorFollowActorsDefaultSubscription = MActorFollow & - PickWith & - PickWith + Use<'ActorFollower', MActorDefault> & + Use<'ActorFollowing', MActorDefault> export type MActorFollowFull = MActorFollow & - PickWith & - PickWith + Use<'ActorFollower', MActorAccountChannel> & + Use<'ActorFollowing', MActorAccountChannel> -export type MActorFollowFollowingHost = MActorFollow & - PickWith +// ############################################################################ + +// For subscriptions + +export type MActorFollowActorsDefaultSubscription = MActorFollow & + Use<'ActorFollower', MActorDefault> & + Use<'ActorFollowing', MActorDefault & MActorChannel> + +export type MActorFollowFollowingFullFollowerAccount = MActorFollow & + Use<'ActorFollower', MActorAccount> & + Use<'ActorFollowing', MActorAccountChannel> export type MActorFollowSubscriptions = MActorFollow & - PickWith + Use<'ActorFollowing', MActorChannelAccountActor> diff --git a/server/typings/models/account/actor.ts b/server/typings/models/account/actor.ts index f3e752a98..7d99a433b 100644 --- a/server/typings/models/account/actor.ts +++ b/server/typings/models/account/actor.ts @@ -1,74 +1,103 @@ import { ActorModel } from '../../../models/activitypub/actor' import { PickWith } from '../../utils' -import { MAccount, MAccountActorDefault, MAccountId, MAccountIdActor } from './account' -import { MServerHost, MServerHostBlocks, MServer } from '../server' +import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account' +import { MServer, MServerHost, MServerHostBlocks } from '../server' import { MAvatar } from './avatar' -import { MChannel, MChannelAccountActor, MChannelActorAccountDefault, MChannelId, MChannelIdActor } from '../video' +import { MChannel, MChannelAccountActor, MChannelAccountDefault, MChannelId, MChannelIdActor } from '../video' + +type Use = PickWith + +// ############################################################################ export type MActor = Omit +// ############################################################################ + export type MActorUrl = Pick export type MActorId = Pick export type MActorUsername = Pick -export type MActorHost = PickWith export type MActorFollowersUrl = Pick export type MActorAudience = MActorUrl & MActorFollowersUrl +export type MActorFollowerException = Pick +export type MActorSignature = MActorAccountChannelId export type MActorLight = Omit +// ############################################################################ + +// Some association attributes + +export type MActorHost = Use<'Server', MServerHost> + export type MActorDefaultLight = MActorLight & - MActorHost & - PickWith + Use<'Server', MServerHost> & + Use<'Avatar', MAvatar> export type MActorAccountId = MActor & - PickWith + Use<'Account', MAccountId> export type MActorAccountIdActor = MActor & - PickWith + Use<'Account', MAccountIdActor> export type MActorChannelId = MActor & - PickWith + Use<'VideoChannel', MChannelId> export type MActorChannelIdActor = MActor & - PickWith + Use<'VideoChannel', MChannelIdActor> export type MActorAccountChannelId = MActorAccountId & MActorChannelId export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor +// ############################################################################ + +// Include raw account/channel/server + export type MActorAccount = MActor & - PickWith + Use<'Account', MAccount> export type MActorChannel = MActor & - PickWith + Use<'VideoChannel', MChannel> export type MActorAccountChannel = MActorAccount & MActorChannel -export type MActorChannelAccount = MActor & - PickWith - export type MActorServer = MActor & - PickWith + Use<'Server', MServer> -export type MActorDefault = MActorServer & - PickWith +// ############################################################################ -export type MActorFull = MActorDefault & - PickWith & - PickWith +// Complex actor associations -export type MActorFullActor = MActorDefault & - PickWith & - PickWith +export type MActorDefault = MActor & + Use<'Server', MServer> & + Use<'Avatar', MAvatar> -export type MActorSummary = Pick & - MActorHost & - PickWith +// Actor with channel that is associated to an account and its actor +// Actor -> VideoChannel -> Account -> Actor +export type MActorChannelAccountActor = MActor & + Use<'VideoChannel', MChannelAccountActor> -export type MActorSummaryBlocks = Omit & - PickWith +export type MActorFull = MActor & + Use<'Server', MServer> & + Use<'Avatar', MAvatar> & + Use<'Account', MAccount> & + Use<'VideoChannel', MChannelAccountActor> -export type MActorFollowerException = Pick +// Same than ActorFull, but the account and the channel have their actor +export type MActorFullActor = MActor & + Use<'Server', MServer> & + Use<'Avatar', MAvatar> & + Use<'Account', MAccountDefault> & + Use<'VideoChannel', MChannelAccountDefault> + +// ############################################################################ + +// API + +export type MActorSummary = Pick & + Use<'Server', MServerHost> & + Use<'Avatar', MAvatar> + +export type MActorSummaryBlocks = MActorSummary & + Use<'Server', MServerHostBlocks> export type MActorAPI = Omit - -export type MActorSignature = MActorAccountChannelId diff --git a/server/typings/models/index.d.ts b/server/typings/models/index.d.ts index 39e82e4a8..78b4948ce 100644 --- a/server/typings/models/index.d.ts +++ b/server/typings/models/index.d.ts @@ -1,4 +1,5 @@ export * from './account' +export * from './oauth' export * from './server' export * from './user' export * from './video' diff --git a/server/typings/models/oauth/index.d.ts b/server/typings/models/oauth/index.d.ts new file mode 100644 index 000000000..36b7ea8ca --- /dev/null +++ b/server/typings/models/oauth/index.d.ts @@ -0,0 +1,2 @@ +export * from './oauth-client' +export * from './oauth-token' diff --git a/server/typings/models/oauth/oauth-token.ts b/server/typings/models/oauth/oauth-token.ts index 105ea3df3..af3412925 100644 --- a/server/typings/models/oauth/oauth-token.ts +++ b/server/typings/models/oauth/oauth-token.ts @@ -2,8 +2,12 @@ import { OAuthTokenModel } from '@server/models/oauth/oauth-token' import { PickWith } from '@server/typings/utils' import { MUserAccountUrl } from '@server/typings/models' +type Use = PickWith + +// ############################################################################ + export type MOAuthToken = Omit export type MOAuthTokenUser = MOAuthToken & - PickWith & + Use<'User', MUserAccountUrl> & { user?: MUserAccountUrl } diff --git a/server/typings/models/server/server-blocklist.ts b/server/typings/models/server/server-blocklist.ts index 38065f382..0ca00b5c2 100644 --- a/server/typings/models/server/server-blocklist.ts +++ b/server/typings/models/server/server-blocklist.ts @@ -2,8 +2,14 @@ import { ServerBlocklistModel } from '@server/models/server/server-blocklist' import { PickWith } from '@server/typings/utils' import { MAccountDefault, MServer } from '@server/typings/models' +type Use = PickWith + +// ############################################################################ + export type MServerBlocklist = Omit +// ############################################################################ + export type MServerBlocklistAccountServer = MServerBlocklist & - PickWith & - PickWith + Use<'ByAccount', MAccountDefault> & + Use<'BlockedServer', MServer> diff --git a/server/typings/models/server/server.ts b/server/typings/models/server/server.ts index 6be7bf9bb..c059cff79 100644 --- a/server/typings/models/server/server.ts +++ b/server/typings/models/server/server.ts @@ -2,9 +2,15 @@ import { ServerModel } from '../../../models/server/server' import { PickWith } from '../../utils' import { MAccountBlocklistId } from '../account' +type Use = PickWith + +// ############################################################################ + export type MServer = Omit +// ############################################################################ + export type MServerHost = Pick export type MServerHostBlocks = MServerHost & - PickWith + Use<'BlockedByAccounts', MAccountBlocklistId[]> diff --git a/server/typings/models/user/index.d.ts b/server/typings/models/user/index.d.ts index e3353d0b1..6657b2128 100644 --- a/server/typings/models/user/index.d.ts +++ b/server/typings/models/user/index.d.ts @@ -1,3 +1,4 @@ export * from './user' export * from './user-notification' +export * from './user-notification-setting' export * from './user-video-history' diff --git a/server/typings/models/user/user-notification.ts b/server/typings/models/user/user-notification.ts index b872c5dc5..f9daf5eb2 100644 --- a/server/typings/models/user/user-notification.ts +++ b/server/typings/models/user/user-notification.ts @@ -12,6 +12,10 @@ import { VideoBlacklistModel } from '../../../models/video/video-blacklist' import { VideoImportModel } from '../../../models/video/video-import' import { ActorFollowModel } from '../../../models/activitypub/actor-follow' +type Use = PickWith + +// ############################################################################ + export namespace UserNotificationIncludes { export type VideoInclude = Pick export type VideoIncludeChannel = VideoInclude & @@ -56,14 +60,18 @@ export namespace UserNotificationIncludes { PickWith } -export type UserNotificationModelOnly = Omit -export type UserNotificationModelForApi = UserNotificationModelOnly & - PickWith & - PickWith & - PickWith & - PickWith & - PickWith & - PickWith & - PickWith +// ############################################################################ + +export type UserNotificationModelForApi = MUserNotification & + Use<'Video', UserNotificationIncludes.VideoIncludeChannel> & + Use<'Comment', UserNotificationIncludes.VideoCommentInclude> & + Use<'VideoAbuse', UserNotificationIncludes.VideoAbuseInclude> & + Use<'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> & + Use<'VideoImport', UserNotificationIncludes.VideoImportInclude> & + Use<'ActorFollow', UserNotificationIncludes.ActorFollowInclude> & + Use<'Account', UserNotificationIncludes.AccountIncludeActor> diff --git a/server/typings/models/user/user.ts b/server/typings/models/user/user.ts index b91eed8d9..466cde33b 100644 --- a/server/typings/models/user/user.ts +++ b/server/typings/models/user/user.ts @@ -3,30 +3,49 @@ import { PickWith } from '../../utils' import { MAccount, MAccountDefault, MAccountDefaultChannelDefault, MAccountId, MAccountIdActorId, MAccountUrl } from '../account' import { MNotificationSetting } from './user-notification-setting' +type Use = PickWith + +// ############################################################################ + export type MUser = Omit +// ############################################################################ + export type MUserId = Pick -export type MUserWithNotificationSetting = MUser & - PickWith +// ############################################################################ -export type MUserAccountDefault = MUser & - PickWith +// With account + +export type MUserAccountId = MUser & + Use<'Account', MAccountId> + +export type MUserAccountUrl = MUser & + Use<'Account', MAccountUrl & MAccountIdActorId> export type MUserAccount = MUser & - PickWith + Use<'Account', MAccount> -export type MUserAccountId = MUser & - PickWith +export type MUserAccountDefault = MUser & + Use<'Account', MAccountDefault> -export type MUserNotifSettingAccount = MUserWithNotificationSetting & MUserAccount +// With channel -export type MUserDefault = MUser & - MUserWithNotificationSetting & - MUserAccountDefault +export type MUserNotifSettingChannelDefault = MUser & + Use<'NotificationSetting', MNotificationSetting> & + Use<'Account', MAccountDefaultChannelDefault> -export type MUserChannel = MUserWithNotificationSetting & - PickWith +// With notification settings -export type MUserAccountUrl = MUser & - PickWith +export type MUserWithNotificationSetting = MUser & + Use<'NotificationSetting', MNotificationSetting> + +export type MUserNotifSettingAccount = MUser & + Use<'NotificationSetting', MNotificationSetting> & + Use<'Account', MAccount> + +// Default scope + +export type MUserDefault = MUser & + Use<'NotificationSetting', MNotificationSetting> & + Use<'Account', MAccountDefault> diff --git a/server/typings/models/video/index.d.ts b/server/typings/models/video/index.d.ts index 528e9d274..bd69c8a4b 100644 --- a/server/typings/models/video/index.d.ts +++ b/server/typings/models/video/index.d.ts @@ -5,10 +5,14 @@ export * from './video' export * from './video-abuse' export * from './video-blacklist' export * from './video-caption' +export * from './video-change-ownership' export * from './video-channels' export * from './video-comment' export * from './video-file' +export * from './video-import' export * from './video-playlist' +export * from './video-playlist-element' +export * from './video-rate' export * from './video-redundancy' export * from './video-share' export * from './video-streaming-playlist' diff --git a/server/typings/models/video/video-abuse.ts b/server/typings/models/video/video-abuse.ts index 1667ae55a..0474cac5b 100644 --- a/server/typings/models/video/video-abuse.ts +++ b/server/typings/models/video/video-abuse.ts @@ -3,13 +3,21 @@ import { PickWith } from '../../utils' import { MVideo } from './video' import { MAccountDefault } from '../account' +type Use = PickWith + +// ############################################################################ + export type MVideoAbuse = Omit +// ############################################################################ + export type MVideoAbuseId = Pick export type MVideoAbuseVideo = MVideoAbuse & Pick & - PickWith + Use<'Video', MVideo> -export type MVideoAbuseAccountVideo = MVideoAbuseVideo & - PickWith +export type MVideoAbuseAccountVideo = MVideoAbuse & + Pick & + Use<'Video', MVideo> & + Use<'Account', MAccountDefault> diff --git a/server/typings/models/video/video-blacklist.ts b/server/typings/models/video/video-blacklist.ts index 9242b357d..cc539f95c 100644 --- a/server/typings/models/video/video-blacklist.ts +++ b/server/typings/models/video/video-blacklist.ts @@ -2,10 +2,16 @@ import { VideoBlacklistModel } from '../../../models/video/video-blacklist' import { PickWith } from '@server/typings/utils' import { MVideo } from '@server/typings/models' +type Use = PickWith + +// ############################################################################ + export type MVideoBlacklist = Omit export type MVideoBlacklistLight = Pick export type MVideoBlacklistUnfederated = Pick +// ############################################################################ + export type MVideoBlacklistVideo = MVideoBlacklist & - PickWith + Use<'Video', MVideo> diff --git a/server/typings/models/video/video-caption.ts b/server/typings/models/video/video-caption.ts index 16d8b7392..fe0e664c2 100644 --- a/server/typings/models/video/video-caption.ts +++ b/server/typings/models/video/video-caption.ts @@ -2,9 +2,15 @@ import { VideoCaptionModel } from '../../../models/video/video-caption' import { PickWith } from '@server/typings/utils' import { VideoModel } from '@server/models/video/video' +type Use = PickWith + +// ############################################################################ + export type MVideoCaption = Omit +// ############################################################################ + export type MVideoCaptionLanguage = Pick export type MVideoCaptionVideo = MVideoCaption & - PickWith> + Use<'Video', Pick> diff --git a/server/typings/models/video/video-change-ownership.ts b/server/typings/models/video/video-change-ownership.ts index 718515e2d..0410115c6 100644 --- a/server/typings/models/video/video-change-ownership.ts +++ b/server/typings/models/video/video-change-ownership.ts @@ -2,9 +2,13 @@ import { VideoChangeOwnershipModel } from '@server/models/video/video-change-own import { PickWith } from '@server/typings/utils' import { MAccountDefault, MVideoWithFileThumbnail } from '@server/typings/models' +type Use = PickWith + +// ############################################################################ + export type MVideoChangeOwnership = Omit export type MVideoChangeOwnershipFull = MVideoChangeOwnership & - PickWith & - PickWith & - PickWith + Use<'Initiator', MAccountDefault> & + Use<'NextOwner', MAccountDefault> & + Use<'Video', MVideoWithFileThumbnail> diff --git a/server/typings/models/video/video-channels.ts b/server/typings/models/video/video-channels.ts index e10bd6842..b6506ed9f 100644 --- a/server/typings/models/video/video-channels.ts +++ b/server/typings/models/video/video-channels.ts @@ -1,70 +1,97 @@ -import { FunctionProperties, PickWith } from '../../utils' +import { PickWith } from '../../utils' import { VideoChannelModel } from '../../../models/video/video-channel' import { MAccountActor, MAccountAPI, - MAccountBlocks, MAccountDefault, MAccountLight, + MAccountSummaryBlocks, MAccountUserId, MActor, MActorAccountChannelId, MActorAPI, MActorDefault, - MActorDefaultLight, MActorLight, + MActorDefaultLight, + MActorLight, MActorSummary } from '../account' import { MVideo } from './video' -export type MChannelId = FunctionProperties -export type MChannelIdActor = MChannelId & - PickWith +type Use = PickWith + +// ############################################################################ export type MChannel = Omit +// ############################################################################ + +export type MChannelId = Pick + +// ############################################################################ + +export type MChannelIdActor = MChannelId & + Use<'Actor', MActorAccountChannelId> + export type MChannelUserId = Pick & - PickWith + Use<'Account', MAccountUserId> + +export type MChannelActor = MChannel & + Use<'Actor', MActor> // Default scope export type MChannelDefault = MChannel & - PickWith + Use<'Actor', MActorDefault> + +// ############################################################################ + +// Not all association attributes export type MChannelLight = MChannel & - PickWith + Use<'Actor', MActorDefaultLight> -export type MChannelAccountLight = MChannel & - PickWith & - PickWith +export type MChannelActorLight = MChannel & + Use<'Actor', MActorLight> -export type MChannelSummary = Pick & - PickWith +export type MChannelAccountLight = MChannel & + Use<'Actor', MActorDefaultLight> & + Use<'Account', MAccountLight> -export type MChannelSummaryAccount = MChannelSummary & - PickWith +// ############################################################################ -export type MChannelAPI = MChannel & - PickWith & - PickWith +// Account associations export type MChannelAccountActor = MChannel & - PickWith -export type MChannelAccountDefault = MChannelActor & - PickWith + Use<'Account', MAccountActor> + +export type MChannelAccountDefault = MChannel & + Use<'Actor', MActorDefault> & + Use<'Account', MAccountDefault> +export type MChannelActorAccountActor = MChannel & + Use<'Account', MAccountActor> & + Use<'Actor', MActor> + +// ############################################################################ + +// Videos associations export type MChannelVideos = MChannel & - PickWith + Use<'Videos', MVideo[]> -export type MChannelActor = MChannel & - PickWith -export type MChannelActorLight = MChannel & - PickWith -export type MChannelActorDefault = MChannel & - PickWith +export type MChannelActorAccountDefaultVideos = MChannel & + Use<'Actor', MActorDefault> & + Use<'Account', MAccountDefault> & + Use<'Videos', MVideo[]> + +// ############################################################################ + +// For API -export type MChannelActorAccountActor = MChannelAccountActor & MChannelActor +export type MChannelSummary = Pick & + Use<'Actor', MActorSummary> -export type MChannelActorAccountDefault = MChannel & - PickWith & - PickWith +export type MChannelSummaryAccount = MChannelSummary & + Use<'Account', MAccountSummaryBlocks> -export type MChannelActorAccountDefaultVideos = MChannelActorAccountDefault & MChannelVideos +export type MChannelAPI = MChannel & + Use<'Actor', MActorAPI> & + Use<'Account', MAccountAPI> diff --git a/server/typings/models/video/video-comment.ts b/server/typings/models/video/video-comment.ts index 675613804..187461213 100644 --- a/server/typings/models/video/video-comment.ts +++ b/server/typings/models/video/video-comment.ts @@ -1,29 +1,43 @@ import { VideoCommentModel } from '../../../models/video/video-comment' import { PickWith } from '../../utils' import { MAccountDefault } from '../account' -import { MVideoAccountDefault, MVideoAccountLight, MVideoFeed, MVideoIdUrl } from './video' +import { MVideoAccountLight, MVideoFeed, MVideoIdUrl } from './video' + +type Use = PickWith + +// ############################################################################ export type MComment = Omit export type MCommentId = Pick -export type MCommentAPI = MComment & { totalReplies: number } +// ############################################################################ export type MCommentOwner = MComment & - PickWith + Use<'Account', MAccountDefault> export type MCommentVideo = MComment & - PickWith + Use<'Video', MVideoAccountLight> export type MCommentReply = MComment & - PickWith + Use<'InReplyToVideoComment', MComment> + +export type MCommentOwnerVideo = MComment & + Use<'Account', MAccountDefault> & + Use<'Video', MVideoAccountLight> -export type MCommentOwnerReply = MCommentOwner & MCommentReply -export type MCommentOwnerVideo = MCommentOwner & MCommentVideo -export type MCommentReplyVideo = MCommentReply & MCommentVideo -export type MCommentOwnerVideoReply = MCommentOwnerVideo & MCommentReply +export type MCommentOwnerVideoReply = MComment & + Use<'Account', MAccountDefault> & + Use<'Video', MVideoAccountLight> & + Use<'InReplyToVideoComment', MComment> -export type MCommentOwnerReplyVideoLight = MCommentOwnerReply & - PickWith +export type MCommentOwnerReplyVideoLight = MComment & + Use<'Account', MAccountDefault> & + Use<'InReplyToVideoComment', MComment> & + Use<'Video', MVideoIdUrl> export type MCommentOwnerVideoFeed = MCommentOwner & - PickWith + Use<'Video', MVideoFeed> + +// ############################################################################ + +export type MCommentAPI = MComment & { totalReplies: number } diff --git a/server/typings/models/video/video-file.ts b/server/typings/models/video/video-file.ts index afa659d1f..484351a8d 100644 --- a/server/typings/models/video/video-file.ts +++ b/server/typings/models/video/video-file.ts @@ -3,13 +3,17 @@ import { PickWith, PickWithOpt } from '../../utils' import { MVideo, MVideoUUID } from './video' import { MVideoRedundancyFileUrl } from './video-redundancy' +type Use = PickWith + +// ############################################################################ + export type MVideoFile = Omit export type MVideoFileVideo = MVideoFile & - PickWith + Use<'Video', MVideo> export type MVideoFileVideoUUID = MVideoFile & - PickWith + Use<'Video', MVideoUUID> export type MVideoFileRedundanciesOpt = MVideoFile & PickWithOpt diff --git a/server/typings/models/video/video-import.ts b/server/typings/models/video/video-import.ts index 51be900d6..ada723713 100644 --- a/server/typings/models/video/video-import.ts +++ b/server/typings/models/video/video-import.ts @@ -2,14 +2,23 @@ import { VideoImportModel } from '@server/models/video/video-import' import { PickWith } from '@server/typings/utils' import { MUser, MVideo, MVideoAccountLight, MVideoTag, MVideoThumbnail, MVideoWithFile } from '@server/typings/models' -export type MVideoImport = Omit +type Use = PickWith -export type MVideoImportDefault = MVideoImport & - PickWith & - PickWith +// ############################################################################ -export type MVideoImportDefaultFiles = MVideoImportDefault & - PickWith +export type MVideoImport = Omit export type MVideoImportVideo = MVideoImport & - PickWith + Use<'Video', MVideo> + +// ############################################################################ + +type VideoAssociation = MVideoTag & MVideoAccountLight & MVideoThumbnail + +export type MVideoImportDefault = MVideoImport & + Use<'User', MUser> & + Use<'Video', VideoAssociation> + +export type MVideoImportDefaultFiles = MVideoImport & + Use<'User', MUser> & + Use<'Video', VideoAssociation & MVideoWithFile> diff --git a/server/typings/models/video/video-playlist-element.ts b/server/typings/models/video/video-playlist-element.ts index d1b8a18a0..5a039d7b1 100644 --- a/server/typings/models/video/video-playlist-element.ts +++ b/server/typings/models/video/video-playlist-element.ts @@ -2,14 +2,27 @@ import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-e import { PickWith } from '@server/typings/utils' import { MVideoPlaylistPrivacy, MVideoThumbnail, MVideoUrl } from '@server/typings/models' +type Use = PickWith + +// ############################################################################ + export type MVideoPlaylistElement = Omit + +// ############################################################################ + export type MVideoPlaylistElementId = Pick export type MVideoPlaylistElementLight = Pick +// ############################################################################ + export type MVideoPlaylistVideoThumbnail = MVideoPlaylistElement & - PickWith + Use<'Video', MVideoThumbnail> + +// ############################################################################ + +// For API export type MVideoPlaylistAP = MVideoPlaylistElement & - PickWith & - PickWith + Use<'Video', MVideoUrl> & + Use<'VideoPlaylist', MVideoPlaylistPrivacy> diff --git a/server/typings/models/video/video-playlist.ts b/server/typings/models/video/video-playlist.ts index 825b3391c..633818405 100644 --- a/server/typings/models/video/video-playlist.ts +++ b/server/typings/models/video/video-playlist.ts @@ -5,38 +5,76 @@ import { MThumbnail } from './thumbnail' import { MChannelDefault, MChannelSummary } from './video-channels' import { MVideoPlaylistElementLight } from '@server/typings/models/video/video-playlist-element' +type Use = PickWith + +// ############################################################################ + export type MVideoPlaylist = Omit + +// ############################################################################ + export type MVideoPlaylistId = Pick export type MVideoPlaylistPrivacy = Pick +export type MVideoPlaylistUUID = Pick +export type MVideoPlaylistVideosLength = MVideoPlaylist & { videosLength: number } + +// ############################################################################ + +// With elements export type MVideoPlaylistWithElements = MVideoPlaylist & - PickWith -export type MVideoPlaylistIdWithElements = MVideoPlaylistId & MVideoPlaylistWithElements + Use<'VideoPlaylistElements', MVideoPlaylistElementLight[]> -export type MVideoPlaylistUUID = Pick +export type MVideoPlaylistIdWithElements = MVideoPlaylistId & + Use<'VideoPlaylistElements', MVideoPlaylistElementLight[]> + +// ############################################################################ + +// With account export type MVideoPlaylistOwner = MVideoPlaylist & - PickWith + Use<'OwnerAccount', MAccount> export type MVideoPlaylistOwnerDefault = MVideoPlaylist & - PickWith + Use<'OwnerAccount', MAccountDefault> + +// ############################################################################ + +// With thumbnail export type MVideoPlaylistThumbnail = MVideoPlaylist & - PickWith + Use<'Thumbnail', MThumbnail> -export type MVideoPlaylistAccountThumbnail = MVideoPlaylistOwnerDefault & - PickWith +export type MVideoPlaylistAccountThumbnail = MVideoPlaylist & + Use<'OwnerAccount', MAccountDefault> & + Use<'Thumbnail', MThumbnail> -export type MVideoPlaylistAccountChannelSummary = MVideoPlaylist & - PickWith & - PickWith +// ############################################################################ + +// With channel export type MVideoPlaylistAccountChannelDefault = MVideoPlaylist & - PickWith & - PickWith + Use<'OwnerAccount', MAccountDefault> & + Use<'VideoChannel', MChannelDefault> -export type MVideoPlaylistVideosLength = MVideoPlaylist & { videosLength: number } +// ############################################################################ -export type MVideoPlaylistFullSummary = MVideoPlaylistAccountChannelSummary & MVideoPlaylistThumbnail +// With all associations + +export type MVideoPlaylistFull = MVideoPlaylist & + Use<'OwnerAccount', MAccountDefault> & + Use<'VideoChannel', MChannelDefault> & + Use<'Thumbnail', MThumbnail> + +// ############################################################################ + +// For API + +export type MVideoPlaylistAccountChannelSummary = MVideoPlaylist & + Use<'OwnerAccount', MAccountSummary> & + Use<'VideoChannel', MChannelSummary> -export type MVideoPlaylistFull = MVideoPlaylist & MVideoPlaylistThumbnail & MVideoPlaylistAccountChannelDefault +export type MVideoPlaylistFullSummary = MVideoPlaylist & + Use<'Thumbnail', MThumbnail> & + Use<'OwnerAccount', MAccountSummary> & + Use<'VideoChannel', MChannelSummary> diff --git a/server/typings/models/video/video-rate.ts b/server/typings/models/video/video-rate.ts index 6eefe6362..fc9329993 100644 --- a/server/typings/models/video/video-rate.ts +++ b/server/typings/models/video/video-rate.ts @@ -2,11 +2,15 @@ import { AccountVideoRateModel } from '@server/models/account/account-video-rate import { PickWith } from '@server/typings/utils' import { MAccountAudience, MAccountUrl, MVideo } from '..' +type Use = PickWith + +// ############################################################################ + export type MAccountVideoRate = Omit export type MAccountVideoRateAccountUrl = MAccountVideoRate & - PickWith + Use<'Account', MAccountUrl> export type MAccountVideoRateAccountVideo = MAccountVideoRate & - PickWith & - PickWith + Use<'Account', MAccountAudience> & + Use<'Video', MVideo> diff --git a/server/typings/models/video/video-redundancy.ts b/server/typings/models/video/video-redundancy.ts index ec61bfb68..c25eb9c09 100644 --- a/server/typings/models/video/video-redundancy.ts +++ b/server/typings/models/video/video-redundancy.ts @@ -2,17 +2,25 @@ import { VideoRedundancyModel } from '../../../models/redundancy/video-redundanc import { PickWith } from '@server/typings/utils' import { MStreamingPlaylistVideo, MVideoFile, MVideoFileVideo } from '@server/typings/models' +type Use = PickWith + +// ############################################################################ + export type MVideoRedundancy = Omit export type MVideoRedundancyFileUrl = Pick +// ############################################################################ + export type MVideoRedundancyFile = MVideoRedundancy & - PickWith + Use<'VideoFile', MVideoFile> export type MVideoRedundancyFileVideo = MVideoRedundancy & - PickWith + Use<'VideoFile', MVideoFileVideo> export type MVideoRedundancyStreamingPlaylistVideo = MVideoRedundancy & - PickWith + Use<'VideoStreamingPlaylist', MStreamingPlaylistVideo> -export type MVideoRedundancyVideo = MVideoRedundancyFileVideo | MVideoRedundancyStreamingPlaylistVideo +export type MVideoRedundancyVideo = MVideoRedundancy & + Use<'VideoFile', MVideoFileVideo> & + Use<'VideoStreamingPlaylist', MStreamingPlaylistVideo> diff --git a/server/typings/models/video/video-share.ts b/server/typings/models/video/video-share.ts index 7e8cb8b61..a7a90beeb 100644 --- a/server/typings/models/video/video-share.ts +++ b/server/typings/models/video/video-share.ts @@ -3,10 +3,15 @@ import { PickWith } from '../../utils' import { MActorDefault } from '../account' import { MVideo } from './video' +type Use = PickWith + +// ############################################################################ + export type MVideoShare = Omit export type MVideoShareActor = MVideoShare & - PickWith + Use<'Actor', MActorDefault> -export type MVideoShareFull = MVideoShareActor & - PickWith +export type MVideoShareFull = MVideoShare & + Use<'Actor', MActorDefault> & + Use<'Video', MVideo> diff --git a/server/typings/models/video/video-streaming-playlist.ts b/server/typings/models/video/video-streaming-playlist.ts index 5b6310771..f1b3438b6 100644 --- a/server/typings/models/video/video-streaming-playlist.ts +++ b/server/typings/models/video/video-streaming-playlist.ts @@ -3,10 +3,14 @@ import { PickWith } from '../../utils' import { MVideoRedundancyFileUrl } from './video-redundancy' import { MVideo } from '@server/typings/models' +type Use = PickWith + +// ############################################################################ + export type MStreamingPlaylist = Omit export type MStreamingPlaylistVideo = MStreamingPlaylist & - PickWith + Use<'Video', MVideo> export type MStreamingPlaylistRedundancies = MStreamingPlaylist & - PickWith + Use<'RedundancyVideos', MVideoRedundancyFileUrl[]> diff --git a/server/typings/models/video/video.ts b/server/typings/models/video/video.ts index 0ffd0c302..914eb7f57 100644 --- a/server/typings/models/video/video.ts +++ b/server/typings/models/video/video.ts @@ -1,6 +1,6 @@ import { VideoModel } from '../../../models/video/video' import { PickWith, PickWithOpt } from '../../utils' -import { MChannelAccountLight, MChannelActor, MChannelActorAccountDefault, MChannelUserId } from './video-channels' +import { MChannelAccountDefault, MChannelAccountLight, MChannelActor, MChannelUserId } from './video-channels' import { MTag } from './tag' import { MVideoCaptionLanguage } from './video-caption' import { MStreamingPlaylist, MStreamingPlaylistRedundancies } from './video-streaming-playlist' @@ -10,10 +10,16 @@ import { MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blackl import { MScheduleVideoUpdate } from './schedule-video-update' import { MUserVideoHistoryTime } from '../user/user-video-history' +type Use = PickWith + +// ############################################################################ + export type MVideo = Omit +// ############################################################################ + export type MVideoId = Pick export type MVideoUrl = Pick export type MVideoUUID = Pick @@ -21,83 +27,120 @@ export type MVideoUUID = Pick export type MVideoIdUrl = MVideoId & MVideoUrl export type MVideoFeed = Pick +// ############################################################################ + +// Video raw associations: schedules, video files, tags, thumbnails, captions, streaming playlists + +// "With" to not confuse with the VideoFile model export type MVideoWithFile = MVideo & - PickWith + Use<'VideoFiles', MVideoFile[]> export type MVideoThumbnail = MVideo & - PickWith -export type MVideoIdThumbnail = MVideoThumbnail & MVideoId + Use<'Thumbnails', MThumbnail[]> + +export type MVideoIdThumbnail = MVideoId & + Use<'Thumbnails', MThumbnail[]> + +export type MVideoWithFileThumbnail = MVideo & + Use<'VideoFiles', MVideoFile[]> & + Use<'Thumbnails', MThumbnail[]> export type MVideoTag = MVideo & - PickWith + Use<'Tags', MTag[]> export type MVideoWithSchedule = MVideo & PickWithOpt -export type MVideoWithFileThumbnail = MVideoWithFile & MVideoThumbnail +export type MVideoWithCaptions = MVideo & + Use<'VideoCaptions', MVideoCaptionLanguage[]> -export type MVideoUser = MVideo & - PickWith +export type MVideoWithStreamingPlaylist = MVideo & + Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> -export type MVideoWithCaptions = MVideo & - PickWith +// ############################################################################ + +// Associations with not all their attributes + +export type MVideoUserHistory = MVideo & + Use<'UserVideoHistories', MUserVideoHistoryTime[]> export type MVideoWithBlacklistLight = MVideo & - PickWith + Use<'VideoBlacklist', MVideoBlacklistLight> export type MVideoAccountLight = MVideo & - PickWith + Use<'VideoChannel', MChannelAccountLight> -export type MVideoWithRights = MVideoWithBlacklistLight & MVideoThumbnail & MVideoUser +export type MVideoWithRights = MVideo & + Use<'VideoBlacklist', MVideoBlacklistLight> & + Use<'Thumbnails', MThumbnail[]> & + Use<'VideoChannel', MChannelUserId> -export type MVideoWithStreamingPlaylist = MVideo & - PickWith +// ############################################################################ -export type MVideoWithAllFiles = MVideoWithFileThumbnail & MVideoWithStreamingPlaylist +// All files with some additional associations -export type MVideoAccountAllFiles = MVideoWithAllFiles & MVideoAccountLight & MVideoWithBlacklistLight -export type MVideoAccountAllFilesCaptions = MVideoAccountAllFiles & MVideoWithCaptions +export type MVideoWithAllFiles = MVideo & + Use<'VideoFiles', MVideoFile[]> & + Use<'Thumbnails', MThumbnail[]> & + Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> -export type MVideoUserHistory = MVideo & - PickWith +export type MVideoAccountLightBlacklistAllFiles = MVideo & + Use<'VideoFiles', MVideoFile[]> & + Use<'Thumbnails', MThumbnail[]> & + Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> & + Use<'VideoChannel', MChannelAccountLight> & + Use<'VideoBlacklist', MVideoBlacklistLight> -export type MVideoWithBlacklistThumbnailScheduled = MVideoWithSchedule & MVideoWithBlacklistLight & MVideoWithFileThumbnail +// ############################################################################ + +// With account export type MVideoAccountDefault = MVideo & - PickWith + Use<'VideoChannel', MChannelAccountDefault> -export type MVideoThumbnailAccountDefault = MVideoThumbnail & - PickWith +export type MVideoThumbnailAccountDefault = MVideo & + Use<'Thumbnails', MThumbnail[]> & + Use<'VideoChannel', MChannelAccountDefault> export type MVideoWithChannelActor = MVideo & - PickWith - -export type MVideoFullLight = MVideoThumbnail & - MVideoWithBlacklistLight & - MVideoTag & - MVideoAccountLight & - MVideoUserHistory & - MVideoWithFile & - MVideoWithSchedule & - MVideoWithStreamingPlaylist & - MVideoUserHistory + Use<'VideoChannel', MChannelActor> + +export type MVideoFullLight = MVideo & + Use<'Thumbnails', MThumbnail[]> & + Use<'VideoBlacklist', MVideoBlacklistLight> & + Use<'Tags', MTag[]> & + Use<'VideoChannel', MChannelAccountLight> & + Use<'UserVideoHistories', MUserVideoHistoryTime[]> & + Use<'VideoFiles', MVideoFile[]> & + Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> & + Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> + +// ############################################################################ + +// API export type MVideoAP = MVideo & - MVideoTag & - MVideoAccountLight & - MVideoWithStreamingPlaylist & - MVideoWithCaptions & - PickWith & - PickWith + Use<'Tags', MTag[]> & + Use<'VideoChannel', MChannelAccountLight> & + Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> & + Use<'VideoCaptions', MVideoCaptionLanguage[]> & + Use<'VideoBlacklist', MVideoBlacklistUnfederated> & + Use<'VideoFiles', MVideoFileRedundanciesOpt[]> export type MVideoAPWithoutCaption = Omit export type MVideoDetails = MVideo & - MVideoWithBlacklistLight & - MVideoTag & - MVideoAccountLight & - MVideoWithSchedule & - MVideoThumbnail & - MVideoUserHistory & - PickWith & - PickWith + Use<'VideoBlacklist', MVideoBlacklistLight> & + Use<'Tags', MTag[]> & + Use<'VideoChannel', MChannelAccountLight> & + Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> & + Use<'Thumbnails', MThumbnail[]> & + Use<'UserVideoHistories', MUserVideoHistoryTime[]> & + Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> & + Use<'VideoFiles', MVideoFileRedundanciesOpt[]> + +export type MVideoForUser = MVideo & + Use<'VideoChannel', MChannelAccountDefault> & + Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> & + Use<'VideoBlacklist', MVideoBlacklistLight> & + Use<'Thumbnails', MThumbnail[]> -- cgit v1.2.3