@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/README.md CHANGED
@@ -100,6 +100,69 @@ await client.sendToQueue(MessageTypes.FILE_DOWNLOAD_REQUEST, {
100
100
  ## Available Message Types
101
101
 
102
102
 
103
+ ### backend-logging-event
104
+
105
+ **Description:** Centralized logging event for capturing all warn/error/failure logs from meshsync-backend.
106
+ This event is sent to ELK for centralized monitoring, alerting, and debugging.
107
+
108
+ Automatically emitted by the custom Pino logger interceptor when:
109
+ - logger.warn() is called
110
+ - logger.error() is called
111
+ - uncaught exceptions occur
112
+ - request failures happen (4xx, 5xx responses)
113
+
114
+ Used for:
115
+ - System health monitoring
116
+ - Error tracking and alerting
117
+ - Performance degradation detection
118
+ - Security incident tracking
119
+ - Compliance and audit trails
120
+
121
+
122
+ **Method:** `client.backendLoggingEvent(data)`
123
+
124
+ **Payload Type:** `BackendLoggingEventMessage`
125
+
126
+ **Fields:**
127
+
128
+ - `eventType` (string) [✓]: Type of logging event
129
+
130
+ - `timestamp` (string) [✓]: ISO 8601 timestamp when the log was generated
131
+
132
+ - `level` (string) [✓]: Log level severity
133
+
134
+ - `message` (string) [✓]: Human-readable log message
135
+
136
+ - `context` (string) [✓]: Logger context (typically the class/service name)
137
+
138
+ - `requestId` (string) [✗]: Unique request ID for correlation (X-Request-Id header)
139
+
140
+ - `userId` (string) [✗]: ID of the authenticated user (if available)
141
+
142
+ - `httpMethod` (string) [✗]: HTTP method of the request
143
+
144
+ - `httpUrl` (string) [✗]: Request URL path (without query params for privacy)
145
+
146
+ - `httpStatusCode` (integer) [✗]: HTTP response status code
147
+
148
+ - `errorType` (string) [✗]: Error class/type name
149
+
150
+ - `errorStack` (string) [✗]: Stack trace (sanitized, no sensitive data)
151
+
152
+ - `errorCode` (string) [✗]: Application-specific error code for categorization
153
+
154
+ - `metadata` (object) [✗]: Additional structured context (sanitized, no PII)
155
+
156
+ - `environment` (string) [✗]: Deployment environment
157
+
158
+ - `serviceVersion` (string) [✗]: Backend service version
159
+
160
+ - `hostname` (string) [✗]: Server hostname/pod name
161
+
162
+ - `durationMs` (number) [✗]: Operation duration in milliseconds (if applicable)
163
+
164
+
165
+
103
166
  ### etsy-analytics-sync-completed
104
167
 
105
168
  **Description:** Contains synced analytics data for Etsy listings. Backend stores this in etsy_analytics_snapshots table and indexes to ELK.
@@ -251,7 +314,7 @@ Example: Publishing a metamodel with PLA, Resin, ABS materials creates 3 jobs.
251
314
 
252
315
  ### file-download-request
253
316
 
254
- **Description:** Handles file download requests.
317
+ **Description:** Downloads model file from storage provider to MinIO for processing pipeline. Acts as parent job for thumbnail generation, technical metadata analysis, and metadata generation.
255
318
 
256
319
  **Method:** `client.fileDownloadRequest(data)`
257
320
 
@@ -261,8 +324,18 @@ Example: Publishing a metamodel with PLA, Resin, ABS materials creates 3 jobs.
261
324
 
262
325
  - `modelId` (string) [✗]: The unique identifier for the model to be downloaded.
263
326
 
327
+ - `ownerId` (string) [✗]: The identifier of the user who owns the model. Optional - if not provided, will be retrieved from StorageConnection.
328
+
264
329
  - `storageLocation` (object) [✗]: The storage location of the model.
265
330
 
331
+ - `minioDestination` (object) [✗]: Destination in MinIO where file will be uploaded after download.
332
+
333
+ - `autoEnqueueChildren` (boolean) [✗]: Automatically enqueue thumbnail generation, technical metadata analysis, and metadata generation jobs after download completes.
334
+
335
+ - `previewType` (string) [✗]: Preview type for thumbnail generation (passed to child job).
336
+
337
+ - `generate360Views` (boolean) [✗]: Generate 16 angle views for 360° preview (passed to child job).
338
+
266
339
 
267
340
 
268
341
  ### marketplace-analytics-sync-completed
@@ -325,6 +398,226 @@ Example: Publishing a metamodel with PLA, Resin, ABS materials creates 3 jobs.
325
398
 
326
399
 
327
400
 
401
+ ### marketplace-connection-sync-completed
402
+
403
+ **Description:** Notification that marketplace connection sync has completed. Contains updated connection metadata, profile information, and sync statistics.
404
+
405
+
406
+ **Method:** `client.marketplaceConnectionSyncCompleted(data)`
407
+
408
+ **Payload Type:** `MarketplaceConnectionSyncCompletedMessage`
409
+
410
+ **Fields:**
411
+
412
+ - `requestId` (string) [✗]: Original request ID for correlation
413
+
414
+ - `connectionId` (string) [✗]: Marketplace connection that was synced
415
+
416
+ - `marketplaceId` (string) [✗]: Marketplace provider ID
417
+
418
+ - `userId` (string) [✗]: Connection owner user ID
419
+
420
+ - `status` (string) [✗]: Overall sync result status
421
+
422
+ - `syncType` (string) [✗]: Type of sync that was performed
423
+
424
+ - `connectionData` (object) [✗]: Updated connection information
425
+
426
+ - `categories` (array) [✗]: Available marketplace categories
427
+
428
+ - `statistics` (object) [✗]: Sync operation statistics
429
+
430
+ - `completedAt` (string) [✗]: When sync completed
431
+
432
+ - `error` (object) [✗]: Error details if sync failed
433
+
434
+
435
+
436
+ ### marketplace-connection-sync-request
437
+
438
+ **Description:** 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
439
+ This is typically triggered after initial connection or periodically to keep marketplace metadata up to date.
440
+
441
+
442
+ **Method:** `client.marketplaceConnectionSyncRequest(data)`
443
+
444
+ **Payload Type:** `MarketplaceConnectionSyncRequestMessage`
445
+
446
+ **Fields:**
447
+
448
+ - `connectionId` (string) [✗]: Internal marketplace connection ID
449
+
450
+ - `marketplaceId` (string) [✗]: Marketplace provider ID (etsy, ebay, etc.)
451
+
452
+ - `userId` (string) [✗]: User who owns this connection
453
+
454
+ - `syncType` (string) [✗]: Type of sync to perform
455
+
456
+ - `priority` (string) [✗]: Processing priority
457
+
458
+ - `requestId` (string) [✗]: Unique request identifier for tracking
459
+
460
+ - `webhookUrl` (string) [✗]: Webhook URL to call when sync completes
461
+
462
+ - `metadata` (object) [✗]: Additional context data
463
+
464
+
465
+
466
+ ### marketplace-credential-rotation-completed
467
+
468
+ **Description:** Notification that marketplace credential rotation has completed. Contains the rotation results, new credential metadata, and any issues encountered.
469
+
470
+
471
+ **Method:** `client.marketplaceCredentialRotationCompleted(data)`
472
+
473
+ **Payload Type:** `MarketplaceCredentialRotationCompletedMessage`
474
+
475
+ **Fields:**
476
+
477
+ - `requestId` (string) [✗]: Original rotation request ID
478
+
479
+ - `connectionId` (string) [✗]: Marketplace connection that was rotated
480
+
481
+ - `marketplaceId` (string) [✗]: Marketplace provider ID
482
+
483
+ - `userId` (string) [✗]: Connection owner user ID
484
+
485
+ - `status` (string) [✗]: Overall rotation operation status
486
+
487
+ - `rotationType` (string) [✗]: Type of rotation that was performed
488
+
489
+ - `reason` (string) [✗]: Original reason for rotation
490
+
491
+ - `newCredentials` (object) [✗]: Metadata about new credentials
492
+
493
+ - `oldCredentials` (object) [✗]: Status of previous credentials
494
+
495
+ - `operationDetails` (object) [✗]: Details of the rotation operation
496
+
497
+ - `connectionStatus` (object) [✗]: Connection status after credential rotation
498
+
499
+ - `nextRotation` (object) [✗]: Information about next scheduled rotation
500
+
501
+ - `error` (object) [✗]: Error details if rotation failed
502
+
503
+ - `notifications` (array) [✗]: Notifications sent as part of rotation
504
+
505
+
506
+
507
+ ### marketplace-credential-rotation-request
508
+
509
+ **Description:** 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
510
+
511
+
512
+ **Method:** `client.marketplaceCredentialRotationRequest(data)`
513
+
514
+ **Payload Type:** `MarketplaceCredentialRotationRequestMessage`
515
+
516
+ **Fields:**
517
+
518
+ - `connectionId` (string) [✗]: Marketplace connection ID requiring credential rotation
519
+
520
+ - `marketplaceId` (string) [✗]: Marketplace provider ID (etsy, ebay, etc.)
521
+
522
+ - `userId` (string) [✗]: User who owns the connection
523
+
524
+ - `rotationType` (string) [✗]: Type of credential rotation to perform
525
+
526
+ - `reason` (string) [✗]: Reason for credential rotation
527
+
528
+ - `urgency` (string) [✗]: How urgently the rotation is needed
529
+
530
+ - `currentCredentials` (object) [✗]: Current credential metadata (no actual secrets)
531
+
532
+ - `options` (object) [✗]: Rotation configuration options
533
+
534
+ - `requestId` (string) [✗]: Unique request identifier
535
+
536
+ - `webhookUrl` (string) [✗]: Webhook URL for completion notification
537
+
538
+ - `scheduledAt` (string) [✗]: When this rotation was scheduled (if scheduled)
539
+
540
+ - `metadata` (object) [✗]: Additional request context
541
+
542
+
543
+
544
+ ### marketplace-listing-sync-completed
545
+
546
+ **Description:** Notification that marketplace listing sync operation has completed. Contains detailed results of the sync including created/updated listings, errors encountered, and performance statistics.
547
+
548
+
549
+ **Method:** `client.marketplaceListingSyncCompleted(data)`
550
+
551
+ **Payload Type:** `MarketplaceListingSyncCompletedMessage`
552
+
553
+ **Fields:**
554
+
555
+ - `requestId` (string) [✗]: Original request ID for correlation
556
+
557
+ - `connectionId` (string) [✗]: Marketplace connection that was synced
558
+
559
+ - `marketplaceId` (string) [✗]: Marketplace provider ID
560
+
561
+ - `userId` (string) [✗]: Connection owner user ID
562
+
563
+ - `status` (string) [✗]: Overall sync operation status
564
+
565
+ - `syncDirection` (string) [✗]: Direction of sync that was performed
566
+
567
+ - `statistics` (object) [✗]: Detailed sync operation statistics
568
+
569
+ - `results` (object) [✗]: Detailed sync results by operation
570
+
571
+ - `successfulListings` (array) [✗]: Details of successfully processed listings
572
+
573
+ - `failedListings` (array) [✗]: Details of listings that failed to sync
574
+
575
+ - `errors` (array) [✗]: Non-listing-specific errors encountered
576
+
577
+ - `completedAt` (string) [✗]: When sync operation completed
578
+
579
+ - `nextSyncRecommendedAt` (string) [✗]: When next sync is recommended
580
+
581
+
582
+
583
+ ### marketplace-listing-sync-request
584
+
585
+ **Description:** Requests synchronization of marketplace listings for a connection. Can sync specific listings or all listings for a marketplace connection.
586
+ 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
587
+
588
+
589
+ **Method:** `client.marketplaceListingSyncRequest(data)`
590
+
591
+ **Payload Type:** `MarketplaceListingSyncRequestMessage`
592
+
593
+ **Fields:**
594
+
595
+ - `connectionId` (string) [✗]: Marketplace connection ID
596
+
597
+ - `marketplaceId` (string) [✗]: Marketplace provider ID (etsy, ebay, etc.)
598
+
599
+ - `userId` (string) [✗]: User who owns the connection
600
+
601
+ - `syncDirection` (string) [✗]: Direction of sync operation
602
+
603
+ - `syncScope` (string) [✗]: Scope of listings to sync
604
+
605
+ - `listingIds` (array) [✗]: Specific listing IDs to sync (if syncScope=specific)
606
+
607
+ - `externalListingIds` (array) [✗]: External marketplace listing IDs to sync
608
+
609
+ - `options` (object) [✗]: Sync configuration options
610
+
611
+ - `priority` (string) [✗]: Processing priority
612
+
613
+ - `requestId` (string) [✗]: Unique request identifier
614
+
615
+ - `webhookUrl` (string) [✗]: Webhook URL for completion notification
616
+
617
+ - `metadata` (object) [✗]: Additional request context
618
+
619
+
620
+
328
621
  ### marketplace-publish-listing-completed
329
622
 
330
623
  **Description:** 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.).
@@ -488,6 +781,43 @@ Example: Publishing a metamodel with PLA, Resin, ABS materials creates 3 jobs.
488
781
 
489
782
 
490
783
 
784
+ ### model-analytics-collection-request
785
+
786
+ **Description:** Request to collect marketplace analytics for a specific metamodel.
787
+ Triggered by backend scheduler every 6 hours for popular/tagged metamodels.
788
+
789
+ Worker performs targeted market searches based on metamodel metadata
790
+ and stores aggregated statistics in Elasticsearch for trend analysis.
791
+
792
+
793
+ **Method:** `client.modelAnalyticsCollectionRequest(data)`
794
+
795
+ **Payload Type:** `ModelAnalyticsCollectionRequestMessage`
796
+
797
+ **Fields:**
798
+
799
+ - `metamodelId` (string) [✓]: The metamodel ID to collect analytics for
800
+
801
+ - `ownerId` (string) [✓]: Owner user ID for audit trail
802
+
803
+ - `primaryCategory` (string) [✗]: Primary classification category (e.g., "miniature", "terrain")
804
+
805
+ - `subCategory` (string) [✗]: Sub-category for more specific targeting
806
+
807
+ - `tags` (array) [✗]: Relevant tags from metamodel metadata (max 10)
808
+
809
+ - `franchise` (string) [✗]: Franchise name if detected (e.g., "Dungeons & Dragons")
810
+
811
+ - `confidence` (number) [✗]: Classification confidence score
812
+
813
+ - `priority` (string) [✗]: Collection priority level
814
+
815
+ - `triggeredBy` (string) [✗]: Source of trigger (e.g., "backend-scheduler", "manual")
816
+
817
+ - `triggeredAt` (string) [✗]: Timestamp when collection was triggered
818
+
819
+
820
+
491
821
  ### model-discovery-folder-processed-event
492
822
 
493
823
  **Description:** Handles model discovery folder processed events.
@@ -578,7 +908,7 @@ Example: Publishing a metamodel with PLA, Resin, ABS materials creates 3 jobs.
578
908
 
579
909
  ### model-metadata-generation-completed
580
910
 
581
- **Description:** Handles model metadata generation completed.
911
+ **Description:** Notifies backend that enriched marketplace metadata generation completed. Backend updates Model entity with generated description, tags, classification, etc.
582
912
 
583
913
  **Method:** `client.modelMetadataGenerationCompleted(data)`
584
914
 
@@ -586,15 +916,15 @@ Example: Publishing a metamodel with PLA, Resin, ABS materials creates 3 jobs.
586
916
 
587
917
  **Fields:**
588
918
 
589
- - `modelId` (string) [✓]: The unique identifier for the model.
919
+ - `modelId` (string) [✓]: UUID of the model that was processed.
590
920
 
591
- - `metadata` (object) [✓]: The enriched metadata for the model.
921
+ - `metadata` (object) [✓]: Enriched marketplace metadata generated by LLM.
592
922
 
593
923
 
594
924
 
595
925
  ### model-metadata-generation-request
596
926
 
597
- **Description:** Handles model metadata generation requests.
927
+ **Description:** 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).
598
928
 
