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