@nmshd/consumption 3.4.3 → 3.5.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.
- package/dist/buildInformation.js +4 -4
- package/dist/consumption/CoreErrors.d.ts +14 -1
- package/dist/consumption/CoreErrors.js +56 -2
- package/dist/consumption/CoreErrors.js.map +1 -1
- package/dist/modules/attributes/AttributesController.d.ts +37 -6
- package/dist/modules/attributes/AttributesController.js +351 -45
- package/dist/modules/attributes/AttributesController.js.map +1 -1
- package/dist/modules/attributes/events/AttributeSucceededEventData.d.ts +5 -0
- package/dist/modules/attributes/events/AttributeSucceededEventData.js +3 -0
- package/dist/modules/attributes/events/AttributeSucceededEventData.js.map +1 -0
- package/dist/modules/attributes/events/OwnSharedAttributeSucceededEvent.d.ts +7 -0
- package/dist/modules/attributes/events/OwnSharedAttributeSucceededEvent.js +12 -0
- package/dist/modules/attributes/events/OwnSharedAttributeSucceededEvent.js.map +1 -0
- package/dist/modules/attributes/events/PeerSharedAttributeSucceededEvent.d.ts +7 -0
- package/dist/modules/attributes/events/PeerSharedAttributeSucceededEvent.js +12 -0
- package/dist/modules/attributes/events/PeerSharedAttributeSucceededEvent.js.map +1 -0
- package/dist/modules/attributes/events/RepositoryAttributeSucceededEvent.d.ts +7 -0
- package/dist/modules/attributes/events/RepositoryAttributeSucceededEvent.js +12 -0
- package/dist/modules/attributes/events/RepositoryAttributeSucceededEvent.js.map +1 -0
- package/dist/modules/attributes/events/index.d.ts +4 -1
- package/dist/modules/attributes/events/index.js +4 -1
- package/dist/modules/attributes/events/index.js.map +1 -1
- package/dist/modules/attributes/index.d.ts +1 -2
- package/dist/modules/attributes/index.js +1 -2
- package/dist/modules/attributes/index.js.map +1 -1
- package/dist/modules/attributes/local/CreateLocalAttributeParams.d.ts +12 -1
- package/dist/modules/attributes/local/CreateLocalAttributeParams.js +18 -2
- package/dist/modules/attributes/local/CreateLocalAttributeParams.js.map +1 -1
- package/dist/modules/attributes/local/IAttributeSuccessorParams.d.ts +6 -0
- package/dist/modules/attributes/local/IAttributeSuccessorParams.js +3 -0
- package/dist/modules/attributes/local/IAttributeSuccessorParams.js.map +1 -0
- package/dist/modules/attributes/local/LocalAttribute.d.ts +51 -11
- package/dist/modules/attributes/local/LocalAttribute.js +45 -11
- package/dist/modules/attributes/local/LocalAttribute.js.map +1 -1
- package/dist/modules/attributes/local/LocalAttributeShareInfo.d.ts +16 -7
- package/dist/modules/attributes/local/LocalAttributeShareInfo.js +21 -2
- package/dist/modules/attributes/local/LocalAttributeShareInfo.js.map +1 -1
- package/dist/modules/common/ValidationResult.js.map +1 -0
- package/dist/modules/common/index.d.ts +1 -0
- package/dist/modules/common/index.js +18 -0
- package/dist/modules/common/index.js.map +1 -0
- package/dist/modules/index.d.ts +1 -0
- package/dist/modules/index.js +1 -0
- package/dist/modules/index.js.map +1 -1
- package/dist/modules/notifications/NotificationsController.js +4 -5
- package/dist/modules/notifications/NotificationsController.js.map +1 -1
- package/dist/modules/notifications/itemProcessors/AbstractNotificationItemProcessor.d.ts +19 -12
- package/dist/modules/notifications/itemProcessors/AbstractNotificationItemProcessor.js.map +1 -1
- package/dist/modules/notifications/itemProcessors/attributeSucceeded/AttributeSucceededNotificationItemProcessor.d.ts +10 -4
- package/dist/modules/notifications/itemProcessors/attributeSucceeded/AttributeSucceededNotificationItemProcessor.js +67 -7
- package/dist/modules/notifications/itemProcessors/attributeSucceeded/AttributeSucceededNotificationItemProcessor.js.map +1 -1
- package/dist/modules/requests/incoming/DecideRequestParametersValidator.d.ts +1 -1
- package/dist/modules/requests/incoming/DecideRequestParametersValidator.js +1 -1
- package/dist/modules/requests/incoming/DecideRequestParametersValidator.js.map +1 -1
- package/dist/modules/requests/incoming/IncomingRequestsController.d.ts +1 -1
- package/dist/modules/requests/incoming/IncomingRequestsController.js +1 -1
- package/dist/modules/requests/incoming/IncomingRequestsController.js.map +1 -1
- package/dist/modules/requests/index.d.ts +0 -1
- package/dist/modules/requests/index.js +0 -1
- package/dist/modules/requests/index.js.map +1 -1
- package/dist/modules/requests/itemProcessors/AbstractRequestItemProcessor.d.ts +1 -1
- package/dist/modules/requests/itemProcessors/GenericRequestItemProcessor.d.ts +1 -1
- package/dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js +1 -1
- package/dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js.map +1 -1
- package/dist/modules/requests/itemProcessors/IRequestItemProcessor.d.ts +1 -1
- package/dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.d.ts +1 -1
- package/dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js +6 -3
- package/dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js.map +1 -1
- package/dist/modules/requests/itemProcessors/freeText/FreeTextRequestItemProcessor.d.ts +1 -1
- package/dist/modules/requests/itemProcessors/freeText/FreeTextRequestItemProcessor.js +1 -1
- package/dist/modules/requests/itemProcessors/freeText/FreeTextRequestItemProcessor.js.map +1 -1
- package/dist/modules/requests/itemProcessors/proposeAttribute/AcceptProposeAttributeRequestItemParameters.js +2 -2
- package/dist/modules/requests/itemProcessors/proposeAttribute/AcceptProposeAttributeRequestItemParameters.js.map +1 -1
- package/dist/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.d.ts +1 -1
- package/dist/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.js +1 -1
- package/dist/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.js.map +1 -1
- package/dist/modules/requests/itemProcessors/readAttribute/AcceptReadAttributeRequestItemParameters.js +2 -2
- package/dist/modules/requests/itemProcessors/readAttribute/AcceptReadAttributeRequestItemParameters.js.map +1 -1
- package/dist/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.d.ts +1 -1
- package/dist/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.js +1 -1
- package/dist/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.js.map +1 -1
- package/dist/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.d.ts +1 -1
- package/dist/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.js +1 -1
- package/dist/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.js.map +1 -1
- package/dist/modules/requests/itemProcessors/utility/validateQuery.d.ts +1 -1
- package/dist/modules/requests/itemProcessors/utility/validateQuery.js +1 -1
- package/dist/modules/requests/itemProcessors/utility/validateQuery.js.map +1 -1
- package/dist/modules/requests/outgoing/OutgoingRequestsController.d.ts +1 -1
- package/dist/modules/requests/outgoing/OutgoingRequestsController.js +1 -1
- package/dist/modules/requests/outgoing/OutgoingRequestsController.js.map +1 -1
- package/lib-web/nmshd.consumption.js +737 -230
- package/lib-web/nmshd.consumption.js.map +1 -1
- package/lib-web/nmshd.consumption.min.js +1 -1
- package/lib-web/nmshd.consumption.min.js.map +1 -1
- package/package.json +2 -2
- package/dist/modules/attributes/events/AttributeSucceededEvent.d.ts +0 -6
- package/dist/modules/attributes/events/AttributeSucceededEvent.js +0 -12
- package/dist/modules/attributes/events/AttributeSucceededEvent.js.map +0 -1
- package/dist/modules/attributes/local/SucceedLocalAttributeParams.d.ts +0 -16
- package/dist/modules/attributes/local/SucceedLocalAttributeParams.js +0 -32
- package/dist/modules/attributes/local/SucceedLocalAttributeParams.js.map +0 -1
- package/dist/modules/attributes/local/UpdateLocalAttributeParams.d.ts +0 -16
- package/dist/modules/attributes/local/UpdateLocalAttributeParams.js +0 -32
- package/dist/modules/attributes/local/UpdateLocalAttributeParams.js.map +0 -1
- package/dist/modules/requests/itemProcessors/ValidationResult.js.map +0 -1
- /package/dist/modules/{requests/itemProcessors → common}/ValidationResult.d.ts +0 -0
- /package/dist/modules/{requests/itemProcessors → common}/ValidationResult.js +0 -0
|
@@ -17,10 +17,10 @@ const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
|
17
17
|
const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
|
|
18
18
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
19
19
|
exports.buildInformation = {
|
|
20
|
-
version: "3.
|
|
21
|
-
build: "
|
|
22
|
-
date: "2023-10-
|
|
23
|
-
commit: "
|
|
20
|
+
version: "3.5.0",
|
|
21
|
+
build: "112",
|
|
22
|
+
date: "2023-10-31T10:17:19+00:00",
|
|
23
|
+
commit: "cc4cf4fbea8615d02b0ad15ab787b4b6dc355bb5",
|
|
24
24
|
dependencies: {"@js-soft/docdb-querytranslator":"^1.1.1","@nmshd/iql":"^0.0.4","ts-simple-nameof":"^1.3.1"},
|
|
25
25
|
libraries: {
|
|
26
26
|
transport: transport_1.buildInformation,
|
|
@@ -228,8 +228,62 @@ exports.CoreErrors = void 0;
|
|
|
228
228
|
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
229
229
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
230
230
|
class Attributes {
|
|
231
|
-
|
|
232
|
-
return new transport_1.CoreError("error.consumption.attributes.
|
|
231
|
+
successionMustNotChangeKey() {
|
|
232
|
+
return new transport_1.CoreError("error.consumption.attributes.successionMustNotChangeKey", "The predecessor attribute's key does not match that of the successor. The succession of a relationship attribute must not change the key.");
|
|
233
|
+
}
|
|
234
|
+
successionPeerIsNotOwner() {
|
|
235
|
+
return new transport_1.CoreError("error.consumption.attributes.successionPeerIsNotOwner", "The peer of the succeeded attribute is not its owner. This may be an attempt of spoofing.");
|
|
236
|
+
}
|
|
237
|
+
invalidSuccessionOfOwnSharedIdentityAttribute(comment) {
|
|
238
|
+
let errorMessage = "Invalid succession of own shared identity attribute.";
|
|
239
|
+
if (comment)
|
|
240
|
+
errorMessage += ` ${comment}`;
|
|
241
|
+
return new transport_1.CoreError("error.consumption.attributes.invalidSuccessionOfOwnSharedIdentityAttribute", errorMessage);
|
|
242
|
+
}
|
|
243
|
+
cannotSucceedPartOfComplexAttribute(parentId) {
|
|
244
|
+
return new transport_1.CoreError("error.consumption.attributes.cannotSucceedPartOfComplexAttribute", `The attribute you want to succeed is part of a complex attribute (id: ${parentId}), and cannot be succeeded on its own. Instead, succeed the parent which will implicitly succeed all its children.`);
|
|
245
|
+
}
|
|
246
|
+
successorMustNotYetExist() {
|
|
247
|
+
return new transport_1.CoreError("error.consumption.attributes.successorMustNotYetExist", "The predecessor attribute's successor must not exist. It will be created by the succession handlers and must not be created manually.");
|
|
248
|
+
}
|
|
249
|
+
successorMustNotHaveASuccessor(comment) {
|
|
250
|
+
let errorMessage = "The successor must not have a successor itself.";
|
|
251
|
+
if (comment)
|
|
252
|
+
errorMessage += ` ${comment}`;
|
|
253
|
+
return new transport_1.CoreError("error.consumption.attributes.successorMustNotHaveASuccessor", errorMessage);
|
|
254
|
+
}
|
|
255
|
+
invalidPredecessor(comment) {
|
|
256
|
+
let errorMessage = "Invalid predecessor.";
|
|
257
|
+
if (comment)
|
|
258
|
+
errorMessage += ` ${comment}`;
|
|
259
|
+
return new transport_1.CoreError("error.consumption.attributes.invalidPredecessor", errorMessage);
|
|
260
|
+
}
|
|
261
|
+
invalidSuccessor(comment) {
|
|
262
|
+
let errorMessage = "Invalid successor.";
|
|
263
|
+
if (comment)
|
|
264
|
+
errorMessage += ` ${comment}`;
|
|
265
|
+
return new transport_1.CoreError("error.consumption.attributes.invalidSuccessor", errorMessage);
|
|
266
|
+
}
|
|
267
|
+
predecessorDoesNotExist() {
|
|
268
|
+
return new transport_1.CoreError("error.consumption.attributes.predecessorDoesNotExist", "The predecessor does not exist.");
|
|
269
|
+
}
|
|
270
|
+
successionMustNotChangeOwner() {
|
|
271
|
+
return new transport_1.CoreError("error.consumption.attributes.successionMustNotChangeOwner", "The successor attribute's owner does not match that of the predecessor. An attribute succession must not change the attribute's owner.");
|
|
272
|
+
}
|
|
273
|
+
successionMustNotChangeValueType() {
|
|
274
|
+
return new transport_1.CoreError("error.consumption.attributes.successionMustNotChangeValueType", "The successor attribute's value type does not match that of the predecessor. An attribute succession must not change the attribute's value type.");
|
|
275
|
+
}
|
|
276
|
+
successionMustNotChangeContentType() {
|
|
277
|
+
return new transport_1.CoreError("error.consumption.attributes.successionMustNotChangeContentType", "The successor attribute's content type does not match that of the predecessor. An attribute succession must not change the attribute's content type, i.e. an identity attribute must not be succeeded by a relationship attribute and v.v.");
|
|
278
|
+
}
|
|
279
|
+
successionMustNotChangePeer(comment) {
|
|
280
|
+
let errorMessage = "The peer of the shared attribute must not change.";
|
|
281
|
+
if (comment)
|
|
282
|
+
errorMessage += ` ${comment}`;
|
|
283
|
+
return new transport_1.CoreError("error.consumption.attributes.successionMustNotChangePeer", errorMessage);
|
|
284
|
+
}
|
|
285
|
+
cannotSucceedAttributesWithASuccessor(successorId) {
|
|
286
|
+
return new transport_1.CoreError("error.consumption.attributes.cannotSucceedAttributesWithASuccessor", `The Attribute you want to succeed has a successor (id: ${successorId}). You cannot succeed Attributes with a successor. Instead, succeed the successor.`);
|
|
233
287
|
}
|
|
234
288
|
}
|
|
235
289
|
class Requests {
|
|
@@ -577,23 +631,28 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
577
631
|
__setModuleDefault(result, mod);
|
|
578
632
|
return result;
|
|
579
633
|
};
|
|
634
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
635
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
636
|
+
};
|
|
580
637
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
581
638
|
exports.AttributesController = void 0;
|
|
582
639
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
583
640
|
const Iql = __importStar(__webpack_require__(/*! @nmshd/iql */ "./node_modules/@nmshd/iql/dist/src/index.js"));
|
|
584
641
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
642
|
+
const lodash_1 = __importDefault(__webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js"));
|
|
585
643
|
const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
|
|
586
644
|
const ConsumptionBaseController_1 = __webpack_require__(/*! ../../consumption/ConsumptionBaseController */ "./dist/consumption/ConsumptionBaseController.js");
|
|
587
645
|
const ConsumptionControllerName_1 = __webpack_require__(/*! ../../consumption/ConsumptionControllerName */ "./dist/consumption/ConsumptionControllerName.js");
|
|
588
646
|
const ConsumptionError_1 = __webpack_require__(/*! ../../consumption/ConsumptionError */ "./dist/consumption/ConsumptionError.js");
|
|
589
647
|
const ConsumptionIds_1 = __webpack_require__(/*! ../../consumption/ConsumptionIds */ "./dist/consumption/ConsumptionIds.js");
|
|
590
648
|
const CoreErrors_1 = __webpack_require__(/*! ../../consumption/CoreErrors */ "./dist/consumption/CoreErrors.js");
|
|
649
|
+
const common_1 = __webpack_require__(/*! ../common */ "./dist/modules/common/index.js");
|
|
591
650
|
const events_1 = __webpack_require__(/*! ./events */ "./dist/modules/attributes/events/index.js");
|
|
651
|
+
const CreateLocalAttributeParams_1 = __webpack_require__(/*! ./local/CreateLocalAttributeParams */ "./dist/modules/attributes/local/CreateLocalAttributeParams.js");
|
|
592
652
|
const CreateSharedLocalAttributeCopyParams_1 = __webpack_require__(/*! ./local/CreateSharedLocalAttributeCopyParams */ "./dist/modules/attributes/local/CreateSharedLocalAttributeCopyParams.js");
|
|
593
653
|
const LocalAttribute_1 = __webpack_require__(/*! ./local/LocalAttribute */ "./dist/modules/attributes/local/LocalAttribute.js");
|
|
594
654
|
const LocalAttributeShareInfo_1 = __webpack_require__(/*! ./local/LocalAttributeShareInfo */ "./dist/modules/attributes/local/LocalAttributeShareInfo.js");
|
|
595
655
|
const QueryTranslator_1 = __webpack_require__(/*! ./local/QueryTranslator */ "./dist/modules/attributes/local/QueryTranslator.js");
|
|
596
|
-
const SucceedLocalAttributeParams_1 = __webpack_require__(/*! ./local/SucceedLocalAttributeParams */ "./dist/modules/attributes/local/SucceedLocalAttributeParams.js");
|
|
597
656
|
class AttributesController extends ConsumptionBaseController_1.ConsumptionBaseController {
|
|
598
657
|
constructor(parent, eventBus, identity) {
|
|
599
658
|
super(ConsumptionControllerName_1.ConsumptionControllerName.AttributesController, parent);
|
|
@@ -739,11 +798,14 @@ class AttributesController extends ConsumptionBaseController_1.ConsumptionBaseCo
|
|
|
739
798
|
return this.parseArray(attributes, LocalAttribute_1.LocalAttribute);
|
|
740
799
|
}
|
|
741
800
|
async createLocalAttribute(params) {
|
|
801
|
+
const parsedParams = CreateLocalAttributeParams_1.CreateLocalAttributeParams.from(params);
|
|
742
802
|
const localAttribute = LocalAttribute_1.LocalAttribute.from({
|
|
743
|
-
id: await ConsumptionIds_1.ConsumptionIds.attribute.generate(),
|
|
803
|
+
id: parsedParams.id ?? (await ConsumptionIds_1.ConsumptionIds.attribute.generate()),
|
|
744
804
|
createdAt: transport_1.CoreDate.utc(),
|
|
745
|
-
content:
|
|
746
|
-
parentId:
|
|
805
|
+
content: parsedParams.content,
|
|
806
|
+
parentId: parsedParams.parentId,
|
|
807
|
+
succeeds: parsedParams.succeeds,
|
|
808
|
+
shareInfo: parsedParams.shareInfo
|
|
747
809
|
});
|
|
748
810
|
await this.attributes.create(localAttribute);
|
|
749
811
|
if (localAttribute.content instanceof content_1.IdentityAttribute && // nested Local Attributes should only be created for Identity Attributes
|
|
@@ -766,29 +828,6 @@ class AttributesController extends ConsumptionBaseController_1.ConsumptionBaseCo
|
|
|
766
828
|
await this.createLocalAttribute({ content: nestedAttribute, parentId: localAttribute.id });
|
|
767
829
|
}
|
|
768
830
|
}
|
|
769
|
-
async succeedLocalAttribute(params) {
|
|
770
|
-
const parsedParams = SucceedLocalAttributeParams_1.SucceedLocalAttributeParams.from(params);
|
|
771
|
-
const currentAttributeDoc = await this.attributes.findOne({
|
|
772
|
-
[(0, ts_simple_nameof_1.nameof)((c) => c.id)]: params.succeeds.toString()
|
|
773
|
-
});
|
|
774
|
-
const currentAttribute = LocalAttribute_1.LocalAttribute.from(currentAttributeDoc);
|
|
775
|
-
if (currentAttribute.parentId) {
|
|
776
|
-
throw CoreErrors_1.CoreErrors.attributes.cannotSucceedAttributesWithAParent(parsedParams.succeeds.toString());
|
|
777
|
-
}
|
|
778
|
-
if (!currentAttributeDoc) {
|
|
779
|
-
throw transport_1.CoreErrors.general.recordNotFound(LocalAttribute_1.LocalAttribute, parsedParams.succeeds.toString());
|
|
780
|
-
}
|
|
781
|
-
if (!parsedParams.successorContent.validFrom) {
|
|
782
|
-
parsedParams.successorContent.validFrom = transport_1.CoreDate.utc();
|
|
783
|
-
}
|
|
784
|
-
const validFrom = parsedParams.successorContent.validFrom;
|
|
785
|
-
currentAttribute.content.validTo = validFrom.subtract(1);
|
|
786
|
-
await this.attributes.update(currentAttributeDoc, currentAttribute);
|
|
787
|
-
const successor = await LocalAttribute_1.LocalAttribute.fromAttribute(parsedParams.successorContent, parsedParams.succeeds);
|
|
788
|
-
await this.attributes.create(successor);
|
|
789
|
-
this.eventBus.publish(new events_1.AttributeSucceededEvent(this.identity.address.toString(), successor));
|
|
790
|
-
return successor;
|
|
791
|
-
}
|
|
792
831
|
async createSharedLocalAttributeCopy(params) {
|
|
793
832
|
const parsedParams = CreateSharedLocalAttributeCopyParams_1.CreateSharedLocalAttributeCopyParams.from(params);
|
|
794
833
|
const sourceAttribute = await this.getLocalAttribute(parsedParams.sourceAttributeId);
|
|
@@ -820,28 +859,349 @@ class AttributesController extends ConsumptionBaseController_1.ConsumptionBaseCo
|
|
|
820
859
|
this.eventBus.publish(new events_1.AttributeCreatedEvent(this.identity.address.toString(), peerLocalAttribute));
|
|
821
860
|
return peerLocalAttribute;
|
|
822
861
|
}
|
|
823
|
-
async
|
|
824
|
-
|
|
825
|
-
|
|
862
|
+
async deleteAttribute(attribute) {
|
|
863
|
+
await this.deleteAttributeUnsafe(attribute.id);
|
|
864
|
+
this.eventBus.publish(new events_1.AttributeDeletedEvent(this.identity.address.toString(), attribute));
|
|
865
|
+
}
|
|
866
|
+
async succeedRepositoryAttribute(predecessorId, successorParams, validate = true) {
|
|
867
|
+
if (validate) {
|
|
868
|
+
const validationResult = await this.validateRepositoryAttributeSuccession(predecessorId, successorParams);
|
|
869
|
+
if (validationResult.isError()) {
|
|
870
|
+
throw validationResult.error;
|
|
871
|
+
}
|
|
872
|
+
}
|
|
873
|
+
const { predecessor, successor } = await this._succeedAttributeUnsafe(predecessorId, {
|
|
874
|
+
id: successorParams.id,
|
|
875
|
+
content: successorParams.content,
|
|
876
|
+
succeeds: predecessorId,
|
|
877
|
+
shareInfo: successorParams.shareInfo,
|
|
878
|
+
parentId: successorParams.parentId,
|
|
879
|
+
createdAt: successorParams.createdAt,
|
|
880
|
+
succeededBy: successorParams.succeededBy
|
|
826
881
|
});
|
|
827
|
-
|
|
828
|
-
|
|
882
|
+
this.eventBus.publish(new events_1.RepositoryAttributeSucceededEvent(this.identity.address.toString(), predecessor, successor));
|
|
883
|
+
return { predecessor, successor };
|
|
884
|
+
}
|
|
885
|
+
async succeedOwnSharedIdentityAttribute(predecessorId, successorParams, validate = true) {
|
|
886
|
+
if (validate) {
|
|
887
|
+
const validationResult = await this.validateOwnSharedIdentityAttributeSuccession(predecessorId, successorParams);
|
|
888
|
+
if (validationResult.isError()) {
|
|
889
|
+
throw validationResult.error;
|
|
890
|
+
}
|
|
829
891
|
}
|
|
830
|
-
const
|
|
831
|
-
id:
|
|
832
|
-
content:
|
|
833
|
-
|
|
834
|
-
shareInfo:
|
|
835
|
-
|
|
836
|
-
|
|
892
|
+
const { predecessor, successor } = await this._succeedAttributeUnsafe(predecessorId, {
|
|
893
|
+
id: successorParams.id,
|
|
894
|
+
content: successorParams.content,
|
|
895
|
+
succeeds: predecessorId,
|
|
896
|
+
shareInfo: successorParams.shareInfo,
|
|
897
|
+
parentId: successorParams.parentId,
|
|
898
|
+
createdAt: successorParams.createdAt,
|
|
899
|
+
succeededBy: successorParams.succeededBy
|
|
900
|
+
});
|
|
901
|
+
this.eventBus.publish(new events_1.OwnSharedAttributeSucceededEvent(this.identity.address.toString(), predecessor, successor));
|
|
902
|
+
return { predecessor, successor };
|
|
903
|
+
}
|
|
904
|
+
async succeedOwnSharedRelationshipAttribute(predecessorId, successorParams, validate = true) {
|
|
905
|
+
if (validate) {
|
|
906
|
+
const validationResult = await this.validateOwnSharedRelationshipAttributeSuccession(predecessorId, successorParams);
|
|
907
|
+
if (validationResult.isError()) {
|
|
908
|
+
throw validationResult.error;
|
|
909
|
+
}
|
|
910
|
+
}
|
|
911
|
+
const { predecessor, successor } = await this._succeedAttributeUnsafe(predecessorId, {
|
|
912
|
+
id: successorParams.id,
|
|
913
|
+
content: successorParams.content,
|
|
914
|
+
succeeds: predecessorId,
|
|
915
|
+
shareInfo: successorParams.shareInfo,
|
|
916
|
+
parentId: successorParams.parentId,
|
|
917
|
+
createdAt: successorParams.createdAt,
|
|
918
|
+
succeededBy: successorParams.succeededBy
|
|
919
|
+
});
|
|
920
|
+
this.eventBus.publish(new events_1.OwnSharedAttributeSucceededEvent(this.identity.address.toString(), predecessor, successor));
|
|
921
|
+
return { predecessor, successor };
|
|
922
|
+
}
|
|
923
|
+
async succeedPeerSharedIdentityAttribute(predecessorId, successorParams, validate = true) {
|
|
924
|
+
if (validate) {
|
|
925
|
+
const validationResult = await this.validatePeerSharedIdentityAttributeSuccession(predecessorId, successorParams);
|
|
926
|
+
if (validationResult.isError()) {
|
|
927
|
+
throw validationResult.error;
|
|
928
|
+
}
|
|
929
|
+
}
|
|
930
|
+
const { predecessor, successor } = await this._succeedAttributeUnsafe(predecessorId, {
|
|
931
|
+
id: successorParams.id,
|
|
932
|
+
content: successorParams.content,
|
|
933
|
+
succeeds: predecessorId,
|
|
934
|
+
shareInfo: successorParams.shareInfo,
|
|
935
|
+
parentId: successorParams.parentId,
|
|
936
|
+
createdAt: successorParams.createdAt,
|
|
937
|
+
succeededBy: successorParams.succeededBy
|
|
938
|
+
});
|
|
939
|
+
/* No succeeded attribute event fired here. This is done by the notification system. */
|
|
940
|
+
return { predecessor, successor };
|
|
941
|
+
}
|
|
942
|
+
async succeedPeerSharedRelationshipAttribute(predecessorId, successorParams, validate = true) {
|
|
943
|
+
if (validate) {
|
|
944
|
+
const validationResult = await this.validatePeerSharedRelationshipAttributeSuccession(predecessorId, successorParams);
|
|
945
|
+
if (validationResult.isError()) {
|
|
946
|
+
throw validationResult.error;
|
|
947
|
+
}
|
|
948
|
+
}
|
|
949
|
+
const { predecessor, successor } = await this._succeedAttributeUnsafe(predecessorId, {
|
|
950
|
+
id: successorParams.id,
|
|
951
|
+
content: successorParams.content,
|
|
952
|
+
succeeds: predecessorId,
|
|
953
|
+
shareInfo: successorParams.shareInfo,
|
|
954
|
+
parentId: successorParams.parentId,
|
|
955
|
+
createdAt: successorParams.createdAt,
|
|
956
|
+
succeededBy: successorParams.succeededBy
|
|
957
|
+
});
|
|
958
|
+
/* No succeeded attribute event fired here. This is done by the notification system. */
|
|
959
|
+
return { predecessor, successor };
|
|
960
|
+
}
|
|
961
|
+
async _succeedAttributeUnsafe(predecessorId, successorParams) {
|
|
962
|
+
const successor = await this.createAttributeUnsafe({
|
|
963
|
+
id: successorParams.id,
|
|
964
|
+
content: successorParams.content,
|
|
965
|
+
succeeds: predecessorId,
|
|
966
|
+
shareInfo: successorParams.shareInfo,
|
|
967
|
+
parentId: successorParams.parentId,
|
|
968
|
+
createdAt: successorParams.createdAt,
|
|
969
|
+
succeededBy: successorParams.succeededBy
|
|
970
|
+
});
|
|
971
|
+
const predecessor = (await this.getLocalAttribute(predecessorId));
|
|
972
|
+
predecessor.succeededBy = successor.id;
|
|
973
|
+
await this.updateAttributeUnsafe(predecessor);
|
|
974
|
+
return { predecessor, successor };
|
|
975
|
+
}
|
|
976
|
+
async validateRepositoryAttributeSuccession(predecessorId, successorParams) {
|
|
977
|
+
const commonValidation = await this.validateAttributeSuccessionCommon(predecessorId, successorParams);
|
|
978
|
+
if (commonValidation.isError())
|
|
979
|
+
return commonValidation;
|
|
980
|
+
const predecessor = (await this.getLocalAttribute(predecessorId));
|
|
981
|
+
const successor = LocalAttribute_1.LocalAttribute.from({
|
|
982
|
+
id: transport_1.CoreId.from(successorParams.id ?? "dummy"),
|
|
983
|
+
content: successorParams.content,
|
|
984
|
+
createdAt: successorParams.createdAt ?? transport_1.CoreDate.utc(),
|
|
985
|
+
succeeds: successorParams.succeeds,
|
|
986
|
+
succeededBy: successorParams.succeededBy,
|
|
987
|
+
shareInfo: successorParams.shareInfo,
|
|
988
|
+
parentId: successorParams.parentId
|
|
989
|
+
});
|
|
990
|
+
if (!predecessor.isIdentityAttribute() || predecessor.isShared()) {
|
|
991
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidPredecessor("Predecessor is not a valid repository attribute."));
|
|
992
|
+
}
|
|
993
|
+
if (!successor.isIdentityAttribute() || successor.isShared()) {
|
|
994
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidPredecessor("Successor is not a valid repository attribute."));
|
|
995
|
+
}
|
|
996
|
+
return common_1.ValidationResult.success();
|
|
997
|
+
}
|
|
998
|
+
async validateOwnSharedIdentityAttributeSuccession(predecessorId, successorParams) {
|
|
999
|
+
const commonValidation = await this.validateAttributeSuccessionCommon(predecessorId, successorParams);
|
|
1000
|
+
if (commonValidation.isError())
|
|
1001
|
+
return commonValidation;
|
|
1002
|
+
const predecessor = (await this.getLocalAttribute(predecessorId));
|
|
1003
|
+
const successor = LocalAttribute_1.LocalAttribute.from({
|
|
1004
|
+
id: transport_1.CoreId.from(successorParams.id ?? "dummy"),
|
|
1005
|
+
content: successorParams.content,
|
|
1006
|
+
createdAt: successorParams.createdAt ?? transport_1.CoreDate.utc(),
|
|
1007
|
+
succeeds: successorParams.succeeds,
|
|
1008
|
+
succeededBy: successorParams.succeededBy,
|
|
1009
|
+
shareInfo: successorParams.shareInfo,
|
|
1010
|
+
parentId: successorParams.parentId
|
|
1011
|
+
});
|
|
1012
|
+
if (!predecessor.isOwnSharedIdentityAttribute(this.identity.address)) {
|
|
1013
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidPredecessor("Predecessor is not a valid own shared identity attribute."));
|
|
1014
|
+
}
|
|
1015
|
+
if (!successor.isOwnSharedIdentityAttribute(this.identity.address)) {
|
|
1016
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidSuccessor("Successor is not a valid peer shared identity attribute."));
|
|
1017
|
+
}
|
|
1018
|
+
if (!predecessor.shareInfo.peer.equals(successor.shareInfo.peer)) {
|
|
1019
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successionMustNotChangePeer());
|
|
1020
|
+
}
|
|
1021
|
+
/* Succession of own shared identity attribute must be matched by their
|
|
1022
|
+
* respective repository attributes. */
|
|
1023
|
+
const predecessorSource = await this.getLocalAttribute(predecessor.shareInfo.sourceAttribute);
|
|
1024
|
+
const successorSource = await this.getLocalAttribute(successor.shareInfo.sourceAttribute);
|
|
1025
|
+
if (typeof predecessorSource === "undefined" || !predecessorSource.isRepositoryAttribute()) {
|
|
1026
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidSuccessionOfOwnSharedIdentityAttribute());
|
|
1027
|
+
}
|
|
1028
|
+
if (typeof successorSource === "undefined" || !successorSource.isRepositoryAttribute()) {
|
|
1029
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidSuccessionOfOwnSharedIdentityAttribute("Source attribute is not a valid repository attribute."));
|
|
1030
|
+
}
|
|
1031
|
+
if (typeof successorSource.succeeds === "undefined" ||
|
|
1032
|
+
!successorSource.succeeds.equals(predecessorSource.id) ||
|
|
1033
|
+
typeof predecessorSource.succeededBy === "undefined" ||
|
|
1034
|
+
!predecessorSource.succeededBy.equals(successorSource.id)) {
|
|
1035
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidSuccessionOfOwnSharedIdentityAttribute("Prdeecessor source attribute is not succeeded by successor source attribute."));
|
|
1036
|
+
}
|
|
1037
|
+
const repositoryAttributeContentMatchesItsSharedAttribute = lodash_1.default.isEqual(predecessorSource.content, predecessor.content) &&
|
|
1038
|
+
lodash_1.default.isEqual(successorSource.content, successor.content);
|
|
1039
|
+
if (!repositoryAttributeContentMatchesItsSharedAttribute) {
|
|
1040
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidSuccessionOfOwnSharedIdentityAttribute("Successor source attribute contents don't match successor shared attribute copy."));
|
|
1041
|
+
}
|
|
1042
|
+
return common_1.ValidationResult.success();
|
|
1043
|
+
}
|
|
1044
|
+
async validateOwnSharedRelationshipAttributeSuccession(predecessorId, successorParams) {
|
|
1045
|
+
const commonValidation = await this.validateAttributeSuccessionCommon(predecessorId, successorParams);
|
|
1046
|
+
if (commonValidation.isError())
|
|
1047
|
+
return commonValidation;
|
|
1048
|
+
const predecessor = (await this.getLocalAttribute(predecessorId));
|
|
1049
|
+
const successor = LocalAttribute_1.LocalAttribute.from({
|
|
1050
|
+
id: transport_1.CoreId.from(successorParams.id ?? "dummy"),
|
|
1051
|
+
content: successorParams.content,
|
|
1052
|
+
createdAt: successorParams.createdAt ?? transport_1.CoreDate.utc(),
|
|
1053
|
+
succeeds: successorParams.succeeds,
|
|
1054
|
+
succeededBy: successorParams.succeededBy,
|
|
1055
|
+
shareInfo: successorParams.shareInfo,
|
|
1056
|
+
parentId: successorParams.parentId
|
|
1057
|
+
});
|
|
1058
|
+
if (!predecessor.isOwnSharedRelationshipAttribute(this.identity.address)) {
|
|
1059
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidPredecessor("Predecessor is not a valid own shared relationship attribute."));
|
|
1060
|
+
}
|
|
1061
|
+
if (!successor.isOwnSharedRelationshipAttribute(this.identity.address)) {
|
|
1062
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidSuccessor("Successor is not a valid own shared relationship attribute."));
|
|
1063
|
+
}
|
|
1064
|
+
if (successor.content.key !== predecessor.content.key) {
|
|
1065
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successionMustNotChangeKey());
|
|
1066
|
+
}
|
|
1067
|
+
if (!predecessor.shareInfo.peer.equals(successor.shareInfo.peer)) {
|
|
1068
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successionMustNotChangePeer());
|
|
1069
|
+
}
|
|
1070
|
+
return common_1.ValidationResult.success();
|
|
1071
|
+
}
|
|
1072
|
+
async validatePeerSharedIdentityAttributeSuccession(predecessorId, successorParams) {
|
|
1073
|
+
const commonValidation = await this.validateAttributeSuccessionCommon(predecessorId, successorParams);
|
|
1074
|
+
if (commonValidation.isError())
|
|
1075
|
+
return commonValidation;
|
|
1076
|
+
const predecessor = (await this.getLocalAttribute(predecessorId));
|
|
1077
|
+
const successor = LocalAttribute_1.LocalAttribute.from({
|
|
1078
|
+
id: transport_1.CoreId.from(successorParams.id ?? "dummy"),
|
|
1079
|
+
content: successorParams.content,
|
|
1080
|
+
createdAt: successorParams.createdAt ?? transport_1.CoreDate.utc(),
|
|
1081
|
+
succeeds: successorParams.succeeds,
|
|
1082
|
+
succeededBy: successorParams.succeededBy,
|
|
1083
|
+
shareInfo: successorParams.shareInfo,
|
|
1084
|
+
parentId: successorParams.parentId
|
|
1085
|
+
});
|
|
1086
|
+
if (!predecessor.isPeerSharedIdentityAttribute()) {
|
|
1087
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidPredecessor("Predecessor is not a valid peer shared identity attribute."));
|
|
1088
|
+
}
|
|
1089
|
+
if (!successor.isPeerSharedIdentityAttribute()) {
|
|
1090
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidSuccessor("Successor is not a valid peer shared identity attribute."));
|
|
1091
|
+
}
|
|
1092
|
+
if (!predecessor.shareInfo.peer.equals(successor.shareInfo.peer)) {
|
|
1093
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successionMustNotChangePeer());
|
|
1094
|
+
}
|
|
1095
|
+
return common_1.ValidationResult.success();
|
|
1096
|
+
}
|
|
1097
|
+
async validatePeerSharedRelationshipAttributeSuccession(predecessorId, successorParams) {
|
|
1098
|
+
const commonValidation = await this.validateAttributeSuccessionCommon(predecessorId, successorParams);
|
|
1099
|
+
if (commonValidation.isError())
|
|
1100
|
+
return commonValidation;
|
|
1101
|
+
const predecessor = (await this.getLocalAttribute(predecessorId));
|
|
1102
|
+
const successor = LocalAttribute_1.LocalAttribute.from({
|
|
1103
|
+
id: transport_1.CoreId.from(successorParams.id ?? "dummy"),
|
|
1104
|
+
content: successorParams.content,
|
|
1105
|
+
createdAt: successorParams.createdAt ?? transport_1.CoreDate.utc(),
|
|
1106
|
+
succeeds: successorParams.succeeds,
|
|
1107
|
+
succeededBy: successorParams.succeededBy,
|
|
1108
|
+
shareInfo: successorParams.shareInfo,
|
|
1109
|
+
parentId: successorParams.parentId
|
|
837
1110
|
});
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
1111
|
+
if (!predecessor.isPeerSharedRelationshipAttribute()) {
|
|
1112
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidPredecessor("Predecessor is not a valid peer shared relationship attribute."));
|
|
1113
|
+
}
|
|
1114
|
+
if (!successor.isPeerSharedRelationshipAttribute()) {
|
|
1115
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidSuccessor("Successor is not a valid peer shared relationship attribute."));
|
|
1116
|
+
}
|
|
1117
|
+
if (successor.content.key !== predecessor.content.key) {
|
|
1118
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successionMustNotChangeKey());
|
|
1119
|
+
}
|
|
1120
|
+
if (!predecessor.shareInfo.peer.equals(successor.shareInfo.peer)) {
|
|
1121
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successionMustNotChangePeer());
|
|
1122
|
+
}
|
|
1123
|
+
return common_1.ValidationResult.success();
|
|
841
1124
|
}
|
|
842
|
-
async
|
|
843
|
-
|
|
844
|
-
|
|
1125
|
+
async validateAttributeSuccessionCommon(predecessorId, successorParams) {
|
|
1126
|
+
const successor = LocalAttribute_1.LocalAttribute.from({
|
|
1127
|
+
id: transport_1.CoreId.from(successorParams.id ?? "dummy"),
|
|
1128
|
+
content: successorParams.content,
|
|
1129
|
+
createdAt: successorParams.createdAt ?? transport_1.CoreDate.utc(),
|
|
1130
|
+
succeeds: successorParams.succeeds,
|
|
1131
|
+
succeededBy: successorParams.succeededBy,
|
|
1132
|
+
shareInfo: successorParams.shareInfo,
|
|
1133
|
+
parentId: successorParams.parentId
|
|
1134
|
+
});
|
|
1135
|
+
if (typeof successorParams.id !== "undefined") {
|
|
1136
|
+
const successor = await this.getLocalAttribute(transport_1.CoreId.from(successorParams.id));
|
|
1137
|
+
if (typeof successor !== "undefined") {
|
|
1138
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successorMustNotYetExist());
|
|
1139
|
+
}
|
|
1140
|
+
}
|
|
1141
|
+
if (typeof successor.succeeds !== "undefined" && !predecessorId.equals(successor.succeeds.toString())) {
|
|
1142
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidPredecessor("The predecessor's id and the explicitly set value for the successor's succeeds field don't match."));
|
|
1143
|
+
}
|
|
1144
|
+
if (typeof successor.succeededBy !== "undefined") {
|
|
1145
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successorMustNotHaveASuccessor());
|
|
1146
|
+
}
|
|
1147
|
+
if (typeof successor.parentId !== "undefined") {
|
|
1148
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.cannotSucceedPartOfComplexAttribute(predecessorId.toString()));
|
|
1149
|
+
}
|
|
1150
|
+
const predecessor = await this.getLocalAttribute(predecessorId);
|
|
1151
|
+
if (typeof predecessor === "undefined") {
|
|
1152
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.predecessorDoesNotExist());
|
|
1153
|
+
}
|
|
1154
|
+
if (typeof predecessor.succeededBy !== "undefined") {
|
|
1155
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.cannotSucceedAttributesWithASuccessor(predecessor.succeededBy.toString()));
|
|
1156
|
+
}
|
|
1157
|
+
if (predecessor.parentId) {
|
|
1158
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.cannotSucceedPartOfComplexAttribute(predecessorId.toString()));
|
|
1159
|
+
}
|
|
1160
|
+
if (!predecessor.content.owner.equals(transport_1.CoreAddress.from(successor.content.owner))) {
|
|
1161
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successionMustNotChangeOwner());
|
|
1162
|
+
}
|
|
1163
|
+
if (successor.content.constructor !== predecessor.content.constructor) {
|
|
1164
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successionMustNotChangeContentType());
|
|
1165
|
+
}
|
|
1166
|
+
if (predecessor.content.value.constructor !== successor.content.value.constructor) {
|
|
1167
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successionMustNotChangeValueType());
|
|
1168
|
+
}
|
|
1169
|
+
return common_1.ValidationResult.success();
|
|
1170
|
+
}
|
|
1171
|
+
async createAttributeUnsafe(attributeData) {
|
|
1172
|
+
const localAttribute = LocalAttribute_1.LocalAttribute.from({
|
|
1173
|
+
id: attributeData.id ?? (await ConsumptionIds_1.ConsumptionIds.attribute.generate()),
|
|
1174
|
+
content: attributeData.content,
|
|
1175
|
+
createdAt: attributeData.createdAt ?? transport_1.CoreDate.utc(),
|
|
1176
|
+
shareInfo: attributeData.shareInfo,
|
|
1177
|
+
parentId: attributeData.parentId,
|
|
1178
|
+
succeededBy: attributeData.succeededBy,
|
|
1179
|
+
succeeds: attributeData.succeeds
|
|
1180
|
+
});
|
|
1181
|
+
await this.attributes.create(localAttribute);
|
|
1182
|
+
return localAttribute;
|
|
1183
|
+
}
|
|
1184
|
+
async updateAttributeUnsafe(attributeParams) {
|
|
1185
|
+
const doc = await this.attributes.findOne({
|
|
1186
|
+
[(0, ts_simple_nameof_1.nameof)((c) => c.id)]: attributeParams.id.toString()
|
|
1187
|
+
});
|
|
1188
|
+
if (!doc) {
|
|
1189
|
+
throw transport_1.CoreErrors.general.recordNotFound(LocalAttribute_1.LocalAttribute, attributeParams.id.toString());
|
|
1190
|
+
}
|
|
1191
|
+
const params = {
|
|
1192
|
+
id: attributeParams.id,
|
|
1193
|
+
content: attributeParams.content,
|
|
1194
|
+
createdAt: attributeParams.createdAt,
|
|
1195
|
+
parentId: attributeParams.parentId,
|
|
1196
|
+
shareInfo: attributeParams.shareInfo,
|
|
1197
|
+
succeededBy: attributeParams.succeededBy,
|
|
1198
|
+
succeeds: attributeParams.succeeds
|
|
1199
|
+
};
|
|
1200
|
+
const newAttribute = LocalAttribute_1.LocalAttribute.from(params);
|
|
1201
|
+
await this.attributes.update(doc, newAttribute);
|
|
1202
|
+
}
|
|
1203
|
+
async deleteAttributeUnsafe(id) {
|
|
1204
|
+
await this.attributes.delete({ id: id });
|
|
845
1205
|
}
|
|
846
1206
|
}
|
|
847
1207
|
exports.AttributesController = AttributesController;
|
|
@@ -893,25 +1253,16 @@ AttributeDeletedEvent.namespace = "consumption.attributeDeleted";
|
|
|
893
1253
|
|
|
894
1254
|
/***/ }),
|
|
895
1255
|
|
|
896
|
-
/***/ "./dist/modules/attributes/events/
|
|
897
|
-
|
|
898
|
-
!*** ./dist/modules/attributes/events/
|
|
899
|
-
|
|
900
|
-
/***/ ((__unused_webpack_module, exports
|
|
1256
|
+
/***/ "./dist/modules/attributes/events/AttributeSucceededEventData.js":
|
|
1257
|
+
/*!***********************************************************************!*\
|
|
1258
|
+
!*** ./dist/modules/attributes/events/AttributeSucceededEventData.js ***!
|
|
1259
|
+
\***********************************************************************/
|
|
1260
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
901
1261
|
|
|
902
1262
|
"use strict";
|
|
903
1263
|
|
|
904
1264
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
905
|
-
|
|
906
|
-
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
907
|
-
class AttributeSucceededEvent extends transport_1.TransportDataEvent {
|
|
908
|
-
constructor(eventTargetAddress, data) {
|
|
909
|
-
super(AttributeSucceededEvent.namespace, eventTargetAddress, data);
|
|
910
|
-
}
|
|
911
|
-
}
|
|
912
|
-
exports.AttributeSucceededEvent = AttributeSucceededEvent;
|
|
913
|
-
AttributeSucceededEvent.namespace = "consumption.attributeSucceded";
|
|
914
|
-
//# sourceMappingURL=AttributeSucceededEvent.js.map
|
|
1265
|
+
//# sourceMappingURL=AttributeSucceededEventData.js.map
|
|
915
1266
|
|
|
916
1267
|
/***/ }),
|
|
917
1268
|
|
|
@@ -937,6 +1288,72 @@ AttributeUpdatedEvent.namespace = "consumption.attributeUpdated";
|
|
|
937
1288
|
|
|
938
1289
|
/***/ }),
|
|
939
1290
|
|
|
1291
|
+
/***/ "./dist/modules/attributes/events/OwnSharedAttributeSucceededEvent.js":
|
|
1292
|
+
/*!****************************************************************************!*\
|
|
1293
|
+
!*** ./dist/modules/attributes/events/OwnSharedAttributeSucceededEvent.js ***!
|
|
1294
|
+
\****************************************************************************/
|
|
1295
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1296
|
+
|
|
1297
|
+
"use strict";
|
|
1298
|
+
|
|
1299
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1300
|
+
exports.OwnSharedAttributeSucceededEvent = void 0;
|
|
1301
|
+
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
1302
|
+
class OwnSharedAttributeSucceededEvent extends transport_1.TransportDataEvent {
|
|
1303
|
+
constructor(eventTargetAddress, predecessor, successor) {
|
|
1304
|
+
super(OwnSharedAttributeSucceededEvent.namespace, eventTargetAddress, { predecessor, successor });
|
|
1305
|
+
}
|
|
1306
|
+
}
|
|
1307
|
+
exports.OwnSharedAttributeSucceededEvent = OwnSharedAttributeSucceededEvent;
|
|
1308
|
+
OwnSharedAttributeSucceededEvent.namespace = "consumption.ownSharedAttributeSucceded";
|
|
1309
|
+
//# sourceMappingURL=OwnSharedAttributeSucceededEvent.js.map
|
|
1310
|
+
|
|
1311
|
+
/***/ }),
|
|
1312
|
+
|
|
1313
|
+
/***/ "./dist/modules/attributes/events/PeerSharedAttributeSucceededEvent.js":
|
|
1314
|
+
/*!*****************************************************************************!*\
|
|
1315
|
+
!*** ./dist/modules/attributes/events/PeerSharedAttributeSucceededEvent.js ***!
|
|
1316
|
+
\*****************************************************************************/
|
|
1317
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1318
|
+
|
|
1319
|
+
"use strict";
|
|
1320
|
+
|
|
1321
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1322
|
+
exports.PeerSharedAttributeSucceededEvent = void 0;
|
|
1323
|
+
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
1324
|
+
class PeerSharedAttributeSucceededEvent extends transport_1.TransportDataEvent {
|
|
1325
|
+
constructor(eventTargetAddress, predecessor, successor) {
|
|
1326
|
+
super(PeerSharedAttributeSucceededEvent.namespace, eventTargetAddress, { predecessor, successor });
|
|
1327
|
+
}
|
|
1328
|
+
}
|
|
1329
|
+
exports.PeerSharedAttributeSucceededEvent = PeerSharedAttributeSucceededEvent;
|
|
1330
|
+
PeerSharedAttributeSucceededEvent.namespace = "consumption.peerSharedAttributeSucceded";
|
|
1331
|
+
//# sourceMappingURL=PeerSharedAttributeSucceededEvent.js.map
|
|
1332
|
+
|
|
1333
|
+
/***/ }),
|
|
1334
|
+
|
|
1335
|
+
/***/ "./dist/modules/attributes/events/RepositoryAttributeSucceededEvent.js":
|
|
1336
|
+
/*!*****************************************************************************!*\
|
|
1337
|
+
!*** ./dist/modules/attributes/events/RepositoryAttributeSucceededEvent.js ***!
|
|
1338
|
+
\*****************************************************************************/
|
|
1339
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1340
|
+
|
|
1341
|
+
"use strict";
|
|
1342
|
+
|
|
1343
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1344
|
+
exports.RepositoryAttributeSucceededEvent = void 0;
|
|
1345
|
+
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
1346
|
+
class RepositoryAttributeSucceededEvent extends transport_1.TransportDataEvent {
|
|
1347
|
+
constructor(eventTargetAddress, predecessor, successor) {
|
|
1348
|
+
super(RepositoryAttributeSucceededEvent.namespace, eventTargetAddress, { predecessor, successor });
|
|
1349
|
+
}
|
|
1350
|
+
}
|
|
1351
|
+
exports.RepositoryAttributeSucceededEvent = RepositoryAttributeSucceededEvent;
|
|
1352
|
+
RepositoryAttributeSucceededEvent.namespace = "consumption.repositoryAttributeSucceded";
|
|
1353
|
+
//# sourceMappingURL=RepositoryAttributeSucceededEvent.js.map
|
|
1354
|
+
|
|
1355
|
+
/***/ }),
|
|
1356
|
+
|
|
940
1357
|
/***/ "./dist/modules/attributes/events/SharedAttributeCopyCreatedEvent.js":
|
|
941
1358
|
/*!***************************************************************************!*\
|
|
942
1359
|
!*** ./dist/modules/attributes/events/SharedAttributeCopyCreatedEvent.js ***!
|
|
@@ -984,8 +1401,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
984
1401
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
985
1402
|
__exportStar(__webpack_require__(/*! ./AttributeCreatedEvent */ "./dist/modules/attributes/events/AttributeCreatedEvent.js"), exports);
|
|
986
1403
|
__exportStar(__webpack_require__(/*! ./AttributeDeletedEvent */ "./dist/modules/attributes/events/AttributeDeletedEvent.js"), exports);
|
|
987
|
-
__exportStar(__webpack_require__(/*! ./
|
|
1404
|
+
__exportStar(__webpack_require__(/*! ./AttributeSucceededEventData */ "./dist/modules/attributes/events/AttributeSucceededEventData.js"), exports);
|
|
988
1405
|
__exportStar(__webpack_require__(/*! ./AttributeUpdatedEvent */ "./dist/modules/attributes/events/AttributeUpdatedEvent.js"), exports);
|
|
1406
|
+
__exportStar(__webpack_require__(/*! ./OwnSharedAttributeSucceededEvent */ "./dist/modules/attributes/events/OwnSharedAttributeSucceededEvent.js"), exports);
|
|
1407
|
+
__exportStar(__webpack_require__(/*! ./PeerSharedAttributeSucceededEvent */ "./dist/modules/attributes/events/PeerSharedAttributeSucceededEvent.js"), exports);
|
|
1408
|
+
__exportStar(__webpack_require__(/*! ./RepositoryAttributeSucceededEvent */ "./dist/modules/attributes/events/RepositoryAttributeSucceededEvent.js"), exports);
|
|
989
1409
|
__exportStar(__webpack_require__(/*! ./SharedAttributeCopyCreatedEvent */ "./dist/modules/attributes/events/SharedAttributeCopyCreatedEvent.js"), exports);
|
|
990
1410
|
//# sourceMappingURL=index.js.map
|
|
991
1411
|
|
|
@@ -1019,10 +1439,9 @@ __exportStar(__webpack_require__(/*! ./events */ "./dist/modules/attributes/even
|
|
|
1019
1439
|
__exportStar(__webpack_require__(/*! ./local/CreateLocalAttributeParams */ "./dist/modules/attributes/local/CreateLocalAttributeParams.js"), exports);
|
|
1020
1440
|
__exportStar(__webpack_require__(/*! ./local/CreatePeerLocalAttributeParams */ "./dist/modules/attributes/local/CreatePeerLocalAttributeParams.js"), exports);
|
|
1021
1441
|
__exportStar(__webpack_require__(/*! ./local/CreateSharedLocalAttributeCopyParams */ "./dist/modules/attributes/local/CreateSharedLocalAttributeCopyParams.js"), exports);
|
|
1442
|
+
__exportStar(__webpack_require__(/*! ./local/IAttributeSuccessorParams */ "./dist/modules/attributes/local/IAttributeSuccessorParams.js"), exports);
|
|
1022
1443
|
__exportStar(__webpack_require__(/*! ./local/LocalAttribute */ "./dist/modules/attributes/local/LocalAttribute.js"), exports);
|
|
1023
1444
|
__exportStar(__webpack_require__(/*! ./local/LocalAttributeShareInfo */ "./dist/modules/attributes/local/LocalAttributeShareInfo.js"), exports);
|
|
1024
|
-
__exportStar(__webpack_require__(/*! ./local/SucceedLocalAttributeParams */ "./dist/modules/attributes/local/SucceedLocalAttributeParams.js"), exports);
|
|
1025
|
-
__exportStar(__webpack_require__(/*! ./local/UpdateLocalAttributeParams */ "./dist/modules/attributes/local/UpdateLocalAttributeParams.js"), exports);
|
|
1026
1445
|
//# sourceMappingURL=index.js.map
|
|
1027
1446
|
|
|
1028
1447
|
/***/ }),
|
|
@@ -1049,22 +1468,38 @@ exports.CreateLocalAttributeParams = void 0;
|
|
|
1049
1468
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
1050
1469
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
1051
1470
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
1471
|
+
const LocalAttributeShareInfo_1 = __webpack_require__(/*! ./LocalAttributeShareInfo */ "./dist/modules/attributes/local/LocalAttributeShareInfo.js");
|
|
1052
1472
|
class CreateLocalAttributeParams extends ts_serval_1.Serializable {
|
|
1053
1473
|
static from(value) {
|
|
1054
1474
|
return this.fromAny(value);
|
|
1055
1475
|
}
|
|
1056
1476
|
}
|
|
1057
1477
|
exports.CreateLocalAttributeParams = CreateLocalAttributeParams;
|
|
1478
|
+
__decorate([
|
|
1479
|
+
(0, ts_serval_1.serialize)(),
|
|
1480
|
+
(0, ts_serval_1.validate)({ nullable: true }),
|
|
1481
|
+
__metadata("design:type", transport_1.CoreId)
|
|
1482
|
+
], CreateLocalAttributeParams.prototype, "id", void 0);
|
|
1058
1483
|
__decorate([
|
|
1059
1484
|
(0, ts_serval_1.serialize)({ unionTypes: [content_1.IdentityAttribute, content_1.RelationshipAttribute] }),
|
|
1060
1485
|
(0, ts_serval_1.validate)(),
|
|
1061
1486
|
__metadata("design:type", Object)
|
|
1062
1487
|
], CreateLocalAttributeParams.prototype, "content", void 0);
|
|
1063
1488
|
__decorate([
|
|
1064
|
-
(0, ts_serval_1.serialize)(
|
|
1065
|
-
(0, ts_serval_1.validate)(),
|
|
1489
|
+
(0, ts_serval_1.serialize)(),
|
|
1490
|
+
(0, ts_serval_1.validate)({ nullable: true }),
|
|
1066
1491
|
__metadata("design:type", transport_1.CoreId)
|
|
1067
1492
|
], CreateLocalAttributeParams.prototype, "parentId", void 0);
|
|
1493
|
+
__decorate([
|
|
1494
|
+
(0, ts_serval_1.serialize)(),
|
|
1495
|
+
(0, ts_serval_1.validate)({ nullable: true }),
|
|
1496
|
+
__metadata("design:type", transport_1.CoreId)
|
|
1497
|
+
], CreateLocalAttributeParams.prototype, "succeeds", void 0);
|
|
1498
|
+
__decorate([
|
|
1499
|
+
(0, ts_serval_1.serialize)(),
|
|
1500
|
+
(0, ts_serval_1.validate)({ nullable: true }),
|
|
1501
|
+
__metadata("design:type", LocalAttributeShareInfo_1.LocalAttributeShareInfo)
|
|
1502
|
+
], CreateLocalAttributeParams.prototype, "shareInfo", void 0);
|
|
1068
1503
|
//# sourceMappingURL=CreateLocalAttributeParams.js.map
|
|
1069
1504
|
|
|
1070
1505
|
/***/ }),
|
|
@@ -1172,6 +1607,19 @@ __decorate([
|
|
|
1172
1607
|
|
|
1173
1608
|
/***/ }),
|
|
1174
1609
|
|
|
1610
|
+
/***/ "./dist/modules/attributes/local/IAttributeSuccessorParams.js":
|
|
1611
|
+
/*!********************************************************************!*\
|
|
1612
|
+
!*** ./dist/modules/attributes/local/IAttributeSuccessorParams.js ***!
|
|
1613
|
+
\********************************************************************/
|
|
1614
|
+
/***/ ((__unused_webpack_module, exports) => {
|
|
1615
|
+
|
|
1616
|
+
"use strict";
|
|
1617
|
+
|
|
1618
|
+
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1619
|
+
//# sourceMappingURL=IAttributeSuccessorParams.js.map
|
|
1620
|
+
|
|
1621
|
+
/***/ }),
|
|
1622
|
+
|
|
1175
1623
|
/***/ "./dist/modules/attributes/local/LocalAttribute.js":
|
|
1176
1624
|
/*!*********************************************************!*\
|
|
1177
1625
|
!*** ./dist/modules/attributes/local/LocalAttribute.js ***!
|
|
@@ -1211,26 +1659,60 @@ let LocalAttribute = class LocalAttribute extends transport_1.CoreSynchronizable
|
|
|
1211
1659
|
];
|
|
1212
1660
|
this.userdataProperties = [(0, ts_simple_nameof_1.nameof)((r) => r.content)];
|
|
1213
1661
|
}
|
|
1662
|
+
isOwnSharedIdentityAttribute(ownAddress, peerAddress) {
|
|
1663
|
+
return this.isIdentityAttribute() && this.isOwnSharedAttribute(ownAddress, peerAddress);
|
|
1664
|
+
}
|
|
1665
|
+
isOwnSharedRelationshipAttribute(ownAddress, peerAddress) {
|
|
1666
|
+
return this.isRelationshipAttribute() && this.isOwnSharedAttribute(ownAddress, peerAddress);
|
|
1667
|
+
}
|
|
1668
|
+
isPeerSharedIdentityAttribute(peerAddress) {
|
|
1669
|
+
return this.isIdentityAttribute() && this.isPeerSharedAttribute(peerAddress);
|
|
1670
|
+
}
|
|
1671
|
+
isPeerSharedRelationshipAttribute(peerAddress) {
|
|
1672
|
+
return this.isRelationshipAttribute() && this.isPeerSharedAttribute(peerAddress);
|
|
1673
|
+
}
|
|
1674
|
+
isRepositoryAttribute() {
|
|
1675
|
+
return this.isIdentityAttribute() && !this.isShared();
|
|
1676
|
+
}
|
|
1677
|
+
isOwnSharedAttribute(ownAddress, peerAddress) {
|
|
1678
|
+
let isOwnSharedAttribute = this.isShared() && this.isOwnedBy(ownAddress);
|
|
1679
|
+
if (!isOwnSharedAttribute) {
|
|
1680
|
+
return isOwnSharedAttribute;
|
|
1681
|
+
}
|
|
1682
|
+
if (this.isIdentityAttribute()) {
|
|
1683
|
+
isOwnSharedAttribute &&= typeof this.shareInfo.sourceAttribute !== "undefined";
|
|
1684
|
+
}
|
|
1685
|
+
if (typeof peerAddress !== "undefined") {
|
|
1686
|
+
isOwnSharedAttribute &&= this.shareInfo.peer.equals(ownAddress);
|
|
1687
|
+
}
|
|
1688
|
+
return isOwnSharedAttribute;
|
|
1689
|
+
}
|
|
1690
|
+
isPeerSharedAttribute(peerAddress) {
|
|
1691
|
+
let isPeerSharedAttribute = this.isShared() && this.isOwnedBy(this.shareInfo.peer);
|
|
1692
|
+
if (!isPeerSharedAttribute) {
|
|
1693
|
+
return isPeerSharedAttribute;
|
|
1694
|
+
}
|
|
1695
|
+
if (this.isIdentityAttribute()) {
|
|
1696
|
+
isPeerSharedAttribute &&= typeof this.shareInfo.sourceAttribute === "undefined";
|
|
1697
|
+
}
|
|
1698
|
+
if (typeof peerAddress !== "undefined") {
|
|
1699
|
+
isPeerSharedAttribute &&= this.isOwnedBy(peerAddress);
|
|
1700
|
+
}
|
|
1701
|
+
return isPeerSharedAttribute;
|
|
1702
|
+
}
|
|
1214
1703
|
isIdentityAttribute() {
|
|
1215
1704
|
return this.content instanceof content_1.IdentityAttribute;
|
|
1216
1705
|
}
|
|
1217
1706
|
isRelationshipAttribute() {
|
|
1218
|
-
return this.content instanceof content_1.RelationshipAttribute
|
|
1707
|
+
return (this.content instanceof content_1.RelationshipAttribute &&
|
|
1708
|
+
this.isShared() &&
|
|
1709
|
+
typeof this.shareInfo.sourceAttribute === "undefined");
|
|
1219
1710
|
}
|
|
1220
1711
|
isOwnedBy(identity) {
|
|
1221
1712
|
return this.content.owner.equals(identity);
|
|
1222
1713
|
}
|
|
1223
|
-
isRepositoryAttribute() {
|
|
1224
|
-
return this.isIdentityAttribute() && !this.isShared();
|
|
1225
|
-
}
|
|
1226
1714
|
isShared() {
|
|
1227
|
-
return this.shareInfo !== undefined;
|
|
1228
|
-
}
|
|
1229
|
-
isSharedWith(address) {
|
|
1230
|
-
if (!this.isShared()) {
|
|
1231
|
-
return false;
|
|
1232
|
-
}
|
|
1233
|
-
return this.shareInfo.peer === address;
|
|
1715
|
+
return typeof this.shareInfo !== "undefined";
|
|
1234
1716
|
}
|
|
1235
1717
|
static from(value) {
|
|
1236
1718
|
return this.fromAny(value);
|
|
@@ -1305,25 +1787,44 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
1305
1787
|
exports.LocalAttributeShareInfo = void 0;
|
|
1306
1788
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
1307
1789
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
1790
|
+
const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
|
|
1791
|
+
const ConsumptionError_1 = __webpack_require__(/*! ../../../consumption/ConsumptionError */ "./dist/consumption/ConsumptionError.js");
|
|
1308
1792
|
class LocalAttributeShareInfo extends transport_1.CoreSerializable {
|
|
1309
1793
|
static from(value) {
|
|
1310
1794
|
return super.fromAny(value);
|
|
1311
1795
|
}
|
|
1796
|
+
static postFrom(value) {
|
|
1797
|
+
if (!(value instanceof LocalAttributeShareInfo)) {
|
|
1798
|
+
throw new ConsumptionError_1.ConsumptionError("this should never happen");
|
|
1799
|
+
}
|
|
1800
|
+
if (typeof value.requestReference === "undefined" && typeof value.notificationReference === "undefined") {
|
|
1801
|
+
throw new ts_serval_1.ValidationError(LocalAttributeShareInfo.name, (0, ts_simple_nameof_1.nameof)((x) => x.requestReference), `One of ${(0, ts_simple_nameof_1.nameof)((x) => x.requestReference)} or ${(0, ts_simple_nameof_1.nameof)((x) => x.notificationReference)} must be set.`);
|
|
1802
|
+
}
|
|
1803
|
+
if (typeof value.requestReference !== "undefined" && typeof value.notificationReference !== "undefined") {
|
|
1804
|
+
throw new ts_serval_1.ValidationError(LocalAttributeShareInfo.name, (0, ts_simple_nameof_1.nameof)((x) => x.requestReference), `Both of ${(0, ts_simple_nameof_1.nameof)((x) => x.requestReference)} or ${(0, ts_simple_nameof_1.nameof)((x) => x.notificationReference)} must not be set.`);
|
|
1805
|
+
}
|
|
1806
|
+
return value;
|
|
1807
|
+
}
|
|
1312
1808
|
}
|
|
1313
1809
|
exports.LocalAttributeShareInfo = LocalAttributeShareInfo;
|
|
1314
1810
|
__decorate([
|
|
1315
|
-
(0, ts_serval_1.validate)(),
|
|
1316
1811
|
(0, ts_serval_1.serialize)(),
|
|
1812
|
+
(0, ts_serval_1.validate)({ nullable: true }),
|
|
1317
1813
|
__metadata("design:type", transport_1.CoreId)
|
|
1318
1814
|
], LocalAttributeShareInfo.prototype, "requestReference", void 0);
|
|
1815
|
+
__decorate([
|
|
1816
|
+
(0, ts_serval_1.serialize)(),
|
|
1817
|
+
(0, ts_serval_1.validate)({ nullable: true }),
|
|
1818
|
+
__metadata("design:type", transport_1.CoreId)
|
|
1819
|
+
], LocalAttributeShareInfo.prototype, "notificationReference", void 0);
|
|
1319
1820
|
__decorate([
|
|
1320
1821
|
(0, ts_serval_1.validate)(),
|
|
1321
1822
|
(0, ts_serval_1.serialize)(),
|
|
1322
1823
|
__metadata("design:type", transport_1.CoreAddress)
|
|
1323
1824
|
], LocalAttributeShareInfo.prototype, "peer", void 0);
|
|
1324
1825
|
__decorate([
|
|
1325
|
-
(0, ts_serval_1.validate)({ nullable: true }),
|
|
1326
1826
|
(0, ts_serval_1.serialize)(),
|
|
1827
|
+
(0, ts_serval_1.validate)({ nullable: true }),
|
|
1327
1828
|
__metadata("design:type", transport_1.CoreId)
|
|
1328
1829
|
], LocalAttributeShareInfo.prototype, "sourceAttribute", void 0);
|
|
1329
1830
|
//# sourceMappingURL=LocalAttributeShareInfo.js.map
|
|
@@ -1510,87 +2011,82 @@ ThirdPartyRelationshipAttributeQueryTranslator.translator = new docdb_querytrans
|
|
|
1510
2011
|
|
|
1511
2012
|
/***/ }),
|
|
1512
2013
|
|
|
1513
|
-
/***/ "./dist/modules/
|
|
1514
|
-
|
|
1515
|
-
!*** ./dist/modules/
|
|
1516
|
-
|
|
1517
|
-
/***/ (
|
|
2014
|
+
/***/ "./dist/modules/common/ValidationResult.js":
|
|
2015
|
+
/*!*************************************************!*\
|
|
2016
|
+
!*** ./dist/modules/common/ValidationResult.js ***!
|
|
2017
|
+
\*************************************************/
|
|
2018
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1518
2019
|
|
|
1519
2020
|
"use strict";
|
|
1520
2021
|
|
|
1521
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
1522
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1523
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1524
|
-
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
1525
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1526
|
-
};
|
|
1527
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
1528
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1529
|
-
};
|
|
1530
2022
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1531
|
-
exports.
|
|
1532
|
-
const
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
2023
|
+
exports.ErrorValidationResult = exports.SuccessfulValidationResult = exports.ValidationResult = void 0;
|
|
2024
|
+
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
2025
|
+
class ValidationResult {
|
|
2026
|
+
constructor(items) {
|
|
2027
|
+
this.items = items;
|
|
2028
|
+
}
|
|
2029
|
+
isSuccess() {
|
|
2030
|
+
return this instanceof SuccessfulValidationResult;
|
|
2031
|
+
}
|
|
2032
|
+
isError() {
|
|
2033
|
+
return this instanceof ErrorValidationResult;
|
|
2034
|
+
}
|
|
2035
|
+
static success(items = []) {
|
|
2036
|
+
return new SuccessfulValidationResult(items);
|
|
2037
|
+
}
|
|
2038
|
+
static error(error, items = []) {
|
|
2039
|
+
return new ErrorValidationResult(error, items);
|
|
2040
|
+
}
|
|
2041
|
+
static fromItems(items) {
|
|
2042
|
+
return items.some((r) => r.isError())
|
|
2043
|
+
? ValidationResult.error(new ts_utils_1.ApplicationError("inheritedFromItem", "Some child items have errors."), items)
|
|
2044
|
+
: ValidationResult.success(items);
|
|
1538
2045
|
}
|
|
1539
2046
|
}
|
|
1540
|
-
exports.
|
|
1541
|
-
|
|
1542
|
-
(
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
(
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
2047
|
+
exports.ValidationResult = ValidationResult;
|
|
2048
|
+
class SuccessfulValidationResult extends ValidationResult {
|
|
2049
|
+
constructor(items) {
|
|
2050
|
+
super(items);
|
|
2051
|
+
}
|
|
2052
|
+
}
|
|
2053
|
+
exports.SuccessfulValidationResult = SuccessfulValidationResult;
|
|
2054
|
+
class ErrorValidationResult extends ValidationResult {
|
|
2055
|
+
constructor(error, items) {
|
|
2056
|
+
super(items);
|
|
2057
|
+
this.error = error;
|
|
2058
|
+
}
|
|
2059
|
+
}
|
|
2060
|
+
exports.ErrorValidationResult = ErrorValidationResult;
|
|
2061
|
+
//# sourceMappingURL=ValidationResult.js.map
|
|
1552
2062
|
|
|
1553
2063
|
/***/ }),
|
|
1554
2064
|
|
|
1555
|
-
/***/ "./dist/modules/
|
|
1556
|
-
|
|
1557
|
-
!*** ./dist/modules/
|
|
1558
|
-
|
|
2065
|
+
/***/ "./dist/modules/common/index.js":
|
|
2066
|
+
/*!**************************************!*\
|
|
2067
|
+
!*** ./dist/modules/common/index.js ***!
|
|
2068
|
+
\**************************************/
|
|
1559
2069
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
1560
2070
|
|
|
1561
2071
|
"use strict";
|
|
1562
2072
|
|
|
1563
|
-
var
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
}
|
|
1569
|
-
|
|
1570
|
-
|
|
2073
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
2074
|
+
if (k2 === undefined) k2 = k;
|
|
2075
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
2076
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
2077
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
2078
|
+
}
|
|
2079
|
+
Object.defineProperty(o, k2, desc);
|
|
2080
|
+
}) : (function(o, m, k, k2) {
|
|
2081
|
+
if (k2 === undefined) k2 = k;
|
|
2082
|
+
o[k2] = m[k];
|
|
2083
|
+
}));
|
|
2084
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
2085
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
1571
2086
|
};
|
|
1572
2087
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
1576
|
-
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
1577
|
-
class UpdateLocalAttributeParams extends ts_serval_1.Serializable {
|
|
1578
|
-
static from(value) {
|
|
1579
|
-
return this.fromAny(value);
|
|
1580
|
-
}
|
|
1581
|
-
}
|
|
1582
|
-
exports.UpdateLocalAttributeParams = UpdateLocalAttributeParams;
|
|
1583
|
-
__decorate([
|
|
1584
|
-
(0, ts_serval_1.serialize)(),
|
|
1585
|
-
(0, ts_serval_1.validate)(),
|
|
1586
|
-
__metadata("design:type", transport_1.CoreId)
|
|
1587
|
-
], UpdateLocalAttributeParams.prototype, "id", void 0);
|
|
1588
|
-
__decorate([
|
|
1589
|
-
(0, ts_serval_1.serialize)({ unionTypes: [content_1.IdentityAttribute, content_1.RelationshipAttribute] }),
|
|
1590
|
-
(0, ts_serval_1.validate)(),
|
|
1591
|
-
__metadata("design:type", Object)
|
|
1592
|
-
], UpdateLocalAttributeParams.prototype, "content", void 0);
|
|
1593
|
-
//# sourceMappingURL=UpdateLocalAttributeParams.js.map
|
|
2088
|
+
__exportStar(__webpack_require__(/*! ./ValidationResult */ "./dist/modules/common/ValidationResult.js"), exports);
|
|
2089
|
+
//# sourceMappingURL=index.js.map
|
|
1594
2090
|
|
|
1595
2091
|
/***/ }),
|
|
1596
2092
|
|
|
@@ -1788,6 +2284,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
1788
2284
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1789
2285
|
__exportStar(__webpack_require__(/*! ./attributeListeners */ "./dist/modules/attributeListeners/index.js"), exports);
|
|
1790
2286
|
__exportStar(__webpack_require__(/*! ./attributes */ "./dist/modules/attributes/index.js"), exports);
|
|
2287
|
+
__exportStar(__webpack_require__(/*! ./common */ "./dist/modules/common/index.js"), exports);
|
|
1791
2288
|
__exportStar(__webpack_require__(/*! ./drafts */ "./dist/modules/drafts/index.js"), exports);
|
|
1792
2289
|
__exportStar(__webpack_require__(/*! ./notifications */ "./dist/modules/notifications/index.js"), exports);
|
|
1793
2290
|
__exportStar(__webpack_require__(/*! ./requests */ "./dist/modules/requests/index.js"), exports);
|
|
@@ -1906,14 +2403,13 @@ class NotificationsController extends ConsumptionBaseController_1.ConsumptionBas
|
|
|
1906
2403
|
try {
|
|
1907
2404
|
for (const item of notification.content.items) {
|
|
1908
2405
|
const processor = this.processorRegistry.getProcessorForItem(item);
|
|
1909
|
-
const
|
|
1910
|
-
if (
|
|
2406
|
+
const checkResult = await processor.checkPrerequisitesOfIncomingNotificationItem(item, notification);
|
|
2407
|
+
if (checkResult.isError()) {
|
|
1911
2408
|
const index = notification.content.items.indexOf(item);
|
|
1912
2409
|
throw new Error(`Prerequisites of notificationItem with index '${index}' of Notification ${notification.id} not met.`);
|
|
1913
2410
|
}
|
|
1914
|
-
|
|
2411
|
+
const event = await processor.process(item, notification);
|
|
1915
2412
|
processedItems.push(item);
|
|
1916
|
-
const event = await processor.process(item);
|
|
1917
2413
|
if (event)
|
|
1918
2414
|
events.push(event);
|
|
1919
2415
|
}
|
|
@@ -1922,7 +2418,7 @@ class NotificationsController extends ConsumptionBaseController_1.ConsumptionBas
|
|
|
1922
2418
|
this._log.error(`Error while processing notification ${notification.id}: ${e}`);
|
|
1923
2419
|
for (const item of processedItems.reverse()) {
|
|
1924
2420
|
const processor = this.processorRegistry.getProcessorForItem(item);
|
|
1925
|
-
await processor.rollback(item);
|
|
2421
|
+
await processor.rollback(item, notification);
|
|
1926
2422
|
}
|
|
1927
2423
|
notification.status = LocalNotification_1.LocalNotificationStatus.Error;
|
|
1928
2424
|
await this.localNotifications.update(oldDoc, notification);
|
|
@@ -2071,17 +2567,77 @@ exports.NotificationItemProcessorRegistry = NotificationItemProcessorRegistry;
|
|
|
2071
2567
|
|
|
2072
2568
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2073
2569
|
exports.AttributeSucceededNotificationItemProcessor = void 0;
|
|
2570
|
+
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
2571
|
+
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
2572
|
+
const CoreErrors_1 = __webpack_require__(/*! ../../../../consumption/CoreErrors */ "./dist/consumption/CoreErrors.js");
|
|
2573
|
+
const attributes_1 = __webpack_require__(/*! ../../../attributes */ "./dist/modules/attributes/index.js");
|
|
2574
|
+
const common_1 = __webpack_require__(/*! ../../../common */ "./dist/modules/common/index.js");
|
|
2074
2575
|
const AbstractNotificationItemProcessor_1 = __webpack_require__(/*! ../AbstractNotificationItemProcessor */ "./dist/modules/notifications/itemProcessors/AbstractNotificationItemProcessor.js");
|
|
2075
2576
|
class AttributeSucceededNotificationItemProcessor extends AbstractNotificationItemProcessor_1.AbstractNotificationItemProcessor {
|
|
2076
|
-
|
|
2077
|
-
|
|
2577
|
+
constructor(consumptionController) {
|
|
2578
|
+
super(consumptionController);
|
|
2579
|
+
this._logger = transport_1.TransportLoggerFactory.getLogger(AttributeSucceededNotificationItemProcessor);
|
|
2580
|
+
}
|
|
2581
|
+
async checkPrerequisitesOfIncomingNotificationItem(notificationItem, notification) {
|
|
2582
|
+
if (!notification.peer.equals(notificationItem.attribute.owner)) {
|
|
2583
|
+
return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successionPeerIsNotOwner());
|
|
2584
|
+
}
|
|
2585
|
+
const successorParams = {
|
|
2586
|
+
id: notificationItem.newAttributeId,
|
|
2587
|
+
content: notificationItem.attribute,
|
|
2588
|
+
shareInfo: { requestReference: notification.id, peer: notification.peer }
|
|
2589
|
+
};
|
|
2590
|
+
if (notificationItem.attribute instanceof content_1.IdentityAttribute) {
|
|
2591
|
+
const validationResult = await this.consumptionController.attributes.validatePeerSharedIdentityAttributeSuccession(notificationItem.succeededAttributeId, successorParams);
|
|
2592
|
+
return validationResult;
|
|
2593
|
+
}
|
|
2594
|
+
const validationResult = await this.consumptionController.attributes.validatePeerSharedRelationshipAttributeSuccession(notificationItem.succeededAttributeId, successorParams);
|
|
2595
|
+
return validationResult;
|
|
2596
|
+
}
|
|
2597
|
+
async process(notificationItem, notification) {
|
|
2598
|
+
const successorParams = {
|
|
2599
|
+
id: notificationItem.newAttributeId,
|
|
2600
|
+
content: notificationItem.attribute,
|
|
2601
|
+
shareInfo: { requestReference: notification.id, peer: notification.peer }
|
|
2602
|
+
};
|
|
2603
|
+
let predecessor;
|
|
2604
|
+
let successor;
|
|
2605
|
+
try {
|
|
2606
|
+
if (notificationItem.attribute instanceof content_1.IdentityAttribute) {
|
|
2607
|
+
;
|
|
2608
|
+
({ predecessor, successor } =
|
|
2609
|
+
await this.consumptionController.attributes.succeedPeerSharedIdentityAttribute(notificationItem.succeededAttributeId, successorParams, false));
|
|
2610
|
+
}
|
|
2611
|
+
else {
|
|
2612
|
+
;
|
|
2613
|
+
({ predecessor, successor } =
|
|
2614
|
+
await this.consumptionController.attributes.succeedPeerSharedRelationshipAttribute(notificationItem.succeededAttributeId, successorParams, false));
|
|
2615
|
+
}
|
|
2616
|
+
}
|
|
2617
|
+
catch (e) {
|
|
2618
|
+
await this.rollbackPartialWork(notificationItem, notification).catch((e) => this._logger.error(`Rollback failed for notification item (notification id: ${notification.id}).`, e));
|
|
2619
|
+
throw e;
|
|
2620
|
+
}
|
|
2621
|
+
const myAddress = this.consumptionController.accountController.identity.address;
|
|
2622
|
+
return new attributes_1.PeerSharedAttributeSucceededEvent(myAddress.toString(), predecessor, successor);
|
|
2078
2623
|
}
|
|
2079
|
-
|
|
2080
|
-
|
|
2081
|
-
throw new Error("Method not implemented.");
|
|
2624
|
+
async rollback(notificationItem, notification) {
|
|
2625
|
+
await this.rollbackPartialWork(notificationItem, notification);
|
|
2082
2626
|
}
|
|
2083
|
-
|
|
2084
|
-
|
|
2627
|
+
async rollbackPartialWork(notificationItem, _notification) {
|
|
2628
|
+
const successor = await this.consumptionController.attributes.getLocalAttribute(notificationItem.newAttributeId);
|
|
2629
|
+
if (typeof successor !== "undefined") {
|
|
2630
|
+
await this.consumptionController.attributes
|
|
2631
|
+
.deleteAttributeUnsafe(successor.id)
|
|
2632
|
+
.catch((e) => this._logger.error(`Deletion failed for attribute (attribute id: ${successor.id}).`, e));
|
|
2633
|
+
}
|
|
2634
|
+
const predecessor = await this.consumptionController.attributes.getLocalAttribute(notificationItem.succeededAttributeId);
|
|
2635
|
+
if (typeof predecessor?.succeededBy !== "undefined") {
|
|
2636
|
+
predecessor.succeededBy = undefined;
|
|
2637
|
+
await this.consumptionController.attributes
|
|
2638
|
+
.updateAttributeUnsafe(predecessor)
|
|
2639
|
+
.catch((e) => this._logger.error(`Update failed for attribute (attribute id: ${notificationItem.succeededAttributeId}).`, e));
|
|
2640
|
+
}
|
|
2085
2641
|
}
|
|
2086
2642
|
}
|
|
2087
2643
|
exports.AttributeSucceededNotificationItemProcessor = AttributeSucceededNotificationItemProcessor;
|
|
@@ -2417,7 +2973,7 @@ exports.DecideRequestParametersValidator = void 0;
|
|
|
2417
2973
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
2418
2974
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
2419
2975
|
const CoreErrors_1 = __webpack_require__(/*! ../../../consumption/CoreErrors */ "./dist/consumption/CoreErrors.js");
|
|
2420
|
-
const ValidationResult_1 = __webpack_require__(/*!
|
|
2976
|
+
const ValidationResult_1 = __webpack_require__(/*! ../../common/ValidationResult */ "./dist/modules/common/ValidationResult.js");
|
|
2421
2977
|
const DecideRequestItemGroupParameters_1 = __webpack_require__(/*! ./decide/DecideRequestItemGroupParameters */ "./dist/modules/requests/incoming/decide/DecideRequestItemGroupParameters.js");
|
|
2422
2978
|
const DecideRequestItemParameters_1 = __webpack_require__(/*! ./decide/DecideRequestItemParameters */ "./dist/modules/requests/incoming/decide/DecideRequestItemParameters.js");
|
|
2423
2979
|
class DecideRequestParametersValidator {
|
|
@@ -2490,8 +3046,8 @@ const ConsumptionControllerName_1 = __webpack_require__(/*! ../../../consumption
|
|
|
2490
3046
|
const ConsumptionError_1 = __webpack_require__(/*! ../../../consumption/ConsumptionError */ "./dist/consumption/ConsumptionError.js");
|
|
2491
3047
|
const ConsumptionIds_1 = __webpack_require__(/*! ../../../consumption/ConsumptionIds */ "./dist/consumption/ConsumptionIds.js");
|
|
2492
3048
|
const CoreErrors_1 = __webpack_require__(/*! ../../../consumption/CoreErrors */ "./dist/consumption/CoreErrors.js");
|
|
3049
|
+
const ValidationResult_1 = __webpack_require__(/*! ../../common/ValidationResult */ "./dist/modules/common/ValidationResult.js");
|
|
2493
3050
|
const events_1 = __webpack_require__(/*! ../events */ "./dist/modules/requests/events/index.js");
|
|
2494
|
-
const ValidationResult_1 = __webpack_require__(/*! ../itemProcessors/ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
2495
3051
|
const LocalRequest_1 = __webpack_require__(/*! ../local/LocalRequest */ "./dist/modules/requests/local/LocalRequest.js");
|
|
2496
3052
|
const LocalRequestStatus_1 = __webpack_require__(/*! ../local/LocalRequestStatus */ "./dist/modules/requests/local/LocalRequestStatus.js");
|
|
2497
3053
|
const LocalResponse_1 = __webpack_require__(/*! ../local/LocalResponse */ "./dist/modules/requests/local/LocalResponse.js");
|
|
@@ -3127,7 +3683,6 @@ __exportStar(__webpack_require__(/*! ./itemProcessors/IRequestItemProcessor */ "
|
|
|
3127
3683
|
__exportStar(__webpack_require__(/*! ./itemProcessors/RequestItemConstructor */ "./dist/modules/requests/itemProcessors/RequestItemConstructor.js"), exports);
|
|
3128
3684
|
__exportStar(__webpack_require__(/*! ./itemProcessors/RequestItemProcessorConstructor */ "./dist/modules/requests/itemProcessors/RequestItemProcessorConstructor.js"), exports);
|
|
3129
3685
|
__exportStar(__webpack_require__(/*! ./itemProcessors/RequestItemProcessorRegistry */ "./dist/modules/requests/itemProcessors/RequestItemProcessorRegistry.js"), exports);
|
|
3130
|
-
__exportStar(__webpack_require__(/*! ./itemProcessors/ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js"), exports);
|
|
3131
3686
|
__exportStar(__webpack_require__(/*! ./itemProcessors/createAttribute/CreateAttributeRequestItemProcessor */ "./dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js"), exports);
|
|
3132
3687
|
__exportStar(__webpack_require__(/*! ./itemProcessors/freeText/AcceptFreeTextRequestItemParameters */ "./dist/modules/requests/itemProcessors/freeText/AcceptFreeTextRequestItemParameters.js"), exports);
|
|
3133
3688
|
__exportStar(__webpack_require__(/*! ./itemProcessors/freeText/FreeTextRequestItemProcessor */ "./dist/modules/requests/itemProcessors/freeText/FreeTextRequestItemProcessor.js"), exports);
|
|
@@ -3184,8 +3739,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
3184
3739
|
exports.GenericRequestItemProcessor = void 0;
|
|
3185
3740
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
3186
3741
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
3742
|
+
const ValidationResult_1 = __webpack_require__(/*! ../../common/ValidationResult */ "./dist/modules/common/ValidationResult.js");
|
|
3187
3743
|
const AbstractRequestItemProcessor_1 = __webpack_require__(/*! ./AbstractRequestItemProcessor */ "./dist/modules/requests/itemProcessors/AbstractRequestItemProcessor.js");
|
|
3188
|
-
const ValidationResult_1 = __webpack_require__(/*! ./ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
3189
3744
|
class GenericRequestItemProcessor extends AbstractRequestItemProcessor_1.AbstractRequestItemProcessor {
|
|
3190
3745
|
checkPrerequisitesOfIncomingRequestItem(requestItem, requestInfo) {
|
|
3191
3746
|
return true;
|
|
@@ -3294,57 +3849,6 @@ exports.RequestItemProcessorRegistry = RequestItemProcessorRegistry;
|
|
|
3294
3849
|
|
|
3295
3850
|
/***/ }),
|
|
3296
3851
|
|
|
3297
|
-
/***/ "./dist/modules/requests/itemProcessors/ValidationResult.js":
|
|
3298
|
-
/*!******************************************************************!*\
|
|
3299
|
-
!*** ./dist/modules/requests/itemProcessors/ValidationResult.js ***!
|
|
3300
|
-
\******************************************************************/
|
|
3301
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
3302
|
-
|
|
3303
|
-
"use strict";
|
|
3304
|
-
|
|
3305
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3306
|
-
exports.ErrorValidationResult = exports.SuccessfulValidationResult = exports.ValidationResult = void 0;
|
|
3307
|
-
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
3308
|
-
class ValidationResult {
|
|
3309
|
-
constructor(items) {
|
|
3310
|
-
this.items = items;
|
|
3311
|
-
}
|
|
3312
|
-
isSuccess() {
|
|
3313
|
-
return this instanceof SuccessfulValidationResult;
|
|
3314
|
-
}
|
|
3315
|
-
isError() {
|
|
3316
|
-
return this instanceof ErrorValidationResult;
|
|
3317
|
-
}
|
|
3318
|
-
static success(items = []) {
|
|
3319
|
-
return new SuccessfulValidationResult(items);
|
|
3320
|
-
}
|
|
3321
|
-
static error(error, items = []) {
|
|
3322
|
-
return new ErrorValidationResult(error, items);
|
|
3323
|
-
}
|
|
3324
|
-
static fromItems(items) {
|
|
3325
|
-
return items.some((r) => r.isError())
|
|
3326
|
-
? ValidationResult.error(new ts_utils_1.ApplicationError("inheritedFromItem", "Some child items have errors."), items)
|
|
3327
|
-
: ValidationResult.success(items);
|
|
3328
|
-
}
|
|
3329
|
-
}
|
|
3330
|
-
exports.ValidationResult = ValidationResult;
|
|
3331
|
-
class SuccessfulValidationResult extends ValidationResult {
|
|
3332
|
-
constructor(items) {
|
|
3333
|
-
super(items);
|
|
3334
|
-
}
|
|
3335
|
-
}
|
|
3336
|
-
exports.SuccessfulValidationResult = SuccessfulValidationResult;
|
|
3337
|
-
class ErrorValidationResult extends ValidationResult {
|
|
3338
|
-
constructor(error, items) {
|
|
3339
|
-
super(items);
|
|
3340
|
-
this.error = error;
|
|
3341
|
-
}
|
|
3342
|
-
}
|
|
3343
|
-
exports.ErrorValidationResult = ErrorValidationResult;
|
|
3344
|
-
//# sourceMappingURL=ValidationResult.js.map
|
|
3345
|
-
|
|
3346
|
-
/***/ }),
|
|
3347
|
-
|
|
3348
3852
|
/***/ "./dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js":
|
|
3349
3853
|
/*!*****************************************************************************************************!*\
|
|
3350
3854
|
!*** ./dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js ***!
|
|
@@ -3357,8 +3861,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
3357
3861
|
exports.CreateAttributeRequestItemProcessor = void 0;
|
|
3358
3862
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
3359
3863
|
const CoreErrors_1 = __webpack_require__(/*! ../../../../consumption/CoreErrors */ "./dist/consumption/CoreErrors.js");
|
|
3864
|
+
const ValidationResult_1 = __webpack_require__(/*! ../../../common/ValidationResult */ "./dist/modules/common/ValidationResult.js");
|
|
3360
3865
|
const GenericRequestItemProcessor_1 = __webpack_require__(/*! ../GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js");
|
|
3361
|
-
const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
3362
3866
|
class CreateAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.GenericRequestItemProcessor {
|
|
3363
3867
|
canCreateOutgoingRequestItem(requestItem, _request, recipient) {
|
|
3364
3868
|
const recipientIsAttributeOwner = requestItem.attribute.owner.equals(recipient);
|
|
@@ -3368,12 +3872,15 @@ class CreateAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.
|
|
|
3368
3872
|
if (senderIsAttributeOwner) {
|
|
3369
3873
|
return ValidationResult_1.ValidationResult.error(CoreErrors_1.CoreErrors.requests.invalidRequestItem("Cannot create own Attributes with a CreateAttributeRequestItem. Use a ShareAttributeRequestItem instead."));
|
|
3370
3874
|
}
|
|
3371
|
-
if (recipientIsAttributeOwner || ownerIsEmptyString || recipient === undefined) {
|
|
3875
|
+
if (recipientIsAttributeOwner || ownerIsEmptyString || typeof recipient === "undefined") {
|
|
3372
3876
|
return ValidationResult_1.ValidationResult.success();
|
|
3373
3877
|
}
|
|
3374
3878
|
return ValidationResult_1.ValidationResult.error(CoreErrors_1.CoreErrors.requests.invalidRequestItem("The owner of the given `attribute` can only be the recipient's address or an empty string. The latter will default to the recipient's address."));
|
|
3375
3879
|
}
|
|
3376
|
-
if (recipientIsAttributeOwner ||
|
|
3880
|
+
if (recipientIsAttributeOwner ||
|
|
3881
|
+
senderIsAttributeOwner ||
|
|
3882
|
+
ownerIsEmptyString ||
|
|
3883
|
+
typeof recipient === "undefined") {
|
|
3377
3884
|
return ValidationResult_1.ValidationResult.success();
|
|
3378
3885
|
}
|
|
3379
3886
|
return ValidationResult_1.ValidationResult.error(CoreErrors_1.CoreErrors.requests.invalidRequestItem("The owner of the given 'attribute' can only be the sender's address, the recipient's address or an empty string. The latter will default to the recipient's address."));
|
|
@@ -3475,8 +3982,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
3475
3982
|
exports.FreeTextRequestItemProcessor = void 0;
|
|
3476
3983
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
3477
3984
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
3985
|
+
const ValidationResult_1 = __webpack_require__(/*! ../../../common/ValidationResult */ "./dist/modules/common/ValidationResult.js");
|
|
3478
3986
|
const GenericRequestItemProcessor_1 = __webpack_require__(/*! ../GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js");
|
|
3479
|
-
const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
3480
3987
|
const CoreErrors_1 = __webpack_require__(/*! ../../../../consumption/CoreErrors */ "./dist/consumption/CoreErrors.js");
|
|
3481
3988
|
const AcceptFreeTextRequestItemParameters_1 = __webpack_require__(/*! ./AcceptFreeTextRequestItemParameters */ "./dist/modules/requests/itemProcessors/freeText/AcceptFreeTextRequestItemParameters.js");
|
|
3482
3989
|
class FreeTextRequestItemProcessor extends GenericRequestItemProcessor_1.GenericRequestItemProcessor {
|
|
@@ -3531,10 +4038,10 @@ const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_m
|
|
|
3531
4038
|
const ConsumptionError_1 = __webpack_require__(/*! ../../../../consumption/ConsumptionError */ "./dist/consumption/ConsumptionError.js");
|
|
3532
4039
|
let AcceptProposeAttributeRequestItemParameters = AcceptProposeAttributeRequestItemParameters_1 = class AcceptProposeAttributeRequestItemParameters extends ts_serval_1.Serializable {
|
|
3533
4040
|
isWithExistingAttribute() {
|
|
3534
|
-
return this.attributeId !== undefined;
|
|
4041
|
+
return typeof this.attributeId !== "undefined";
|
|
3535
4042
|
}
|
|
3536
4043
|
isWithNewAttribute() {
|
|
3537
|
-
return this.attribute !== undefined;
|
|
4044
|
+
return typeof this.attribute !== "undefined";
|
|
3538
4045
|
}
|
|
3539
4046
|
static from(value) {
|
|
3540
4047
|
return this.fromAny(value);
|
|
@@ -3587,8 +4094,8 @@ const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
|
3587
4094
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
3588
4095
|
const CoreErrors_1 = __webpack_require__(/*! ../../../../consumption/CoreErrors */ "./dist/consumption/CoreErrors.js");
|
|
3589
4096
|
const LocalAttribute_1 = __webpack_require__(/*! ../../../attributes/local/LocalAttribute */ "./dist/modules/attributes/local/LocalAttribute.js");
|
|
4097
|
+
const ValidationResult_1 = __webpack_require__(/*! ../../../common/ValidationResult */ "./dist/modules/common/ValidationResult.js");
|
|
3590
4098
|
const GenericRequestItemProcessor_1 = __webpack_require__(/*! ../GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js");
|
|
3591
|
-
const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
3592
4099
|
const validateQuery_1 = __importDefault(__webpack_require__(/*! ../utility/validateQuery */ "./dist/modules/requests/itemProcessors/utility/validateQuery.js"));
|
|
3593
4100
|
const AcceptProposeAttributeRequestItemParameters_1 = __webpack_require__(/*! ./AcceptProposeAttributeRequestItemParameters */ "./dist/modules/requests/itemProcessors/proposeAttribute/AcceptProposeAttributeRequestItemParameters.js");
|
|
3594
4101
|
class ProposeAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.GenericRequestItemProcessor {
|
|
@@ -3719,10 +4226,10 @@ const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_m
|
|
|
3719
4226
|
const ConsumptionError_1 = __webpack_require__(/*! ../../../../consumption/ConsumptionError */ "./dist/consumption/ConsumptionError.js");
|
|
3720
4227
|
let AcceptReadAttributeRequestItemParameters = AcceptReadAttributeRequestItemParameters_1 = class AcceptReadAttributeRequestItemParameters extends ts_serval_1.Serializable {
|
|
3721
4228
|
isWithExistingAttribute() {
|
|
3722
|
-
return this.existingAttributeId !== undefined;
|
|
4229
|
+
return typeof this.existingAttributeId !== "undefined";
|
|
3723
4230
|
}
|
|
3724
4231
|
isWithNewAttribute() {
|
|
3725
|
-
return this.newAttribute !== undefined;
|
|
4232
|
+
return typeof this.newAttribute !== "undefined";
|
|
3726
4233
|
}
|
|
3727
4234
|
static from(value) {
|
|
3728
4235
|
return this.fromAny(value);
|
|
@@ -3775,8 +4282,8 @@ const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
|
3775
4282
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
3776
4283
|
const CoreErrors_1 = __webpack_require__(/*! ../../../../consumption/CoreErrors */ "./dist/consumption/CoreErrors.js");
|
|
3777
4284
|
const LocalAttribute_1 = __webpack_require__(/*! ../../../attributes/local/LocalAttribute */ "./dist/modules/attributes/local/LocalAttribute.js");
|
|
4285
|
+
const ValidationResult_1 = __webpack_require__(/*! ../../../common/ValidationResult */ "./dist/modules/common/ValidationResult.js");
|
|
3778
4286
|
const GenericRequestItemProcessor_1 = __webpack_require__(/*! ../GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js");
|
|
3779
|
-
const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
3780
4287
|
const validateQuery_1 = __importDefault(__webpack_require__(/*! ../utility/validateQuery */ "./dist/modules/requests/itemProcessors/utility/validateQuery.js"));
|
|
3781
4288
|
const AcceptReadAttributeRequestItemParameters_1 = __webpack_require__(/*! ./AcceptReadAttributeRequestItemParameters */ "./dist/modules/requests/itemProcessors/readAttribute/AcceptReadAttributeRequestItemParameters.js");
|
|
3782
4289
|
class ReadAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.GenericRequestItemProcessor {
|
|
@@ -3902,8 +4409,8 @@ exports.ShareAttributeRequestItemProcessor = void 0;
|
|
|
3902
4409
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
3903
4410
|
const lodash_1 = __importDefault(__webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js"));
|
|
3904
4411
|
const CoreErrors_1 = __webpack_require__(/*! ../../../../consumption/CoreErrors */ "./dist/consumption/CoreErrors.js");
|
|
4412
|
+
const ValidationResult_1 = __webpack_require__(/*! ../../../common/ValidationResult */ "./dist/modules/common/ValidationResult.js");
|
|
3905
4413
|
const GenericRequestItemProcessor_1 = __webpack_require__(/*! ../GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js");
|
|
3906
|
-
const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
3907
4414
|
class ShareAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.GenericRequestItemProcessor {
|
|
3908
4415
|
async canCreateOutgoingRequestItem(requestItem, _request, recipient) {
|
|
3909
4416
|
const attribute = await this.consumptionController.attributes.getLocalAttribute(requestItem.sourceAttributeId);
|
|
@@ -3982,7 +4489,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
3982
4489
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
3983
4490
|
const iql_1 = __webpack_require__(/*! @nmshd/iql */ "./node_modules/@nmshd/iql/dist/src/index.js");
|
|
3984
4491
|
const CoreErrors_1 = __webpack_require__(/*! ../../../../consumption/CoreErrors */ "./dist/consumption/CoreErrors.js");
|
|
3985
|
-
const ValidationResult_1 = __webpack_require__(/*!
|
|
4492
|
+
const ValidationResult_1 = __webpack_require__(/*! ../../../common/ValidationResult */ "./dist/modules/common/ValidationResult.js");
|
|
3986
4493
|
function validateQuery(query, sender, recipient) {
|
|
3987
4494
|
if (query instanceof content_1.ThirdPartyRelationshipAttributeQuery) {
|
|
3988
4495
|
for (const thirdParty of query.thirdParty) {
|
|
@@ -4333,8 +4840,8 @@ const ConsumptionBaseController_1 = __webpack_require__(/*! ../../../consumption
|
|
|
4333
4840
|
const ConsumptionControllerName_1 = __webpack_require__(/*! ../../../consumption/ConsumptionControllerName */ "./dist/consumption/ConsumptionControllerName.js");
|
|
4334
4841
|
const ConsumptionError_1 = __webpack_require__(/*! ../../../consumption/ConsumptionError */ "./dist/consumption/ConsumptionError.js");
|
|
4335
4842
|
const ConsumptionIds_1 = __webpack_require__(/*! ../../../consumption/ConsumptionIds */ "./dist/consumption/ConsumptionIds.js");
|
|
4843
|
+
const ValidationResult_1 = __webpack_require__(/*! ../../common/ValidationResult */ "./dist/modules/common/ValidationResult.js");
|
|
4336
4844
|
const events_1 = __webpack_require__(/*! ../events */ "./dist/modules/requests/events/index.js");
|
|
4337
|
-
const ValidationResult_1 = __webpack_require__(/*! ../itemProcessors/ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
4338
4845
|
const LocalRequest_1 = __webpack_require__(/*! ../local/LocalRequest */ "./dist/modules/requests/local/LocalRequest.js");
|
|
4339
4846
|
const LocalRequestStatus_1 = __webpack_require__(/*! ../local/LocalRequestStatus */ "./dist/modules/requests/local/LocalRequestStatus.js");
|
|
4340
4847
|
const LocalResponse_1 = __webpack_require__(/*! ../local/LocalResponse */ "./dist/modules/requests/local/LocalResponse.js");
|