@nmshd/consumption 2.0.0-alpha.6 → 2.0.0-alpha.9
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/ConsumptionBaseController.d.ts +1 -1
- package/dist/consumption/ConsumptionController.d.ts +1 -5
- package/dist/consumption/ConsumptionController.js +2 -10
- package/dist/consumption/ConsumptionController.js.map +1 -1
- package/dist/consumption/ConsumptionIds.d.ts +0 -3
- package/dist/consumption/ConsumptionIds.js +0 -3
- package/dist/consumption/ConsumptionIds.js.map +1 -1
- package/dist/modules/attributes/ConsumptionAttributesController.d.ts +1 -1
- package/dist/modules/drafts/DraftsController.d.ts +1 -1
- package/dist/modules/index.d.ts +0 -6
- package/dist/modules/index.js +0 -6
- package/dist/modules/index.js.map +1 -1
- package/dist/modules/requests/incoming/IncomingRequestsController.d.ts +6 -6
- package/dist/modules/requests/incoming/IncomingRequestsController.js +13 -10
- package/dist/modules/requests/incoming/IncomingRequestsController.js.map +1 -1
- package/dist/modules/requests/outgoing/OutgoingRequestsController.d.ts +6 -6
- package/dist/modules/requests/outgoing/OutgoingRequestsController.js +11 -8
- package/dist/modules/requests/outgoing/OutgoingRequestsController.js.map +1 -1
- package/dist/modules/settings/SettingsController.d.ts +1 -1
- package/lib-web/nmshd.consumption.js +30 -711
- 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 +1 -1
- package/dist/modules/relationships/RelationshipInfoController.d.ts +0 -15
- package/dist/modules/relationships/RelationshipInfoController.js +0 -61
- package/dist/modules/relationships/RelationshipInfoController.js.map +0 -1
- package/dist/modules/relationships/RelationshipInfoUtil.d.ts +0 -15
- package/dist/modules/relationships/RelationshipInfoUtil.js +0 -219
- package/dist/modules/relationships/RelationshipInfoUtil.js.map +0 -1
- package/dist/modules/relationships/local/RelationshipAttribute.d.ts +0 -14
- package/dist/modules/relationships/local/RelationshipAttribute.js +0 -40
- package/dist/modules/relationships/local/RelationshipAttribute.js.map +0 -1
- package/dist/modules/relationships/local/RelationshipInfo.d.ts +0 -27
- package/dist/modules/relationships/local/RelationshipInfo.js +0 -97
- package/dist/modules/relationships/local/RelationshipInfo.js.map +0 -1
- package/dist/modules/relationships/local/RelationshipTheme.d.ts +0 -14
- package/dist/modules/relationships/local/RelationshipTheme.js +0 -43
- package/dist/modules/relationships/local/RelationshipTheme.js.map +0 -1
- package/dist/modules/sharedItems/SharedItemsController.d.ts +0 -14
- package/dist/modules/sharedItems/SharedItemsController.js +0 -40
- package/dist/modules/sharedItems/SharedItemsController.js.map +0 -1
- package/dist/modules/sharedItems/local/SharedItem.d.ts +0 -31
- package/dist/modules/sharedItems/local/SharedItem.js +0 -100
- package/dist/modules/sharedItems/local/SharedItem.js.map +0 -1
|
@@ -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: "2.0.0-alpha.
|
|
21
|
-
build: "
|
|
22
|
-
date: "2022-
|
|
23
|
-
commit: "
|
|
20
|
+
version: "2.0.0-alpha.9",
|
|
21
|
+
build: "27",
|
|
22
|
+
date: "2022-05-09T15:04:46+00:00",
|
|
23
|
+
commit: "d91fff65600f42a4e813034e0a8ae618b60e2e52",
|
|
24
24
|
dependencies: {},
|
|
25
25
|
libraries: {
|
|
26
26
|
transport: transport_1.buildInformation,
|
|
@@ -100,21 +100,13 @@ class ConsumptionController {
|
|
|
100
100
|
get settings() {
|
|
101
101
|
return this._settings;
|
|
102
102
|
}
|
|
103
|
-
get sharedItems() {
|
|
104
|
-
return this._sharedItems;
|
|
105
|
-
}
|
|
106
|
-
get relationshipInfo() {
|
|
107
|
-
return this._relationshipInfo;
|
|
108
|
-
}
|
|
109
103
|
async init(requestItemProcessors = []) {
|
|
110
104
|
this._attributes = await new modules_1.ConsumptionAttributesController(this).init();
|
|
111
105
|
this._drafts = await new modules_1.DraftsController(this).init();
|
|
112
106
|
const processorRegistry = new modules_1.RequestItemProcessorRegistry(requestItemProcessors);
|
|
113
|
-
this._outgoingRequests = await new modules_1.OutgoingRequestsController(this, processorRegistry).init();
|
|
114
|
-
this._incomingRequests = await new IncomingRequestsController_1.IncomingRequestsController(this, processorRegistry).init();
|
|
107
|
+
this._outgoingRequests = await new modules_1.OutgoingRequestsController(await this.accountController.getSynchronizedCollection("Requests"), processorRegistry, this).init();
|
|
108
|
+
this._incomingRequests = await new IncomingRequestsController_1.IncomingRequestsController(await this.accountController.getSynchronizedCollection("Requests"), processorRegistry, this).init();
|
|
115
109
|
this._settings = await new modules_1.SettingsController(this).init();
|
|
116
|
-
this._sharedItems = await new modules_1.SharedItemsController(this).init();
|
|
117
|
-
this._relationshipInfo = await new modules_1.RelationshipInfoController(this).init();
|
|
118
110
|
return this;
|
|
119
111
|
}
|
|
120
112
|
}
|
|
@@ -210,9 +202,6 @@ class ConsumptionIds {
|
|
|
210
202
|
exports.ConsumptionIds = ConsumptionIds;
|
|
211
203
|
ConsumptionIds.attribute = new transport_1.CoreIdHelper("CNSATT");
|
|
212
204
|
ConsumptionIds.draft = new transport_1.CoreIdHelper("CNSDRF");
|
|
213
|
-
ConsumptionIds.relationshipInfo = new transport_1.CoreIdHelper("CNSRIN");
|
|
214
|
-
ConsumptionIds.sharedItem = new transport_1.CoreIdHelper("CNSSIT");
|
|
215
|
-
ConsumptionIds.response = new transport_1.CoreIdHelper("CNSRES");
|
|
216
205
|
ConsumptionIds.request = new transport_1.CoreIdHelper("CNSREQ");
|
|
217
206
|
ConsumptionIds.setting = new transport_1.CoreIdHelper("CNSSET");
|
|
218
207
|
//# sourceMappingURL=ConsumptionIds.js.map
|
|
@@ -673,10 +662,6 @@ __exportStar(__webpack_require__(/*! ./attributes/ConsumptionAttributesControlle
|
|
|
673
662
|
__exportStar(__webpack_require__(/*! ./attributes/local/ConsumptionAttribute */ "./dist/modules/attributes/local/ConsumptionAttribute.js"), exports);
|
|
674
663
|
__exportStar(__webpack_require__(/*! ./drafts/DraftsController */ "./dist/modules/drafts/DraftsController.js"), exports);
|
|
675
664
|
__exportStar(__webpack_require__(/*! ./drafts/local/Draft */ "./dist/modules/drafts/local/Draft.js"), exports);
|
|
676
|
-
__exportStar(__webpack_require__(/*! ./relationships/local/RelationshipAttribute */ "./dist/modules/relationships/local/RelationshipAttribute.js"), exports);
|
|
677
|
-
__exportStar(__webpack_require__(/*! ./relationships/local/RelationshipInfo */ "./dist/modules/relationships/local/RelationshipInfo.js"), exports);
|
|
678
|
-
__exportStar(__webpack_require__(/*! ./relationships/local/RelationshipTheme */ "./dist/modules/relationships/local/RelationshipTheme.js"), exports);
|
|
679
|
-
__exportStar(__webpack_require__(/*! ./relationships/RelationshipInfoController */ "./dist/modules/relationships/RelationshipInfoController.js"), exports);
|
|
680
665
|
__exportStar(__webpack_require__(/*! ./requests/incoming/checkPrerequisites/CheckPrerequisitesOfIncomingRequestParameters */ "./dist/modules/requests/incoming/checkPrerequisites/CheckPrerequisitesOfIncomingRequestParameters.js"), exports);
|
|
681
666
|
__exportStar(__webpack_require__(/*! ./requests/incoming/complete/CompleteIncomingRequestParameters */ "./dist/modules/requests/incoming/complete/CompleteIncomingRequestParameters.js"), exports);
|
|
682
667
|
__exportStar(__webpack_require__(/*! ./requests/incoming/decide/AcceptRequestItemParameters */ "./dist/modules/requests/incoming/decide/AcceptRequestItemParameters.js"), exports);
|
|
@@ -704,524 +689,12 @@ __exportStar(__webpack_require__(/*! ./requests/outgoing/OutgoingRequestsControl
|
|
|
704
689
|
__exportStar(__webpack_require__(/*! ./requests/outgoing/sentOutgoingRequest/SentOutgoingRequestParameters */ "./dist/modules/requests/outgoing/sentOutgoingRequest/SentOutgoingRequestParameters.js"), exports);
|
|
705
690
|
__exportStar(__webpack_require__(/*! ./settings/local/Setting */ "./dist/modules/settings/local/Setting.js"), exports);
|
|
706
691
|
__exportStar(__webpack_require__(/*! ./settings/SettingsController */ "./dist/modules/settings/SettingsController.js"), exports);
|
|
707
|
-
__exportStar(__webpack_require__(/*! ./sharedItems/local/SharedItem */ "./dist/modules/sharedItems/local/SharedItem.js"), exports);
|
|
708
|
-
__exportStar(__webpack_require__(/*! ./sharedItems/SharedItemsController */ "./dist/modules/sharedItems/SharedItemsController.js"), exports);
|
|
709
692
|
__exportStar(__webpack_require__(/*! ./signatures/Signature */ "./dist/modules/signatures/Signature.js"), exports);
|
|
710
693
|
__exportStar(__webpack_require__(/*! ./signatures/SignatureContent */ "./dist/modules/signatures/SignatureContent.js"), exports);
|
|
711
694
|
//# sourceMappingURL=index.js.map
|
|
712
695
|
|
|
713
696
|
/***/ }),
|
|
714
697
|
|
|
715
|
-
/***/ "./dist/modules/relationships/RelationshipInfoController.js":
|
|
716
|
-
/*!******************************************************************!*\
|
|
717
|
-
!*** ./dist/modules/relationships/RelationshipInfoController.js ***!
|
|
718
|
-
\******************************************************************/
|
|
719
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
720
|
-
|
|
721
|
-
"use strict";
|
|
722
|
-
|
|
723
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
724
|
-
exports.RelationshipInfoController = void 0;
|
|
725
|
-
const consumption_1 = __webpack_require__(/*! ../../consumption */ "./dist/consumption/index.js");
|
|
726
|
-
const RelationshipInfo_1 = __webpack_require__(/*! ./local/RelationshipInfo */ "./dist/modules/relationships/local/RelationshipInfo.js");
|
|
727
|
-
const RelationshipInfoUtil_1 = __webpack_require__(/*! ./RelationshipInfoUtil */ "./dist/modules/relationships/RelationshipInfoUtil.js");
|
|
728
|
-
class RelationshipInfoController extends consumption_1.ConsumptionBaseController {
|
|
729
|
-
constructor(parent) {
|
|
730
|
-
super(consumption_1.ConsumptionControllerName.RelationshipInfoController, parent);
|
|
731
|
-
}
|
|
732
|
-
async init() {
|
|
733
|
-
await super.init();
|
|
734
|
-
this.relationshipInfo = await this.parent.accountController.getSynchronizedCollection("RelationshipInfo");
|
|
735
|
-
return this;
|
|
736
|
-
}
|
|
737
|
-
async getRelationshipInfo(id) {
|
|
738
|
-
const result = await this.relationshipInfo.read(id.toString());
|
|
739
|
-
return result ? RelationshipInfo_1.RelationshipInfo.from(result) : undefined;
|
|
740
|
-
}
|
|
741
|
-
async getRelationshipInfoByRelationship(relationshipId) {
|
|
742
|
-
const info = await new RelationshipInfoUtil_1.RelationshipInfoUtil(this.parent).createInitialRelationshipInfo(relationshipId);
|
|
743
|
-
return info;
|
|
744
|
-
/*
|
|
745
|
-
// So far, do not store the relationshipInfo, as they wouldn't be updated correctly
|
|
746
|
-
|
|
747
|
-
const result = await this.relationshipInfo.findOne({ relationshipId: relationshipId.toString() })
|
|
748
|
-
|
|
749
|
-
if (result) {
|
|
750
|
-
return await RelationshipInfo.from(result)
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
const info = await new RelationshipInfoUtil(this.parent).createInitialRelationshipInfo(relationshipId)
|
|
754
|
-
await this.relationshipInfo.create(info)
|
|
755
|
-
return info
|
|
756
|
-
*/
|
|
757
|
-
}
|
|
758
|
-
async getRelationshipInfos(query) {
|
|
759
|
-
const items = await this.relationshipInfo.find(query);
|
|
760
|
-
return await this.parseArray(items, RelationshipInfo_1.RelationshipInfo);
|
|
761
|
-
}
|
|
762
|
-
async createRelationshipInfo(relationshipInfo) {
|
|
763
|
-
const exists = await this.relationshipInfo.exists({ relationshipId: relationshipInfo.relationshipId });
|
|
764
|
-
if (exists) {
|
|
765
|
-
throw consumption_1.ConsumptionErrors.relationshipInfo.relationshipInfoExists(relationshipInfo.relationshipId.toString());
|
|
766
|
-
}
|
|
767
|
-
await this.relationshipInfo.create(relationshipInfo);
|
|
768
|
-
return relationshipInfo;
|
|
769
|
-
}
|
|
770
|
-
async updateRelationshipInfo(relationshipInfo) {
|
|
771
|
-
const oldRelationshipInfo = await this.relationshipInfo.read(relationshipInfo.id.toString());
|
|
772
|
-
if (!oldRelationshipInfo) {
|
|
773
|
-
throw new Error("RelationshipInfo Not Found");
|
|
774
|
-
}
|
|
775
|
-
await this.relationshipInfo.update(oldRelationshipInfo, relationshipInfo);
|
|
776
|
-
}
|
|
777
|
-
async deleteRelationshipInfo(relationshipInfo) {
|
|
778
|
-
await this.relationshipInfo.delete(relationshipInfo);
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
exports.RelationshipInfoController = RelationshipInfoController;
|
|
782
|
-
//# sourceMappingURL=RelationshipInfoController.js.map
|
|
783
|
-
|
|
784
|
-
/***/ }),
|
|
785
|
-
|
|
786
|
-
/***/ "./dist/modules/relationships/RelationshipInfoUtil.js":
|
|
787
|
-
/*!************************************************************!*\
|
|
788
|
-
!*** ./dist/modules/relationships/RelationshipInfoUtil.js ***!
|
|
789
|
-
\************************************************************/
|
|
790
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
791
|
-
|
|
792
|
-
"use strict";
|
|
793
|
-
|
|
794
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
795
|
-
exports.RelationshipInfoUtil = void 0;
|
|
796
|
-
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
797
|
-
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
798
|
-
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
799
|
-
const consumption_1 = __webpack_require__(/*! ../../consumption */ "./dist/consumption/index.js");
|
|
800
|
-
const SharedItem_1 = __webpack_require__(/*! ../sharedItems/local/SharedItem */ "./dist/modules/sharedItems/local/SharedItem.js");
|
|
801
|
-
const RelationshipAttribute_1 = __webpack_require__(/*! ./local/RelationshipAttribute */ "./dist/modules/relationships/local/RelationshipAttribute.js");
|
|
802
|
-
const RelationshipInfo_1 = __webpack_require__(/*! ./local/RelationshipInfo */ "./dist/modules/relationships/local/RelationshipInfo.js");
|
|
803
|
-
class RelationshipInfoUtil {
|
|
804
|
-
constructor(parent) {
|
|
805
|
-
this.parent = parent;
|
|
806
|
-
this._log = transport_1.TransportLoggerFactory.getLogger(RelationshipInfoUtil);
|
|
807
|
-
}
|
|
808
|
-
get log() {
|
|
809
|
-
return this._log;
|
|
810
|
-
}
|
|
811
|
-
async createInitialRelationshipInfo(id) {
|
|
812
|
-
const relationship = await this.parent.accountController.relationships.getRelationship(id);
|
|
813
|
-
if (!relationship) {
|
|
814
|
-
throw transport_1.TransportErrors.general.recordNotFound(transport_1.Relationship, id.toString()).logWith(this._log);
|
|
815
|
-
}
|
|
816
|
-
await this.parseTemplateBody(relationship);
|
|
817
|
-
await this.parseCreationRequest(relationship);
|
|
818
|
-
return await this.createRelationshipInfo(relationship);
|
|
819
|
-
}
|
|
820
|
-
getTitle(relationship, attributeMap) {
|
|
821
|
-
let title = relationship.peer.address.toString().substring(3, 9);
|
|
822
|
-
const thingName = attributeMap.get("Thing.name")?.content.value;
|
|
823
|
-
const givenName = attributeMap.get("Person.givenName")?.content.value;
|
|
824
|
-
const familyName = attributeMap.get("Person.familyName")?.content.value;
|
|
825
|
-
const gender = attributeMap.get("Person.gender")?.content.value;
|
|
826
|
-
const orgname = attributeMap.get("Organization.name")?.content.value;
|
|
827
|
-
const legalName = attributeMap.get("Organization.legalname")?.content.value;
|
|
828
|
-
if (thingName) {
|
|
829
|
-
title = thingName;
|
|
830
|
-
}
|
|
831
|
-
else if (givenName && familyName) {
|
|
832
|
-
title = `${givenName} ${familyName}`;
|
|
833
|
-
}
|
|
834
|
-
else if (givenName) {
|
|
835
|
-
title = givenName;
|
|
836
|
-
}
|
|
837
|
-
else if (familyName && gender) {
|
|
838
|
-
title = `i18n://salutation.gender.${gender} ${familyName}`;
|
|
839
|
-
}
|
|
840
|
-
else if (orgname) {
|
|
841
|
-
title = orgname;
|
|
842
|
-
}
|
|
843
|
-
else if (legalName) {
|
|
844
|
-
title = legalName;
|
|
845
|
-
}
|
|
846
|
-
return title;
|
|
847
|
-
}
|
|
848
|
-
async createRelationshipInfo(relationship) {
|
|
849
|
-
const peerAddress = relationship.peer.address;
|
|
850
|
-
const truncatedAddress = peerAddress.address.substring(3, 9);
|
|
851
|
-
const info = RelationshipInfo_1.RelationshipInfo.from({
|
|
852
|
-
attributes: [],
|
|
853
|
-
id: await consumption_1.ConsumptionIds.relationshipInfo.generate(),
|
|
854
|
-
isPinned: false,
|
|
855
|
-
relationshipId: relationship.id,
|
|
856
|
-
title: truncatedAddress
|
|
857
|
-
});
|
|
858
|
-
// info = await this.parent.relationshipInfo.createRelationshipInfo(info)
|
|
859
|
-
const items = await this.parent.sharedItems.getSharedItems({
|
|
860
|
-
sharedBy: relationship.peer.address.toString()
|
|
861
|
-
});
|
|
862
|
-
const attributes = [];
|
|
863
|
-
const attributeMap = new Map();
|
|
864
|
-
for (const item of items) {
|
|
865
|
-
if (item.content instanceof content_1.Attribute) {
|
|
866
|
-
const relAttr = RelationshipAttribute_1.RelationshipAttribute.from({
|
|
867
|
-
name: item.content.name,
|
|
868
|
-
sharedItem: item.id,
|
|
869
|
-
content: item.content
|
|
870
|
-
});
|
|
871
|
-
attributes.push(relAttr);
|
|
872
|
-
attributeMap.set(relAttr.name, relAttr);
|
|
873
|
-
}
|
|
874
|
-
}
|
|
875
|
-
info.attributes = attributes;
|
|
876
|
-
const title = this.getTitle(relationship, attributeMap);
|
|
877
|
-
info.title = title;
|
|
878
|
-
// await this.parent.relationshipInfo.updateRelationshipInfo(info)
|
|
879
|
-
return info;
|
|
880
|
-
}
|
|
881
|
-
async parseTemplateBody(relationship) {
|
|
882
|
-
const template = relationship.cache.template;
|
|
883
|
-
if (!template.cache) {
|
|
884
|
-
throw transport_1.TransportErrors.general.cacheEmpty(transport_1.RelationshipTemplate, template.id.toString()).logWith(this._log);
|
|
885
|
-
}
|
|
886
|
-
const body = template.cache.content;
|
|
887
|
-
const isTemplator = this.parent.accountController.identity.isMe(template.cache.createdBy);
|
|
888
|
-
const sharedAt = template.cache.createdAt;
|
|
889
|
-
const sharedBy = isTemplator ? this.parent.accountController.identity.address : relationship.peer.address;
|
|
890
|
-
const sharedWith = isTemplator ? relationship.peer.address : this.parent.accountController.identity.address;
|
|
891
|
-
const sharedItemsWithSameReference = await this.parent.sharedItems.getSharedItems({
|
|
892
|
-
reference: template.id.toString()
|
|
893
|
-
});
|
|
894
|
-
const missingItems = [];
|
|
895
|
-
if (body instanceof content_1.RelationshipTemplateBody) {
|
|
896
|
-
const attributes = body.sharedAttributes;
|
|
897
|
-
if (attributes) {
|
|
898
|
-
if (sharedItemsWithSameReference.length !== attributes.length) {
|
|
899
|
-
attributes.forEach((attribute) => {
|
|
900
|
-
if (!sharedItemsWithSameReference.find(function (item) {
|
|
901
|
-
const content = item.content;
|
|
902
|
-
return content.name === attribute.name;
|
|
903
|
-
})) {
|
|
904
|
-
missingItems.push(attribute);
|
|
905
|
-
}
|
|
906
|
-
});
|
|
907
|
-
}
|
|
908
|
-
}
|
|
909
|
-
}
|
|
910
|
-
else {
|
|
911
|
-
// Try to parse the old template format (without types)
|
|
912
|
-
let oldTemplateBody = body;
|
|
913
|
-
if (body instanceof ts_serval_1.JSONWrapper) {
|
|
914
|
-
oldTemplateBody = oldTemplateBody.value;
|
|
915
|
-
}
|
|
916
|
-
if (oldTemplateBody?.attributes && Array.isArray(oldTemplateBody.attributes)) {
|
|
917
|
-
if (sharedItemsWithSameReference.length !== oldTemplateBody.attributes.length) {
|
|
918
|
-
oldTemplateBody.attributes.forEach((attribute) => {
|
|
919
|
-
if (!sharedItemsWithSameReference.find(function (item) {
|
|
920
|
-
const content = item.content;
|
|
921
|
-
return content.name === attribute.name;
|
|
922
|
-
})) {
|
|
923
|
-
missingItems.push(content_1.Attribute.from({
|
|
924
|
-
name: attribute.name,
|
|
925
|
-
value: attribute.value
|
|
926
|
-
}));
|
|
927
|
-
}
|
|
928
|
-
});
|
|
929
|
-
}
|
|
930
|
-
}
|
|
931
|
-
}
|
|
932
|
-
for (const attribute of missingItems) {
|
|
933
|
-
const sharedItem = SharedItem_1.SharedItem.from({
|
|
934
|
-
id: await consumption_1.ConsumptionIds.sharedItem.generate(),
|
|
935
|
-
content: attribute,
|
|
936
|
-
sharedAt: sharedAt,
|
|
937
|
-
sharedBy: sharedBy,
|
|
938
|
-
sharedWith: sharedWith,
|
|
939
|
-
reference: template.id,
|
|
940
|
-
expiresAt: attribute.validTo
|
|
941
|
-
});
|
|
942
|
-
await this.parent.sharedItems.createSharedItem(sharedItem);
|
|
943
|
-
}
|
|
944
|
-
}
|
|
945
|
-
async parseCreationRequest(relationship) {
|
|
946
|
-
const change = relationship.cache.creationChange;
|
|
947
|
-
const request = change.request;
|
|
948
|
-
const body = request.content;
|
|
949
|
-
const isRequestor = this.parent.accountController.identity.isMe(request.createdBy);
|
|
950
|
-
const sharedAt = request.createdAt;
|
|
951
|
-
const sharedBy = isRequestor ? this.parent.accountController.identity.address : relationship.peer.address;
|
|
952
|
-
const sharedWith = isRequestor ? relationship.peer.address : this.parent.accountController.identity.address;
|
|
953
|
-
const sharedItemsWithSameReference = await this.parent.sharedItems.getSharedItems({
|
|
954
|
-
reference: change.id.toString()
|
|
955
|
-
});
|
|
956
|
-
const missingItems = [];
|
|
957
|
-
if (body instanceof content_1.RelationshipCreationChangeRequestBody) {
|
|
958
|
-
const attributes = body.sharedAttributes;
|
|
959
|
-
if (attributes && attributes.length > 0) {
|
|
960
|
-
if (sharedItemsWithSameReference.length !== attributes.length) {
|
|
961
|
-
attributes.forEach((attribute) => {
|
|
962
|
-
if (!sharedItemsWithSameReference.find(function (item) {
|
|
963
|
-
const content = item.content;
|
|
964
|
-
return content.name === attribute.name;
|
|
965
|
-
})) {
|
|
966
|
-
missingItems.push(attribute);
|
|
967
|
-
}
|
|
968
|
-
});
|
|
969
|
-
}
|
|
970
|
-
}
|
|
971
|
-
}
|
|
972
|
-
else {
|
|
973
|
-
// Try to parse the old request format (without types)
|
|
974
|
-
let oldRequestBody = body;
|
|
975
|
-
if (body instanceof ts_serval_1.JSONWrapper) {
|
|
976
|
-
oldRequestBody = oldRequestBody.value;
|
|
977
|
-
}
|
|
978
|
-
if (oldRequestBody?.attributes) {
|
|
979
|
-
const keys = Object.keys(oldRequestBody.attributes);
|
|
980
|
-
if (sharedItemsWithSameReference.length !== keys.length) {
|
|
981
|
-
keys.forEach((key) => {
|
|
982
|
-
const attribute = oldRequestBody.attributes[key];
|
|
983
|
-
if (!sharedItemsWithSameReference.find(function (item) {
|
|
984
|
-
const content = item.content;
|
|
985
|
-
return content.name === attribute.name;
|
|
986
|
-
})) {
|
|
987
|
-
missingItems.push(content_1.Attribute.from({
|
|
988
|
-
name: attribute.name,
|
|
989
|
-
value: attribute.value
|
|
990
|
-
}));
|
|
991
|
-
}
|
|
992
|
-
});
|
|
993
|
-
}
|
|
994
|
-
}
|
|
995
|
-
}
|
|
996
|
-
for (const attribute of missingItems) {
|
|
997
|
-
const sharedItem = SharedItem_1.SharedItem.from({
|
|
998
|
-
id: await consumption_1.ConsumptionIds.sharedItem.generate(),
|
|
999
|
-
content: attribute,
|
|
1000
|
-
sharedAt: sharedAt,
|
|
1001
|
-
sharedBy: sharedBy,
|
|
1002
|
-
sharedWith: sharedWith,
|
|
1003
|
-
reference: change.id,
|
|
1004
|
-
expiresAt: attribute.validTo
|
|
1005
|
-
});
|
|
1006
|
-
await this.parent.sharedItems.createSharedItem(sharedItem);
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
}
|
|
1010
|
-
exports.RelationshipInfoUtil = RelationshipInfoUtil;
|
|
1011
|
-
//# sourceMappingURL=RelationshipInfoUtil.js.map
|
|
1012
|
-
|
|
1013
|
-
/***/ }),
|
|
1014
|
-
|
|
1015
|
-
/***/ "./dist/modules/relationships/local/RelationshipAttribute.js":
|
|
1016
|
-
/*!*******************************************************************!*\
|
|
1017
|
-
!*** ./dist/modules/relationships/local/RelationshipAttribute.js ***!
|
|
1018
|
-
\*******************************************************************/
|
|
1019
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
1020
|
-
|
|
1021
|
-
"use strict";
|
|
1022
|
-
|
|
1023
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
1024
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1025
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1026
|
-
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;
|
|
1027
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1028
|
-
};
|
|
1029
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
1030
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1031
|
-
};
|
|
1032
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1033
|
-
exports.RelationshipAttribute = void 0;
|
|
1034
|
-
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
1035
|
-
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
1036
|
-
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
1037
|
-
let RelationshipAttribute = class RelationshipAttribute extends ts_serval_1.Serializable {
|
|
1038
|
-
static from(value) {
|
|
1039
|
-
return this.fromAny(value);
|
|
1040
|
-
}
|
|
1041
|
-
};
|
|
1042
|
-
__decorate([
|
|
1043
|
-
(0, ts_serval_1.validate)(),
|
|
1044
|
-
(0, ts_serval_1.serialize)(),
|
|
1045
|
-
__metadata("design:type", String)
|
|
1046
|
-
], RelationshipAttribute.prototype, "name", void 0);
|
|
1047
|
-
__decorate([
|
|
1048
|
-
(0, ts_serval_1.validate)(),
|
|
1049
|
-
(0, ts_serval_1.serialize)(),
|
|
1050
|
-
__metadata("design:type", content_1.Attribute)
|
|
1051
|
-
], RelationshipAttribute.prototype, "content", void 0);
|
|
1052
|
-
__decorate([
|
|
1053
|
-
(0, ts_serval_1.validate)(),
|
|
1054
|
-
(0, ts_serval_1.serialize)(),
|
|
1055
|
-
__metadata("design:type", transport_1.CoreId)
|
|
1056
|
-
], RelationshipAttribute.prototype, "sharedItem", void 0);
|
|
1057
|
-
RelationshipAttribute = __decorate([
|
|
1058
|
-
(0, ts_serval_1.type)("RelationshipAttribute")
|
|
1059
|
-
], RelationshipAttribute);
|
|
1060
|
-
exports.RelationshipAttribute = RelationshipAttribute;
|
|
1061
|
-
//# sourceMappingURL=RelationshipAttribute.js.map
|
|
1062
|
-
|
|
1063
|
-
/***/ }),
|
|
1064
|
-
|
|
1065
|
-
/***/ "./dist/modules/relationships/local/RelationshipInfo.js":
|
|
1066
|
-
/*!**************************************************************!*\
|
|
1067
|
-
!*** ./dist/modules/relationships/local/RelationshipInfo.js ***!
|
|
1068
|
-
\**************************************************************/
|
|
1069
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
1070
|
-
|
|
1071
|
-
"use strict";
|
|
1072
|
-
|
|
1073
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
1074
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1075
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1076
|
-
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;
|
|
1077
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1078
|
-
};
|
|
1079
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
1080
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1081
|
-
};
|
|
1082
|
-
var RelationshipInfo_1;
|
|
1083
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1084
|
-
exports.RelationshipInfo = void 0;
|
|
1085
|
-
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
1086
|
-
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
1087
|
-
const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
|
|
1088
|
-
const consumption_1 = __webpack_require__(/*! ../../../consumption */ "./dist/consumption/index.js");
|
|
1089
|
-
const RelationshipAttribute_1 = __webpack_require__(/*! ./RelationshipAttribute */ "./dist/modules/relationships/local/RelationshipAttribute.js");
|
|
1090
|
-
const RelationshipTheme_1 = __webpack_require__(/*! ./RelationshipTheme */ "./dist/modules/relationships/local/RelationshipTheme.js");
|
|
1091
|
-
let RelationshipInfo = RelationshipInfo_1 = class RelationshipInfo extends transport_1.CoreSynchronizable {
|
|
1092
|
-
constructor() {
|
|
1093
|
-
super(...arguments);
|
|
1094
|
-
this.technicalProperties = [
|
|
1095
|
-
"@type",
|
|
1096
|
-
"@context",
|
|
1097
|
-
(0, ts_simple_nameof_1.nameof)((r) => r.relationshipId),
|
|
1098
|
-
(0, ts_simple_nameof_1.nameof)((r) => r.title),
|
|
1099
|
-
(0, ts_simple_nameof_1.nameof)((r) => r.description),
|
|
1100
|
-
(0, ts_simple_nameof_1.nameof)((r) => r.theme)
|
|
1101
|
-
];
|
|
1102
|
-
this.userdataProperties = [
|
|
1103
|
-
(0, ts_simple_nameof_1.nameof)((r) => r.isPinned),
|
|
1104
|
-
(0, ts_simple_nameof_1.nameof)((r) => r.userTitle),
|
|
1105
|
-
(0, ts_simple_nameof_1.nameof)((r) => r.userDescription)
|
|
1106
|
-
];
|
|
1107
|
-
}
|
|
1108
|
-
static async fromRelationship(relationship) {
|
|
1109
|
-
if (typeof relationship.metadata === "undefined") {
|
|
1110
|
-
return RelationshipInfo_1.from({
|
|
1111
|
-
id: await consumption_1.ConsumptionIds.relationshipInfo.generate(),
|
|
1112
|
-
relationshipId: relationship.id,
|
|
1113
|
-
attributes: [],
|
|
1114
|
-
isPinned: false,
|
|
1115
|
-
title: relationship.peer.address.address.substring(3, 9)
|
|
1116
|
-
});
|
|
1117
|
-
}
|
|
1118
|
-
return RelationshipInfo_1.from(relationship.metadata);
|
|
1119
|
-
}
|
|
1120
|
-
static from(value) {
|
|
1121
|
-
return this.fromAny(value);
|
|
1122
|
-
}
|
|
1123
|
-
};
|
|
1124
|
-
__decorate([
|
|
1125
|
-
(0, ts_serval_1.validate)(),
|
|
1126
|
-
(0, ts_serval_1.serialize)(),
|
|
1127
|
-
__metadata("design:type", transport_1.CoreId)
|
|
1128
|
-
], RelationshipInfo.prototype, "relationshipId", void 0);
|
|
1129
|
-
__decorate([
|
|
1130
|
-
(0, ts_serval_1.validate)(),
|
|
1131
|
-
(0, ts_serval_1.serialize)({ type: RelationshipAttribute_1.RelationshipAttribute }),
|
|
1132
|
-
__metadata("design:type", Array)
|
|
1133
|
-
], RelationshipInfo.prototype, "attributes", void 0);
|
|
1134
|
-
__decorate([
|
|
1135
|
-
(0, ts_serval_1.validate)(),
|
|
1136
|
-
(0, ts_serval_1.serialize)(),
|
|
1137
|
-
__metadata("design:type", Boolean)
|
|
1138
|
-
], RelationshipInfo.prototype, "isPinned", void 0);
|
|
1139
|
-
__decorate([
|
|
1140
|
-
(0, ts_serval_1.validate)({ nullable: true }),
|
|
1141
|
-
(0, ts_serval_1.serialize)(),
|
|
1142
|
-
__metadata("design:type", String)
|
|
1143
|
-
], RelationshipInfo.prototype, "userTitle", void 0);
|
|
1144
|
-
__decorate([
|
|
1145
|
-
(0, ts_serval_1.validate)(),
|
|
1146
|
-
(0, ts_serval_1.serialize)(),
|
|
1147
|
-
__metadata("design:type", String)
|
|
1148
|
-
], RelationshipInfo.prototype, "title", void 0);
|
|
1149
|
-
__decorate([
|
|
1150
|
-
(0, ts_serval_1.validate)({ nullable: true }),
|
|
1151
|
-
(0, ts_serval_1.serialize)(),
|
|
1152
|
-
__metadata("design:type", String)
|
|
1153
|
-
], RelationshipInfo.prototype, "userDescription", void 0);
|
|
1154
|
-
__decorate([
|
|
1155
|
-
(0, ts_serval_1.validate)({ nullable: true }),
|
|
1156
|
-
(0, ts_serval_1.serialize)(),
|
|
1157
|
-
__metadata("design:type", String)
|
|
1158
|
-
], RelationshipInfo.prototype, "description", void 0);
|
|
1159
|
-
__decorate([
|
|
1160
|
-
(0, ts_serval_1.validate)({ nullable: true }),
|
|
1161
|
-
(0, ts_serval_1.serialize)(),
|
|
1162
|
-
__metadata("design:type", RelationshipTheme_1.RelationshipTheme)
|
|
1163
|
-
], RelationshipInfo.prototype, "theme", void 0);
|
|
1164
|
-
RelationshipInfo = RelationshipInfo_1 = __decorate([
|
|
1165
|
-
(0, ts_serval_1.type)("RelationshipInfo")
|
|
1166
|
-
], RelationshipInfo);
|
|
1167
|
-
exports.RelationshipInfo = RelationshipInfo;
|
|
1168
|
-
//# sourceMappingURL=RelationshipInfo.js.map
|
|
1169
|
-
|
|
1170
|
-
/***/ }),
|
|
1171
|
-
|
|
1172
|
-
/***/ "./dist/modules/relationships/local/RelationshipTheme.js":
|
|
1173
|
-
/*!***************************************************************!*\
|
|
1174
|
-
!*** ./dist/modules/relationships/local/RelationshipTheme.js ***!
|
|
1175
|
-
\***************************************************************/
|
|
1176
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
1177
|
-
|
|
1178
|
-
"use strict";
|
|
1179
|
-
|
|
1180
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
1181
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
1182
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
1183
|
-
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;
|
|
1184
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
1185
|
-
};
|
|
1186
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
1187
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
1188
|
-
};
|
|
1189
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
1190
|
-
exports.RelationshipTheme = void 0;
|
|
1191
|
-
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
1192
|
-
let RelationshipTheme = class RelationshipTheme extends ts_serval_1.Serializable {
|
|
1193
|
-
static from(value) {
|
|
1194
|
-
return this.fromAny(value);
|
|
1195
|
-
}
|
|
1196
|
-
};
|
|
1197
|
-
__decorate([
|
|
1198
|
-
(0, ts_serval_1.validate)(),
|
|
1199
|
-
(0, ts_serval_1.serialize)(),
|
|
1200
|
-
__metadata("design:type", String)
|
|
1201
|
-
], RelationshipTheme.prototype, "image", void 0);
|
|
1202
|
-
__decorate([
|
|
1203
|
-
(0, ts_serval_1.validate)(),
|
|
1204
|
-
(0, ts_serval_1.serialize)(),
|
|
1205
|
-
__metadata("design:type", String)
|
|
1206
|
-
], RelationshipTheme.prototype, "imageBar", void 0);
|
|
1207
|
-
__decorate([
|
|
1208
|
-
(0, ts_serval_1.validate)(),
|
|
1209
|
-
(0, ts_serval_1.serialize)(),
|
|
1210
|
-
__metadata("design:type", String)
|
|
1211
|
-
], RelationshipTheme.prototype, "backgroundColor", void 0);
|
|
1212
|
-
__decorate([
|
|
1213
|
-
(0, ts_serval_1.validate)(),
|
|
1214
|
-
(0, ts_serval_1.serialize)(),
|
|
1215
|
-
__metadata("design:type", String)
|
|
1216
|
-
], RelationshipTheme.prototype, "foregroundColor", void 0);
|
|
1217
|
-
RelationshipTheme = __decorate([
|
|
1218
|
-
(0, ts_serval_1.type)("RelationshipTheme")
|
|
1219
|
-
], RelationshipTheme);
|
|
1220
|
-
exports.RelationshipTheme = RelationshipTheme;
|
|
1221
|
-
//# sourceMappingURL=RelationshipTheme.js.map
|
|
1222
|
-
|
|
1223
|
-
/***/ }),
|
|
1224
|
-
|
|
1225
698
|
/***/ "./dist/modules/requests/incoming/DecideRequestParametersValidator.js":
|
|
1226
699
|
/*!****************************************************************************!*\
|
|
1227
700
|
!*** ./dist/modules/requests/incoming/DecideRequestParametersValidator.js ***!
|
|
@@ -1324,21 +797,17 @@ const DecideRequestParametersValidator_1 = __webpack_require__(/*! ./DecideReque
|
|
|
1324
797
|
const ReceivedIncomingRequestParameters_1 = __webpack_require__(/*! ./received/ReceivedIncomingRequestParameters */ "./dist/modules/requests/incoming/received/ReceivedIncomingRequestParameters.js");
|
|
1325
798
|
const RequireManualDecisionOfIncomingRequestParameters_1 = __webpack_require__(/*! ./requireManualDecision/RequireManualDecisionOfIncomingRequestParameters */ "./dist/modules/requests/incoming/requireManualDecision/RequireManualDecisionOfIncomingRequestParameters.js");
|
|
1326
799
|
class IncomingRequestsController extends consumption_1.ConsumptionBaseController {
|
|
1327
|
-
constructor(
|
|
800
|
+
constructor(consumptionRequests, processorRegistry, parent) {
|
|
1328
801
|
super(consumption_1.ConsumptionControllerName.RequestsController, parent);
|
|
802
|
+
this.consumptionRequests = consumptionRequests;
|
|
1329
803
|
this.processorRegistry = processorRegistry;
|
|
1330
804
|
this.decideRequestParamsValidator = new DecideRequestParametersValidator_1.DecideRequestParametersValidator();
|
|
1331
805
|
}
|
|
1332
|
-
async init() {
|
|
1333
|
-
await super.init();
|
|
1334
|
-
this.consumptionRequests = await this.parent.accountController.getSynchronizedCollection("Requests");
|
|
1335
|
-
return this;
|
|
1336
|
-
}
|
|
1337
806
|
async received(params) {
|
|
1338
807
|
const parsedParams = ReceivedIncomingRequestParameters_1.ReceivedIncomingRequestParameters.from(params);
|
|
1339
808
|
const infoFromSource = this.extractInfoFromSource(parsedParams.requestSourceObject);
|
|
1340
809
|
const consumptionRequest = ConsumptionRequest_1.ConsumptionRequest.from({
|
|
1341
|
-
id: parsedParams.receivedRequest.id ?? (await
|
|
810
|
+
id: parsedParams.receivedRequest.id ?? (await consumption_1.ConsumptionIds.request.generate()),
|
|
1342
811
|
createdAt: transport_1.CoreDate.utc(),
|
|
1343
812
|
status: ConsumptionRequestStatus_1.ConsumptionRequestStatus.Open,
|
|
1344
813
|
content: parsedParams.receivedRequest,
|
|
@@ -1557,13 +1026,20 @@ class IncomingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
1557
1026
|
await this.update(request);
|
|
1558
1027
|
return request;
|
|
1559
1028
|
}
|
|
1560
|
-
async
|
|
1561
|
-
|
|
1029
|
+
async getIncomingRequests(query) {
|
|
1030
|
+
query ??= {};
|
|
1031
|
+
query.isOwn = false;
|
|
1032
|
+
const requestDocs = await this.consumptionRequests.find(query);
|
|
1033
|
+
const requests = requestDocs.map((r) => ConsumptionRequest_1.ConsumptionRequest.from(r));
|
|
1034
|
+
return requests;
|
|
1035
|
+
}
|
|
1036
|
+
async getIncomingRequest(idIncomingRequest) {
|
|
1037
|
+
const requestDoc = await this.consumptionRequests.findOne({ id: idIncomingRequest.toString(), isOwn: false });
|
|
1562
1038
|
const request = requestDoc ? ConsumptionRequest_1.ConsumptionRequest.from(requestDoc) : undefined;
|
|
1563
1039
|
return request;
|
|
1564
1040
|
}
|
|
1565
1041
|
async getOrThrow(id) {
|
|
1566
|
-
const request = await this.
|
|
1042
|
+
const request = await this.getIncomingRequest(transport_1.CoreId.from(id));
|
|
1567
1043
|
if (!request) {
|
|
1568
1044
|
throw transport_1.TransportErrors.general.recordNotFound(ConsumptionRequest_1.ConsumptionRequest, id.toString());
|
|
1569
1045
|
}
|
|
@@ -2324,15 +1800,11 @@ const CreateOutgoingRequestFromRelationshipCreationChangeParameters_1 = __webpac
|
|
|
2324
1800
|
const CreateOutgoingRequestParameters_1 = __webpack_require__(/*! ./createOutgoingRequest/CreateOutgoingRequestParameters */ "./dist/modules/requests/outgoing/createOutgoingRequest/CreateOutgoingRequestParameters.js");
|
|
2325
1801
|
const SentOutgoingRequestParameters_1 = __webpack_require__(/*! ./sentOutgoingRequest/SentOutgoingRequestParameters */ "./dist/modules/requests/outgoing/sentOutgoingRequest/SentOutgoingRequestParameters.js");
|
|
2326
1802
|
class OutgoingRequestsController extends consumption_1.ConsumptionBaseController {
|
|
2327
|
-
constructor(
|
|
1803
|
+
constructor(consumptionRequests, processorRegistry, parent) {
|
|
2328
1804
|
super(consumption_1.ConsumptionControllerName.RequestsController, parent);
|
|
1805
|
+
this.consumptionRequests = consumptionRequests;
|
|
2329
1806
|
this.processorRegistry = processorRegistry;
|
|
2330
1807
|
}
|
|
2331
|
-
async init() {
|
|
2332
|
-
await super.init();
|
|
2333
|
-
this.consumptionRequests = await this.parent.accountController.getSynchronizedCollection("Requests");
|
|
2334
|
-
return this;
|
|
2335
|
-
}
|
|
2336
1808
|
async canCreate(params) {
|
|
2337
1809
|
const parsedParams = CreateOutgoingRequestParameters_1.CreateOutgoingRequestParameters.from(params);
|
|
2338
1810
|
const innerResults = await this.canCreateItems(parsedParams.content.items);
|
|
@@ -2507,13 +1979,20 @@ class OutgoingRequestsController extends consumption_1.ConsumptionBaseController
|
|
|
2507
1979
|
const processor = this.processorRegistry.getProcessorForItem(requestItem);
|
|
2508
1980
|
await processor.applyIncomingResponseItem(responseItem, requestItem);
|
|
2509
1981
|
}
|
|
2510
|
-
async
|
|
1982
|
+
async getOutgoingRequests(query) {
|
|
1983
|
+
query ??= {};
|
|
1984
|
+
query.isOwn = true;
|
|
1985
|
+
const requestDocs = await this.consumptionRequests.find(query);
|
|
1986
|
+
const requests = requestDocs.map((r) => ConsumptionRequest_1.ConsumptionRequest.from(r));
|
|
1987
|
+
return requests;
|
|
1988
|
+
}
|
|
1989
|
+
async getOutgoingRequest(id) {
|
|
2511
1990
|
const requestDoc = await this.consumptionRequests.findOne({ id: id.toString(), isOwn: true });
|
|
2512
1991
|
const request = requestDoc ? ConsumptionRequest_1.ConsumptionRequest.from(requestDoc) : undefined;
|
|
2513
1992
|
return request;
|
|
2514
1993
|
}
|
|
2515
1994
|
async getOrThrow(id) {
|
|
2516
|
-
const request = await this.
|
|
1995
|
+
const request = await this.getOutgoingRequest(id);
|
|
2517
1996
|
if (!request) {
|
|
2518
1997
|
throw transport_1.TransportErrors.general.recordNotFound(ConsumptionRequest_1.ConsumptionRequest, id.toString());
|
|
2519
1998
|
}
|
|
@@ -2890,166 +2369,6 @@ exports.Setting = Setting;
|
|
|
2890
2369
|
|
|
2891
2370
|
/***/ }),
|
|
2892
2371
|
|
|
2893
|
-
/***/ "./dist/modules/sharedItems/SharedItemsController.js":
|
|
2894
|
-
/*!***********************************************************!*\
|
|
2895
|
-
!*** ./dist/modules/sharedItems/SharedItemsController.js ***!
|
|
2896
|
-
\***********************************************************/
|
|
2897
|
-
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2898
|
-
|
|
2899
|
-
"use strict";
|
|
2900
|
-
|
|
2901
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2902
|
-
exports.SharedItemsController = void 0;
|
|
2903
|
-
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
2904
|
-
const consumption_1 = __webpack_require__(/*! ../../consumption */ "./dist/consumption/index.js");
|
|
2905
|
-
const SharedItem_1 = __webpack_require__(/*! ./local/SharedItem */ "./dist/modules/sharedItems/local/SharedItem.js");
|
|
2906
|
-
class SharedItemsController extends consumption_1.ConsumptionBaseController {
|
|
2907
|
-
constructor(parent) {
|
|
2908
|
-
super(consumption_1.ConsumptionControllerName.SharedItemsController, parent);
|
|
2909
|
-
}
|
|
2910
|
-
async init() {
|
|
2911
|
-
await super.init();
|
|
2912
|
-
this.sharedItems = await this.parent.accountController.getSynchronizedCollection("SharedItems");
|
|
2913
|
-
return this;
|
|
2914
|
-
}
|
|
2915
|
-
async getSharedItem(id) {
|
|
2916
|
-
const result = await this.sharedItems.read(id.toString());
|
|
2917
|
-
return result ? SharedItem_1.SharedItem.from(result) : undefined;
|
|
2918
|
-
}
|
|
2919
|
-
async getSharedItems(query) {
|
|
2920
|
-
const items = await this.sharedItems.find(query);
|
|
2921
|
-
return await this.parseArray(items, SharedItem_1.SharedItem);
|
|
2922
|
-
}
|
|
2923
|
-
async createSharedItem(sharedItem) {
|
|
2924
|
-
await this.sharedItems.create(sharedItem);
|
|
2925
|
-
return sharedItem;
|
|
2926
|
-
}
|
|
2927
|
-
async updateSharedItem(sharedItem) {
|
|
2928
|
-
const oldSharedItem = await this.sharedItems.read(sharedItem.id.toString());
|
|
2929
|
-
if (!oldSharedItem) {
|
|
2930
|
-
throw transport_1.TransportErrors.general.recordNotFound(SharedItem_1.SharedItem, sharedItem.id.toString());
|
|
2931
|
-
}
|
|
2932
|
-
return await this.sharedItems.update(oldSharedItem, sharedItem);
|
|
2933
|
-
}
|
|
2934
|
-
async deleteSharedItem(sharedItem) {
|
|
2935
|
-
await this.sharedItems.delete(sharedItem);
|
|
2936
|
-
}
|
|
2937
|
-
}
|
|
2938
|
-
exports.SharedItemsController = SharedItemsController;
|
|
2939
|
-
//# sourceMappingURL=SharedItemsController.js.map
|
|
2940
|
-
|
|
2941
|
-
/***/ }),
|
|
2942
|
-
|
|
2943
|
-
/***/ "./dist/modules/sharedItems/local/SharedItem.js":
|
|
2944
|
-
/*!******************************************************!*\
|
|
2945
|
-
!*** ./dist/modules/sharedItems/local/SharedItem.js ***!
|
|
2946
|
-
\******************************************************/
|
|
2947
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2948
|
-
|
|
2949
|
-
"use strict";
|
|
2950
|
-
|
|
2951
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2952
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
2953
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
2954
|
-
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;
|
|
2955
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2956
|
-
};
|
|
2957
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
2958
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
2959
|
-
};
|
|
2960
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2961
|
-
exports.SharedItem = void 0;
|
|
2962
|
-
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
2963
|
-
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
2964
|
-
const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
|
|
2965
|
-
let SharedItem = class SharedItem extends transport_1.CoreSynchronizable {
|
|
2966
|
-
constructor() {
|
|
2967
|
-
super(...arguments);
|
|
2968
|
-
this.technicalProperties = [
|
|
2969
|
-
"@type",
|
|
2970
|
-
"@context",
|
|
2971
|
-
(0, ts_simple_nameof_1.nameof)((r) => r.tags),
|
|
2972
|
-
(0, ts_simple_nameof_1.nameof)((r) => r.sharedBy),
|
|
2973
|
-
(0, ts_simple_nameof_1.nameof)((r) => r.sharedWith),
|
|
2974
|
-
(0, ts_simple_nameof_1.nameof)((r) => r.sharedAt),
|
|
2975
|
-
(0, ts_simple_nameof_1.nameof)((r) => r.reference),
|
|
2976
|
-
(0, ts_simple_nameof_1.nameof)((r) => r.content),
|
|
2977
|
-
(0, ts_simple_nameof_1.nameof)((r) => r.succeedsItem),
|
|
2978
|
-
(0, ts_simple_nameof_1.nameof)((r) => r.succeedsAt),
|
|
2979
|
-
(0, ts_simple_nameof_1.nameof)((r) => r.expiresAt)
|
|
2980
|
-
];
|
|
2981
|
-
this.metadataProperties = [
|
|
2982
|
-
(0, ts_simple_nameof_1.nameof)((r) => r.metadata),
|
|
2983
|
-
(0, ts_simple_nameof_1.nameof)((r) => r.metadataModifiedAt)
|
|
2984
|
-
];
|
|
2985
|
-
}
|
|
2986
|
-
static from(value) {
|
|
2987
|
-
return this.fromAny(value);
|
|
2988
|
-
}
|
|
2989
|
-
};
|
|
2990
|
-
__decorate([
|
|
2991
|
-
(0, ts_serval_1.validate)({ nullable: true }),
|
|
2992
|
-
(0, ts_serval_1.serialize)({ type: String }),
|
|
2993
|
-
__metadata("design:type", Array)
|
|
2994
|
-
], SharedItem.prototype, "tags", void 0);
|
|
2995
|
-
__decorate([
|
|
2996
|
-
(0, ts_serval_1.validate)(),
|
|
2997
|
-
(0, ts_serval_1.serialize)(),
|
|
2998
|
-
__metadata("design:type", transport_1.CoreAddress)
|
|
2999
|
-
], SharedItem.prototype, "sharedBy", void 0);
|
|
3000
|
-
__decorate([
|
|
3001
|
-
(0, ts_serval_1.validate)(),
|
|
3002
|
-
(0, ts_serval_1.serialize)(),
|
|
3003
|
-
__metadata("design:type", transport_1.CoreAddress)
|
|
3004
|
-
], SharedItem.prototype, "sharedWith", void 0);
|
|
3005
|
-
__decorate([
|
|
3006
|
-
(0, ts_serval_1.validate)(),
|
|
3007
|
-
(0, ts_serval_1.serialize)(),
|
|
3008
|
-
__metadata("design:type", transport_1.CoreDate)
|
|
3009
|
-
], SharedItem.prototype, "sharedAt", void 0);
|
|
3010
|
-
__decorate([
|
|
3011
|
-
(0, ts_serval_1.validate)({ nullable: true }),
|
|
3012
|
-
(0, ts_serval_1.serialize)(),
|
|
3013
|
-
__metadata("design:type", transport_1.CoreId)
|
|
3014
|
-
], SharedItem.prototype, "reference", void 0);
|
|
3015
|
-
__decorate([
|
|
3016
|
-
(0, ts_serval_1.validate)(),
|
|
3017
|
-
(0, ts_serval_1.serialize)(),
|
|
3018
|
-
__metadata("design:type", ts_serval_1.Serializable)
|
|
3019
|
-
], SharedItem.prototype, "content", void 0);
|
|
3020
|
-
__decorate([
|
|
3021
|
-
(0, ts_serval_1.validate)({ nullable: true }),
|
|
3022
|
-
(0, ts_serval_1.serialize)(),
|
|
3023
|
-
__metadata("design:type", transport_1.CoreId)
|
|
3024
|
-
], SharedItem.prototype, "succeedsItem", void 0);
|
|
3025
|
-
__decorate([
|
|
3026
|
-
(0, ts_serval_1.validate)({ nullable: true }),
|
|
3027
|
-
(0, ts_serval_1.serialize)(),
|
|
3028
|
-
__metadata("design:type", transport_1.CoreDate)
|
|
3029
|
-
], SharedItem.prototype, "succeedsAt", void 0);
|
|
3030
|
-
__decorate([
|
|
3031
|
-
(0, ts_serval_1.validate)({ nullable: true }),
|
|
3032
|
-
(0, ts_serval_1.serialize)(),
|
|
3033
|
-
__metadata("design:type", transport_1.CoreDate)
|
|
3034
|
-
], SharedItem.prototype, "expiresAt", void 0);
|
|
3035
|
-
__decorate([
|
|
3036
|
-
(0, ts_serval_1.validate)({ nullable: true }),
|
|
3037
|
-
(0, ts_serval_1.serialize)({ any: true }),
|
|
3038
|
-
__metadata("design:type", Object)
|
|
3039
|
-
], SharedItem.prototype, "metadata", void 0);
|
|
3040
|
-
__decorate([
|
|
3041
|
-
(0, ts_serval_1.validate)({ nullable: true }),
|
|
3042
|
-
(0, ts_serval_1.serialize)(),
|
|
3043
|
-
__metadata("design:type", transport_1.CoreDate)
|
|
3044
|
-
], SharedItem.prototype, "metadataModifiedAt", void 0);
|
|
3045
|
-
SharedItem = __decorate([
|
|
3046
|
-
(0, ts_serval_1.type)("SharedItem")
|
|
3047
|
-
], SharedItem);
|
|
3048
|
-
exports.SharedItem = SharedItem;
|
|
3049
|
-
//# sourceMappingURL=SharedItem.js.map
|
|
3050
|
-
|
|
3051
|
-
/***/ }),
|
|
3052
|
-
|
|
3053
2372
|
/***/ "./dist/modules/signatures/Signature.js":
|
|
3054
2373
|
/*!**********************************************!*\
|
|
3055
2374
|
!*** ./dist/modules/signatures/Signature.js ***!
|