@nmshd/consumption 2.0.0-beta.11 → 2.0.0-beta.14
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/ConsumptionBaseController.js +2 -3
- package/dist/consumption/ConsumptionBaseController.js.map +1 -1
- package/dist/consumption/ConsumptionController.js +1 -1
- package/dist/consumption/ConsumptionController.js.map +1 -1
- package/dist/modules/attributes/LocalAttributesController.d.ts +3 -2
- package/dist/modules/attributes/LocalAttributesController.js +14 -4
- package/dist/modules/attributes/LocalAttributesController.js.map +1 -1
- package/dist/modules/attributes/local/{CreateRelationshipAttributeParams.d.ts → CreateAttributeParams.d.ts} +3 -3
- package/dist/modules/attributes/local/{CreateRelationshipAttributeParams.js → CreateAttributeParams.js} +10 -10
- package/dist/modules/attributes/local/CreateAttributeParams.js.map +1 -0
- package/dist/modules/attributes/local/QueryTranslator.d.ts +5 -1
- package/dist/modules/attributes/local/QueryTranslator.js +50 -6
- package/dist/modules/attributes/local/QueryTranslator.js.map +1 -1
- package/dist/modules/drafts/DraftsController.js +1 -1
- package/dist/modules/drafts/DraftsController.js.map +1 -1
- package/dist/modules/requests/index.d.ts +2 -2
- package/dist/modules/requests/index.js +2 -2
- package/dist/modules/requests/index.js.map +1 -1
- package/dist/modules/requests/itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters.d.ts +7 -0
- package/dist/modules/requests/itemProcessors/{createRelationshipAttribute/AcceptCreateRelationshipAttributeRequestItemParameters.js → createAttribute/AcceptCreateAttributeRequestItemParameters.js} +7 -7
- package/dist/modules/requests/itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters.js.map +1 -0
- package/dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.d.ts +11 -0
- package/dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js +70 -0
- package/dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js.map +1 -0
- package/dist/modules/requests/itemProcessors/utility/validateQuery.d.ts +2 -2
- package/dist/modules/requests/itemProcessors/utility/validateQuery.js +4 -4
- package/dist/modules/requests/itemProcessors/utility/validateQuery.js.map +1 -1
- package/dist/modules/settings/SettingsController.js +1 -1
- package/dist/modules/settings/SettingsController.js.map +1 -1
- package/lib-web/nmshd.consumption.js +139 -60
- 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 +9 -9
- package/dist/modules/attributes/local/CreateRelationshipAttributeParams.js.map +0 -1
- package/dist/modules/requests/itemProcessors/createRelationshipAttribute/AcceptCreateRelationshipAttributeRequestItemParameters.d.ts +0 -7
- package/dist/modules/requests/itemProcessors/createRelationshipAttribute/AcceptCreateRelationshipAttributeRequestItemParameters.js.map +0 -1
- package/dist/modules/requests/itemProcessors/createRelationshipAttribute/CreateRelationshipAttributeRequestItemProcessor.d.ts +0 -11
- package/dist/modules/requests/itemProcessors/createRelationshipAttribute/CreateRelationshipAttributeRequestItemProcessor.js +0 -44
- package/dist/modules/requests/itemProcessors/createRelationshipAttribute/CreateRelationshipAttributeRequestItemProcessor.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SettingsController.js","sourceRoot":"","sources":["../../../src/modules/settings/SettingsController.ts"],"names":[],"mappings":";;;AAAA,gDAA4F;AAC5F,mDAAwG;AAGxG,6CAAuD;AAEvD,MAAa,kBAAmB,SAAQ,uCAAyB;IAG7D,YAAmB,MAA6B;QAC5C,KAAK,CAAC,uCAAyB,CAAC,kBAAkB,EAAE,MAAM,CAAC,CAAA;IAC/D,CAAC;IAEe,KAAK,CAAC,IAAI;QACtB,MAAM,KAAK,CAAC,IAAI,EAAE,CAAA;QAElB,IAAI,CAAC,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,iBA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,CAAC,QAAQ,CAAC,MAAM,CAAC,OAAO,CAAC,CAAA;IACvC,CAAC;CACJ;AAlDD,gDAkDC"}
|
|
@@ -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-beta.
|
|
21
|
-
build: "
|
|
22
|
-
date: "2022-09-
|
|
23
|
-
commit: "
|
|
20
|
+
version: "2.0.0-beta.14",
|
|
21
|
+
build: "65",
|
|
22
|
+
date: "2022-09-08T16:46:17+00:00",
|
|
23
|
+
commit: "5e08a83edb35bff3255290783a568dc0123b7394",
|
|
24
24
|
dependencies: {"@js-soft/docdb-querytranslator":"^1.1.0","ts-simple-nameof":"^1.3.1"},
|
|
25
25
|
libraries: {
|
|
26
26
|
transport: transport_1.buildInformation,
|
|
@@ -58,9 +58,8 @@ class ConsumptionBaseController {
|
|
|
58
58
|
init() {
|
|
59
59
|
return Promise.resolve(this);
|
|
60
60
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return await Promise.all(parsePromises);
|
|
61
|
+
parseArray(values, type) {
|
|
62
|
+
return values.map((v) => type.from(v));
|
|
64
63
|
}
|
|
65
64
|
}
|
|
66
65
|
exports.ConsumptionBaseController = ConsumptionBaseController;
|
|
@@ -121,7 +120,7 @@ class ConsumptionController {
|
|
|
121
120
|
getDefaultProcessors() {
|
|
122
121
|
return new Map([
|
|
123
122
|
[content_1.ShareAttributeRequestItem, modules_1.ShareAttributeRequestItemProcessor],
|
|
124
|
-
[content_1.
|
|
123
|
+
[content_1.CreateAttributeRequestItem, modules_1.CreateAttributeRequestItemProcessor],
|
|
125
124
|
[content_1.ReadAttributeRequestItem, modules_1.ReadAttributeRequestItemProcessor],
|
|
126
125
|
[content_1.ProposeAttributeRequestItem, modules_1.ProposeAttributeRequestItemProcessor],
|
|
127
126
|
[content_1.ConsentRequestItem, modules_1.GenericRequestItemProcessor],
|
|
@@ -413,11 +412,11 @@ class LocalAttributesController extends consumption_1.ConsumptionBaseController
|
|
|
413
412
|
}
|
|
414
413
|
async getLocalAttributes(query) {
|
|
415
414
|
const attributes = await this.attributes.find(query);
|
|
416
|
-
return
|
|
415
|
+
return this.parseArray(attributes, LocalAttribute_1.LocalAttribute);
|
|
417
416
|
}
|
|
418
417
|
async getValidLocalAttributes(query) {
|
|
419
418
|
const attributes = await this.attributes.find(query);
|
|
420
|
-
const items =
|
|
419
|
+
const items = this.parseArray(attributes, LocalAttribute_1.LocalAttribute);
|
|
421
420
|
return this.filterCurrent(items);
|
|
422
421
|
}
|
|
423
422
|
async executeRelationshipAttributeQuery(query) {
|
|
@@ -425,7 +424,16 @@ class LocalAttributesController extends consumption_1.ConsumptionBaseController
|
|
|
425
424
|
const dbQuery = QueryTranslator_1.RelationshipAttributeQueryTranslator.translate(parsedQuery);
|
|
426
425
|
dbQuery["content.confidentiality"] = { $ne: "private" };
|
|
427
426
|
const attributes = await this.attributes.find(dbQuery);
|
|
428
|
-
|
|
427
|
+
const attribute = attributes.length > 0 ? attributes[0] : undefined;
|
|
428
|
+
return attribute === undefined ? undefined : LocalAttribute_1.LocalAttribute.from(attribute);
|
|
429
|
+
}
|
|
430
|
+
async executeThirdPartyRelationshipAttributeQuery(query) {
|
|
431
|
+
const parsedQuery = content_1.ThirdPartyRelationshipAttributeQuery.from(query);
|
|
432
|
+
const dbQuery = QueryTranslator_1.ThirdPartyRelationshipAttributeQueryTranslator.translate(parsedQuery);
|
|
433
|
+
dbQuery["content.confidentiality"] = { $ne: "private" };
|
|
434
|
+
const attributes = await this.attributes.find(dbQuery);
|
|
435
|
+
const attribute = attributes.length > 0 ? attributes[0] : undefined;
|
|
436
|
+
return attribute ?? LocalAttribute_1.LocalAttribute.from(attribute);
|
|
429
437
|
}
|
|
430
438
|
async executeIdentityAttributeQuery(query) {
|
|
431
439
|
const parsedQuery = content_1.IdentityAttributeQuery.from(query);
|
|
@@ -433,7 +441,7 @@ class LocalAttributesController extends consumption_1.ConsumptionBaseController
|
|
|
433
441
|
dbQuery["content.owner"] = this.identity.address.toString();
|
|
434
442
|
dbQuery["shareInfo"] = { $exists: false };
|
|
435
443
|
const attributes = await this.attributes.find(dbQuery);
|
|
436
|
-
return
|
|
444
|
+
return this.parseArray(attributes, LocalAttribute_1.LocalAttribute);
|
|
437
445
|
}
|
|
438
446
|
async createLocalAttribute(params) {
|
|
439
447
|
const localAttribute = await LocalAttribute_1.LocalAttribute.fromAttribute(params.content);
|
|
@@ -489,6 +497,7 @@ class LocalAttributesController extends consumption_1.ConsumptionBaseController
|
|
|
489
497
|
createdAt: transport_1.CoreDate.utc()
|
|
490
498
|
});
|
|
491
499
|
await this.attributes.create(peerLocalAttribute);
|
|
500
|
+
this.eventBus.publish(new events_1.AttributeCreatedEvent(this.identity.address.toString(), peerLocalAttribute));
|
|
492
501
|
return peerLocalAttribute;
|
|
493
502
|
}
|
|
494
503
|
async updateLocalAttribute(params) {
|
|
@@ -981,7 +990,7 @@ exports.LocalAttributeShareInfo = LocalAttributeShareInfo;
|
|
|
981
990
|
"use strict";
|
|
982
991
|
|
|
983
992
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
984
|
-
exports.RelationshipAttributeQueryTranslator = exports.IdentityAttributeQueryTranslator = void 0;
|
|
993
|
+
exports.ThirdPartyRelationshipAttributeQueryTranslator = exports.RelationshipAttributeQueryTranslator = exports.IdentityAttributeQueryTranslator = void 0;
|
|
985
994
|
const docdb_querytranslator_1 = __webpack_require__(/*! @js-soft/docdb-querytranslator */ "./node_modules/@js-soft/docdb-querytranslator/dist/index.js");
|
|
986
995
|
const luxon_1 = __webpack_require__(/*! luxon */ "./node_modules/luxon/build/node/luxon.js");
|
|
987
996
|
const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
|
|
@@ -1053,11 +1062,9 @@ exports.RelationshipAttributeQueryTranslator = RelationshipAttributeQueryTransla
|
|
|
1053
1062
|
RelationshipAttributeQueryTranslator.translator = new docdb_querytranslator_1.QueryTranslator({
|
|
1054
1063
|
whitelist: {
|
|
1055
1064
|
[(0, ts_simple_nameof_1.nameof)((x) => x.key)]: true,
|
|
1056
|
-
[(0, ts_simple_nameof_1.nameof)((x) => x.valueType)]: true,
|
|
1057
1065
|
[(0, ts_simple_nameof_1.nameof)((x) => x.validFrom)]: true,
|
|
1058
1066
|
[(0, ts_simple_nameof_1.nameof)((x) => x.validTo)]: true,
|
|
1059
1067
|
[(0, ts_simple_nameof_1.nameof)((x) => x.owner)]: true,
|
|
1060
|
-
[(0, ts_simple_nameof_1.nameof)((x) => x.thirdParty)]: true,
|
|
1061
1068
|
attributeType: true
|
|
1062
1069
|
},
|
|
1063
1070
|
alias: {
|
|
@@ -1065,9 +1072,55 @@ RelationshipAttributeQueryTranslator.translator = new docdb_querytranslator_1.Qu
|
|
|
1065
1072
|
[(0, ts_simple_nameof_1.nameof)((x) => x.key)]: [
|
|
1066
1073
|
`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.${(0, ts_simple_nameof_1.nameof)((x) => x.key)}`
|
|
1067
1074
|
],
|
|
1068
|
-
// @type of
|
|
1069
|
-
[(0, ts_simple_nameof_1.nameof)((x) => x.
|
|
1070
|
-
|
|
1075
|
+
// @type of attribute
|
|
1076
|
+
attributeType: [`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.@type`],
|
|
1077
|
+
// owner
|
|
1078
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.owner)]: [
|
|
1079
|
+
`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.${(0, ts_simple_nameof_1.nameof)((x) => x.owner)}`
|
|
1080
|
+
]
|
|
1081
|
+
},
|
|
1082
|
+
custom: {
|
|
1083
|
+
// validFrom
|
|
1084
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.validFrom)]: (query, input) => {
|
|
1085
|
+
if (!input) {
|
|
1086
|
+
return;
|
|
1087
|
+
}
|
|
1088
|
+
const validFromUtcString = luxon_1.DateTime.fromISO(input).toUTC().toString();
|
|
1089
|
+
query[`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.${(0, ts_simple_nameof_1.nameof)((x) => x.validFrom)}`] = {
|
|
1090
|
+
$gte: validFromUtcString
|
|
1091
|
+
};
|
|
1092
|
+
},
|
|
1093
|
+
// validTo
|
|
1094
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.validTo)]: (query, input) => {
|
|
1095
|
+
if (!input) {
|
|
1096
|
+
return;
|
|
1097
|
+
}
|
|
1098
|
+
const validToUtcString = luxon_1.DateTime.fromISO(input).toUTC().toString();
|
|
1099
|
+
query[`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.${(0, ts_simple_nameof_1.nameof)((x) => x.validTo)}`] = {
|
|
1100
|
+
$lte: validToUtcString
|
|
1101
|
+
};
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1104
|
+
});
|
|
1105
|
+
class ThirdPartyRelationshipAttributeQueryTranslator {
|
|
1106
|
+
static translate(query) {
|
|
1107
|
+
return this.translator.parse({ ...query.toJSON(), attributeType: "RelationshipAttribute" });
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
exports.ThirdPartyRelationshipAttributeQueryTranslator = ThirdPartyRelationshipAttributeQueryTranslator;
|
|
1111
|
+
ThirdPartyRelationshipAttributeQueryTranslator.translator = new docdb_querytranslator_1.QueryTranslator({
|
|
1112
|
+
whitelist: {
|
|
1113
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.key)]: true,
|
|
1114
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.validFrom)]: true,
|
|
1115
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.validTo)]: true,
|
|
1116
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.owner)]: true,
|
|
1117
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.thirdParty)]: true,
|
|
1118
|
+
attributeType: true
|
|
1119
|
+
},
|
|
1120
|
+
alias: {
|
|
1121
|
+
// key
|
|
1122
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.key)]: [
|
|
1123
|
+
`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.${(0, ts_simple_nameof_1.nameof)((x) => x.key)}`
|
|
1071
1124
|
],
|
|
1072
1125
|
// @type of attribute
|
|
1073
1126
|
attributeType: [`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.@type`],
|
|
@@ -1219,7 +1272,7 @@ class DraftsController extends consumption_1.ConsumptionBaseController {
|
|
|
1219
1272
|
}
|
|
1220
1273
|
async getDrafts(query) {
|
|
1221
1274
|
const items = await this.drafts.find(query);
|
|
1222
|
-
return
|
|
1275
|
+
return this.parseArray(items, Draft_1.Draft);
|
|
1223
1276
|
}
|
|
1224
1277
|
async createDraft(content, type = "") {
|
|
1225
1278
|
const draft = Draft_1.Draft.from({
|
|
@@ -2245,8 +2298,8 @@ __exportStar(__webpack_require__(/*! ./incoming/IncomingRequestsController */ ".
|
|
|
2245
2298
|
__exportStar(__webpack_require__(/*! ./incoming/received/ReceivedIncomingRequestParameters */ "./dist/modules/requests/incoming/received/ReceivedIncomingRequestParameters.js"), exports);
|
|
2246
2299
|
__exportStar(__webpack_require__(/*! ./incoming/requireManualDecision/RequireManualDecisionOfIncomingRequestParameters */ "./dist/modules/requests/incoming/requireManualDecision/RequireManualDecisionOfIncomingRequestParameters.js"), exports);
|
|
2247
2300
|
__exportStar(__webpack_require__(/*! ./itemProcessors/AbstractRequestItemProcessor */ "./dist/modules/requests/itemProcessors/AbstractRequestItemProcessor.js"), exports);
|
|
2248
|
-
__exportStar(__webpack_require__(/*! ./itemProcessors/
|
|
2249
|
-
__exportStar(__webpack_require__(/*! ./itemProcessors/
|
|
2301
|
+
__exportStar(__webpack_require__(/*! ./itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters */ "./dist/modules/requests/itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters.js"), exports);
|
|
2302
|
+
__exportStar(__webpack_require__(/*! ./itemProcessors/createAttribute/CreateAttributeRequestItemProcessor */ "./dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js"), exports);
|
|
2250
2303
|
__exportStar(__webpack_require__(/*! ./itemProcessors/GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js"), exports);
|
|
2251
2304
|
__exportStar(__webpack_require__(/*! ./itemProcessors/IRequestItemProcessor */ "./dist/modules/requests/itemProcessors/IRequestItemProcessor.js"), exports);
|
|
2252
2305
|
__exportStar(__webpack_require__(/*! ./itemProcessors/ProcessorConstructor */ "./dist/modules/requests/itemProcessors/ProcessorConstructor.js"), exports);
|
|
@@ -2466,10 +2519,10 @@ exports.ErrorValidationResult = ErrorValidationResult;
|
|
|
2466
2519
|
|
|
2467
2520
|
/***/ }),
|
|
2468
2521
|
|
|
2469
|
-
/***/ "./dist/modules/requests/itemProcessors/
|
|
2470
|
-
|
|
2471
|
-
!*** ./dist/modules/requests/itemProcessors/
|
|
2472
|
-
|
|
2522
|
+
/***/ "./dist/modules/requests/itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters.js":
|
|
2523
|
+
/*!************************************************************************************************************!*\
|
|
2524
|
+
!*** ./dist/modules/requests/itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters.js ***!
|
|
2525
|
+
\************************************************************************************************************/
|
|
2473
2526
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2474
2527
|
|
|
2475
2528
|
"use strict";
|
|
@@ -2481,61 +2534,87 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
2481
2534
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2482
2535
|
};
|
|
2483
2536
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2484
|
-
exports.
|
|
2537
|
+
exports.AcceptCreateAttributeRequestItemParameters = void 0;
|
|
2485
2538
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
2486
|
-
let
|
|
2539
|
+
let AcceptCreateAttributeRequestItemParameters = class AcceptCreateAttributeRequestItemParameters extends ts_serval_1.Serializable {
|
|
2487
2540
|
static from(value) {
|
|
2488
2541
|
return this.fromAny(value);
|
|
2489
2542
|
}
|
|
2490
2543
|
};
|
|
2491
|
-
|
|
2492
|
-
(0, ts_serval_1.type)("
|
|
2493
|
-
],
|
|
2494
|
-
exports.
|
|
2495
|
-
//# sourceMappingURL=
|
|
2544
|
+
AcceptCreateAttributeRequestItemParameters = __decorate([
|
|
2545
|
+
(0, ts_serval_1.type)("AcceptCreateAttributeRequestItemParameters")
|
|
2546
|
+
], AcceptCreateAttributeRequestItemParameters);
|
|
2547
|
+
exports.AcceptCreateAttributeRequestItemParameters = AcceptCreateAttributeRequestItemParameters;
|
|
2548
|
+
//# sourceMappingURL=AcceptCreateAttributeRequestItemParameters.js.map
|
|
2496
2549
|
|
|
2497
2550
|
/***/ }),
|
|
2498
2551
|
|
|
2499
|
-
/***/ "./dist/modules/requests/itemProcessors/
|
|
2500
|
-
|
|
2501
|
-
!*** ./dist/modules/requests/itemProcessors/
|
|
2502
|
-
|
|
2552
|
+
/***/ "./dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js":
|
|
2553
|
+
/*!*****************************************************************************************************!*\
|
|
2554
|
+
!*** ./dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js ***!
|
|
2555
|
+
\*****************************************************************************************************/
|
|
2503
2556
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2504
2557
|
|
|
2505
2558
|
"use strict";
|
|
2506
2559
|
|
|
2507
2560
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2508
|
-
exports.
|
|
2561
|
+
exports.CreateAttributeRequestItemProcessor = void 0;
|
|
2509
2562
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
2510
2563
|
const consumption_1 = __webpack_require__(/*! ../../../../consumption */ "./dist/consumption/index.js");
|
|
2511
2564
|
const GenericRequestItemProcessor_1 = __webpack_require__(/*! ../GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js");
|
|
2512
2565
|
const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
2513
|
-
class
|
|
2514
|
-
canCreateOutgoingRequestItem(requestItem, _request,
|
|
2515
|
-
|
|
2516
|
-
|
|
2517
|
-
|
|
2566
|
+
class CreateAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.GenericRequestItemProcessor {
|
|
2567
|
+
canCreateOutgoingRequestItem(requestItem, _request, recipient) {
|
|
2568
|
+
const recipientIsAttributeOwner = requestItem.attribute.owner.equals(recipient);
|
|
2569
|
+
const senderIsAttributeOwner = requestItem.attribute.owner.equals(this.currentIdentityAddress);
|
|
2570
|
+
const ownerIsEmptyString = requestItem.attribute.owner.toString() === "";
|
|
2571
|
+
if (requestItem.attribute instanceof content_1.IdentityAttribute) {
|
|
2572
|
+
if (senderIsAttributeOwner) {
|
|
2573
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.ConsumptionErrors.requests.invalidRequestItem("Cannot create own Attributes with a CreateAttributeRequestItem. Use a ShareAttributeRequestItem instead."));
|
|
2574
|
+
}
|
|
2575
|
+
if (recipientIsAttributeOwner || ownerIsEmptyString || recipient === undefined) {
|
|
2576
|
+
return ValidationResult_1.ValidationResult.success();
|
|
2577
|
+
}
|
|
2578
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.ConsumptionErrors.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."));
|
|
2518
2579
|
}
|
|
2519
|
-
|
|
2580
|
+
if (recipientIsAttributeOwner || senderIsAttributeOwner || ownerIsEmptyString || recipient === undefined) {
|
|
2581
|
+
return ValidationResult_1.ValidationResult.success();
|
|
2582
|
+
}
|
|
2583
|
+
return ValidationResult_1.ValidationResult.error(consumption_1.ConsumptionErrors.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."));
|
|
2520
2584
|
}
|
|
2521
2585
|
async accept(requestItem, _params, requestInfo) {
|
|
2522
|
-
requestItem.attribute.owner
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2586
|
+
if (requestItem.attribute.owner.toString() === "") {
|
|
2587
|
+
requestItem.attribute.owner = this.currentIdentityAddress;
|
|
2588
|
+
}
|
|
2589
|
+
let sharedAttribute;
|
|
2590
|
+
if (requestItem.attribute instanceof content_1.IdentityAttribute) {
|
|
2591
|
+
const repositoryAttribute = await this.consumptionController.attributes.createLocalAttribute({
|
|
2592
|
+
content: requestItem.attribute
|
|
2593
|
+
});
|
|
2594
|
+
sharedAttribute = await this.consumptionController.attributes.createSharedLocalAttributeCopy({
|
|
2595
|
+
peer: requestInfo.peer,
|
|
2596
|
+
requestReference: requestInfo.id,
|
|
2597
|
+
sourceAttributeId: repositoryAttribute.id
|
|
2598
|
+
});
|
|
2599
|
+
}
|
|
2600
|
+
else {
|
|
2601
|
+
sharedAttribute = await this.consumptionController.attributes.createPeerLocalAttribute({
|
|
2602
|
+
content: requestItem.attribute,
|
|
2603
|
+
peer: requestInfo.peer,
|
|
2604
|
+
requestReference: requestInfo.id
|
|
2605
|
+
});
|
|
2606
|
+
}
|
|
2607
|
+
return content_1.CreateAttributeAcceptResponseItem.from({
|
|
2529
2608
|
result: content_1.ResponseItemResult.Accepted,
|
|
2530
|
-
attributeId:
|
|
2609
|
+
attributeId: sharedAttribute.id
|
|
2531
2610
|
});
|
|
2532
2611
|
}
|
|
2533
2612
|
async applyIncomingResponseItem(responseItem, requestItem, requestInfo) {
|
|
2534
|
-
if (!(responseItem instanceof content_1.
|
|
2613
|
+
if (!(responseItem instanceof content_1.CreateAttributeAcceptResponseItem)) {
|
|
2535
2614
|
return;
|
|
2536
2615
|
}
|
|
2537
2616
|
if (requestItem.attribute.owner.toString() === "") {
|
|
2538
|
-
requestItem.attribute.owner =
|
|
2617
|
+
requestItem.attribute.owner = requestInfo.peer;
|
|
2539
2618
|
}
|
|
2540
2619
|
await this.consumptionController.attributes.createPeerLocalAttribute({
|
|
2541
2620
|
id: responseItem.attributeId,
|
|
@@ -2545,8 +2624,8 @@ class CreateRelationshipAttributeRequestItemProcessor extends GenericRequestItem
|
|
|
2545
2624
|
});
|
|
2546
2625
|
}
|
|
2547
2626
|
}
|
|
2548
|
-
exports.
|
|
2549
|
-
//# sourceMappingURL=
|
|
2627
|
+
exports.CreateAttributeRequestItemProcessor = CreateAttributeRequestItemProcessor;
|
|
2628
|
+
//# sourceMappingURL=CreateAttributeRequestItemProcessor.js.map
|
|
2550
2629
|
|
|
2551
2630
|
/***/ }),
|
|
2552
2631
|
|
|
@@ -2999,14 +3078,14 @@ const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
|
2999
3078
|
const consumption_1 = __webpack_require__(/*! ../../../../consumption */ "./dist/consumption/index.js");
|
|
3000
3079
|
const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
3001
3080
|
function validateQuery(query, sender, recipient) {
|
|
3002
|
-
if (query instanceof content_1.
|
|
3003
|
-
if (query.thirdParty
|
|
3081
|
+
if (query instanceof content_1.ThirdPartyRelationshipAttributeQuery) {
|
|
3082
|
+
if (query.thirdParty.equals(sender)) {
|
|
3004
3083
|
return ValidationResult_1.ValidationResult.error(consumption_1.ConsumptionErrors.requests.invalidRequestItem("Cannot query an Attribute with the own address as third party."));
|
|
3005
3084
|
}
|
|
3006
|
-
if (query.thirdParty
|
|
3085
|
+
if (query.thirdParty.equals(recipient)) {
|
|
3007
3086
|
return ValidationResult_1.ValidationResult.error(consumption_1.ConsumptionErrors.requests.invalidRequestItem("Cannot query an Attribute with the recipient's address as third party."));
|
|
3008
3087
|
}
|
|
3009
|
-
if (query.owner.equals(sender)
|
|
3088
|
+
if (query.owner.equals(sender)) {
|
|
3010
3089
|
return ValidationResult_1.ValidationResult.error(consumption_1.ConsumptionErrors.requests.invalidRequestItem("Cannot query own Attributes from a third party."));
|
|
3011
3090
|
}
|
|
3012
3091
|
}
|
|
@@ -3804,7 +3883,7 @@ class SettingsController extends consumption_1.ConsumptionBaseController {
|
|
|
3804
3883
|
}
|
|
3805
3884
|
async getSettings(query) {
|
|
3806
3885
|
const items = await this.settings.find(query);
|
|
3807
|
-
return
|
|
3886
|
+
return this.parseArray(items, Setting_1.Setting);
|
|
3808
3887
|
}
|
|
3809
3888
|
async createSetting(parameters) {
|
|
3810
3889
|
const setting = Setting_1.Setting.from({
|