@mesh-sync/worker-backend-client 1.0.6 → 4.0.3

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.
package/dist/types.d.ts CHANGED
@@ -2,6 +2,7 @@
2
2
  * Message type constants
3
3
  */
4
4
  export declare const MessageTypes: {
5
+ readonly BACKEND_LOGGING_EVENT: "backend-logging-event";
5
6
  readonly ETSY_ANALYTICS_SYNC_COMPLETED: "etsy-analytics-sync-completed";
6
7
  readonly ETSY_ANALYTICS_SYNC_REQUEST: "etsy-analytics-sync-request";
7
8
  readonly ETSY_PUBLISH_LISTING_COMPLETED: "etsy-publish-listing-completed";
@@ -10,12 +11,19 @@ export declare const MessageTypes: {
10
11
  readonly FILE_DOWNLOAD_REQUEST: "file-download-request";
11
12
  readonly MARKETPLACE_ANALYTICS_SYNC_COMPLETED: "marketplace-analytics-sync-completed";
12
13
  readonly MARKETPLACE_ANALYTICS_SYNC_REQUEST: "marketplace-analytics-sync-request";
14
+ readonly MARKETPLACE_CONNECTION_SYNC_COMPLETED: "marketplace-connection-sync-completed";
15
+ readonly MARKETPLACE_CONNECTION_SYNC_REQUEST: "marketplace-connection-sync-request";
16
+ readonly MARKETPLACE_CREDENTIAL_ROTATION_COMPLETED: "marketplace-credential-rotation-completed";
17
+ readonly MARKETPLACE_CREDENTIAL_ROTATION_REQUEST: "marketplace-credential-rotation-request";
18
+ readonly MARKETPLACE_LISTING_SYNC_COMPLETED: "marketplace-listing-sync-completed";
19
+ readonly MARKETPLACE_LISTING_SYNC_REQUEST: "marketplace-listing-sync-request";
13
20
  readonly MARKETPLACE_PUBLISH_LISTING_COMPLETED: "marketplace-publish-listing-completed";
14
21
  readonly MARKETPLACE_PUBLISH_LISTING_REQUEST: "marketplace-publish-listing-request";
15
22
  readonly MEDIA_BATCH_DOWNLOAD_COMPLETED: "media-batch-download-completed";
16
23
  readonly MEDIA_BATCH_DOWNLOAD_REQUEST: "media-batch-download-request";
17
24
  readonly METAMODEL_METADATA_GENERATION_COMPLETED: "metamodel-metadata-generation-completed";
18
25
  readonly METAMODEL_METADATA_GENERATION_REQUEST: "metamodel-metadata-generation-request";
26
+ readonly MODEL_ANALYTICS_COLLECTION_REQUEST: "model-analytics-collection-request";
19
27
  readonly MODEL_DISCOVERY_FOLDER_PROCESSED_EVENT: "model-discovery-folder-processed-event";
20
28
  readonly MODEL_DISCOVERY_SCAN_FOUND_EVENT: "model-discovery-scan-found-event";
21
29
  readonly MODEL_DISCOVERY_SCAN_PROGRESS_EVENT: "model-discovery-scan-progress-event";
@@ -26,12 +34,73 @@ export declare const MessageTypes: {
26
34
  readonly MODEL_METAMODEL_DETECTION_REQUEST: "model-metamodel-detection-request";
27
35
  readonly MODEL_SELLABILITY_ANALYSIS_COMPLETED: "model-sellability-analysis-completed";
28
36
  readonly MODEL_SELLABILITY_ANALYSIS_REQUEST: "model-sellability-analysis-request";
37
+ readonly MODEL_SEMANTIC_ANALYSIS_COMPLETED: "model-semantic-analysis-completed";
38
+ readonly MODEL_SEMANTIC_ANALYSIS_REQUEST: "model-semantic-analysis-request";
29
39
  readonly MODEL_TECHNICAL_METADATA_COMPLETED: "model-technical-metadata-completed";
30
40
  readonly MODEL_TECHNICAL_METADATA_REQUEST: "model-technical-metadata-request";
31
41
  readonly THUMBNAIL_GENERATION_COMPLETED: "thumbnail-generation-completed";
32
42
  readonly THUMBNAIL_GENERATION_REQUEST: "thumbnail-generation-request";
43
+ readonly USER_ENGAGEMENT_EVENT: "user-engagement-event";
44
+ readonly WORKER_ANALYTICS_EVENT: "worker-analytics-event";
45
+ readonly WORKER_METRICS_ENRICHED_EVENT: "worker-metrics-enriched-event";
33
46
  };
34
47
  export type MessageType = typeof MessageTypes[keyof typeof MessageTypes];
48
+ /**
49
+ * Centralized logging event for capturing all warn/error/failure logs from meshsync-backend.
50
+ This event is sent to ELK for centralized monitoring, alerting, and debugging.
51
+
52
+ Automatically emitted by the custom Pino logger interceptor when:
53
+ - logger.warn() is called
54
+ - logger.error() is called
55
+ - uncaught exceptions occur
56
+ - request failures happen (4xx, 5xx responses)
57
+
58
+ Used for:
59
+ - System health monitoring
60
+ - Error tracking and alerting
61
+ - Performance degradation detection
62
+ - Security incident tracking
63
+ - Compliance and audit trails
64
+
65
+ */
66
+ export interface BackendLoggingEventMessage {
67
+ /** Type of logging event */
68
+ eventType: string;
69
+ /** ISO 8601 timestamp when the log was generated */
70
+ timestamp: string;
71
+ /** Log level severity */
72
+ level: string;
73
+ /** Human-readable log message */
74
+ message: string;
75
+ /** Logger context (typically the class/service name) */
76
+ context: string;
77
+ /** Unique request ID for correlation (X-Request-Id header) */
78
+ requestId?: string;
79
+ /** ID of the authenticated user (if available) */
80
+ userId?: string;
81
+ /** HTTP method of the request */
82
+ httpMethod?: string;
83
+ /** Request URL path (without query params for privacy) */
84
+ httpUrl?: string;
85
+ /** HTTP response status code */
86
+ httpStatusCode?: string | number | boolean;
87
+ /** Error class/type name */
88
+ errorType?: string;
89
+ /** Stack trace (sanitized, no sensitive data) */
90
+ errorStack?: string;
91
+ /** Application-specific error code for categorization */
92
+ errorCode?: string;
93
+ /** Additional structured context (sanitized, no PII) */
94
+ metadata?: Record<string, string | number | boolean>;
95
+ /** Deployment environment */
96
+ environment?: string;
97
+ /** Backend service version */
98
+ serviceVersion?: string;
99
+ /** Server hostname/pod name */
100
+ hostname?: string;
101
+ /** Operation duration in milliseconds (if applicable) */
102
+ durationMs?: number;
103
+ }
35
104
  /**
36
105
  * Contains synced analytics data for Etsy listings. Backend stores this in etsy_analytics_snapshots table and indexes to ELK.
37
106
 
@@ -147,13 +216,23 @@ export interface FileDownloadCompletedMessage {
147
216
  downloadedAt?: string;
148
217
  }
149
218
  /**
150
- * Handles file download requests.
219
+ * Downloads model file from storage provider to MinIO for processing pipeline. Acts as parent job for thumbnail generation, technical metadata analysis, and metadata generation.
151
220
  */
152
221
  export interface FileDownloadRequestMessage {
153
222
  /** The unique identifier for the model to be downloaded. */
154
223
  modelId?: string;
224
+ /** The identifier of the user who owns the model. Optional - if not provided, will be retrieved from StorageConnection. */
225
+ ownerId?: string;
155
226
  /** The storage location of the model. */
156
227
  storageLocation?: Record<string, string | number | boolean>;
228
+ /** Destination in MinIO where file will be uploaded after download. */
229
+ minioDestination?: Record<string, string | number | boolean>;
230
+ /** Automatically enqueue thumbnail generation, technical metadata analysis, and metadata generation jobs after download completes. */
231
+ autoEnqueueChildren?: boolean;
232
+ /** Preview type for thumbnail generation (passed to child job). */
233
+ previewType?: string;
234
+ /** Generate 16 angle views for 360° preview (passed to child job). */
235
+ generate360Views?: boolean;
157
236
  }
158
237
  /**
159
238
  * Contains synced analytics data for marketplace listings. Backend stores this in marketplace_analytics_snapshots table and indexes to ELK. Works with any marketplace provider.
@@ -201,6 +280,184 @@ export interface MarketplaceAnalyticsSyncRequestMessage {
201
280
  /** Callback URL for completion notification */
202
281
  webhookUrl?: string;
203
282
  }
283
+ /**
284
+ * Notification that marketplace connection sync has completed. Contains updated connection metadata, profile information, and sync statistics.
285
+
286
+ */
287
+ export interface MarketplaceConnectionSyncCompletedMessage {
288
+ /** Original request ID for correlation */
289
+ requestId?: string;
290
+ /** Marketplace connection that was synced */
291
+ connectionId?: string;
292
+ /** Marketplace provider ID */
293
+ marketplaceId?: string;
294
+ /** Connection owner user ID */
295
+ userId?: string;
296
+ /** Overall sync result status */
297
+ status?: string;
298
+ /** Type of sync that was performed */
299
+ syncType?: string;
300
+ /** Updated connection information */
301
+ connectionData?: Record<string, string | number | boolean>;
302
+ /** Available marketplace categories */
303
+ categories?: Array<Record<string, string | number | boolean>>;
304
+ /** Sync operation statistics */
305
+ statistics?: Record<string, string | number | boolean>;
306
+ /** When sync completed */
307
+ completedAt?: string;
308
+ /** Error details if sync failed */
309
+ error?: Record<string, string | number | boolean>;
310
+ }
311
+ /**
312
+ * Requests synchronization of marketplace connection data including: - Profile information and shop details - Account status and permissions - Available categories and shipping profiles - Rate limits and API quotas
313
+ This is typically triggered after initial connection or periodically to keep marketplace metadata up to date.
314
+
315
+ */
316
+ export interface MarketplaceConnectionSyncRequestMessage {
317
+ /** Internal marketplace connection ID */
318
+ connectionId?: string;
319
+ /** Marketplace provider ID (etsy, ebay, etc.) */
320
+ marketplaceId?: string;
321
+ /** User who owns this connection */
322
+ userId?: string;
323
+ /** Type of sync to perform */
324
+ syncType?: string;
325
+ /** Processing priority */
326
+ priority?: string;
327
+ /** Unique request identifier for tracking */
328
+ requestId?: string;
329
+ /** Webhook URL to call when sync completes */
330
+ webhookUrl?: string;
331
+ /** Additional context data */
332
+ metadata?: Record<string, string | number | boolean>;
333
+ }
334
+ /**
335
+ * Notification that marketplace credential rotation has completed. Contains the rotation results, new credential metadata, and any issues encountered.
336
+
337
+ */
338
+ export interface MarketplaceCredentialRotationCompletedMessage {
339
+ /** Original rotation request ID */
340
+ requestId?: string;
341
+ /** Marketplace connection that was rotated */
342
+ connectionId?: string;
343
+ /** Marketplace provider ID */
344
+ marketplaceId?: string;
345
+ /** Connection owner user ID */
346
+ userId?: string;
347
+ /** Overall rotation operation status */
348
+ status?: string;
349
+ /** Type of rotation that was performed */
350
+ rotationType?: string;
351
+ /** Original reason for rotation */
352
+ reason?: string;
353
+ /** Metadata about new credentials */
354
+ newCredentials?: Record<string, string | number | boolean>;
355
+ /** Status of previous credentials */
356
+ oldCredentials?: Record<string, string | number | boolean>;
357
+ /** Details of the rotation operation */
358
+ operationDetails?: Record<string, string | number | boolean>;
359
+ /** Connection status after credential rotation */
360
+ connectionStatus?: Record<string, string | number | boolean>;
361
+ /** Information about next scheduled rotation */
362
+ nextRotation?: Record<string, string | number | boolean>;
363
+ /** Error details if rotation failed */
364
+ error?: Record<string, string | number | boolean>;
365
+ /** Notifications sent as part of rotation */
366
+ notifications?: Array<Record<string, string | number | boolean>>;
367
+ }
368
+ /**
369
+ * Requests rotation/refresh of marketplace connection credentials. This is used for: - OAuth token refresh when tokens are near expiry - API key rotation for enhanced security - Re-authentication after connection errors - Scheduled credential updates
370
+
371
+ */
372
+ export interface MarketplaceCredentialRotationRequestMessage {
373
+ /** Marketplace connection ID requiring credential rotation */
374
+ connectionId?: string;
375
+ /** Marketplace provider ID (etsy, ebay, etc.) */
376
+ marketplaceId?: string;
377
+ /** User who owns the connection */
378
+ userId?: string;
379
+ /** Type of credential rotation to perform */
380
+ rotationType?: string;
381
+ /** Reason for credential rotation */
382
+ reason?: string;
383
+ /** How urgently the rotation is needed */
384
+ urgency?: string;
385
+ /** Current credential metadata (no actual secrets) */
386
+ currentCredentials?: Record<string, string | number | boolean>;
387
+ /** Rotation configuration options */
388
+ options?: Record<string, string | number | boolean>;
389
+ /** Unique request identifier */
390
+ requestId?: string;
391
+ /** Webhook URL for completion notification */
392
+ webhookUrl?: string;
393
+ /** When this rotation was scheduled (if scheduled) */
394
+ scheduledAt?: string;
395
+ /** Additional request context */
396
+ metadata?: Record<string, string | number | boolean>;
397
+ }
398
+ /**
399
+ * Notification that marketplace listing sync operation has completed. Contains detailed results of the sync including created/updated listings, errors encountered, and performance statistics.
400
+
401
+ */
402
+ export interface MarketplaceListingSyncCompletedMessage {
403
+ /** Original request ID for correlation */
404
+ requestId?: string;
405
+ /** Marketplace connection that was synced */
406
+ connectionId?: string;
407
+ /** Marketplace provider ID */
408
+ marketplaceId?: string;
409
+ /** Connection owner user ID */
410
+ userId?: string;
411
+ /** Overall sync operation status */
412
+ status?: string;
413
+ /** Direction of sync that was performed */
414
+ syncDirection?: string;
415
+ /** Detailed sync operation statistics */
416
+ statistics?: Record<string, string | number | boolean>;
417
+ /** Detailed sync results by operation */
418
+ results?: Record<string, string | number | boolean>;
419
+ /** Details of successfully processed listings */
420
+ successfulListings?: Array<Record<string, string | number | boolean>>;
421
+ /** Details of listings that failed to sync */
422
+ failedListings?: Array<Record<string, string | number | boolean>>;
423
+ /** Non-listing-specific errors encountered */
424
+ errors?: Array<Record<string, string | number | boolean>>;
425
+ /** When sync operation completed */
426
+ completedAt?: string;
427
+ /** When next sync is recommended */
428
+ nextSyncRecommendedAt?: string;
429
+ }
430
+ /**
431
+ * Requests synchronization of marketplace listings for a connection. Can sync specific listings or all listings for a marketplace connection.
432
+ Includes bidirectional sync: - Pull: Fetch listings from marketplace to update local database - Push: Update marketplace listings with local changes - Full: Both pull and push operations
433
+
434
+ */
435
+ export interface MarketplaceListingSyncRequestMessage {
436
+ /** Marketplace connection ID */
437
+ connectionId?: string;
438
+ /** Marketplace provider ID (etsy, ebay, etc.) */
439
+ marketplaceId?: string;
440
+ /** User who owns the connection */
441
+ userId?: string;
442
+ /** Direction of sync operation */
443
+ syncDirection?: string;
444
+ /** Scope of listings to sync */
445
+ syncScope?: string;
446
+ /** Specific listing IDs to sync (if syncScope=specific) */
447
+ listingIds?: Array<Record<string, string | number | boolean>>;
448
+ /** External marketplace listing IDs to sync */
449
+ externalListingIds?: Array<Record<string, string | number | boolean>>;
450
+ /** Sync configuration options */
451
+ options?: Record<string, string | number | boolean>;
452
+ /** Processing priority */
453
+ priority?: string;
454
+ /** Unique request identifier */
455
+ requestId?: string;
456
+ /** Webhook URL for completion notification */
457
+ webhookUrl?: string;
458
+ /** Additional request context */
459
+ metadata?: Record<string, string | number | boolean>;
460
+ }
204
461
  /**
205
462
  * Indicates completion of marketplace listing publication. Contains external listing ID and URL, or error details if failed. Works with any marketplace provider (etsy, ebay, etc.).
206
463
  */
@@ -322,6 +579,36 @@ export interface MetamodelMetadataGenerationRequestMessage {
322
579
  /** Optional webhook URL for async completion notification */
323
580
  webhookUrl?: string;
324
581
  }
582
+ /**
583
+ * Request to collect marketplace analytics for a specific metamodel.
584
+ Triggered by backend scheduler every 6 hours for popular/tagged metamodels.
585
+
586
+ Worker performs targeted market searches based on metamodel metadata
587
+ and stores aggregated statistics in Elasticsearch for trend analysis.
588
+
589
+ */
590
+ export interface ModelAnalyticsCollectionRequestMessage {
591
+ /** The metamodel ID to collect analytics for */
592
+ metamodelId: string;
593
+ /** Owner user ID for audit trail */
594
+ ownerId: string;
595
+ /** Primary classification category (e.g., "miniature", "terrain") */
596
+ primaryCategory?: string;
597
+ /** Sub-category for more specific targeting */
598
+ subCategory?: string;
599
+ /** Relevant tags from metamodel metadata (max 10) */
600
+ tags?: Array<Record<string, string | number | boolean>>;
601
+ /** Franchise name if detected (e.g., "Dungeons & Dragons") */
602
+ franchise?: string;
603
+ /** Classification confidence score */
604
+ confidence?: number;
605
+ /** Collection priority level */
606
+ priority?: string;
607
+ /** Source of trigger (e.g., "backend-scheduler", "manual") */
608
+ triggeredBy?: string;
609
+ /** Timestamp when collection was triggered */
610
+ triggeredAt?: string;
611
+ }
325
612
  /**
326
613
  * Handles model discovery folder processed events.
327
614
  */
@@ -383,36 +670,30 @@ export interface ModelDiscoveryScanRequestMessage {
383
670
  path?: string;
384
671
  }
385
672
  /**
386
- * Handles model metadata generation completed.
673
+ * Notifies backend that enriched marketplace metadata generation completed. Backend updates Model entity with generated description, tags, classification, etc.
387
674
  */
388
675
  export interface ModelMetadataGenerationCompletedMessage {
389
- /** The unique identifier for the model. */
676
+ /** UUID of the model that was processed. */
390
677
  modelId: string;
391
- /** The enriched metadata for the model. */
678
+ /** Enriched marketplace metadata generated by LLM. */
392
679
  metadata: Record<string, string | number | boolean>;
393
680
  }
394
681
  /**
395
- * Handles model metadata generation requests.
682
+ * Generates enriched marketplace metadata (SEO descriptions, tags, categories) for 3D models using LLM analysis with optional vision capabilities. Worker fetches model data from database and uses thumbnails for enhanced analysis when available. Prerequisites: file download, thumbnail generation (optional for vision), and technical metadata analysis (strongly recommended).
396
683
  */
397
684
  export interface ModelMetadataGenerationRequestMessage {
398
- /** The unique identifier for the model. */
685
+ /** UUID of the model to generate metadata for. Worker queries database for: Model.fileName, Model.fileSize, Model.storageItem (path, provider). For vision-enhanced analysis, worker queries thumbnail_media table for thumbnail paths. */
399
686
  modelId?: string;
400
- /** The ID of the storage connection. */
401
- storageConnectionId?: string;
402
- /** The path to the model file. */
403
- filePath?: string;
404
- /** The name of the model file. */
405
- fileName?: string;
406
- /** The size of the model file in bytes. */
407
- fileSize?: number;
408
- /** The last modified date of the model file. */
409
- fileLastModified?: string;
410
- /** The type of the storage provider. */
411
- storageProviderType?: string;
412
- /** The URL of the model thumbnail. */
413
- modelThumbnailUrl?: string;
414
- /** The metamodel of the model. */
415
- metamodel?: Record<string, string | number | boolean>;
687
+ /** UUID of the model owner. Used for authorization and audit logging. */
688
+ ownerId?: string;
689
+ /** ID of parent job (file-download, thumbnail-generation, or technical-analysis) for BullMQ dependency tracking. Ensures metadata generation runs after prerequisites complete. Should reference thumbnail-generation job when vision analysis is desired. */
690
+ parentJobId?: string;
691
+ /** Technical analysis results (geometry, quality metrics, printability) passed from backend. Worker-core-lib Model schema lacks technical_metadata column, so backend must provide this data. Used for enhanced LLM prompt context. Include: vertexCount, faceCount, surfaceArea, volume, qualityScore, printabilityScore, detectedIssues, etc. */
692
+ technicalMetadata?: Record<string, string | number | boolean>;
693
+ /** Path to generated thumbnail in MinIO storage (e.g., 'thumbnails/{modelId}/thumbnail.webp'). If provided, enables vision-enhanced metadata generation. Worker can also query thumbnail_media table, but explicit path improves performance. */
694
+ thumbnailPath?: string;
695
+ /** Flag to enable vision-based metadata enrichment using thumbnail images. Requires thumbnailPath or available thumbnail in database. Vision analysis generates more accurate descriptions, tags, and classifications based on visual appearance. */
696
+ enableVisionAnalysis?: boolean;
416
697
  }
417
698
  /**
418
699
  * Handles model metamodel detection found with hierarchical relationships.
@@ -476,6 +757,54 @@ export interface ModelSellabilityAnalysisRequestMessage {
476
757
  /** Optional analysis configuration */
477
758
  analysisOptions?: Record<string, string | number | boolean>;
478
759
  }