599
929
  **Method:** `client.modelMetadataGenerationRequest(data)`
600
930
 
@@ -602,23 +932,17 @@ Example: Publishing a metamodel with PLA, Resin, ABS materials creates 3 jobs.
602
932
 
603
933
  **Fields:**
604
934
 
605
- - `modelId` (string) [✗]: The unique identifier for the model.
606
-
607
- - `storageConnectionId` (string) [✗]: The ID of the storage connection.
608
-
609
- - `filePath` (string) [✗]: The path to the model file.
610
-
611
- - `fileName` (string) [✗]: The name of the model file.
935
+ - `modelId` (string) [✗]: 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.
612
936
 
613
- - `fileSize` (number) [✗]: The size of the model file in bytes.
937
+ - `ownerId` (string) [✗]: UUID of the model owner. Used for authorization and audit logging.
614
938
 
615
- - `fileLastModified` (string) [✗]: The last modified date of the model file.
939
+ - `parentJobId` (string) [✗]: 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.
616
940
 
617
- - `storageProviderType` (string) [✗]: The type of the storage provider.
941
+ - `technicalMetadata` (object) [✗]: 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.
618
942
 
619
- - `modelThumbnailUrl` (string) [✗]: The URL of the model thumbnail.
943
+ - `thumbnailPath` (string) [✗]: 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.
620
944
 
