diff options
author | Chocobozzz <me@florianbigard.com> | 2021-05-11 11:15:29 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-05-11 11:32:31 +0200 |
commit | 7d9ba5c08999c6482f0bc5e0c09c6f55b7724090 (patch) | |
tree | 5f4ea1f06dcb781c9e61062522b53a28a401111f /server/types/models/account | |
parent | c07902b9083ab5756436cd020bed5bdfa51028bf (diff) | |
download | PeerTube-7d9ba5c08999c6482f0bc5e0c09c6f55b7724090.tar.gz PeerTube-7d9ba5c08999c6482f0bc5e0c09c6f55b7724090.tar.zst PeerTube-7d9ba5c08999c6482f0bc5e0c09c6f55b7724090.zip |
Cleanup models directory organization
Diffstat (limited to 'server/types/models/account')
-rw-r--r-- | server/types/models/account/account.ts | 6 | ||||
-rw-r--r-- | server/types/models/account/actor-follow.ts | 65 | ||||
-rw-r--r-- | server/types/models/account/actor-image.ts | 12 | ||||
-rw-r--r-- | server/types/models/account/actor.ts | 166 | ||||
-rw-r--r-- | server/types/models/account/index.ts | 3 |
5 files changed, 3 insertions, 249 deletions
diff --git a/server/types/models/account/account.ts b/server/types/models/account/account.ts index 9513acad8..984841291 100644 --- a/server/types/models/account/account.ts +++ b/server/types/models/account/account.ts | |||
@@ -1,7 +1,5 @@ | |||
1 | import { FunctionProperties, PickWith } from '@shared/core-utils' | 1 | import { FunctionProperties, PickWith } from '@shared/core-utils' |
2 | import { AccountModel } from '../../../models/account/account' | 2 | import { AccountModel } from '../../../models/account/account' |
3 | import { MChannelDefault } from '../video/video-channels' | ||
4 | import { MAccountBlocklistId } from './account-blocklist' | ||
5 | import { | 3 | import { |
6 | MActor, | 4 | MActor, |
7 | MActorAPAccount, | 5 | MActorAPAccount, |
@@ -15,7 +13,9 @@ import { | |||
15 | MActorSummary, | 13 | MActorSummary, |
16 | MActorSummaryFormattable, | 14 | MActorSummaryFormattable, |
17 | MActorUrl | 15 | MActorUrl |
18 | } from './actor' | 16 | } from '../actor' |
17 | import { MChannelDefault } from '../video/video-channels' | ||
18 | import { MAccountBlocklistId } from './account-blocklist' | ||
19 | 19 | ||
20 | type Use<K extends keyof AccountModel, M> = PickWith<AccountModel, K, M> | 20 | type Use<K extends keyof AccountModel, M> = PickWith<AccountModel, K, M> |
21 | 21 | ||
diff --git a/server/types/models/account/actor-follow.ts b/server/types/models/account/actor-follow.ts deleted file mode 100644 index 8e19c6140..000000000 --- a/server/types/models/account/actor-follow.ts +++ /dev/null | |||
@@ -1,65 +0,0 @@ | |||
1 | import { PickWith } from '@shared/core-utils' | ||
2 | import { ActorFollowModel } from '../../../models/activitypub/actor-follow' | ||
3 | import { | ||
4 | MActor, | ||
5 | MActorChannelAccountActor, | ||
6 | MActorDefault, | ||
7 | MActorDefaultAccountChannel, | ||
8 | MActorDefaultChannelId, | ||
9 | MActorFormattable, | ||
10 | MActorHost, | ||
11 | MActorUsername | ||
12 | } from './actor' | ||
13 | |||
14 | type Use<K extends keyof ActorFollowModel, M> = PickWith<ActorFollowModel, K, M> | ||
15 | |||
16 | // ############################################################################ | ||
17 | |||
18 | export type MActorFollow = Omit<ActorFollowModel, 'ActorFollower' | 'ActorFollowing'> | ||
19 | |||
20 | // ############################################################################ | ||
21 | |||
22 | export type MActorFollowFollowingHost = | ||
23 | MActorFollow & | ||
24 | Use<'ActorFollowing', MActorUsername & MActorHost> | ||
25 | |||
26 | // ############################################################################ | ||
27 | |||
28 | // With actors or actors default | ||
29 | |||
30 | export type MActorFollowActors = | ||
31 | MActorFollow & | ||
32 | Use<'ActorFollower', MActor> & | ||
33 | Use<'ActorFollowing', MActor> | ||
34 | |||
35 | export type MActorFollowActorsDefault = | ||
36 | MActorFollow & | ||
37 | Use<'ActorFollower', MActorDefault> & | ||
38 | Use<'ActorFollowing', MActorDefault> | ||
39 | |||
40 | export type MActorFollowFull = | ||
41 | MActorFollow & | ||
42 | Use<'ActorFollower', MActorDefaultAccountChannel> & | ||
43 | Use<'ActorFollowing', MActorDefaultAccountChannel> | ||
44 | |||
45 | // ############################################################################ | ||
46 | |||
47 | // For subscriptions | ||
48 | |||
49 | export type MActorFollowActorsDefaultSubscription = | ||
50 | MActorFollow & | ||
51 | Use<'ActorFollower', MActorDefault> & | ||
52 | Use<'ActorFollowing', MActorDefaultChannelId> | ||
53 | |||
54 | export type MActorFollowSubscriptions = | ||
55 | MActorFollow & | ||
56 | Use<'ActorFollowing', MActorChannelAccountActor> | ||
57 | |||
58 | // ############################################################################ | ||
59 | |||
60 | // Format for API or AP object | ||
61 | |||
62 | export type MActorFollowFormattable = | ||
63 | Pick<MActorFollow, 'id' | 'score' | 'state' | 'createdAt' | 'updatedAt'> & | ||
64 | Use<'ActorFollower', MActorFormattable> & | ||
65 | Use<'ActorFollowing', MActorFormattable> | ||
diff --git a/server/types/models/account/actor-image.ts b/server/types/models/account/actor-image.ts deleted file mode 100644 index e59f8b141..000000000 --- a/server/types/models/account/actor-image.ts +++ /dev/null | |||
@@ -1,12 +0,0 @@ | |||
1 | import { ActorImageModel } from '../../../models/account/actor-image' | ||
2 | import { FunctionProperties } from '@shared/core-utils' | ||
3 | |||
4 | export type MActorImage = ActorImageModel | ||
5 | |||
6 | // ############################################################################ | ||
7 | |||
8 | // Format for API or AP object | ||
9 | |||
10 | export type MActorImageFormattable = | ||
11 | FunctionProperties<MActorImage> & | ||
12 | Pick<MActorImage, 'filename' | 'createdAt' | 'updatedAt'> | ||
diff --git a/server/types/models/account/actor.ts b/server/types/models/account/actor.ts deleted file mode 100644 index 0b620872e..000000000 --- a/server/types/models/account/actor.ts +++ /dev/null | |||
@@ -1,166 +0,0 @@ | |||
1 | |||
2 | import { FunctionProperties, PickWith, PickWithOpt } from '@shared/core-utils' | ||
3 | import { ActorModel } from '../../../models/activitypub/actor' | ||
4 | import { MServer, MServerHost, MServerHostBlocks, MServerRedundancyAllowed } from '../server' | ||
5 | import { MChannel, MChannelAccountActor, MChannelAccountDefault, MChannelId, MChannelIdActor } from '../video' | ||
6 | import { MAccount, MAccountDefault, MAccountId, MAccountIdActor } from './account' | ||
7 | import { MActorImage, MActorImageFormattable } from './actor-image' | ||
8 | |||
9 | type Use<K extends keyof ActorModel, M> = PickWith<ActorModel, K, M> | ||
10 | type UseOpt<K extends keyof ActorModel, M> = PickWithOpt<ActorModel, K, M> | ||
11 | |||
12 | // ############################################################################ | ||
13 | |||
14 | export type MActor = Omit<ActorModel, 'Account' | 'VideoChannel' | 'ActorFollowing' | 'Avatar' | 'ActorFollowers' | 'Server' | 'Banner'> | ||
15 | |||
16 | // ############################################################################ | ||
17 | |||
18 | export type MActorUrl = Pick<MActor, 'url'> | ||
19 | export type MActorId = Pick<MActor, 'id'> | ||
20 | export type MActorUsername = Pick<MActor, 'preferredUsername'> | ||
21 | |||
22 | export type MActorFollowersUrl = Pick<MActor, 'followersUrl'> | ||
23 | export type MActorAudience = MActorUrl & MActorFollowersUrl | ||
24 | export type MActorWithInboxes = Pick<ActorModel, 'sharedInboxUrl' | 'inboxUrl' | 'getSharedInbox'> | ||
25 | export type MActorSignature = MActorAccountChannelId | ||
26 | |||
27 | export type MActorLight = Omit<MActor, 'privateKey' | 'privateKey'> | ||
28 | |||
29 | // ############################################################################ | ||
30 | |||
31 | // Some association attributes | ||
32 | |||
33 | export type MActorHost = Use<'Server', MServerHost> | ||
34 | export type MActorRedundancyAllowedOpt = PickWithOpt<ActorModel, 'Server', MServerRedundancyAllowed> | ||
35 | |||
36 | export type MActorDefaultLight = | ||
37 | MActorLight & | ||
38 | Use<'Server', MServerHost> & | ||
39 | Use<'Avatar', MActorImage> | ||
40 | |||
41 | export type MActorAccountId = | ||
42 | MActor & | ||
43 | Use<'Account', MAccountId> | ||
44 | export type MActorAccountIdActor = | ||
45 | MActor & | ||
46 | Use<'Account', MAccountIdActor> | ||
47 | |||
48 | export type MActorChannelId = | ||
49 | MActor & | ||
50 | Use<'VideoChannel', MChannelId> | ||
51 | export type MActorChannelIdActor = | ||
52 | MActor & | ||
53 | Use<'VideoChannel', MChannelIdActor> | ||
54 | |||
55 | export type MActorAccountChannelId = MActorAccountId & MActorChannelId | ||
56 | export type MActorAccountChannelIdActor = MActorAccountIdActor & MActorChannelIdActor | ||
57 | |||
58 | // ############################################################################ | ||
59 | |||
60 | // Include raw account/channel/server | ||
61 | |||
62 | export type MActorAccount = | ||
63 | MActor & | ||
64 | Use<'Account', MAccount> | ||
65 | |||
66 | export type MActorChannel = | ||
67 | MActor & | ||
68 | Use<'VideoChannel', MChannel> | ||
69 | |||
70 | export type MActorDefaultAccountChannel = MActorDefault & MActorAccount & MActorChannel | ||
71 | |||
72 | export type MActorServer = | ||
73 | MActor & | ||
74 | Use<'Server', MServer> | ||
75 | |||
76 | // ############################################################################ | ||
77 | |||
78 | // Complex actor associations | ||
79 | |||
80 | export type MActorImages = | ||
81 | MActor & | ||
82 | Use<'Avatar', MActorImage> & | ||
83 | UseOpt<'Banner', MActorImage> | ||
84 | |||
85 | export type MActorDefault = | ||
86 | MActor & | ||
87 | Use<'Server', MServer> & | ||
88 | Use<'Avatar', MActorImage> | ||
89 | |||
90 | export type MActorDefaultChannelId = | ||
91 | MActorDefault & | ||
92 | Use<'VideoChannel', MChannelId> | ||
93 | |||
94 | export type MActorDefaultBanner = | ||
95 | MActor & | ||
96 | Use<'Server', MServer> & | ||
97 | Use<'Avatar', MActorImage> & | ||
98 | Use<'Banner', MActorImage> | ||
99 | |||
100 | // Actor with channel that is associated to an account and its actor | ||
101 | // Actor -> VideoChannel -> Account -> Actor | ||
102 | export type MActorChannelAccountActor = | ||
103 | MActor & | ||
104 | Use<'VideoChannel', MChannelAccountActor> | ||
105 | |||
106 | export type MActorFull = | ||
107 | MActor & | ||
108 | Use<'Server', MServer> & | ||
109 | Use<'Avatar', MActorImage> & | ||
110 | Use<'Banner', MActorImage> & | ||
111 | Use<'Account', MAccount> & | ||
112 | Use<'VideoChannel', MChannelAccountActor> | ||
113 | |||
114 | // Same than ActorFull, but the account and the channel have their actor | ||
115 | export type MActorFullActor = | ||
116 | MActor & | ||
117 | Use<'Server', MServer> & | ||
118 | Use<'Avatar', MActorImage> & | ||
119 | Use<'Banner', MActorImage> & | ||
120 | Use<'Account', MAccountDefault> & | ||
121 | Use<'VideoChannel', MChannelAccountDefault> | ||
122 | |||
123 | // ############################################################################ | ||
124 | |||
125 | // API | ||
126 | |||
127 | export type MActorSummary = | ||
128 | FunctionProperties<MActor> & | ||
129 | Pick<MActor, 'id' | 'preferredUsername' | 'url' | 'serverId' | 'avatarId'> & | ||
130 | Use<'Server', MServerHost> & | ||
131 | Use<'Avatar', MActorImage> | ||
132 | |||
133 | export type MActorSummaryBlocks = | ||
134 | MActorSummary & | ||
135 | Use<'Server', MServerHostBlocks> | ||
136 | |||
137 | export type MActorAPI = | ||
138 | Omit<MActorDefault, 'publicKey' | 'privateKey' | 'inboxUrl' | 'outboxUrl' | 'sharedInboxUrl' | | ||
139 | 'followersUrl' | 'followingUrl' | 'url' | 'createdAt' | 'updatedAt'> | ||
140 | |||
141 | // ############################################################################ | ||
142 | |||
143 | // Format for API or AP object | ||
144 | |||
145 | export type MActorSummaryFormattable = | ||
146 | FunctionProperties<MActor> & | ||
147 | Pick<MActor, 'url' | 'preferredUsername'> & | ||
148 | Use<'Server', MServerHost> & | ||
149 | Use<'Avatar', MActorImageFormattable> | ||
150 | |||
151 | export type MActorFormattable = | ||
152 | MActorSummaryFormattable & | ||
153 | Pick<MActor, 'id' | 'followingCount' | 'followersCount' | 'createdAt' | 'updatedAt' | 'remoteCreatedAt' | 'bannerId' | 'avatarId'> & | ||
154 | Use<'Server', MServerHost & Partial<Pick<MServer, 'redundancyAllowed'>>> & | ||
155 | UseOpt<'Banner', MActorImageFormattable> | ||
156 | |||
157 | type MActorAPBase = | ||
158 | MActor & | ||
159 | Use<'Avatar', MActorImage> | ||
160 | |||
161 | export type MActorAPAccount = | ||
162 | MActorAPBase | ||
163 | |||
164 | export type MActorAPChannel = | ||
165 | MActorAPBase & | ||
166 | Use<'Banner', MActorImage> | ||
diff --git a/server/types/models/account/index.ts b/server/types/models/account/index.ts index e3fc00f94..dab2eea7e 100644 --- a/server/types/models/account/index.ts +++ b/server/types/models/account/index.ts | |||
@@ -1,5 +1,2 @@ | |||
1 | export * from './account' | 1 | export * from './account' |
2 | export * from './account-blocklist' | 2 | export * from './account-blocklist' |
3 | export * from './actor-follow' | ||
4 | export * from './actor-image' | ||
5 | export * from './actor' | ||