aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/typings/models/video/video-channels.ts
blob: 2be7dd7ed01cbfbbf610a9aeeecba05de0583f3c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import { FunctionProperties, PickWith, PickWithOpt } from '../../utils'
import { VideoChannelModel } from '../../../models/video/video-channel'
import {
  MAccountActor,
  MAccountAPI,
  MAccountDefault,
  MAccountFormattable,
  MAccountLight,
  MAccountSummaryBlocks,
  MAccountSummaryFormattable,
  MAccountUserId,
  MActor,
  MActorAccountChannelId,
  MActorAPI,
  MActorDefault,
  MActorDefaultLight,
  MActorFormattable,
  MActorLight,
  MActorSummary,
  MActorSummaryFormattable
} from '../account'
import { MVideo } from './video'

type Use<K extends keyof VideoChannelModel, M> = PickWith<VideoChannelModel, K, M>

// ############################################################################

export type MChannel = Omit<VideoChannelModel, 'Actor' | 'Account' | 'Videos' | 'VideoPlaylists'>

// ############################################################################

export type MChannelId = Pick<MChannel, 'id'>

// ############################################################################

export type MChannelIdActor = MChannelId &
  Use<'Actor', MActorAccountChannelId>

export type MChannelUserId = Pick<MChannel, 'accountId'> &
  Use<'Account', MAccountUserId>

export type MChannelActor = MChannel &
  Use<'Actor', MActor>

// Default scope
export type MChannelDefault = MChannel &
  Use<'Actor', MActorDefault>

// ############################################################################

// Not all association attributes

export type MChannelLight = MChannel &
  Use<'Actor', MActorDefaultLight>

export type MChannelActorLight = MChannel &
  Use<'Actor', MActorLight>

export type MChannelAccountLight = MChannel &
  Use<'Actor', MActorDefaultLight> &
  Use<'Account', MAccountLight>

// ############################################################################

// Account associations

export type MChannelAccountActor = MChannel &
  Use<'Account', MAccountActor>

export type MChannelAccountDefault = MChannel &
  Use<'Actor', MActorDefault> &
  Use<'Account', MAccountDefault>

export type MChannelActorAccountActor = MChannel &
  Use<'Account', MAccountActor> &
  Use<'Actor', MActor>

// ############################################################################

// Videos  associations
export type MChannelVideos = MChannel &
  Use<'Videos', MVideo[]>

export type MChannelActorAccountDefaultVideos = MChannel &
  Use<'Actor', MActorDefault> &
  Use<'Account', MAccountDefault> &
  Use<'Videos', MVideo[]>

// ############################################################################

// For API

export type MChannelSummary = FunctionProperties<MChannel> &
  Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> &
  Use<'Actor', MActorSummary>

export type MChannelSummaryAccount = MChannelSummary &
  Use<'Account', MAccountSummaryBlocks>

export type MChannelAPI = MChannel &
  Use<'Actor', MActorAPI> &
  Use<'Account', MAccountAPI>

// ############################################################################

// Format for API or AP object

export type MChannelSummaryFormattable = FunctionProperties<MChannel> &
  Pick<MChannel, 'id' | 'name'> &
  Use<'Actor', MActorSummaryFormattable>

export type MChannelAccountSummaryFormattable = MChannelSummaryFormattable &
  Use<'Account', MAccountSummaryFormattable>

export type MChannelFormattable = FunctionProperties<MChannel> &
  Pick<MChannel, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'support'> &
  Use<'Actor', MActorFormattable> &
  PickWithOpt<VideoChannelModel, 'Account', MAccountFormattable>