From 5fb89809b55545d731f2fdb7e97b6b32b1f043b3 Mon Sep 17 00:00:00 2001 From: Milena Czierlinski <146972016+Milena-Czierlinski@users.noreply.github.com> Date: Thu, 23 May 2024 18:30:17 +0200 Subject: [PATCH] Fix/SharedToPeerDVO without sourceAttribute (#134) * fix: make sourceAttribute of shared to peer dvo optional * chore: version bump * fix: condition for peer shared Attributes --- package-lock.json | 2 +- packages/runtime/package.json | 2 +- .../runtime/src/dataViews/DataViewExpander.ts | 19 +++++++++---------- .../consumption/LocalAttributeDVO.ts | 2 +- 4 files changed, 12 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index d81148900..9eb04a6d5 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12332,7 +12332,7 @@ }, "packages/runtime": { "name": "@nmshd/runtime", - "version": "4.8.0", + "version": "4.8.1", "license": "MIT", "dependencies": { "@js-soft/docdb-querytranslator": "^1.1.4", diff --git a/packages/runtime/package.json b/packages/runtime/package.json index e960d57bb..39750ee67 100644 --- a/packages/runtime/package.json +++ b/packages/runtime/package.json @@ -1,6 +1,6 @@ { "name": "@nmshd/runtime", - "version": "4.8.0", + "version": "4.8.1", "description": "The enmeshed client runtime.", "homepage": "https://enmeshed.eu", "repository": { diff --git a/packages/runtime/src/dataViews/DataViewExpander.ts b/packages/runtime/src/dataViews/DataViewExpander.ts index d90dc417b..0d1cc5184 100644 --- a/packages/runtime/src/dataViews/DataViewExpander.ts +++ b/packages/runtime/src/dataViews/DataViewExpander.ts @@ -1026,7 +1026,7 @@ export class DataViewExpander { } // Peer Relationship Attribute - if (relationshipAttribute.owner === localAttribute.shareInfo.peer) { + if (relationshipAttribute.owner.toString() === peer) { return { type: "PeerRelationshipAttributeDVO", id: attribute.id, @@ -1082,10 +1082,10 @@ export class DataViewExpander { } const identityAttribute = localAttribute.content; - if (localAttribute.shareInfo.sourceAttribute) { - // Own Shared Attribute + if (identityAttribute.owner.toString() === peer) { + // Peer Attribute return { - type: "SharedToPeerAttributeDVO", + type: "PeerAttributeDVO", id: attribute.id, name, description, @@ -1097,22 +1097,20 @@ export class DataViewExpander { valueHints, isValid: true, createdAt: attribute.createdAt, - isOwn: true, + isOwn: false, peer: peer, isDraft: false, requestReference: localAttribute.shareInfo.requestReference?.toString(), notificationReference: localAttribute.shareInfo.notificationReference?.toString(), - sourceAttribute: localAttribute.shareInfo.sourceAttribute.toString(), tags: identityAttribute.tags ? identityAttribute.tags : [], valueType, deletionStatus: localAttribute.deletionInfo?.deletionStatus, deletionDate: localAttribute.deletionInfo?.deletionDate.toString() }; } - - // Peer Attribute + // Own Shared Attribute return { - type: "PeerAttributeDVO", + type: "SharedToPeerAttributeDVO", id: attribute.id, name, description, @@ -1124,11 +1122,12 @@ export class DataViewExpander { valueHints, isValid: true, createdAt: attribute.createdAt, - isOwn: false, + isOwn: true, peer: peer, isDraft: false, requestReference: localAttribute.shareInfo.requestReference?.toString(), notificationReference: localAttribute.shareInfo.notificationReference?.toString(), + sourceAttribute: localAttribute.shareInfo.sourceAttribute?.toString(), tags: identityAttribute.tags ? identityAttribute.tags : [], valueType, deletionStatus: localAttribute.deletionInfo?.deletionStatus, diff --git a/packages/runtime/src/dataViews/consumption/LocalAttributeDVO.ts b/packages/runtime/src/dataViews/consumption/LocalAttributeDVO.ts index 460d58c2d..7ae825b18 100644 --- a/packages/runtime/src/dataViews/consumption/LocalAttributeDVO.ts +++ b/packages/runtime/src/dataViews/consumption/LocalAttributeDVO.ts @@ -44,7 +44,7 @@ export interface SharedToPeerAttributeDVO extends LocalAttributeDVO { peer: string; // Careful: We cannot expand the peer to an IdentityDVO, as the IdentityDVO possibly contains the LocalAttributesDVO of the Relationship (endless recursion) requestReference?: string; notificationReference?: string; - sourceAttribute: string; + sourceAttribute?: string; isOwn: true; tags: string[]; deletionDate?: string;