]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - shared/models/server/job.model.ts
Add ability to list imports of a channel sync
[github/Chocobozzz/PeerTube.git] / shared / models / server / job.model.ts
1 import { ContextType } from '../activitypub/context'
2 import { VideoState } from '../videos'
3 import { VideoResolution } from '../videos/file/video-resolution.enum'
4 import { VideoStudioTaskCut } from '../videos/studio'
5 import { SendEmailOptions } from './emailer.model'
6
7 export type JobState = 'active' | 'completed' | 'failed' | 'waiting' | 'delayed' | 'paused' | 'waiting-children'
8
9 export type JobType =
10 | 'activitypub-cleaner'
11 | 'activitypub-follow'
12 | 'activitypub-http-broadcast-parallel'
13 | 'activitypub-http-broadcast'
14 | 'activitypub-http-fetcher'
15 | 'activitypub-http-unicast'
16 | 'activitypub-refresher'
17 | 'actor-keys'
18 | 'after-video-channel-import'
19 | 'email'
20 | 'federate-video'
21 | 'manage-video-torrent'
22 | 'move-to-object-storage'
23 | 'notify'
24 | 'video-channel-import'
25 | 'video-file-import'
26 | 'video-import'
27 | 'video-live-ending'
28 | 'video-redundancy'
29 | 'video-studio-edition'
30 | 'video-transcoding'
31 | 'videos-views-stats'
32
33 export interface Job {
34 id: number | string
35 state: JobState | 'unknown'
36 type: JobType
37 data: any
38 priority: number
39 progress: number
40 error: any
41 createdAt: Date | string
42 finishedOn: Date | string
43 processedOn: Date | string
44 }
45
46 export type ActivitypubHttpBroadcastPayload = {
47 uris: string[]
48 contextType: ContextType
49 body: any
50 signatureActorId?: number
51 }
52
53 export type ActivitypubFollowPayload = {
54 followerActorId: number
55 name: string
56 host: string
57 isAutoFollow?: boolean
58 assertIsChannel?: boolean
59 }
60
61 export type FetchType = 'activity' | 'video-shares' | 'video-comments' | 'account-playlists'
62 export type ActivitypubHttpFetcherPayload = {
63 uri: string
64 type: FetchType
65 videoId?: number
66 }
67
68 export type ActivitypubHttpUnicastPayload = {
69 uri: string
70 contextType: ContextType
71 signatureActorId?: number
72 body: object
73 }
74
75 export type RefreshPayload = {
76 type: 'video' | 'video-playlist' | 'actor'
77 url: string
78 }
79
80 export type EmailPayload = SendEmailOptions
81
82 export type VideoFileImportPayload = {
83 videoUUID: string
84 filePath: string
85 }
86
87 // ---------------------------------------------------------------------------
88
89 export type VideoImportTorrentPayloadType = 'magnet-uri' | 'torrent-file'
90 export type VideoImportYoutubeDLPayloadType = 'youtube-dl'
91
92 export interface VideoImportYoutubeDLPayload {
93 type: VideoImportYoutubeDLPayloadType
94 videoImportId: number
95
96 fileExt?: string
97 }
98
99 export interface VideoImportTorrentPayload {
100 type: VideoImportTorrentPayloadType
101 videoImportId: number
102 }
103
104 export type VideoImportPayload = (VideoImportYoutubeDLPayload | VideoImportTorrentPayload) & {
105 preventException: boolean
106 }
107
108 export interface VideoImportPreventExceptionResult {
109 resultType: 'success' | 'error'
110 }
111
112 // ---------------------------------------------------------------------------
113
114 export type VideoRedundancyPayload = {
115 videoId: number
116 }
117
118 export type ManageVideoTorrentPayload =
119 {
120 action: 'create'
121 videoId: number
122 videoFileId: number
123 } | {
124 action: 'update-metadata'
125
126 videoId?: number
127 streamingPlaylistId?: number
128
129 videoFileId: number
130 }
131
132 // Video transcoding payloads
133
134 interface BaseTranscodingPayload {
135 videoUUID: string
136 isNewVideo?: boolean
137 }
138
139 export interface HLSTranscodingPayload extends BaseTranscodingPayload {
140 type: 'new-resolution-to-hls'
141 resolution: VideoResolution
142 copyCodecs: boolean
143
144 hasAudio: boolean
145
146 autoDeleteWebTorrentIfNeeded: boolean
147 isMaxQuality: boolean
148 }
149
150 export interface NewWebTorrentResolutionTranscodingPayload extends BaseTranscodingPayload {
151 type: 'new-resolution-to-webtorrent'
152 resolution: VideoResolution
153
154 hasAudio: boolean
155 createHLSIfNeeded: boolean
156 }
157
158 export interface MergeAudioTranscodingPayload extends BaseTranscodingPayload {
159 type: 'merge-audio-to-webtorrent'
160 resolution: VideoResolution
161 createHLSIfNeeded: true
162 }
163
164 export interface OptimizeTranscodingPayload extends BaseTranscodingPayload {
165 type: 'optimize-to-webtorrent'
166 }
167
168 export type VideoTranscodingPayload =
169 HLSTranscodingPayload
170 | NewWebTorrentResolutionTranscodingPayload
171 | OptimizeTranscodingPayload
172 | MergeAudioTranscodingPayload
173
174 export interface VideoLiveEndingPayload {
175 videoId: number
176 publishedAt: string
177 liveSessionId: number
178 streamingPlaylistId: number
179
180 replayDirectory?: string
181 }
182
183 export interface ActorKeysPayload {
184 actorId: number
185 }
186
187 export interface DeleteResumableUploadMetaFilePayload {
188 filepath: string
189 }
190
191 export interface MoveObjectStoragePayload {
192 videoUUID: string
193 isNewVideo: boolean
194 previousVideoState: VideoState
195 }
196
197 export type VideoStudioTaskCutPayload = VideoStudioTaskCut
198
199 export type VideoStudioTaskIntroPayload = {
200 name: 'add-intro'
201
202 options: {
203 file: string
204 }
205 }
206
207 export type VideoStudioTaskOutroPayload = {
208 name: 'add-outro'
209
210 options: {
211 file: string
212 }
213 }
214
215 export type VideoStudioTaskWatermarkPayload = {
216 name: 'add-watermark'
217
218 options: {
219 file: string
220 }
221 }
222
223 export type VideoStudioTaskPayload =
224 VideoStudioTaskCutPayload |
225 VideoStudioTaskIntroPayload |
226 VideoStudioTaskOutroPayload |
227 VideoStudioTaskWatermarkPayload
228
229 export interface VideoStudioEditionPayload {
230 videoUUID: string
231 tasks: VideoStudioTaskPayload[]
232 }
233
234 // ---------------------------------------------------------------------------
235
236 export interface VideoChannelImportPayload {
237 externalChannelUrl: string
238 videoChannelId: number
239
240 partOfChannelSyncId?: number
241 }
242
243 export interface AfterVideoChannelImportPayload {
244 channelSyncId: number
245 }
246
247 // ---------------------------------------------------------------------------
248
249 export type NotifyPayload =
250 {
251 action: 'new-video'
252 videoUUID: string
253 }
254
255 // ---------------------------------------------------------------------------
256
257 export interface FederateVideoPayload {
258 videoUUID: string
259 isNewVideo: boolean
260 }