diff options
author | Chocobozzz <me@florianbigard.com> | 2020-06-18 10:45:25 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-06-18 10:46:27 +0200 |
commit | 26d6bf6533023326fa017812cf31bbe20c752d36 (patch) | |
tree | 9c4e3ecdc344420190f17d429bdf05d78fae7a8c /server/typings/models/account | |
parent | d6d951ddc0c492f3261065b5dcb4df0534d252fc (diff) | |
download | PeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.tar.gz PeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.tar.zst PeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.zip |
Split types and typings
Diffstat (limited to 'server/typings/models/account')
-rw-r--r-- | server/typings/models/account/account-blocklist.ts | 27 | ||||
-rw-r--r-- | server/typings/models/account/account.ts | 109 | ||||
-rw-r--r-- | server/typings/models/account/actor-follow.ts | 70 | ||||
-rw-r--r-- | server/typings/models/account/actor.ts | 139 | ||||
-rw-r--r-- | server/typings/models/account/avatar.ts | 12 | ||||
-rw-r--r-- | server/typings/models/account/index.ts | 5 |
6 files changed, 0 insertions, 362 deletions
diff --git a/server/typings/models/account/account-blocklist.ts b/server/typings/models/account/account-blocklist.ts deleted file mode 100644 index 0d8bf11bd..000000000 --- a/server/typings/models/account/account-blocklist.ts +++ /dev/null | |||
@@ -1,27 +0,0 @@ | |||
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 = | ||
16 | MAccountBlocklist & | ||
17 | Use<'ByAccount', MAccountDefault> & | ||
18 | Use<'BlockedAccount', MAccountDefault> | ||
19 | |||
20 | // ############################################################################ | ||
21 | |||
22 | // Format for API or AP object | ||
23 | |||
24 | export type MAccountBlocklistFormattable = | ||
25 | Pick<MAccountBlocklist, 'createdAt'> & | ||
26 | Use<'ByAccount', MAccountFormattable> & | ||
27 | Use<'BlockedAccount', MAccountFormattable> | ||
diff --git a/server/typings/models/account/account.ts b/server/typings/models/account/account.ts deleted file mode 100644 index 7b826ee04..000000000 --- a/server/typings/models/account/account.ts +++ /dev/null | |||
@@ -1,109 +0,0 @@ | |||
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 '../video/video-channels' | ||
19 | |||
20 | type Use<K extends keyof AccountModel, M> = PickWith<AccountModel, K, M> | ||
21 | |||
22 | // ############################################################################ | ||
23 | |||
24 | export type MAccount = | ||
25 | Omit<AccountModel, 'Actor' | 'User' | 'Application' | 'VideoChannels' | 'VideoPlaylists' | | ||
26 | 'VideoComments' | 'BlockedAccounts'> | ||
27 | |||
28 | // ############################################################################ | ||
29 | |||
30 | // Only some attributes | ||
31 | export type MAccountId = Pick<MAccount, 'id'> | ||
32 | export type MAccountUserId = Pick<MAccount, 'userId'> | ||
33 | |||
34 | // Only some Actor attributes | ||
35 | export type MAccountUrl = Use<'Actor', MActorUrl> | ||
36 | export type MAccountAudience = Use<'Actor', MActorAudience> | ||
37 | |||
38 | export type MAccountIdActor = | ||
39 | MAccountId & | ||
40 | Use<'Actor', MActor> | ||
41 | |||
42 | export type MAccountIdActorId = | ||
43 | MAccountId & | ||
44 | Use<'Actor', MActorId> | ||
45 | |||
46 | // ############################################################################ | ||
47 | |||
48 | // Default scope | ||
49 | export type MAccountDefault = | ||
50 | MAccount & | ||
51 | Use<'Actor', MActorDefault> | ||
52 | |||
53 | // Default with default association scopes | ||
54 | export type MAccountDefaultChannelDefault = | ||
55 | MAccount & | ||
56 | Use<'Actor', MActorDefault> & | ||
57 | Use<'VideoChannels', MChannelDefault[]> | ||
58 | |||
59 | // We don't need some actors attributes | ||
60 | export type MAccountLight = | ||
61 | MAccount & | ||
62 | Use<'Actor', MActorDefaultLight> | ||
63 | |||
64 | // ############################################################################ | ||
65 | |||
66 | // Full actor | ||
67 | export type MAccountActor = | ||
68 | MAccount & | ||
69 | Use<'Actor', MActor> | ||
70 | |||
71 | // Full actor with server | ||
72 | export type MAccountServer = | ||
73 | MAccount & | ||
74 | Use<'Actor', MActorServer> | ||
75 | |||
76 | // ############################################################################ | ||
77 | |||
78 | // For API | ||
79 | |||
80 | export type MAccountSummary = | ||
81 | FunctionProperties<MAccount> & | ||
82 | Pick<MAccount, 'id' | 'name'> & | ||
83 | Use<'Actor', MActorSummary> | ||
84 | |||
85 | export type MAccountSummaryBlocks = | ||
86 | MAccountSummary & | ||
87 | Use<'BlockedAccounts', MAccountBlocklistId[]> | ||
88 | |||
89 | export type MAccountAPI = | ||
90 | MAccount & | ||
91 | Use<'Actor', MActorAPI> | ||
92 | |||
93 | // ############################################################################ | ||
94 | |||
95 | // Format for API or AP object | ||
96 | |||
97 | export type MAccountSummaryFormattable = | ||
98 | FunctionProperties<MAccount> & | ||
99 | Pick<MAccount, 'id' | 'name'> & | ||
100 | Use<'Actor', MActorSummaryFormattable> | ||
101 | |||
102 | export type MAccountFormattable = | ||
103 | FunctionProperties<MAccount> & | ||
104 | Pick<MAccount, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'userId'> & | ||
105 | Use<'Actor', MActorFormattable> | ||
106 | |||
107 | export type MAccountAP = | ||
108 | Pick<MAccount, 'name' | 'description'> & | ||
109 | Use<'Actor', MActorAP> | ||
diff --git a/server/typings/models/account/actor-follow.ts b/server/typings/models/account/actor-follow.ts deleted file mode 100644 index 5d0c03c8d..000000000 --- a/server/typings/models/account/actor-follow.ts +++ /dev/null | |||
@@ -1,70 +0,0 @@ | |||
1 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | ||
2 | import { | ||
3 | MActor, | ||
4 | MActorChannelAccountActor, | ||
5 | MActorDefault, | ||
6 | MActorDefaultAccountChannel, | ||
7 | MActorFormattable, | ||
8 | MActorHost, | ||
9 | MActorUsername | ||
10 | } from './actor' | ||
11 | import { PickWith } from '../../utils' | ||
12 | import { ActorModel } from '@server/models/activitypub/actor' | ||
13 | import { MChannelDefault } from '../video/video-channels' | ||
14 | |||
15 | type Use<K extends keyof ActorFollowModel, M> = PickWith<ActorFollowModel, K, M> | ||
16 | |||
17 | // ############################################################################ | ||
18 | |||
19 | export type MActorFollow = Omit<ActorFollowModel, 'ActorFollower' | 'ActorFollowing'> | ||
20 | |||
21 | // ############################################################################ | ||
22 | |||
23 | export type MActorFollowFollowingHost = | ||
24 | MActorFollow & | ||
25 | Use<'ActorFollowing', MActorUsername & MActorHost> | ||
26 | |||
27 | // ############################################################################ | ||
28 | |||
29 | // With actors or actors default | ||
30 | |||
31 | export type MActorFollowActors = | ||
32 | MActorFollow & | ||
33 | Use<'ActorFollower', MActor> & | ||
34 | Use<'ActorFollowing', MActor> | ||
35 | |||
36 | export type MActorFollowActorsDefault = | ||
37 | MActorFollow & | ||
38 | Use<'ActorFollower', MActorDefault> & | ||
39 | Use<'ActorFollowing', MActorDefault> | ||
40 | |||
41 | export type MActorFollowFull = | ||
42 | MActorFollow & | ||
43 | Use<'ActorFollower', MActorDefaultAccountChannel> & | ||
44 | Use<'ActorFollowing', MActorDefaultAccountChannel> | ||
45 | |||
46 | // ############################################################################ | ||
47 | |||
48 | // For subscriptions | ||
49 | |||
50 | type SubscriptionFollowing = | ||
51 | MActorDefault & | ||
52 | PickWith<ActorModel, 'VideoChannel', MChannelDefault> | ||
53 | |||
54 | export type MActorFollowActorsDefaultSubscription = | ||
55 | MActorFollow & | ||
56 | Use<'ActorFollower', MActorDefault> & | ||
57 | Use<'ActorFollowing', SubscriptionFollowing> | ||
58 | |||
59 | export type MActorFollowSubscriptions = | ||
60 | MActorFollow & | ||
61 | Use<'ActorFollowing', MActorChannelAccountActor> | ||
62 | |||
63 | // ############################################################################ | ||
64 | |||
65 | // Format for API or AP object | ||
66 | |||
67 | export type MActorFollowFormattable = | ||
68 | Pick<MActorFollow, 'id' | 'score' | 'state' | 'createdAt' | 'updatedAt'> & | ||
69 | Use<'ActorFollower', MActorFormattable> & | ||
70 | Use<'ActorFollowing', MActorFormattable> | ||
diff --git a/server/typings/models/account/actor.ts b/server/typings/models/account/actor.ts deleted file mode 100644 index 1160e84cb..000000000 --- a/server/typings/models/account/actor.ts +++ /dev/null | |||
@@ -1,139 +0,0 @@ | |||
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 MActorWithInboxes = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl' | 'getSharedInbox'> | ||
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 = | ||
35 | MActorLight & | ||
36 | Use<'Server', MServerHost> & | ||
37 | Use<'Avatar', MAvatar> | ||
38 | |||
39 | export type MActorAccountId = | ||
40 | MActor & | ||
41 | Use<'Account', MAccountId> | ||
42 | export type MActorAccountIdActor = | ||
43 | MActor & | ||
44 | Use<'Account', MAccountIdActor> | ||
45 | |||
46 | export type MActorChannelId = | ||
47 | MActor & | ||
48 | Use<'VideoChannel', MChannelId> | ||
49 | export type MActorChannelIdActor = | ||
50 | MActor & | ||
51 | Use<'VideoChannel', MChannelIdActor> | ||
52 | |||
53 | export type MActorAccountChannelId = MActorAccountId & MActorChannelId | ||
54 | export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor | ||
55 | |||
56 | // ############################################################################ | ||
57 | |||
58 | // Include raw account/channel/server | ||
59 | |||
60 | export type MActorAccount = | ||
61 | MActor & | ||
62 | Use<'Account', MAccount> | ||
63 | |||
64 | export type MActorChannel = | ||
65 | MActor & | ||
66 | Use<'VideoChannel', MChannel> | ||
67 | |||
68 | export type MActorDefaultAccountChannel = MActorDefault & MActorAccount & MActorChannel | ||
69 | |||
70 | export type MActorServer = | ||
71 | MActor & | ||
72 | Use<'Server', MServer> | ||
73 | |||
74 | // ############################################################################ | ||
75 | |||
76 | // Complex actor associations | ||
77 | |||
78 | export type MActorDefault = | ||
79 | MActor & | ||
80 | Use<'Server', MServer> & | ||
81 | Use<'Avatar', MAvatar> | ||
82 | |||
83 | // Actor with channel that is associated to an account and its actor | ||
84 | // Actor -> VideoChannel -> Account -> Actor | ||
85 | export type MActorChannelAccountActor = | ||
86 | MActor & | ||
87 | Use<'VideoChannel', MChannelAccountActor> | ||
88 | |||
89 | export type MActorFull = | ||
90 | MActor & | ||
91 | Use<'Server', MServer> & | ||
92 | Use<'Avatar', MAvatar> & | ||
93 | Use<'Account', MAccount> & | ||
94 | Use<'VideoChannel', MChannelAccountActor> | ||
95 | |||
96 | // Same than ActorFull, but the account and the channel have their actor | ||
97 | export type MActorFullActor = | ||
98 | MActor & | ||
99 | Use<'Server', MServer> & | ||
100 | Use<'Avatar', MAvatar> & | ||
101 | Use<'Account', MAccountDefault> & | ||
102 | Use<'VideoChannel', MChannelAccountDefault> | ||
103 | |||
104 | // ############################################################################ | ||
105 | |||
106 | // API | ||
107 | |||
108 | export type MActorSummary = | ||
109 | FunctionProperties<MActor> & | ||
110 | Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> & | ||
111 | Use<'Server', MServerHost> & | ||
112 | Use<'Avatar', MAvatar> | ||
113 | |||
114 | export type MActorSummaryBlocks = | ||
115 | MActorSummary & | ||
116 | Use<'Server', MServerHostBlocks> | ||
117 | |||
118 | export type MActorAPI = | ||
119 | Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' | | ||
120 | 'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'> | ||
121 | |||
122 | // ############################################################################ | ||
123 | |||
124 | // Format for API or AP object | ||
125 | |||
126 | export type MActorSummaryFormattable = | ||
127 | FunctionProperties<MActor> & | ||
128 | Pick<MActor, 'url' | 'preferredUsername'> & | ||
129 | Use<'Server', MServerHost> & | ||
130 | Use<'Avatar', MAvatarFormattable> | ||
131 | |||
132 | export type MActorFormattable = | ||
133 | MActorSummaryFormattable & | ||
134 | Pick<MActor, 'id' | 'followingCount' | 'followersCount' | 'createdAt' | 'updatedAt'> & | ||
135 | Use<'Server', MServerHost & Partial<Pick<MServer, 'redundancyAllowed'>>> | ||
136 | |||
137 | export type MActorAP = | ||
138 | MActor & | ||
139 | Use<'Avatar', MAvatar> | ||
diff --git a/server/typings/models/account/avatar.ts b/server/typings/models/account/avatar.ts deleted file mode 100644 index 21b47180f..000000000 --- a/server/typings/models/account/avatar.ts +++ /dev/null | |||
@@ -1,12 +0,0 @@ | |||
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 = | ||
11 | FunctionProperties<MAvatar> & | ||
12 | Pick<MAvatar, 'filename' | 'createdAt' | 'updatedAt'> | ||
diff --git a/server/typings/models/account/index.ts b/server/typings/models/account/index.ts deleted file mode 100644 index 513c09c40..000000000 --- a/server/typings/models/account/index.ts +++ /dev/null | |||
@@ -1,5 +0,0 @@ | |||
1 | export * from './account' | ||
2 | export * from './account-blocklist' | ||
3 | export * from './actor' | ||
4 | export * from './actor-follow' | ||
5 | export * from './avatar' | ||