PeerTube/server/types/models/actor/actor-follow.ts

66 lines
1.9 KiB
TypeScript
Raw Normal View History

import { PickWith } from '@shared/typescript-utils'
2021-05-11 11:15:29 +02:00
import { ActorFollowModel } from '../../../models/actor/actor-follow'
2019-08-20 13:52:49 +02:00
import {
MActor,
MActorChannelAccountActor,
MActorDefault,
MActorDefaultAccountChannel,
2021-04-06 17:01:35 +02:00
MActorDefaultChannelId,
2019-08-20 19:05:31 +02:00
MActorFormattable,
2019-08-20 13:52:49 +02:00
MActorHost,
MActorUsername
} from './actor'
type Use<K extends keyof ActorFollowModel, M> = PickWith<ActorFollowModel, K, M>
// ############################################################################
2019-08-15 11:53:26 +02:00
export type MActorFollow = Omit<ActorFollowModel, 'ActorFollower' | 'ActorFollowing'>
2019-08-20 13:52:49 +02:00
// ############################################################################
2020-01-31 16:56:52 +01:00
export type MActorFollowFollowingHost =
MActorFollow &
2019-08-20 13:52:49 +02:00
Use<'ActorFollowing', MActorUsername & MActorHost>
// ############################################################################
// With actors or actors default
2020-01-31 16:56:52 +01:00
export type MActorFollowActors =
MActorFollow &
2019-08-20 13:52:49 +02:00
Use<'ActorFollower', MActor> &
Use<'ActorFollowing', MActor>
2019-08-15 11:53:26 +02:00
2020-01-31 16:56:52 +01:00
export type MActorFollowActorsDefault =
MActorFollow &
2019-08-20 13:52:49 +02:00
Use<'ActorFollower', MActorDefault> &
Use<'ActorFollowing', MActorDefault>
2019-08-15 11:53:26 +02:00
2020-01-31 16:56:52 +01:00
export type MActorFollowFull =
MActorFollow &
Use<'ActorFollower', MActorDefaultAccountChannel> &
Use<'ActorFollowing', MActorDefaultAccountChannel>
2019-08-15 11:53:26 +02:00
2019-08-20 13:52:49 +02:00
// ############################################################################
// For subscriptions
2020-01-31 16:56:52 +01:00
export type MActorFollowActorsDefaultSubscription =
MActorFollow &
2019-08-20 13:52:49 +02:00
Use<'ActorFollower', MActorDefault> &
2021-04-06 17:01:35 +02:00
Use<'ActorFollowing', MActorDefaultChannelId>
2019-08-20 13:52:49 +02:00
2020-01-31 16:56:52 +01:00
export type MActorFollowSubscriptions =
MActorFollow &
2019-08-20 13:52:49 +02:00
Use<'ActorFollowing', MActorChannelAccountActor>
2019-08-20 19:05:31 +02:00
// ############################################################################
// Format for API or AP object
2020-01-31 16:56:52 +01:00
export type MActorFollowFormattable =
Pick<MActorFollow, 'id' | 'score' | 'state' | 'createdAt' | 'updatedAt'> &
2019-08-20 19:05:31 +02:00
Use<'ActorFollower', MActorFormattable> &
Use<'ActorFollowing', MActorFormattable>