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