621
- - `metamodel` (object) [✗]: The metamodel of the model.
945
+ - `enableVisionAnalysis` (boolean) [✗]: 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.
622
946
 
623
947
 
624
948
 
@@ -712,6 +1036,68 @@ Example: Publishing a metamodel with PLA, Resin, ABS materials creates 3 jobs.
712
1036
 
713
1037
 
714
1038
 
1039
+ ### model-semantic-analysis-completed
1040
+
1041
+ **Description:** Handles completion of 3D model semantic analysis with generated tags and similarity results.
1042
+
1043
+ **Method:** `client.modelSemanticAnalysisCompleted(data)`
1044
+
1045
+ **Payload Type:** `ModelSemanticAnalysisCompletedMessage`
1046
+
1047
+ **Fields:**
1048
+
1049
+ - `modelId` (string) [✗]: The unique identifier for the model.
1050
+
1051
+ - `userId` (string) [✗]: The user ID who owns the model.
1052
+
1053
+ - `processingStatus` (string) [✗]: Final processing status.
1054
+
1055
+ - `semanticMetadata` (object) [✗]: Generated semantic metadata and analysis results.
1056
+
1057
+ - `processingTime` (object) [✗]: Processing performance metrics.
1058
+
1059
+ - `qualityMetrics` (object) [✗]: Processing quality and confidence metrics.
1060
+
1061
+ - `error` (object) [✗]: Error information if processing failed.
1062
+
1063
+ - `debugInfo` (object) [✗]: Additional debug information for troubleshooting.
1064
+
1065
+
1066
+
1067
+ ### model-semantic-analysis-request
1068
+
1069
+ **Description:** Handles 3D model semantic analysis requests using ULIP-2 neural networks and FAISS vector similarity search.
1070
+
1071
+ **Method:** `client.modelSemanticAnalysisRequest(data)`
1072
+
1073
+ **Payload Type:** `ModelSemanticAnalysisRequestMessage`
1074
+
1075
+ **Fields:**
1076
+
1077
+ - `modelId` (string) [✗]: The unique identifier for the model.
1078
+
1079
+ - `userId` (string) [✗]: The user ID who owns the model.
1080
+
1081
+ - `storageConnectionId` (string) [✗]: The ID of the storage connection.
1082
+
1083
+ - `filePath` (string) [✗]: The path to the 3D model file in storage.
1084
+
1085
+ - `fileName` (string) [✗]: The name of the model file.
1086
+
1087
+ - `fileSize` (number) [✗]: The size of the model file in bytes.
1088
+
1089
+ - `storageProviderType` (string) [✗]: The type of the storage provider (S3, GoogleDrive, SFTP, etc).
1090
+
1091
+ - `processingOptions` (object) [✗]: Configuration options for semantic analysis.
1092
+
1093
+ - `priority` (number) [✗]: Processing priority (1=highest, 10=lowest).
1094
+
1095
+ - `webhookUrl` (string) [✗]: Optional webhook URL for completion notification.
1096
+
1097
+ - `retryCount` (number) [✗]: Current retry attempt number.
1098
+
1099
+
1100
+
715
1101
  ### model-technical-metadata-completed
