@nmshd/consumption 3.4.2 → 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 +357 -48
- 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 +743 -233
- 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 +8 -8
- 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);
|
|
@@ -697,9 +756,12 @@ class AttributesController extends ConsumptionBaseController_1.ConsumptionBaseCo
|
|
|
697
756
|
}
|
|
698
757
|
async executeIQLQuery(query) {
|
|
699
758
|
/* Fetch subset of attributes relevant for IQL queries. We filter for
|
|
700
|
-
*
|
|
701
|
-
const envelopedAttributes =
|
|
702
|
-
|
|
759
|
+
* identity attributes which are not shared. */
|
|
760
|
+
const envelopedAttributes = await this.attributes.find({
|
|
761
|
+
"content.@type": "IdentityAttribute",
|
|
762
|
+
shareInfo: {
|
|
763
|
+
$exists: false
|
|
764
|
+
}
|
|
703
765
|
});
|
|
704
766
|
/* Remove envelope from attributes and execute query. IQL makes no use
|
|
705
767
|
* of the envelope data. */
|
|
@@ -736,11 +798,14 @@ class AttributesController extends ConsumptionBaseController_1.ConsumptionBaseCo
|
|
|
736
798
|
return this.parseArray(attributes, LocalAttribute_1.LocalAttribute);
|
|
737
799
|
}
|
|
738
800
|
async createLocalAttribute(params) {
|
|
801
|
+
const parsedParams = CreateLocalAttributeParams_1.CreateLocalAttributeParams.from(params);
|
|
739
802
|
const localAttribute = LocalAttribute_1.LocalAttribute.from({
|
|
740
|
-
id: await ConsumptionIds_1.ConsumptionIds.attribute.generate(),
|
|
803
|
+
id: parsedParams.id ?? (await ConsumptionIds_1.ConsumptionIds.attribute.generate()),
|
|
741
804
|
createdAt: transport_1.CoreDate.utc(),
|
|
742
|
-
content:
|
|
743
|
-
parentId:
|
|
805
|
+
content: parsedParams.content,
|
|
806
|
+
parentId: parsedParams.parentId,
|
|
807
|
+
succeeds: parsedParams.succeeds,
|
|
808
|
+
shareInfo: parsedParams.shareInfo
|
|
744
809
|
});
|
|
745
810
|
await this.attributes.create(localAttribute);
|
|
746
811
|
if (localAttribute.content instanceof content_1.IdentityAttribute && // nested Local Attributes should only be created for Identity Attributes
|
|
@@ -763,29 +828,6 @@ class AttributesController extends ConsumptionBaseController_1.ConsumptionBaseCo
|
|
|
763
828
|
await this.createLocalAttribute({ content: nestedAttribute, parentId: localAttribute.id });
|
|
764
829
|
}
|
|
765
830
|
}
|
|
766
|
-
async succeedLocalAttribute(params) {
|
|
767
|
-
const parsedParams = SucceedLocalAttributeParams_1.SucceedLocalAttributeParams.from(params);
|
|
768
|
-
const currentAttributeDoc = await this.attributes.findOne({
|
|
769
|
-
[(0, ts_simple_nameof_1.nameof)((c) => c.id)]: params.succeeds.toString()
|
|
770
|
-
});
|
|
771
|
-
const currentAttribute = LocalAttribute_1.LocalAttribute.from(currentAttributeDoc);
|
|
772
|
-
if (currentAttribute.parentId) {
|
|
773
|
-
throw CoreErrors_1.CoreErrors.attributes.cannotSucceedAttributesWithAParent(parsedParams.succeeds.toString());
|
|
774
|
-
}
|
|
775
|
-
if (!currentAttributeDoc) {
|
|
776
|
-
throw transport_1.CoreErrors.general.recordNotFound(LocalAttribute_1.LocalAttribute, parsedParams.succeeds.toString());
|
|
777
|
-
}
|
|
778
|
-
if (!parsedParams.successorContent.validFrom) {
|
|
779
|
-
parsedParams.successorContent.validFrom = transport_1.CoreDate.utc();
|
|
780
|
-
}
|
|
781
|
-
const validFrom = parsedParams.successorContent.validFrom;
|
|
782
|
-
currentAttribute.content.validTo = validFrom.subtract(1);
|
|
783
|
-
await this.attributes.update(currentAttributeDoc, currentAttribute);
|
|
784
|
-
const successor = await LocalAttribute_1.LocalAttribute.fromAttribute(parsedParams.successorContent, parsedParams.succeeds);
|
|
785
|
-
await this.attributes.create(successor);
|
|
786
|
-
this.eventBus.publish(new events_1.AttributeSucceededEvent(this.identity.address.toString(), successor));
|
|
787
|
-
return successor;
|
|
788
|
-
}
|
|
789
831
|
async createSharedLocalAttributeCopy(params) {
|
|
790
832
|
const parsedParams = CreateSharedLocalAttributeCopyParams_1.CreateSharedLocalAttributeCopyParams.from(params);
|
|
791
833
|
const sourceAttribute = await this.getLocalAttribute(parsedParams.sourceAttributeId);
|
|
@@ -817,28 +859,349 @@ class AttributesController extends ConsumptionBaseController_1.ConsumptionBaseCo
|
|
|
817
859
|
this.eventBus.publish(new events_1.AttributeCreatedEvent(this.identity.address.toString(), peerLocalAttribute));
|
|
818
860
|
return peerLocalAttribute;
|
|
819
861
|
}
|
|
820
|
-
async
|
|
821
|
-
|
|
822
|
-
|
|
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
|
|
823
881
|
});
|
|
824
|
-
|
|
825
|
-
|
|
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
|
+
}
|
|
826
891
|
}
|
|
827
|
-
const
|
|
828
|
-
id:
|
|
829
|
-
content:
|
|
830
|
-
|
|
831
|
-
shareInfo:
|
|
832
|
-
|
|
833
|
-
|
|
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
|
|
834
1085
|
});
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
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
|
|
1110
|
+
});
|
|
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();
|
|
838
1124
|
}
|
|
839
|
-
async
|
|
840
|
-
|
|
841
|
-
|
|
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 });
|
|
842
1205
|
}
|
|
843
1206
|
}
|
|
844
1207
|
exports.AttributesController = AttributesController;
|
|
@@ -890,25 +1253,16 @@ AttributeDeletedEvent.namespace = "consumption.attributeDeleted";
|
|
|
890
1253
|
|
|
891
1254
|
/***/ }),
|
|
892
1255
|
|
|
893
|
-
/***/ "./dist/modules/attributes/events/
|
|
894
|
-
|
|
895
|
-
!*** ./dist/modules/attributes/events/
|
|
896
|
-
|
|
897
|
-
/***/ ((__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) => {
|
|
898
1261
|
|
|
899
1262
|
"use strict";
|
|
900
1263
|
|
|
901
1264
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
902
|
-
|
|
903
|
-
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
904
|
-
class AttributeSucceededEvent extends transport_1.TransportDataEvent {
|
|
905
|
-
constructor(eventTargetAddress, data) {
|
|
906
|
-
super(AttributeSucceededEvent.namespace, eventTargetAddress, data);
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
exports.AttributeSucceededEvent = AttributeSucceededEvent;
|
|
910
|
-
AttributeSucceededEvent.namespace = "consumption.attributeSucceded";
|
|
911
|
-
//# sourceMappingURL=AttributeSucceededEvent.js.map
|
|
1265
|
+
//# sourceMappingURL=AttributeSucceededEventData.js.map
|
|
912
1266
|
|
|
913
1267
|
/***/ }),
|
|
914
1268
|
|
|
@@ -934,6 +1288,72 @@ AttributeUpdatedEvent.namespace = "consumption.attributeUpdated";
|
|
|
934
1288
|
|
|
935
1289
|
/***/ }),
|
|
936
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
|
+
|
|
937
1357
|
/***/ "./dist/modules/attributes/events/SharedAttributeCopyCreatedEvent.js":
|
|
938
1358
|
/*!***************************************************************************!*\
|
|
939
1359
|
!*** ./dist/modules/attributes/events/SharedAttributeCopyCreatedEvent.js ***!
|
|
@@ -981,8 +1401,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
981
1401
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
982
1402
|
__exportStar(__webpack_require__(/*! ./AttributeCreatedEvent */ "./dist/modules/attributes/events/AttributeCreatedEvent.js"), exports);
|
|
983
1403
|
__exportStar(__webpack_require__(/*! ./AttributeDeletedEvent */ "./dist/modules/attributes/events/AttributeDeletedEvent.js"), exports);
|
|
984
|
-
__exportStar(__webpack_require__(/*! ./
|
|
1404
|
+
__exportStar(__webpack_require__(/*! ./AttributeSucceededEventData */ "./dist/modules/attributes/events/AttributeSucceededEventData.js"), exports);
|
|
985
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);
|
|
986
1409
|
__exportStar(__webpack_require__(/*! ./SharedAttributeCopyCreatedEvent */ "./dist/modules/attributes/events/SharedAttributeCopyCreatedEvent.js"), exports);
|
|
987
1410
|
//# sourceMappingURL=index.js.map
|
|
988
1411
|
|
|
@@ -1016,10 +1439,9 @@ __exportStar(__webpack_require__(/*! ./events */ "./dist/modules/attributes/even
|
|
|
1016
1439
|
__exportStar(__webpack_require__(/*! ./local/CreateLocalAttributeParams */ "./dist/modules/attributes/local/CreateLocalAttributeParams.js"), exports);
|
|
1017
1440
|
__exportStar(__webpack_require__(/*! ./local/CreatePeerLocalAttributeParams */ "./dist/modules/attributes/local/CreatePeerLocalAttributeParams.js"), exports);
|
|
1018
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);
|
|
1019
1443
|
__exportStar(__webpack_require__(/*! ./local/LocalAttribute */ "./dist/modules/attributes/local/LocalAttribute.js"), exports);
|
|
1020
1444
|
__exportStar(__webpack_require__(/*! ./local/LocalAttributeShareInfo */ "./dist/modules/attributes/local/LocalAttributeShareInfo.js"), exports);
|
|
1021
|
-
__exportStar(__webpack_require__(/*! ./local/SucceedLocalAttributeParams */ "./dist/modules/attributes/local/SucceedLocalAttributeParams.js"), exports);
|
|
1022
|
-
__exportStar(__webpack_require__(/*! ./local/UpdateLocalAttributeParams */ "./dist/modules/attributes/local/UpdateLocalAttributeParams.js"), exports);
|
|
1023
1445
|
//# sourceMappingURL=index.js.map
|
|
1024
1446
|
|
|
1025
1447
|
/***/ }),
|
|
@@ -1046,22 +1468,38 @@ exports.CreateLocalAttributeParams = void 0;
|
|
|
1046
1468
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
1047
1469
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
1048
1470
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
1471
|
+
const LocalAttributeShareInfo_1 = __webpack_require__(/*! ./LocalAttributeShareInfo */ "./dist/modules/attributes/local/LocalAttributeShareInfo.js");
|
|
1049
1472
|
class CreateLocalAttributeParams extends ts_serval_1.Serializable {
|
|
1050
1473
|
static from(value) {
|
|
1051
1474
|
return this.fromAny(value);
|
|
1052
1475
|
}
|
|
1053
1476
|
}
|
|
1054
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);
|
|
1055
1483
|
__decorate([
|
|
1056
1484
|
(0, ts_serval_1.serialize)({ unionTypes: [content_1.IdentityAttribute, content_1.RelationshipAttribute] }),
|
|
1057
1485
|
(0, ts_serval_1.validate)(),
|
|
1058
1486
|
__metadata("design:type", Object)
|
|
1059
1487
|
], CreateLocalAttributeParams.prototype, "content", void 0);
|
|
1060
1488
|
__decorate([
|
|
1061
|
-
(0, ts_serval_1.serialize)(
|
|
1062
|
-
(0, ts_serval_1.validate)(),
|
|
1489
|
+
(0, ts_serval_1.serialize)(),
|
|
1490
|
+
(0, ts_serval_1.validate)({ nullable: true }),
|
|
1063
1491
|
__metadata("design:type", transport_1.CoreId)
|
|
1064
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);
|
|
1065
1503
|
//# sourceMappingURL=CreateLocalAttributeParams.js.map
|
|
1066
1504
|
|
|
1067
1505
|
/***/ }),
|
|
@@ -1169,6 +1607,19 @@ __decorate([
|
|
|
1169
1607
|
|
|
1170
1608
|
/***/ }),
|
|
1171
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
|
+
|
|
1172
1623
|
/***/ "./dist/modules/attributes/local/LocalAttribute.js":
|
|
1173
1624
|
/*!*********************************************************!*\
|
|
1174
1625
|
!*** ./dist/modules/attributes/local/LocalAttribute.js ***!
|
|
@@ -1208,26 +1659,60 @@ let LocalAttribute = class LocalAttribute extends transport_1.CoreSynchronizable
|
|
|
1208
1659
|
];
|
|
1209
1660
|
this.userdataProperties = [(0, ts_simple_nameof_1.nameof)((r) => r.content)];
|
|
1210
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
|
+
}
|
|
1211
1703
|
isIdentityAttribute() {
|
|
1212
1704
|
return this.content instanceof content_1.IdentityAttribute;
|
|
1213
1705
|
}
|
|
1214
1706
|
isRelationshipAttribute() {
|
|
1215
|
-
return this.content instanceof content_1.RelationshipAttribute
|
|
1707
|
+
return (this.content instanceof content_1.RelationshipAttribute &&
|
|
1708
|
+
this.isShared() &&
|
|
1709
|
+
typeof this.shareInfo.sourceAttribute === "undefined");
|
|
1216
1710
|
}
|
|
1217
1711
|
isOwnedBy(identity) {
|
|
1218
1712
|
return this.content.owner.equals(identity);
|
|
1219
1713
|
}
|
|
1220
|
-
isRepositoryAttribute() {
|
|
1221
|
-
return this.isIdentityAttribute() && !this.isShared();
|
|
1222
|
-
}
|
|
1223
1714
|
isShared() {
|
|
1224
|
-
return this.shareInfo !== undefined;
|
|
1225
|
-
}
|
|
1226
|
-
isSharedWith(address) {
|
|
1227
|
-
if (!this.isShared()) {
|
|
1228
|
-
return false;
|
|
1229
|
-
}
|
|
1230
|
-
return this.shareInfo.peer === address;
|
|
1715
|
+
return typeof this.shareInfo !== "undefined";
|
|
1231
1716
|
}
|
|
1232
1717
|
static from(value) {
|
|
1233
1718
|
return this.fromAny(value);
|
|
@@ -1302,25 +1787,44 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
1302
1787
|
exports.LocalAttributeShareInfo = void 0;
|
|
1303
1788
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
1304
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");
|
|
1305
1792
|
class LocalAttributeShareInfo extends transport_1.CoreSerializable {
|
|
1306
1793
|
static from(value) {
|
|
1307
1794
|
return super.fromAny(value);
|
|
1308
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
|
+
}
|
|
1309
1808
|
}
|
|
1310
1809
|
exports.LocalAttributeShareInfo = LocalAttributeShareInfo;
|
|
1311
1810
|
__decorate([
|
|
1312
|
-
(0, ts_serval_1.validate)(),
|
|
1313
1811
|
(0, ts_serval_1.serialize)(),
|
|
1812
|
+
(0, ts_serval_1.validate)({ nullable: true }),
|
|
1314
1813
|
__metadata("design:type", transport_1.CoreId)
|
|
1315
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);
|
|
1316
1820
|
__decorate([
|
|
1317
1821
|
(0, ts_serval_1.validate)(),
|
|
1318
1822
|
(0, ts_serval_1.serialize)(),
|
|
1319
1823
|
__metadata("design:type", transport_1.CoreAddress)
|
|
1320
1824
|
], LocalAttributeShareInfo.prototype, "peer", void 0);
|
|
1321
1825
|
__decorate([
|
|
1322
|
-
(0, ts_serval_1.validate)({ nullable: true }),
|
|
1323
1826
|
(0, ts_serval_1.serialize)(),
|
|
1827
|
+
(0, ts_serval_1.validate)({ nullable: true }),
|
|
1324
1828
|
__metadata("design:type", transport_1.CoreId)
|
|
1325
1829
|
], LocalAttributeShareInfo.prototype, "sourceAttribute", void 0);
|
|
1326
1830
|
//# sourceMappingURL=LocalAttributeShareInfo.js.map
|
|
@@ -1507,87 +2011,82 @@ ThirdPartyRelationshipAttributeQueryTranslator.translator = new docdb_querytrans
|
|
|
1507
2011
|
|
|
1508
2012
|
/***/ }),
|
|
1509
2013
|
|
|
1510
|
-
/***/ "./dist/modules/
|
|
1511
|
-
|
|
1512
|
-
!*** ./dist/modules/
|
|
1513
|
-
|
|
1514
|
-
/***/ (
|
|
2014
|
+
/***/ "./dist/modules/common/ValidationResult.js":
|
|
2015
|
+
/*!*************************************************!*\
|
|
2016
|
+
!*** ./dist/modules/common/ValidationResult.js ***!
|
|
2017
|
+
\*************************************************/
|
|
2018
|
+
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
1515
2019
|
|
|
1516
2020
|
"use strict";
|
|
1517
2021
|
|
|
1518
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
1519
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1520
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1521
|
-
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;
|
|
1522
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1523
|
-
};
|
|
1524
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
1525
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1526
|
-
};
|
|
1527
2022
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1528
|
-
exports.
|
|
1529
|
-
const
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
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);
|
|
1535
2045
|
}
|
|
1536
2046
|
}
|
|
1537
|
-
exports.
|
|
1538
|
-
|
|
1539
|
-
(
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
(
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
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
|
|
1549
2062
|
|
|
1550
2063
|
/***/ }),
|
|
1551
2064
|
|
|
1552
|
-
/***/ "./dist/modules/
|
|
1553
|
-
|
|
1554
|
-
!*** ./dist/modules/
|
|
1555
|
-
|
|
2065
|
+
/***/ "./dist/modules/common/index.js":
|
|
2066
|
+
/*!**************************************!*\
|
|
2067
|
+
!*** ./dist/modules/common/index.js ***!
|
|
2068
|
+
\**************************************/
|
|
1556
2069
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
1557
2070
|
|
|
1558
2071
|
"use strict";
|
|
1559
2072
|
|
|
1560
|
-
var
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
}
|
|
1566
|
-
|
|
1567
|
-
|
|
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);
|
|
1568
2086
|
};
|
|
1569
2087
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
1573
|
-
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
1574
|
-
class UpdateLocalAttributeParams extends ts_serval_1.Serializable {
|
|
1575
|
-
static from(value) {
|
|
1576
|
-
return this.fromAny(value);
|
|
1577
|
-
}
|
|
1578
|
-
}
|
|
1579
|
-
exports.UpdateLocalAttributeParams = UpdateLocalAttributeParams;
|
|
1580
|
-
__decorate([
|
|
1581
|
-
(0, ts_serval_1.serialize)(),
|
|
1582
|
-
(0, ts_serval_1.validate)(),
|
|
1583
|
-
__metadata("design:type", transport_1.CoreId)
|
|
1584
|
-
], UpdateLocalAttributeParams.prototype, "id", void 0);
|
|
1585
|
-
__decorate([
|
|
1586
|
-
(0, ts_serval_1.serialize)({ unionTypes: [content_1.IdentityAttribute, content_1.RelationshipAttribute] }),
|
|
1587
|
-
(0, ts_serval_1.validate)(),
|
|
1588
|
-
__metadata("design:type", Object)
|
|
1589
|
-
], UpdateLocalAttributeParams.prototype, "content", void 0);
|
|
1590
|
-
//# sourceMappingURL=UpdateLocalAttributeParams.js.map
|
|
2088
|
+
__exportStar(__webpack_require__(/*! ./ValidationResult */ "./dist/modules/common/ValidationResult.js"), exports);
|
|
2089
|
+
//# sourceMappingURL=index.js.map
|
|
1591
2090
|
|
|
1592
2091
|
/***/ }),
|
|
1593
2092
|
|
|
@@ -1785,6 +2284,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
1785
2284
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1786
2285
|
__exportStar(__webpack_require__(/*! ./attributeListeners */ "./dist/modules/attributeListeners/index.js"), exports);
|
|
1787
2286
|
__exportStar(__webpack_require__(/*! ./attributes */ "./dist/modules/attributes/index.js"), exports);
|
|
2287
|
+
__exportStar(__webpack_require__(/*! ./common */ "./dist/modules/common/index.js"), exports);
|
|
1788
2288
|
__exportStar(__webpack_require__(/*! ./drafts */ "./dist/modules/drafts/index.js"), exports);
|
|
1789
2289
|
__exportStar(__webpack_require__(/*! ./notifications */ "./dist/modules/notifications/index.js"), exports);
|
|
1790
2290
|
__exportStar(__webpack_require__(/*! ./requests */ "./dist/modules/requests/index.js"), exports);
|
|
@@ -1903,14 +2403,13 @@ class NotificationsController extends ConsumptionBaseController_1.ConsumptionBas
|
|
|
1903
2403
|
try {
|
|
1904
2404
|
for (const item of notification.content.items) {
|
|
1905
2405
|
const processor = this.processorRegistry.getProcessorForItem(item);
|
|
1906
|
-
const
|
|
1907
|
-
if (
|
|
2406
|
+
const checkResult = await processor.checkPrerequisitesOfIncomingNotificationItem(item, notification);
|
|
2407
|
+
if (checkResult.isError()) {
|
|
1908
2408
|
const index = notification.content.items.indexOf(item);
|
|
1909
2409
|
throw new Error(`Prerequisites of notificationItem with index '${index}' of Notification ${notification.id} not met.`);
|
|
1910
2410
|
}
|
|
1911
|
-
|
|
2411
|
+
const event = await processor.process(item, notification);
|
|
1912
2412
|
processedItems.push(item);
|
|
1913
|
-
const event = await processor.process(item);
|
|
1914
2413
|
if (event)
|
|
1915
2414
|
events.push(event);
|
|
1916
2415
|
}
|
|
@@ -1919,7 +2418,7 @@ class NotificationsController extends ConsumptionBaseController_1.ConsumptionBas
|
|
|
1919
2418
|
this._log.error(`Error while processing notification ${notification.id}: ${e}`);
|
|
1920
2419
|
for (const item of processedItems.reverse()) {
|
|
1921
2420
|
const processor = this.processorRegistry.getProcessorForItem(item);
|
|
1922
|
-
await processor.rollback(item);
|
|
2421
|
+
await processor.rollback(item, notification);
|
|
1923
2422
|
}
|
|
1924
2423
|
notification.status = LocalNotification_1.LocalNotificationStatus.Error;
|
|
1925
2424
|
await this.localNotifications.update(oldDoc, notification);
|
|
@@ -2068,17 +2567,77 @@ exports.NotificationItemProcessorRegistry = NotificationItemProcessorRegistry;
|
|
|
2068
2567
|
|
|
2069
2568
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2070
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");
|
|
2071
2575
|
const AbstractNotificationItemProcessor_1 = __webpack_require__(/*! ../AbstractNotificationItemProcessor */ "./dist/modules/notifications/itemProcessors/AbstractNotificationItemProcessor.js");
|
|
2072
2576
|
class AttributeSucceededNotificationItemProcessor extends AbstractNotificationItemProcessor_1.AbstractNotificationItemProcessor {
|
|
2073
|
-
|
|
2074
|
-
|
|
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);
|
|
2075
2623
|
}
|
|
2076
|
-
|
|
2077
|
-
|
|
2078
|
-
throw new Error("Method not implemented.");
|
|
2624
|
+
async rollback(notificationItem, notification) {
|
|
2625
|
+
await this.rollbackPartialWork(notificationItem, notification);
|
|
2079
2626
|
}
|
|
2080
|
-
|
|
2081
|
-
|
|
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
|
+
}
|
|
2082
2641
|
}
|
|
2083
2642
|
}
|
|
2084
2643
|
exports.AttributeSucceededNotificationItemProcessor = AttributeSucceededNotificationItemProcessor;
|
|
@@ -2414,7 +2973,7 @@ exports.DecideRequestParametersValidator = void 0;
|
|
|
2414
2973
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
2415
2974
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
2416
2975
|
const CoreErrors_1 = __webpack_require__(/*! ../../../consumption/CoreErrors */ "./dist/consumption/CoreErrors.js");
|
|
2417
|
-
const ValidationResult_1 = __webpack_require__(/*!
|
|
2976
|
+
const ValidationResult_1 = __webpack_require__(/*! ../../common/ValidationResult */ "./dist/modules/common/ValidationResult.js");
|
|
2418
2977
|
const DecideRequestItemGroupParameters_1 = __webpack_require__(/*! ./decide/DecideRequestItemGroupParameters */ "./dist/modules/requests/incoming/decide/DecideRequestItemGroupParameters.js");
|
|
2419
2978
|
const DecideRequestItemParameters_1 = __webpack_require__(/*! ./decide/DecideRequestItemParameters */ "./dist/modules/requests/incoming/decide/DecideRequestItemParameters.js");
|
|
2420
2979
|
class DecideRequestParametersValidator {
|
|
@@ -2487,8 +3046,8 @@ const ConsumptionControllerName_1 = __webpack_require__(/*! ../../../consumption
|
|
|
2487
3046
|
const ConsumptionError_1 = __webpack_require__(/*! ../../../consumption/ConsumptionError */ "./dist/consumption/ConsumptionError.js");
|
|
2488
3047
|
const ConsumptionIds_1 = __webpack_require__(/*! ../../../consumption/ConsumptionIds */ "./dist/consumption/ConsumptionIds.js");
|
|
2489
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");
|
|
2490
3050
|
const events_1 = __webpack_require__(/*! ../events */ "./dist/modules/requests/events/index.js");
|
|
2491
|
-
const ValidationResult_1 = __webpack_require__(/*! ../itemProcessors/ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
2492
3051
|
const LocalRequest_1 = __webpack_require__(/*! ../local/LocalRequest */ "./dist/modules/requests/local/LocalRequest.js");
|
|
2493
3052
|
const LocalRequestStatus_1 = __webpack_require__(/*! ../local/LocalRequestStatus */ "./dist/modules/requests/local/LocalRequestStatus.js");
|
|
2494
3053
|
const LocalResponse_1 = __webpack_require__(/*! ../local/LocalResponse */ "./dist/modules/requests/local/LocalResponse.js");
|
|
@@ -3124,7 +3683,6 @@ __exportStar(__webpack_require__(/*! ./itemProcessors/IRequestItemProcessor */ "
|
|
|
3124
3683
|
__exportStar(__webpack_require__(/*! ./itemProcessors/RequestItemConstructor */ "./dist/modules/requests/itemProcessors/RequestItemConstructor.js"), exports);
|
|
3125
3684
|
__exportStar(__webpack_require__(/*! ./itemProcessors/RequestItemProcessorConstructor */ "./dist/modules/requests/itemProcessors/RequestItemProcessorConstructor.js"), exports);
|
|
3126
3685
|
__exportStar(__webpack_require__(/*! ./itemProcessors/RequestItemProcessorRegistry */ "./dist/modules/requests/itemProcessors/RequestItemProcessorRegistry.js"), exports);
|
|
3127
|
-
__exportStar(__webpack_require__(/*! ./itemProcessors/ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js"), exports);
|
|
3128
3686
|
__exportStar(__webpack_require__(/*! ./itemProcessors/createAttribute/CreateAttributeRequestItemProcessor */ "./dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js"), exports);
|
|
3129
3687
|
__exportStar(__webpack_require__(/*! ./itemProcessors/freeText/AcceptFreeTextRequestItemParameters */ "./dist/modules/requests/itemProcessors/freeText/AcceptFreeTextRequestItemParameters.js"), exports);
|
|
3130
3688
|
__exportStar(__webpack_require__(/*! ./itemProcessors/freeText/FreeTextRequestItemProcessor */ "./dist/modules/requests/itemProcessors/freeText/FreeTextRequestItemProcessor.js"), exports);
|
|
@@ -3181,8 +3739,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
3181
3739
|
exports.GenericRequestItemProcessor = void 0;
|
|
3182
3740
|
/* eslint-disable @typescript-eslint/no-unused-vars */
|
|
3183
3741
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
3742
|
+
const ValidationResult_1 = __webpack_require__(/*! ../../common/ValidationResult */ "./dist/modules/common/ValidationResult.js");
|
|
3184
3743
|
const AbstractRequestItemProcessor_1 = __webpack_require__(/*! ./AbstractRequestItemProcessor */ "./dist/modules/requests/itemProcessors/AbstractRequestItemProcessor.js");
|
|
3185
|
-
const ValidationResult_1 = __webpack_require__(/*! ./ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
3186
3744
|
class GenericRequestItemProcessor extends AbstractRequestItemProcessor_1.AbstractRequestItemProcessor {
|
|
3187
3745
|
checkPrerequisitesOfIncomingRequestItem(requestItem, requestInfo) {
|
|
3188
3746
|
return true;
|
|
@@ -3291,57 +3849,6 @@ exports.RequestItemProcessorRegistry = RequestItemProcessorRegistry;
|
|
|
3291
3849
|
|
|
3292
3850
|
/***/ }),
|
|
3293
3851
|
|
|
3294
|
-
/***/ "./dist/modules/requests/itemProcessors/ValidationResult.js":
|
|
3295
|
-
/*!******************************************************************!*\
|
|
3296
|
-
!*** ./dist/modules/requests/itemProcessors/ValidationResult.js ***!
|
|
3297
|
-
\******************************************************************/
|
|
3298
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
3299
|
-
|
|
3300
|
-
"use strict";
|
|
3301
|
-
|
|
3302
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
3303
|
-
exports.ErrorValidationResult = exports.SuccessfulValidationResult = exports.ValidationResult = void 0;
|
|
3304
|
-
const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "./node_modules/@js-soft/ts-utils/dist/index.js");
|
|
3305
|
-
class ValidationResult {
|
|
3306
|
-
constructor(items) {
|
|
3307
|
-
this.items = items;
|
|
3308
|
-
}
|
|
3309
|
-
isSuccess() {
|
|
3310
|
-
return this instanceof SuccessfulValidationResult;
|
|
3311
|
-
}
|
|
3312
|
-
isError() {
|
|
3313
|
-
return this instanceof ErrorValidationResult;
|
|
3314
|
-
}
|
|
3315
|
-
static success(items = []) {
|
|
3316
|
-
return new SuccessfulValidationResult(items);
|
|
3317
|
-
}
|
|
3318
|
-
static error(error, items = []) {
|
|
3319
|
-
return new ErrorValidationResult(error, items);
|
|
3320
|
-
}
|
|
3321
|
-
static fromItems(items) {
|
|
3322
|
-
return items.some((r) => r.isError())
|
|
3323
|
-
? ValidationResult.error(new ts_utils_1.ApplicationError("inheritedFromItem", "Some child items have errors."), items)
|
|
3324
|
-
: ValidationResult.success(items);
|
|
3325
|
-
}
|
|
3326
|
-
}
|
|
3327
|
-
exports.ValidationResult = ValidationResult;
|
|
3328
|
-
class SuccessfulValidationResult extends ValidationResult {
|
|
3329
|
-
constructor(items) {
|
|
3330
|
-
super(items);
|
|
3331
|
-
}
|
|
3332
|
-
}
|
|
3333
|
-
exports.SuccessfulValidationResult = SuccessfulValidationResult;
|
|
3334
|
-
class ErrorValidationResult extends ValidationResult {
|
|
3335
|
-
constructor(error, items) {
|
|
3336
|
-
super(items);
|
|
3337
|
-
this.error = error;
|
|
3338
|
-
}
|
|
3339
|
-
}
|
|
3340
|
-
exports.ErrorValidationResult = ErrorValidationResult;
|
|
3341
|
-
//# sourceMappingURL=ValidationResult.js.map
|
|
3342
|
-
|
|
3343
|
-
/***/ }),
|
|
3344
|
-
|
|
3345
3852
|
/***/ "./dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js":
|
|
3346
3853
|
/*!*****************************************************************************************************!*\
|
|
3347
3854
|
!*** ./dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js ***!
|
|
@@ -3354,8 +3861,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
3354
3861
|
exports.CreateAttributeRequestItemProcessor = void 0;
|
|
3355
3862
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
3356
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");
|
|
3357
3865
|
const GenericRequestItemProcessor_1 = __webpack_require__(/*! ../GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js");
|
|
3358
|
-
const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
3359
3866
|
class CreateAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.GenericRequestItemProcessor {
|
|
3360
3867
|
canCreateOutgoingRequestItem(requestItem, _request, recipient) {
|
|
3361
3868
|
const recipientIsAttributeOwner = requestItem.attribute.owner.equals(recipient);
|
|
@@ -3365,12 +3872,15 @@ class CreateAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.
|
|
|
3365
3872
|
if (senderIsAttributeOwner) {
|
|
3366
3873
|
return ValidationResult_1.ValidationResult.error(CoreErrors_1.CoreErrors.requests.invalidRequestItem("Cannot create own Attributes with a CreateAttributeRequestItem. Use a ShareAttributeRequestItem instead."));
|
|
3367
3874
|
}
|
|
3368
|
-
if (recipientIsAttributeOwner || ownerIsEmptyString || recipient === undefined) {
|
|
3875
|
+
if (recipientIsAttributeOwner || ownerIsEmptyString || typeof recipient === "undefined") {
|
|
3369
3876
|
return ValidationResult_1.ValidationResult.success();
|
|
3370
3877
|
}
|
|
3371
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."));
|
|
3372
3879
|
}
|
|
3373
|
-
if (recipientIsAttributeOwner ||
|
|
3880
|
+
if (recipientIsAttributeOwner ||
|
|
3881
|
+
senderIsAttributeOwner ||
|
|
3882
|
+
ownerIsEmptyString ||
|
|
3883
|
+
typeof recipient === "undefined") {
|
|
3374
3884
|
return ValidationResult_1.ValidationResult.success();
|
|
3375
3885
|
}
|
|
3376
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."));
|
|
@@ -3472,8 +3982,8 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
3472
3982
|
exports.FreeTextRequestItemProcessor = void 0;
|
|
3473
3983
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
3474
3984
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
3985
|
+
const ValidationResult_1 = __webpack_require__(/*! ../../../common/ValidationResult */ "./dist/modules/common/ValidationResult.js");
|
|
3475
3986
|
const GenericRequestItemProcessor_1 = __webpack_require__(/*! ../GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js");
|
|
3476
|
-
const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
3477
3987
|
const CoreErrors_1 = __webpack_require__(/*! ../../../../consumption/CoreErrors */ "./dist/consumption/CoreErrors.js");
|
|
3478
3988
|
const AcceptFreeTextRequestItemParameters_1 = __webpack_require__(/*! ./AcceptFreeTextRequestItemParameters */ "./dist/modules/requests/itemProcessors/freeText/AcceptFreeTextRequestItemParameters.js");
|
|
3479
3989
|
class FreeTextRequestItemProcessor extends GenericRequestItemProcessor_1.GenericRequestItemProcessor {
|
|
@@ -3528,10 +4038,10 @@ const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_m
|
|
|
3528
4038
|
const ConsumptionError_1 = __webpack_require__(/*! ../../../../consumption/ConsumptionError */ "./dist/consumption/ConsumptionError.js");
|
|
3529
4039
|
let AcceptProposeAttributeRequestItemParameters = AcceptProposeAttributeRequestItemParameters_1 = class AcceptProposeAttributeRequestItemParameters extends ts_serval_1.Serializable {
|
|
3530
4040
|
isWithExistingAttribute() {
|
|
3531
|
-
return this.attributeId !== undefined;
|
|
4041
|
+
return typeof this.attributeId !== "undefined";
|
|
3532
4042
|
}
|
|
3533
4043
|
isWithNewAttribute() {
|
|
3534
|
-
return this.attribute !== undefined;
|
|
4044
|
+
return typeof this.attribute !== "undefined";
|
|
3535
4045
|
}
|
|
3536
4046
|
static from(value) {
|
|
3537
4047
|
return this.fromAny(value);
|
|
@@ -3584,8 +4094,8 @@ const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
|
3584
4094
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
3585
4095
|
const CoreErrors_1 = __webpack_require__(/*! ../../../../consumption/CoreErrors */ "./dist/consumption/CoreErrors.js");
|
|
3586
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");
|
|
3587
4098
|
const GenericRequestItemProcessor_1 = __webpack_require__(/*! ../GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js");
|
|
3588
|
-
const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
3589
4099
|
const validateQuery_1 = __importDefault(__webpack_require__(/*! ../utility/validateQuery */ "./dist/modules/requests/itemProcessors/utility/validateQuery.js"));
|
|
3590
4100
|
const AcceptProposeAttributeRequestItemParameters_1 = __webpack_require__(/*! ./AcceptProposeAttributeRequestItemParameters */ "./dist/modules/requests/itemProcessors/proposeAttribute/AcceptProposeAttributeRequestItemParameters.js");
|
|
3591
4101
|
class ProposeAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.GenericRequestItemProcessor {
|
|
@@ -3716,10 +4226,10 @@ const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_m
|
|
|
3716
4226
|
const ConsumptionError_1 = __webpack_require__(/*! ../../../../consumption/ConsumptionError */ "./dist/consumption/ConsumptionError.js");
|
|
3717
4227
|
let AcceptReadAttributeRequestItemParameters = AcceptReadAttributeRequestItemParameters_1 = class AcceptReadAttributeRequestItemParameters extends ts_serval_1.Serializable {
|
|
3718
4228
|
isWithExistingAttribute() {
|
|
3719
|
-
return this.existingAttributeId !== undefined;
|
|
4229
|
+
return typeof this.existingAttributeId !== "undefined";
|
|
3720
4230
|
}
|
|
3721
4231
|
isWithNewAttribute() {
|
|
3722
|
-
return this.newAttribute !== undefined;
|
|
4232
|
+
return typeof this.newAttribute !== "undefined";
|
|
3723
4233
|
}
|
|
3724
4234
|
static from(value) {
|
|
3725
4235
|
return this.fromAny(value);
|
|
@@ -3772,8 +4282,8 @@ const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
|
3772
4282
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
3773
4283
|
const CoreErrors_1 = __webpack_require__(/*! ../../../../consumption/CoreErrors */ "./dist/consumption/CoreErrors.js");
|
|
3774
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");
|
|
3775
4286
|
const GenericRequestItemProcessor_1 = __webpack_require__(/*! ../GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js");
|
|
3776
|
-
const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
3777
4287
|
const validateQuery_1 = __importDefault(__webpack_require__(/*! ../utility/validateQuery */ "./dist/modules/requests/itemProcessors/utility/validateQuery.js"));
|
|
3778
4288
|
const AcceptReadAttributeRequestItemParameters_1 = __webpack_require__(/*! ./AcceptReadAttributeRequestItemParameters */ "./dist/modules/requests/itemProcessors/readAttribute/AcceptReadAttributeRequestItemParameters.js");
|
|
3779
4289
|
class ReadAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.GenericRequestItemProcessor {
|
|
@@ -3899,8 +4409,8 @@ exports.ShareAttributeRequestItemProcessor = void 0;
|
|
|
3899
4409
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
3900
4410
|
const lodash_1 = __importDefault(__webpack_require__(/*! lodash */ "./node_modules/lodash/lodash.js"));
|
|
3901
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");
|
|
3902
4413
|
const GenericRequestItemProcessor_1 = __webpack_require__(/*! ../GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js");
|
|
3903
|
-
const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
3904
4414
|
class ShareAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.GenericRequestItemProcessor {
|
|
3905
4415
|
async canCreateOutgoingRequestItem(requestItem, _request, recipient) {
|
|
3906
4416
|
const attribute = await this.consumptionController.attributes.getLocalAttribute(requestItem.sourceAttributeId);
|
|
@@ -3979,7 +4489,7 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
3979
4489
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
3980
4490
|
const iql_1 = __webpack_require__(/*! @nmshd/iql */ "./node_modules/@nmshd/iql/dist/src/index.js");
|
|
3981
4491
|
const CoreErrors_1 = __webpack_require__(/*! ../../../../consumption/CoreErrors */ "./dist/consumption/CoreErrors.js");
|
|
3982
|
-
const ValidationResult_1 = __webpack_require__(/*!
|
|
4492
|
+
const ValidationResult_1 = __webpack_require__(/*! ../../../common/ValidationResult */ "./dist/modules/common/ValidationResult.js");
|
|
3983
4493
|
function validateQuery(query, sender, recipient) {
|
|
3984
4494
|
if (query instanceof content_1.ThirdPartyRelationshipAttributeQuery) {
|
|
3985
4495
|
for (const thirdParty of query.thirdParty) {
|
|
@@ -4330,8 +4840,8 @@ const ConsumptionBaseController_1 = __webpack_require__(/*! ../../../consumption
|
|
|
4330
4840
|
const ConsumptionControllerName_1 = __webpack_require__(/*! ../../../consumption/ConsumptionControllerName */ "./dist/consumption/ConsumptionControllerName.js");
|
|
4331
4841
|
const ConsumptionError_1 = __webpack_require__(/*! ../../../consumption/ConsumptionError */ "./dist/consumption/ConsumptionError.js");
|
|
4332
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");
|
|
4333
4844
|
const events_1 = __webpack_require__(/*! ../events */ "./dist/modules/requests/events/index.js");
|
|
4334
|
-
const ValidationResult_1 = __webpack_require__(/*! ../itemProcessors/ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
4335
4845
|
const LocalRequest_1 = __webpack_require__(/*! ../local/LocalRequest */ "./dist/modules/requests/local/LocalRequest.js");
|
|
4336
4846
|
const LocalRequestStatus_1 = __webpack_require__(/*! ../local/LocalRequestStatus */ "./dist/modules/requests/local/LocalRequestStatus.js");
|
|
4337
4847
|
const LocalResponse_1 = __webpack_require__(/*! ../local/LocalResponse */ "./dist/modules/requests/local/LocalResponse.js");
|