@nmshd/consumption 2.0.0-beta.13 → 2.0.0-beta.16

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.
Files changed (95) hide show
  1. package/dist/buildInformation.js +4 -4
  2. package/dist/consumption/ConsumptionBaseController.d.ts +1 -1
  3. package/dist/consumption/ConsumptionBaseController.js +2 -3
  4. package/dist/consumption/ConsumptionBaseController.js.map +1 -1
  5. package/dist/consumption/ConsumptionController.d.ts +3 -7
  6. package/dist/consumption/ConsumptionController.js +11 -13
  7. package/dist/consumption/ConsumptionController.js.map +1 -1
  8. package/dist/consumption/ConsumptionControllerName.d.ts +1 -0
  9. package/dist/consumption/ConsumptionControllerName.js +1 -0
  10. package/dist/consumption/ConsumptionControllerName.js.map +1 -1
  11. package/dist/consumption/ConsumptionIds.d.ts +1 -0
  12. package/dist/consumption/ConsumptionIds.js +1 -0
  13. package/dist/consumption/ConsumptionIds.js.map +1 -1
  14. package/dist/modules/attributeListeners/AttributeListenersController.d.ts +18 -0
  15. package/dist/modules/attributeListeners/AttributeListenersController.js +44 -0
  16. package/dist/modules/attributeListeners/AttributeListenersController.js.map +1 -0
  17. package/dist/modules/attributeListeners/events/AttributeListenerCreatedEvent.d.ts +6 -0
  18. package/dist/modules/attributeListeners/events/AttributeListenerCreatedEvent.js +12 -0
  19. package/dist/modules/attributeListeners/events/AttributeListenerCreatedEvent.js.map +1 -0
  20. package/dist/modules/attributeListeners/events/index.d.ts +1 -0
  21. package/dist/modules/attributeListeners/events/index.js +18 -0
  22. package/dist/modules/attributeListeners/events/index.js.map +1 -0
  23. package/dist/modules/attributeListeners/index.d.ts +4 -0
  24. package/dist/modules/attributeListeners/index.js +21 -0
  25. package/dist/modules/attributeListeners/index.js.map +1 -0
  26. package/dist/modules/attributeListeners/local/CreateLocalAttributeListenerParams.d.ts +12 -0
  27. package/dist/modules/attributeListeners/local/CreateLocalAttributeListenerParams.js +31 -0
  28. package/dist/modules/attributeListeners/local/CreateLocalAttributeListenerParams.js.map +1 -0
  29. package/dist/modules/attributeListeners/local/LocalAttributeListener.d.ts +19 -0
  30. package/dist/modules/attributeListeners/local/LocalAttributeListener.js +48 -0
  31. package/dist/modules/attributeListeners/local/LocalAttributeListener.js.map +1 -0
  32. package/dist/modules/attributes/LocalAttributesController.d.ts +3 -2
  33. package/dist/modules/attributes/LocalAttributesController.js +13 -4
  34. package/dist/modules/attributes/LocalAttributesController.js.map +1 -1
  35. package/dist/modules/attributes/local/{CreateRelationshipAttributeParams.d.ts → CreateAttributeParams.d.ts} +3 -3
  36. package/dist/modules/attributes/local/{CreateRelationshipAttributeParams.js → CreateAttributeParams.js} +10 -10
  37. package/dist/modules/attributes/local/CreateAttributeParams.js.map +1 -0
  38. package/dist/modules/attributes/local/CreateLocalAttributeParams.js.map +1 -1
  39. package/dist/modules/attributes/local/CreatePeerLocalAttributeParams.js.map +1 -1
  40. package/dist/modules/attributes/local/CreateSharedLocalAttributeCopyParams.js.map +1 -1
  41. package/dist/modules/attributes/local/LocalAttribute.js.map +1 -1
  42. package/dist/modules/attributes/local/LocalAttributeShareInfo.js.map +1 -1
  43. package/dist/modules/attributes/local/QueryTranslator.d.ts +5 -1
  44. package/dist/modules/attributes/local/QueryTranslator.js +50 -1
  45. package/dist/modules/attributes/local/QueryTranslator.js.map +1 -1
  46. package/dist/modules/attributes/local/SucceedLocalAttributeParams.js.map +1 -1
  47. package/dist/modules/attributes/local/UpdateLocalAttributeParams.js.map +1 -1
  48. package/dist/modules/drafts/DraftsController.js +1 -1
  49. package/dist/modules/drafts/DraftsController.js.map +1 -1
  50. package/dist/modules/drafts/local/Draft.js.map +1 -1
  51. package/dist/modules/index.d.ts +1 -0
  52. package/dist/modules/index.js +1 -0
  53. package/dist/modules/index.js.map +1 -1
  54. package/dist/modules/requests/incoming/checkPrerequisites/CheckPrerequisitesOfIncomingRequestParameters.js.map +1 -1
  55. package/dist/modules/requests/incoming/complete/CompleteIncomingRequestParameters.js.map +1 -1
  56. package/dist/modules/requests/incoming/decide/InternalDecideRequestParameters.js.map +1 -1
  57. package/dist/modules/requests/incoming/received/ReceivedIncomingRequestParameters.js.map +1 -1
  58. package/dist/modules/requests/incoming/requireManualDecision/RequireManualDecisionOfIncomingRequestParameters.js.map +1 -1
  59. package/dist/modules/requests/index.d.ts +2 -2
  60. package/dist/modules/requests/index.js +2 -2
  61. package/dist/modules/requests/index.js.map +1 -1
  62. package/dist/modules/requests/itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters.d.ts +7 -0
  63. package/dist/modules/requests/itemProcessors/{createRelationshipAttribute/AcceptCreateRelationshipAttributeRequestItemParameters.js → createAttribute/AcceptCreateAttributeRequestItemParameters.js} +7 -7
  64. package/dist/modules/requests/itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters.js.map +1 -0
  65. package/dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.d.ts +11 -0
  66. package/dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js +70 -0
  67. package/dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js.map +1 -0
  68. package/dist/modules/requests/itemProcessors/proposeAttribute/AcceptProposeAttributeRequestItemParameters.js.map +1 -1
  69. package/dist/modules/requests/itemProcessors/readAttribute/AcceptReadAttributeRequestItemParameters.js.map +1 -1
  70. package/dist/modules/requests/itemProcessors/shareAttribute/AcceptShareAttributeRequestItemParameters.js.map +1 -1
  71. package/dist/modules/requests/itemProcessors/utility/validateQuery.d.ts +2 -2
  72. package/dist/modules/requests/itemProcessors/utility/validateQuery.js +4 -4
  73. package/dist/modules/requests/itemProcessors/utility/validateQuery.js.map +1 -1
  74. package/dist/modules/requests/local/LocalRequest.js.map +1 -1
  75. package/dist/modules/requests/local/LocalRequestStatusLogEntry.js.map +1 -1
  76. package/dist/modules/requests/local/LocalResponse.js.map +1 -1
  77. package/dist/modules/requests/outgoing/completeOutgoingRequest/CompleteOutgoingRequestParameters.js.map +1 -1
  78. package/dist/modules/requests/outgoing/createFromRelationshipCreationChange/CreateOutgoingRequestFromRelationshipCreationChangeParameters.js.map +1 -1
  79. package/dist/modules/requests/outgoing/createOutgoingRequest/CanCreateOutgoingRequestParameters.js.map +1 -1
  80. package/dist/modules/requests/outgoing/createOutgoingRequest/CreateOutgoingRequestParameters.js.map +1 -1
  81. package/dist/modules/requests/outgoing/sentOutgoingRequest/SentOutgoingRequestParameters.js.map +1 -1
  82. package/dist/modules/settings/SettingsController.js +1 -1
  83. package/dist/modules/settings/SettingsController.js.map +1 -1
  84. package/dist/modules/settings/local/Setting.js.map +1 -1
  85. package/lib-web/nmshd.consumption.js +430 -91
  86. package/lib-web/nmshd.consumption.js.map +1 -1
  87. package/lib-web/nmshd.consumption.min.js +1 -1
  88. package/lib-web/nmshd.consumption.min.js.map +1 -1
  89. package/package.json +8 -8
  90. package/dist/modules/attributes/local/CreateRelationshipAttributeParams.js.map +0 -1
  91. package/dist/modules/requests/itemProcessors/createRelationshipAttribute/AcceptCreateRelationshipAttributeRequestItemParameters.d.ts +0 -7
  92. package/dist/modules/requests/itemProcessors/createRelationshipAttribute/AcceptCreateRelationshipAttributeRequestItemParameters.js.map +0 -1
  93. package/dist/modules/requests/itemProcessors/createRelationshipAttribute/CreateRelationshipAttributeRequestItemProcessor.d.ts +0 -11
  94. package/dist/modules/requests/itemProcessors/createRelationshipAttribute/CreateRelationshipAttributeRequestItemProcessor.js +0 -44
  95. 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.13",