716
1102
 
717
1103
  **Description:** Reports comprehensive results of technical metadata analysis including geometry, quality metrics, and print-readiness assessment
@@ -814,7 +1200,11 @@ Example: Publishing a metamodel with PLA, Resin, ABS materials creates 3 jobs.
814
1200
 
815
1201
  - `ownerId` (string) [✗]: User ID who owns the model
816
1202
 
817
- - `storageLocation` (object) [✗]: Location of the 3D model file
1203
+ - `storageLocation` (object) [✗]: Location of the 3D model file (legacy - used for direct download if minioPath not provided)
1204
+
1205
+ - `minioPath` (string) [✗]: 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.
1206
+
1207
+ - `parentJobId` (string) [✗]: ID of parent file-download job (for BullMQ dependency tracking).
818
1208
 
819
1209
  - `analysisOptions` (object) [✗]: Optional analysis configuration parameters
820
1210
 
@@ -846,7 +1236,7 @@ Example: Publishing a metamodel with PLA, Resin, ABS materials creates 3 jobs.
846
1236
 
847
1237
  ### thumbnail-generation-request
848
1238
 
849
- **Description:** Handles thumbnail generation requests with customization options.
1239
+ **Description:** Handles thumbnail generation requests with customization options. Supports both storage provider downloads and MinIO-cached files.
850
1240
 
