( payload: ProcessVideoWorkflowPayload, )
| 31 | } |
| 32 | |
| 33 | export async function processVideoWorkflow( |
| 34 | payload: ProcessVideoWorkflowPayload, |
| 35 | ): Promise<VideoProcessingResult> { |
| 36 | "use workflow"; |
| 37 | |
| 38 | const { videoId, userId, rawFileKey, bucketId } = payload; |
| 39 | |
| 40 | try { |
| 41 | await validateProcessingRequest(videoId, rawFileKey); |
| 42 | |
| 43 | const result = await processVideoOnMediaServer( |
| 44 | videoId, |
| 45 | userId, |
| 46 | rawFileKey, |
| 47 | bucketId, |
| 48 | ); |
| 49 | |
| 50 | await saveMetadataAndComplete(videoId, result.metadata); |
| 51 | |
| 52 | const outputKey = `${userId}/${videoId}/result.mp4`; |
| 53 | if (rawFileKey !== outputKey) { |
| 54 | await cleanupRawUpload(videoId, rawFileKey); |
| 55 | } |
| 56 | |
| 57 | return { |
| 58 | success: true, |
| 59 | message: "Video processing completed", |
| 60 | metadata: result.metadata, |
| 61 | }; |
| 62 | } catch (error) { |
| 63 | const errorMessage = error instanceof Error ? error.message : String(error); |
| 64 | await setProcessingError(videoId, errorMessage); |
| 65 | throw new FatalError(errorMessage); |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | async function validateProcessingRequest( |
| 70 | videoId: string, |
nothing calls this directly
no test coverage detected