diff options
author | Chocobozzz <me@florianbigard.com> | 2019-08-22 10:43:11 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2019-08-22 10:43:11 +0200 |
commit | 5c5e587307a27e173333789b5b5167d35f468b01 (patch) | |
tree | 94e3721caf2e11d38fd5f4112c0fc98da89ac535 /server/typings | |
parent | 1b42d73f44811eec1b7ddd72dd0d640a57c3376c (diff) | |
parent | b5fecbf44192144d1ca27c23a0b53922de288c10 (diff) | |
download | PeerTube-5c5e587307a27e173333789b5b5167d35f468b01.tar.gz PeerTube-5c5e587307a27e173333789b5b5167d35f468b01.tar.zst PeerTube-5c5e587307a27e173333789b5b5167d35f468b01.zip |
Merge branch 'feature/strong-model-types' into develop
Diffstat (limited to 'server/typings')
44 files changed, 1415 insertions, 94 deletions
diff --git a/server/typings/activitypub-processor.model.ts b/server/typings/activitypub-processor.model.ts index 37b2859de..7ed3a65b1 100644 --- a/server/typings/activitypub-processor.model.ts +++ b/server/typings/activitypub-processor.model.ts | |||
@@ -1,10 +1,9 @@ | |||
1 | import { Activity } from '../../shared/models/activitypub' | 1 | import { Activity } from '../../shared/models/activitypub' |
2 | import { ActorModel } from '../models/activitypub/actor' | 2 | import { MActorDefault, MActorSignature } from './models' |
3 | import { SignatureActorModel } from './models' | ||
4 | 3 | ||
5 | export type APProcessorOptions<T extends Activity> = { | 4 | export type APProcessorOptions<T extends Activity> = { |
6 | activity: T | 5 | activity: T |
7 | byActor: SignatureActorModel | 6 | byActor: MActorSignature |
8 | inboxActor?: ActorModel | 7 | inboxActor?: MActorDefault |
9 | fromFetch?: boolean | 8 | fromFetch?: boolean |
10 | } | 9 | } |
diff --git a/server/typings/express.ts b/server/typings/express.ts index f7da55ab0..3cc7c7632 100644 --- a/server/typings/express.ts +++ b/server/typings/express.ts | |||
@@ -1,89 +1,103 @@ | |||
1 | import { VideoChannelModel } from '../models/video/video-channel' | ||
2 | import { VideoPlaylistModel } from '../models/video/video-playlist' | ||
3 | import { VideoPlaylistElementModel } from '../models/video/video-playlist-element' | ||
4 | import { UserModel } from '../models/account/user' | ||
5 | import { VideoModel } from '../models/video/video' | ||
6 | import { AccountModel } from '../models/account/account' | ||
7 | import { VideoChangeOwnershipModel } from '../models/video/video-change-ownership' | ||
8 | import { ActorModel } from '../models/activitypub/actor' | ||
9 | import { VideoCommentModel } from '../models/video/video-comment' | ||
10 | import { VideoShareModel } from '../models/video/video-share' | ||
11 | import { AccountVideoRateModel } from '../models/account/account-video-rate' | ||
12 | import { ActorFollowModel } from '../models/activitypub/actor-follow' | ||
13 | import { ServerModel } from '../models/server/server' | ||
14 | import { VideoFileModel } from '../models/video/video-file' | ||
15 | import { VideoRedundancyModel } from '../models/redundancy/video-redundancy' | ||
16 | import { ServerBlocklistModel } from '../models/server/server-blocklist' | ||
17 | import { AccountBlocklistModel } from '../models/account/account-blocklist' | ||
18 | import { VideoImportModel } from '../models/video/video-import' | ||
19 | import { VideoAbuseModel } from '../models/video/video-abuse' | ||
20 | import { VideoBlacklistModel } from '../models/video/video-blacklist' | ||
21 | import { VideoCaptionModel } from '../models/video/video-caption' | ||
22 | import { VideoStreamingPlaylistModel } from '../models/video/video-streaming-playlist' | ||
23 | import { RegisteredPlugin } from '../lib/plugins/plugin-manager' | 1 | import { RegisteredPlugin } from '../lib/plugins/plugin-manager' |
24 | import { PluginModel } from '../models/server/plugin' | 2 | import { |
25 | import { SignatureActorModel } from './models' | 3 | MAccountDefault, |
4 | MActorAccountChannelId, | ||
5 | MActorFollowActorsDefault, | ||
6 | MActorFollowActorsDefaultSubscription, | ||
7 | MActorFull, | ||
8 | MChannelAccountDefault, | ||
9 | MComment, | ||
10 | MCommentOwnerVideoReply, | ||
11 | MUserDefault, | ||
12 | MVideoAbuse, | ||
13 | MVideoBlacklist, | ||
14 | MVideoCaptionVideo, | ||
15 | MVideoFullLight, | ||
16 | MVideoIdThumbnail, | ||
17 | MVideoRedundancyVideo, | ||
18 | MVideoShareActor, | ||
19 | MVideoThumbnail, | ||
20 | MVideoWithRights | ||
21 | } from './models' | ||
22 | import { MVideoPlaylistFull, MVideoPlaylistFullSummary } from './models/video/video-playlist' | ||
23 | import { MVideoImportDefault } from '@server/typings/models/video/video-import' | ||
24 | import { MAccountBlocklist, MStreamingPlaylist, MVideoFile } from '@server/typings/models' | ||
25 | import { MVideoPlaylistElement, MVideoPlaylistElementVideoUrlPlaylistPrivacy } from '@server/typings/models/video/video-playlist-element' | ||
26 | import { MAccountVideoRateAccountVideo } from '@server/typings/models/video/video-rate' | ||
27 | import { MVideoChangeOwnershipFull } from './models/video/video-change-ownership' | ||
28 | import { MPlugin, MServer } from '@server/typings/models/server' | ||
29 | import { MServerBlocklist } from './models/server/server-blocklist' | ||
30 | import { MOAuthTokenUser } from '@server/typings/models/oauth/oauth-token' | ||
26 | 31 | ||
27 | declare module 'express' { | 32 | declare module 'express' { |
28 | 33 | ||
29 | interface Response { | 34 | interface Response { |
35 | |||
30 | locals: { | 36 | locals: { |
31 | video?: VideoModel | 37 | videoAll?: MVideoFullLight |
32 | videoShare?: VideoShareModel | 38 | onlyVideo?: MVideoThumbnail |
33 | videoFile?: VideoFileModel | 39 | onlyVideoWithRights?: MVideoWithRights |
40 | videoId?: MVideoIdThumbnail | ||
41 | |||
42 | videoShare?: MVideoShareActor | ||
43 | |||
44 | videoFile?: MVideoFile | ||
45 | |||
46 | videoImport?: MVideoImportDefault | ||
47 | |||
48 | videoBlacklist?: MVideoBlacklist | ||
49 | |||
50 | videoCaption?: MVideoCaptionVideo | ||
51 | |||
52 | videoAbuse?: MVideoAbuse | ||
34 | 53 | ||
35 | videoImport?: VideoImportModel | 54 | videoStreamingPlaylist?: MStreamingPlaylist |
36 | 55 | ||
37 | videoBlacklist?: VideoBlacklistModel | 56 | videoChannel?: MChannelAccountDefault |
38 | 57 | ||
39 | videoCaption?: VideoCaptionModel | 58 | videoPlaylistFull?: MVideoPlaylistFull |
59 | videoPlaylistSummary?: MVideoPlaylistFullSummary | ||
40 | 60 | ||
41 | videoAbuse?: VideoAbuseModel | 61 | videoPlaylistElement?: MVideoPlaylistElement |
62 | videoPlaylistElementAP?: MVideoPlaylistElementVideoUrlPlaylistPrivacy | ||
42 | 63 | ||
43 | videoStreamingPlaylist?: VideoStreamingPlaylistModel | 64 | accountVideoRate?: MAccountVideoRateAccountVideo |
44 | 65 | ||
45 | videoChannel?: VideoChannelModel | 66 | videoCommentFull?: MCommentOwnerVideoReply |
67 | videoCommentThread?: MComment | ||
46 | 68 | ||
47 | videoPlaylist?: VideoPlaylistModel | 69 | follow?: MActorFollowActorsDefault |
48 | videoPlaylistElement?: VideoPlaylistElementModel | 70 | subscription?: MActorFollowActorsDefaultSubscription |
49 | 71 | ||
50 | accountVideoRate?: AccountVideoRateModel | 72 | nextOwner?: MAccountDefault |
73 | videoChangeOwnership?: MVideoChangeOwnershipFull | ||
51 | 74 | ||
52 | videoComment?: VideoCommentModel | 75 | account?: MAccountDefault |
53 | videoCommentThread?: VideoCommentModel | ||
54 | 76 | ||
55 | follow?: ActorFollowModel | 77 | actorFull?: MActorFull |
56 | subscription?: ActorFollowModel | ||
57 | 78 | ||
58 | nextOwner?: AccountModel | 79 | user?: MUserDefault |
59 | videoChangeOwnership?: VideoChangeOwnershipModel | ||
60 | account?: AccountModel | ||
61 | actor?: ActorModel | ||
62 | user?: UserModel | ||
63 | 80 | ||
64 | server?: ServerModel | 81 | server?: MServer |
65 | 82 | ||
66 | videoRedundancy?: VideoRedundancyModel | 83 | videoRedundancy?: MVideoRedundancyVideo |
67 | 84 | ||
68 | accountBlock?: AccountBlocklistModel | 85 | accountBlock?: MAccountBlocklist |
69 | serverBlock?: ServerBlocklistModel | 86 | serverBlock?: MServerBlocklist |
70 | 87 | ||
71 | oauth?: { | 88 | oauth?: { |
72 | token: { | 89 | token: MOAuthTokenUser |
73 | User: UserModel | ||
74 | user: UserModel | ||
75 | } | ||
76 | } | 90 | } |
77 | 91 | ||
78 | signature?: { | 92 | signature?: { |
79 | actor: SignatureActorModel | 93 | actor: MActorAccountChannelId |
80 | } | 94 | } |
81 | 95 | ||
82 | authenticated?: boolean | 96 | authenticated?: boolean |
83 | 97 | ||
84 | registeredPlugin?: RegisteredPlugin | 98 | registeredPlugin?: RegisteredPlugin |
85 | 99 | ||
86 | plugin?: PluginModel | 100 | plugin?: MPlugin |
87 | } | 101 | } |
88 | } | 102 | } |
89 | } | 103 | } |
diff --git a/server/typings/models/account/account-blocklist.ts b/server/typings/models/account/account-blocklist.ts new file mode 100644 index 000000000..c9cb55332 --- /dev/null +++ b/server/typings/models/account/account-blocklist.ts | |||
@@ -0,0 +1,25 @@ | |||
1 | import { AccountBlocklistModel } from '../../../models/account/account-blocklist' | ||
2 | import { PickWith } from '../../utils' | ||
3 | import { MAccountDefault, MAccountFormattable } from './account' | ||
4 | |||
5 | type Use<K extends keyof AccountBlocklistModel, M> = PickWith<AccountBlocklistModel, K, M> | ||
6 | |||
7 | // ############################################################################ | ||
8 | |||
9 | export type MAccountBlocklist = Omit<AccountBlocklistModel, 'ByAccount' | 'BlockedAccount'> | ||
10 | |||
11 | // ############################################################################ | ||
12 | |||
13 | export type MAccountBlocklistId = Pick<AccountBlocklistModel, 'id'> | ||
14 | |||
15 | export type MAccountBlocklistAccounts = MAccountBlocklist & | ||
16 | Use<'ByAccount', MAccountDefault> & | ||
17 | Use<'BlockedAccount', MAccountDefault> | ||
18 | |||
19 | // ############################################################################ | ||
20 | |||
21 | // Format for API or AP object | ||
22 | |||
23 | export type MAccountBlocklistFormattable = Pick<MAccountBlocklist, 'createdAt'> & | ||
24 | Use<'ByAccount', MAccountFormattable> & | ||
25 | Use<'BlockedAccount', MAccountFormattable> | ||
diff --git a/server/typings/models/account/account.ts b/server/typings/models/account/account.ts new file mode 100644 index 000000000..ec78fece8 --- /dev/null +++ b/server/typings/models/account/account.ts | |||
@@ -0,0 +1,95 @@ | |||
1 | import { AccountModel } from '../../../models/account/account' | ||
2 | import { | ||
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' | ||
16 | import { FunctionProperties, PickWith } from '../../utils' | ||
17 | import { MAccountBlocklistId } from './account-blocklist' | ||
18 | import { MChannelDefault } from '@server/typings/models' | ||
19 | |||
20 | type Use<K extends keyof AccountModel, M> = PickWith<AccountModel, K, M> | ||
21 | |||
22 | // ############################################################################ | ||
23 | |||
24 | export type MAccount = Omit<AccountModel, 'Actor' | 'User' | 'Application' | 'VideoChannels' | 'VideoPlaylists' | | ||
25 | 'VideoComments' | 'BlockedAccounts'> | ||
26 | |||
27 | // ############################################################################ | ||
28 | |||
29 | // Only some attributes | ||
30 | export type MAccountId = Pick<MAccount, 'id'> | ||
31 | export type MAccountUserId = Pick<MAccount, 'userId'> | ||
32 | |||
33 | // Only some Actor attributes | ||
34 | export type MAccountUrl = Use<'Actor', MActorUrl> | ||
35 | export type MAccountAudience = Use<'Actor', MActorAudience> | ||
36 | |||
37 | export type MAccountIdActor = MAccountId & | ||
38 | Use<'Actor', MActor> | ||
39 | |||
40 | export type MAccountIdActorId = MAccountId & | ||
41 | Use<'Actor', MActorId> | ||
42 | |||
43 | // ############################################################################ | ||
44 | |||
45 | // Default scope | ||
46 | export type MAccountDefault = MAccount & | ||
47 | Use<'Actor', MActorDefault> | ||
48 | |||
49 | // Default with default association scopes | ||
50 | export type MAccountDefaultChannelDefault = MAccount & | ||
51 | Use<'Actor', MActorDefault> & | ||
52 | Use<'VideoChannels', MChannelDefault[]> | ||
53 | |||
54 | // We don't need some actors attributes | ||
55 | export type MAccountLight = MAccount & | ||
56 | Use<'Actor', MActorDefaultLight> | ||
57 | |||
58 | // ############################################################################ | ||
59 | |||
60 | // Full actor | ||
61 | export type MAccountActor = MAccount & | ||
62 | Use<'Actor', MActor> | ||
63 | |||
64 | // Full actor with server | ||
65 | export type MAccountServer = MAccount & | ||
66 | Use<'Actor', MActorServer> | ||
67 | |||
68 | // ############################################################################ | ||
69 | |||
70 | // For API | ||
71 | |||
72 | export type MAccountSummary = FunctionProperties<MAccount> & | ||
73 | Pick<MAccount, 'id' | 'name'> & | ||
74 | Use<'Actor', MActorSummary> | ||
75 | |||
76 | export type MAccountSummaryBlocks = MAccountSummary & | ||
77 | Use<'BlockedAccounts', MAccountBlocklistId[]> | ||
78 | |||
79 | export type MAccountAPI = MAccount & | ||
80 | Use<'Actor', MActorAPI> | ||
81 | |||
82 | // ############################################################################ | ||
83 | |||
84 | // Format for API or AP object | ||
85 | |||
86 | export type MAccountSummaryFormattable = FunctionProperties<MAccount> & | ||
87 | Pick<MAccount, 'id' | 'name'> & | ||
88 | Use<'Actor', MActorSummaryFormattable> | ||
89 | |||
90 | export type MAccountFormattable = FunctionProperties<MAccount> & | ||
91 | Pick<MAccount, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'userId'> & | ||
92 | Use<'Actor', MActorFormattable> | ||
93 | |||
94 | export type MAccountAP = Pick<MAccount, 'name' | 'description'> & | ||
95 | Use<'Actor', MActorAP> | ||
diff --git a/server/typings/models/account/actor-follow.ts b/server/typings/models/account/actor-follow.ts new file mode 100644 index 000000000..17a47b8df --- /dev/null +++ b/server/typings/models/account/actor-follow.ts | |||
@@ -0,0 +1,67 @@ | |||
1 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | ||
2 | import { | ||
3 | MActor, | ||
4 | MActorAccount, | ||
5 | MActorAccountChannel, | ||
6 | MActorChannelAccountActor, | ||
7 | MActorDefault, | ||
8 | MActorFormattable, | ||
9 | MActorHost, | ||
10 | MActorUsername | ||
11 | } from './actor' | ||
12 | import { PickWith } from '../../utils' | ||
13 | import { ActorModel } from '@server/models/activitypub/actor' | ||
14 | import { MChannelDefault } from '@server/typings/models' | ||
15 | |||
16 | type Use<K extends keyof ActorFollowModel, M> = PickWith<ActorFollowModel, K, M> | ||
17 | |||
18 | // ############################################################################ | ||
19 | |||
20 | export type MActorFollow = Omit<ActorFollowModel, 'ActorFollower' | 'ActorFollowing'> | ||
21 | |||
22 | // ############################################################################ | ||
23 | |||
24 | export type MActorFollowFollowingHost = MActorFollow & | ||
25 | Use<'ActorFollowing', MActorUsername & MActorHost> | ||
26 | |||
27 | // ############################################################################ | ||
28 | |||
29 | // With actors or actors default | ||
30 | |||
31 | export type MActorFollowActors = MActorFollow & | ||
32 | Use<'ActorFollower', MActor> & | ||
33 | Use<'ActorFollowing', MActor> | ||
34 | |||
35 | export type MActorFollowActorsDefault = MActorFollow & | ||
36 | Use<'ActorFollower', MActorDefault> & | ||
37 | Use<'ActorFollowing', MActorDefault> | ||
38 | |||
39 | export type MActorFollowFull = MActorFollow & | ||
40 | Use<'ActorFollower', MActorAccountChannel> & | ||
41 | Use<'ActorFollowing', MActorAccountChannel> | ||
42 | |||
43 | // ############################################################################ | ||
44 | |||
45 | // For subscriptions | ||
46 | |||
47 | type SubscriptionFollowing = MActorDefault & | ||
48 | PickWith<ActorModel, 'VideoChannel', MChannelDefault> | ||
49 | |||
50 | export type MActorFollowActorsDefaultSubscription = MActorFollow & | ||
51 | Use<'ActorFollower', MActorDefault> & | ||
52 | Use<'ActorFollowing', SubscriptionFollowing> | ||
53 | |||
54 | export type MActorFollowFollowingFullFollowerAccount = MActorFollow & | ||
55 | Use<'ActorFollower', MActorAccount> & | ||
56 | Use<'ActorFollowing', MActorAccountChannel> | ||
57 | |||
58 | export type MActorFollowSubscriptions = MActorFollow & | ||
59 | Use<'ActorFollowing', MActorChannelAccountActor> | ||
60 | |||
61 | // ############################################################################ | ||
62 | |||
63 | // Format for API or AP object | ||
64 | |||
65 | export type MActorFollowFormattable = Pick<MActorFollow, 'id' | 'score' | 'state' | 'createdAt' | 'updatedAt'> & | ||
66 | Use<'ActorFollower', MActorFormattable> & | ||
67 | Use<'ActorFollowing', MActorFormattable> | ||
diff --git a/server/typings/models/account/actor.ts b/server/typings/models/account/actor.ts new file mode 100644 index 000000000..d4bcac4a3 --- /dev/null +++ b/server/typings/models/account/actor.ts | |||
@@ -0,0 +1,121 @@ | |||
1 | import { ActorModel } from '../../../models/activitypub/actor' | ||
2 | import { FunctionProperties, PickWith, PickWithOpt } from '../../utils' | ||
3 | import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account' | ||
4 | import { MServer, MServerHost, MServerHostBlocks, MServerRedundancyAllowed } from '../server' | ||
5 | import { MAvatar, MAvatarFormattable } from './avatar' | ||
6 | import { MChannel, MChannelAccountActor, MChannelAccountDefault, MChannelId, MChannelIdActor } from '../video' | ||
7 | |||
8 | type Use<K extends keyof ActorModel, M> = PickWith<ActorModel, K, M> | ||
9 | |||
10 | // ############################################################################ | ||
11 | |||
12 | export type MActor = Omit<ActorModel, 'Account' | 'VideoChannel' | 'ActorFollowing' | 'Avatar' | 'ActorFollowers' | 'Server'> | ||
13 | |||
14 | // ############################################################################ | ||
15 | |||
16 | export type MActorUrl = Pick<MActor, 'url'> | ||
17 | export type MActorId = Pick<MActor, 'id'> | ||
18 | export type MActorUsername = Pick<MActor, 'preferredUsername'> | ||
19 | |||
20 | export type MActorFollowersUrl = Pick<MActor, 'followersUrl'> | ||
21 | export type MActorAudience = MActorUrl & MActorFollowersUrl | ||
22 | export type MActorFollowerException = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl'> | ||
23 | export type MActorSignature = MActorAccountChannelId | ||
24 | |||
25 | export type MActorLight = Omit<MActor, 'privateKey' | 'privateKey'> | ||
26 | |||
27 | // ############################################################################ | ||
28 | |||
29 | // Some association attributes | ||
30 | |||
31 | export type MActorHost = Use<'Server', MServerHost> | ||
32 | export type MActorRedundancyAllowedOpt = PickWithOpt<ActorModel, 'Server', MServerRedundancyAllowed> | ||
33 | |||
34 | export type MActorDefaultLight = MActorLight & | ||
35 | Use<'Server', MServerHost> & | ||
36 | Use<'Avatar', MAvatar> | ||
37 | |||
38 | export type MActorAccountId = MActor & | ||
39 | Use<'Account', MAccountId> | ||
40 | export type MActorAccountIdActor = MActor & | ||
41 | Use<'Account', MAccountIdActor> | ||
42 | |||
43 | export type MActorChannelId = MActor & | ||
44 | Use<'VideoChannel', MChannelId> | ||
45 | export type MActorChannelIdActor = MActor & | ||
46 | Use<'VideoChannel', MChannelIdActor> | ||
47 | |||
48 | export type MActorAccountChannelId = MActorAccountId & MActorChannelId | ||
49 | export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor | ||
50 | |||
51 | // ############################################################################ | ||
52 | |||
53 | // Include raw account/channel/server | ||
54 | |||
55 | export type MActorAccount = MActor & | ||
56 | Use<'Account', MAccount> | ||
57 | |||
58 | export type MActorChannel = MActor & | ||
59 | Use<'VideoChannel', MChannel> | ||
60 | |||
61 | export type MActorAccountChannel = MActorAccount & MActorChannel | ||
62 | |||
63 | export type MActorServer = MActor & | ||
64 | Use<'Server', MServer> | ||
65 | |||
66 | // ############################################################################ | ||
67 | |||
68 | // Complex actor associations | ||
69 | |||
70 | export type MActorDefault = MActor & | ||
71 | Use<'Server', MServer> & | ||
72 | Use<'Avatar', MAvatar> | ||
73 | |||
74 | // Actor with channel that is associated to an account and its actor | ||
75 | // Actor -> VideoChannel -> Account -> Actor | ||
76 | export type MActorChannelAccountActor = MActor & | ||
77 | Use<'VideoChannel', MChannelAccountActor> | ||
78 | |||
79 | export type MActorFull = MActor & | ||
80 | Use<'Server', MServer> & | ||
81 | Use<'Avatar', MAvatar> & | ||
82 | Use<'Account', MAccount> & | ||
83 | Use<'VideoChannel', MChannelAccountActor> | ||
84 | |||
85 | // Same than ActorFull, but the account and the channel have their actor | ||
86 | export type MActorFullActor = MActor & | ||
87 | Use<'Server', MServer> & | ||
88 | Use<'Avatar', MAvatar> & | ||
89 | Use<'Account', MAccountDefault> & | ||
90 | Use<'VideoChannel', MChannelAccountDefault> | ||
91 | |||
92 | // ############################################################################ | ||
93 | |||
94 | // API | ||
95 | |||
96 | export type MActorSummary = FunctionProperties<MActor> & | ||
97 | Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> & | ||
98 | Use<'Server', MServerHost> & | ||
99 | Use<'Avatar', MAvatar> | ||
100 | |||
101 | export type MActorSummaryBlocks = MActorSummary & | ||
102 | Use<'Server', MServerHostBlocks> | ||
103 | |||
104 | export type MActorAPI = Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' | | ||
105 | 'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'> | ||
106 | |||
107 | // ############################################################################ | ||
108 | |||
109 | // Format for API or AP object | ||
110 | |||
111 | export type MActorSummaryFormattable = FunctionProperties<MActor> & | ||
112 | Pick<MActor, 'url' | 'preferredUsername'> & | ||
113 | Use<'Server', MServerHost> & | ||
114 | Use<'Avatar', MAvatarFormattable> | ||
115 | |||
116 | export type MActorFormattable = MActorSummaryFormattable & | ||
117 | Pick<MActor, 'id' | 'followingCount' | 'followersCount' | 'createdAt' | 'updatedAt'> & | ||
118 | Use<'Server', MServerHost & Partial<Pick<MServer, 'redundancyAllowed'>>> | ||
119 | |||
120 | export type MActorAP = MActor & | ||
121 | Use<'Avatar', MAvatar> | ||
diff --git a/server/typings/models/account/avatar.ts b/server/typings/models/account/avatar.ts new file mode 100644 index 000000000..8af6cc787 --- /dev/null +++ b/server/typings/models/account/avatar.ts | |||
@@ -0,0 +1,11 @@ | |||
1 | import { AvatarModel } from '../../../models/avatar/avatar' | ||
2 | import { FunctionProperties } from '@server/typings/utils' | ||
3 | |||
4 | export type MAvatar = AvatarModel | ||
5 | |||
6 | // ############################################################################ | ||
7 | |||
8 | // Format for API or AP object | ||
9 | |||
10 | export type MAvatarFormattable = FunctionProperties<MAvatar> & | ||
11 | Pick<MAvatar, 'filename' | 'createdAt' | 'updatedAt'> | ||
diff --git a/server/typings/models/account/index.d.ts b/server/typings/models/account/index.d.ts new file mode 100644 index 000000000..513c09c40 --- /dev/null +++ b/server/typings/models/account/index.d.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | export * from './account' | ||
2 | export * from './account-blocklist' | ||
3 | export * from './actor' | ||
4 | export * from './actor-follow' | ||
5 | export * from './avatar' | ||
diff --git a/server/typings/models/actor-follow.ts b/server/typings/models/actor-follow.ts deleted file mode 100644 index 952ef877b..000000000 --- a/server/typings/models/actor-follow.ts +++ /dev/null | |||
@@ -1,8 +0,0 @@ | |||
1 | import { ActorFollowModel } from '../../models/activitypub/actor-follow' | ||
2 | import { ActorModelOnly } from './actor' | ||
3 | |||
4 | export type ActorFollowModelOnly = Omit<ActorFollowModel, 'ActorFollower' | 'ActorFollowing'> | ||
5 | export type ActorFollowModelLight = ActorFollowModelOnly & { | ||
6 | ActorFollower: ActorModelOnly | ||
7 | ActorFollowing: ActorModelOnly | ||
8 | } | ||
diff --git a/server/typings/models/actor.ts b/server/typings/models/actor.ts deleted file mode 100644 index 2656c7b66..000000000 --- a/server/typings/models/actor.ts +++ /dev/null | |||
@@ -1,22 +0,0 @@ | |||
1 | import { ActorModel } from '../../models/activitypub/actor' | ||
2 | import { VideoChannelModel } from '../../models/video/video-channel' | ||
3 | import { AccountModel } from '../../models/account/account' | ||
4 | import { FunctionProperties } from '../utils' | ||
5 | |||
6 | export type VideoChannelModelId = FunctionProperties<VideoChannelModel> | ||
7 | export type AccountModelId = FunctionProperties<AccountModel> | Pick<AccountModel, 'id'> | ||
8 | |||
9 | export type VideoChannelModelIdActor = VideoChannelModelId & Pick<VideoChannelModel, 'Actor'> | ||
10 | export type AccountModelIdActor = AccountModelId & Pick<AccountModel, 'Actor'> | ||
11 | |||
12 | export type ActorModelUrl = Pick<ActorModel, 'url'> | ||
13 | export type ActorModelOnly = Omit<ActorModel, 'Account' | 'VideoChannel' | 'ActorFollowing' | 'Avatar' | 'ActorFollowers' | 'Server'> | ||
14 | export type ActorModelId = Pick<ActorModelOnly, 'id'> | ||
15 | |||
16 | export type SignatureActorModel = ActorModelOnly & { | ||
17 | VideoChannel: VideoChannelModelIdActor | ||
18 | |||
19 | Account: AccountModelIdActor | ||
20 | } | ||
21 | |||
22 | export type ActorFollowerException = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl'> | ||
diff --git a/server/typings/models/index.d.ts b/server/typings/models/index.d.ts index c90656965..78b4948ce 100644 --- a/server/typings/models/index.d.ts +++ b/server/typings/models/index.d.ts | |||
@@ -1 +1,5 @@ | |||
1 | export * from './actor' | 1 | export * from './account' |
2 | export * from './oauth' | ||
3 | export * from './server' | ||
4 | export * from './user' | ||
5 | 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 @@ | |||
1 | export * from './oauth-client' | ||
2 | export * from './oauth-token' | ||
diff --git a/server/typings/models/oauth/oauth-client.ts b/server/typings/models/oauth/oauth-client.ts new file mode 100644 index 000000000..904a07863 --- /dev/null +++ b/server/typings/models/oauth/oauth-client.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | import { OAuthClientModel } from '@server/models/oauth/oauth-client' | ||
2 | |||
3 | export type MOAuthClient = Omit<OAuthClientModel, 'OAuthTokens'> | ||
diff --git a/server/typings/models/oauth/oauth-token.ts b/server/typings/models/oauth/oauth-token.ts new file mode 100644 index 000000000..af3412925 --- /dev/null +++ b/server/typings/models/oauth/oauth-token.ts | |||
@@ -0,0 +1,13 @@ | |||
1 | import { OAuthTokenModel } from '@server/models/oauth/oauth-token' | ||
2 | import { PickWith } from '@server/typings/utils' | ||
3 | import { MUserAccountUrl } from '@server/typings/models' | ||
4 | |||
5 | type Use<K extends keyof OAuthTokenModel, M> = PickWith<OAuthTokenModel, K, M> | ||
6 | |||
7 | // ############################################################################ | ||
8 | |||
9 | export type MOAuthToken = Omit<OAuthTokenModel, 'User' | 'OAuthClients'> | ||
10 | |||
11 | export type MOAuthTokenUser = MOAuthToken & | ||
12 | Use<'User', MUserAccountUrl> & | ||
13 | { user?: MUserAccountUrl } | ||
diff --git a/server/typings/models/server/index.d.ts b/server/typings/models/server/index.d.ts new file mode 100644 index 000000000..c853795ad --- /dev/null +++ b/server/typings/models/server/index.d.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export * from './plugin' | ||
2 | export * from './server' | ||
3 | export * from './server-blocklist' | ||
diff --git a/server/typings/models/server/plugin.ts b/server/typings/models/server/plugin.ts new file mode 100644 index 000000000..94674c318 --- /dev/null +++ b/server/typings/models/server/plugin.ts | |||
@@ -0,0 +1,10 @@ | |||
1 | import { PluginModel } from '@server/models/server/plugin' | ||
2 | |||
3 | export type MPlugin = PluginModel | ||
4 | |||
5 | // ############################################################################ | ||
6 | |||
7 | // Format for API or AP object | ||
8 | |||
9 | export type MPluginFormattable = Pick<MPlugin, 'name' | 'type' | 'version' | 'latestVersion' | 'enabled' | 'uninstalled' | ||
10 | | 'peertubeEngine' | 'description' | 'homepage' | 'settings' | 'createdAt' | 'updatedAt'> | ||
diff --git a/server/typings/models/server/server-blocklist.ts b/server/typings/models/server/server-blocklist.ts new file mode 100644 index 000000000..c81f604f5 --- /dev/null +++ b/server/typings/models/server/server-blocklist.ts | |||
@@ -0,0 +1,23 @@ | |||
1 | import { ServerBlocklistModel } from '@server/models/server/server-blocklist' | ||
2 | import { PickWith } from '@server/typings/utils' | ||
3 | import { MAccountDefault, MAccountFormattable, MServer, MServerFormattable } from '@server/typings/models' | ||
4 | |||
5 | type Use<K extends keyof ServerBlocklistModel, M> = PickWith<ServerBlocklistModel, K, M> | ||
6 | |||
7 | // ############################################################################ | ||
8 | |||
9 | export type MServerBlocklist = Omit<ServerBlocklistModel, 'ByAccount' | 'BlockedServer'> | ||
10 | |||
11 | // ############################################################################ | ||
12 | |||
13 | export type MServerBlocklistAccountServer = MServerBlocklist & | ||
14 | Use<'ByAccount', MAccountDefault> & | ||
15 | Use<'BlockedServer', MServer> | ||
16 | |||
17 | // ############################################################################ | ||
18 | |||
19 | // Format for API or AP object | ||
20 | |||
21 | export type MServerBlocklistFormattable = Pick<MServerBlocklist, 'createdAt'> & | ||
22 | Use<'ByAccount', MAccountFormattable> & | ||
23 | Use<'BlockedServer', MServerFormattable> | ||
diff --git a/server/typings/models/server/server.ts b/server/typings/models/server/server.ts new file mode 100644 index 000000000..190cc0c28 --- /dev/null +++ b/server/typings/models/server/server.ts | |||
@@ -0,0 +1,24 @@ | |||
1 | import { ServerModel } from '../../../models/server/server' | ||
2 | import { FunctionProperties, PickWith } from '../../utils' | ||
3 | import { MAccountBlocklistId } from '../account' | ||
4 | |||
5 | type Use<K extends keyof ServerModel, M> = PickWith<ServerModel, K, M> | ||
6 | |||
7 | // ############################################################################ | ||
8 | |||
9 | export type MServer = Omit<ServerModel, 'Actors' | 'BlockedByAccounts'> | ||
10 | |||
11 | // ############################################################################ | ||
12 | |||
13 | export type MServerHost = Pick<MServer, 'host'> | ||
14 | export type MServerRedundancyAllowed = Pick<MServer, 'redundancyAllowed'> | ||
15 | |||
16 | export type MServerHostBlocks = MServerHost & | ||
17 | Use<'BlockedByAccounts', MAccountBlocklistId[]> | ||
18 | |||
19 | // ############################################################################ | ||
20 | |||
21 | // Format for API or AP object | ||
22 | |||
23 | export type MServerFormattable = FunctionProperties<MServer> & | ||
24 | Pick<MServer, 'host'> | ||
diff --git a/server/typings/models/user/index.d.ts b/server/typings/models/user/index.d.ts new file mode 100644 index 000000000..6657b2128 --- /dev/null +++ b/server/typings/models/user/index.d.ts | |||
@@ -0,0 +1,4 @@ | |||
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 new file mode 100644 index 000000000..c674add1b --- /dev/null +++ b/server/typings/models/user/user-notification-setting.ts | |||
@@ -0,0 +1,9 @@ | |||
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 new file mode 100644 index 000000000..f9daf5eb2 --- /dev/null +++ b/server/typings/models/user/user-notification.ts | |||
@@ -0,0 +1,77 @@ | |||
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 | type Use<K extends keyof UserNotificationModel, M> = PickWith<UserNotificationModel, K, M> | ||
16 | |||
17 | // ############################################################################ | ||
18 | |||
19 | export namespace UserNotificationIncludes { | ||
20 | export type VideoInclude = Pick<VideoModel, 'id' | 'uuid' | 'name'> | ||
21 | export type VideoIncludeChannel = VideoInclude & | ||
22 | PickWith<VideoModel, 'VideoChannel', VideoChannelIncludeActor> | ||
23 | |||
24 | export type ActorInclude = Pick<ActorModel, 'preferredUsername' | 'getHost'> & | ||
25 | PickWith<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>> & | ||
26 | PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>> | ||
27 | |||
28 | export type VideoChannelInclude = Pick<VideoChannelModel, 'id' | 'name' | 'getDisplayName'> | ||
29 | export type VideoChannelIncludeActor = VideoChannelInclude & | ||
30 | PickWith<VideoChannelModel, 'Actor', ActorInclude> | ||
31 | |||
32 | export type AccountInclude = Pick<AccountModel, 'id' | 'name' | 'getDisplayName'> | ||
33 | export type AccountIncludeActor = AccountInclude & | ||
34 | PickWith<AccountModel, 'Actor', ActorInclude> | ||
35 | |||
36 | export type VideoCommentInclude = Pick<VideoCommentModel, 'id' | 'originCommentId' | 'getThreadId'> & | ||
37 | PickWith<VideoCommentModel, 'Account', AccountIncludeActor> & | ||
38 | PickWith<VideoCommentModel, 'Video', VideoInclude> | ||
39 | |||
40 | export type VideoAbuseInclude = Pick<VideoAbuseModel, 'id'> & | ||
41 | PickWith<VideoAbuseModel, 'Video', VideoInclude> | ||
42 | |||
43 | export type VideoBlacklistInclude = Pick<VideoBlacklistModel, 'id'> & | ||
44 | PickWith<VideoAbuseModel, 'Video', VideoInclude> | ||
45 | |||
46 | export type VideoImportInclude = Pick<VideoImportModel, 'id' | 'magnetUri' | 'targetUrl' | 'torrentName'> & | ||
47 | PickWith<VideoImportModel, 'Video', VideoInclude> | ||
48 | |||
49 | export type ActorFollower = Pick<ActorModel, 'preferredUsername' | 'getHost'> & | ||
50 | PickWith<ActorModel, 'Account', AccountInclude> & | ||
51 | PickWith<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>> & | ||
52 | PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>> | ||
53 | |||
54 | export type ActorFollowing = Pick<ActorModel, 'preferredUsername'> & | ||
55 | PickWith<ActorModel, 'VideoChannel', VideoChannelInclude> & | ||
56 | PickWith<ActorModel, 'Account', AccountInclude> | ||
57 | |||
58 | export type ActorFollowInclude = Pick<ActorFollowModel, 'id' | 'state'> & | ||
59 | PickWith<ActorFollowModel, 'ActorFollower', ActorFollower> & | ||
60 | PickWith<ActorFollowModel, 'ActorFollowing', ActorFollowing> | ||
61 | } | ||
62 | |||
63 | // ############################################################################ | ||
64 | |||
65 | export type MUserNotification = Omit<UserNotificationModel, 'User' | 'Video' | 'Comment' | 'VideoAbuse' | 'VideoBlacklist' | | ||
66 | 'VideoImport' | 'Account' | 'ActorFollow'> | ||
67 | |||
68 | // ############################################################################ | ||
69 | |||
70 | export type UserNotificationModelForApi = MUserNotification & | ||
71 | Use<'Video', UserNotificationIncludes.VideoIncludeChannel> & | ||
72 | Use<'Comment', UserNotificationIncludes.VideoCommentInclude> & | ||
73 | Use<'VideoAbuse', UserNotificationIncludes.VideoAbuseInclude> & | ||
74 | Use<'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> & | ||
75 | Use<'VideoImport', UserNotificationIncludes.VideoImportInclude> & | ||
76 | Use<'ActorFollow', UserNotificationIncludes.ActorFollowInclude> & | ||
77 | Use<'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..52d6d4a05 --- /dev/null +++ b/server/typings/models/user/user.ts | |||
@@ -0,0 +1,70 @@ | |||
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 '@server/typings/models' | ||
15 | |||
16 | type Use<K extends keyof UserModel, M> = PickWith<UserModel, K, M> | ||
17 | |||
18 | // ############################################################################ | ||
19 | |||
20 | export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoImports' | 'OAuthTokens'> | ||
21 | |||
22 | // ############################################################################ | ||
23 | |||
24 | export type MUserQuotaUsed = MUser & { videoQuotaUsed?: number, videoQuotaUsedDaily?: number } | ||
25 | export type MUserId = Pick<UserModel, 'id'> | ||
26 | |||
27 | // ############################################################################ | ||
28 | |||
29 | // With account | ||
30 | |||
31 | export type MUserAccountId = MUser & | ||
32 | Use<'Account', MAccountId> | ||
33 | |||
34 | export type MUserAccountUrl = MUser & | ||
35 | Use<'Account', MAccountUrl & MAccountIdActorId> | ||
36 | |||
37 | export type MUserAccount = MUser & | ||
38 | Use<'Account', MAccount> | ||
39 | |||
40 | export type MUserAccountDefault = MUser & | ||
41 | Use<'Account', MAccountDefault> | ||
42 | |||
43 | // With channel | ||
44 | |||
45 | export type MUserNotifSettingChannelDefault = MUser & | ||
46 | Use<'NotificationSetting', MNotificationSetting> & | ||
47 | Use<'Account', MAccountDefaultChannelDefault> | ||
48 | |||
49 | // With notification settings | ||
50 | |||
51 | export type MUserWithNotificationSetting = MUser & | ||
52 | Use<'NotificationSetting', MNotificationSetting> | ||
53 | |||
54 | export type MUserNotifSettingAccount = MUser & | ||
55 | Use<'NotificationSetting', MNotificationSetting> & | ||
56 | Use<'Account', MAccount> | ||
57 | |||
58 | // Default scope | ||
59 | |||
60 | export type MUserDefault = MUser & | ||
61 | Use<'NotificationSetting', MNotificationSetting> & | ||
62 | Use<'Account', MAccountDefault> | ||
63 | |||
64 | // ############################################################################ | ||
65 | |||
66 | // Format for API or AP object | ||
67 | |||
68 | export type MUserFormattable = MUserQuotaUsed & | ||
69 | Use<'Account', MAccountFormattable & PickWithOpt<AccountModel, 'VideoChannels', MChannelFormattable[]>> & | ||
70 | PickWithOpt<UserModel, 'NotificationSetting', MNotificationSettingFormattable> | ||
diff --git a/server/typings/models/video-share.ts b/server/typings/models/video-share.ts deleted file mode 100644 index 1406749d2..000000000 --- a/server/typings/models/video-share.ts +++ /dev/null | |||
@@ -1,3 +0,0 @@ | |||
1 | import { VideoShareModel } from '../../models/video/video-share' | ||
2 | |||
3 | export type VideoShareModelOnly = Omit<VideoShareModel, 'Actor' | 'Video'> | ||
diff --git a/server/typings/models/video/index.d.ts b/server/typings/models/video/index.d.ts new file mode 100644 index 000000000..bd69c8a4b --- /dev/null +++ b/server/typings/models/video/index.d.ts | |||
@@ -0,0 +1,18 @@ | |||
1 | export * from './schedule-video-update' | ||
2 | export * from './tag' | ||
3 | export * from './thumbnail' | ||
4 | export * from './video' | ||
5 | export * from './video-abuse' | ||
6 | export * from './video-blacklist' | ||
7 | export * from './video-caption' | ||
8 | export * from './video-change-ownership' | ||
9 | export * from './video-channels' | ||
10 | export * from './video-comment' | ||
11 | export * from './video-file' | ||
12 | export * from './video-import' | ||
13 | export * from './video-playlist' | ||
14 | export * from './video-playlist-element' | ||
15 | export * from './video-rate' | ||
16 | export * from './video-redundancy' | ||
17 | export * from './video-share' | ||
18 | export * from './video-streaming-playlist' | ||
diff --git a/server/typings/models/video/schedule-video-update.ts b/server/typings/models/video/schedule-video-update.ts new file mode 100644 index 000000000..ada9af06e --- /dev/null +++ b/server/typings/models/video/schedule-video-update.ts | |||
@@ -0,0 +1,9 @@ | |||
1 | import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' | ||
2 | |||
3 | export type MScheduleVideoUpdate = Omit<ScheduleVideoUpdateModel, 'Video'> | ||
4 | |||
5 | // ############################################################################ | ||
6 | |||
7 | // Format for API or AP object | ||
8 | |||
9 | export type MScheduleVideoUpdateFormattable = Pick<MScheduleVideoUpdate, 'updateAt' | 'privacy'> | ||
diff --git a/server/typings/models/video/tag.ts b/server/typings/models/video/tag.ts new file mode 100644 index 000000000..64a68873e --- /dev/null +++ b/server/typings/models/video/tag.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | import { TagModel } from '../../../models/video/tag' | ||
2 | |||
3 | export type MTag = Omit<TagModel, 'Videos'> | ||
diff --git a/server/typings/models/video/thumbnail.ts b/server/typings/models/video/thumbnail.ts new file mode 100644 index 000000000..c03ba55ac --- /dev/null +++ b/server/typings/models/video/thumbnail.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | import { ThumbnailModel } from '../../../models/video/thumbnail' | ||
2 | |||
3 | export type MThumbnail = Omit<ThumbnailModel, 'Video' | 'VideoPlaylist'> | ||
diff --git a/server/typings/models/video/video-abuse.ts b/server/typings/models/video/video-abuse.ts new file mode 100644 index 000000000..e38c3f586 --- /dev/null +++ b/server/typings/models/video/video-abuse.ts | |||
@@ -0,0 +1,31 @@ | |||
1 | import { VideoAbuseModel } from '../../../models/video/video-abuse' | ||
2 | import { PickWith } from '../../utils' | ||
3 | import { MVideo } from './video' | ||
4 | import { MAccountDefault, MAccountFormattable } from '../account' | ||
5 | |||
6 | type Use<K extends keyof VideoAbuseModel, M> = PickWith<VideoAbuseModel, K, M> | ||
7 | |||
8 | // ############################################################################ | ||
9 | |||
10 | export type MVideoAbuse = Omit<VideoAbuseModel, 'Account' | 'Video' | 'toActivityPubObject'> | ||
11 | |||
12 | // ############################################################################ | ||
13 | |||
14 | export type MVideoAbuseId = Pick<VideoAbuseModel, 'id'> | ||
15 | |||
16 | export type MVideoAbuseVideo = MVideoAbuse & | ||
17 | Pick<VideoAbuseModel, 'toActivityPubObject'> & | ||
18 | Use<'Video', MVideo> | ||
19 | |||
20 | export type MVideoAbuseAccountVideo = MVideoAbuse & | ||
21 | Pick<VideoAbuseModel, 'toActivityPubObject'> & | ||
22 | Use<'Video', MVideo> & | ||
23 | Use<'Account', MAccountDefault> | ||
24 | |||
25 | // ############################################################################ | ||
26 | |||
27 | // Format for API or AP object | ||
28 | |||
29 | export type MVideoAbuseFormattable = MVideoAbuse & | ||
30 | Use<'Account', MAccountFormattable> & | ||
31 | Use<'Video', Pick<MVideo, 'id' | 'uuid' | 'name'>> | ||
diff --git a/server/typings/models/video/video-blacklist.ts b/server/typings/models/video/video-blacklist.ts new file mode 100644 index 000000000..1dedfa37f --- /dev/null +++ b/server/typings/models/video/video-blacklist.ts | |||
@@ -0,0 +1,24 @@ | |||
1 | import { VideoBlacklistModel } from '../../../models/video/video-blacklist' | ||
2 | import { PickWith } from '@server/typings/utils' | ||
3 | import { MVideo, MVideoFormattable } from '@server/typings/models' | ||
4 | |||
5 | type Use<K extends keyof VideoBlacklistModel, M> = PickWith<VideoBlacklistModel, K, M> | ||
6 | |||
7 | // ############################################################################ | ||
8 | |||
9 | export type MVideoBlacklist = Omit<VideoBlacklistModel, 'Video'> | ||
10 | |||
11 | export type MVideoBlacklistLight = Pick<MVideoBlacklist, 'id' | 'reason' | 'unfederated'> | ||
12 | export type MVideoBlacklistUnfederated = Pick<MVideoBlacklist, 'unfederated'> | ||
13 | |||
14 | // ############################################################################ | ||
15 | |||
16 | export type MVideoBlacklistVideo = MVideoBlacklist & | ||
17 | Use<'Video', MVideo> | ||
18 | |||
19 | // ############################################################################ | ||
20 | |||
21 | // Format for API or AP object | ||
22 | |||
23 | export type MVideoBlacklistFormattable = MVideoBlacklist & | ||
24 | Use<'Video', MVideoFormattable> | ||
diff --git a/server/typings/models/video/video-caption.ts b/server/typings/models/video/video-caption.ts new file mode 100644 index 000000000..7cb2a2ad3 --- /dev/null +++ b/server/typings/models/video/video-caption.ts | |||
@@ -0,0 +1,24 @@ | |||
1 | import { VideoCaptionModel } from '../../../models/video/video-caption' | ||
2 | import { FunctionProperties, PickWith } from '@server/typings/utils' | ||
3 | import { MVideo, MVideoUUID } from '@server/typings/models' | ||
4 | |||
5 | type Use<K extends keyof VideoCaptionModel, M> = PickWith<VideoCaptionModel, K, M> | ||
6 | |||
7 | // ############################################################################ | ||
8 | |||
9 | export type MVideoCaption = Omit<VideoCaptionModel, 'Video'> | ||
10 | |||
11 | // ############################################################################ | ||
12 | |||
13 | export type MVideoCaptionLanguage = Pick<MVideoCaption, 'language'> | ||
14 | |||
15 | export type MVideoCaptionVideo = MVideoCaption & | ||
16 | Use<'Video', Pick<MVideo, 'id' | 'remote' | 'uuid'>> | ||
17 | |||
18 | // ############################################################################ | ||
19 | |||
20 | // Format for API or AP object | ||
21 | |||
22 | export type MVideoCaptionFormattable = FunctionProperties<MVideoCaption> & | ||
23 | Pick<MVideoCaption, 'language'> & | ||
24 | Use<'Video', MVideoUUID> | ||
diff --git a/server/typings/models/video/video-change-ownership.ts b/server/typings/models/video/video-change-ownership.ts new file mode 100644 index 000000000..72634cdb2 --- /dev/null +++ b/server/typings/models/video/video-change-ownership.ts | |||
@@ -0,0 +1,23 @@ | |||
1 | import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership' | ||
2 | import { PickWith } from '@server/typings/utils' | ||
3 | import { MAccountDefault, MAccountFormattable, MVideo, MVideoWithFileThumbnail } from '@server/typings/models' | ||
4 | |||
5 | type Use<K extends keyof VideoChangeOwnershipModel, M> = PickWith<VideoChangeOwnershipModel, K, M> | ||
6 | |||
7 | // ############################################################################ | ||
8 | |||
9 | export type MVideoChangeOwnership = Omit<VideoChangeOwnershipModel, 'Initiator' | 'NextOwner' | 'Video'> | ||
10 | |||
11 | export type MVideoChangeOwnershipFull = MVideoChangeOwnership & | ||
12 | Use<'Initiator', MAccountDefault> & | ||
13 | Use<'NextOwner', MAccountDefault> & | ||
14 | Use<'Video', MVideoWithFileThumbnail> | ||
15 | |||
16 | // ############################################################################ | ||
17 | |||
18 | // Format for API or AP object | ||
19 | |||
20 | export type MVideoChangeOwnershipFormattable = Pick<MVideoChangeOwnership, 'id' | 'status' | 'createdAt'> & | ||
21 | Use<'Initiator', MAccountFormattable> & | ||
22 | Use<'NextOwner', MAccountFormattable> & | ||
23 | Use<'Video', Pick<MVideo, 'id' | 'uuid' | 'url' | 'name'>> | ||
diff --git a/server/typings/models/video/video-channels.ts b/server/typings/models/video/video-channels.ts new file mode 100644 index 000000000..292d0ac95 --- /dev/null +++ b/server/typings/models/video/video-channels.ts | |||
@@ -0,0 +1,126 @@ | |||
1 | import { FunctionProperties, PickWith, PickWithOpt } from '../../utils' | ||
2 | import { VideoChannelModel } from '../../../models/video/video-channel' | ||
3 | import { | ||
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' | ||
24 | import { MVideo } from './video' | ||
25 | |||
26 | type Use<K extends keyof VideoChannelModel, M> = PickWith<VideoChannelModel, K, M> | ||
27 | |||
28 | // ############################################################################ | ||
29 | |||
30 | export type MChannel = Omit<VideoChannelModel, 'Actor' | 'Account' | 'Videos' | 'VideoPlaylists'> | ||
31 | |||
32 | // ############################################################################ | ||
33 | |||
34 | export type MChannelId = Pick<MChannel, 'id'> | ||
35 | |||
36 | // ############################################################################ | ||
37 | |||
38 | export type MChannelIdActor = MChannelId & | ||
39 | Use<'Actor', MActorAccountChannelId> | ||
40 | |||
41 | export type MChannelUserId = Pick<MChannel, 'accountId'> & | ||
42 | Use<'Account', MAccountUserId> | ||
43 | |||
44 | export type MChannelActor = MChannel & | ||
45 | Use<'Actor', MActor> | ||
46 | |||
47 | export type MChannelUrl = Use<'Actor', MActorUrl> | ||
48 | |||
49 | // Default scope | ||
50 | export type MChannelDefault = MChannel & | ||
51 | Use<'Actor', MActorDefault> | ||
52 | |||
53 | // ############################################################################ | ||
54 | |||
55 | // Not all association attributes | ||
56 | |||
57 | export type MChannelLight = MChannel & | ||
58 | Use<'Actor', MActorDefaultLight> | ||
59 | |||
60 | export type MChannelActorLight = MChannel & | ||
61 | Use<'Actor', MActorLight> | ||
62 | |||
63 | export type MChannelAccountLight = MChannel & | ||
64 | Use<'Actor', MActorDefaultLight> & | ||
65 | Use<'Account', MAccountLight> | ||
66 | |||
67 | // ############################################################################ | ||
68 | |||
69 | // Account associations | ||
70 | |||
71 | export type MChannelAccountActor = MChannel & | ||
72 | Use<'Account', MAccountActor> | ||
73 | |||
74 | export type MChannelAccountDefault = MChannel & | ||
75 | Use<'Actor', MActorDefault> & | ||
76 | Use<'Account', MAccountDefault> | ||
77 | |||
78 | export type MChannelActorAccountActor = MChannel & | ||
79 | Use<'Account', MAccountActor> & | ||
80 | Use<'Actor', MActor> | ||
81 | |||
82 | // ############################################################################ | ||
83 | |||
84 | // Videos associations | ||
85 | export type MChannelVideos = MChannel & | ||
86 | Use<'Videos', MVideo[]> | ||
87 | |||
88 | export type MChannelActorAccountDefaultVideos = MChannel & | ||
89 | Use<'Actor', MActorDefault> & | ||
90 | Use<'Account', MAccountDefault> & | ||
91 | Use<'Videos', MVideo[]> | ||
92 | |||
93 | // ############################################################################ | ||
94 | |||
95 | // For API | ||
96 | |||
97 | export type MChannelSummary = FunctionProperties<MChannel> & | ||
98 | Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> & | ||
99 | Use<'Actor', MActorSummary> | ||
100 | |||
101 | export type MChannelSummaryAccount = MChannelSummary & | ||
102 | Use<'Account', MAccountSummaryBlocks> | ||
103 | |||
104 | export type MChannelAPI = MChannel & | ||
105 | Use<'Actor', MActorAPI> & | ||
106 | Use<'Account', MAccountAPI> | ||
107 | |||
108 | // ############################################################################ | ||
109 | |||
110 | // Format for API or AP object | ||
111 | |||
112 | export type MChannelSummaryFormattable = FunctionProperties<MChannel> & | ||
113 | Pick<MChannel, 'id' | 'name'> & | ||
114 | Use<'Actor', MActorSummaryFormattable> | ||
115 | |||
116 | export type MChannelAccountSummaryFormattable = MChannelSummaryFormattable & | ||
117 | Use<'Account', MAccountSummaryFormattable> | ||
118 | |||
119 | export type MChannelFormattable = FunctionProperties<MChannel> & | ||
120 | Pick<MChannel, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'support'> & | ||
121 | Use<'Actor', MActorFormattable> & | ||
122 | PickWithOpt<VideoChannelModel, 'Account', MAccountFormattable> | ||
123 | |||
124 | export type MChannelAP = Pick<MChannel, 'name' | 'description' | 'support'> & | ||
125 | Use<'Actor', MActorAP> & | ||
126 | Use<'Account', MAccountUrl> | ||
diff --git a/server/typings/models/video/video-comment.ts b/server/typings/models/video/video-comment.ts new file mode 100644 index 000000000..4fd1c29e8 --- /dev/null +++ b/server/typings/models/video/video-comment.ts | |||
@@ -0,0 +1,57 @@ | |||
1 | import { VideoCommentModel } from '../../../models/video/video-comment' | ||
2 | import { PickWith, PickWithOpt } from '../../utils' | ||
3 | import { MAccountDefault, MAccountFormattable, MAccountUrl, MActorUrl } from '../account' | ||
4 | import { MVideoAccountLight, MVideoFeed, MVideoIdUrl, MVideoUrl } from './video' | ||
5 | |||
6 | type Use<K extends keyof VideoCommentModel, M> = PickWith<VideoCommentModel, K, M> | ||
7 | |||
8 | // ############################################################################ | ||
9 | |||
10 | export type MComment = Omit<VideoCommentModel, 'OriginVideoComment' | 'InReplyToVideoComment' | 'Video' | 'Account'> | ||
11 | export type MCommentTotalReplies = MComment & { totalReplies?: number } | ||
12 | export type MCommentId = Pick<MComment, 'id'> | ||
13 | export type MCommentUrl = Pick<MComment, 'url'> | ||
14 | |||
15 | // ############################################################################ | ||
16 | |||
17 | export type MCommentOwner = MComment & | ||
18 | Use<'Account', MAccountDefault> | ||
19 | |||
20 | export type MCommentVideo = MComment & | ||
21 | Use<'Video', MVideoAccountLight> | ||
22 | |||
23 | export type MCommentReply = MComment & | ||
24 | Use<'InReplyToVideoComment', MComment> | ||
25 | |||
26 | export type MCommentOwnerVideo = MComment & | ||
27 | Use<'Account', MAccountDefault> & | ||
28 | Use<'Video', MVideoAccountLight> | ||
29 | |||
30 | export type MCommentOwnerVideoReply = MComment & | ||
31 | Use<'Account', MAccountDefault> & | ||
32 | Use<'Video', MVideoAccountLight> & | ||
33 | Use<'InReplyToVideoComment', MComment> | ||
34 | |||
35 | export type MCommentOwnerReplyVideoLight = MComment & | ||
36 | Use<'Account', MAccountDefault> & | ||
37 | Use<'InReplyToVideoComment', MComment> & | ||
38 | Use<'Video', MVideoIdUrl> | ||
39 | |||
40 | export type MCommentOwnerVideoFeed = MCommentOwner & | ||
41 | Use<'Video', MVideoFeed> | ||
42 | |||
43 | // ############################################################################ | ||
44 | |||
45 | export type MCommentAPI = MComment & { totalReplies: number } | ||
46 | |||
47 | // ############################################################################ | ||
48 | |||
49 | // Format for API or AP object | ||
50 | |||
51 | export type MCommentFormattable = MCommentTotalReplies & | ||
52 | Use<'Account', MAccountFormattable> | ||
53 | |||
54 | export type MCommentAP = MComment & | ||
55 | Use<'Account', MAccountUrl> & | ||
56 | PickWithOpt<VideoCommentModel, 'Video', MVideoUrl> & | ||
57 | PickWithOpt<VideoCommentModel, 'InReplyToVideoComment', MCommentUrl> | ||
diff --git a/server/typings/models/video/video-file.ts b/server/typings/models/video/video-file.ts new file mode 100644 index 000000000..484351a8d --- /dev/null +++ b/server/typings/models/video/video-file.ts | |||
@@ -0,0 +1,19 @@ | |||
1 | import { VideoFileModel } from '../../../models/video/video-file' | ||
2 | import { PickWith, PickWithOpt } from '../../utils' | ||
3 | import { MVideo, MVideoUUID } from './video' | ||
4 | import { MVideoRedundancyFileUrl } from './video-redundancy' | ||
5 | |||
6 | type Use<K extends keyof VideoFileModel, M> = PickWith<VideoFileModel, K, M> | ||
7 | |||
8 | // ############################################################################ | ||
9 | |||
10 | export type MVideoFile = Omit<VideoFileModel, 'Video' | 'RedundancyVideos'> | ||
11 | |||
12 | export type MVideoFileVideo = MVideoFile & | ||
13 | Use<'Video', MVideo> | ||
14 | |||
15 | export type MVideoFileVideoUUID = MVideoFile & | ||
16 | Use<'Video', MVideoUUID> | ||
17 | |||
18 | export type MVideoFileRedundanciesOpt = MVideoFile & | ||
19 | PickWithOpt<VideoFileModel, 'RedundancyVideos', MVideoRedundancyFileUrl[]> | ||
diff --git a/server/typings/models/video/video-import.ts b/server/typings/models/video/video-import.ts new file mode 100644 index 000000000..c6a1c5b66 --- /dev/null +++ b/server/typings/models/video/video-import.ts | |||
@@ -0,0 +1,31 @@ | |||
1 | import { VideoImportModel } from '@server/models/video/video-import' | ||
2 | import { PickWith, PickWithOpt } from '@server/typings/utils' | ||
3 | import { MUser, MVideo, MVideoAccountLight, MVideoFormattable, MVideoTag, MVideoThumbnail, MVideoWithFile } from '@server/typings/models' | ||
4 | |||
5 | type Use<K extends keyof VideoImportModel, M> = PickWith<VideoImportModel, K, M> | ||
6 | |||
7 | // ############################################################################ | ||
8 | |||
9 | export type MVideoImport = Omit<VideoImportModel, 'User' | 'Video'> | ||
10 | |||
11 | export type MVideoImportVideo = MVideoImport & | ||
12 | Use<'Video', MVideo> | ||
13 | |||
14 | // ############################################################################ | ||
15 | |||
16 | type VideoAssociation = MVideoTag & MVideoAccountLight & MVideoThumbnail | ||
17 | |||
18 | export type MVideoImportDefault = MVideoImport & | ||
19 | Use<'User', MUser> & | ||
20 | Use<'Video', VideoAssociation> | ||
21 | |||
22 | export type MVideoImportDefaultFiles = MVideoImport & | ||
23 | Use<'User', MUser> & | ||
24 | Use<'Video', VideoAssociation & MVideoWithFile> | ||
25 | |||
26 | // ############################################################################ | ||
27 | |||
28 | // Format for API or AP object | ||
29 | |||
30 | export type MVideoImportFormattable = MVideoImport & | ||
31 | PickWithOpt<VideoImportModel, 'Video', MVideoFormattable & MVideoTag> | ||
diff --git a/server/typings/models/video/video-playlist-element.ts b/server/typings/models/video/video-playlist-element.ts new file mode 100644 index 000000000..7b1b993ce --- /dev/null +++ b/server/typings/models/video/video-playlist-element.ts | |||
@@ -0,0 +1,34 @@ | |||
1 | import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element' | ||
2 | import { PickWith } from '@server/typings/utils' | ||
3 | import { MVideoFormattable, MVideoPlaylistPrivacy, MVideoThumbnail, MVideoUrl } from '@server/typings/models' | ||
4 | |||
5 | type Use<K extends keyof VideoPlaylistElementModel, M> = PickWith<VideoPlaylistElementModel, K, M> | ||
6 | |||
7 | // ############################################################################ | ||
8 | |||
9 | export type MVideoPlaylistElement = Omit<VideoPlaylistElementModel, 'VideoPlaylist' | 'Video'> | ||
10 | |||
11 | // ############################################################################ | ||
12 | |||
13 | export type MVideoPlaylistElementId = Pick<MVideoPlaylistElement, 'id'> | ||
14 | |||
15 | export type MVideoPlaylistElementLight = Pick<MVideoPlaylistElement, 'id' | 'videoId' | 'startTimestamp' | 'stopTimestamp'> | ||
16 | |||
17 | // ############################################################################ | ||
18 | |||
19 | export type MVideoPlaylistVideoThumbnail = MVideoPlaylistElement & | ||
20 | Use<'Video', MVideoThumbnail> | ||
21 | |||
22 | export type MVideoPlaylistElementVideoUrlPlaylistPrivacy = MVideoPlaylistElement & | ||
23 | Use<'Video', MVideoUrl> & | ||
24 | Use<'VideoPlaylist', MVideoPlaylistPrivacy> | ||
25 | |||
26 | // ############################################################################ | ||
27 | |||
28 | // Format for API or AP object | ||
29 | |||
30 | export type MVideoPlaylistElementFormattable = MVideoPlaylistElement & | ||
31 | Use<'Video', MVideoFormattable> | ||
32 | |||
33 | export type MVideoPlaylistElementAP = MVideoPlaylistElement & | ||
34 | Use<'Video', MVideoUrl> | ||
diff --git a/server/typings/models/video/video-playlist.ts b/server/typings/models/video/video-playlist.ts new file mode 100644 index 000000000..a40c7aca9 --- /dev/null +++ b/server/typings/models/video/video-playlist.ts | |||
@@ -0,0 +1,92 @@ | |||
1 | import { VideoPlaylistModel } from '../../../models/video/video-playlist' | ||
2 | import { PickWith } from '../../utils' | ||
3 | import { MAccount, MAccountDefault, MAccountSummary, MAccountSummaryFormattable } from '../account' | ||
4 | import { MThumbnail } from './thumbnail' | ||
5 | import { MChannelDefault, MChannelSummary, MChannelSummaryFormattable, MChannelUrl } from './video-channels' | ||
6 | import { MVideoPlaylistElementLight } from '@server/typings/models/video/video-playlist-element' | ||
7 | |||
8 | type Use<K extends keyof VideoPlaylistModel, M> = PickWith<VideoPlaylistModel, K, M> | ||
9 | |||
10 | // ############################################################################ | ||
11 | |||
12 | export type MVideoPlaylist = Omit<VideoPlaylistModel, 'OwnerAccount' | 'VideoChannel' | 'VideoPlaylistElements' | 'Thumbnail'> | ||
13 | |||
14 | // ############################################################################ | ||
15 | |||
16 | export type MVideoPlaylistId = Pick<MVideoPlaylist, 'id'> | ||
17 | export type MVideoPlaylistPrivacy = Pick<MVideoPlaylist, 'privacy'> | ||
18 | export type MVideoPlaylistUUID = Pick<MVideoPlaylist, 'uuid'> | ||
19 | export type MVideoPlaylistVideosLength = MVideoPlaylist & { videosLength?: number } | ||
20 | |||
21 | // ############################################################################ | ||
22 | |||
23 | // With elements | ||
24 | |||
25 | export type MVideoPlaylistWithElements = MVideoPlaylist & | ||
26 | Use<'VideoPlaylistElements', MVideoPlaylistElementLight[]> | ||
27 | |||
28 | export type MVideoPlaylistIdWithElements = MVideoPlaylistId & | ||
29 | Use<'VideoPlaylistElements', MVideoPlaylistElementLight[]> | ||
30 | |||
31 | // ############################################################################ | ||
32 | |||
33 | // With account | ||
34 | |||
35 | export type MVideoPlaylistOwner = MVideoPlaylist & | ||
36 | Use<'OwnerAccount', MAccount> | ||
37 | |||
38 | export type MVideoPlaylistOwnerDefault = MVideoPlaylist & | ||
39 | Use<'OwnerAccount', MAccountDefault> | ||
40 | |||
41 | // ############################################################################ | ||
42 | |||
43 | // With thumbnail | ||
44 | |||
45 | export type MVideoPlaylistThumbnail = MVideoPlaylist & | ||
46 | Use<'Thumbnail', MThumbnail> | ||
47 | |||
48 | export type MVideoPlaylistAccountThumbnail = MVideoPlaylist & | ||
49 | Use<'OwnerAccount', MAccountDefault> & | ||
50 | Use<'Thumbnail', MThumbnail> | ||
51 | |||
52 | // ############################################################################ | ||
53 | |||
54 | // With channel | ||
55 | |||
56 | export type MVideoPlaylistAccountChannelDefault = MVideoPlaylist & | ||
57 | Use<'OwnerAccount', MAccountDefault> & | ||
58 | Use<'VideoChannel', MChannelDefault> | ||
59 | |||
60 | // ############################################################################ | ||
61 | |||
62 | // With all associations | ||
63 | |||
64 | export type MVideoPlaylistFull = MVideoPlaylist & | ||
65 | Use<'OwnerAccount', MAccountDefault> & | ||
66 | Use<'VideoChannel', MChannelDefault> & | ||
67 | Use<'Thumbnail', MThumbnail> | ||
68 | |||
69 | // ############################################################################ | ||
70 | |||
71 | // For API | ||
72 | |||
73 | export type MVideoPlaylistAccountChannelSummary = MVideoPlaylist & | ||
74 | Use<'OwnerAccount', MAccountSummary> & | ||
75 | Use<'VideoChannel', MChannelSummary> | ||
76 | |||
77 | export type MVideoPlaylistFullSummary = MVideoPlaylist & | ||
78 | Use<'Thumbnail', MThumbnail> & | ||
79 | Use<'OwnerAccount', MAccountSummary> & | ||
80 | Use<'VideoChannel', MChannelSummary> | ||
81 | |||
82 | // ############################################################################ | ||
83 | |||
84 | // Format for API or AP object | ||
85 | |||
86 | export type MVideoPlaylistFormattable = MVideoPlaylistVideosLength & | ||
87 | Use<'OwnerAccount', MAccountSummaryFormattable> & | ||
88 | Use<'VideoChannel', MChannelSummaryFormattable> | ||
89 | |||
90 | export type MVideoPlaylistAP = MVideoPlaylist & | ||
91 | Use<'Thumbnail', MThumbnail> & | ||
92 | Use<'VideoChannel', MChannelUrl> | ||
diff --git a/server/typings/models/video/video-rate.ts b/server/typings/models/video/video-rate.ts new file mode 100644 index 000000000..2ff8a625b --- /dev/null +++ b/server/typings/models/video/video-rate.ts | |||
@@ -0,0 +1,23 @@ | |||
1 | import { AccountVideoRateModel } from '@server/models/account/account-video-rate' | ||
2 | import { PickWith } from '@server/typings/utils' | ||
3 | import { MAccountAudience, MAccountUrl, MVideo, MVideoFormattable } from '..' | ||
4 | |||
5 | type Use<K extends keyof AccountVideoRateModel, M> = PickWith<AccountVideoRateModel, K, M> | ||
6 | |||
7 | // ############################################################################ | ||
8 | |||
9 | export type MAccountVideoRate = Omit<AccountVideoRateModel, 'Video' | 'Account'> | ||
10 | |||
11 | export type MAccountVideoRateAccountUrl = MAccountVideoRate & | ||
12 | Use<'Account', MAccountUrl> | ||
13 | |||
14 | export type MAccountVideoRateAccountVideo = MAccountVideoRate & | ||
15 | Use<'Account', MAccountAudience> & | ||
16 | Use<'Video', MVideo> | ||
17 | |||
18 | // ############################################################################ | ||
19 | |||
20 | // Format for API or AP object | ||
21 | |||
22 | export type MAccountVideoRateFormattable = Pick<MAccountVideoRate, 'type'> & | ||
23 | Use<'Video', MVideoFormattable> | ||
diff --git a/server/typings/models/video/video-redundancy.ts b/server/typings/models/video/video-redundancy.ts new file mode 100644 index 000000000..f3846afd7 --- /dev/null +++ b/server/typings/models/video/video-redundancy.ts | |||
@@ -0,0 +1,38 @@ | |||
1 | import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy' | ||
2 | import { PickWith, PickWithOpt } from '@server/typings/utils' | ||
3 | import { MStreamingPlaylistVideo, MVideoFile, MVideoFileVideo, MVideoUrl } from '@server/typings/models' | ||
4 | import { VideoStreamingPlaylist } from '../../../../shared/models/videos/video-streaming-playlist.model' | ||
5 | import { VideoStreamingPlaylistModel } from '@server/models/video/video-streaming-playlist' | ||
6 | import { VideoFile } from '../../../../shared/models/videos' | ||
7 | import { VideoFileModel } from '@server/models/video/video-file' | ||
8 | |||
9 | type Use<K extends keyof VideoRedundancyModel, M> = PickWith<VideoRedundancyModel, K, M> | ||
10 | |||
11 | // ############################################################################ | ||
12 | |||
13 | export type MVideoRedundancy = Omit<VideoRedundancyModel, 'VideoFile' | 'VideoStreamingPlaylist' | 'Actor'> | ||
14 | |||
15 | export type MVideoRedundancyFileUrl = Pick<MVideoRedundancy, 'fileUrl'> | ||
16 | |||
17 | // ############################################################################ | ||
18 | |||
19 | export type MVideoRedundancyFile = MVideoRedundancy & | ||
20 | Use<'VideoFile', MVideoFile> | ||
21 | |||
22 | export type MVideoRedundancyFileVideo = MVideoRedundancy & | ||
23 | Use<'VideoFile', MVideoFileVideo> | ||
24 | |||
25 | export type MVideoRedundancyStreamingPlaylistVideo = MVideoRedundancy & | ||
26 | Use<'VideoStreamingPlaylist', MStreamingPlaylistVideo> | ||
27 | |||
28 | export type MVideoRedundancyVideo = MVideoRedundancy & | ||
29 | Use<'VideoFile', MVideoFileVideo> & | ||
30 | Use<'VideoStreamingPlaylist', MStreamingPlaylistVideo> | ||
31 | |||
32 | // ############################################################################ | ||
33 | |||
34 | // Format for API or AP object | ||
35 | |||
36 | export type MVideoRedundancyAP = MVideoRedundancy & | ||
37 | PickWithOpt<VideoRedundancyModel, 'VideoFile', MVideoFile & PickWith<VideoFileModel, 'Video', MVideoUrl>> & | ||
38 | PickWithOpt<VideoRedundancyModel, 'VideoStreamingPlaylist', PickWith<VideoStreamingPlaylistModel, 'Video', MVideoUrl>> | ||
diff --git a/server/typings/models/video/video-share.ts b/server/typings/models/video/video-share.ts new file mode 100644 index 000000000..a7a90beeb --- /dev/null +++ b/server/typings/models/video/video-share.ts | |||
@@ -0,0 +1,17 @@ | |||
1 | import { VideoShareModel } from '../../../models/video/video-share' | ||
2 | import { PickWith } from '../../utils' | ||
3 | import { MActorDefault } from '../account' | ||
4 | import { MVideo } from './video' | ||
5 | |||
6 | type Use<K extends keyof VideoShareModel, M> = PickWith<VideoShareModel, K, M> | ||
7 | |||
8 | // ############################################################################ | ||
9 | |||
10 | export type MVideoShare = Omit<VideoShareModel, 'Actor' | 'Video'> | ||
11 | |||
12 | export type MVideoShareActor = MVideoShare & | ||
13 | Use<'Actor', MActorDefault> | ||
14 | |||
15 | export type MVideoShareFull = MVideoShare & | ||
16 | Use<'Actor', MActorDefault> & | ||
17 | Use<'Video', MVideo> | ||
diff --git a/server/typings/models/video/video-streaming-playlist.ts b/server/typings/models/video/video-streaming-playlist.ts new file mode 100644 index 000000000..79696bcff --- /dev/null +++ b/server/typings/models/video/video-streaming-playlist.ts | |||
@@ -0,0 +1,19 @@ | |||
1 | import { VideoStreamingPlaylistModel } from '../../../models/video/video-streaming-playlist' | ||
2 | import { PickWith, PickWithOpt } from '../../utils' | ||
3 | import { MVideoRedundancyFileUrl } from './video-redundancy' | ||
4 | import { MVideo, MVideoUrl } from '@server/typings/models' | ||
5 | |||
6 | type Use<K extends keyof VideoStreamingPlaylistModel, M> = PickWith<VideoStreamingPlaylistModel, K, M> | ||
7 | |||
8 | // ############################################################################ | ||
9 | |||
10 | export type MStreamingPlaylist = Omit<VideoStreamingPlaylistModel, 'Video' | 'RedundancyVideos'> | ||
11 | |||
12 | export type MStreamingPlaylistVideo = MStreamingPlaylist & | ||
13 | Use<'Video', MVideo> | ||
14 | |||
15 | export type MStreamingPlaylistRedundancies = MStreamingPlaylist & | ||
16 | Use<'RedundancyVideos', MVideoRedundancyFileUrl[]> | ||
17 | |||
18 | export type MStreamingPlaylistRedundanciesOpt = MStreamingPlaylist & | ||
19 | PickWithOpt<VideoStreamingPlaylistModel, 'RedundancyVideos', MVideoRedundancyFileUrl[]> | ||
diff --git a/server/typings/models/video/video.ts b/server/typings/models/video/video.ts new file mode 100644 index 000000000..be32d4617 --- /dev/null +++ b/server/typings/models/video/video.ts | |||
@@ -0,0 +1,169 @@ | |||
1 | import { VideoModel } from '../../../models/video/video' | ||
2 | import { PickWith, PickWithOpt } from '../../utils' | ||
3 | import { | ||
4 | MChannelAccountDefault, | ||
5 | MChannelAccountLight, | ||
6 | MChannelAccountSummaryFormattable, | ||
7 | MChannelActor, | ||
8 | MChannelFormattable, | ||
9 | MChannelUserId | ||
10 | } from './video-channels' | ||
11 | import { MTag } from './tag' | ||
12 | import { MVideoCaptionLanguage } from './video-caption' | ||
13 | import { MStreamingPlaylist, MStreamingPlaylistRedundancies, MStreamingPlaylistRedundanciesOpt } from './video-streaming-playlist' | ||
14 | import { MVideoFile, MVideoFileRedundanciesOpt } from './video-file' | ||
15 | import { MThumbnail } from './thumbnail' | ||
16 | import { MVideoBlacklist, MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist' | ||
17 | import { MScheduleVideoUpdate } from './schedule-video-update' | ||
18 | import { MUserVideoHistoryTime } from '../user/user-video-history' | ||
19 | |||
20 | type Use<K extends keyof VideoModel, M> = PickWith<VideoModel, K, M> | ||
21 | |||
22 | // ############################################################################ | ||
23 | |||
24 | export type MVideo = Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' | | ||
25 | 'VideoFiles' | 'VideoStreamingPlaylists' | 'VideoShares' | 'AccountVideoRates' | 'VideoComments' | 'VideoViews' | 'UserVideoHistories' | | ||
26 | 'ScheduleVideoUpdate' | 'VideoBlacklist' | 'VideoImport' | 'VideoCaptions'> | ||
27 | |||
28 | // ############################################################################ | ||
29 | |||
30 | export type MVideoId = Pick<MVideo, 'id'> | ||
31 | export type MVideoUrl = Pick<MVideo, 'url'> | ||
32 | export type MVideoUUID = Pick<MVideo, 'uuid'> | ||
33 | |||
34 | export type MVideoIdUrl = MVideoId & MVideoUrl | ||
35 | export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'> | ||
36 | |||
37 | // ############################################################################ | ||
38 | |||
39 | // Video raw associations: schedules, video files, tags, thumbnails, captions, streaming playlists | ||
40 | |||
41 | // "With" to not confuse with the VideoFile model | ||
42 | export type MVideoWithFile = MVideo & | ||
43 | Use<'VideoFiles', MVideoFile[]> | ||
44 | |||
45 | export type MVideoThumbnail = MVideo & | ||
46 | Use<'Thumbnails', MThumbnail[]> | ||
47 | |||
48 | export type MVideoIdThumbnail = MVideoId & | ||
49 | Use<'Thumbnails', MThumbnail[]> | ||
50 | |||
51 | export type MVideoWithFileThumbnail = MVideo & | ||
52 | Use<'VideoFiles', MVideoFile[]> & | ||
53 | Use<'Thumbnails', MThumbnail[]> | ||
54 | |||
55 | export type MVideoTag = MVideo & | ||
56 | Use<'Tags', MTag[]> | ||
57 | |||
58 | export type MVideoWithSchedule = MVideo & | ||
59 | PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate> | ||
60 | |||
61 | export type MVideoWithCaptions = MVideo & | ||
62 | Use<'VideoCaptions', MVideoCaptionLanguage[]> | ||
63 | |||
64 | export type MVideoWithStreamingPlaylist = MVideo & | ||
65 | Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> | ||
66 | |||
67 | // ############################################################################ | ||
68 | |||
69 | // Associations with not all their attributes | ||
70 | |||
71 | export type MVideoUserHistory = MVideo & | ||
72 | Use<'UserVideoHistories', MUserVideoHistoryTime[]> | ||
73 | |||
74 | export type MVideoWithBlacklistLight = MVideo & | ||
75 | Use<'VideoBlacklist', MVideoBlacklistLight> | ||
76 | |||
77 | export type MVideoAccountLight = MVideo & | ||
78 | Use<'VideoChannel', MChannelAccountLight> | ||
79 | |||
80 | export type MVideoWithRights = MVideo & | ||
81 | Use<'VideoBlacklist', MVideoBlacklistLight> & | ||
82 | Use<'Thumbnails', MThumbnail[]> & | ||
83 | Use<'VideoChannel', MChannelUserId> | ||
84 | |||
85 | // ############################################################################ | ||
86 | |||
87 | // All files with some additional associations | ||
88 | |||
89 | export type MVideoWithAllFiles = MVideo & | ||
90 | Use<'VideoFiles', MVideoFile[]> & | ||
91 | Use<'Thumbnails', MThumbnail[]> & | ||
92 | Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> | ||
93 | |||
94 | export type MVideoAccountLightBlacklistAllFiles = MVideo & | ||
95 | Use<'VideoFiles', MVideoFile[]> & | ||
96 | Use<'Thumbnails', MThumbnail[]> & | ||
97 | Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> & | ||
98 | Use<'VideoChannel', MChannelAccountLight> & | ||
99 | Use<'VideoBlacklist', MVideoBlacklistLight> | ||
100 | |||
101 | // ############################################################################ | ||
102 | |||
103 | // With account | ||
104 | |||
105 | export type MVideoAccountDefault = MVideo & | ||
106 | Use<'VideoChannel', MChannelAccountDefault> | ||
107 | |||
108 | export type MVideoThumbnailAccountDefault = MVideo & | ||
109 | Use<'Thumbnails', MThumbnail[]> & | ||
110 | Use<'VideoChannel', MChannelAccountDefault> | ||
111 | |||
112 | export type MVideoWithChannelActor = MVideo & | ||
113 | Use<'VideoChannel', MChannelActor> | ||
114 | |||
115 | export type MVideoFullLight = MVideo & | ||
116 | Use<'Thumbnails', MThumbnail[]> & | ||
117 | Use<'VideoBlacklist', MVideoBlacklistLight> & | ||
118 | Use<'Tags', MTag[]> & | ||
119 | Use<'VideoChannel', MChannelAccountLight> & | ||
120 | Use<'UserVideoHistories', MUserVideoHistoryTime[]> & | ||
121 | Use<'VideoFiles', MVideoFile[]> & | ||
122 | Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> & | ||
123 | Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> | ||
124 | |||
125 | // ############################################################################ | ||
126 | |||
127 | // API | ||
128 | |||
129 | export type MVideoAP = MVideo & | ||
130 | Use<'Tags', MTag[]> & | ||
131 | Use<'VideoChannel', MChannelAccountLight> & | ||
132 | Use<'VideoStreamingPlaylists', MStreamingPlaylist[]> & | ||
133 | Use<'VideoCaptions', MVideoCaptionLanguage[]> & | ||
134 | Use<'VideoBlacklist', MVideoBlacklistUnfederated> & | ||
135 | Use<'VideoFiles', MVideoFileRedundanciesOpt[]> | ||
136 | |||
137 | export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'> | ||
138 | |||
139 | export type MVideoDetails = MVideo & | ||
140 | Use<'VideoBlacklist', MVideoBlacklistLight> & | ||
141 | Use<'Tags', MTag[]> & | ||
142 | Use<'VideoChannel', MChannelAccountLight> & | ||
143 | Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> & | ||
144 | Use<'Thumbnails', MThumbnail[]> & | ||
145 | Use<'UserVideoHistories', MUserVideoHistoryTime[]> & | ||
146 | Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> & | ||
147 | Use<'VideoFiles', MVideoFileRedundanciesOpt[]> | ||
148 | |||
149 | export type MVideoForUser = MVideo & | ||
150 | Use<'VideoChannel', MChannelAccountDefault> & | ||
151 | Use<'ScheduleVideoUpdate', MScheduleVideoUpdate> & | ||
152 | Use<'VideoBlacklist', MVideoBlacklistLight> & | ||
153 | Use<'Thumbnails', MThumbnail[]> | ||
154 | |||
155 | // ############################################################################ | ||
156 | |||
157 | // Format for API or AP object | ||
158 | |||
159 | export type MVideoFormattable = MVideo & | ||
160 | PickWithOpt<VideoModel, 'UserVideoHistories', MUserVideoHistoryTime[]> & | ||
161 | Use<'VideoChannel', MChannelAccountSummaryFormattable> & | ||
162 | PickWithOpt<VideoModel, 'ScheduleVideoUpdate', Pick<MScheduleVideoUpdate, 'updateAt' | 'privacy'>> & | ||
163 | PickWithOpt<VideoModel, 'VideoBlacklist', Pick<MVideoBlacklist, 'reason'>> | ||
164 | |||
165 | export type MVideoFormattableDetails = MVideoFormattable & | ||
166 | Use<'VideoChannel', MChannelFormattable> & | ||
167 | Use<'Tags', MTag[]> & | ||
168 | Use<'VideoStreamingPlaylists', MStreamingPlaylistRedundanciesOpt[]> & | ||
169 | Use<'VideoFiles', MVideoFileRedundanciesOpt[]> | ||
diff --git a/server/typings/utils.ts b/server/typings/utils.ts index a86b05be2..4b5cf4d7e 100644 --- a/server/typings/utils.ts +++ b/server/typings/utils.ts | |||
@@ -1,3 +1,13 @@ | |||
1 | export type FunctionPropertyNames<T> = { [K in keyof T]: T[K] extends Function ? K : never }[keyof T] | 1 | export type FunctionPropertyNames<T> = { |
2 | [K in keyof T]: T[K] extends Function ? K : never | ||
3 | }[keyof T] | ||
2 | 4 | ||
3 | export type FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>> | 5 | export type FunctionProperties<T> = Pick<T, FunctionPropertyNames<T>> |
6 | |||
7 | export type PickWith<T, KT extends keyof T, V> = { | ||
8 | [P in KT]: T[P] extends V ? V : never | ||
9 | } | ||
10 | |||
11 | export type PickWithOpt<T, KT extends keyof T, V> = { | ||
12 | [P in KT]?: T[P] extends V ? V : never | ||
13 | } | ||