851
1241
  **Method:** `client.thumbnailGenerationRequest(data)`
852
1242
 
@@ -858,14 +1248,193 @@ Example: Publishing a metamodel with PLA, Resin, ABS materials creates 3 jobs.
858
1248
 
859
1249
  - `ownerId` (string) [✗]: The identifier of the user who owns the entity.
860
1250
 
861
- - `storageLocation` (object) [✗]: The storage location of the model.
1251
+ - `storageLocation` (object) [✗]: The storage location of the model (legacy - used for direct download if minioPath not provided).
1252
+
1253
+ - `minioPath` (string) [✗]: 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.
862
1254
 
863
1255
  - `previewType` (string) [✗]: The type of preview to generate, e.g., 'default', 'static', 'glb'.
864
1256
 
1257
+ - `generate360Views` (boolean) [✗]: Generate 16 angle views for 360° preview (4 horizontal x 4 vertical angles).
1258
+
1259
+ - `parentJobId` (string) [✗]: ID of parent file-download job (for BullMQ dependency tracking).
1260
+
865
1261
  - `customization` (object) [✗]: User-defined customizations for the thumbnail.
866
1262
 
867
1263
 
868
1264
 
1265
+ ### user-engagement-event
1266
+
1267
+ **Description:** User engagement and onboarding tracking events for analytics and behavioral insights.
1268
+
1269
+ Captures key user actions throughout their journey:
1270
+ - Account creation and onboarding steps
1271
+ - Feature usage and adoption
1272
+ - Model management activities
1273
+ - Marketplace interactions
1274
+ - Subscription changes
1275
+
1276
+ Used for:
1277
+ - User onboarding funnel analysis
1278
+ - Feature adoption tracking
1279
+ - User retention metrics
1280
+ - A/B testing and experimentation
1281
+ - Personalization and recommendations
1282
+ - Product analytics dashboards
1283
+
1284
+
1285
+ **Method:** `client.userEngagementEvent(data)`
1286
+
1287
+ **Payload Type:** `UserEngagementEventMessage`
1288
+
1289
+ **Fields:**
1290
+
1291
+ - `eventType` (string) [✓]: Category of user engagement event
1292
+
1293
+ - `action` (string) [✓]: Specific user action performed
1294
+
1295
+ - `timestamp` (string) [✓]: ISO 8601 timestamp when the action occurred
1296
+
1297
+ - `userId` (string) [✓]: Unique identifier of the user
1298
+
1299
+ - `userEmail` (string) [✗]: User's email (hashed for privacy in analytics)
1300
+
1301
+ - `userCreatedAt` (string) [✗]: When the user account was created (for cohort analysis)
1302
+
1303
+ - `userPlanTier` (string) [✗]: Current subscription plan tier
1304
+
1305
+ - `sessionId` (string) [✗]: User session identifier for grouping actions
1306
+
1307
+ - `requestId` (string) [✗]: Request ID for correlation with logs
1308
+
1309
+ - `actionDetails` (object) [✗]: Additional context about the action
1310
+
1311
+ - `source` (string) [✗]: Where the action originated
1312
+
1313
+ - `httpMethod` (string) [✗]: HTTP method used
1314
+
1315
+ - `httpUrl` (string) [✗]: API endpoint path
1316
+
1317
+ - `httpStatusCode` (integer) [✗]: HTTP response status code
1318
+
1319
+ - `durationMs` (number) [✗]: Action duration in milliseconds
1320
+
1321
+ - `experimentId` (string) [✗]: A/B test or experiment ID
1322
+
1323
+ - `experimentVariant` (string) [✗]: Experiment variant/group
1324
+
1325
+ - `environment` (string) [✗]: Deployment environment
1326
+
1327
+ - `clientInfo` (object) [✗]: Client/browser information (anonymized)
1328
+
1329
+
1330
+
1331
+ ### worker-analytics-event
1332
+
1333
+ **Description:** Analytics event emitted by workers for tracking processing metrics, user behavior,
1334
+ and model statistics. Consumed by worker-analytic-collector and forwarded to ELK.
1335
+
1336
+ All workers MUST emit this event upon job completion (success or failure).
1337
+ Each worker includes its specific metrics in the `metrics` object.
1338
+
1339
+
1340
+ **Method:** `client.workerAnalyticsEvent(data)`
1341
+
1342
+ **Payload Type:** `WorkerAnalyticsEventMessage`
1343
+
1344
+ **Fields:**
1345
+
1346
+ - `eventType` (string) [✓]: Type of analytics event
1347
+
1348
+ - `workerId` (string) [✓]: Identifier of the worker that processed the job
1349
+
1350
+ - `jobId` (string) [✓]: Unique job identifier from BullMQ
1351
+
1352
+ - `timestamp` (string) [✓]: ISO 8601 timestamp of event emission
1353
+
1354
+ - `userId` (string) [✗]: User who owns the model/triggered the job
1355
+
1356
+ - `modelId` (string) [✗]: Model identifier (if applicable)
1357
+
1358
+ - `metamodelId` (string) [✗]: Metamodel identifier (if applicable)
1359
+
1360
+ - `storageItemId` (string) [✗]: Storage item identifier (for download events)
1361
+
1362
+ - `status` (string) [✗]: Job completion status
1363
+
1364
+ - `errorCode` (string) [✗]: Error code if status is failure
1365
+
1366
+ - `errorMessage` (string) [✗]: Error message if status is failure
1367
+
1368
+ - `timing` (object) [✗]: Processing time metrics in milliseconds
1369
+
1370
+ - `metrics` (object) [✗]: Worker-specific metrics. Structure varies by eventType.
1371
+
1372
+
1373
+
1374
+ ### worker-metrics-enriched-event
1375
+
1376
+ **Description:** Enriched metrics event for detailed worker monitoring, cost tracking,
1377
+ and performance analysis. Published to backend.logging.events for
1378
+ centralized monitoring and cost attribution.
1379
+
1380
+ This event is emitted by all workers on job completion and includes:
1381
+ - LLM token usage and cost breakdown
1382
+ - System resource consumption (CPU, RAM, disk I/O)
1383
+ - Detailed timing breakdown by stage
1384
+ - User and context attribution
1385
+ - Model-specific metadata
1386
+
1387
+
1388
+ **Method:** `client.workerMetricsEnrichedEvent(data)`
1389
+
1390
+ **Payload Type:** `WorkerMetricsEnrichedEventMessage`
1391
+
1392
+ **Fields:**
1393
+
1394
+ - `eventType` (string) [✓]: Fixed type for enriched worker metrics
1395
+
1396
+ - `workerId` (string) [✓]: Identifier of the worker
1397
+
1398
+ - `jobId` (string) [✓]: Unique BullMQ job identifier
1399
+
1400
+ - `timestamp` (string) [✓]: ISO 8601 timestamp when job completed
1401
+
1402
+ - `status` (string) [✓]: Job completion status
1403
+
1404
+ - `userId` (string) [✗]: User who owns the resource/triggered the job
1405
+
1406
+ - `tenantId` (string) [✗]: Organization/tenant ID (for multi-tenant deployments)
1407
+
1408
+ - `sessionId` (string) [✗]: Session ID for correlating user actions
1409
+
1410
+ - `requestId` (string) [✗]: Request ID from originating API call (X-Request-Id)
1411
+
1412
+ - `modelId` (string) [✗]: Model ID being processed
1413
+
1414
+ - `metamodelId` (string) [✗]: Metamodel ID being processed
1415
+
1416
+ - `storageItemId` (string) [✗]: Storage item ID (for file operations)
1417
+
1418
+ - `timing` (object) [✗]: Comprehensive timing breakdown
1419
+
1420
+ - `llmUsage` (object) [✗]: LLM token usage and cost breakdown
1421
+
1422
+ - `resources` (object) [✗]: System resource consumption during job
1423
+
1424
+ - `workerMetrics` (object) [✗]: Worker-specific metrics (varies by worker type)
1425
+
1426
+ - `error` (object) [✗]: Error details if status is failure
1427
+
1428
+ - `environment` (string) [✗]: Deployment environment
1429
+
1430
+ - `region` (string) [✗]: Cloud region/datacenter
1431
+
1432
+ - `workerVersion` (string) [✗]: Worker service version
1433
+
1434
+ - `hostname` (string) [✗]: Pod/container hostname
1435
+
1436
+
1437
+
869
1438
  ## Configuration