760
+ /**
761
+ * Handles completion of 3D model semantic analysis with generated tags and similarity results.
762
+ */
763
+ export interface ModelSemanticAnalysisCompletedMessage {
764
+ /** The unique identifier for the model. */
765
+ modelId?: string;
766
+ /** The user ID who owns the model. */
767
+ userId?: string;
768
+ /** Final processing status. */
769
+ processingStatus?: string;
770
+ /** Generated semantic metadata and analysis results. */
771
+ semanticMetadata?: Record<string, string | number | boolean>;
772
+ /** Processing performance metrics. */
773
+ processingTime?: Record<string, string | number | boolean>;
774
+ /** Processing quality and confidence metrics. */
775
+ qualityMetrics?: Record<string, string | number | boolean>;
776
+ /** Error information if processing failed. */
777
+ error?: Record<string, string | number | boolean>;
778
+ /** Additional debug information for troubleshooting. */
779
+ debugInfo?: Record<string, string | number | boolean>;
780
+ }
781
+ /**
782
+ * Handles 3D model semantic analysis requests using ULIP-2 neural networks and FAISS vector similarity search.
783
+ */
784
+ export interface ModelSemanticAnalysisRequestMessage {
785
+ /** The unique identifier for the model. */
786
+ modelId?: string;
787
+ /** The user ID who owns the model. */
788
+ userId?: string;
789
+ /** The ID of the storage connection. */
790
+ storageConnectionId?: string;
791
+ /** The path to the 3D model file in storage. */
792
+ filePath?: string;
793
+ /** The name of the model file. */
794
+ fileName?: string;
795
+ /** The size of the model file in bytes. */
796
+ fileSize?: number;
797
+ /** The type of the storage provider (S3, GoogleDrive, SFTP, etc). */
798
+ storageProviderType?: string;
799
+ /** Configuration options for semantic analysis. */
800
+ processingOptions?: Record<string, string | number | boolean>;
801
+ /** Processing priority (1=highest, 10=lowest). */
802
+ priority?: number;
803
+ /** Optional webhook URL for completion notification. */
804
+ webhookUrl?: string;
805
+ /** Current retry attempt number. */
806
+ retryCount?: number;
807
+ }
479
808
  /**
480
809
  * Reports comprehensive results of technical metadata analysis including geometry, quality metrics, and print-readiness assessment
481
810
  */
