@nmshd/consumption 2.0.0-beta.12 → 2.0.0-beta.15
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 -1
- 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 +184 -79
- 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/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
|
@@ -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.15",
|
|
21
|
+
build: "66",
|
|
22
|
+
date: "2022-09-09T06:59:05+00:00",
|
|
23
|
+
commit: "36168f3d7a06186c388a1563731cfa88541125b5",
|
|
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.fromAny(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");
|
|
@@ -1051,6 +1060,55 @@ class RelationshipAttributeQueryTranslator {
|
|
|
1051
1060
|
}
|
|
1052
1061
|
exports.RelationshipAttributeQueryTranslator = RelationshipAttributeQueryTranslator;
|
|
1053
1062
|
RelationshipAttributeQueryTranslator.translator = new docdb_querytranslator_1.QueryTranslator({
|
|
1063
|
+
whitelist: {
|
|
1064
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.key)]: true,
|
|
1065
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.validFrom)]: true,
|
|
1066
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.validTo)]: true,
|
|
1067
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.owner)]: true,
|
|
1068
|
+
attributeType: true
|
|
1069
|
+
},
|
|
1070
|
+
alias: {
|
|
1071
|
+
// key
|
|
1072
|
+
[(0, ts_simple_nameof_1.nameof)((x) => x.key)]: [
|
|
1073
|
+
`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.${(0, ts_simple_nameof_1.nameof)((x) => x.key)}`
|
|
1074
|
+
],
|
|
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({
|
|
1054
1112
|
whitelist: {
|
|
1055
1113
|
[(0, ts_simple_nameof_1.nameof)((x) => x.key)]: true,
|
|
1056
1114
|
[(0, ts_simple_nameof_1.nameof)((x) => x.validFrom)]: true,
|
|
@@ -1214,7 +1272,7 @@ class DraftsController extends consumption_1.ConsumptionBaseController {
|
|
|
1214
1272
|
}
|
|
1215
1273
|
async getDrafts(query) {
|
|
1216
1274
|
const items = await this.drafts.find(query);
|
|
1217
|
-
return
|
|
1275
|
+
return this.parseArray(items, Draft_1.Draft);
|
|
1218
1276
|
}
|
|
1219
1277
|
async createDraft(content, type = "") {
|
|
1220
1278
|
const draft = Draft_1.Draft.from({
|
|
@@ -2240,8 +2298,8 @@ __exportStar(__webpack_require__(/*! ./incoming/IncomingRequestsController */ ".
|
|
|
2240
2298
|
__exportStar(__webpack_require__(/*! ./incoming/received/ReceivedIncomingRequestParameters */ "./dist/modules/requests/incoming/received/ReceivedIncomingRequestParameters.js"), exports);
|
|
2241
2299
|
__exportStar(__webpack_require__(/*! ./incoming/requireManualDecision/RequireManualDecisionOfIncomingRequestParameters */ "./dist/modules/requests/incoming/requireManualDecision/RequireManualDecisionOfIncomingRequestParameters.js"), exports);
|
|
2242
2300
|
__exportStar(__webpack_require__(/*! ./itemProcessors/AbstractRequestItemProcessor */ "./dist/modules/requests/itemProcessors/AbstractRequestItemProcessor.js"), exports);
|
|
2243
|
-
__exportStar(__webpack_require__(/*! ./itemProcessors/
|
|
2244
|
-
__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);
|
|
2245
2303
|
__exportStar(__webpack_require__(/*! ./itemProcessors/GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js"), exports);
|
|
2246
2304
|
__exportStar(__webpack_require__(/*! ./itemProcessors/IRequestItemProcessor */ "./dist/modules/requests/itemProcessors/IRequestItemProcessor.js"), exports);
|
|
2247
2305
|
__exportStar(__webpack_require__(/*! ./itemProcessors/ProcessorConstructor */ "./dist/modules/requests/itemProcessors/ProcessorConstructor.js"), exports);
|
|
@@ -2461,10 +2519,10 @@ exports.ErrorValidationResult = ErrorValidationResult;
|
|
|
2461
2519
|
|
|
2462
2520
|
/***/ }),
|
|
2463
2521
|
|
|
2464
|
-
/***/ "./dist/modules/requests/itemProcessors/
|
|
2465
|
-
|
|
2466
|
-
!*** ./dist/modules/requests/itemProcessors/
|
|
2467
|
-
|
|
2522
|
+
/***/ "./dist/modules/requests/itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters.js":
|
|
2523
|
+
/*!************************************************************************************************************!*\
|
|
2524
|
+
!*** ./dist/modules/requests/itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters.js ***!
|
|
2525
|
+
\************************************************************************************************************/
|
|
2468
2526
|
/***/ (function(__unused_webpack_module, exports, __webpack_require__) {
|
|
2469
2527
|
|
|
2470
2528
|
"use strict";
|
|
@@ -2476,61 +2534,87 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
2476
2534
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
2477
2535
|
};
|
|
2478
2536
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2479
|
-
exports.
|
|
2537
|
+
exports.AcceptCreateAttributeRequestItemParameters = void 0;
|
|
2480
2538
|
const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
|
|
2481
|
-
let
|
|
2539
|
+
let AcceptCreateAttributeRequestItemParameters = class AcceptCreateAttributeRequestItemParameters extends ts_serval_1.Serializable {
|
|
2482
2540
|
static from(value) {
|
|
2483
2541
|
return this.fromAny(value);
|
|
2484
2542
|
}
|
|
2485
2543
|
};
|
|
2486
|
-
|
|
2487
|
-
(0, ts_serval_1.type)("
|
|
2488
|
-
],
|
|
2489
|
-
exports.
|
|
2490
|
-
//# sourceMappingURL=
|
|
2544
|
+
AcceptCreateAttributeRequestItemParameters = __decorate([
|
|
2545
|
+
(0, ts_serval_1.type)("AcceptCreateAttributeRequestItemParameters")
|
|
2546
|
+
], AcceptCreateAttributeRequestItemParameters);
|
|
2547
|
+
exports.AcceptCreateAttributeRequestItemParameters = AcceptCreateAttributeRequestItemParameters;
|
|
2548
|
+
//# sourceMappingURL=AcceptCreateAttributeRequestItemParameters.js.map
|
|
2491
2549
|
|
|
2492
2550
|
/***/ }),
|
|
2493
2551
|
|
|
2494
|
-
/***/ "./dist/modules/requests/itemProcessors/
|
|
2495
|
-
|
|
2496
|
-
!*** ./dist/modules/requests/itemProcessors/
|
|
2497
|
-
|
|
2552
|
+
/***/ "./dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js":
|
|
2553
|
+
/*!*****************************************************************************************************!*\
|
|
2554
|
+
!*** ./dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js ***!
|
|
2555
|
+
\*****************************************************************************************************/
|
|
2498
2556
|
/***/ ((__unused_webpack_module, exports, __webpack_require__) => {
|
|
2499
2557
|
|
|
2500
2558
|
"use strict";
|
|
2501
2559
|
|
|
2502
2560
|
Object.defineProperty(exports, "__esModule", ({ value: true }));
|
|
2503
|
-
exports.
|
|
2561
|
+
exports.CreateAttributeRequestItemProcessor = void 0;
|
|
2504
2562
|
const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
2505
2563
|
const consumption_1 = __webpack_require__(/*! ../../../../consumption */ "./dist/consumption/index.js");
|
|
2506
2564
|
const GenericRequestItemProcessor_1 = __webpack_require__(/*! ../GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js");
|
|
2507
2565
|
const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
2508
|
-
class
|
|
2509
|
-
canCreateOutgoingRequestItem(requestItem, _request,
|
|
2510
|
-
|
|
2511
|
-
|
|
2512
|
-
|
|
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."));
|
|
2513
2579
|
}
|
|
2514
|
-
|
|
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."));
|
|
2515
2584
|
}
|
|
2516
2585
|
async accept(requestItem, _params, requestInfo) {
|
|
2517
|
-
requestItem.attribute.owner
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
|
|
2521
|
-
|
|
2522
|
-
|
|
2523
|
-
|
|
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({
|
|
2524
2608
|
result: content_1.ResponseItemResult.Accepted,
|
|
2525
|
-
attributeId:
|
|
2609
|
+
attributeId: sharedAttribute.id
|
|
2526
2610
|
});
|
|
2527
2611
|
}
|
|
2528
2612
|
async applyIncomingResponseItem(responseItem, requestItem, requestInfo) {
|
|
2529
|
-
if (!(responseItem instanceof content_1.
|
|
2613
|
+
if (!(responseItem instanceof content_1.CreateAttributeAcceptResponseItem)) {
|
|
2530
2614
|
return;
|
|
2531
2615
|
}
|
|
2532
2616
|
if (requestItem.attribute.owner.toString() === "") {
|
|
2533
|
-
requestItem.attribute.owner =
|
|
2617
|
+
requestItem.attribute.owner = requestInfo.peer;
|
|
2534
2618
|
}
|
|
2535
2619
|
await this.consumptionController.attributes.createPeerLocalAttribute({
|
|
2536
2620
|
id: responseItem.attributeId,
|
|
@@ -2540,8 +2624,8 @@ class CreateRelationshipAttributeRequestItemProcessor extends GenericRequestItem
|
|
|
2540
2624
|
});
|
|
2541
2625
|
}
|
|
2542
2626
|
}
|
|
2543
|
-
exports.
|
|
2544
|
-
//# sourceMappingURL=
|
|
2627
|
+
exports.CreateAttributeRequestItemProcessor = CreateAttributeRequestItemProcessor;
|
|
2628
|
+
//# sourceMappingURL=CreateAttributeRequestItemProcessor.js.map
|
|
2545
2629
|
|
|
2546
2630
|
/***/ }),
|
|
2547
2631
|
|
|
@@ -2994,14 +3078,14 @@ const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
|
|
|
2994
3078
|
const consumption_1 = __webpack_require__(/*! ../../../../consumption */ "./dist/consumption/index.js");
|
|
2995
3079
|
const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
|
|
2996
3080
|
function validateQuery(query, sender, recipient) {
|
|
2997
|
-
if (query instanceof content_1.
|
|
2998
|
-
if (query.thirdParty
|
|
3081
|
+
if (query instanceof content_1.ThirdPartyRelationshipAttributeQuery) {
|
|
3082
|
+
if (query.thirdParty.equals(sender)) {
|
|
2999
3083
|
return ValidationResult_1.ValidationResult.error(consumption_1.ConsumptionErrors.requests.invalidRequestItem("Cannot query an Attribute with the own address as third party."));
|
|
3000
3084
|
}
|
|
3001
|
-
if (query.thirdParty
|
|
3085
|
+
if (query.thirdParty.equals(recipient)) {
|
|
3002
3086
|
return ValidationResult_1.ValidationResult.error(consumption_1.ConsumptionErrors.requests.invalidRequestItem("Cannot query an Attribute with the recipient's address as third party."));
|
|
3003
3087
|
}
|
|
3004
|
-
if (query.owner.equals(sender)
|
|
3088
|
+
if (query.owner.equals(sender)) {
|
|
3005
3089
|
return ValidationResult_1.ValidationResult.error(consumption_1.ConsumptionErrors.requests.invalidRequestItem("Cannot query own Attributes from a third party."));
|
|
3006
3090
|
}
|
|
3007
3091
|
}
|
|
@@ -3799,7 +3883,7 @@ class SettingsController extends consumption_1.ConsumptionBaseController {
|
|
|
3799
3883
|
}
|
|
3800
3884
|
async getSettings(query) {
|
|
3801
3885
|
const items = await this.settings.find(query);
|
|
3802
|
-
return
|
|
3886
|
+
return this.parseArray(items, Setting_1.Setting);
|
|
3803
3887
|
}
|
|
3804
3888
|
async createSetting(parameters) {
|
|
3805
3889
|
const setting = Setting_1.Setting.from({
|
|
@@ -9027,7 +9111,8 @@ function clone$1(dur, alts, clear = false) {
|
|
|
9027
9111
|
...(alts.values || {})
|
|
9028
9112
|
},
|
|
9029
9113
|
loc: dur.loc.clone(alts.loc),
|
|
9030
|
-
conversionAccuracy: alts.conversionAccuracy || dur.conversionAccuracy
|
|
9114
|
+
conversionAccuracy: alts.conversionAccuracy || dur.conversionAccuracy,
|
|
9115
|
+
matrix: alts.matrix || dur.matrix
|
|
9031
9116
|
};
|
|
9032
9117
|
return new Duration(conf);
|
|
9033
9118
|
}
|
|
@@ -9066,7 +9151,7 @@ function normalizeValues(matrix, vals) {
|
|
|
9066
9151
|
*
|
|
9067
9152
|
* Here is a brief overview of commonly used methods and getters in Duration:
|
|
9068
9153
|
*
|
|
9069
|
-
* * **Creation** To create a Duration, use {@link Duration
|
|
9154
|
+
* * **Creation** To create a Duration, use {@link Duration.fromMillis}, {@link Duration.fromObject}, or {@link Duration.fromISO}.
|
|
9070
9155
|
* * **Unit values** See the {@link Duration#years}, {@link Duration#months}, {@link Duration#weeks}, {@link Duration#days}, {@link Duration#hours}, {@link Duration#minutes}, {@link Duration#seconds}, {@link Duration#milliseconds} accessors.
|
|
9071
9156
|
* * **Configuration** See {@link Duration#locale} and {@link Duration#numberingSystem} accessors.
|
|
9072
9157
|
* * **Transformation** To create new Durations out of old ones use {@link Duration#plus}, {@link Duration#minus}, {@link Duration#normalize}, {@link Duration#set}, {@link Duration#reconfigure}, {@link Duration#shiftTo}, and {@link Duration#negate}.
|
|
@@ -9082,10 +9167,16 @@ class Duration {
|
|
|
9082
9167
|
*/
|
|
9083
9168
|
constructor(config) {
|
|
9084
9169
|
const accurate = config.conversionAccuracy === "longterm" || false;
|
|
9170
|
+
let matrix = accurate ? accurateMatrix : casualMatrix;
|
|
9171
|
+
|
|
9172
|
+
if (config.matrix) {
|
|
9173
|
+
matrix = config.matrix;
|
|
9174
|
+
}
|
|
9085
9175
|
/**
|
|
9086
9176
|
* @access private
|
|
9087
9177
|
*/
|
|
9088
9178
|
|
|
9179
|
+
|
|
9089
9180
|
this.values = config.values;
|
|
9090
9181
|
/**
|
|
9091
9182
|
* @access private
|
|
@@ -9106,7 +9197,7 @@ class Duration {
|
|
|
9106
9197
|
* @access private
|
|
9107
9198
|
*/
|
|
9108
9199
|
|
|
9109
|
-
this.matrix =
|
|
9200
|
+
this.matrix = matrix;
|
|
9110
9201
|
/**
|
|
9111
9202
|
* @access private
|
|
9112
9203
|
*/
|
|
@@ -9145,7 +9236,8 @@ class Duration {
|
|
|
9145
9236
|
* @param {Object} [opts=[]] - options for creating this Duration
|
|
9146
9237
|
* @param {string} [opts.locale='en-US'] - the locale to use
|
|
9147
9238
|
* @param {string} opts.numberingSystem - the numbering system to use
|
|
9148
|
-
* @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
|
|
9239
|
+
* @param {string} [opts.conversionAccuracy='casual'] - the preset conversion system to use
|
|
9240
|
+
* @param {string} [opts.matrix=Object] - the custom conversion system to use
|
|
9149
9241
|
* @return {Duration}
|
|
9150
9242
|
*/
|
|
9151
9243
|
|
|
@@ -9158,7 +9250,8 @@ class Duration {
|
|
|
9158
9250
|
return new Duration({
|
|
9159
9251
|
values: normalizeObject(obj, Duration.normalizeUnit),
|
|
9160
9252
|
loc: Locale.fromObject(opts),
|
|
9161
|
-
conversionAccuracy: opts.conversionAccuracy
|
|
9253
|
+
conversionAccuracy: opts.conversionAccuracy,
|
|
9254
|
+
matrix: opts.matrix
|
|
9162
9255
|
});
|
|
9163
9256
|
}
|
|
9164
9257
|
/**
|
|
@@ -9190,7 +9283,8 @@ class Duration {
|
|
|
9190
9283
|
* @param {Object} opts - options for parsing
|
|
9191
9284
|
* @param {string} [opts.locale='en-US'] - the locale to use
|
|
9192
9285
|
* @param {string} opts.numberingSystem - the numbering system to use
|
|
9193
|
-
* @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
|
|
9286
|
+
* @param {string} [opts.conversionAccuracy='casual'] - the preset conversion system to use
|
|
9287
|
+
* @param {string} [opts.matrix=Object] - the preset conversion system to use
|
|
9194
9288
|
* @see https://en.wikipedia.org/wiki/ISO_8601#Durations
|
|
9195
9289
|
* @example Duration.fromISO('P3Y6M1W4DT12H30M5S').toObject() //=> { years: 3, months: 6, weeks: 1, days: 4, hours: 12, minutes: 30, seconds: 5 }
|
|
9196
9290
|
* @example Duration.fromISO('PT23H').toObject() //=> { hours: 23 }
|
|
@@ -9214,7 +9308,8 @@ class Duration {
|
|
|
9214
9308
|
* @param {Object} opts - options for parsing
|
|
9215
9309
|
* @param {string} [opts.locale='en-US'] - the locale to use
|
|
9216
9310
|
* @param {string} opts.numberingSystem - the numbering system to use
|
|
9217
|
-
* @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
|
|
9311
|
+
* @param {string} [opts.conversionAccuracy='casual'] - the preset conversion system to use
|
|
9312
|
+
* @param {string} [opts.matrix=Object] - the conversion system to use
|
|
9218
9313
|
* @see https://en.wikipedia.org/wiki/ISO_8601#Times
|
|
9219
9314
|
* @example Duration.fromISOTime('11:22:33.444').toObject() //=> { hours: 11, minutes: 22, seconds: 33, milliseconds: 444 }
|
|
9220
9315
|
* @example Duration.fromISOTime('11:00').toObject() //=> { hours: 11, minutes: 0, seconds: 0 }
|
|
@@ -9545,7 +9640,7 @@ class Duration {
|
|
|
9545
9640
|
* Scale this Duration by the specified amount. Return a newly-constructed Duration.
|
|
9546
9641
|
* @param {function} fn - The function to apply to each unit. Arity is 1 or 2: the value of the unit and, optionally, the unit name. Must return a number.
|
|
9547
9642
|
* @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnits(x => x * 2) //=> { hours: 2, minutes: 60 }
|
|
9548
|
-
* @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnits((x, u) => u === "
|
|
9643
|
+
* @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnits((x, u) => u === "hours" ? x * 2 : x) //=> { hours: 2, minutes: 30 }
|
|
9549
9644
|
* @return {Duration}
|
|
9550
9645
|
*/
|
|
9551
9646
|
|
|
@@ -9603,20 +9698,18 @@ class Duration {
|
|
|
9603
9698
|
reconfigure({
|
|
9604
9699
|
locale,
|
|
9605
9700
|
numberingSystem,
|
|
9606
|
-
conversionAccuracy
|
|
9701
|
+
conversionAccuracy,
|
|
9702
|
+
matrix
|
|
9607
9703
|
} = {}) {
|
|
9608
9704
|
const loc = this.loc.clone({
|
|
9609
9705
|
locale,
|
|
9610
9706
|
numberingSystem
|
|
9611
|
-
})
|
|
9612
|
-
|
|
9613
|
-
loc
|
|
9707
|
+
});
|
|
9708
|
+
const opts = {
|
|
9709
|
+
loc,
|
|
9710
|
+
matrix,
|
|
9711
|
+
conversionAccuracy
|
|
9614
9712
|
};
|
|
9615
|
-
|
|
9616
|
-
if (conversionAccuracy) {
|
|
9617
|
-
opts.conversionAccuracy = conversionAccuracy;
|
|
9618
|
-
}
|
|
9619
|
-
|
|
9620
9713
|
return clone$1(this, opts);
|
|
9621
9714
|
}
|
|
9622
9715
|
/**
|
|
@@ -9890,10 +9983,10 @@ function validateStartEnd(start, end) {
|
|
|
9890
9983
|
*
|
|
9891
9984
|
* Here is a brief overview of the most commonly used methods and getters in Interval:
|
|
9892
9985
|
*
|
|
9893
|
-
* * **Creation** To create an Interval, use {@link Interval
|
|
9986
|
+
* * **Creation** To create an Interval, use {@link Interval.fromDateTimes}, {@link Interval.after}, {@link Interval.before}, or {@link Interval.fromISO}.
|
|
9894
9987
|
* * **Accessors** Use {@link Interval#start} and {@link Interval#end} to get the start and end.
|
|
9895
9988
|
* * **Interrogation** To analyze the Interval, use {@link Interval#count}, {@link Interval#length}, {@link Interval#hasSame}, {@link Interval#contains}, {@link Interval#isAfter}, or {@link Interval#isBefore}.
|
|
9896
|
-
* * **Transformation** To create other Intervals out of this one, use {@link Interval#set}, {@link Interval#splitAt}, {@link Interval#splitBy}, {@link Interval#divideEqually}, {@link Interval
|
|
9989
|
+
* * **Transformation** To create other Intervals out of this one, use {@link Interval#set}, {@link Interval#splitAt}, {@link Interval#splitBy}, {@link Interval#divideEqually}, {@link Interval.merge}, {@link Interval.xor}, {@link Interval#union}, {@link Interval#intersection}, or {@link Interval#difference}.
|
|
9897
9990
|
* * **Comparison** To compare this Interval to another one, use {@link Interval#equals}, {@link Interval#overlaps}, {@link Interval#abutsStart}, {@link Interval#abutsEnd}, {@link Interval#engulfs}
|
|
9898
9991
|
* * **Output** To convert the Interval into other representations, see {@link Interval#toString}, {@link Interval#toISO}, {@link Interval#toISODate}, {@link Interval#toISOTime}, {@link Interval#toFormat}, and {@link Interval#toDuration}.
|
|
9899
9992
|
*/
|
|
@@ -11334,7 +11427,6 @@ function expandMacroTokens(tokens, locale) {
|
|
|
11334
11427
|
* @private
|
|
11335
11428
|
*/
|
|
11336
11429
|
|
|
11337
|
-
|
|
11338
11430
|
function explainFromTokens(locale, input, format) {
|
|
11339
11431
|
const tokens = expandMacroTokens(Formatter.parseFormat(format), locale),
|
|
11340
11432
|
units = tokens.map(t => unitForToken(t, locale)),
|
|
@@ -11930,7 +12022,7 @@ function lastOpts(argList) {
|
|
|
11930
12022
|
*
|
|
11931
12023
|
* Here is a brief overview of the most commonly used functionality it provides:
|
|
11932
12024
|
*
|
|
11933
|
-
* * **Creation**: To create a DateTime from its components, use one of its factory class methods: {@link DateTime
|
|
12025
|
+
* * **Creation**: To create a DateTime from its components, use one of its factory class methods: {@link DateTime.local}, {@link DateTime.utc}, and (most flexibly) {@link DateTime.fromObject}. To create one from a standard string format, use {@link DateTime.fromISO}, {@link DateTime.fromHTTP}, and {@link DateTime.fromRFC2822}. To create one from a custom string format, use {@link DateTime.fromFormat}. To create one from a native JS date, use {@link DateTime.fromJSDate}.
|
|
11934
12026
|
* * **Gregorian calendar and time**: To examine the Gregorian properties of a DateTime individually (i.e as opposed to collectively through {@link DateTime#toObject}), use the {@link DateTime#year}, {@link DateTime#month},
|
|
11935
12027
|
* {@link DateTime#day}, {@link DateTime#hour}, {@link DateTime#minute}, {@link DateTime#second}, {@link DateTime#millisecond} accessors.
|
|
11936
12028
|
* * **Week calendar**: For ISO week calendar attributes, see the {@link DateTime#weekYear}, {@link DateTime#weekNumber}, and {@link DateTime#weekday} accessors.
|
|
@@ -12469,6 +12561,19 @@ class DateTime {
|
|
|
12469
12561
|
static parseFormatForOpts(formatOpts, localeOpts = {}) {
|
|
12470
12562
|
const tokenList = formatOptsToTokens(formatOpts, Locale.fromObject(localeOpts));
|
|
12471
12563
|
return !tokenList ? null : tokenList.map(t => t ? t.val : null).join("");
|
|
12564
|
+
}
|
|
12565
|
+
/**
|
|
12566
|
+
* Produce the the fully expanded format token for the locale
|
|
12567
|
+
* Does NOT quote characters, so quoted tokens will not round trip correctly
|
|
12568
|
+
* @param fmt
|
|
12569
|
+
* @param localeOpts
|
|
12570
|
+
* @returns {string}
|
|
12571
|
+
*/
|
|
12572
|
+
|
|
12573
|
+
|
|
12574
|
+
static expandFormat(fmt, localeOpts = {}) {
|
|
12575
|
+
const expanded = expandMacroTokens(Formatter.parseFormat(fmt), Locale.fromObject(localeOpts));
|
|
12576
|
+
return expanded.map(t => t.val).join("");
|
|
12472
12577
|
} // INFO
|
|
12473
12578
|
|
|
12474
12579
|
/**
|
|
@@ -13161,8 +13266,8 @@ class DateTime {
|
|
|
13161
13266
|
* @param {Object} opts - opts to override the configuration options on this DateTime
|
|
13162
13267
|
* @example DateTime.now().toLocaleString(); //=> 4/20/2017
|
|
13163
13268
|
* @example DateTime.now().setLocale('en-gb').toLocaleString(); //=> '20/04/2017'
|
|
13164
|
-
* @example DateTime.now().toLocaleString({ locale: 'en-gb' }); //=> '20/04/2017'
|
|
13165
13269
|
* @example DateTime.now().toLocaleString(DateTime.DATE_FULL); //=> 'April 20, 2017'
|
|
13270
|
+
* @example DateTime.now().toLocaleString(DateTime.DATE_FULL, { locale: 'fr' }); //=> '28 août 2022'
|
|
13166
13271
|
* @example DateTime.now().toLocaleString(DateTime.TIME_SIMPLE); //=> '11:32 AM'
|
|
13167
13272
|
* @example DateTime.now().toLocaleString(DateTime.DATETIME_SHORT); //=> '4/20/2017, 11:32 AM'
|
|
13168
13273
|
* @example DateTime.now().toLocaleString({ weekday: 'long', month: 'long', day: '2-digit' }); //=> 'Thursday, April 20'
|
|
@@ -13199,7 +13304,7 @@ class DateTime {
|
|
|
13199
13304
|
* @param {boolean} [opts.suppressMilliseconds=false] - exclude milliseconds from the format if they're 0
|
|
13200
13305
|
* @param {boolean} [opts.suppressSeconds=false] - exclude seconds from the format if they're 0
|
|
13201
13306
|
* @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
|
|
13202
|
-
* @param {boolean} [opts.extendedZone=
|
|
13307
|
+
* @param {boolean} [opts.extendedZone=false] - add the time zone format extension
|
|
13203
13308
|
* @param {string} [opts.format='extended'] - choose between the basic and extended format
|
|
13204
13309
|
* @example DateTime.utc(1983, 5, 25).toISO() //=> '1982-05-25T00:00:00.000Z'
|
|
13205
13310
|
* @example DateTime.now().toISO() //=> '2017-04-22T20:47:05.335-04:00'
|
|
@@ -13904,7 +14009,7 @@ function friendlyDateTime(dateTimeish) {
|
|
|
13904
14009
|
}
|
|
13905
14010
|
}
|
|
13906
14011
|
|
|
13907
|
-
const VERSION = "3.0.
|
|
14012
|
+
const VERSION = "3.0.3";
|
|
13908
14013
|
|
|
13909
14014
|
exports.DateTime = DateTime;
|
|
13910
14015
|
exports.Duration = Duration;
|