870
1439
 
871
1440
  ### Environment Variables
@@ -904,6 +1473,24 @@ new WorkerClient(config: WorkerClientConfig)
904
1473
  - Get the current status of a job
905
1474
 
906
1475
 
1476
+ - `backendLoggingEvent(data: BackendLoggingEventMessage): Promise<JobResponse>`
1477
+ - Centralized logging event for capturing all warn/error/failure logs from meshsync-backend.
1478
+ This event is sent to ELK for centralized monitoring, alerting, and debugging.
1479
+
1480
+ Automatically emitted by the custom Pino logger interceptor when:
1481
+ - logger.warn() is called
1482
+ - logger.error() is called
1483
+ - uncaught exceptions occur
1484
+ - request failures happen (4xx, 5xx responses)
1485
+
1486
+ Used for:
1487
+ - System health monitoring
1488
+ - Error tracking and alerting
1489
+ - Performance degradation detection
1490
+ - Security incident tracking
1491
+ - Compliance and audit trails
1492
+
1493
+
907
1494
  - `etsyAnalyticsSyncCompleted(data: EtsyAnalyticsSyncCompletedMessage): Promise<JobResponse>`
908
1495
  - Contains synced analytics data for Etsy listings. Backend stores this in etsy_analytics_snapshots table and indexes to ELK.
