]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - shared/models/server/job.model.ts
22ecee324d0b0d2b440c04f7f31e94c6e41e5d02
[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 | 'transcoding-job-builder'
22 | 'manage-video-torrent'
23 | 'move-to-object-storage'
24 | 'notify'
25 | 'video-channel-import'
26 | 'video-file-import'
27 | 'video-import'
28 | 'video-live-ending'
29 | 'video-redundancy'
30 | 'video-studio-edition'
31 | 'video-transcoding'
32 | 'videos-views-stats'
33
34 export interface Job {
35 id: number | string
36 state: JobState | 'unknown'
37 type: JobType
38 data: any
39 priority: number
40 progress: number
41 error: any
42 createdAt: Date | string
43 finishedOn: Date | string
44 processedOn: Date | string
45
46 parent?: {
47 id: string
48 }
49 }
50
51 export type ActivitypubHttpBroadcastPayload = {
52 uris: string[]
53 contextType: ContextType
54 body: any
55 signatureActorId?: number
56 }
57
58 export type ActivitypubFollowPayload = {
59 followerActorId: number
60 name: string
61 host: string
62 isAutoFollow?: boolean
63 assertIsChannel?: boolean
64 }
65
66 export type FetchType = 'activity' | 'video-shares' | 'video-comments' | 'account-playlists'
67 export type ActivitypubHttpFetcherPayload = {
68 uri: string
69 type: FetchType
70 videoId?: number
71 }
72
73 export type ActivitypubHttpUnicastPayload = {
74 uri: string
75 contextType: ContextType
76 signatureActorId?: number
77 body: object
78 }
79
80 export type RefreshPayload = {
81 type: 'video' | 'video-playlist' | 'actor'
82 url: string
83 }
84
85 export type EmailPayload = SendEmailOptions
86
87 export type VideoFileImportPayload = {
88 videoUUID: string
89 filePath: string
90 }
91
92 // ---------------------------------------------------------------------------
93
94 export type VideoImportTorrentPayloadType = 'magnet-uri' | 'torrent-file'
95 export type VideoImportYoutubeDLPayloadType = 'youtube-dl'
96
97 export interface VideoImportYoutubeDLPayload {
98 type: VideoImportYoutubeDLPayloadType
99 videoImportId: number
100
101 fileExt?: string
102 }
103
104 export interface VideoImportTorrentPayload {
105 type: VideoImportTorrentPayloadType
106 videoImportId: number
107 }
108
109 export type VideoImportPayload = (VideoImportYoutubeDLPayload | VideoImportTorrentPayload) & {
110 preventException: boolean
111 }
112
113 export interface VideoImportPreventExceptionResult {
114 resultType: 'success' | 'error'
115 }
116
117 // ---------------------------------------------------------------------------
118
119 export type VideoRedundancyPayload = {
120 videoId: number
121 }
122
123 export type ManageVideoTorrentPayload =
124 {
125 action: 'create'
126 videoId: number
127 videoFileId: number
128 } | {
129 action: 'update-metadata'
130
131 videoId?: number
132 streamingPlaylistId?: number
133
134 videoFileId: number
135 }
136
137 // Video transcoding payloads
138
139 interface BaseTranscodingPayload {
140 videoUUID: string
141 isNewVideo?: boolean
142 }
143
144 export interface HLSTranscodingPayload extends BaseTranscodingPayload {
145 type: 'new-resolution-to-hls'
146 resolution: VideoResolution
147 fps: number
148 copyCodecs: boolean
149
150 deleteWebTorrentFiles: boolean
151 }
152
153 export interface NewWebTorrentResolutionTranscodingPayload extends BaseTranscodingPayload {
154 type: 'new-resolution-to-webtorrent'
155 resolution: VideoResolution
156 fps: number
157 }
158
159 export interface MergeAudioTranscodingPayload extends BaseTranscodingPayload {
160 type: 'merge-audio-to-webtorrent'
161
162 resolution: VideoResolution
163 fps: number
164
165 hasChildren: boolean
166 }
167
168 export interface OptimizeTranscodingPayload extends BaseTranscodingPayload {
169 type: 'optimize-to-webtorrent'
170
171 quickTranscode: boolean
172
173 hasChildren: boolean
174 }
175
176 export type VideoTranscodingPayload =
177 HLSTranscodingPayload
178 | NewWebTorrentResolutionTranscodingPayload
179 | OptimizeTranscodingPayload
180 | MergeAudioTranscodingPayload
181
182 export interface VideoLiveEndingPayload {
183 videoId: number
184 publishedAt: string
185 liveSessionId: number
186 streamingPlaylistId: number
187
188 replayDirectory?: string
189 }
190
191 export interface ActorKeysPayload {
192 actorId: number
193 }
194
195 export interface DeleteResumableUploadMetaFilePayload {
196 filepath: string
197 }
198
199 export interface MoveObjectStoragePayload {
200 videoUUID: string
201 isNewVideo: boolean
202 previousVideoState: VideoState
203 }
204
205 export type VideoStudioTaskCutPayload = VideoStudioTaskCut
206
207 export type VideoStudioTaskIntroPayload = {
208 name: 'add-intro'
209
210 options: {
211 file: string
212 }
213 }
214
215 export type VideoStudioTaskOutroPayload = {
216 name: 'add-outro'
217
218 options: {
219 file: string
220 }
221 }
222
223 export type VideoStudioTaskWatermarkPayload = {
224 name: 'add-watermark'
225
226 options: {
227 file: string
228
229 watermarkSizeRatio: number
230 horitonzalMarginRatio: number
231 verticalMarginRatio: number
232 }
233 }
234
235 export type VideoStudioTaskPayload =
236 VideoStudioTaskCutPayload |
237 VideoStudioTaskIntroPayload |
238 VideoStudioTaskOutroPayload |
239 VideoStudioTaskWatermarkPayload
240
241 export interface VideoStudioEditionPayload {
242 videoUUID: string
243 tasks: VideoStudioTaskPayload[]
244 }
245
246 // ---------------------------------------------------------------------------
247
248 export interface VideoChannelImportPayload {
249 externalChannelUrl: string
250 videoChannelId: number
251
252 partOfChannelSyncId?: number
253 }
254
255 export interface AfterVideoChannelImportPayload {
256 channelSyncId: number
257 }
258
259 // ---------------------------------------------------------------------------
260
261 export type NotifyPayload =
262 {
263 action: 'new-video'
264 videoUUID: string
265 }
266
267 // ---------------------------------------------------------------------------
268
269 export interface FederateVideoPayload {
270 videoUUID: string
271 isNewVideo: boolean
272 }
273
274 // ---------------------------------------------------------------------------
275
276 export interface TranscodingJobBuilderPayload {
277 videoUUID: string
278
279 optimizeJob?: {
280 isNewVideo: boolean
281 }
282
283 // Array of jobs to create
284 jobs?: {
285 type: 'video-transcoding'
286 payload: VideoTranscodingPayload
287 priority?: number
288 }[]
289
290 // Array of sequential jobs to create
291 sequentialJobs?: {
292 type: 'video-transcoding'
293 payload: VideoTranscodingPayload
294 priority?: number
295 }[][]
296 }