@mesh-sync/worker-backend-client 4.0.2 → 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
@@ -324,7 +324,7 @@ Example: Publishing a metamodel with PLA, Resin, ABS materials creates 3 jobs.
324
324
 
325
325
  - `modelId` (string) [✗]: The unique identifier for the model to be downloaded.
326
326
 
327
- - `ownerId` (string) [✗]: The identifier of the user who owns the model.
327
+ - `ownerId` (string) [✗]: The identifier of the user who owns the model. Optional - if not provided, will be retrieved from StorageConnection.
328
328
 
329
329
  - `storageLocation` (object) [✗]: The storage location of the model.
330
330
 
@@ -908,7 +908,7 @@ and stores aggregated statistics in Elasticsearch for trend analysis.
908
908
 
909
909
  ### model-metadata-generation-completed
910
910
 
911
- **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.
912
912
 
913
913
  **Method:** `client.modelMetadataGenerationCompleted(data)`
914
914
 
@@ -916,15 +916,15 @@ and stores aggregated statistics in Elasticsearch for trend analysis.
916
916
 
917
917
  **Fields:**
918
918
 
919
- - `modelId` (string) [✓]: The unique identifier for the model.
919
+ - `modelId` (string) [✓]: UUID of the model that was processed.
920
920
 
921
- - `metadata` (object) [✓]: The enriched metadata for the model.
921
+ - `metadata` (object) [✓]: Enriched marketplace metadata generated by LLM.
922
922
 
923
923
 
924
924
 
925
925
  ### model-metadata-generation-request
926
926
 
927
- **Description:** Handles model metadata generation requests. Supports both storage provider downloads and MinIO-cached files.
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).
928
928
 
929
929
  **Method:** `client.modelMetadataGenerationRequest(data)`
930
930
 
@@ -932,29 +932,17 @@ and stores aggregated statistics in Elasticsearch for trend analysis.
932
932
 
933
933
  **Fields:**
934
934
 
935
- - `modelId` (string) [✗]: The unique identifier for the model.
936
-
937
- - `ownerId` (string) [✗]: The identifier of the user who owns the model.
938
-
939
- - `storageConnectionId` (string) [✗]: The ID of the storage connection (legacy - used if minioPath not provided).
940
-
941
- - `filePath` (string) [✗]: The path to the model file (legacy - used if minioPath not provided).
942
-
943
- - `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.
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.
944
936
 
945
- - `fileName` (string) [✗]: The name of the model file.
946
-
947
- - `fileSize` (number) [✗]: The size of the model file in bytes.
937
+ - `ownerId` (string) [✗]: UUID of the model owner. Used for authorization and audit logging.
948
938
 
949
- - `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.
950
940
 
951
- - `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.
952
942
 
953
- - `parentJobId` (string) [✗]: ID of parent file-download job (for BullMQ dependency tracking).
954
-
955
- - `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.
956
944
 
