@yuuvis/client-core 2.3.31 → 2.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1360,10 +1360,28 @@ class SystemService {
1360
1360
  getRelationship(id, withLabel) {
1361
1361
  const relationship = this.system.relationships.find((r) => r.id === id);
1362
1362
  if (relationship && withLabel) {
1363
- relationship.label = this.getLocalizedResource(`${relationship.id}_label`) || relationship.id;
1363
+ relationship.label = this.getLocalizedLabel(relationship.id) || relationship.id;
1364
1364
  }
1365
1365
  return relationship;
1366
1366
  }
1367
+ /**
1368
+ * Get supported relationships for a given dms object
1369
+ * @param dmsObject DmsObject to get supported relationships for
1370
+ */
1371
+ getSupportedRelationships(dmsObject, withLabel) {
1372
+ // supported relationships are those where the given object's type (or one of its SOTs)
1373
+ // is the allowed source type of the relationship
1374
+ return (this.system?.relationships || [])
1375
+ .filter((rel) => {
1376
+ // check if the allowed source types include the object's type
1377
+ const supportsType = rel.allowedSourceTypes.includes(dmsObject.objectTypeId);
1378
+ // check if the allowed source types include one of the objects SOTs
1379
+ const sots = dmsObject.data[BaseObjectTypeField.SECONDARY_OBJECT_TYPE_IDS] || [];
1380
+ const supportsSOT = sots.some((sotId) => rel.allowedSourceTypes.includes(sotId));
1381
+ return supportsType || supportsSOT;
1382
+ })
1383
+ .map((rel) => (withLabel ? { ...rel, label: this.getLocalizedLabel(rel.id) || rel.id } : rel));
1384
+ }
1367
1385
  /**
1368
1386
  * Get the base document type all documents belong to
1369
1387
  * @param withLabel Whether or not to also add the types label
@@ -2297,6 +2315,8 @@ var YuvEventType;
2297
2315
  YuvEventType["DMS_OBJECT_UPDATED"] = "yuv.dms.object.updated";
2298
2316
  YuvEventType["DMS_OBJECT_CONTENT_UPDATED"] = "yuv.dms.object.content.updated";
2299
2317
  YuvEventType["DMS_OBJECTS_MOVED"] = "yuv.dms.objects.moved";
2318
+ YuvEventType["RELATIONSHIP_CREATED"] = "yuv.dms.relationship.created";
2319
+ YuvEventType["RELATIONSHIP_DELETED"] = "yuv.dms.relationship.deleted";
2300
2320
  })(YuvEventType || (YuvEventType = {}));
2301
2321
 
2302
2322
  /**