@@ -565,8 +894,12 @@ export interface ModelTechnicalMetadataRequestMessage {
565
894
  modelId?: string;
566
895
  /** User ID who owns the model */
567
896
  ownerId?: string;
568
- /** Location of the 3D model file */
897
+ /** Location of the 3D model file (legacy - used for direct download if minioPath not provided) */
569
898
  storageLocation?: Record<string, string | number | boolean>;
899
+ /** Path to model in MinIO (e.g., 'raw_models/{modelId}/original.glb'). If provided, file will be read from MinIO instead of downloading from storage provider. */
900
+ minioPath?: string;
901
+ /** ID of parent file-download job (for BullMQ dependency tracking). */
902
+ parentJobId?: string;
570
903
  /** Optional analysis configuration parameters */
571
904
  analysisOptions?: Record<string, string | number | boolean>;
572
905
  }
@@ -588,17 +921,175 @@ export interface ThumbnailGenerationCompletedMessage {
588
921
  storageLocation?: Record<string, string | number | boolean>;
589
922
  }
590
923
  /**
591
- * Handles thumbnail generation requests with customization options.
924
+ * Handles thumbnail generation requests with customization options. Supports both storage provider downloads and MinIO-cached files.
592
925
  */
593
926
  export interface ThumbnailGenerationRequestMessage {
594
927
  /** The unique identifier for the model requiring a thumbnail. */
595
928
  modelId?: string;
596
929
  /** The identifier of the user who owns the entity. */
597
930
  ownerId?: string;
598
- /** The storage location of the model. */
931
+ /** The storage location of the model (legacy - used for direct download if minioPath not provided). */
599
932
  storageLocation?: Record<string, string | number | boolean>;
933
+ /** Path to model in MinIO (e.g., 'raw_models/{modelId}/original.glb'). If provided, file will be read from MinIO instead of downloading from storage provider. */
934
+ minioPath?: string;
600
935
  /** The type of preview to generate, e.g., 'default', 'static', 'glb'. */
601
936
  previewType?: string;
937
+ /** Generate 16 angle views for 360° preview (4 horizontal x 4 vertical angles). */
938
+ generate360Views?: boolean;
939
+ /** ID of parent file-download job (for BullMQ dependency tracking). */
940
+ parentJobId?: string;
602
941
  /** User-defined customizations for the thumbnail. */
603
942
  customization?: Record<string, string | number | boolean>;
604
943
  }
