@hff-ai/media-processor-client 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,453 @@
1
+ /**
2
+ * Type definitions for the Media Processor Client
3
+ */
4
+ /**
5
+ * S3 bucket configuration
6
+ */
7
+ export interface S3Config {
8
+ /** S3-compatible provider (e.g., 'idrive', 'aws', 'minio') */
9
+ provider: string;
10
+ /** S3 endpoint URL */
11
+ endpoint: string;
12
+ /** S3 access key ID */
13
+ accessKey: string;
14
+ /** S3 secret access key */
15
+ secretAccessKey: string;
16
+ /** S3 region */
17
+ region: string;
18
+ /** Bucket name */
19
+ bucketName: string;
20
+ }
21
+ /**
22
+ * Optional processing configuration
23
+ */
24
+ export interface ProcessorOptions {
25
+ /** Maximum concurrent processing jobs (default: 5) */
26
+ maxConcurrentJobs?: number;
27
+ /** Default user ID for processing requests */
28
+ defaultUserId?: string;
29
+ /** Auto-reconnect on connection loss (default: true) */
30
+ autoReconnect?: boolean;
31
+ /** Reconnection delay in milliseconds (default: 5000) */
32
+ reconnectDelay?: number;
33
+ /** Maximum reconnection attempts (default: 10, 0 = infinite) */
34
+ maxReconnectAttempts?: number;
35
+ /** Request timeout in milliseconds (default: 30000) */
36
+ requestTimeout?: number;
37
+ }
38
+ /**
39
+ * Main configuration object for MediaProcessor
40
+ */
41
+ export interface MediaProcessorConfig {
42
+ /** Base URL of the media processor REST API */
43
+ processorUrl: string;
44
+ /** AMQP connection URL for RabbitMQ */
45
+ processorAmqp: string;
46
+ /** JWT authentication token */
47
+ token: string;
48
+ /** S3 bucket configuration */
49
+ s3Details: S3Config;
50
+ /** System namespace for queue routing */
51
+ system: string;
52
+ /** Optional processing defaults */
53
+ options?: ProcessorOptions;
54
+ }
55
+ /**
56
+ * Base options for all processing requests
57
+ */
58
+ export interface BaseProcessOptions {
59
+ /** Custom media ID (auto-generated if not provided) */
60
+ mediaId?: string;
61
+ /** User ID associated with this media */
62
+ userId?: string;
63
+ /** Original filename for metadata */
64
+ originalFilename?: string;
65
+ /** MIME type (auto-detected if not provided) */
66
+ mimeType?: string;
67
+ /** File size in bytes */
68
+ fileSize?: number;
69
+ /** Custom metadata to include in processing */
70
+ metadata?: Record<string, unknown>;
71
+ }
72
+ /**
73
+ * Options for image processing
74
+ */
75
+ export interface ImageProcessOptions extends BaseProcessOptions {
76
+ }
77
+ /**
78
+ * Options for video processing
79
+ */
80
+ export interface VideoProcessOptions extends BaseProcessOptions {
81
+ /** Target qualities for transcoding (e.g., ['1080p', '720p', '480p']) */
82
+ targetQualities?: string[];
83
+ /** Generate thumbnail at these timestamps (seconds) */
84
+ thumbnailTimestamps?: number[];
85
+ }
86
+ /**
87
+ * Options for zip processing
88
+ */
89
+ export interface ZipProcessOptions extends BaseProcessOptions {
90
+ /** Process images found in the archive (default: true) */
91
+ processImages?: boolean;
92
+ /** Process videos found in the archive (default: true) */
93
+ processVideos?: boolean;
94
+ }
95
+ /**
96
+ * Base options for async processing requests (processS3* methods)
97
+ */
98
+ export interface AsyncProcessOptions {
99
+ /** Timeout in milliseconds (rejects with timeout error if exceeded) */
100
+ timeout?: number;
101
+ /** Callback for progress updates during async processing */
102
+ onProgress?: (progress: MediaProgressMessage) => void;
103
+ }
104
+ /**
105
+ * Options for async image processing
106
+ */
107
+ export interface AsyncImageProcessOptions extends ImageProcessOptions, AsyncProcessOptions {
108
+ }
109
+ /**
110
+ * Options for async video processing
111
+ */
112
+ export interface AsyncVideoProcessOptions extends VideoProcessOptions, AsyncProcessOptions {
113
+ }
114
+ /**
115
+ * Options for async zip processing
116
+ */
117
+ export interface AsyncZipProcessOptions extends ZipProcessOptions, AsyncProcessOptions {
118
+ }
119
+ /**
120
+ * Internal structure for tracking pending async requests
121
+ */
122
+ export interface PendingRequest {
123
+ resolve: (result: MediaResultMessage) => void;
124
+ reject: (error: Error) => void;
125
+ timeoutId?: NodeJS.Timeout;
126
+ onProgress?: (progress: MediaProgressMessage) => void;
127
+ }
128
+ export type MediaType = 'image' | 'video' | 'zip';
129
+ /**
130
+ * Processing request message sent to the media processor
131
+ */
132
+ export interface MediaProcessMessage {
133
+ /** Always 'request' for processing requests */
134
+ messageType: 'request';
135
+ /** Type of media being processed */
136
+ mediaType: MediaType;
137
+ /** Unique identifier for this media item */
138
+ mediaId: string;
139
+ /** User ID associated with the media */
140
+ userId: string;
141
+ /** ISO-8601 timestamp of when the request was created */
142
+ timestamp: string;
143
+ /** S3 object key of the source file */
144
+ s3Key: string;
145
+ /** Original filename (for metadata/display purposes) */
146
+ originalFilename: string;
147
+ /** MIME type of the source file */
148
+ mimeType: string;
149
+ /** File size in bytes */
150
+ fileSize: number;
151
+ /** Optional custom metadata */
152
+ metadata?: {
153
+ /** Client-assigned job ID for correlation */
154
+ jobId?: string;
155
+ /** Any additional custom fields */
156
+ [key: string]: unknown;
157
+ };
158
+ }
159
+ /**
160
+ * Processing status values
161
+ */
162
+ export type ProcessingStatus = 'QUEUED' | 'DOWNLOADING' | 'PROCESSING' | 'UPLOADING' | 'COMPLETED' | 'FAILED';
163
+ /**
164
+ * Processing stage values
165
+ */
166
+ export type ProcessingStage = 'queued' | 'downloading' | 'processing' | 'uploading';
167
+ /**
168
+ * Progress update message
169
+ */
170
+ export interface MediaProgressMessage {
171
+ /** Discriminator for progress updates */
172
+ messageType: 'progress';
173
+ /** Type of media being processed */
174
+ mediaType: MediaType;
175
+ /** Media identifier (correlates to the original request) */
176
+ mediaId: string;
177
+ /** User ID associated with the media */
178
+ userId: string;
179
+ /** ISO-8601 timestamp */
180
+ timestamp: string;
181
+ /** Current processing status */
182
+ status: ProcessingStatus;
183
+ /** Progress percentage (0-100) */
184
+ progress: number;
185
+ /** Human-readable progress message */
186
+ message: string;
187
+ /** Current processing stage */
188
+ stage: ProcessingStage;
189
+ /** Additional details */
190
+ details?: {
191
+ jobId?: string;
192
+ correlationId?: string;
193
+ currentStep?: string;
194
+ totalSteps?: number;
195
+ [key: string]: unknown;
196
+ };
197
+ }
198
+ /**
199
+ * Image version information
200
+ */
201
+ export interface ImageVersion {
202
+ quality: string;
203
+ s3Key: string;
204
+ width: number;
205
+ height: number;
206
+ }
207
+ /**
208
+ * Video version information
209
+ */
210
+ export interface VideoVersion {
211
+ quality: string;
212
+ s3Key: string;
213
+ width: number;
214
+ height: number;
215
+ bitrate?: number;
216
+ }
217
+ /**
218
+ * Video thumbnail information
219
+ */
220
+ export interface VideoThumbnail {
221
+ s3Key: string;
222
+ timestamp: number;
223
+ }
224
+ /**
225
+ * Image processing result
226
+ */
227
+ export interface ImageResult {
228
+ /** S3 key of the processed original image */
229
+ s3Key: string;
230
+ /** S3 key of the generated thumbnail */
231
+ thumbnailS3Key: string;
232
+ /** Image width in pixels */
233
+ width: number;
234
+ /** Image height in pixels */
235
+ height: number;
236
+ /** Additional metadata */
237
+ metadata?: {
238
+ /** Generated image versions at different sizes */
239
+ imageVersions?: ImageVersion[];
240
+ /** Total processing time in milliseconds */
241
+ processingTime?: number;
242
+ /** EXIF data extracted from the image */
243
+ exif?: Record<string, unknown>;
244
+ };
245
+ }
246
+ /**
247
+ * Video processing result
248
+ */
249
+ export interface VideoResult {
250
+ /** S3 key of the processed original video */
251
+ s3Key: string;
252
+ /** S3 key of the generated thumbnail */
253
+ thumbnailS3Key: string;
254
+ /** Video width in pixels */
255
+ width: number;
256
+ /** Video height in pixels */
257
+ height: number;
258
+ /** Video duration in seconds */
259
+ duration: number;
260
+ /** Additional metadata */
261
+ metadata?: {
262
+ /** Transcoded video versions */
263
+ videoVersions?: VideoVersion[];
264
+ /** Generated thumbnails */
265
+ thumbnails?: VideoThumbnail[];
266
+ /** Total processing time in milliseconds */
267
+ processingTime?: number;
268
+ /** Video codec information */
269
+ codec?: string;
270
+ /** Audio codec information */
271
+ audioCodec?: string;
272
+ };
273
+ }
274
+ /**
275
+ * Extracted media item from a zip file
276
+ */
277
+ export interface ExtractedMediaItem {
278
+ /** S3 key of the extracted file */
279
+ s3Key: string;
280
+ /** Original filename within the archive */
281
+ originalFilename: string;
282
+ /** MIME type of the extracted file */
283
+ mimeType: string;
284
+ /** File width (for images/videos) */
285
+ width?: number;
286
+ /** File height (for images/videos) */
287
+ height?: number;
288
+ /** Video duration (for videos only) */
289
+ duration?: number;
290
+ /** Processing result for this file (if processed) */
291
+ processingResult?: ImageResult | VideoResult;
292
+ }
293
+ /**
294
+ * Skipped file information
295
+ */
296
+ export interface SkippedFile {
297
+ filename: string;
298
+ reason: string;
299
+ }
300
+ /**
301
+ * Zip processing result
302
+ */
303
+ export interface ZipResult {
304
+ /** Array of extracted and processed media items */
305
+ extractedMedia: ExtractedMediaItem[];
306
+ /** Total number of files in the archive */
307
+ totalFiles: number;
308
+ /** Number of files successfully processed */
309
+ processedFiles: number;
310
+ /** Files that were skipped (unsupported format, etc.) */
311
+ skippedFiles?: SkippedFile[];
312
+ }
313
+ /**
314
+ * Union type for all result types
315
+ */
316
+ export type ProcessingResult = ImageResult | VideoResult | ZipResult;
317
+ /**
318
+ * Result message for successful processing
319
+ */
320
+ export interface MediaResultMessage {
321
+ /** Discriminator for successful results */
322
+ messageType: 'result';
323
+ /** Type of media that was processed */
324
+ mediaType: MediaType;
325
+ /** Media identifier (correlates to the original request) */
326
+ mediaId: string;
327
+ /** User ID associated with the media */
328
+ userId: string;
329
+ /** ISO-8601 timestamp of completion */
330
+ timestamp: string;
331
+ /** Always 'COMPLETED' for successful results */
332
+ status: 'COMPLETED';
333
+ /** Processing results (structure varies by media type) */
334
+ result: ProcessingResult;
335
+ }
336
+ /**
337
+ * Error codes for programmatic handling
338
+ */
339
+ export type MediaProcessorErrorCode = 'S3_ACCESS_DENIED' | 'S3_NOT_FOUND' | 'S3_UPLOAD_FAILED' | 'INVALID_FORMAT' | 'UNSUPPORTED_CODEC' | 'FILE_TOO_LARGE' | 'FILE_CORRUPTED' | 'PROCESSING_TIMEOUT' | 'TRANSCODING_FAILED' | 'THUMBNAIL_FAILED' | 'ZIP_EXTRACTION_FAILED' | 'ZIP_PASSWORD_PROTECTED' | 'INTERNAL_ERROR' | 'UNKNOWN_ERROR';
340
+ /**
341
+ * Error message for processing failures
342
+ */
343
+ export interface MediaErrorMessage {
344
+ /** Discriminator for error messages */
345
+ messageType: 'error';
346
+ /** Type of media that failed processing */
347
+ mediaType: MediaType;
348
+ /** Media identifier (correlates to the original request) */
349
+ mediaId: string;
350
+ /** User ID associated with the media */
351
+ userId: string;
352
+ /** ISO-8601 timestamp of the error */
353
+ timestamp: string;
354
+ /** Error code for programmatic handling */
355
+ errorCode?: MediaProcessorErrorCode;
356
+ /** Human-readable error message */
357
+ error: string;
358
+ /** Additional error details */
359
+ details?: {
360
+ jobId?: string;
361
+ correlationId?: string;
362
+ stage?: string;
363
+ originalError?: string;
364
+ retryable?: boolean;
365
+ [key: string]: unknown;
366
+ };
367
+ }
368
+ /**
369
+ * Union type for all update messages received from the processor
370
+ */
371
+ export type MediaUpdateMessage = MediaProgressMessage | MediaResultMessage | MediaErrorMessage;
372
+ /**
373
+ * System status information from the REST API
374
+ */
375
+ export interface SystemStatus {
376
+ name: string;
377
+ isActive: boolean;
378
+ pendingJobs: number;
379
+ completedJobs: number;
380
+ failedJobs: number;
381
+ averageProcessingTime: number;
382
+ bucket?: {
383
+ provider: string;
384
+ bucketName: string;
385
+ region: string;
386
+ };
387
+ }
388
+ /**
389
+ * Type guard for progress messages
390
+ */
391
+ export declare function isProgressMessage(msg: MediaUpdateMessage): msg is MediaProgressMessage;
392
+ /**
393
+ * Type guard for result messages
394
+ */
395
+ export declare function isResultMessage(msg: MediaUpdateMessage): msg is MediaResultMessage;
396
+ /**
397
+ * Type guard for error messages
398
+ */
399
+ export declare function isErrorMessage(msg: MediaUpdateMessage): msg is MediaErrorMessage;
400
+ /**
401
+ * Type guard for image results
402
+ */
403
+ export declare function isImageResult(result: ProcessingResult): result is ImageResult;
404
+ /**
405
+ * Type guard for video results
406
+ */
407
+ export declare function isVideoResult(result: ProcessingResult): result is VideoResult;
408
+ /**
409
+ * Type guard for zip results
410
+ */
411
+ export declare function isZipResult(result: ProcessingResult): result is ZipResult;
412
+ /**
413
+ * Connection event payloads
414
+ */
415
+ export interface DisconnectedPayload {
416
+ reason: string;
417
+ }
418
+ export interface ReconnectingPayload {
419
+ attempt: number;
420
+ }
421
+ /**
422
+ * Payload for unhandled message warnings
423
+ * Emitted when a result/error message has no listeners
424
+ */
425
+ export interface UnhandledMessagePayload {
426
+ type: 'completed' | 'error';
427
+ mediaType: MediaType;
428
+ mediaId: string;
429
+ message: string;
430
+ }
431
+ /**
432
+ * Event map for MediaProcessor
433
+ */
434
+ export interface MediaProcessorEvents {
435
+ connected: void;
436
+ disconnected: DisconnectedPayload;
437
+ reconnecting: ReconnectingPayload;
438
+ error: Error;
439
+ unhandled_message: UnhandledMessagePayload;
440
+ image_progress: MediaProgressMessage;
441
+ image_completed: MediaResultMessage;
442
+ image_error: MediaErrorMessage;
443
+ video_progress: MediaProgressMessage;
444
+ video_completed: MediaResultMessage;
445
+ video_error: MediaErrorMessage;
446
+ zip_progress: MediaProgressMessage;
447
+ zip_completed: MediaResultMessage;
448
+ zip_error: MediaErrorMessage;
449
+ progress: MediaProgressMessage;
450
+ completed: MediaResultMessage;
451
+ processing_error: MediaErrorMessage;
452
+ }
453
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AAMH;;GAEG;AACH,MAAM,WAAW,QAAQ;IACvB,8DAA8D;IAC9D,QAAQ,EAAE,MAAM,CAAC;IAEjB,sBAAsB;IACtB,QAAQ,EAAE,MAAM,CAAC;IAEjB,uBAAuB;IACvB,SAAS,EAAE,MAAM,CAAC;IAElB,2BAA2B;IAC3B,eAAe,EAAE,MAAM,CAAC;IAExB,gBAAgB;IAChB,MAAM,EAAE,MAAM,CAAC;IAEf,kBAAkB;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,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AAC;CACjB;AAED;;GAEG;AACH,MAAM,WAAW,oBAAoB;IAEnC,SAAS,EAAE,IAAI,CAAC;IAChB,YAAY,EAAE,mBAAmB,CAAC;IAClC,YAAY,EAAE,mBAAmB,CAAC;IAClC,KAAK,EAAE,KAAK,CAAC;IAGb,iBAAiB,EAAE,uBAAuB,CAAC;IAG3C,cAAc,EAAE,oBAAoB,CAAC;IACrC,eAAe,EAAE,kBAAkB,CAAC;IACpC,WAAW,EAAE,iBAAiB,CAAC;IAG/B,cAAc,EAAE,oBAAoB,CAAC;IACrC,eAAe,EAAE,kBAAkB,CAAC;IACpC,WAAW,EAAE,iBAAiB,CAAC;IAG/B,YAAY,EAAE,oBAAoB,CAAC;IACnC,aAAa,EAAE,kBAAkB,CAAC;IAClC,SAAS,EAAE,iBAAiB,CAAC;IAG7B,QAAQ,EAAE,oBAAoB,CAAC;IAC/B,SAAS,EAAE,kBAAkB,CAAC;IAC9B,gBAAgB,EAAE,iBAAiB,CAAC;CACrC"}
package/dist/types.js ADDED
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ /**
3
+ * Type definitions for the Media Processor Client
4
+ */
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.isProgressMessage = isProgressMessage;
7
+ exports.isResultMessage = isResultMessage;
8
+ exports.isErrorMessage = isErrorMessage;
9
+ exports.isImageResult = isImageResult;
10
+ exports.isVideoResult = isVideoResult;
11
+ exports.isZipResult = isZipResult;
12
+ // =============================================================================
13
+ // Type Guards
14
+ // =============================================================================
15
+ /**
16
+ * Type guard for progress messages
17
+ */
18
+ function isProgressMessage(msg) {
19
+ return msg.messageType === 'progress';
20
+ }
21
+ /**
22
+ * Type guard for result messages
23
+ */
24
+ function isResultMessage(msg) {
25
+ return msg.messageType === 'result';
26
+ }
27
+ /**
28
+ * Type guard for error messages
29
+ */
30
+ function isErrorMessage(msg) {
31
+ return msg.messageType === 'error';
32
+ }
33
+ /**
34
+ * Type guard for image results
35
+ */
36
+ function isImageResult(result) {
37
+ return 'thumbnailS3Key' in result && !('duration' in result) && !('extractedMedia' in result);
38
+ }
39
+ /**
40
+ * Type guard for video results
41
+ */
42
+ function isVideoResult(result) {
43
+ return 'duration' in result && 'thumbnailS3Key' in result;
44
+ }
45
+ /**
46
+ * Type guard for zip results
47
+ */
48
+ function isZipResult(result) {
49
+ return 'extractedMedia' in result;
50
+ }
51
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA;;GAEG;;AAuiBH,8CAEC;AAKD,0CAEC;AAKD,wCAEC;AAKD,sCAEC;AAKD,sCAEC;AAKD,kCAEC;AA5CD,gFAAgF;AAChF,cAAc;AACd,gFAAgF;AAEhF;;GAEG;AACH,SAAgB,iBAAiB,CAAC,GAAuB;IACvD,OAAO,GAAG,CAAC,WAAW,KAAK,UAAU,CAAC;AACxC,CAAC;AAED;;GAEG;AACH,SAAgB,eAAe,CAAC,GAAuB;IACrD,OAAO,GAAG,CAAC,WAAW,KAAK,QAAQ,CAAC;AACtC,CAAC;AAED;;GAEG;AACH,SAAgB,cAAc,CAAC,GAAuB;IACpD,OAAO,GAAG,CAAC,WAAW,KAAK,OAAO,CAAC;AACrC,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,MAAwB;IACpD,OAAO,gBAAgB,IAAI,MAAM,IAAI,CAAC,CAAC,UAAU,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,gBAAgB,IAAI,MAAM,CAAC,CAAC;AAChG,CAAC;AAED;;GAEG;AACH,SAAgB,aAAa,CAAC,MAAwB;IACpD,OAAO,UAAU,IAAI,MAAM,IAAI,gBAAgB,IAAI,MAAM,CAAC;AAC5D,CAAC;AAED;;GAEG;AACH,SAAgB,WAAW,CAAC,MAAwB;IAClD,OAAO,gBAAgB,IAAI,MAAM,CAAC;AACpC,CAAC"}
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@hff-ai/media-processor-client",
3
+ "version": "1.0.0",
4
+ "description": "TypeScript client for communicating with the HFF Media Processor service",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist",
9
+ "README.md"
10
+ ],
11
+ "scripts": {
12
+ "build": "tsc",
13
+ "clean": "rm -rf dist",
14
+ "prepublishOnly": "npm run clean && npm run build",
15
+ "test": "jest",
16
+ "test:unit": "jest src/__tests__/unit",
17
+ "test:integration": "jest src/__tests__/integration",
18
+ "test:watch": "jest --watch",
19
+ "test:coverage": "jest --coverage",
20
+ "lint": "eslint src/**/*.ts",
21
+ "lint:fix": "eslint src/**/*.ts --fix"
22
+ },
23
+ "keywords": [
24
+ "media",
25
+ "processing",
26
+ "video",
27
+ "image",
28
+ "amqp",
29
+ "rabbitmq",
30
+ "client"
31
+ ],
32
+ "author": "HFF Team",
33
+ "license": "MIT",
34
+ "dependencies": {
35
+ "amqplib": "^0.10.3",
36
+ "axios": "^1.5.0",
37
+ "uuid": "^9.0.0"
38
+ },
39
+ "devDependencies": {
40
+ "@types/amqplib": "^0.10.1",
41
+ "@types/jest": "^29.5.0",
42
+ "@types/node": "^20.5.0",
43
+ "@types/uuid": "^9.0.4",
44
+ "jest": "^29.7.0",
45
+ "nock": "^14.0.0",
46
+ "ts-jest": "^29.1.1",
47
+ "typescript": "^5.1.6"
48
+ },
49
+ "peerDependencies": {},
50
+ "engines": {
51
+ "node": ">=18.0.0"
52
+ },
53
+ "repository": {
54
+ "type": "git",
55
+ "url": "https://github.com/hff/media-processor.git",
56
+ "directory": "packages/media-processor-client"
57
+ }
58
+ }