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