21
- build: "63",
22
- date: "2022-09-07T12:50:15+00:00",
23
- commit: "10ee9ba1cf7cd57193bd549a7f27df6e481ae543",
20
+ version: "2.0.0-beta.16",
21
+ build: "68",
22
+ date: "2022-09-13T12:54:16+00:00",
23
+ commit: "0e745294518a8409ceacda7019eb2cd6c442a755",
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
- async parseArray(values, type) {
62
- const parsePromises = values.map((v) => type.from(v));
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;
@@ -80,12 +79,6 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
80
79
  exports.ConsumptionController = void 0;
81
80
  const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
82
81
  const modules_1 = __webpack_require__(/*! ../modules */ "./dist/modules/index.js");
83
- const LocalAttributesController_1 = __webpack_require__(/*! ../modules/attributes/LocalAttributesController */ "./dist/modules/attributes/LocalAttributesController.js");
84
- const DraftsController_1 = __webpack_require__(/*! ../modules/drafts/DraftsController */ "./dist/modules/drafts/DraftsController.js");
85
- const IncomingRequestsController_1 = __webpack_require__(/*! ../modules/requests/incoming/IncomingRequestsController */ "./dist/modules/requests/incoming/IncomingRequestsController.js");
86
- const RequestItemProcessorRegistry_1 = __webpack_require__(/*! ../modules/requests/itemProcessors/RequestItemProcessorRegistry */ "./dist/modules/requests/itemProcessors/RequestItemProcessorRegistry.js");
87
- const OutgoingRequestsController_1 = __webpack_require__(/*! ../modules/requests/outgoing/OutgoingRequestsController */ "./dist/modules/requests/outgoing/OutgoingRequestsController.js");
88
- const SettingsController_1 = __webpack_require__(/*! ../modules/settings/SettingsController */ "./dist/modules/settings/SettingsController.js");
89
82
  class ConsumptionController {
90
83
  constructor(transport, accountController) {
91
84
  this.transport = transport;
@@ -106,22 +99,26 @@ class ConsumptionController {
106
99
  get settings() {
107
100
  return this._settings;
108
101
  }
102
+ get attributeListeners() {
103
+ return this._attributeListeners;
104
+ }
109
105
  async init(requestItemProcessorOverrides = new Map()) {
110
- this._attributes = await new LocalAttributesController_1.LocalAttributesController(this, this.transport.eventBus, this.accountController.identity).init();
111
- this._drafts = await new DraftsController_1.DraftsController(this).init();
112
- const processorRegistry = new RequestItemProcessorRegistry_1.RequestItemProcessorRegistry(this, this.getDefaultProcessors());
106
+ this._attributes = await new modules_1.LocalAttributesController(this, this.transport.eventBus, this.accountController.identity).init();
107
+ this._drafts = await new modules_1.DraftsController(this).init();
108
+ const processorRegistry = new modules_1.RequestItemProcessorRegistry(this, this.getDefaultProcessors());
113
109
  for (const [itemConstructor, processorConstructor] of requestItemProcessorOverrides) {
114
110
  processorRegistry.registerOrReplaceProcessor(itemConstructor, processorConstructor);
115
111
  }
116
- this._outgoingRequests = await new OutgoingRequestsController_1.OutgoingRequestsController(await this.accountController.getSynchronizedCollection("Requests"), processorRegistry, this, this.transport.eventBus, this.accountController.identity).init();
117
- this._incomingRequests = await new IncomingRequestsController_1.IncomingRequestsController(await this.accountController.getSynchronizedCollection("Requests"), processorRegistry, this, this.transport.eventBus, this.accountController.identity).init();
118
- this._settings = await new SettingsController_1.SettingsController(this).init();
112
+ this._outgoingRequests = await new modules_1.OutgoingRequestsController(await this.accountController.getSynchronizedCollection("Requests"), processorRegistry, this, this.transport.eventBus, this.accountController.identity).init();
113
+ this._incomingRequests = await new modules_1.IncomingRequestsController(await this.accountController.getSynchronizedCollection("Requests"), processorRegistry, this, this.transport.eventBus, this.accountController.identity).init();
114
+ this._settings = await new modules_1.SettingsController(this).init();
115
+ this._attributeListeners = await new modules_1.AttributeListenersController(this, this.transport.eventBus, this.accountController.identity).init();
119
116
  return this;
120
117
  }
121
118
  getDefaultProcessors() {
122
119
  return new Map([
123
120
  [content_1.ShareAttributeRequestItem, modules_1.ShareAttributeRequestItemProcessor],
124
- [content_1.CreateRelationshipAttributeRequestItem, modules_1.CreateRelationshipAttributeRequestItemProcessor],
121
+ [content_1.CreateAttributeRequestItem, modules_1.CreateAttributeRequestItemProcessor],
125
122
  [content_1.ReadAttributeRequestItem, modules_1.ReadAttributeRequestItemProcessor],
126
123
  [content_1.ProposeAttributeRequestItem, modules_1.ProposeAttributeRequestItemProcessor],
127
124
  [content_1.ConsentRequestItem, modules_1.GenericRequestItemProcessor],
@@ -147,6 +144,7 @@ exports.ConsumptionControllerName = void 0;
147
144
  var ConsumptionControllerName;
148
145
  (function (ConsumptionControllerName) {
149
146
  ConsumptionControllerName["LocalAttributesController"] = "LocalAttributesController";
147
+ ConsumptionControllerName["AttributeListenersController"] = "AttributeListenersController";
150
148
  ConsumptionControllerName["DraftsController"] = "DraftsController";
151
149
  ConsumptionControllerName["RelationshipInfoController"] = "RelationshipInfoController";
152
150
  ConsumptionControllerName["SingleRelationshipController"] = "SingleRelationshipController";
@@ -259,6 +257,7 @@ ConsumptionIds.draft = new transport_1.CoreIdHelper("LCLDRF");
259
257
  ConsumptionIds.setting = new transport_1.CoreIdHelper("LCLSET");
260
258
  ConsumptionIds.attribute = new transport_1.CoreIdHelper("ATT");
261
259
  ConsumptionIds.request = new transport_1.CoreIdHelper("REQ");
260
+ ConsumptionIds.attributeListener = new transport_1.CoreIdHelper("ATL");
262
261
  //# sourceMappingURL=ConsumptionIds.js.map
263
262
 
264
263
  /***/ }),
@@ -325,6 +324,240 @@ __exportStar(__webpack_require__(/*! ./modules */ "./dist/modules/index.js"), ex
325
324
 
326
325
  /***/ }),
327
326
 
327
+ /***/ "./dist/modules/attributeListeners/AttributeListenersController.js":
328
+ /*!*************************************************************************!*\
329
+ !*** ./dist/modules/attributeListeners/AttributeListenersController.js ***!
330
+ \*************************************************************************/
331
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
332
+
333
+ "use strict";
334
+
335
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
336
+ exports.AttributeListenersController = void 0;
337
+ const consumption_1 = __webpack_require__(/*! ../../consumption */ "./dist/consumption/index.js");
338
+ const ConsumptionBaseController_1 = __webpack_require__(/*! ../../consumption/ConsumptionBaseController */ "./dist/consumption/ConsumptionBaseController.js");
339
+ const ConsumptionControllerName_1 = __webpack_require__(/*! ../../consumption/ConsumptionControllerName */ "./dist/consumption/ConsumptionControllerName.js");
340
+ const events_1 = __webpack_require__(/*! ./events */ "./dist/modules/attributeListeners/events/index.js");
341
+ const CreateLocalAttributeListenerParams_1 = __webpack_require__(/*! ./local/CreateLocalAttributeListenerParams */ "./dist/modules/attributeListeners/local/CreateLocalAttributeListenerParams.js");
342
+ const LocalAttributeListener_1 = __webpack_require__(/*! ./local/LocalAttributeListener */ "./dist/modules/attributeListeners/local/LocalAttributeListener.js");
343
+ class AttributeListenersController extends ConsumptionBaseController_1.ConsumptionBaseController {
344
+ constructor(parent, eventBus, identity) {
345
+ super(ConsumptionControllerName_1.ConsumptionControllerName.AttributeListenersController, parent);
346
+ this.eventBus = eventBus;
347
+ this.identity = identity;
348
+ }
349
+ async init() {
350
+ await super.init();
351
+ this.attributeListeners = await this.parent.accountController.getSynchronizedCollection("AttributeListeners");
352
+ return this;
353
+ }
354
+ async getAttributeListeners(query) {
355
+ const items = await this.attributeListeners.find(query);
356
+ return this.parseArray(items, LocalAttributeListener_1.LocalAttributeListener);
357
+ }
358
+ async getAttributeListener(id) {
359
+ const listener = await this.attributeListeners.read(id.toString());
360
+ if (!listener)
361
+ return;
362
+ return LocalAttributeListener_1.LocalAttributeListener.from(listener);
363
+ }
364
+ async createAttributeListener(params) {
365
+ const parsedParams = CreateLocalAttributeListenerParams_1.CreateLocalAttributeListenerParams.from(params);
366
+ const listener = LocalAttributeListener_1.LocalAttributeListener.from({
367
+ id: await consumption_1.ConsumptionIds.attributeListener.generate(),
368
+ query: parsedParams.query,
369
+ peer: parsedParams.peer
370
+ });
371
+ await this.attributeListeners.create(listener);
372
+ this.eventBus.publish(new events_1.AttributeListenerCreatedEvent(this.identity.address.toString(), listener));
373
+ return listener;
374
+ }
375
+ }
376
+ exports.AttributeListenersController = AttributeListenersController;
377
+ //# sourceMappingURL=AttributeListenersController.js.map
378
+
379
+ /***/ }),
380
+
381
+ /***/ "./dist/modules/attributeListeners/events/AttributeListenerCreatedEvent.js":
382
+ /*!*********************************************************************************!*\
383
+ !*** ./dist/modules/attributeListeners/events/AttributeListenerCreatedEvent.js ***!
384
+ \*********************************************************************************/
385
+ /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
386
+
387
+ "use strict";
388
+
389
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
390
+ exports.AttributeListenerCreatedEvent = void 0;
391
+ const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
392
+ class AttributeListenerCreatedEvent extends transport_1.TransportDataEvent {
393
+ constructor(eventTargetAddress, data) {
394
+ super(AttributeListenerCreatedEvent.namespace, eventTargetAddress, data);
395
+ }
396
+ }
397
+ exports.AttributeListenerCreatedEvent = AttributeListenerCreatedEvent;
398
+ AttributeListenerCreatedEvent.namespace = "consumption.attributeListenerCreated";
399
+ //# sourceMappingURL=AttributeListenerCreatedEvent.js.map
400
+
401
+ /***/ }),
402
+
403
+ /***/ "./dist/modules/attributeListeners/events/index.js":
404
+ /*!*********************************************************!*\
405
+ !*** ./dist/modules/attributeListeners/events/index.js ***!
406
+ \*********************************************************/
407
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
408
+
409
+ "use strict";
410
+
411
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
412
+ if (k2 === undefined) k2 = k;
413
+ var desc = Object.getOwnPropertyDescriptor(m, k);
414
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
415
+ desc = { enumerable: true, get: function() { return m[k]; } };
416
+ }
417
+ Object.defineProperty(o, k2, desc);
418
+ }) : (function(o, m, k, k2) {
419
+ if (k2 === undefined) k2 = k;
420
+ o[k2] = m[k];
421
+ }));
422
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
423
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
424
+ };
425
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
426
+ __exportStar(__webpack_require__(/*! ./AttributeListenerCreatedEvent */ "./dist/modules/attributeListeners/events/AttributeListenerCreatedEvent.js"), exports);
427
+ //# sourceMappingURL=index.js.map
428
+
429
+ /***/ }),
430
+
431
+ /***/ "./dist/modules/attributeListeners/index.js":
432
+ /*!**************************************************!*\
433
+ !*** ./dist/modules/attributeListeners/index.js ***!
434
+ \**************************************************/
435
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
436
+
437
+ "use strict";
438
+
439
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
440
+ if (k2 === undefined) k2 = k;
441
+ var desc = Object.getOwnPropertyDescriptor(m, k);
442
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
443
+ desc = { enumerable: true, get: function() { return m[k]; } };
444
+ }
445
+ Object.defineProperty(o, k2, desc);
446
+ }) : (function(o, m, k, k2) {
447
+ if (k2 === undefined) k2 = k;
448
+ o[k2] = m[k];
449
+ }));
450
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
451
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
452
+ };
453
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
454
+ __exportStar(__webpack_require__(/*! ./AttributeListenersController */ "./dist/modules/attributeListeners/AttributeListenersController.js"), exports);
455
+ __exportStar(__webpack_require__(/*! ./events */ "./dist/modules/attributeListeners/events/index.js"), exports);
456
+ __exportStar(__webpack_require__(/*! ./local/CreateLocalAttributeListenerParams */ "./dist/modules/attributeListeners/local/CreateLocalAttributeListenerParams.js"), exports);
457
+ __exportStar(__webpack_require__(/*! ./local/LocalAttributeListener */ "./dist/modules/attributeListeners/local/LocalAttributeListener.js"), exports);
458
+ //# sourceMappingURL=index.js.map
459
+
460
+ /***/ }),
461
+
462
+ /***/ "./dist/modules/attributeListeners/local/CreateLocalAttributeListenerParams.js":
463
+ /*!*************************************************************************************!*\
464
+ !*** ./dist/modules/attributeListeners/local/CreateLocalAttributeListenerParams.js ***!
465
+ \*************************************************************************************/
466
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
467
+
468
+ "use strict";
469
+
470
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
471
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
472
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
473
+ 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;
474
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
475
+ };
476
+ var __metadata = (this && this.__metadata) || function (k, v) {
477
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
478
+ };
479
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
480
+ exports.CreateLocalAttributeListenerParams = void 0;
481
+ const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
482
+ const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
483
+ class CreateLocalAttributeListenerParams extends ts_serval_1.Serializable {
484
+ static from(value) {
485
+ return this.fromAny(value);
486
+ }
487
+ }
488
+ __decorate([
489
+ (0, ts_serval_1.serialize)(),
490
+ (0, ts_serval_1.validate)(),
491
+ __metadata("design:type", Object)
492
+ ], CreateLocalAttributeListenerParams.prototype, "query", void 0);
493
+ __decorate([
494
+ (0, ts_serval_1.serialize)(),
495
+ (0, ts_serval_1.validate)(),
496
+ __metadata("design:type", transport_1.CoreAddress)
497
+ ], CreateLocalAttributeListenerParams.prototype, "peer", void 0);
498
+ exports.CreateLocalAttributeListenerParams = CreateLocalAttributeListenerParams;
499
+ //# sourceMappingURL=CreateLocalAttributeListenerParams.js.map
500
+
501
+ /***/ }),
502
+
503
+ /***/ "./dist/modules/attributeListeners/local/LocalAttributeListener.js":
504
+ /*!*************************************************************************!*\
505
+ !*** ./dist/modules/attributeListeners/local/LocalAttributeListener.js ***!
506
+ \*************************************************************************/
507
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
508
+
509
+ "use strict";
510
+
511
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
512
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
513
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
514
+ 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;
515
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
516
+ };
517
+ var __metadata = (this && this.__metadata) || function (k, v) {
518
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
519
+ };
520
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
521
+ exports.LocalAttributeListener = void 0;
522
+ const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
523
+ const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
524
+ const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
525
+ const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
526
+ let LocalAttributeListener = class LocalAttributeListener extends transport_1.CoreSynchronizable {
527
+ constructor() {
528
+ super(...arguments);
529
+ this.userdataProperties = [
530
+ (0, ts_simple_nameof_1.nameof)((r) => r.query),
531
+ (0, ts_simple_nameof_1.nameof)((r) => r.peer)
532
+ ];
533
+ }
534
+ static from(value) {
535
+ return this.fromAny(value);
536
+ }
537
+ toJSON() {
538
+ return super.toJSON();
539
+ }
540
+ };
541
+ __decorate([
542
+ (0, ts_serval_1.serialize)({
543
+ unionTypes: [content_1.IdentityAttributeQuery, content_1.RelationshipAttributeQuery, content_1.ThirdPartyRelationshipAttributeQuery]
544
+ }),
545
+ (0, ts_serval_1.validate)(),
546
+ __metadata("design:type", Object)
547
+ ], LocalAttributeListener.prototype, "query", void 0);
548
+ __decorate([
549
+ (0, ts_serval_1.serialize)(),
550
+ (0, ts_serval_1.validate)(),
551
+ __metadata("design:type", transport_1.CoreAddress)
552
+ ], LocalAttributeListener.prototype, "peer", void 0);
553
+ LocalAttributeListener = __decorate([
554
+ (0, ts_serval_1.type)("LocalAttributeListener")
555
+ ], LocalAttributeListener);
556
+ exports.LocalAttributeListener = LocalAttributeListener;
557
+ //# sourceMappingURL=LocalAttributeListener.js.map
558
+
559
+ /***/ }),
560
+
328
561
  /***/ "./dist/modules/attributes/LocalAttributesController.js":