944
+ /**
945
+ * User engagement and onboarding tracking events for analytics and behavioral insights.
946
+
947
+ Captures key user actions throughout their journey:
948
+ - Account creation and onboarding steps
949
+ - Feature usage and adoption
950
+ - Model management activities
951
+ - Marketplace interactions
952
+ - Subscription changes
953
+
954
+ Used for:
955
+ - User onboarding funnel analysis
956
+ - Feature adoption tracking
957
+ - User retention metrics
958
+ - A/B testing and experimentation
959
+ - Personalization and recommendations
960
+ - Product analytics dashboards
961
+
962
+ */
963
+ export interface UserEngagementEventMessage {
964
+ /** Category of user engagement event */
965
+ eventType: string;
966
+ /** Specific user action performed */
967
+ action: string;
968
+ /** ISO 8601 timestamp when the action occurred */
969
+ timestamp: string;
970
+ /** Unique identifier of the user */
971
+ userId: string;
972
+ /** User's email (hashed for privacy in analytics) */
973
+ userEmail?: string;
974
+ /** When the user account was created (for cohort analysis) */
975
+ userCreatedAt?: string;
976
+ /** Current subscription plan tier */
977
+ userPlanTier?: string;
978
+ /** User session identifier for grouping actions */
979
+ sessionId?: string;
980
+ /** Request ID for correlation with logs */
981
+ requestId?: string;
982
+ /** Additional context about the action */
983
+ actionDetails?: Record<string, string | number | boolean>;
984
+ /** Where the action originated */
985
+ source?: string;
986
+ /** HTTP method used */
987
+ httpMethod?: string;
988
+ /** API endpoint path */
989
+ httpUrl?: string;
990
+ /** HTTP response status code */
991
+ httpStatusCode?: string | number | boolean;
992
+ /** Action duration in milliseconds */
993
+ durationMs?: number;
994
+ /** A/B test or experiment ID */
995
+ experimentId?: string;
996
+ /** Experiment variant/group */
997
+ experimentVariant?: string;
998
+ /** Deployment environment */
999
+ environment?: string;
1000
+ /** Client/browser information (anonymized) */
1001
+ clientInfo?: Record<string, string | number | boolean>;
1002
+ }
1003
+ /**
1004
+ * Analytics event emitted by workers for tracking processing metrics, user behavior,
1005
+ and model statistics. Consumed by worker-analytic-collector and forwarded to ELK.
1006
+
1007
+ All workers MUST emit this event upon job completion (success or failure).
1008
+ Each worker includes its specific metrics in the `metrics` object.
1009
+
1010
+ */
1011
+ export interface WorkerAnalyticsEventMessage {
1012
+ /** Type of analytics event */
1013
+ eventType: string;
1014
+ /** Identifier of the worker that processed the job */
1015
+ workerId: string;
1016
+ /** Unique job identifier from BullMQ */
1017
+ jobId: string;
1018
+ /** ISO 8601 timestamp of event emission */
1019
+ timestamp: string;
1020
+ /** User who owns the model/triggered the job */
1021
+ userId?: string;
1022
+ /** Model identifier (if applicable) */
1023
+ modelId?: string;
1024
+ /** Metamodel identifier (if applicable) */
1025
+ metamodelId?: string;
1026
+ /** Storage item identifier (for download events) */
1027
+ storageItemId?: string;
1028
+ /** Job completion status */
1029
+ status?: string;
1030
+ /** Error code if status is failure */
1031
+ errorCode?: string;
1032
+ /** Error message if status is failure */
1033
+ errorMessage?: string;
1034
+ /** Processing time metrics in milliseconds */
1035
+ timing?: Record<string, string | number | boolean>;
1036
+ /** Worker-specific metrics. Structure varies by eventType. */
1037
+ metrics?: Record<string, string | number | boolean>;
1038
+ }
1039
+ /**
1040
+ * Enriched metrics event for detailed worker monitoring, cost tracking,
1041
+ and performance analysis. Published to backend.logging.events for
1042
+ centralized monitoring and cost attribution.
1043
+
1044
+ This event is emitted by all workers on job completion and includes:
1045
+ - LLM token usage and cost breakdown
1046
+ - System resource consumption (CPU, RAM, disk I/O)
1047
+ - Detailed timing breakdown by stage
1048
+ - User and context attribution
1049
+ - Model-specific metadata
1050
+
1051
+ */
1052
+ export interface WorkerMetricsEnrichedEventMessage {
1053
+ /** Fixed type for enriched worker metrics */
1054
+ eventType: string;
1055
+ /** Identifier of the worker */
1056
+ workerId: string;
1057
+ /** Unique BullMQ job identifier */
1058
+ jobId: string;
1059
+ /** ISO 8601 timestamp when job completed */
1060
+ timestamp: string;
1061
+ /** Job completion status */
1062
+ status: string;
1063
+ /** User who owns the resource/triggered the job */
1064
+ userId?: string;
1065
+ /** Organization/tenant ID (for multi-tenant deployments) */
1066
+ tenantId?: string;
1067
+ /** Session ID for correlating user actions */
1068
+ sessionId?: string;
1069
+ /** Request ID from originating API call (X-Request-Id) */
1070
+ requestId?: string;
1071
+ /** Model ID being processed */
1072
+ modelId?: string;
1073
+ /** Metamodel ID being processed */
1074
+ metamodelId?: string;
1075
+ /** Storage item ID (for file operations) */
1076
+ storageItemId?: string;
1077
+ /** Comprehensive timing breakdown */
1078
+ timing?: Record<string, string | number | boolean>;
1079
+ /** LLM token usage and cost breakdown */
1080
+ llmUsage?: Record<string, string | number | boolean>;
1081
+ /** System resource consumption during job */
1082
+ resources?: Record<string, string | number | boolean>;
1083
+ /** Worker-specific metrics (varies by worker type) */
1084
+ workerMetrics?: Record<string, string | number | boolean>;
1085
+ /** Error details if status is failure */
1086
+ error?: Record<string, string | number | boolean>;
1087
+ /** Deployment environment */
1088
+ environment?: string;
1089
+ /** Cloud region/datacenter */
1090
+ region?: string;
1091
+ /** Worker service version */
1092
+ workerVersion?: string;
1093
+ /** Pod/container hostname */
1094
+ hostname?: string;
1095
+ }