@nmshd/consumption 2.0.0-alpha.25 → 2.0.0-alpha.28
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/modules/attributes/LocalAttributesController.d.ts +3 -4
- package/dist/modules/attributes/LocalAttributesController.js +11 -12
- package/dist/modules/attributes/LocalAttributesController.js.map +1 -1
- package/dist/modules/attributes/local/CreateSharedLocalAttributeCopyParams.d.ts +6 -3
- package/dist/modules/attributes/local/CreateSharedLocalAttributeCopyParams.js +6 -1
- package/dist/modules/attributes/local/CreateSharedLocalAttributeCopyParams.js.map +1 -1
- package/dist/modules/attributes/local/LocalAttribute.d.ts +4 -2
- package/dist/modules/attributes/local/LocalAttribute.js +8 -2
- package/dist/modules/attributes/local/LocalAttribute.js.map +1 -1
- package/dist/modules/attributes/local/QueryTranslator.d.ts +9 -3
- package/dist/modules/attributes/local/QueryTranslator.js +31 -20
- package/dist/modules/attributes/local/QueryTranslator.js.map +1 -1
- package/dist/modules/index.d.ts +0 -2
- package/dist/modules/index.js +0 -2
- package/dist/modules/index.js.map +1 -1
- package/dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.d.ts +1 -1
- package/dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js +25 -8
- package/dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js.map +1 -1
- package/dist/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.js +2 -2
- package/dist/modules/requests/itemProcessors/proposeAttribute/ProposeAttributeRequestItemProcessor.js.map +1 -1
- package/dist/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.js +2 -2
- package/dist/modules/requests/itemProcessors/readAttribute/ReadAttributeRequestItemProcessor.js.map +1 -1
- package/dist/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.js +3 -2
- package/dist/modules/requests/itemProcessors/shareAttribute/ShareAttributeRequestItemProcessor.js.map +1 -1
- package/lib-web/nmshd.consumption.js +92 -127
- package/lib-web/nmshd.consumption.js.map +1 -1
- package/lib-web/nmshd.consumption.min.js +1 -1
- package/lib-web/nmshd.consumption.min.js.map +1 -1
- package/package.json +2 -2
- package/dist/modules/attributes/local/GetIdentityAttributesParams.d.ts +0 -12
- package/dist/modules/attributes/local/GetIdentityAttributesParams.js +0 -26
- package/dist/modules/attributes/local/GetIdentityAttributesParams.js.map +0 -1
- package/dist/modules/attributes/local/GetRelationshipAttributesParams.d.ts +0 -12
- package/dist/modules/attributes/local/GetRelationshipAttributesParams.js +0 -26
- package/dist/modules/attributes/local/GetRelationshipAttributesParams.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-07-
|
|
23
|
-
commit: "
|
|
20
|
+
version: "2.0.0-alpha.28",
|
|
21
|
+
build: "48",
|
|
22
|
+
date: "2022-07-07T13:12:39+00:00",
|
|
23
|
+
commit: "81c8304697f68fe9ed157cebc415dd1fb2f7b941",
|
|
24
24
|
dependencies: {"@js-soft/docdb-querytranslator":"^1.0.1","ts-simple-nameof":"^1.3.1"},
|
|
25
25
|
libraries: {
|
|
26
26
|
transport: transport_1.buildInformation,
|
|
@@ -306,6 +306,7 @@ __exportStar(__webpack_require__(/*! ./modules */ "./dist/modules/index.js"), ex
|
|
|
306
306
|
|
|
307
307
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
308
308
|
exports.LocalAttributesController = void 0;
|
|
309
|
+
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
309
310
|
const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
|
|
310
311
|
const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
|
|
311
312
|
const consumption_1 = __webpack_require__(/*! ../../consumption */ "./dist/consumption/index.js");
|
|
@@ -387,17 +388,15 @@ class LocalAttributesController extends consumption_1.ConsumptionBaseController
|
|
|
387
388
|
const items = await this.parseArray(attributes, LocalAttribute_1.LocalAttribute);
|
|
388
389
|
return this.filterCurrent(items);
|
|
389
390
|
}
|
|
390
|
-
async executeRelationshipAttributeQuery(
|
|
391
|
-
const
|
|
392
|
-
|
|
393
|
-
const dbQuery = QueryTranslator_1.relationshipQueryTranslator.parse(queryWithType);
|
|
391
|
+
async executeRelationshipAttributeQuery(query) {
|
|
392
|
+
const parsedQuery = content_1.RelationshipAttributeQuery.from(query);
|
|
393
|
+
const dbQuery = QueryTranslator_1.RelationshipAttributeQueryTranslator.translate(parsedQuery);
|
|
394
394
|
const attributes = await this.attributes.find(dbQuery);
|
|
395
395
|
return await this.parseArray(attributes, LocalAttribute_1.LocalAttribute);
|
|
396
396
|
}
|
|
397
|
-
async executeIdentityAttributeQuery(
|
|
398
|
-
const
|
|
399
|
-
|
|
400
|
-
const dbQuery = QueryTranslator_1.identityQueryTranslator.parse(queryWithType);
|
|
397
|
+
async executeIdentityAttributeQuery(query) {
|
|
398
|
+
const parsedQuery = content_1.IdentityAttributeQuery.from(query);
|
|
399
|
+
const dbQuery = QueryTranslator_1.IdentityAttributeQueryTranslator.translate(parsedQuery);
|
|
401
400
|
const attributes = await this.attributes.find(dbQuery);
|
|
402
401
|
return await this.parseArray(attributes, LocalAttribute_1.LocalAttribute);
|
|
403
402
|
}
|
|
@@ -427,16 +426,16 @@ class LocalAttributesController extends consumption_1.ConsumptionBaseController
|
|
|
427
426
|
}
|
|
428
427
|
async createSharedLocalAttributeCopy(params) {
|
|
429
428
|
const parsedParams = CreateSharedLocalAttributeCopyParams_1.CreateSharedLocalAttributeCopyParams.from(params);
|
|
430
|
-
const sourceAttribute = await this.getLocalAttribute(parsedParams.
|
|
429
|
+
const sourceAttribute = await this.getLocalAttribute(parsedParams.sourceAttributeId);
|
|
431
430
|
if (!sourceAttribute) {
|
|
432
|
-
throw consumption_1.ConsumptionErrors.attributes.predecessorNotFound(parsedParams.
|
|
431
|
+
throw consumption_1.ConsumptionErrors.attributes.predecessorNotFound(parsedParams.sourceAttributeId.toString());
|
|
433
432
|
}
|
|
434
433
|
const shareInfo = LocalAttributeShareInfo_1.LocalAttributeShareInfo.from({
|
|
435
434
|
peer: parsedParams.peer,
|
|
436
435
|
requestReference: parsedParams.requestReference,
|
|
437
|
-
sourceAttribute: parsedParams.
|
|
436
|
+
sourceAttribute: parsedParams.sourceAttributeId
|
|
438
437
|
});
|
|
439
|
-
const sharedLocalAttributeCopy = await LocalAttribute_1.LocalAttribute.fromAttribute(sourceAttribute.content, undefined, shareInfo);
|
|
438
|
+
const sharedLocalAttributeCopy = await LocalAttribute_1.LocalAttribute.fromAttribute(sourceAttribute.content, undefined, shareInfo, parsedParams.attributeId);
|
|
440
439
|
await this.attributes.create(sharedLocalAttributeCopy);
|
|
441
440
|
return sharedLocalAttributeCopy;
|
|
442
441
|
}
|
|
@@ -597,9 +596,14 @@ class CreateSharedLocalAttributeCopyParams extends ts_serval_1.Serializable {
|
|
|
597
596
|
}
|
|
598
597
|
__decorate([
|
|
599
598
|
(0, ts_serval_1.serialize)(),
|
|
600
|
-
(0, ts_serval_1.validate)(),
|
|
599
|
+
(0, ts_serval_1.validate)({ nullable: true }),
|
|
601
600
|
__metadata("design:type", transport_1.CoreId)
|
|
602
601
|
], CreateSharedLocalAttributeCopyParams.prototype, "attributeId", void 0);
|
|
602
|
+
__decorate([
|
|
603
|
+
(0, ts_serval_1.serialize)(),
|
|
604
|
+
(0, ts_serval_1.validate)(),
|
|
605
|
+
__metadata("design:type", transport_1.CoreId)
|
|
606
|
+
], CreateSharedLocalAttributeCopyParams.prototype, "sourceAttributeId", void 0);
|
|
603
607
|
__decorate([
|
|
604
608
|
(0, ts_serval_1.serialize)(),
|
|
605
609
|
(0, ts_serval_1.validate)(),
|
|
@@ -615,78 +619,6 @@ exports.CreateSharedLocalAttributeCopyParams = CreateSharedLocalAttributeCopyPar
|
|
|
615
619
|
|
|
616
620
|
/***/ }),
|
|
617
621
|
|
|
618
|
-
/***/ "./dist/modules/attributes/local/GetIdentityAttributesParams.js":
|
|
619
|
-
/*!**********************************************************************!*\
|
|
620
|
-
!*** ./dist/modules/attributes/local/GetIdentityAttributesParams.js ***!
|
|
621
|
-
\**********************************************************************/
|
|
622
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
623
|
-
|
|
624
|
-
"use strict";
|
|
625
|
-
|
|
626
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
627
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
628
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
629
|
-
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;
|
|
630
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
631
|
-
};
|
|
632
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
633
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
634
|
-
};
|
|
635
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
636
|
-
exports.GetIdentityAttributesParams = void 0;
|
|
637
|
-
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
638
|
-
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
639
|
-
class GetIdentityAttributesParams extends ts_serval_1.Serializable {
|
|
640
|
-
static from(value) {
|
|
641
|
-
return this.fromAny(value);
|
|
642
|
-
}
|
|
643
|
-
}
|
|
644
|
-
__decorate([
|
|
645
|
-
(0, ts_serval_1.serialize)(),
|
|
646
|
-
(0, ts_serval_1.validate)(),
|
|
647
|
-
__metadata("design:type", content_1.IdentityAttributeQuery)
|
|
648
|
-
], GetIdentityAttributesParams.prototype, "query", void 0);
|
|
649
|
-
exports.GetIdentityAttributesParams = GetIdentityAttributesParams;
|
|
650
|
-
//# sourceMappingURL=GetIdentityAttributesParams.js.map
|
|
651
|
-
|
|
652
|
-
/***/ }),
|
|
653
|
-
|
|
654
|
-
/***/ "./dist/modules/attributes/local/GetRelationshipAttributesParams.js":
|
|
655
|
-
/*!**************************************************************************!*\
|
|
656
|
-
!*** ./dist/modules/attributes/local/GetRelationshipAttributesParams.js ***!
|
|
657
|
-
\**************************************************************************/
|
|
658
|
-
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
659
|
-
|
|
660
|
-
"use strict";
|
|
661
|
-
|
|
662
|
-
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
663
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
664
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
665
|
-
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;
|
|
666
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
667
|
-
};
|
|
668
|
-
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
669
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
670
|
-
};
|
|
671
|
-
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
672
|
-
exports.GetRelationshipAttributesParams = void 0;
|
|
673
|
-
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
674
|
-
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
675
|
-
class GetRelationshipAttributesParams extends ts_serval_1.Serializable {
|
|
676
|
-
static from(value) {
|
|
677
|
-
return this.fromAny(value);
|
|
678
|
-
}
|
|
679
|
-
}
|
|
680
|
-
__decorate([
|
|
681
|
-
(0, ts_serval_1.serialize)(),
|
|
682
|
-
(0, ts_serval_1.validate)(),
|
|
683
|
-
__metadata("design:type", content_1.RelationshipAttributeQuery)
|
|
684
|
-
], GetRelationshipAttributesParams.prototype, "query", void 0);
|
|
685
|
-
exports.GetRelationshipAttributesParams = GetRelationshipAttributesParams;
|
|
686
|
-
//# sourceMappingURL=GetRelationshipAttributesParams.js.map
|
|
687
|
-
|
|
688
|
-
/***/ }),
|
|
689
|
-
|
|
690
622
|
/***/ "./dist/modules/attributes/local/LocalAttribute.js":
|
|
691
623
|
/*!*********************************************************!*\
|
|
692
624
|
!*** ./dist/modules/attributes/local/LocalAttribute.js ***!
|
|
@@ -724,13 +656,19 @@ let LocalAttribute = class LocalAttribute extends transport_1.CoreSynchronizable
|
|
|
724
656
|
];
|
|
725
657
|
this.userdataProperties = [(0, ts_simple_nameof_1.nameof)((r) => r.content)];
|
|
726
658
|
}
|
|
659
|
+
isIdentityAttribute() {
|
|
660
|
+
return this.content instanceof content_1.IdentityAttribute;
|
|
661
|
+
}
|
|
662
|
+
isOwnedBy(identity) {
|
|
663
|
+
return this.content.owner.equals(identity);
|
|
664
|
+
}
|
|
727
665
|
static from(value) {
|
|
728
666
|
return this.fromAny(value);
|
|
729
667
|
}
|
|
730
|
-
static async fromAttribute(attribute, succeeds, shareInfo) {
|
|
668
|
+
static async fromAttribute(attribute, succeeds, shareInfo, id) {
|
|
731
669
|
return this.from({
|
|
670
|
+
id: id ?? (await consumption_1.ConsumptionIds.attribute.generate()),
|
|
732
671
|
content: attribute,
|
|
733
|
-
id: await consumption_1.ConsumptionIds.attribute.generate(),
|
|
734
672
|
createdAt: transport_1.CoreDate.utc(),
|
|
735
673
|
succeeds: succeeds,
|
|
736
674
|
shareInfo: shareInfo
|
|
@@ -825,11 +763,17 @@ exports.LocalAttributeShareInfo = LocalAttributeShareInfo;
|
|
|
825
763
|
"use strict";
|
|
826
764
|
|
|
827
765
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
828
|
-
exports.
|
|
766
|
+
exports.RelationshipAttributeQueryTranslator = exports.IdentityAttributeQueryTranslator = void 0;
|
|
829
767
|
const docdb_querytranslator_1 = __webpack_require__(/*! @js-soft/docdb-querytranslator */ "./node_modules/@js-soft/docdb-querytranslator/dist/index.js");
|
|
830
768
|
const luxon_1 = __webpack_require__(/*! luxon */ "./node_modules/luxon/build/cjs-browser/luxon.js");
|
|
831
769
|
const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
|
|
832
|
-
|
|
770
|
+
class IdentityAttributeQueryTranslator {
|
|
771
|
+
static translate(query) {
|
|
772
|
+
return this.translator.parse({ ...query.toJSON(), attributeType: "IdentityAttribute" });
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
exports.IdentityAttributeQueryTranslator = IdentityAttributeQueryTranslator;
|
|
776
|
+
IdentityAttributeQueryTranslator.translator = new docdb_querytranslator_1.QueryTranslator({
|
|
833
777
|
whitelist: {
|
|
834
778
|
[(0, ts_simple_nameof_1.nameof)((x) => x.tags)]: true,
|
|
835
779
|
[(0, ts_simple_nameof_1.nameof)((x) => x.valueType)]: true,
|
|
@@ -848,16 +792,17 @@ exports.identityQueryTranslator = new docdb_querytranslator_1.QueryTranslator({
|
|
|
848
792
|
custom: {
|
|
849
793
|
// tags
|
|
850
794
|
[(0, ts_simple_nameof_1.nameof)((x) => x.tags)]: (query, input) => {
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
$contains: tag
|
|
856
|
-
}
|
|
857
|
-
};
|
|
858
|
-
allowedTags.push(tagQuery);
|
|
795
|
+
if (!input)
|
|
796
|
+
return;
|
|
797
|
+
if (!Array.isArray(input)) {
|
|
798
|
+
throw new Error("Invalid input: 'tags' must be an array");
|
|
859
799
|
}
|
|
860
|
-
|
|
800
|
+
const inputAsArray = input;
|
|
801
|
+
query["$or"] = inputAsArray.map((t) => ({
|
|
802
|
+
[`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.${(0, ts_simple_nameof_1.nameof)((x) => x.tags)}`]: {
|
|
803
|
+
$contains: t
|
|
804
|
+
}
|
|
805
|
+
}));
|
|
861
806
|
},
|
|
862
807
|
// validFrom
|
|
863
808
|
[(0, ts_simple_nameof_1.nameof)((x) => x.validFrom)]: (query, input) => {
|
|
@@ -865,10 +810,9 @@ exports.identityQueryTranslator = new docdb_querytranslator_1.QueryTranslator({
|
|
|
865
810
|
return;
|
|
866
811
|
}
|
|
867
812
|
const validFromUtcString = luxon_1.DateTime.fromISO(input).toUTC().toString();
|
|
868
|
-
query[`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.${(0, ts_simple_nameof_1.nameof)((x) => x.validFrom)}`] =
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
};
|
|
813
|
+
query[`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.${(0, ts_simple_nameof_1.nameof)((x) => x.validFrom)}`] = {
|
|
814
|
+
$gte: validFromUtcString
|
|
815
|
+
};
|
|
872
816
|
},
|
|
873
817
|
// validTo
|
|
874
818
|
[(0, ts_simple_nameof_1.nameof)((x) => x.validTo)]: (query, input) => {
|
|
@@ -882,7 +826,13 @@ exports.identityQueryTranslator = new docdb_querytranslator_1.QueryTranslator({
|
|
|
882
826
|
}
|
|
883
827
|
}
|
|
884
828
|
});
|
|
885
|
-
|
|
829
|
+
class RelationshipAttributeQueryTranslator {
|
|
830
|
+
static translate(query) {
|
|
831
|
+
return this.translator.parse({ ...query.toJSON(), attributeType: "RelationshipAttribute" });
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
exports.RelationshipAttributeQueryTranslator = RelationshipAttributeQueryTranslator;
|
|
835
|
+
RelationshipAttributeQueryTranslator.translator = new docdb_querytranslator_1.QueryTranslator({
|
|
886
836
|
whitelist: {
|
|
887
837
|
[(0, ts_simple_nameof_1.nameof)((x) => x.key)]: true,
|
|
888
838
|
[(0, ts_simple_nameof_1.nameof)((x) => x.valueType)]: true,
|
|
@@ -919,10 +869,9 @@ exports.relationshipQueryTranslator = new docdb_querytranslator_1.QueryTranslato
|
|
|
919
869
|
return;
|
|
920
870
|
}
|
|
921
871
|
const validFromUtcString = luxon_1.DateTime.fromISO(input).toUTC().toString();
|
|
922
|
-
query[`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.${(0, ts_simple_nameof_1.nameof)((x) => x.validFrom)}`] =
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
};
|
|
872
|
+
query[`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.${(0, ts_simple_nameof_1.nameof)((x) => x.validFrom)}`] = {
|
|
873
|
+
$gte: validFromUtcString
|
|
874
|
+
};
|
|
926
875
|
},
|
|
927
876
|
// validTo
|
|
928
877
|
[(0, ts_simple_nameof_1.nameof)((x) => x.validTo)]: (query, input) => {
|
|
@@ -1187,8 +1136,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
|
1187
1136
|
__exportStar(__webpack_require__(/*! ./attributes/local/CreateLocalAttributeParams */ "./dist/modules/attributes/local/CreateLocalAttributeParams.js"), exports);
|
|
1188
1137
|
__exportStar(__webpack_require__(/*! ./attributes/local/CreatePeerLocalAttributeParams */ "./dist/modules/attributes/local/CreatePeerLocalAttributeParams.js"), exports);
|
|
1189
1138
|
__exportStar(__webpack_require__(/*! ./attributes/local/CreateSharedLocalAttributeCopyParams */ "./dist/modules/attributes/local/CreateSharedLocalAttributeCopyParams.js"), exports);
|
|
1190
|
-
__exportStar(__webpack_require__(/*! ./attributes/local/GetIdentityAttributesParams */ "./dist/modules/attributes/local/GetIdentityAttributesParams.js"), exports);
|
|
1191
|
-
__exportStar(__webpack_require__(/*! ./attributes/local/GetRelationshipAttributesParams */ "./dist/modules/attributes/local/GetRelationshipAttributesParams.js"), exports);
|
|
1192
1139
|
__exportStar(__webpack_require__(/*! ./attributes/local/LocalAttribute */ "./dist/modules/attributes/local/LocalAttribute.js"), exports);
|
|
1193
1140
|
__exportStar(__webpack_require__(/*! ./attributes/local/LocalAttributeShareInfo */ "./dist/modules/attributes/local/LocalAttributeShareInfo.js"), exports);
|
|
1194
1141
|
__exportStar(__webpack_require__(/*! ./attributes/local/SucceedLocalAttributeParams */ "./dist/modules/attributes/local/SucceedLocalAttributeParams.js"), exports);
|
|
@@ -2131,7 +2078,14 @@ const consumption_1 = __webpack_require__(/*! ../../../../consumption */ "./dist
|
|
|
2131
2078
|
const GenericRequestItemProcessor_1 = __webpack_require__(/*! ../GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js");
|
|
2132
2079
|
const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
2133
2080
|
class CreateAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.GenericRequestItemProcessor {
|
|
2134
|
-
canCreateOutgoingRequestItem(requestItem, _request,
|
|
2081
|
+
canCreateOutgoingRequestItem(requestItem, _request, recipient) {
|
|
2082
|
+
const recipientIsOwnerOfTheAttribute = requestItem.attribute.owner.equals(recipient);
|
|
2083
|
+
// When the owner of the Attribute is not the recipient of the Request, this means that
|
|
2084
|
+
// we need to set the sourceAttributeId, because we have to set shareInfo as soon as the
|
|
2085
|
+
// RequestItem was accepted.
|
|
2086
|
+
if (!recipientIsOwnerOfTheAttribute && !requestItem.sourceAttributeId) {
|
|
2087
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.ConsumptionErrors.requests.invalidRequestItem("'sourceAttributeId' cannot be undefined when sending an attribute that is not owned by the recipient."));
|
|
2088
|
+
}
|
|
2135
2089
|
if (requestItem.attribute instanceof content_1.IdentityAttribute) {
|
|
2136
2090
|
return this.canCreateRequestItemWithIdentityAttribute(requestItem);
|
|
2137
2091
|
}
|
|
@@ -2166,13 +2120,23 @@ class CreateAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.
|
|
|
2166
2120
|
if (!(responseItem instanceof content_1.CreateAttributeAcceptResponseItem)) {
|
|
2167
2121
|
return;
|
|
2168
2122
|
}
|
|
2169
|
-
|
|
2170
|
-
|
|
2171
|
-
|
|
2172
|
-
|
|
2173
|
-
|
|
2174
|
-
|
|
2175
|
-
|
|
2123
|
+
if (requestItem.sourceAttributeId) {
|
|
2124
|
+
const sourceAttribute = await this.consumptionController.attributes.getLocalAttribute(requestItem.sourceAttributeId);
|
|
2125
|
+
await this.consumptionController.attributes.createSharedLocalAttributeCopy({
|
|
2126
|
+
attributeId: responseItem.attributeId,
|
|
2127
|
+
sourceAttributeId: sourceAttribute.id,
|
|
2128
|
+
peer: requestInfo.peer,
|
|
2129
|
+
requestReference: requestInfo.id
|
|
2130
|
+
});
|
|
2131
|
+
}
|
|
2132
|
+
else {
|
|
2133
|
+
await this.consumptionController.attributes.createPeerLocalAttribute({
|
|
2134
|
+
id: responseItem.attributeId,
|
|
2135
|
+
content: requestItem.attribute,
|
|
2136
|
+
peer: requestInfo.peer,
|
|
2137
|
+
requestReference: requestInfo.id
|
|
2138
|
+
});
|
|
2139
|
+
}
|
|
2176
2140
|
}
|
|
2177
2141
|
}
|
|
2178
2142
|
exports.CreateAttributeRequestItemProcessor = CreateAttributeRequestItemProcessor;
|
|
@@ -2296,7 +2260,7 @@ class ProposeAttributeRequestItemProcessor extends GenericRequestItemProcessor_1
|
|
|
2296
2260
|
}
|
|
2297
2261
|
async copyExistingAttribute(attributeId, requestInfo) {
|
|
2298
2262
|
return await this.consumptionController.attributes.createSharedLocalAttributeCopy({
|
|
2299
|
-
|
|
2263
|
+
sourceAttributeId: transport_1.CoreId.from(attributeId),
|
|
2300
2264
|
peer: transport_1.CoreAddress.from(requestInfo.peer),
|
|
2301
2265
|
requestReference: transport_1.CoreId.from(requestInfo.id)
|
|
2302
2266
|
});
|
|
@@ -2307,7 +2271,7 @@ class ProposeAttributeRequestItemProcessor extends GenericRequestItemProcessor_1
|
|
|
2307
2271
|
content: attribute
|
|
2308
2272
|
});
|
|
2309
2273
|
return await this.consumptionController.attributes.createSharedLocalAttributeCopy({
|
|
2310
|
-
|
|
2274
|
+
sourceAttributeId: transport_1.CoreId.from(repositoryLocalAttribute.id),
|
|
2311
2275
|
peer: transport_1.CoreAddress.from(requestInfo.peer),
|
|
2312
2276
|
requestReference: transport_1.CoreId.from(requestInfo.id)
|
|
2313
2277
|
});
|
|
@@ -2458,7 +2422,7 @@ class ReadAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.Ge
|
|
|
2458
2422
|
}
|
|
2459
2423
|
async copyExistingAttribute(attributeId, requestInfo) {
|
|
2460
2424
|
return await this.consumptionController.attributes.createSharedLocalAttributeCopy({
|
|
2461
|
-
|
|
2425
|
+
sourceAttributeId: transport_1.CoreId.from(attributeId),
|
|
2462
2426
|
peer: transport_1.CoreAddress.from(requestInfo.peer),
|
|
2463
2427
|
requestReference: transport_1.CoreId.from(requestInfo.id)
|
|
2464
2428
|
});
|
|
@@ -2469,7 +2433,7 @@ class ReadAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.Ge
|
|
|
2469
2433
|
content: attribute
|
|
2470
2434
|
});
|
|
2471
2435
|
return await this.consumptionController.attributes.createSharedLocalAttributeCopy({
|
|
2472
|
-
|
|
2436
|
+
sourceAttributeId: transport_1.CoreId.from(repositoryLocalAttribute.id),
|
|
2473
2437
|
peer: transport_1.CoreAddress.from(requestInfo.peer),
|
|
2474
2438
|
requestReference: transport_1.CoreId.from(requestInfo.id)
|
|
2475
2439
|
});
|
|
@@ -2586,7 +2550,7 @@ class ShareAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.G
|
|
|
2586
2550
|
return ValidationResult_1.ValidationResult.success();
|
|
2587
2551
|
}
|
|
2588
2552
|
async accept(requestItem, _params, _requestInfo) {
|
|
2589
|
-
const attribute = await this.consumptionController.attributes.getLocalAttribute(requestItem.attributeId);
|
|
2553
|
+
const attribute = (await this.consumptionController.attributes.getLocalAttribute(requestItem.attributeId));
|
|
2590
2554
|
if (!(await this.isAttributeAlreadyShared(attribute, requestItem.shareWith))) {
|
|
2591
2555
|
await this.shareAttribute(attribute, requestItem.shareWith);
|
|
2592
2556
|
}
|
|
@@ -2607,7 +2571,8 @@ class ShareAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.G
|
|
|
2607
2571
|
async shareAttribute(attribute, shareWith) {
|
|
2608
2572
|
const createAttributeRequestItem = content_1.CreateAttributeRequestItem.from({
|
|
2609
2573
|
attribute: attribute.content,
|
|
2610
|
-
mustBeAccepted: true
|
|
2574
|
+
mustBeAccepted: true,
|
|
2575
|
+
sourceAttributeId: attribute.id
|
|
2611
2576
|
});
|
|
2612
2577
|
const createAttributeRequest = await this.consumptionController.outgoingRequests.create({
|
|
2613
2578
|
peer: shareWith,
|