909
1496
 
@@ -927,7 +1514,7 @@ Example: Publishing a metamodel with PLA, Resin, ABS materials creates 3 jobs.
927
1514
  - Notifies that a file download has been processed, indicating success or failure.
928
1515
 
929
1516
  - `fileDownloadRequest(data: FileDownloadRequestMessage): Promise<JobResponse>`
930
- - Handles file download requests.
1517
+ - Downloads model file from storage provider to MinIO for processing pipeline. Acts as parent job for thumbnail generation, technical metadata analysis, and metadata generation.
931
1518
 
932
1519
  - `marketplaceAnalyticsSyncCompleted(data: MarketplaceAnalyticsSyncCompletedMessage): Promise<JobResponse>`
933
1520
  - Contains synced analytics data for marketplace listings. Backend stores this in marketplace_analytics_snapshots table and indexes to ELK. Works with any marketplace provider.
@@ -935,6 +1522,32 @@ Example: Publishing a metamodel with PLA, Resin, ABS materials creates 3 jobs.
935
1522
  - `marketplaceAnalyticsSyncRequest(data: MarketplaceAnalyticsSyncRequestMessage): Promise<JobResponse>`
936
1523
  - Syncs analytics data from marketplace API for one or more listings. Fetches views, favorites, sales, revenue, and traffic source data. Can sync: specific listings, all user listings, or shop-level analytics. Works with any marketplace provider that supports analytics (etsy, ebay, etc.).
937
1524
 
1525
+ - `marketplaceConnectionSyncCompleted(data: MarketplaceConnectionSyncCompletedMessage): Promise<JobResponse>`
1526
+ - Notification that marketplace connection sync has completed. Contains updated connection metadata, profile information, and sync statistics.
1527
+
1528
+
1529
+ - `marketplaceConnectionSyncRequest(data: MarketplaceConnectionSyncRequestMessage): Promise<JobResponse>`
1530
+ - 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
1531
+ This is typically triggered after initial connection or periodically to keep marketplace metadata up to date.
1532
+
1533
+
1534
+ - `marketplaceCredentialRotationCompleted(data: MarketplaceCredentialRotationCompletedMessage): Promise<JobResponse>`
1535
+ - Notification that marketplace credential rotation has completed. Contains the rotation results, new credential metadata, and any issues encountered.
1536
+
1537
+
1538
+ - `marketplaceCredentialRotationRequest(data: MarketplaceCredentialRotationRequestMessage): Promise<JobResponse>`
1539
+ - 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
1540
+
1541
+
1542
+ - `marketplaceListingSyncCompleted(data: MarketplaceListingSyncCompletedMessage): Promise<JobResponse>`
1543
+ - Notification that marketplace listing sync operation has completed. Contains detailed results of the sync including created/updated listings, errors encountered, and performance statistics.
1544
+
1545
+
1546
+ - `marketplaceListingSyncRequest(data: MarketplaceListingSyncRequestMessage): Promise<JobResponse>`
1547
+ - Requests synchronization of marketplace listings for a connection. Can sync specific listings or all listings for a marketplace connection.
1548
+ 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
1549
+
1550
+
938
1551
  - `marketplacePublishListingCompleted(data: MarketplacePublishListingCompletedMessage): Promise<JobResponse>`
939
1552
  - 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.).
940
1553
 
@@ -954,6 +1567,14 @@ Example: Publishing a metamodel with PLA, Resin, ABS materials creates 3 jobs.
954
1567
  - `metamodelMetadataGenerationRequest(data: MetamodelMetadataGenerationRequestMessage): Promise<JobResponse>`
955
1568
  - Handles metamodel metadata generation requests via Ollama. Aggregates data from constituent models and generates AI-enhanced metadata.
956
1569
 
