Type toFormattedJSON
[oweals/peertube.git] / server / typings / models / account / actor-follow.ts
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>