diff options
author | Chocobozzz <me@florianbigard.com> | 2023-07-31 14:34:36 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-08-11 15:02:33 +0200 |
commit | 3a4992633ee62d5edfbb484d9c6bcb3cf158489d (patch) | |
tree | e4510b39bdac9c318fdb4b47018d08f15368b8f0 /shared/models/server/job.model.ts | |
parent | 04d1da5621d25d59bd5fa1543b725c497bf5d9a8 (diff) | |
download | PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.tar.gz PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.tar.zst PeerTube-3a4992633ee62d5edfbb484d9c6bcb3cf158489d.zip |
Migrate server to ESM
Sorry for the very big commit that may lead to git log issues and merge
conflicts, but it's a major step forward:
* Server can be faster at startup because imports() are async and we can
easily lazy import big modules
* Angular doesn't seem to support ES import (with .js extension), so we
had to correctly organize peertube into a monorepo:
* Use yarn workspace feature
* Use typescript reference projects for dependencies
* Shared projects have been moved into "packages", each one is now a
node module (with a dedicated package.json/tsconfig.json)
* server/tools have been moved into apps/ and is now a dedicated app
bundled and published on NPM so users don't have to build peertube
cli tools manually
* server/tests have been moved into packages/ so we don't compile
them every time we want to run the server
* Use isolatedModule option:
* Had to move from const enum to const
(https://www.typescriptlang.org/docs/handbook/enums.html#objects-vs-enums)
* Had to explictely specify "type" imports when used in decorators
* Prefer tsx (that uses esbuild under the hood) instead of ts-node to
load typescript files (tests with mocha or scripts):
* To reduce test complexity as esbuild doesn't support decorator
metadata, we only test server files that do not import server
models
* We still build tests files into js files for a faster CI
* Remove unmaintained peertube CLI import script
* Removed some barrels to speed up execution (less imports)
Diffstat (limited to 'shared/models/server/job.model.ts')
-rw-r--r-- | shared/models/server/job.model.ts | 304 |
1 files changed, 0 insertions, 304 deletions
diff --git a/shared/models/server/job.model.ts b/shared/models/server/job.model.ts deleted file mode 100644 index c14806dab..000000000 --- a/shared/models/server/job.model.ts +++ /dev/null | |||
@@ -1,304 +0,0 @@ | |||
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-cleaner' | ||
11 | | 'activitypub-follow' | ||
12 | | 'activitypub-http-broadcast-parallel' | ||
13 | | 'activitypub-http-broadcast' | ||
14 | | 'activitypub-http-fetcher' | ||
15 | | 'activitypub-http-unicast' | ||
16 | | 'activitypub-refresher' | ||
17 | | 'actor-keys' | ||
18 | | 'after-video-channel-import' | ||
19 | | 'email' | ||
20 | | 'federate-video' | ||
21 | | 'transcoding-job-builder' | ||
22 | | 'manage-video-torrent' | ||
23 | | 'move-to-object-storage' | ||
24 | | 'notify' | ||
25 | | 'video-channel-import' | ||
26 | | 'video-file-import' | ||
27 | | 'video-import' | ||
28 | | 'video-live-ending' | ||
29 | | 'video-redundancy' | ||
30 | | 'video-studio-edition' | ||
31 | | 'video-transcoding' | ||
32 | | 'videos-views-stats' | ||
33 | | 'generate-video-storyboard' | ||
34 | |||
35 | export interface Job { | ||
36 | id: number | string | ||
37 | state: JobState | 'unknown' | ||
38 | type: JobType | ||
39 | data: any | ||
40 | priority: number | ||
41 | progress: number | ||
42 | error: any | ||
43 | createdAt: Date | string | ||
44 | finishedOn: Date | string | ||
45 | processedOn: Date | string | ||
46 | |||
47 | parent?: { | ||
48 | id: string | ||
49 | } | ||
50 | } | ||
51 | |||
52 | export type ActivitypubHttpBroadcastPayload = { | ||
53 | uris: string[] | ||
54 | contextType: ContextType | ||
55 | body: any | ||
56 | signatureActorId?: number | ||
57 | } | ||
58 | |||
59 | export type ActivitypubFollowPayload = { | ||
60 | followerActorId: number | ||
61 | name: string | ||
62 | host: string | ||
63 | isAutoFollow?: boolean | ||
64 | assertIsChannel?: boolean | ||
65 | } | ||
66 | |||
67 | export type FetchType = 'activity' | 'video-shares' | 'video-comments' | 'account-playlists' | ||
68 | export type ActivitypubHttpFetcherPayload = { | ||
69 | uri: string | ||
70 | type: FetchType | ||
71 | videoId?: number | ||
72 | } | ||
73 | |||
74 | export type ActivitypubHttpUnicastPayload = { | ||
75 | uri: string | ||
76 | contextType: ContextType | ||
77 | signatureActorId?: number | ||
78 | body: object | ||
79 | } | ||
80 | |||
81 | export type RefreshPayload = { | ||
82 | type: 'video' | 'video-playlist' | 'actor' | ||
83 | url: string | ||
84 | } | ||
85 | |||
86 | export type EmailPayload = SendEmailOptions | ||
87 | |||
88 | export type VideoFileImportPayload = { | ||
89 | videoUUID: string | ||
90 | filePath: string | ||
91 | } | ||
92 | |||
93 | // --------------------------------------------------------------------------- | ||
94 | |||
95 | export type VideoImportTorrentPayloadType = 'magnet-uri' | 'torrent-file' | ||
96 | export type VideoImportYoutubeDLPayloadType = 'youtube-dl' | ||
97 | |||
98 | export interface VideoImportYoutubeDLPayload { | ||
99 | type: VideoImportYoutubeDLPayloadType | ||
100 | videoImportId: number | ||
101 | |||
102 | fileExt?: string | ||
103 | } | ||
104 | |||
105 | export interface VideoImportTorrentPayload { | ||
106 | type: VideoImportTorrentPayloadType | ||
107 | videoImportId: number | ||
108 | } | ||
109 | |||
110 | export type VideoImportPayload = (VideoImportYoutubeDLPayload | VideoImportTorrentPayload) & { | ||
111 | preventException: boolean | ||
112 | } | ||
113 | |||
114 | export interface VideoImportPreventExceptionResult { | ||
115 | resultType: 'success' | 'error' | ||
116 | } | ||
117 | |||
118 | // --------------------------------------------------------------------------- | ||
119 | |||
120 | export type VideoRedundancyPayload = { | ||
121 | videoId: number | ||
122 | } | ||
123 | |||
124 | export type ManageVideoTorrentPayload = | ||
125 | { | ||
126 | action: 'create' | ||
127 | videoId: number | ||
128 | videoFileId: number | ||
129 | } | { | ||
130 | action: 'update-metadata' | ||
131 | |||
132 | videoId?: number | ||
133 | streamingPlaylistId?: number | ||
134 | |||
135 | videoFileId: number | ||
136 | } | ||
137 | |||
138 | // Video transcoding payloads | ||
139 | |||
140 | interface BaseTranscodingPayload { | ||
141 | videoUUID: string | ||
142 | isNewVideo?: boolean | ||
143 | } | ||
144 | |||
145 | export interface HLSTranscodingPayload extends BaseTranscodingPayload { | ||
146 | type: 'new-resolution-to-hls' | ||
147 | resolution: VideoResolution | ||
148 | fps: number | ||
149 | copyCodecs: boolean | ||
150 | |||
151 | deleteWebVideoFiles: boolean | ||
152 | } | ||
153 | |||
154 | export interface NewWebVideoResolutionTranscodingPayload extends BaseTranscodingPayload { | ||
155 | type: 'new-resolution-to-web-video' | ||
156 | resolution: VideoResolution | ||
157 | fps: number | ||
158 | } | ||
159 | |||
160 | export interface MergeAudioTranscodingPayload extends BaseTranscodingPayload { | ||
161 | type: 'merge-audio-to-web-video' | ||
162 | |||
163 | resolution: VideoResolution | ||
164 | fps: number | ||
165 | |||
166 | hasChildren: boolean | ||
167 | } | ||
168 | |||
169 | export interface OptimizeTranscodingPayload extends BaseTranscodingPayload { | ||
170 | type: 'optimize-to-web-video' | ||
171 | |||
172 | quickTranscode: boolean | ||
173 | |||
174 | hasChildren: boolean | ||
175 | } | ||
176 | |||
177 | export type VideoTranscodingPayload = | ||
178 | HLSTranscodingPayload | ||
179 | | NewWebVideoResolutionTranscodingPayload | ||
180 | | OptimizeTranscodingPayload | ||
181 | | MergeAudioTranscodingPayload | ||
182 | |||
183 | export interface VideoLiveEndingPayload { | ||
184 | videoId: number | ||
185 | publishedAt: string | ||
186 | liveSessionId: number | ||
187 | streamingPlaylistId: number | ||
188 | |||
189 | replayDirectory?: string | ||
190 | } | ||
191 | |||
192 | export interface ActorKeysPayload { | ||
193 | actorId: number | ||
194 | } | ||
195 | |||
196 | export interface DeleteResumableUploadMetaFilePayload { | ||
197 | filepath: string | ||
198 | } | ||
199 | |||
200 | export interface MoveObjectStoragePayload { | ||
201 | videoUUID: string | ||
202 | isNewVideo: boolean | ||
203 | previousVideoState: VideoState | ||
204 | } | ||
205 | |||
206 | export type VideoStudioTaskCutPayload = VideoStudioTaskCut | ||
207 | |||
208 | export type VideoStudioTaskIntroPayload = { | ||
209 | name: 'add-intro' | ||
210 | |||
211 | options: { | ||
212 | file: string | ||
213 | } | ||
214 | } | ||
215 | |||
216 | export type VideoStudioTaskOutroPayload = { | ||
217 | name: 'add-outro' | ||
218 | |||
219 | options: { | ||
220 | file: string | ||
221 | } | ||
222 | } | ||
223 | |||
224 | export type VideoStudioTaskWatermarkPayload = { | ||
225 | name: 'add-watermark' | ||
226 | |||
227 | options: { | ||
228 | file: string | ||
229 | |||
230 | watermarkSizeRatio: number | ||
231 | horitonzalMarginRatio: number | ||
232 | verticalMarginRatio: number | ||
233 | } | ||
234 | } | ||
235 | |||
236 | export type VideoStudioTaskPayload = | ||
237 | VideoStudioTaskCutPayload | | ||
238 | VideoStudioTaskIntroPayload | | ||
239 | VideoStudioTaskOutroPayload | | ||
240 | VideoStudioTaskWatermarkPayload | ||
241 | |||
242 | export interface VideoStudioEditionPayload { | ||
243 | videoUUID: string | ||
244 | tasks: VideoStudioTaskPayload[] | ||
245 | } | ||
246 | |||
247 | // --------------------------------------------------------------------------- | ||
248 | |||
249 | export interface VideoChannelImportPayload { | ||
250 | externalChannelUrl: string | ||
251 | videoChannelId: number | ||
252 | |||
253 | partOfChannelSyncId?: number | ||
254 | } | ||
255 | |||
256 | export interface AfterVideoChannelImportPayload { | ||
257 | channelSyncId: number | ||
258 | } | ||
259 | |||
260 | // --------------------------------------------------------------------------- | ||
261 | |||
262 | export type NotifyPayload = | ||
263 | { | ||
264 | action: 'new-video' | ||
265 | videoUUID: string | ||
266 | } | ||
267 | |||
268 | // --------------------------------------------------------------------------- | ||
269 | |||
270 | export interface FederateVideoPayload { | ||
271 | videoUUID: string | ||
272 | isNewVideo: boolean | ||
273 | } | ||
274 | |||
275 | // --------------------------------------------------------------------------- | ||
276 | |||
277 | export interface TranscodingJobBuilderPayload { | ||
278 | videoUUID: string | ||
279 | |||
280 | optimizeJob?: { | ||
281 | isNewVideo: boolean | ||
282 | } | ||
283 | |||
284 | // Array of jobs to create | ||
285 | jobs?: { | ||
286 | type: 'video-transcoding' | ||
287 | payload: VideoTranscodingPayload | ||
288 | priority?: number | ||
289 | }[] | ||
290 | |||
291 | // Array of sequential jobs to create | ||
292 | sequentialJobs?: { | ||
293 | type: 'video-transcoding' | ||
294 | payload: VideoTranscodingPayload | ||
295 | priority?: number | ||
296 | }[][] | ||
297 | } | ||
298 | |||
299 | // --------------------------------------------------------------------------- | ||
300 | |||
301 | export interface GenerateStoryboardPayload { | ||
302 | videoUUID: string | ||
303 | federate: boolean | ||
304 | } | ||