aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/types/models/video/video-channels.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-06-18 10:45:25 +0200
committerChocobozzz <me@florianbigard.com>2020-06-18 10:46:27 +0200
commit26d6bf6533023326fa017812cf31bbe20c752d36 (patch)
tree9c4e3ecdc344420190f17d429bdf05d78fae7a8c /server/types/models/video/video-channels.ts
parentd6d951ddc0c492f3261065b5dcb4df0534d252fc (diff)
downloadPeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.tar.gz
PeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.tar.zst
PeerTube-26d6bf6533023326fa017812cf31bbe20c752d36.zip
Split types and typings
Diffstat (limited to 'server/types/models/video/video-channels.ts')
-rw-r--r--server/types/models/video/video-channels.ts145
1 files changed, 145 insertions, 0 deletions
diff --git a/server/types/models/video/video-channels.ts b/server/types/models/video/video-channels.ts
new file mode 100644
index 000000000..50f7c2d8a
--- /dev/null
+++ b/server/types/models/video/video-channels.ts
@@ -0,0 +1,145 @@
1import { FunctionProperties, PickWith, PickWithOpt } from '../../utils'
2import { VideoChannelModel } from '../../../models/video/video-channel'
3import {
4 MAccountActor,
5 MAccountAPI,
6 MAccountDefault,
7 MAccountFormattable,
8 MAccountLight,
9 MAccountSummaryBlocks,
10 MAccountSummaryFormattable,
11 MAccountUrl,
12 MAccountUserId,
13 MActor,
14 MActorAccountChannelId,
15 MActorAP,
16 MActorAPI,
17 MActorDefault,
18 MActorDefaultLight,
19 MActorFormattable,
20 MActorLight,
21 MActorSummary,
22 MActorSummaryFormattable, MActorUrl
23} from '../account'
24import { MVideo } from './video'
25
26type Use<K extends keyof VideoChannelModel, M> = PickWith<VideoChannelModel, K, M>
27
28// ############################################################################
29
30export type MChannel = Omit<VideoChannelModel, 'Actor' | 'Account' | 'Videos' | 'VideoPlaylists'>
31
32// ############################################################################
33
34export type MChannelId = Pick<MChannel, 'id'>
35
36// ############################################################################
37
38export type MChannelIdActor =
39 MChannelId &
40 Use<'Actor', MActorAccountChannelId>
41
42export type MChannelUserId =
43 Pick<MChannel, 'accountId'> &
44 Use<'Account', MAccountUserId>
45
46export type MChannelActor =
47 MChannel &
48 Use<'Actor', MActor>
49
50export type MChannelUrl = Use<'Actor', MActorUrl>
51
52// Default scope
53export type MChannelDefault =
54 MChannel &
55 Use<'Actor', MActorDefault>
56
57// ############################################################################
58
59// Not all association attributes
60
61export type MChannelLight =
62 MChannel &
63 Use<'Actor', MActorDefaultLight>
64
65export type MChannelActorLight =
66 MChannel &
67 Use<'Actor', MActorLight>
68
69export type MChannelAccountLight =
70 MChannel &
71 Use<'Actor', MActorDefaultLight> &
72 Use<'Account', MAccountLight>
73
74// ############################################################################
75
76// Account associations
77
78export type MChannelAccountActor =
79 MChannel &
80 Use<'Account', MAccountActor>
81
82export type MChannelAccountDefault =
83 MChannel &
84 Use<'Actor', MActorDefault> &
85 Use<'Account', MAccountDefault>
86
87export type MChannelActorAccountActor =
88 MChannel &
89 Use<'Account', MAccountActor> &
90 Use<'Actor', MActor>
91
92// ############################################################################
93
94// Videos associations
95export type MChannelVideos =
96 MChannel &
97 Use<'Videos', MVideo[]>
98
99export type MChannelActorAccountDefaultVideos =
100 MChannel &
101 Use<'Actor', MActorDefault> &
102 Use<'Account', MAccountDefault> &
103 Use<'Videos', MVideo[]>
104
105// ############################################################################
106
107// For API
108
109export type MChannelSummary =
110 FunctionProperties<MChannel> &
111 Pick<MChannel, 'id' | 'name' | 'description' | 'actorId'> &
112 Use<'Actor', MActorSummary>
113
114export type MChannelSummaryAccount =
115 MChannelSummary &
116 Use<'Account', MAccountSummaryBlocks>
117
118export type MChannelAPI =
119 MChannel &
120 Use<'Actor', MActorAPI> &
121 Use<'Account', MAccountAPI>
122
123// ############################################################################
124
125// Format for API or AP object
126
127export type MChannelSummaryFormattable =
128 FunctionProperties<MChannel> &
129 Pick<MChannel, 'id' | 'name'> &
130 Use<'Actor', MActorSummaryFormattable>
131
132export type MChannelAccountSummaryFormattable =
133 MChannelSummaryFormattable &
134 Use<'Account', MAccountSummaryFormattable>
135
136export type MChannelFormattable =
137 FunctionProperties<MChannel> &
138 Pick<MChannel, 'id' | 'name' | 'description' | 'createdAt' | 'updatedAt' | 'support'> &
139 Use<'Actor', MActorFormattable> &
140 PickWithOpt<VideoChannelModel, 'Account', MAccountFormattable>
141
142export type MChannelAP =
143 Pick<MChannel, 'name' | 'description' | 'support'> &
144 Use<'Actor', MActorAP> &
145 Use<'Account', MAccountUrl>