329
562
  /*!**************************************************************!*\
330
563
  !*** ./dist/modules/attributes/LocalAttributesController.js ***!
@@ -413,11 +646,11 @@ class LocalAttributesController extends consumption_1.ConsumptionBaseController
413
646
  }
414
647
  async getLocalAttributes(query) {
415
648
  const attributes = await this.attributes.find(query);
416
- return await this.parseArray(attributes, LocalAttribute_1.LocalAttribute);
649
+ return this.parseArray(attributes, LocalAttribute_1.LocalAttribute);
417
650
  }
418
651
  async getValidLocalAttributes(query) {
419
652
  const attributes = await this.attributes.find(query);
420
- const items = await this.parseArray(attributes, LocalAttribute_1.LocalAttribute);
653
+ const items = this.parseArray(attributes, LocalAttribute_1.LocalAttribute);
421
654
  return this.filterCurrent(items);
422
655
  }
423
656
  async executeRelationshipAttributeQuery(query) {
@@ -425,7 +658,16 @@ class LocalAttributesController extends consumption_1.ConsumptionBaseController
425
658
  const dbQuery = QueryTranslator_1.RelationshipAttributeQueryTranslator.translate(parsedQuery);
426
659
  dbQuery["content.confidentiality"] = { $ne: "private" };
427
660
  const attributes = await this.attributes.find(dbQuery);
428
- return await this.parseArray(attributes, LocalAttribute_1.LocalAttribute);
661
+ const attribute = attributes.length > 0 ? attributes[0] : undefined;
662
+ return attribute === undefined ? undefined : LocalAttribute_1.LocalAttribute.from(attribute);
663
+ }
664
+ async executeThirdPartyRelationshipAttributeQuery(query) {
665
+ const parsedQuery = content_1.ThirdPartyRelationshipAttributeQuery.from(query);
666
+ const dbQuery = QueryTranslator_1.ThirdPartyRelationshipAttributeQueryTranslator.translate(parsedQuery);
667
+ dbQuery["content.confidentiality"] = { $ne: "private" };
668
+ const attributes = await this.attributes.find(dbQuery);
669
+ const attribute = attributes.length > 0 ? attributes[0] : undefined;
670
+ return attribute ?? LocalAttribute_1.LocalAttribute.from(attribute);
429
671
  }
430
672
  async executeIdentityAttributeQuery(query) {
431
673
  const parsedQuery = content_1.IdentityAttributeQuery.from(query);
@@ -433,7 +675,7 @@ class LocalAttributesController extends consumption_1.ConsumptionBaseController
433
675
  dbQuery["content.owner"] = this.identity.address.toString();
434
676
  dbQuery["shareInfo"] = { $exists: false };
435
677
  const attributes = await this.attributes.find(dbQuery);
436
- return await this.parseArray(attributes, LocalAttribute_1.LocalAttribute);
678
+ return this.parseArray(attributes, LocalAttribute_1.LocalAttribute);
437
679
  }
438
680
  async createLocalAttribute(params) {
439
681
  const localAttribute = await LocalAttribute_1.LocalAttribute.fromAttribute(params.content);
@@ -982,7 +1224,7 @@ exports.LocalAttributeShareInfo = LocalAttributeShareInfo;
982
1224
  "use strict";
983
1225
 
984
1226
  Object.defineProperty(exports, "__esModule", ({ value: true }));
985
- exports.RelationshipAttributeQueryTranslator = exports.IdentityAttributeQueryTranslator = void 0;
1227
+ exports.ThirdPartyRelationshipAttributeQueryTranslator = exports.RelationshipAttributeQueryTranslator = exports.IdentityAttributeQueryTranslator = void 0;
986
1228
  const docdb_querytranslator_1 = __webpack_require__(/*! @js-soft/docdb-querytranslator */ "./node_modules/@js-soft/docdb-querytranslator/dist/index.js");