1570
+ - `modelAnalyticsCollectionRequest(data: ModelAnalyticsCollectionRequestMessage): Promise<JobResponse>`
1571
+ - Request to collect marketplace analytics for a specific metamodel.
1572
+ Triggered by backend scheduler every 6 hours for popular/tagged metamodels.
1573
+
1574
+ Worker performs targeted market searches based on metamodel metadata
1575
+ and stores aggregated statistics in Elasticsearch for trend analysis.
1576
+
1577
+
957
1578
  - `modelDiscoveryFolderProcessedEvent(data: ModelDiscoveryFolderProcessedEventMessage): Promise<JobResponse>`
958
1579
  - Handles model discovery folder processed events.
959
1580
 
@@ -967,10 +1588,10 @@ Example: Publishing a metamodel with PLA, Resin, ABS materials creates 3 jobs.
967
1588
  - Handles model discovery scan requests events.
968
1589
 
969
1590
  - `modelMetadataGenerationCompleted(data: ModelMetadataGenerationCompletedMessage): Promise<JobResponse>`
970
- - Handles model metadata generation completed.
1591
+ - Notifies backend that enriched marketplace metadata generation completed. Backend updates Model entity with generated description, tags, classification, etc.
971
1592
 
972
1593
  - `modelMetadataGenerationRequest(data: ModelMetadataGenerationRequestMessage): Promise<JobResponse>`
973
- - Handles model metadata generation requests.
1594
+ - 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).
974
1595
 
975
1596
  - `modelMetamodelDetectionFound(data: ModelMetamodelDetectionFoundMessage): Promise<JobResponse>`
976
1597
  - Handles model metamodel detection found with hierarchical relationships.
@@ -984,6 +1605,12 @@ Example: Publishing a metamodel with PLA, Resin, ABS materials creates 3 jobs.
984
1605
  - `modelSellabilityAnalysisRequest(data: ModelSellabilityAnalysisRequestMessage): Promise<JobResponse>`
985
1606
  - Analyzes a metamodel to determine sellability score, pricing recommendations, and optimal marketplace selection. Enhanced with Etsy-specific analysis including competitor pricing, category demand trends, and material suitability.
986
1607
 
1608
+ - `modelSemanticAnalysisCompleted(data: ModelSemanticAnalysisCompletedMessage): Promise<JobResponse>`
1609
+ - Handles completion of 3D model semantic analysis with generated tags and similarity results.
1610
+
1611
+ - `modelSemanticAnalysisRequest(data: ModelSemanticAnalysisRequestMessage): Promise<JobResponse>`
1612
+ - Handles 3D model semantic analysis requests using ULIP-2 neural networks and FAISS vector similarity search.
1613
+
987
1614
  - `modelTechnicalMetadataCompleted(data: ModelTechnicalMetadataCompletedMessage): Promise<JobResponse>`
988
1615
  - Reports comprehensive results of technical metadata analysis including geometry, quality metrics, and print-readiness assessment
989
1616
 
@@ -994,7 +1621,47 @@ Example: Publishing a metamodel with PLA, Resin, ABS materials creates 3 jobs.
994
1621
  - Handles thumbnail generation completed.
995
1622
 
996
1623
  - `thumbnailGenerationRequest(data: ThumbnailGenerationRequestMessage): Promise<JobResponse>`
997
- - Handles thumbnail generation requests with customization options.
1624
+ - Handles thumbnail generation requests with customization options. Supports both storage provider downloads and MinIO-cached files.
1625
+
1626
+ - `userEngagementEvent(data: UserEngagementEventMessage): Promise<JobResponse>`
1627
+ - User engagement and onboarding tracking events for analytics and behavioral insights.
1628
+
1629
+ Captures key user actions throughout their journey:
1630
+ - Account creation and onboarding steps
1631
+ - Feature usage and adoption
1632
+ - Model management activities
1633
+ - Marketplace interactions
1634
+ - Subscription changes
1635
+
1636
+ Used for:
1637
+ - User onboarding funnel analysis
1638
+ - Feature adoption tracking
1639
+ - User retention metrics
1640
+ - A/B testing and experimentation
1641
+ - Personalization and recommendations
1642
+ - Product analytics dashboards
1643
+
1644
+
1645
+ - `workerAnalyticsEvent(data: WorkerAnalyticsEventMessage): Promise<JobResponse>`
1646
+ - Analytics event emitted by workers for tracking processing metrics, user behavior,
1647
+ and model statistics. Consumed by worker-analytic-collector and forwarded to ELK.
1648
+
1649
+ All workers MUST emit this event upon job completion (success or failure).
1650
+ Each worker includes its specific metrics in the `metrics` object.
1651
+
1652
+
1653
+ - `workerMetricsEnrichedEvent(data: WorkerMetricsEnrichedEventMessage): Promise<JobResponse>`
1654
+ - Enriched metrics event for detailed worker monitoring, cost tracking,
1655
+ and performance analysis. Published to backend.logging.events for
1656
+ centralized monitoring and cost attribution.
1657
+
1658
+ This event is emitted by all workers on job completion and includes:
1659
+ - LLM token usage and cost breakdown
1660
+ - System resource consumption (CPU, RAM, disk I/O)
1661
+ - Detailed timing breakdown by stage
1662
+ - User and context attribution
1663
+ - Model-specific metadata
1664
+
998
1665
 
999
1666
 
1000
1667
  ### Response Types