job.model.ts 5.7 KB

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