diff options
Diffstat (limited to 'server/typings')
43 files changed, 825 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..260091461 100644 --- a/server/typings/express.ts +++ b/server/typings/express.ts | |||
@@ -1,89 +1,102 @@ | |||
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 | MChannelActorAccountDefault, | ||
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 } 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?: MChannelActorAccountDefault |
38 | 57 | ||
39 | videoCaption?: VideoCaptionModel | 58 | videoPlaylistFull?: MVideoPlaylistFull |
59 | videoPlaylistSummary?: MVideoPlaylistFullSummary | ||
40 | 60 | ||
41 | videoAbuse?: VideoAbuseModel | 61 | videoPlaylistElement?: MVideoPlaylistElement |
42 | 62 | ||
43 | videoStreamingPlaylist?: VideoStreamingPlaylistModel | 63 | accountVideoRate?: MAccountVideoRateAccountVideo |
44 | 64 | ||
45 | videoChannel?: VideoChannelModel | 65 | videoCommentFull?: MCommentOwnerVideoReply |
66 | videoCommentThread?: MComment | ||
46 | 67 | ||
47 | videoPlaylist?: VideoPlaylistModel | 68 | follow?: MActorFollowActorsDefault |
48 | videoPlaylistElement?: VideoPlaylistElementModel | 69 | subscription?: MActorFollowActorsDefaultSubscription |
49 | 70 | ||
50 | accountVideoRate?: AccountVideoRateModel | 71 | nextOwner?: MAccountDefault |
72 | videoChangeOwnership?: MVideoChangeOwnershipFull | ||
51 | 73 | ||
52 | videoComment?: VideoCommentModel | 74 | account?: MAccountDefault |
53 | videoCommentThread?: VideoCommentModel | ||
54 | 75 | ||
55 | follow?: ActorFollowModel | 76 | actorFull?: MActorFull |
56 | subscription?: ActorFollowModel | ||
57 | 77 | ||
58 | nextOwner?: AccountModel | 78 | user?: MUserDefault |
59 | videoChangeOwnership?: VideoChangeOwnershipModel | ||
60 | account?: AccountModel | ||
61 | actor?: ActorModel | ||
62 | user?: UserModel | ||
63 | 79 | ||
64 | server?: ServerModel | 80 | server?: MServer |
65 | 81 | ||
66 | videoRedundancy?: VideoRedundancyModel | 82 | videoRedundancy?: MVideoRedundancyVideo |
67 | 83 | ||
68 | accountBlock?: AccountBlocklistModel | 84 | accountBlock?: MAccountBlocklist |
69 | serverBlock?: ServerBlocklistModel | 85 | serverBlock?: MServerBlocklist |
70 | 86 | ||
71 | oauth?: { | 87 | oauth?: { |
72 | token: { | 88 | token: MOAuthTokenUser |
73 | User: UserModel | ||
74 | user: UserModel | ||
75 | } | ||
76 | } | 89 | } |
77 | 90 | ||
78 | signature?: { | 91 | signature?: { |
79 | actor: SignatureActorModel | 92 | actor: MActorAccountChannelId |
80 | } | 93 | } |
81 | 94 | ||
82 | authenticated?: boolean | 95 | authenticated?: boolean |
83 | 96 | ||
84 | registeredPlugin?: RegisteredPlugin | 97 | registeredPlugin?: RegisteredPlugin |
85 | 98 | ||
86 | plugin?: PluginModel | 99 | plugin?: MPlugin |
87 | } | 100 | } |
88 | } | 101 | } |
89 | } | 102 | } |
diff --git a/server/typings/models/account/account-blocklist.ts b/server/typings/models/account/account-blocklist.ts new file mode 100644 index 000000000..6d1771de8 --- /dev/null +++ b/server/typings/models/account/account-blocklist.ts | |||
@@ -0,0 +1,11 @@ | |||
1 | import { AccountBlocklistModel } from '../../../models/account/account-blocklist' | ||
2 | import { PickWith } from '../../utils' | ||
3 | import { MAccountDefault } from './account' | ||
4 | |||
5 | export type MAccountBlocklist = Omit<AccountBlocklistModel, 'ByAccount' | 'BlockedAccount'> | ||
6 | |||
7 | export type MAccountBlocklistId = Pick<AccountBlocklistModel, 'id'> | ||
8 | |||
9 | export type MAccountBlocklistAccounts = MAccountBlocklist & | ||
10 | PickWith<AccountBlocklistModel, 'ByAccount', MAccountDefault> & | ||
11 | PickWith<AccountBlocklistModel, 'BlockedAccount', MAccountDefault> | ||
diff --git a/server/typings/models/account/account.ts b/server/typings/models/account/account.ts new file mode 100644 index 000000000..f3646d510 --- /dev/null +++ b/server/typings/models/account/account.ts | |||
@@ -0,0 +1,56 @@ | |||
1 | import { AccountModel } from '../../../models/account/account' | ||
2 | import { | ||
3 | MActor, | ||
4 | MActorAccountChannelId, | ||
5 | MActorAPI, | ||
6 | MActorAudience, | ||
7 | MActorDefault, | ||
8 | MActorDefaultLight, MActorId, | ||
9 | MActorServer, | ||
10 | MActorSummary, | ||
11 | MActorUrl | ||
12 | } from './actor' | ||
13 | import { PickWith } from '../../utils' | ||
14 | import { MAccountBlocklistId } from './account-blocklist' | ||
15 | import { MChannelDefault } from '@server/typings/models' | ||
16 | |||
17 | export type MAccountId = Pick<AccountModel, 'id'> | ||
18 | export type MAccountIdActor = MAccountId & | ||
19 | PickWith<AccountModel, 'Actor', MActorAccountChannelId> | ||
20 | export type MAccountIdActorId = MAccountId & | ||
21 | PickWith<AccountModel, 'Actor', MActorId> | ||
22 | |||
23 | export type MAccount = Omit<AccountModel, 'Actor' | 'User' | 'Application' | 'VideoChannels' | 'VideoPlaylists' | | ||
24 | 'VideoComments' | 'BlockedAccounts'> | ||
25 | |||
26 | // Default scope | ||
27 | export type MAccountDefault = MAccount & | ||
28 | PickWith<AccountModel, 'Actor', MActorDefault> | ||
29 | |||
30 | export type MAccountDefaultChannelDefault = MAccountDefault & | ||
31 | PickWith<AccountModel, 'VideoChannels', MChannelDefault[]> | ||
32 | |||
33 | export type MAccountLight = MAccount & | ||
34 | PickWith<AccountModel, 'Actor', MActorDefaultLight> | ||
35 | |||
36 | export type MAccountUserId = Pick<MAccount, 'userId'> | ||
37 | |||
38 | export type MAccountActor = MAccount & | ||
39 | PickWith<AccountModel, 'Actor', MActor> | ||
40 | export type MAccountServer = MAccountActor & | ||
41 | PickWith<AccountModel, 'Actor', MActorServer> | ||
42 | |||
43 | export type MAccountActorDefault = MAccount & | ||
44 | PickWith<AccountModel, 'Actor', MActorDefault> | ||
45 | |||
46 | export type MAccountSummary = Pick<MAccount, 'id' | 'name'> & | ||
47 | PickWith<AccountModel, 'Actor', MActorSummary> | ||
48 | |||
49 | export type MAccountBlocks = MAccountSummary & | ||
50 | PickWith<AccountModel, 'BlockedAccounts', MAccountBlocklistId[]> | ||
51 | |||
52 | export type MAccountAPI = MAccountDefault & | ||
53 | PickWith<AccountModel, 'Actor', MActorAPI> | ||
54 | |||
55 | export type MAccountUrl = PickWith<AccountModel, 'Actor', MActorUrl> | ||
56 | export type MAccountAudience = PickWith<AccountModel, 'Actor', MActorAudience> | ||
diff --git a/server/typings/models/account/actor-follow.ts b/server/typings/models/account/actor-follow.ts new file mode 100644 index 000000000..96c53d857 --- /dev/null +++ b/server/typings/models/account/actor-follow.ts | |||
@@ -0,0 +1,27 @@ | |||
1 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | ||
2 | import { MActor, MActorAccountChannel, MActorChannel, MActorChannelAccount, MActorDefault, MActorHost, MActorUsername } from './actor' | ||
3 | import { PickWith } from '../../utils' | ||
4 | |||
5 | export type MActorFollow = Omit<ActorFollowModel, 'ActorFollower' | 'ActorFollowing'> | ||
6 | |||
7 | export type MActorFollowActors = MActorFollow & | ||
8 | PickWith<ActorFollowModel, 'ActorFollower', MActor> & | ||
9 | PickWith<ActorFollowModel, 'ActorFollowing', MActor> | ||
10 | |||
11 | export type MActorFollowActorsDefault = MActorFollow & | ||
12 | PickWith<ActorFollowModel, 'ActorFollower', MActorDefault> & | ||
13 | PickWith<ActorFollowModel, 'ActorFollowing', MActorDefault> | ||
14 | |||
15 | export type MActorFollowActorsDefaultSubscription = MActorFollow & | ||
16 | PickWith<ActorFollowModel, 'ActorFollower', MActorDefault> & | ||
17 | PickWith<ActorFollowModel, 'ActorFollowing', MActorDefault & MActorChannel> | ||
18 | |||
19 | export type MActorFollowFull = MActorFollow & | ||
20 | PickWith<ActorFollowModel, 'ActorFollower', MActorAccountChannel> & | ||
21 | PickWith<ActorFollowModel, 'ActorFollowing', MActorAccountChannel> | ||
22 | |||
23 | export type MActorFollowFollowingHost = MActorFollow & | ||
24 | PickWith<ActorFollowModel, 'ActorFollowing', MActorUsername & MActorHost> | ||
25 | |||
26 | export type MActorFollowSubscriptions = MActorFollow & | ||
27 | PickWith<ActorFollowModel, 'ActorFollowing', MActorChannelAccount> | ||
diff --git a/server/typings/models/account/actor.ts b/server/typings/models/account/actor.ts new file mode 100644 index 000000000..f3e752a98 --- /dev/null +++ b/server/typings/models/account/actor.ts | |||
@@ -0,0 +1,74 @@ | |||
1 | import { ActorModel } from '../../../models/activitypub/actor' | ||
2 | import { PickWith } from '../../utils' | ||
3 | import { MAccount, MAccountActorDefault, MAccountId, MAccountIdActor } from './account' | ||
4 | import { MServerHost, MServerHostBlocks, MServer } from '../server' | ||
5 | import { MAvatar } from './avatar' | ||
6 | import { MChannel, MChannelAccountActor, MChannelActorAccountDefault, MChannelId, MChannelIdActor } from '../video' | ||
7 | |||
8 | export type MActor = Omit<ActorModel, 'Account' | 'VideoChannel' | 'ActorFollowing' | 'Avatar' | 'ActorFollowers' | 'Server'> | ||
9 | |||
10 | export type MActorUrl = Pick<MActor, 'url'> | ||
11 | export type MActorId = Pick<MActor, 'id'> | ||
12 | export type MActorUsername = Pick<MActor, 'preferredUsername'> | ||
13 | export type MActorHost = PickWith<ActorModel, 'Server', MServerHost> | ||
14 | |||
15 | export type MActorFollowersUrl = Pick<MActor, 'followersUrl'> | ||
16 | export type MActorAudience = MActorUrl & MActorFollowersUrl | ||
17 | |||
18 | export type MActorLight = Omit<MActor, 'privateKey' | 'privateKey'> | ||
19 | |||
20 | export type MActorDefaultLight = MActorLight & | ||
21 | MActorHost & | ||
22 | PickWith<ActorModel, 'Avatar', MAvatar> | ||
23 | |||
24 | export type MActorAccountId = MActor & | ||
25 | PickWith<ActorModel, 'Account', MAccountId> | ||
26 | export type MActorAccountIdActor = MActor & | ||
27 | PickWith<ActorModel, 'Account', MAccountIdActor> | ||
28 | |||
29 | export type MActorChannelId = MActor & | ||
30 | PickWith<ActorModel, 'VideoChannel', MChannelId> | ||
31 | export type MActorChannelIdActor = MActor & | ||
32 | PickWith<ActorModel, 'VideoChannel', MChannelIdActor> | ||
33 | |||
34 | export type MActorAccountChannelId = MActorAccountId & MActorChannelId | ||
35 | export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor | ||
36 | |||
37 | export type MActorAccount = MActor & | ||
38 | PickWith<ActorModel, 'Account', MAccount> | ||
39 | |||
40 | export type MActorChannel = MActor & | ||
41 | PickWith<ActorModel, 'VideoChannel', MChannel> | ||
42 | |||
43 | export type MActorAccountChannel = MActorAccount & MActorChannel | ||
44 | |||
45 | export type MActorChannelAccount = MActor & | ||
46 | PickWith<ActorModel, 'VideoChannel', MChannelAccountActor> | ||
47 | |||
48 | export type MActorServer = MActor & | ||
49 | PickWith<ActorModel, 'Server', MServer> | ||
50 | |||
51 | export type MActorDefault = MActorServer & | ||
52 | PickWith<ActorModel, 'Avatar', MAvatar> | ||
53 | |||
54 | export type MActorFull = MActorDefault & | ||
55 | PickWith<ActorModel, 'Account', MAccount> & | ||
56 | PickWith<ActorModel, 'VideoChannel', MChannelAccountActor> | ||
57 | |||
58 | export type MActorFullActor = MActorDefault & | ||
59 | PickWith<ActorModel, 'Account', MAccountActorDefault> & | ||
60 | PickWith<ActorModel, 'VideoChannel', MChannelActorAccountDefault> | ||
61 | |||
62 | export type MActorSummary = Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> & | ||
63 | MActorHost & | ||
64 | PickWith<ActorModel, 'Avatar', MAvatar> | ||
65 | |||
66 | export type MActorSummaryBlocks = Omit<MActorSummary, 'Server'> & | ||
67 | PickWith<ActorModel, 'Server', MServerHostBlocks> | ||
68 | |||
69 | export type MActorFollowerException = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl'> | ||
70 | |||
71 | export type MActorAPI = Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' | | ||
72 | 'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'> | ||
73 | |||
74 | export type MActorSignature = MActorAccountChannelId | ||
diff --git a/server/typings/models/account/avatar.ts b/server/typings/models/account/avatar.ts new file mode 100644 index 000000000..257c48bfc --- /dev/null +++ b/server/typings/models/account/avatar.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | import { AvatarModel } from '../../../models/avatar/avatar' | ||
2 | |||
3 | export type MAvatar = AvatarModel | ||
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..39e82e4a8 100644 --- a/server/typings/models/index.d.ts +++ b/server/typings/models/index.d.ts | |||
@@ -1 +1,4 @@ | |||
1 | export * from './actor' | 1 | export * from './account' |
2 | export * from './server' | ||
3 | export * from './user' | ||
4 | export * from './video' | ||
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..105ea3df3 --- /dev/null +++ b/server/typings/models/oauth/oauth-token.ts | |||
@@ -0,0 +1,9 @@ | |||
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 | export type MOAuthToken = Omit<OAuthTokenModel, 'User' | 'OAuthClients'> | ||
6 | |||
7 | export type MOAuthTokenUser = MOAuthToken & | ||
8 | PickWith<OAuthTokenModel, 'User', MUserAccountUrl> & | ||
9 | { 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..b1e2e149d --- /dev/null +++ b/server/typings/models/server/plugin.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | import { PluginModel } from '@server/models/server/plugin' | ||
2 | |||
3 | export type MPlugin = PluginModel | ||
diff --git a/server/typings/models/server/server-blocklist.ts b/server/typings/models/server/server-blocklist.ts new file mode 100644 index 000000000..38065f382 --- /dev/null +++ b/server/typings/models/server/server-blocklist.ts | |||
@@ -0,0 +1,9 @@ | |||
1 | import { ServerBlocklistModel } from '@server/models/server/server-blocklist' | ||
2 | import { PickWith } from '@server/typings/utils' | ||
3 | import { MAccountDefault, MServer } from '@server/typings/models' | ||
4 | |||
5 | export type MServerBlocklist = Omit<ServerBlocklistModel, 'ByAccount' | 'BlockedServer'> | ||
6 | |||
7 | export type MServerBlocklistAccountServer = MServerBlocklist & | ||
8 | PickWith<ServerBlocklistModel, 'ByAccount', MAccountDefault> & | ||
9 | PickWith<ServerBlocklistModel, 'BlockedServer', MServer> | ||
diff --git a/server/typings/models/server/server.ts b/server/typings/models/server/server.ts new file mode 100644 index 000000000..6be7bf9bb --- /dev/null +++ b/server/typings/models/server/server.ts | |||
@@ -0,0 +1,10 @@ | |||
1 | import { ServerModel } from '../../../models/server/server' | ||
2 | import { PickWith } from '../../utils' | ||
3 | import { MAccountBlocklistId } from '../account' | ||
4 | |||
5 | export type MServer = Omit<ServerModel, 'Actors' | 'BlockedByAccounts'> | ||
6 | |||
7 | export type MServerHost = Pick<MServer, 'host'> | ||
8 | |||
9 | export type MServerHostBlocks = MServerHost & | ||
10 | PickWith<ServerModel, 'BlockedByAccounts', MAccountBlocklistId[]> | ||
diff --git a/server/typings/models/user/index.d.ts b/server/typings/models/user/index.d.ts new file mode 100644 index 000000000..e3353d0b1 --- /dev/null +++ b/server/typings/models/user/index.d.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | export * from './user' | ||
2 | export * from './user-notification' | ||
3 | export * from './user-video-history' | ||
diff --git a/server/typings/models/user/user-notification-setting.ts b/server/typings/models/user/user-notification-setting.ts new file mode 100644 index 000000000..585d30a66 --- /dev/null +++ b/server/typings/models/user/user-notification-setting.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | import { UserNotificationSettingModel } from '@server/models/account/user-notification-setting' | ||
2 | |||
3 | export type MNotificationSetting = Omit<UserNotificationSettingModel, 'User'> | ||
diff --git a/server/typings/models/user/user-notification.ts b/server/typings/models/user/user-notification.ts new file mode 100644 index 000000000..b872c5dc5 --- /dev/null +++ b/server/typings/models/user/user-notification.ts | |||
@@ -0,0 +1,69 @@ | |||
1 | import { UserNotificationModel } from '../../../models/account/user-notification' | ||
2 | import { PickWith } from '../../utils' | ||
3 | import { VideoModel } from '../../../models/video/video' | ||
4 | import { ActorModel } from '../../../models/activitypub/actor' | ||
5 | import { ServerModel } from '../../../models/server/server' | ||
6 | import { AvatarModel } from '../../../models/avatar/avatar' | ||
7 | import { VideoChannelModel } from '../../../models/video/video-channel' | ||
8 | import { AccountModel } from '../../../models/account/account' | ||
9 | import { VideoCommentModel } from '../../../models/video/video-comment' | ||
10 | import { VideoAbuseModel } from '../../../models/video/video-abuse' | ||
11 | import { VideoBlacklistModel } from '../../../models/video/video-blacklist' | ||
12 | import { VideoImportModel } from '../../../models/video/video-import' | ||
13 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | ||
14 | |||
15 | export namespace UserNotificationIncludes { | ||
16 | export type VideoInclude = Pick<VideoModel, 'id' | 'uuid' | 'name'> | ||
17 | export type VideoIncludeChannel = VideoInclude & | ||
18 | PickWith<VideoModel, 'VideoChannel', VideoChannelIncludeActor> | ||
19 | |||
20 | export type ActorInclude = Pick<ActorModel, 'preferredUsername' | 'getHost'> & | ||
21 | PickWith<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>> & | ||
22 | PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>> | ||
23 | |||
24 | export type VideoChannelInclude = Pick<VideoChannelModel, 'id' | 'name' | 'getDisplayName'> | ||
25 | export type VideoChannelIncludeActor = VideoChannelInclude & | ||
26 | PickWith<VideoChannelModel, 'Actor', ActorInclude> | ||
27 | |||
28 | export type AccountInclude = Pick<AccountModel, 'id' | 'name' | 'getDisplayName'> | ||
29 | export type AccountIncludeActor = AccountInclude & | ||
30 | PickWith<AccountModel, 'Actor', ActorInclude> | ||
31 | |||
32 | export type VideoCommentInclude = Pick<VideoCommentModel, 'id' | 'originCommentId' | 'getThreadId'> & | ||
33 | PickWith<VideoCommentModel, 'Account', AccountIncludeActor> & | ||
34 | PickWith<VideoCommentModel, 'Video', VideoInclude> | ||
35 | |||
36 | export type VideoAbuseInclude = Pick<VideoAbuseModel, 'id'> & | ||
37 | PickWith<VideoAbuseModel, 'Video', VideoInclude> | ||
38 | |||
39 | export type VideoBlacklistInclude = Pick<VideoBlacklistModel, 'id'> & | ||
40 | PickWith<VideoAbuseModel, 'Video', VideoInclude> | ||
41 | |||
42 | export type VideoImportInclude = Pick<VideoImportModel, 'id' | 'magnetUri' | 'targetUrl' | 'torrentName'> & | ||
43 | PickWith<VideoImportModel, 'Video', VideoInclude> | ||
44 | |||
45 | export type ActorFollower = Pick<ActorModel, 'preferredUsername' | 'getHost'> & | ||
46 | PickWith<ActorModel, 'Account', AccountInclude> & | ||
47 | PickWith<ActorModel, 'Avatar', Pick<AvatarModel, 'filename' | 'getStaticPath'>> & | ||
48 | PickWith<ActorModel, 'Server', Pick<ServerModel, 'host'>> | ||
49 | |||
50 | export type ActorFollowing = Pick<ActorModel, 'preferredUsername'> & | ||
51 | PickWith<ActorModel, 'VideoChannel', VideoChannelInclude> & | ||
52 | PickWith<ActorModel, 'Account', AccountInclude> | ||
53 | |||
54 | export type ActorFollowInclude = Pick<ActorFollowModel, 'id' | 'state'> & | ||
55 | PickWith<ActorFollowModel, 'ActorFollower', ActorFollower> & | ||
56 | PickWith<ActorFollowModel, 'ActorFollowing', ActorFollowing> | ||
57 | } | ||
58 | |||
59 | export type UserNotificationModelOnly = Omit<UserNotificationModel, 'User' | 'Video' | 'Comment' | 'VideoAbuse' | 'VideoBlacklist' | | ||
60 | 'VideoImport' | 'Account' | 'ActorFollow'> | ||
61 | |||
62 | export type UserNotificationModelForApi = UserNotificationModelOnly & | ||
63 | PickWith<UserNotificationModel, 'Video', UserNotificationIncludes.VideoIncludeChannel> & | ||
64 | PickWith<UserNotificationModel, 'Comment', UserNotificationIncludes.VideoCommentInclude> & | ||
65 | PickWith<UserNotificationModel, 'VideoAbuse', UserNotificationIncludes.VideoAbuseInclude> & | ||
66 | PickWith<UserNotificationModel, 'VideoBlacklist', UserNotificationIncludes.VideoBlacklistInclude> & | ||
67 | PickWith<UserNotificationModel, 'VideoImport', UserNotificationIncludes.VideoImportInclude> & | ||
68 | PickWith<UserNotificationModel, 'ActorFollow', UserNotificationIncludes.ActorFollowInclude> & | ||
69 | PickWith<UserNotificationModel, 'Account', UserNotificationIncludes.AccountIncludeActor> | ||
diff --git a/server/typings/models/user/user-video-history.ts b/server/typings/models/user/user-video-history.ts new file mode 100644 index 000000000..62673ab1b --- /dev/null +++ b/server/typings/models/user/user-video-history.ts | |||
@@ -0,0 +1,5 @@ | |||
1 | import { UserVideoHistoryModel } from '../../../models/account/user-video-history' | ||
2 | |||
3 | export type MUserVideoHistory = Omit<UserVideoHistoryModel, 'Video' | 'User'> | ||
4 | |||
5 | export type MUserVideoHistoryTime = Pick<MUserVideoHistory, 'currentTime'> | ||
diff --git a/server/typings/models/user/user.ts b/server/typings/models/user/user.ts new file mode 100644 index 000000000..b91eed8d9 --- /dev/null +++ b/server/typings/models/user/user.ts | |||
@@ -0,0 +1,32 @@ | |||
1 | import { UserModel } from '../../../models/account/user' | ||
2 | import { PickWith } from '../../utils' | ||
3 | import { MAccount, MAccountDefault, MAccountDefaultChannelDefault, MAccountId, MAccountIdActorId, MAccountUrl } from '../account' | ||
4 | import { MNotificationSetting } from './user-notification-setting' | ||
5 | |||
6 | export type MUser = Omit<UserModel, 'Account' | 'NotificationSetting' | 'VideoImports' | 'OAuthTokens'> | ||
7 | |||
8 | export type MUserId = Pick<UserModel, 'id'> | ||
9 | |||
10 | export type MUserWithNotificationSetting = MUser & | ||
11 | PickWith<UserModel, 'NotificationSetting', MNotificationSetting> | ||
12 | |||
13 | export type MUserAccountDefault = MUser & | ||
14 | PickWith<UserModel, 'Account', MAccountDefault> | ||
15 | |||
16 | export type MUserAccount = MUser & | ||
17 | PickWith<UserModel, 'Account', MAccount> | ||
18 | |||
19 | export type MUserAccountId = MUser & | ||
20 | PickWith<UserModel, 'Account', MAccountId> | ||
21 | |||
22 | export type MUserNotifSettingAccount = MUserWithNotificationSetting & MUserAccount | ||
23 | |||
24 | export type MUserDefault = MUser & | ||
25 | MUserWithNotificationSetting & | ||
26 | MUserAccountDefault | ||
27 | |||
28 | export type MUserChannel = MUserWithNotificationSetting & | ||
29 | PickWith<UserModel, 'Account', MAccountDefaultChannelDefault> | ||
30 | |||
31 | export type MUserAccountUrl = MUser & | ||
32 | PickWith<UserModel, 'Account', MAccountUrl & MAccountIdActorId> | ||
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..528e9d274 --- /dev/null +++ b/server/typings/models/video/index.d.ts | |||
@@ -0,0 +1,14 @@ | |||
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-channels' | ||
9 | export * from './video-comment' | ||
10 | export * from './video-file' | ||
11 | export * from './video-playlist' | ||
12 | export * from './video-redundancy' | ||
13 | export * from './video-share' | ||
14 | 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..069705536 --- /dev/null +++ b/server/typings/models/video/schedule-video-update.ts | |||
@@ -0,0 +1,3 @@ | |||
1 | import { ScheduleVideoUpdateModel } from '../../../models/video/schedule-video-update' | ||
2 | |||
3 | export type MScheduleVideoUpdate = Omit<ScheduleVideoUpdateModel, 'Video'> | ||
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..1667ae55a --- /dev/null +++ b/server/typings/models/video/video-abuse.ts | |||
@@ -0,0 +1,15 @@ | |||
1 | import { VideoAbuseModel } from '../../../models/video/video-abuse' | ||
2 | import { PickWith } from '../../utils' | ||
3 | import { MVideo } from './video' | ||
4 | import { MAccountDefault } from '../account' | ||
5 | |||
6 | export type MVideoAbuse = Omit<VideoAbuseModel, 'Account' | 'Video' | 'toActivityPubObject'> | ||
7 | |||
8 | export type MVideoAbuseId = Pick<VideoAbuseModel, 'id'> | ||
9 | |||
10 | export type MVideoAbuseVideo = MVideoAbuse & | ||
11 | Pick<VideoAbuseModel, 'toActivityPubObject'> & | ||
12 | PickWith<VideoAbuseModel, 'Video', MVideo> | ||
13 | |||
14 | export type MVideoAbuseAccountVideo = MVideoAbuseVideo & | ||
15 | PickWith<VideoAbuseModel, 'Account', MAccountDefault> | ||
diff --git a/server/typings/models/video/video-blacklist.ts b/server/typings/models/video/video-blacklist.ts new file mode 100644 index 000000000..9242b357d --- /dev/null +++ b/server/typings/models/video/video-blacklist.ts | |||
@@ -0,0 +1,11 @@ | |||
1 | import { VideoBlacklistModel } from '../../../models/video/video-blacklist' | ||
2 | import { PickWith } from '@server/typings/utils' | ||
3 | import { MVideo } from '@server/typings/models' | ||
4 | |||
5 | export type MVideoBlacklist = Omit<VideoBlacklistModel, 'Video'> | ||
6 | |||
7 | export type MVideoBlacklistLight = Pick<MVideoBlacklist, 'id' | 'reason' | 'unfederated'> | ||
8 | export type MVideoBlacklistUnfederated = Pick<MVideoBlacklist, 'unfederated'> | ||
9 | |||
10 | export type MVideoBlacklistVideo = MVideoBlacklist & | ||
11 | PickWith<VideoBlacklistModel, 'Video', MVideo> | ||
diff --git a/server/typings/models/video/video-caption.ts b/server/typings/models/video/video-caption.ts new file mode 100644 index 000000000..16d8b7392 --- /dev/null +++ b/server/typings/models/video/video-caption.ts | |||
@@ -0,0 +1,10 @@ | |||
1 | import { VideoCaptionModel } from '../../../models/video/video-caption' | ||
2 | import { PickWith } from '@server/typings/utils' | ||
3 | import { VideoModel } from '@server/models/video/video' | ||
4 | |||
5 | export type MVideoCaption = Omit<VideoCaptionModel, 'Video'> | ||
6 | |||
7 | export type MVideoCaptionLanguage = Pick<MVideoCaption, 'language'> | ||
8 | |||
9 | export type MVideoCaptionVideo = MVideoCaption & | ||
10 | PickWith<VideoCaptionModel, 'Video', Pick<VideoModel, 'id' | 'remote' | 'uuid'>> | ||
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..718515e2d --- /dev/null +++ b/server/typings/models/video/video-change-ownership.ts | |||
@@ -0,0 +1,10 @@ | |||
1 | import { VideoChangeOwnershipModel } from '@server/models/video/video-change-ownership' | ||
2 | import { PickWith } from '@server/typings/utils' | ||
3 | import { MAccountDefault, MVideoWithFileThumbnail } from '@server/typings/models' | ||
4 | |||
5 | export type MVideoChangeOwnership = Omit<VideoChangeOwnershipModel, 'Initiator' | 'NextOwner' | 'Video'> | ||
6 | |||
7 | export type MVideoChangeOwnershipFull = MVideoChangeOwnership & | ||
8 | PickWith<VideoChangeOwnershipModel, 'Initiator', MAccountDefault> & | ||
9 | PickWith<VideoChangeOwnershipModel, 'NextOwner', MAccountDefault> & | ||
10 | PickWith<VideoChangeOwnershipModel, 'Video', MVideoWithFileThumbnail> | ||
diff --git a/server/typings/models/video/video-channels.ts b/server/typings/models/video/video-channels.ts new file mode 100644 index 000000000..e10bd6842 --- /dev/null +++ b/server/typings/models/video/video-channels.ts | |||
@@ -0,0 +1,70 @@ | |||
1 | import { FunctionProperties, PickWith } from '../../utils' | ||
2 | import { VideoChannelModel } from '../../../models/video/video-channel' | ||
3 | import { | ||
4 | MAccountActor, | ||
5 | MAccountAPI, | ||
6 | MAccountBlocks, | ||
7 | MAccountDefault, | ||
8 | MAccountLight, | ||
9 | MAccountUserId, | ||
10 | MActor, | ||
11 | MActorAccountChannelId, | ||
12 | MActorAPI, | ||
13 | MActorDefault, | ||
14 | MActorDefaultLight, MActorLight, | ||
15 | MActorSummary | ||
16 | } from '../account' | ||
17 | import { MVideo } from './video' | ||
18 | |||
19 | export type MChannelId = FunctionProperties<VideoChannelModel> | ||
20 | export type MChannelIdActor = MChannelId & | ||
21 | PickWith<VideoChannelModel, 'Actor', MActorAccountChannelId> | ||
22 | |||
23 | export type MChannel = Omit<VideoChannelModel, 'Actor' | 'Account' | 'Videos' | 'VideoPlaylists'> | ||
24 | |||
25 | export type MChannelUserId = Pick<MChannel, 'accountId'> & | ||
26 | PickWith<VideoChannelModel, 'Account', MAccountUserId> | ||
27 | |||
28 | // Default scope | ||
29 | export type MChannelDefault = MChannel & | ||
30 | PickWith<VideoChannelModel, 'Actor', MActorDefault> | ||
31 | |||
32 | export type MChannelLight = MChannel & | ||
33 | PickWith<VideoChannelModel, 'Actor', MActorDefaultLight> | ||
34 | |||
35 | export type MChannelAccountLight = MChannel & | ||
36 | PickWith<VideoChannelModel, 'Actor', MActorDefaultLight> & | ||
37 | PickWith<VideoChannelModel, 'Account', MAccountLight> | ||
38 | |||
39 | export type MChannelSummary = Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> & | ||
40 | PickWith<VideoChannelModel, 'Actor', MActorSummary> | ||
41 | |||
42 | export type MChannelSummaryAccount = MChannelSummary & | ||
43 | PickWith<VideoChannelModel, 'Account', MAccountBlocks> | ||
44 | |||
45 | export type MChannelAPI = MChannel & | ||
46 | PickWith<VideoChannelModel, 'Actor', MActorAPI> & | ||
47 | PickWith<VideoChannelModel, 'Account', MAccountAPI> | ||
48 | |||
49 | export type MChannelAccountActor = MChannel & | ||
50 | PickWith<VideoChannelModel, 'Account', MAccountActor> | ||
51 | export type MChannelAccountDefault = MChannelActor & | ||
52 | PickWith<VideoChannelModel, 'Account', MAccountDefault> | ||
53 | |||
54 | export type MChannelVideos = MChannel & | ||
55 | PickWith<VideoChannelModel, 'Videos', MVideo[]> | ||
56 | |||
57 | export type MChannelActor = MChannel & | ||
58 | PickWith<VideoChannelModel, 'Actor', MActor> | ||
59 | export type MChannelActorLight = MChannel & | ||
60 | PickWith<VideoChannelModel, 'Actor', MActorLight> | ||
61 | export type MChannelActorDefault = MChannel & | ||
62 | PickWith<VideoChannelModel, 'Actor', MActorDefault> | ||
63 | |||
64 | export type MChannelActorAccountActor = MChannelAccountActor & MChannelActor | ||
65 | |||
66 | export type MChannelActorAccountDefault = MChannel & | ||
67 | PickWith<VideoChannelModel, 'Actor', MActorDefault> & | ||
68 | PickWith<VideoChannelModel, 'Account', MAccountDefault> | ||
69 | |||
70 | export type MChannelActorAccountDefaultVideos = MChannelActorAccountDefault & MChannelVideos | ||
diff --git a/server/typings/models/video/video-comment.ts b/server/typings/models/video/video-comment.ts new file mode 100644 index 000000000..675613804 --- /dev/null +++ b/server/typings/models/video/video-comment.ts | |||
@@ -0,0 +1,29 @@ | |||
1 | import { VideoCommentModel } from '../../../models/video/video-comment' | ||
2 | import { PickWith } from '../../utils' | ||
3 | import { MAccountDefault } from '../account' | ||
4 | import { MVideoAccountDefault, MVideoAccountLight, MVideoFeed, MVideoIdUrl } from './video' | ||
5 | |||
6 | export type MComment = Omit<VideoCommentModel, 'OriginVideoComment' | 'InReplyToVideoComment' | 'Video' | 'Account'> | ||
7 | export type MCommentId = Pick<MComment, 'id'> | ||
8 | |||
9 | export type MCommentAPI = MComment & { totalReplies: number } | ||
10 | |||
11 | export type MCommentOwner = MComment & | ||
12 | PickWith<VideoCommentModel, 'Account', MAccountDefault> | ||
13 | |||
14 | export type MCommentVideo = MComment & | ||
15 | PickWith<VideoCommentModel, 'Video', MVideoAccountLight> | ||
16 | |||
17 | export type MCommentReply = MComment & | ||
18 | PickWith<VideoCommentModel, 'InReplyToVideoComment', MComment> | ||
19 | |||
20 | export type MCommentOwnerReply = MCommentOwner & MCommentReply | ||
21 | export type MCommentOwnerVideo = MCommentOwner & MCommentVideo | ||
22 | export type MCommentReplyVideo = MCommentReply & MCommentVideo | ||
23 | export type MCommentOwnerVideoReply = MCommentOwnerVideo & MCommentReply | ||
24 | |||
25 | export type MCommentOwnerReplyVideoLight = MCommentOwnerReply & | ||
26 | PickWith<VideoCommentModel, 'Video', MVideoIdUrl> | ||
27 | |||
28 | export type MCommentOwnerVideoFeed = MCommentOwner & | ||
29 | PickWith<VideoCommentModel, 'Video', MVideoFeed> | ||
diff --git a/server/typings/models/video/video-file.ts b/server/typings/models/video/video-file.ts new file mode 100644 index 000000000..afa659d1f --- /dev/null +++ b/server/typings/models/video/video-file.ts | |||
@@ -0,0 +1,15 @@ | |||
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 | export type MVideoFile = Omit<VideoFileModel, 'Video' | 'RedundancyVideos'> | ||
7 | |||
8 | export type MVideoFileVideo = MVideoFile & | ||
9 | PickWith<VideoFileModel, 'Video', MVideo> | ||
10 | |||
11 | export type MVideoFileVideoUUID = MVideoFile & | ||
12 | PickWith<VideoFileModel, 'Video', MVideoUUID> | ||
13 | |||
14 | export type MVideoFileRedundanciesOpt = MVideoFile & | ||
15 | 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..51be900d6 --- /dev/null +++ b/server/typings/models/video/video-import.ts | |||
@@ -0,0 +1,15 @@ | |||
1 | import { VideoImportModel } from '@server/models/video/video-import' | ||
2 | import { PickWith } from '@server/typings/utils' | ||
3 | import { MUser, MVideo, MVideoAccountLight, MVideoTag, MVideoThumbnail, MVideoWithFile } from '@server/typings/models' | ||
4 | |||
5 | export type MVideoImport = Omit<VideoImportModel, 'User' | 'Video'> | ||
6 | |||
7 | export type MVideoImportDefault = MVideoImport & | ||
8 | PickWith<VideoImportModel, 'User', MUser> & | ||
9 | PickWith<VideoImportModel, 'Video', MVideoTag & MVideoAccountLight & MVideoThumbnail> | ||
10 | |||
11 | export type MVideoImportDefaultFiles = MVideoImportDefault & | ||
12 | PickWith<VideoImportModel, 'Video', MVideoTag & MVideoAccountLight & MVideoThumbnail & MVideoWithFile> | ||
13 | |||
14 | export type MVideoImportVideo = MVideoImport & | ||
15 | PickWith<VideoImportModel, 'Video', MVideo> | ||
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..d1b8a18a0 --- /dev/null +++ b/server/typings/models/video/video-playlist-element.ts | |||
@@ -0,0 +1,15 @@ | |||
1 | import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element' | ||
2 | import { PickWith } from '@server/typings/utils' | ||
3 | import { MVideoPlaylistPrivacy, MVideoThumbnail, MVideoUrl } from '@server/typings/models' | ||
4 | |||
5 | export type MVideoPlaylistElement = Omit<VideoPlaylistElementModel, 'VideoPlaylist' | 'Video'> | ||
6 | export type MVideoPlaylistElementId = Pick<MVideoPlaylistElement, 'id'> | ||
7 | |||
8 | export type MVideoPlaylistElementLight = Pick<MVideoPlaylistElement, 'id' | 'videoId' | 'startTimestamp' | 'stopTimestamp'> | ||
9 | |||
10 | export type MVideoPlaylistVideoThumbnail = MVideoPlaylistElement & | ||
11 | PickWith<VideoPlaylistElementModel, 'Video', MVideoThumbnail> | ||
12 | |||
13 | export type MVideoPlaylistAP = MVideoPlaylistElement & | ||
14 | PickWith<VideoPlaylistElementModel, 'Video', MVideoUrl> & | ||
15 | PickWith<VideoPlaylistElementModel, 'VideoPlaylist', MVideoPlaylistPrivacy> | ||
diff --git a/server/typings/models/video/video-playlist.ts b/server/typings/models/video/video-playlist.ts new file mode 100644 index 000000000..825b3391c --- /dev/null +++ b/server/typings/models/video/video-playlist.ts | |||
@@ -0,0 +1,42 @@ | |||
1 | import { VideoPlaylistModel } from '../../../models/video/video-playlist' | ||
2 | import { PickWith } from '../../utils' | ||
3 | import { MAccount, MAccountDefault, MAccountSummary } from '../account' | ||
4 | import { MThumbnail } from './thumbnail' | ||
5 | import { MChannelDefault, MChannelSummary } from './video-channels' | ||
6 | import { MVideoPlaylistElementLight } from '@server/typings/models/video/video-playlist-element' | ||
7 | |||
8 | export type MVideoPlaylist = Omit<VideoPlaylistModel, 'OwnerAccount' | 'VideoChannel' | 'VideoPlaylistElements' | 'Thumbnail'> | ||
9 | export type MVideoPlaylistId = Pick<MVideoPlaylist, 'id'> | ||
10 | export type MVideoPlaylistPrivacy = Pick<MVideoPlaylist, 'privacy'> | ||
11 | |||
12 | export type MVideoPlaylistWithElements = MVideoPlaylist & | ||
13 | PickWith<VideoPlaylistModel, 'VideoPlaylistElements', MVideoPlaylistElementLight[]> | ||
14 | export type MVideoPlaylistIdWithElements = MVideoPlaylistId & MVideoPlaylistWithElements | ||
15 | |||
16 | export type MVideoPlaylistUUID = Pick<MVideoPlaylist, 'uuid'> | ||
17 | |||
18 | export type MVideoPlaylistOwner = MVideoPlaylist & | ||
19 | PickWith<VideoPlaylistModel, 'OwnerAccount', MAccount> | ||
20 | |||
21 | export type MVideoPlaylistOwnerDefault = MVideoPlaylist & | ||
22 | PickWith<VideoPlaylistModel, 'OwnerAccount', MAccountDefault> | ||
23 | |||
24 | export type MVideoPlaylistThumbnail = MVideoPlaylist & | ||
25 | PickWith<VideoPlaylistModel, 'Thumbnail', MThumbnail> | ||
26 | |||
27 | export type MVideoPlaylistAccountThumbnail = MVideoPlaylistOwnerDefault & | ||
28 | PickWith<VideoPlaylistModel, 'Thumbnail', MThumbnail> | ||
29 | |||
30 | export type MVideoPlaylistAccountChannelSummary = MVideoPlaylist & | ||
31 | PickWith<VideoPlaylistModel, 'OwnerAccount', MAccountSummary> & | ||
32 | PickWith<VideoPlaylistModel, 'VideoChannel', MChannelSummary> | ||
33 | |||
34 | export type MVideoPlaylistAccountChannelDefault = MVideoPlaylist & | ||
35 | PickWith<VideoPlaylistModel, 'OwnerAccount', MAccountDefault> & | ||
36 | PickWith<VideoPlaylistModel, 'VideoChannel', MChannelDefault> | ||
37 | |||
38 | export type MVideoPlaylistVideosLength = MVideoPlaylist & { videosLength: number } | ||
39 | |||
40 | export type MVideoPlaylistFullSummary = MVideoPlaylistAccountChannelSummary & MVideoPlaylistThumbnail | ||
41 | |||
42 | export type MVideoPlaylistFull = MVideoPlaylist & MVideoPlaylistThumbnail & MVideoPlaylistAccountChannelDefault | ||
diff --git a/server/typings/models/video/video-rate.ts b/server/typings/models/video/video-rate.ts new file mode 100644 index 000000000..6eefe6362 --- /dev/null +++ b/server/typings/models/video/video-rate.ts | |||
@@ -0,0 +1,12 @@ | |||
1 | import { AccountVideoRateModel } from '@server/models/account/account-video-rate' | ||
2 | import { PickWith } from '@server/typings/utils' | ||
3 | import { MAccountAudience, MAccountUrl, MVideo } from '..' | ||
4 | |||
5 | export type MAccountVideoRate = Omit<AccountVideoRateModel, 'Video' | 'Account'> | ||
6 | |||
7 | export type MAccountVideoRateAccountUrl = MAccountVideoRate & | ||
8 | PickWith<AccountVideoRateModel, 'Account', MAccountUrl> | ||
9 | |||
10 | export type MAccountVideoRateAccountVideo = MAccountVideoRate & | ||
11 | PickWith<AccountVideoRateModel, 'Account', MAccountAudience> & | ||
12 | PickWith<AccountVideoRateModel, 'Video', MVideo> | ||
diff --git a/server/typings/models/video/video-redundancy.ts b/server/typings/models/video/video-redundancy.ts new file mode 100644 index 000000000..ec61bfb68 --- /dev/null +++ b/server/typings/models/video/video-redundancy.ts | |||
@@ -0,0 +1,18 @@ | |||
1 | import { VideoRedundancyModel } from '../../../models/redundancy/video-redundancy' | ||
2 | import { PickWith } from '@server/typings/utils' | ||
3 | import { MStreamingPlaylistVideo, MVideoFile, MVideoFileVideo } from '@server/typings/models' | ||
4 | |||
5 | export type MVideoRedundancy = Omit<VideoRedundancyModel, 'VideoFile' | 'VideoStreamingPlaylist' | 'Actor'> | ||
6 | |||
7 | export type MVideoRedundancyFileUrl = Pick<MVideoRedundancy, 'fileUrl'> | ||
8 | |||
9 | export type MVideoRedundancyFile = MVideoRedundancy & | ||
10 | PickWith<VideoRedundancyModel, 'VideoFile', MVideoFile> | ||
11 | |||
12 | export type MVideoRedundancyFileVideo = MVideoRedundancy & | ||
13 | PickWith<VideoRedundancyModel, 'VideoFile', MVideoFileVideo> | ||
14 | |||
15 | export type MVideoRedundancyStreamingPlaylistVideo = MVideoRedundancy & | ||
16 | PickWith<VideoRedundancyModel, 'VideoStreamingPlaylist', MStreamingPlaylistVideo> | ||
17 | |||
18 | export type MVideoRedundancyVideo = MVideoRedundancyFileVideo | MVideoRedundancyStreamingPlaylistVideo | ||
diff --git a/server/typings/models/video/video-share.ts b/server/typings/models/video/video-share.ts new file mode 100644 index 000000000..7e8cb8b61 --- /dev/null +++ b/server/typings/models/video/video-share.ts | |||
@@ -0,0 +1,12 @@ | |||
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 | export type MVideoShare = Omit<VideoShareModel, 'Actor' | 'Video'> | ||
7 | |||
8 | export type MVideoShareActor = MVideoShare & | ||
9 | PickWith<VideoShareModel, 'Actor', MActorDefault> | ||
10 | |||
11 | export type MVideoShareFull = MVideoShareActor & | ||
12 | PickWith<VideoShareModel, '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..5b6310771 --- /dev/null +++ b/server/typings/models/video/video-streaming-playlist.ts | |||
@@ -0,0 +1,12 @@ | |||
1 | import { VideoStreamingPlaylistModel } from '../../../models/video/video-streaming-playlist' | ||
2 | import { PickWith } from '../../utils' | ||
3 | import { MVideoRedundancyFileUrl } from './video-redundancy' | ||
4 | import { MVideo } from '@server/typings/models' | ||
5 | |||
6 | export type MStreamingPlaylist = Omit<VideoStreamingPlaylistModel, 'Video' | 'RedundancyVideos'> | ||
7 | |||
8 | export type MStreamingPlaylistVideo = MStreamingPlaylist & | ||
9 | PickWith<VideoStreamingPlaylistModel, 'Video', MVideo> | ||
10 | |||
11 | export type MStreamingPlaylistRedundancies = MStreamingPlaylist & | ||
12 | PickWith<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..0ffd0c302 --- /dev/null +++ b/server/typings/models/video/video.ts | |||
@@ -0,0 +1,103 @@ | |||
1 | import { VideoModel } from '../../../models/video/video' | ||
2 | import { PickWith, PickWithOpt } from '../../utils' | ||
3 | import { MChannelAccountLight, MChannelActor, MChannelActorAccountDefault, MChannelUserId } from './video-channels' | ||
4 | import { MTag } from './tag' | ||
5 | import { MVideoCaptionLanguage } from './video-caption' | ||
6 | import { MStreamingPlaylist, MStreamingPlaylistRedundancies } from './video-streaming-playlist' | ||
7 | import { MVideoFile, MVideoFileRedundanciesOpt } from './video-file' | ||
8 | import { MThumbnail } from './thumbnail' | ||
9 | import { MVideoBlacklistLight, MVideoBlacklistUnfederated } from './video-blacklist' | ||
10 | import { MScheduleVideoUpdate } from './schedule-video-update' | ||
11 | import { MUserVideoHistoryTime } from '../user/user-video-history' | ||
12 | |||
13 | export type MVideo = Omit<VideoModel, 'VideoChannel' | 'Tags' | 'Thumbnails' | 'VideoPlaylistElements' | 'VideoAbuses' | | ||
14 | 'VideoFiles' | 'VideoStreamingPlaylists' | 'VideoShares' | 'AccountVideoRates' | 'VideoComments' | 'VideoViews' | 'UserVideoHistories' | | ||
15 | 'ScheduleVideoUpdate' | 'VideoBlacklist' | 'VideoImport' | 'VideoCaptions'> | ||
16 | |||
17 | export type MVideoId = Pick<MVideo, 'id'> | ||
18 | export type MVideoUrl = Pick<MVideo, 'url'> | ||
19 | export type MVideoUUID = Pick<MVideo, 'uuid'> | ||
20 | |||
21 | export type MVideoIdUrl = MVideoId & MVideoUrl | ||
22 | export type MVideoFeed = Pick<MVideo, 'name' | 'uuid'> | ||
23 | |||
24 | export type MVideoWithFile = MVideo & | ||
25 | PickWith<VideoModel, 'VideoFiles', MVideoFile[]> | ||
26 | |||
27 | export type MVideoThumbnail = MVideo & | ||
28 | PickWith<VideoModel, 'Thumbnails', MThumbnail[]> | ||
29 | export type MVideoIdThumbnail = MVideoThumbnail & MVideoId | ||
30 | |||
31 | export type MVideoTag = MVideo & | ||
32 | PickWith<VideoModel, 'Tags', MTag[]> | ||
33 | |||
34 | export type MVideoWithSchedule = MVideo & | ||
35 | PickWithOpt<VideoModel, 'ScheduleVideoUpdate', MScheduleVideoUpdate> | ||
36 | |||
37 | export type MVideoWithFileThumbnail = MVideoWithFile & MVideoThumbnail | ||
38 | |||
39 | export type MVideoUser = MVideo & | ||
40 | PickWith<VideoModel, 'VideoChannel', MChannelUserId> | ||
41 | |||
42 | export type MVideoWithCaptions = MVideo & | ||
43 | PickWith<VideoModel, 'VideoCaptions', MVideoCaptionLanguage[]> | ||
44 | |||
45 | export type MVideoWithBlacklistLight = MVideo & | ||
46 | PickWith<VideoModel, 'VideoBlacklist', MVideoBlacklistLight> | ||
47 | |||
48 | export type MVideoAccountLight = MVideo & | ||
49 | PickWith<VideoModel, 'VideoChannel', MChannelAccountLight> | ||
50 | |||
51 | export type MVideoWithRights = MVideoWithBlacklistLight & MVideoThumbnail & MVideoUser | ||
52 | |||
53 | export type MVideoWithStreamingPlaylist = MVideo & | ||
54 | PickWith<VideoModel, 'VideoStreamingPlaylists', MStreamingPlaylist[]> | ||
55 | |||
56 | export type MVideoWithAllFiles = MVideoWithFileThumbnail & MVideoWithStreamingPlaylist | ||
57 | |||
58 | export type MVideoAccountAllFiles = MVideoWithAllFiles & MVideoAccountLight & MVideoWithBlacklistLight | ||
59 | export type MVideoAccountAllFilesCaptions = MVideoAccountAllFiles & MVideoWithCaptions | ||
60 | |||
61 | export type MVideoUserHistory = MVideo & | ||
62 | PickWith<VideoModel, 'UserVideoHistories', MUserVideoHistoryTime[]> | ||
63 | |||
64 | export type MVideoWithBlacklistThumbnailScheduled = MVideoWithSchedule & MVideoWithBlacklistLight & MVideoWithFileThumbnail | ||
65 | |||
66 | export type MVideoAccountDefault = MVideo & | ||
67 | PickWith<VideoModel, 'VideoChannel', MChannelActorAccountDefault> | ||
68 | |||
69 | export type MVideoThumbnailAccountDefault = MVideoThumbnail & | ||
70 | PickWith<VideoModel, 'VideoChannel', MChannelActorAccountDefault> | ||
71 | |||
72 | export type MVideoWithChannelActor = MVideo & | ||
73 | PickWith<VideoModel, 'VideoChannel', MChannelActor> | ||
74 | |||
75 | export type MVideoFullLight = MVideoThumbnail & | ||
76 | MVideoWithBlacklistLight & | ||
77 | MVideoTag & | ||
78 | MVideoAccountLight & | ||
79 | MVideoUserHistory & | ||
80 | MVideoWithFile & | ||
81 | MVideoWithSchedule & | ||
82 | MVideoWithStreamingPlaylist & | ||
83 | MVideoUserHistory | ||
84 | |||
85 | export type MVideoAP = MVideo & | ||
86 | MVideoTag & | ||
87 | MVideoAccountLight & | ||
88 | MVideoWithStreamingPlaylist & | ||
89 | MVideoWithCaptions & | ||
90 | PickWith<VideoModel, 'VideoBlacklist', MVideoBlacklistUnfederated> & | ||
91 | PickWith<VideoModel, 'VideoFiles', MVideoFileRedundanciesOpt[]> | ||
92 | |||
93 | export type MVideoAPWithoutCaption = Omit<MVideoAP, 'VideoCaptions'> | ||
94 | |||
95 | export type MVideoDetails = MVideo & | ||
96 | MVideoWithBlacklistLight & | ||
97 | MVideoTag & | ||
98 | MVideoAccountLight & | ||
99 | MVideoWithSchedule & | ||
100 | MVideoThumbnail & | ||
101 | MVideoUserHistory & | ||
102 | PickWith<VideoModel, 'VideoStreamingPlaylists', MStreamingPlaylistRedundancies[]> & | ||
103 | PickWith<VideoModel, 'VideoFiles', MVideoFileRedundanciesOpt[]> | ||
diff --git a/server/typings/utils.ts b/server/typings/utils.ts index a86b05be2..ed0fca3d1 100644 --- a/server/typings/utils.ts +++ b/server/typings/utils.ts | |||
@@ -1,3 +1,15 @@ | |||
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 ValueOf <T, KT extends keyof T> = T[KT] | ||
8 | |||
9 | export type PickWith<T, KT extends keyof T, V> = { | ||
10 | [P in KT]: T[P] extends V ? V : never | ||
11 | } | ||
12 | |||
13 | export type PickWithOpt<T, KT extends keyof T, V> = { | ||
14 | [P in KT]?: T[P] extends V ? V : never | ||
15 | } | ||