957
- - `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.
958
946
 
959
947
 
960
948
 
@@ -1383,6 +1371,70 @@ Each worker includes its specific metrics in the `metrics` object.
1383
1371
 
1384
1372
 
1385
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
+
1386
1438
  ## Configuration
1387
1439
 
1388
1440
  ### Environment Variables
@@ -1536,10 +1588,10 @@ and stores aggregated statistics in Elasticsearch for trend analysis.
1536
1588
  - Handles model discovery scan requests events.
1537
1589
 
1538
1590
  - `modelMetadataGenerationCompleted(data: ModelMetadataGenerationCompletedMessage): Promise<JobResponse>`
1539
- - Handles model metadata generation completed.
1591
+ - Notifies backend that enriched marketplace metadata generation completed. Backend updates Model entity with generated description, tags, classification, etc.
1540
1592
 
1541
1593
  - `modelMetadataGenerationRequest(data: ModelMetadataGenerationRequestMessage): Promise<JobResponse>`
1542
- - Handles model metadata generation requests. Supports both storage provider downloads and MinIO-cached files.
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).
1543
1595
 
1544
1596
  - `modelMetamodelDetectionFound(data: ModelMetamodelDetectionFoundMessage): Promise<JobResponse>`
1545
1597
  - Handles model metamodel detection found with hierarchical relationships.
@@ -1598,6 +1650,19 @@ All workers MUST emit this event upon job completion (success or failure).
1598
1650
  Each worker includes its specific metrics in the `metrics` object.
1599
1651
 
1600
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
+
1665
+
1601
1666
 
1602
1667
  ### Response Types
1603
1668
 
package/dist/client.d.ts CHANGED
@@ -230,13 +230,13 @@ export declare class WorkerClient {
230
230
  */
231
231
  modelDiscoveryScanRequest(data: types.ModelDiscoveryScanRequestMessage): Promise<JobResponse>;
232
232
  /**
233
- * Handles model metadata generation completed.
233
+ * Notifies backend that enriched marketplace metadata generation completed. Backend updates Model entity with generated description, tags, classification, etc.
234
234
  * @param data - The message payload
235
235
  * @returns Job response with job ID
236
236
  */
237
237
  modelMetadataGenerationCompleted(data: types.ModelMetadataGenerationCompletedMessage): Promise<JobResponse>;
238
238
  /**
239
- * Handles model metadata generation requests. Supports both storage provider downloads and MinIO-cached files.
239
+ * 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).
240
240
  * @param data - The message payload
241
241
  * @returns Job response with job ID
242
242
  */
@@ -334,4 +334,20 @@ export declare class WorkerClient {
334
334
  * @returns Job response with job ID
335
335
  */
336
336
  workerAnalyticsEvent(data: types.WorkerAnalyticsEventMessage): Promise<JobResponse>;
337
+ /**
338
+ * Enriched metrics event for detailed worker monitoring, cost tracking,
339
+ and performance analysis. Published to backend.logging.events for
340
+ centralized monitoring and cost attribution.
341
+
342
+ This event is emitted by all workers on job completion and includes:
343
+ - LLM token usage and cost breakdown
344
+ - System resource consumption (CPU, RAM, disk I/O)
345
+ - Detailed timing breakdown by stage
346
+ - User and context attribution
347
+ - Model-specific metadata
348
+
349
+ * @param data - The message payload
350
+ * @returns Job response with job ID
351
+ */
352
+ workerMetricsEnrichedEvent(data: types.WorkerMetricsEnrichedEventMessage): Promise<JobResponse>;
337
353
  }
package/dist/client.js CHANGED
@@ -305,7 +305,7 @@ export class WorkerClient {
305
305
  return this.sendToQueue(types.MessageTypes.MODEL_DISCOVERY_SCAN_REQUEST, data);
306
306
  }
307
307
  /**
308
- * Handles model metadata generation completed.
308
+ * Notifies backend that enriched marketplace metadata generation completed. Backend updates Model entity with generated description, tags, classification, etc.
309
309
  * @param data - The message payload
310
310
  * @returns Job response with job ID
311
311
  */
@@ -313,7 +313,7 @@ export class WorkerClient {
313
313
  return this.sendToQueue(types.MessageTypes.MODEL_METADATA_GENERATION_COMPLETED, data);
314
314
  }
315
315
  /**
316
- * Handles model metadata generation requests. Supports both storage provider downloads and MinIO-cached files.
316
+ * 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).
317
317
  * @param data - The message payload
318
318
  * @returns Job response with job ID
319
319
  */
@@ -437,4 +437,22 @@ export class WorkerClient {
437
437
  async workerAnalyticsEvent(data) {
438
438
  return this.sendToQueue(types.MessageTypes.WORKER_ANALYTICS_EVENT, data);
439
439
  }
440
+ /**
441
+ * Enriched metrics event for detailed worker monitoring, cost tracking,
442
+ and performance analysis. Published to backend.logging.events for
443
+ centralized monitoring and cost attribution.
444
+
445
+ This event is emitted by all workers on job completion and includes:
446
+ - LLM token usage and cost breakdown
447
+ - System resource consumption (CPU, RAM, disk I/O)
448
+ - Detailed timing breakdown by stage
449
+ - User and context attribution
450
+ - Model-specific metadata
451
+
452
+ * @param data - The message payload
453
+ * @returns Job response with job ID
454
+ */
455
+ async workerMetricsEnrichedEvent(data) {
456
+ return this.sendToQueue(types.MessageTypes.WORKER_METRICS_ENRICHED_EVENT, data);
457
+ }
440
458
  }
package/dist/types.d.ts CHANGED
@@ -42,6 +42,7 @@ export declare const MessageTypes: {
42
42
  readonly THUMBNAIL_GENERATION_REQUEST: "thumbnail-generation-request";
43
43
  readonly USER_ENGAGEMENT_EVENT: "user-engagement-event";
44
44
  readonly WORKER_ANALYTICS_EVENT: "worker-analytics-event";
45
+ readonly WORKER_METRICS_ENRICHED_EVENT: "worker-metrics-enriched-event";
45
46
  };
46
47
  export type MessageType = typeof MessageTypes[keyof typeof MessageTypes];
47
48
  /**
@@ -220,7 +221,7 @@ export interface FileDownloadCompletedMessage {
220
221
  export interface FileDownloadRequestMessage {
221
222
  /** The unique identifier for the model to be downloaded. */
222
223
  modelId?: string;
223
- /** The identifier of the user who owns the model. */
224
+ /** The identifier of the user who owns the model. Optional - if not provided, will be retrieved from StorageConnection. */
224
225
  ownerId?: string;
225
226
  /** The storage location of the model. */
226
227
  storageLocation?: Record<string, string | number | boolean>;
@@ -669,42 +670,30 @@ export interface ModelDiscoveryScanRequestMessage {
669
670
  path?: string;
670
671
  }
671
672
  /**
672
- * Handles model metadata generation completed.
673
+ * Notifies backend that enriched marketplace metadata generation completed. Backend updates Model entity with generated description, tags, classification, etc.
673
674
  */
674
675
  export interface ModelMetadataGenerationCompletedMessage {
675
- /** The unique identifier for the model. */
676
+ /** UUID of the model that was processed. */
676
677
  modelId: string;
677
- /** The enriched metadata for the model. */
678
+ /** Enriched marketplace metadata generated by LLM. */
678
679
  metadata: Record<string, string | number | boolean>;
679
680
  }
680
681
  /**
681
- * Handles model metadata generation requests. Supports both storage provider downloads and MinIO-cached files.
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).
682
683
  */
683
684
  export interface ModelMetadataGenerationRequestMessage {
684
- /** 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. */
685
686
  modelId?: string;
686
- /** The identifier of the user who owns the model. */
687
+ /** UUID of the model owner. Used for authorization and audit logging. */
687
688
  ownerId?: string;
688
- /** The ID of the storage connection (legacy - used if minioPath not provided). */
689
- storageConnectionId?: string;
690
- /** The path to the model file (legacy - used if minioPath not provided). */
691
- filePath?: string;
692
- /** 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. */
693
- minioPath?: string;
694
- /** The name of the model file. */
695
- fileName?: string;
696
- /** The size of the model file in bytes. */
697
- fileSize?: number;
698
- /** The last modified date of the model file. */
699
- fileLastModified?: string;
700
- /** The type of the storage provider. */
701
- storageProviderType?: string;
702
- /** ID of parent file-download job (for BullMQ dependency tracking). */
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. */
703
690
  parentJobId?: string;
704
- /** The URL of the model thumbnail. */
705
- modelThumbnailUrl?: string;
706
- /** The metamodel of the model. */
707
- metamodel?: Record<string, string | number | boolean>;
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;
708
697
  }
709
698
  /**
710
699
  * Handles model metamodel detection found with hierarchical relationships.
@@ -1047,3 +1036,60 @@ export interface WorkerAnalyticsEventMessage {
1047
1036
  /** Worker-specific metrics. Structure varies by eventType. */
1048
1037
  metrics?: Record<string, string | number | boolean>;
1049
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
+ }
package/dist/types.js CHANGED
@@ -43,4 +43,5 @@ export const MessageTypes = {
43
43
  THUMBNAIL_GENERATION_REQUEST: 'thumbnail-generation-request',
44
44
  USER_ENGAGEMENT_EVENT: 'user-engagement-event',
45
45
  WORKER_ANALYTICS_EVENT: 'worker-analytics-event',
46
+ WORKER_METRICS_ENRICHED_EVENT: 'worker-metrics-enriched-event',
46
47
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mesh-sync/worker-backend-client",
3
- "version": "4.0.2",
3
+ "version": "4.0.3",
4
4
  "description": "Auto-generated TypeScript client for worker-backend - provides type-safe methods for enqueueing jobs",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",