Skip to content

Commit af98434

Browse files
Milena-Czierlinskijkoenig134mergify[bot]sebbi08
authored
Feature/Attribute deletion (#42)
* chore: bump libs * chore: remove any cast * feat: add deletionInfo to LocalAttribute (#40) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Feature/Add deletion of child attributes (#43) * feat: add deletion of child attributes * chore: make deleteChildAttributesOfComplexAttribute private --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * refactor: getVersionsOfAttribute (#44) * Chore/Adjust to deletionInfo (#45) * feat: add deletionInfo to GetAttributesQuery * feat: add checks regarding deletionInfo * feat: add validation to succession for attributes with deletionInfo * feat: add queries to Get...Attributes UseCases * feat: move deletionInfo validation to setter * feat: extent error message of cannotSucceedAttributesWithDeletionInfo * feat: add type guards * Feature/Deletion of own shared Attributes (#47) * feat: add OwnSharedAttributeDeletedByOwnerEvent * feat: add OwnSharedAttributeDeletedByOwnerNotificationItemProcessor * test: DeleteOwnSharedAttributeAndNotifyPeer * chore: adjust to renamed deletionInfo * feat: add DeleteOwnSharedAttributeAndNotifyPeer UseCase * feat: use setDeletionInfo * chore: clean up * feat: add attributeDeleted folder * feat: integrate comments --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * fix: delete during merge incorrectly re-added attributes-e2e.test * chore: add deletionInfo to DataViewExpander (#60) Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Feature/Deletion of peer shared attributes (#36) * feat: add DeletePeerSharedAttribute Usecase * feat: add AttributeDeletedNotificationItem * feat: add AttributeDeletedNotificationItemProcessor * feat: add AttributeDeletedByPeerEvent * feat: add LocalAttributeDeletionStatus * feat: add LocalAttributeDeletionStatus * test: DeletePeerSharedAttribute * fix: errors while testing * test: AttributeDeletedNotificationItemProcessor * fix: add deletionStatus to AttributeMapper, adjust LocalAttributeDVO, adjust LocalAttributeDeletionStatus * fix: add files * chore: bump version * chore: undo version bump * chore: package-lock * fix: improve comparison of deletedByPeer value * chore: mark parameter notification as unused * refactor: renaming * feat: use enum in deletion status * feat: don't throw if attribute id is unknown * fix: rename runtime event * feat: adjust deletionStatus parameters in DVO * feat: delete child attributes of complex attribute * feat: implement comments * refactor: rename DeletionStatus to DeletionInfo * feat: add deletionInfo to GetAttributesQuery * feat: add checks regarding deletionInfo * feat: add validation to succession for attributes with deletionInfo * feat: add queries to Get...Attributes UseCases * feat: move deletionInfo validation to setter * feat: extent error message of cannotSucceedAttributesWithDeletionInfo * feat: add type guards * feat: add attributeDeleted folder * feat: clean up and delete predecessors * fix: remove unused variable * chore: trace if event was fired but assertion function was not matched * chore: try larger timeout * chore: log all events on timeout * chore: log all events on timeout * chore: log all events on timeout * chore: more logs and resets * chore: more logs and resets * chore: more logs * chore: run only one failing test * chore: run only one failing test * chore: use runtime event instead of consution * chore: remove console log and test code * chore: remove unneeded reset * chore: remove wrong delay * chore: remove unused injection of NotificationsController * feat: integrate comments * chore: build schemas --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Sebastian Mahr <[email protected]> * Feature/Add DeleteAttributeRequestItem and corresponding processor (#48) * fix: use error invalidAcceptParameters in canAccept * feat: add DeleteAttributeRequestItemProcessor * chore: clean up * feat: use setDeletionInfo * feat: set deletionInfo of predecessors * fix: adjust expected error codes to changes * fix: remove unnecessary awaits * feat: integrate comments * feat: integrate comments * feat: add XJSON type to from-method of Request- and ResponseItems * feat: add JSONs to from-method in RequestItems --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * fix: remove succeeds property of successors if predecessor was deleted (#70) * Feature/Deletion of RepositoryAttributes (#57) * feat: add DeleteRepositoryAttributeUseCase * feat: add functions to get shared predecessors/successors * fix: runtime tests and adjust DeleteRepositoryAttributeUseCase * feat: remove check for sourceAttribute for own shared identity attributes * test: DeleteRepositoryAttributeUseCase * feat: adjust validation of ownSharedIdentityAttributeSuccession to missing source attributes * test: adjusted validateOwnSharedIdentityAttributeSuccession * feat: adjust succeededBy property of successor if predecessor is deleted * feat: validate that successor source attribute exists * chore: clean up * feat: integrate comments * feat: integrate comments * fix: adjust expected error * refactor: reassign query * feat: delete succeeds field of shared copy successors * fix: undo last commit * feat: throw unexpected error instead of returning it * feat: extend error description for user * fix: move test to correct location * feat: throw errors without code * fix: delete duplicated test * feat: validate first, put logic in AttributesController * feat: sort shared versions of attribute by peer * refactor: use expect.arrayContaining in tests * refactor: don't use abbreviations in tests * refactor: use empty object as default query * refactor: omit helper variable * refactor: rename deleteRepositoryAttribute --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * fix: add deletionInfo to technicalProperties of LocalAttribute (#79) * Feature/Return AcceptResponseItem if attribute to delete doesn't exit (#93) * feat: return AcceptResponseItem if attribute to delete doesn't exit * feat: allow arbitrary deletionDate if attribute was already deleted --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Feature/Detach ThirdPartyRelationshipAttributes (#99) * feat: detach ThirdPartyRelationshipAttributes * test: detached ThirdPartyRelationshipAttributes * feat: adjust description of helper --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Feature/Add DeleteAttributeRequestItemDVO (#97) * feature: add deleteAttributeRequestItemDVO * fix: allow multiple request status options (for also slower dbs) * fix: correct dvo names * fix: check if list contains result * feat: overwrite isDecidable of DecidableRequestItemDVO --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> * Feature/Delete third party owned RelationshipAttribute use case (#100) * feat: add DeleteThirdPartyOwnedRelationshipAttributeUseCase * feat: add ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItemProcessor * feat: integrate comments * refactor: rename variable * feat: adjust checks for flavor of LocalAttribute * chore: bump version * Feature/Add response types for deletion use cases with notifications (#105) * chore: bump version * feat: integrate comments * fix: deletionInfo setter and add custom validator --------- Co-authored-by: Julian König <[email protected]> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: Sebastian Mahr <[email protected]>
1 parent 658ddd9 commit af98434

File tree

85 files changed

+4870
-280
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+4870
-280
lines changed

package-lock.json

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/consumption/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@nmshd/consumption",
3-
"version": "3.9.7",
3+
"version": "3.10.0",
44
"description": "The consumption library extends the transport library.",
55
"homepage": "https://enmeshed.eu",
66
"repository": {

packages/consumption/src/consumption/ConsumptionController.ts

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,23 @@ import {
22
AuthenticationRequestItem,
33
ConsentRequestItem,
44
CreateAttributeRequestItem,
5+
DeleteAttributeRequestItem,
56
FreeTextRequestItem,
7+
OwnSharedAttributeDeletedByOwnerNotificationItem,
8+
PeerSharedAttributeDeletedByPeerNotificationItem,
69
PeerSharedAttributeSucceededNotificationItem,
710
ProposeAttributeRequestItem,
811
ReadAttributeRequestItem,
912
RegisterAttributeListenerRequestItem,
10-
ShareAttributeRequestItem
13+
ShareAttributeRequestItem,
14+
ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItem
1115
} from "@nmshd/content";
1216
import { AccountController, Transport } from "@nmshd/transport";
1317
import {
1418
AttributeListenersController,
1519
AttributesController,
1620
CreateAttributeRequestItemProcessor,
21+
DeleteAttributeRequestItemProcessor,
1722
DraftsController,
1823
FreeTextRequestItemProcessor,
1924
GenericRequestItemProcessor,
@@ -23,6 +28,8 @@ import {
2328
NotificationItemProcessorRegistry,
2429
NotificationsController,
2530
OutgoingRequestsController,
31+
OwnSharedAttributeDeletedByOwnerNotificationItemProcessor,
32+
PeerSharedAttributeDeletedByPeerNotificationItemProcessor,
2633
PeerSharedAttributeSucceededNotificationItemProcessor,
2734
ProposeAttributeRequestItemProcessor,
2835
ReadAttributeRequestItemProcessor,
@@ -31,7 +38,8 @@ import {
3138
RequestItemProcessorConstructor,
3239
RequestItemProcessorRegistry,
3340
SettingsController,
34-
ShareAttributeRequestItemProcessor
41+
ShareAttributeRequestItemProcessor,
42+
ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItemProcessor
3543
} from "../modules";
3644

3745
export class ConsumptionController {
@@ -127,6 +135,7 @@ export class ConsumptionController {
127135
return new Map<RequestItemConstructor, RequestItemProcessorConstructor>([
128136
[ShareAttributeRequestItem, ShareAttributeRequestItemProcessor],
129137
[CreateAttributeRequestItem, CreateAttributeRequestItemProcessor],
138+
[DeleteAttributeRequestItem, DeleteAttributeRequestItemProcessor],
130139
[ReadAttributeRequestItem, ReadAttributeRequestItemProcessor],
131140
[ProposeAttributeRequestItem, ProposeAttributeRequestItemProcessor],
132141
[ConsentRequestItem, GenericRequestItemProcessor],
@@ -138,7 +147,10 @@ export class ConsumptionController {
138147

139148
private getDefaultNotificationItemProcessors() {
140149
return new Map<NotificationItemConstructor, NotificationItemProcessorConstructor>([
141-
[PeerSharedAttributeSucceededNotificationItem, PeerSharedAttributeSucceededNotificationItemProcessor]
150+
[PeerSharedAttributeSucceededNotificationItem, PeerSharedAttributeSucceededNotificationItemProcessor],
151+
[OwnSharedAttributeDeletedByOwnerNotificationItem, OwnSharedAttributeDeletedByOwnerNotificationItemProcessor],
152+
[PeerSharedAttributeDeletedByPeerNotificationItem, PeerSharedAttributeDeletedByPeerNotificationItemProcessor],
153+
[ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItem, ThirdPartyOwnedRelationshipAttributeDeletedByPeerNotificationItemProcessor]
142154
]);
143155
}
144156
}

packages/consumption/src/consumption/CoreErrors.ts

Lines changed: 86 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { ApplicationError } from "@js-soft/ts-utils";
2-
import { CoreError, CoreId } from "@nmshd/transport";
2+
import { CoreAddress, CoreError, CoreId } from "@nmshd/transport";
33

44
class Attributes {
55
public successorIsNotAValidAttribute(error: any) {
@@ -38,10 +38,17 @@ class Attributes {
3838
);
3939
}
4040

41-
public sourceContentIsNotEqualToCopyContent() {
41+
public predecessorSourceContentIsNotEqualToCopyContent() {
4242
return new CoreError(
43-
"error.consumption.attributes.sourceContentIsNotEqualToCopyContent",
44-
"Successor source attribute contents don't match successor shared attribute copy."
43+
"error.consumption.attributes.predecessorSourceContentIsNotEqualToCopyContent",
44+
"Predecessor source attribute content doesn't match predecessor shared attribute copy."
45+
);
46+
}
47+
48+
public successorSourceContentIsNotEqualToCopyContent() {
49+
return new CoreError(
50+
"error.consumption.attributes.successorSourceContentIsNotEqualToCopyContent",
51+
"Successor source attribute content doesn't match successor shared attribute copy."
4552
);
4653
}
4754

@@ -116,6 +123,18 @@ class Attributes {
116123
return new CoreError("error.consumption.attributes.predecessorDoesNotExist", "The predecessor does not exist.");
117124
}
118125

126+
public successorDoesNotExist() {
127+
return new CoreError("error.consumption.attributes.successorDoesNotExist", "The successor does not exist.");
128+
}
129+
130+
public successorSourceAttributeIsNotSpecified() {
131+
return new CoreError("error.consumption.attributes.successorSourceAttributeIsNotSpecified", "You must specify the source attribute of the successor.");
132+
}
133+
134+
public successorSourceAttributeDoesNotExist() {
135+
return new CoreError("error.consumption.attributes.successorSourceAttributeDoesNotExist", "The successor source Attribute does not exist.");
136+
}
137+
119138
public successionMustNotChangeOwner() {
120139
return new CoreError(
121140
"error.consumption.attributes.successionMustNotChangeOwner",
@@ -154,9 +173,70 @@ class Attributes {
154173
return new CoreError("error.consumption.attributes.invalidParentSuccessor", `The complex parent successor (id: ${parentSuccessorId}) does not exist.`);
155174
}
156175

176+
public cannotSucceedAttributesWithDeletionInfo() {
177+
return new CoreError(
178+
"error.consumption.attributes.cannotSucceedAttributesWithDeletionInfo",
179+
"You cannot succeed attributes with a deletionInfo, since the peer may have already deleted it or marked it for deletion."
180+
);
181+
}
182+
183+
public cannotSetDeletionInfoOfRepositoryAttributes() {
184+
return new CoreError(
185+
"error.consumption.attributes.cannotSetDeletionInfoOfRepositoryAttributes",
186+
"RepositoryAttributes can not have a deletionInfo, since they are not shared with a peer and you can delete them directly."
187+
);
188+
}
189+
190+
public invalidDeletionInfoOfOwnSharedAttribute() {
191+
return new CoreError(
192+
"error.consumption.attributes.invalidDeletionInfoOfOwnSharedAttribute",
193+
"The only valid deletionStatuses for own shared Attributes are 'DeletedByPeer' or 'ToBeDeletedByPeer'."
194+
);
195+
}
196+
197+
public invalidDeletionInfoOfPeerSharedAttribute() {
198+
return new CoreError(
199+
"error.consumption.attributes.invalidDeletionInfoOfPeerSharedAttribute",
200+
"The only valid deletionStatuses for peer shared Attributes are 'DeletedByOwner' or 'ToBeDeleted'."
201+
);
202+
}
203+
204+
public invalidDeletionInfoOfThirdPartyOwnedRelationshipAttribute() {
205+
return new CoreError(
206+
"error.consumption.attributes.invalidDeletionInfoOfThirdPartyOwnedRelationshipAttribute",
207+
"The only valid deletionStatus for third party owned RelationshipAttributes is 'DeletedByPeer'."
208+
);
209+
}
210+
157211
public invalidPropertyValue(message: string) {
158212
return new CoreError("error.consumption.attributes.invalidPropertyValue", message);
159213
}
214+
215+
public isNotSharedAttribute(attributeId: string | CoreId) {
216+
return new CoreError("error.consumption.attributes.isNotSharedAttribute", `The attribute (id: ${attributeId}) is not a shared attribute.`);
217+
}
218+
219+
public isNotOwnSharedAttribute(attributeId: string | CoreId) {
220+
return new CoreError("error.consumption.attributes.isNotOwnSharedAttribute", `The attribute (id: ${attributeId}) is not an own shared attribute.`);
221+
}
222+
223+
public isNotPeerSharedAttribute(attributeId: string | CoreId) {
224+
return new CoreError("error.consumption.attributes.isNotPeerSharedAttribute", `The attribute (id: ${attributeId}) is not a peer shared attribute.`);
225+
}
226+
227+
public isNotThirdPartyOwnedRelationshipAttribute(attributeId: string | CoreId) {
228+
return new CoreError(
229+
"error.consumption.attributes.isNotThirdPartyOwnedRelationshipAttribute",
230+
`The attribute (id: ${attributeId}) is not a third party owned RelationshipAttribute.`
231+
);
232+
}
233+
234+
public senderIsNotPeerOfSharedAttribute(senderId: string | CoreAddress, attributeId: string | CoreId) {
235+
return new CoreError(
236+
"error.consumption.attributes.senderIsNotPeerOfSharedAttribute",
237+
`The sender (id: ${senderId}) is not the peer you shared the attribute (id: ${attributeId}) with.`
238+
);
239+
}
160240
}
161241

162242
class Requests {
@@ -180,8 +260,8 @@ class Requests {
180260
);
181261
}
182262

183-
public invalidAcceptParameters(): ApplicationError {
184-
return new ApplicationError("error.consumption.requests.canAccept.invalidAcceptParameters", "The RequestItem was answered with incorrect parameters.");
263+
public invalidAcceptParameters(message: string): ApplicationError {
264+
return new ApplicationError("error.consumption.requests.invalidAcceptParameters", message);
185265
}
186266

187267
public invalidRequestItem(message: string) {

0 commit comments

Comments
 (0)