diff options
Diffstat (limited to 'packages/models/src/server/job.model.ts')
-rw-r--r-- | packages/models/src/server/job.model.ts | 303 |
1 files changed, 303 insertions, 0 deletions
diff --git a/packages/models/src/server/job.model.ts b/packages/models/src/server/job.model.ts new file mode 100644 index 000000000..f86a20e28 --- /dev/null +++ b/packages/models/src/server/job.model.ts | |||
@@ -0,0 +1,303 @@ | |||
1 | import { ContextType } from '../activitypub/context.js' | ||
2 | import { VideoStateType } from '../videos/index.js' | ||
3 | import { VideoStudioTaskCut } from '../videos/studio/index.js' | ||
4 | import { SendEmailOptions } from './emailer.model.js' | ||
5 | |||
6 | export type JobState = 'active' | 'completed' | 'failed' | 'waiting' | 'delayed' | 'paused' | 'waiting-children' | ||
7 | |||
8 | export type JobType = | ||
9 | | 'activitypub-cleaner' | ||
10 | | 'activitypub-follow' | ||
11 | | 'activitypub-http-broadcast-parallel' | ||
12 | | 'activitypub-http-broadcast' | ||
13 | | 'activitypub-http-fetcher' | ||
14 | | 'activitypub-http-unicast' | ||
15 | | 'activitypub-refresher' | ||
16 | | 'actor-keys' | ||
17 | | 'after-video-channel-import' | ||
18 | | 'email' | ||
19 | | 'federate-video' | ||
20 | | 'transcoding-job-builder' | ||
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 | | 'generate-video-storyboard' | ||
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: number | ||
147 | fps: number | ||
148 | copyCodecs: boolean | ||
149 | |||
150 | deleteWebVideoFiles: boolean | ||
151 | } | ||
152 | |||
153 | export interface NewWebVideoResolutionTranscodingPayload extends BaseTranscodingPayload { | ||
154 | type: 'new-resolution-to-web-video' | ||
155 | resolution: number | ||
156 | fps: number | ||
157 | } | ||
158 | |||
159 | export interface MergeAudioTranscodingPayload extends BaseTranscodingPayload { | ||
160 | type: 'merge-audio-to-web-video' | ||
161 | |||
162 | resolution: number | ||
163 | fps: number | ||
164 | |||
165 | hasChildren: boolean | ||
166 | } | ||
167 | |||
168 | export interface OptimizeTranscodingPayload extends BaseTranscodingPayload { | ||
169 | type: 'optimize-to-web-video' | ||
170 | |||
171 | quickTranscode: boolean | ||
172 | |||
173 | hasChildren: boolean | ||
174 | } | ||
175 | |||
176 | export type VideoTranscodingPayload = | ||
177 | HLSTranscodingPayload | ||
178 | | NewWebVideoResolutionTranscodingPayload | ||
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: VideoStateType | ||
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 | } | ||
297 | |||
298 | // --------------------------------------------------------------------------- | ||
299 | |||
300 | export interface GenerateStoryboardPayload { | ||
301 | videoUUID: string | ||
302 | federate: boolean | ||
303 | } | ||