987
1229
  const luxon_1 = __webpack_require__(/*! luxon */ "./node_modules/luxon/build/node/luxon.js");
988
1230
  const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
@@ -1052,6 +1294,55 @@ class RelationshipAttributeQueryTranslator {
1052
1294
  }
1053
1295
  exports.RelationshipAttributeQueryTranslator = RelationshipAttributeQueryTranslator;
1054
1296
  RelationshipAttributeQueryTranslator.translator = new docdb_querytranslator_1.QueryTranslator({
1297
+ whitelist: {
1298
+ [(0, ts_simple_nameof_1.nameof)((x) => x.key)]: true,
1299
+ [(0, ts_simple_nameof_1.nameof)((x) => x.validFrom)]: true,
1300
+ [(0, ts_simple_nameof_1.nameof)((x) => x.validTo)]: true,
1301
+ [(0, ts_simple_nameof_1.nameof)((x) => x.owner)]: true,
1302
+ attributeType: true
1303
+ },
1304
+ alias: {
1305
+ // key
1306
+ [(0, ts_simple_nameof_1.nameof)((x) => x.key)]: [
1307
+ `${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.${(0, ts_simple_nameof_1.nameof)((x) => x.key)}`
1308
+ ],
1309
+ // @type of attribute
1310
+ attributeType: [`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.@type`],
1311
+ // owner
1312
+ [(0, ts_simple_nameof_1.nameof)((x) => x.owner)]: [
1313
+ `${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.${(0, ts_simple_nameof_1.nameof)((x) => x.owner)}`
1314
+ ]
1315
+ },
1316
+ custom: {
1317
+ // validFrom
1318
+ [(0, ts_simple_nameof_1.nameof)((x) => x.validFrom)]: (query, input) => {
1319
+ if (!input) {
1320
+ return;
1321
+ }
1322
+ const validFromUtcString = luxon_1.DateTime.fromISO(input).toUTC().toString();
1323
+ query[`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.${(0, ts_simple_nameof_1.nameof)((x) => x.validFrom)}`] = {
1324
+ $gte: validFromUtcString
1325
+ };
1326
+ },
1327
+ // validTo
1328
+ [(0, ts_simple_nameof_1.nameof)((x) => x.validTo)]: (query, input) => {
1329
+ if (!input) {
1330
+ return;
1331
+ }
1332
+ const validToUtcString = luxon_1.DateTime.fromISO(input).toUTC().toString();
1333
+ query[`${(0, ts_simple_nameof_1.nameof)((x) => x.content)}.${(0, ts_simple_nameof_1.nameof)((x) => x.validTo)}`] = {
1334
+ $lte: validToUtcString
1335
+ };
1336
+ }
1337
+ }
1338
+ });
1339
+ class ThirdPartyRelationshipAttributeQueryTranslator {
1340
+ static translate(query) {
1341
+ return this.translator.parse({ ...query.toJSON(), attributeType: "RelationshipAttribute" });
1342
+ }
1343
+ }
1344
+ exports.ThirdPartyRelationshipAttributeQueryTranslator = ThirdPartyRelationshipAttributeQueryTranslator;
1345
+ ThirdPartyRelationshipAttributeQueryTranslator.translator = new docdb_querytranslator_1.QueryTranslator({
1055
1346
  whitelist: {
1056
1347
  [(0, ts_simple_nameof_1.nameof)((x) => x.key)]: true,
1057
1348
  [(0, ts_simple_nameof_1.nameof)((x) => x.validFrom)]: true,
@@ -1215,7 +1506,7 @@ class DraftsController extends consumption_1.ConsumptionBaseController {
1215
1506
  }
1216
1507
  async getDrafts(query) {
1217
1508
  const items = await this.drafts.find(query);
1218
- return await this.parseArray(items, Draft_1.Draft);
1509
+ return this.parseArray(items, Draft_1.Draft);
1219
1510
  }
1220
1511
  async createDraft(content, type = "") {
1221
1512
  const draft = Draft_1.Draft.from({
@@ -1376,6 +1667,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
1376
1667
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1377
1668
  };
1378
1669
  Object.defineProperty(exports, "__esModule", ({ value: true }));
1670
+ __exportStar(__webpack_require__(/*! ./attributeListeners */ "./dist/modules/attributeListeners/index.js"), exports);
1379
1671
  __exportStar(__webpack_require__(/*! ./attributes */ "./dist/modules/attributes/index.js"), exports);
1380
1672
  __exportStar(__webpack_require__(/*! ./drafts */ "./dist/modules/drafts/index.js"), exports);
1381
1673
  __exportStar(__webpack_require__(/*! ./requests */ "./dist/modules/requests/index.js"), exports);
@@ -2241,8 +2533,8 @@ __exportStar(__webpack_require__(/*! ./incoming/IncomingRequestsController */ ".
2241
2533
  __exportStar(__webpack_require__(/*! ./incoming/received/ReceivedIncomingRequestParameters */ "./dist/modules/requests/incoming/received/ReceivedIncomingRequestParameters.js"), exports);
2242
2534
  __exportStar(__webpack_require__(/*! ./incoming/requireManualDecision/RequireManualDecisionOfIncomingRequestParameters */ "./dist/modules/requests/incoming/requireManualDecision/RequireManualDecisionOfIncomingRequestParameters.js"), exports);
2243
2535
  __exportStar(__webpack_require__(/*! ./itemProcessors/AbstractRequestItemProcessor */ "./dist/modules/requests/itemProcessors/AbstractRequestItemProcessor.js"), exports);
2244
- __exportStar(__webpack_require__(/*! ./itemProcessors/createRelationshipAttribute/AcceptCreateRelationshipAttributeRequestItemParameters */ "./dist/modules/requests/itemProcessors/createRelationshipAttribute/AcceptCreateRelationshipAttributeRequestItemParameters.js"), exports);
2245
- __exportStar(__webpack_require__(/*! ./itemProcessors/createRelationshipAttribute/CreateRelationshipAttributeRequestItemProcessor */ "./dist/modules/requests/itemProcessors/createRelationshipAttribute/CreateRelationshipAttributeRequestItemProcessor.js"), exports);
2536
+ __exportStar(__webpack_require__(/*! ./itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters */ "./dist/modules/requests/itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters.js"), exports);
2537
+ __exportStar(__webpack_require__(/*! ./itemProcessors/createAttribute/CreateAttributeRequestItemProcessor */ "./dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js"), exports);
2246
2538
  __exportStar(__webpack_require__(/*! ./itemProcessors/GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js"), exports);
2247
2539
  __exportStar(__webpack_require__(/*! ./itemProcessors/IRequestItemProcessor */ "./dist/modules/requests/itemProcessors/IRequestItemProcessor.js"), exports);
2248
2540
  __exportStar(__webpack_require__(/*! ./itemProcessors/ProcessorConstructor */ "./dist/modules/requests/itemProcessors/ProcessorConstructor.js"), exports);
@@ -2462,10 +2754,10 @@ exports.ErrorValidationResult = ErrorValidationResult;
2462
2754
 
2463
2755
  /***/ }),
2464
2756
 
2465
- /***/ "./dist/modules/requests/itemProcessors/createRelationshipAttribute/AcceptCreateRelationshipAttributeRequestItemParameters.js":
2466
- /*!************************************************************************************************************************************!*\
2467
- !*** ./dist/modules/requests/itemProcessors/createRelationshipAttribute/AcceptCreateRelationshipAttributeRequestItemParameters.js ***!
2468
- \************************************************************************************************************************************/
2757
+ /***/ "./dist/modules/requests/itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters.js":
2758
+ /*!************************************************************************************************************!*\
2759
+ !*** ./dist/modules/requests/itemProcessors/createAttribute/AcceptCreateAttributeRequestItemParameters.js ***!
2760
+ \************************************************************************************************************/
2469
2761
  /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
2470
2762
 
2471
2763
  "use strict";
@@ -2477,61 +2769,87 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
2477
2769
  return c > 3 && r && Object.defineProperty(target, key, r), r;
2478
2770
  };
2479
2771
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2480
- exports.AcceptCreateRelationshipAttributeRequestItemParameters = void 0;
2772
+ exports.AcceptCreateAttributeRequestItemParameters = void 0;
2481
2773
  const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
2482
- let AcceptCreateRelationshipAttributeRequestItemParameters = class AcceptCreateRelationshipAttributeRequestItemParameters extends ts_serval_1.Serializable {
2774
+ let AcceptCreateAttributeRequestItemParameters = class AcceptCreateAttributeRequestItemParameters extends ts_serval_1.Serializable {
2483
2775
  static from(value) {
2484
2776
  return this.fromAny(value);
2485
2777
  }
2486
2778
  };
2487
- AcceptCreateRelationshipAttributeRequestItemParameters = __decorate([
2488
- (0, ts_serval_1.type)("AcceptCreateRelationshipAttributeRequestItemParameters")
2489
- ], AcceptCreateRelationshipAttributeRequestItemParameters);
2490
- exports.AcceptCreateRelationshipAttributeRequestItemParameters = AcceptCreateRelationshipAttributeRequestItemParameters;
2491
- //# sourceMappingURL=AcceptCreateRelationshipAttributeRequestItemParameters.js.map
2779
+ AcceptCreateAttributeRequestItemParameters = __decorate([
2780
+ (0, ts_serval_1.type)("AcceptCreateAttributeRequestItemParameters")
2781
+ ], AcceptCreateAttributeRequestItemParameters);
2782
+ exports.AcceptCreateAttributeRequestItemParameters = AcceptCreateAttributeRequestItemParameters;
2783
+ //# sourceMappingURL=AcceptCreateAttributeRequestItemParameters.js.map
2492
2784
 
2493
2785
  /***/ }),
2494
2786
 
2495
- /***/ "./dist/modules/requests/itemProcessors/createRelationshipAttribute/CreateRelationshipAttributeRequestItemProcessor.js":
2496
- /*!*****************************************************************************************************************************!*\
2497
- !*** ./dist/modules/requests/itemProcessors/createRelationshipAttribute/CreateRelationshipAttributeRequestItemProcessor.js ***!
2498
- \*****************************************************************************************************************************/
2787
+ /***/ "./dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js":
2788
+ /*!*****************************************************************************************************!*\
2789
+ !*** ./dist/modules/requests/itemProcessors/createAttribute/CreateAttributeRequestItemProcessor.js ***!
2790
+ \*****************************************************************************************************/
2499
2791
  /***/ ((__unused_webpack_module, exports, __webpack_require__) => {
2500
2792
 
2501
2793
  "use strict";
2502
2794
 
2503
2795
  Object.defineProperty(exports, "__esModule", ({ value: true }));
2504
- exports.CreateRelationshipAttributeRequestItemProcessor = void 0;
2796
+ exports.CreateAttributeRequestItemProcessor = void 0;
2505
2797
  const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
2506
2798
  const consumption_1 = __webpack_require__(/*! ../../../../consumption */ "./dist/consumption/index.js");
2507
2799
  const GenericRequestItemProcessor_1 = __webpack_require__(/*! ../GenericRequestItemProcessor */ "./dist/modules/requests/itemProcessors/GenericRequestItemProcessor.js");
2508
2800
  const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
2509
- class CreateRelationshipAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.GenericRequestItemProcessor {
2510
- canCreateOutgoingRequestItem(requestItem, _request, _recipient) {
2511
- if (requestItem.attribute.owner.toString() !== "" &&
2512
- !requestItem.attribute.owner.equals(this.currentIdentityAddress)) {
2513
- return ValidationResult_1.ValidationResult.error(consumption_1.ConsumptionErrors.requests.invalidRequestItem("The owner of the given `attribute` can only be an empty string. This is because you can only send Attributes where the recipient of the Request is the owner anyway. And in order to avoid mistakes, the owner will be automatically filled for you."));
2801
+ class CreateAttributeRequestItemProcessor extends GenericRequestItemProcessor_1.GenericRequestItemProcessor {
2802
+ canCreateOutgoingRequestItem(requestItem, _request, recipient) {
2803
+ const recipientIsAttributeOwner = requestItem.attribute.owner.equals(recipient);
2804
+ const senderIsAttributeOwner = requestItem.attribute.owner.equals(this.currentIdentityAddress);
2805
+ const ownerIsEmptyString = requestItem.attribute.owner.toString() === "";
2806
+ if (requestItem.attribute instanceof content_1.IdentityAttribute) {
2807
+ if (senderIsAttributeOwner) {
2808
+ return ValidationResult_1.ValidationResult.error(consumption_1.ConsumptionErrors.requests.invalidRequestItem("Cannot create own Attributes with a CreateAttributeRequestItem. Use a ShareAttributeRequestItem instead."));
2809
+ }
2810
+ if (recipientIsAttributeOwner || ownerIsEmptyString || recipient === undefined) {
2811
+ return ValidationResult_1.ValidationResult.success();
2812
+ }
2813
+ 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."));
2514
2814
  }
2515
- return ValidationResult_1.ValidationResult.success();
2815
+ if (recipientIsAttributeOwner || senderIsAttributeOwner || ownerIsEmptyString || recipient === undefined) {
2816
+ return ValidationResult_1.ValidationResult.success();
2817
+ }
2818
+ 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."));
2516
2819
  }
2517
2820
  async accept(requestItem, _params, requestInfo) {
2518
- requestItem.attribute.owner ??= requestInfo.peer;
2519
- const peerLocalAttribute = await this.consumptionController.attributes.createPeerLocalAttribute({
2520
- content: requestItem.attribute,
2521
- peer: requestInfo.peer,
2522
- requestReference: requestInfo.id
2523
- });
2524
- return content_1.CreateRelationshipAttributeAcceptResponseItem.from({
2821
+ if (requestItem.attribute.owner.toString() === "") {
2822
+ requestItem.attribute.owner = this.currentIdentityAddress;
2823
+ }
2824
+ let sharedAttribute;
2825
+ if (requestItem.attribute instanceof content_1.IdentityAttribute) {
2826
+ const repositoryAttribute = await this.consumptionController.attributes.createLocalAttribute({
2827
+ content: requestItem.attribute
2828
+ });
2829
+ sharedAttribute = await this.consumptionController.attributes.createSharedLocalAttributeCopy({
2830
+ peer: requestInfo.peer,
2831
+ requestReference: requestInfo.id,
2832
+ sourceAttributeId: repositoryAttribute.id
2833
+ });
2834
+ }
2835
+ else {
2836
+ sharedAttribute = await this.consumptionController.attributes.createPeerLocalAttribute({
2837
+ content: requestItem.attribute,
2838
+ peer: requestInfo.peer,
2839
+ requestReference: requestInfo.id
2840
+ });
2841
+ }
2842
+ return content_1.CreateAttributeAcceptResponseItem.from({
2525
2843
  result: content_1.ResponseItemResult.Accepted,
2526
- attributeId: peerLocalAttribute.id
2844
+ attributeId: sharedAttribute.id
2527
2845
  });
2528
2846
  }
2529
2847
  async applyIncomingResponseItem(responseItem, requestItem, requestInfo) {
2530
- if (!(responseItem instanceof content_1.CreateRelationshipAttributeAcceptResponseItem)) {
2848
+ if (!(responseItem instanceof content_1.CreateAttributeAcceptResponseItem)) {
2531
2849
  return;
2532
2850
  }
2533
2851
  if (requestItem.attribute.owner.toString() === "") {
2534
- requestItem.attribute.owner = this.currentIdentityAddress;
2852
+ requestItem.attribute.owner = requestInfo.peer;
2535
2853
  }
2536
2854
  await this.consumptionController.attributes.createPeerLocalAttribute({
2537
2855
  id: responseItem.attributeId,
@@ -2541,8 +2859,8 @@ class CreateRelationshipAttributeRequestItemProcessor extends GenericRequestItem
2541
2859
  });
2542
2860
  }
2543
2861
  }
2544
- exports.CreateRelationshipAttributeRequestItemProcessor = CreateRelationshipAttributeRequestItemProcessor;
2545
- //# sourceMappingURL=CreateRelationshipAttributeRequestItemProcessor.js.map
2862
+ exports.CreateAttributeRequestItemProcessor = CreateAttributeRequestItemProcessor;
2863
+ //# sourceMappingURL=CreateAttributeRequestItemProcessor.js.map
2546
2864
 
2547
2865
  /***/ }),
2548
2866
 
@@ -2995,14 +3313,14 @@ const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
2995
3313
  const consumption_1 = __webpack_require__(/*! ../../../../consumption */ "./dist/consumption/index.js");
2996
3314
  const ValidationResult_1 = __webpack_require__(/*! ../ValidationResult */ "./dist/modules/requests/itemProcessors/ValidationResult.js");
2997
3315
  function validateQuery(query, sender, recipient) {
2998
- if (query instanceof content_1.RelationshipAttributeQuery) {
2999
- if (query.thirdParty?.equals(sender)) {
3316
+ if (query instanceof content_1.ThirdPartyRelationshipAttributeQuery) {
3317
+ if (query.thirdParty.equals(sender)) {
3000
3318
  return ValidationResult_1.ValidationResult.error(consumption_1.ConsumptionErrors.requests.invalidRequestItem("Cannot query an Attribute with the own address as third party."));
3001
3319
  }
3002
- if (query.thirdParty?.equals(recipient)) {
3320
+ if (query.thirdParty.equals(recipient)) {
3003
3321
  return ValidationResult_1.ValidationResult.error(consumption_1.ConsumptionErrors.requests.invalidRequestItem("Cannot query an Attribute with the recipient's address as third party."));
3004
3322
  }
3005
- if (query.owner.equals(sender) && query.thirdParty !== undefined) {
3323
+ if (query.owner.equals(sender)) {
3006
3324
  return ValidationResult_1.ValidationResult.error(consumption_1.ConsumptionErrors.requests.invalidRequestItem("Cannot query own Attributes from a third party."));
3007
3325
  }
3008
3326
  }
@@ -3800,7 +4118,7 @@ class SettingsController extends consumption_1.ConsumptionBaseController {
3800
4118
  }
3801
4119
  async getSettings(query) {
3802
4120
  const items = await this.settings.find(query);
3803
- return await this.parseArray(items, Setting_1.Setting);
4121
+ return this.parseArray(items, Setting_1.Setting);
3804
4122
  }
3805
4123
  async createSetting(parameters) {
3806
4124
  const setting = Setting_1.Setting.from({
@@ -9028,7 +9346,8 @@ function clone$1(dur, alts, clear = false) {
9028
9346
  ...(alts.values || {})
9029
9347
  },
9030
9348
  loc: dur.loc.clone(alts.loc),
9031
- conversionAccuracy: alts.conversionAccuracy || dur.conversionAccuracy
9349
+ conversionAccuracy: alts.conversionAccuracy || dur.conversionAccuracy,
9350
+ matrix: alts.matrix || dur.matrix
9032
9351
  };
9033
9352
  return new Duration(conf);
9034
9353
  }
@@ -9067,7 +9386,7 @@ function normalizeValues(matrix, vals) {
9067
9386
  *
9068
9387
  * Here is a brief overview of commonly used methods and getters in Duration:
9069
9388
  *
9070
- * * **Creation** To create a Duration, use {@link Duration#fromMillis}, {@link Duration#fromObject}, or {@link Duration#fromISO}.
9389
+ * * **Creation** To create a Duration, use {@link Duration.fromMillis}, {@link Duration.fromObject}, or {@link Duration.fromISO}.
9071
9390
  * * **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.
9072
9391
  * * **Configuration** See {@link Duration#locale} and {@link Duration#numberingSystem} accessors.
9073
9392
  * * **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}.
@@ -9083,10 +9402,16 @@ class Duration {
9083
9402
  */
9084
9403
  constructor(config) {
9085
9404
  const accurate = config.conversionAccuracy === "longterm" || false;
9405
+ let matrix = accurate ? accurateMatrix : casualMatrix;
9406
+
9407
+ if (config.matrix) {
9408
+ matrix = config.matrix;
9409
+ }
9086
9410
  /**
9087
9411
  * @access private
9088
9412
  */
9089
9413
 
9414
+
9090
9415
  this.values = config.values;
9091
9416
  /**
9092
9417
  * @access private
@@ -9107,7 +9432,7 @@ class Duration {
9107
9432
  * @access private
9108
9433
  */
9109
9434
 
9110
- this.matrix = accurate ? accurateMatrix : casualMatrix;
9435
+ this.matrix = matrix;
9111
9436
  /**
9112
9437
  * @access private
9113
9438
  */
@@ -9146,7 +9471,8 @@ class Duration {
9146
9471
  * @param {Object} [opts=[]] - options for creating this Duration
9147
9472
  * @param {string} [opts.locale='en-US'] - the locale to use
9148
9473
  * @param {string} opts.numberingSystem - the numbering system to use
9149
- * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
9474
+ * @param {string} [opts.conversionAccuracy='casual'] - the preset conversion system to use
9475
+ * @param {string} [opts.matrix=Object] - the custom conversion system to use
9150
9476
  * @return {Duration}
9151
9477
  */
9152
9478
 
@@ -9159,7 +9485,8 @@ class Duration {
9159
9485
  return new Duration({
9160
9486
  values: normalizeObject(obj, Duration.normalizeUnit),
9161
9487
  loc: Locale.fromObject(opts),
9162
- conversionAccuracy: opts.conversionAccuracy
9488
+ conversionAccuracy: opts.conversionAccuracy,
9489
+ matrix: opts.matrix
9163
9490
  });
9164
9491
  }
9165
9492
  /**
@@ -9191,7 +9518,8 @@ class Duration {
9191
9518
  * @param {Object} opts - options for parsing
9192
9519
  * @param {string} [opts.locale='en-US'] - the locale to use
9193
9520
  * @param {string} opts.numberingSystem - the numbering system to use
9194
- * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
9521
+ * @param {string} [opts.conversionAccuracy='casual'] - the preset conversion system to use
9522
+ * @param {string} [opts.matrix=Object] - the preset conversion system to use
9195
9523
  * @see https://en.wikipedia.org/wiki/ISO_8601#Durations
9196
9524
  * @example Duration.fromISO('P3Y6M1W4DT12H30M5S').toObject() //=> { years: 3, months: 6, weeks: 1, days: 4, hours: 12, minutes: 30, seconds: 5 }
9197
9525
  * @example Duration.fromISO('PT23H').toObject() //=> { hours: 23 }
@@ -9215,7 +9543,8 @@ class Duration {
9215
9543
  * @param {Object} opts - options for parsing
9216
9544
  * @param {string} [opts.locale='en-US'] - the locale to use
9217
9545
  * @param {string} opts.numberingSystem - the numbering system to use
9218
- * @param {string} [opts.conversionAccuracy='casual'] - the conversion system to use
9546
+ * @param {string} [opts.conversionAccuracy='casual'] - the preset conversion system to use
9547
+ * @param {string} [opts.matrix=Object] - the conversion system to use
9219
9548
  * @see https://en.wikipedia.org/wiki/ISO_8601#Times
9220
9549
  * @example Duration.fromISOTime('11:22:33.444').toObject() //=> { hours: 11, minutes: 22, seconds: 33, milliseconds: 444 }
9221
9550
  * @example Duration.fromISOTime('11:00').toObject() //=> { hours: 11, minutes: 0, seconds: 0 }
@@ -9546,7 +9875,7 @@ class Duration {
9546
9875
  * Scale this Duration by the specified amount. Return a newly-constructed Duration.
9547
9876
  * @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.
9548
9877
  * @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnits(x => x * 2) //=> { hours: 2, minutes: 60 }
9549
- * @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnits((x, u) => u === "hour" ? x * 2 : x) //=> { hours: 2, minutes: 30 }
9878
+ * @example Duration.fromObject({ hours: 1, minutes: 30 }).mapUnits((x, u) => u === "hours" ? x * 2 : x) //=> { hours: 2, minutes: 30 }
9550
9879
  * @return {Duration}
9551
9880
  */
9552
9881
 
@@ -9604,20 +9933,18 @@ class Duration {
9604
9933
  reconfigure({
9605
9934
  locale,
9606
9935
  numberingSystem,
9607
- conversionAccuracy
9936
+ conversionAccuracy,
9937
+ matrix
9608
9938
  } = {}) {
9609
9939
  const loc = this.loc.clone({
9610
9940
  locale,
9611
9941
  numberingSystem
9612
- }),
9613
- opts = {
9614
- loc
9942
+ });
9943
+ const opts = {
9944
+ loc,
9945
+ matrix,
9946
+ conversionAccuracy
9615
9947
  };
9616
-
9617
- if (conversionAccuracy) {
9618
- opts.conversionAccuracy = conversionAccuracy;
9619
- }
9620
-
9621
9948
  return clone$1(this, opts);
9622
9949
  }
9623
9950
  /**
@@ -9891,10 +10218,10 @@ function validateStartEnd(start, end) {
9891
10218
  *
9892
10219
  * Here is a brief overview of the most commonly used methods and getters in Interval:
9893
10220
  *
9894
- * * **Creation** To create an Interval, use {@link Interval#fromDateTimes}, {@link Interval#after}, {@link Interval#before}, or {@link Interval#fromISO}.
10221
+ * * **Creation** To create an Interval, use {@link Interval.fromDateTimes}, {@link Interval.after}, {@link Interval.before}, or {@link Interval.fromISO}.
9895
10222
  * * **Accessors** Use {@link Interval#start} and {@link Interval#end} to get the start and end.
9896
10223
  * * **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}.
9897
- * * **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}.
10224
+ * * **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}.
9898
10225
  * * **Comparison** To compare this Interval to another one, use {@link Interval#equals}, {@link Interval#overlaps}, {@link Interval#abutsStart}, {@link Interval#abutsEnd}, {@link Interval#engulfs}
9899
10226
  * * **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}.
9900
10227
  */
@@ -11335,7 +11662,6 @@ function expandMacroTokens(tokens, locale) {
11335
11662
  * @private
11336
11663
  */
11337
11664
 
11338
-
11339
11665
  function explainFromTokens(locale, input, format) {
11340
11666
  const tokens = expandMacroTokens(Formatter.parseFormat(format), locale),
11341
11667
  units = tokens.map(t => unitForToken(t, locale)),
@@ -11931,7 +12257,7 @@ function lastOpts(argList) {
11931
12257
  *
11932
12258
  * Here is a brief overview of the most commonly used functionality it provides:
11933
12259
  *
11934
- * * **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}.
12260
+ * * **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}.
11935
12261
  * * **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},
11936
12262
  * {@link DateTime#day}, {@link DateTime#hour}, {@link DateTime#minute}, {@link DateTime#second}, {@link DateTime#millisecond} accessors.
11937
12263
  * * **Week calendar**: For ISO week calendar attributes, see the {@link DateTime#weekYear}, {@link DateTime#weekNumber}, and {@link DateTime#weekday} accessors.
@@ -12470,6 +12796,19 @@ class DateTime {
12470
12796
  static parseFormatForOpts(formatOpts, localeOpts = {}) {
12471
12797
  const tokenList = formatOptsToTokens(formatOpts, Locale.fromObject(localeOpts));
12472
12798
  return !tokenList ? null : tokenList.map(t => t ? t.val : null).join("");
12799
+ }
12800
+ /**
12801
+ * Produce the the fully expanded format token for the locale
12802
+ * Does NOT quote characters, so quoted tokens will not round trip correctly
12803
+ * @param fmt
12804
+ * @param localeOpts
12805
+ * @returns {string}
12806
+ */
12807
+
12808
+
12809
+ static expandFormat(fmt, localeOpts = {}) {
12810
+ const expanded = expandMacroTokens(Formatter.parseFormat(fmt), Locale.fromObject(localeOpts));
12811
+ return expanded.map(t => t.val).join("");
12473
12812
  } // INFO
12474
12813
 
12475
12814
  /**
@@ -13162,8 +13501,8 @@ class DateTime {
13162
13501
  * @param {Object} opts - opts to override the configuration options on this DateTime
13163
13502
  * @example DateTime.now().toLocaleString(); //=> 4/20/2017
13164
13503
  * @example DateTime.now().setLocale('en-gb').toLocaleString(); //=> '20/04/2017'
13165
- * @example DateTime.now().toLocaleString({ locale: 'en-gb' }); //=> '20/04/2017'
13166
13504
  * @example DateTime.now().toLocaleString(DateTime.DATE_FULL); //=> 'April 20, 2017'
13505
+ * @example DateTime.now().toLocaleString(DateTime.DATE_FULL, { locale: 'fr' }); //=> '28 août 2022'
13167
13506
  * @example DateTime.now().toLocaleString(DateTime.TIME_SIMPLE); //=> '11:32 AM'
13168
13507
  * @example DateTime.now().toLocaleString(DateTime.DATETIME_SHORT); //=> '4/20/2017, 11:32 AM'
13169
13508
  * @example DateTime.now().toLocaleString({ weekday: 'long', month: 'long', day: '2-digit' }); //=> 'Thursday, April 20'
@@ -13200,7 +13539,7 @@ class DateTime {
13200
13539
  * @param {boolean} [opts.suppressMilliseconds=false] - exclude milliseconds from the format if they're 0
13201
13540
  * @param {boolean} [opts.suppressSeconds=false] - exclude seconds from the format if they're 0
13202
13541
  * @param {boolean} [opts.includeOffset=true] - include the offset, such as 'Z' or '-04:00'
13203
- * @param {boolean} [opts.extendedZone=true] - add the time zone format extension
13542
+ * @param {boolean} [opts.extendedZone=false] - add the time zone format extension
13204
13543
  * @param {string} [opts.format='extended'] - choose between the basic and extended format
13205
13544
  * @example DateTime.utc(1983, 5, 25).toISO() //=> '1982-05-25T00:00:00.000Z'
13206
13545
  * @example DateTime.now().toISO() //=> '2017-04-22T20:47:05.335-04:00'
@@ -13905,7 +14244,7 @@ function friendlyDateTime(dateTimeish) {
13905
14244
  }
13906
14245
  }
13907
14246
 
13908
- const VERSION = "3.0.1";
14247
+ const VERSION = "3.0.3";
13909
14248
 
13910
14249
  exports.DateTime = DateTime;
13911
14250
  exports.Duration = Duration;