1+ /**
2+ * Explicit schema interfaces required across the ingestion boundaries (worker -> pg -> storage).
3+ */
14export interface JobData {
25 videoId : string ;
36 sourceUrl : string ;
47 userId : string ;
8+ /** Resolves a callback POST upon zero-exit codes enabling loose-coupled status meshes. */
59 webhookUrl ?: string ;
610}
711
12+ /**
13+ * Indexed mapping bound to libavformat streams array for track persistence.
14+ */
815export interface AudioStreamInfo {
916 index : number ;
1017 codec : string ;
@@ -13,6 +20,9 @@ export interface AudioStreamInfo {
1320 title : string ;
1421}
1522
23+ /**
24+ * Maps raw `ffprobe` JSON outputs into explicitly-typed constraints.
25+ */
1626export interface ProbeResult {
1727 duration : number ;
1828 width : number ;
@@ -26,19 +36,30 @@ export interface ProbeResult {
2636 videoRange : string ;
2737}
2838
39+ /**
40+ * Output artifact references mapped directly into CDN manifest namespaces.
41+ */
2942export interface VideoRendition {
3043 resolution : string ;
3144 width : number ;
3245 height : number ;
3346 bitrate : number ;
47+ /** Pre-built HTTP relative-blob URL mapping directly to EXT-X-STREAM-INF payloads. */
3448 url : string ;
3549}
3650
51+ /**
52+ * Final memory resolution passed back up to the master BullMQ job processor.
53+ */
3754export interface TranscodeResult {
55+ /** Virtualized tmpfs / NVMe root mapping the segmented output arrays. */
3856 outputDir : string ;
3957 renditions : VideoRendition [ ] ;
4058}
4159
60+ /**
61+ * Tracks row-level states in PostgreSQL to handle pre-emption and idempotency locks.
62+ */
4263export type JobStatus =
4364 | 'queued'
4465 | 'processing'
@@ -47,6 +68,9 @@ export type JobStatus =
4768 | 'completed'
4869 | 'failed' ;
4970
71+ /**
72+ * Implements the atomic transactions expected off `pg` client handles.
73+ */
5074export interface VideoRepository {
5175 updateStatus (
5276 videoId : string ,
@@ -59,21 +83,33 @@ export interface VideoRepository {
5983}
6084
6185/**
62- * Dependency-inversion interface for blob storage providers (e.g., Azure Blob Storage, AWS S3) .
86+ * Maps the internal Node disk blocks outwards to object blob spaces via multipart SDK uploads .
6387 */
6488export interface StorageProvider {
89+ /**
90+ * Iterates the segment manifests onto Azure/AWS, injecting exact `video/mp4` and `application/vnd.apple.mpegurl` headers.
91+ * @returns Fully qualified FQDN for the resulting master array.
92+ */
6593 uploadHLS ( folderPath : string , videoId : string , onProgress ?: ProgressCallback ) : Promise < string > ;
6694}
6795
96+ /**
97+ * Progress delegate invoked off chunk offsets per internal `ffprobe` loop bindings.
98+ */
6899export type ProgressCallback = ( data : { variant : string ; percent : number } ) => void ;
69100
70101/**
71- * Domain boundary around the native FFmpeg system binary.
72- * Implementors must guarantee that `cleanup()` removes all trailing artifacts from the OS.
102+ * Abstract boundary wrapping child_process execution of the native OS ffmpeg binary.
73103 */
74104export interface TranscodeProvider {
105+ /**
106+ * Synchronous `spawn` intercept for the inbound libavformat properties array.
107+ */
75108 probe ( sourceUrl : string ) : Promise < ProbeResult > ;
76109
110+ /**
111+ * Pushes bounded stream definitions through the libx265 / libx264 cores.
112+ */
77113 transcodeHLS (
78114 sourceUrl : string ,
79115 videoId : string ,
@@ -86,9 +122,15 @@ export interface TranscodeProvider {
86122 videoRange ?: string ,
87123 ) : Promise < TranscodeResult > ;
88124
125+ /**
126+ * Empties the `tmpfs` blocks post-execution, strictly avoiding disk bloat errors.
127+ */
89128 cleanup ( videoId : string ) : Promise < void > ;
90129}
91130
131+ /**
132+ * Dependency-injected service orchestrating the state/execute lifecycle of worker units.
133+ */
92134export interface ProcessVideoUseCase {
93135 execute ( job : JobData , onProgress ?: ProgressCallback ) : Promise < void > ;
94136}
0 commit comments