@nmshd/consumption 2.0.0-alpha.11 → 2.0.0-alpha.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (38) hide show
  1. package/dist/buildInformation.js +4 -4
  2. package/dist/consumption/ConsumptionErrors.d.ts +2 -1
  3. package/dist/consumption/ConsumptionErrors.js +5 -2
  4. package/dist/consumption/ConsumptionErrors.js.map +1 -1
  5. package/dist/modules/attributes/ConsumptionAttributesController.d.ts +14 -10
  6. package/dist/modules/attributes/ConsumptionAttributesController.js +77 -58
  7. package/dist/modules/attributes/ConsumptionAttributesController.js.map +1 -1
  8. package/dist/modules/attributes/CreateConsumptionAttributeParams.d.ts +9 -0
  9. package/dist/modules/attributes/CreateConsumptionAttributeParams.js +26 -0
  10. package/dist/modules/attributes/CreateConsumptionAttributeParams.js.map +1 -0
  11. package/dist/modules/attributes/CreatePeerConsumptionAttributeParams.d.ts +16 -0
  12. package/dist/modules/attributes/CreatePeerConsumptionAttributeParams.js +42 -0
  13. package/dist/modules/attributes/CreatePeerConsumptionAttributeParams.js.map +1 -0
  14. package/dist/modules/attributes/CreateSharedConsumptionAttributeCopyParams.d.ts +13 -0
  15. package/dist/modules/attributes/CreateSharedConsumptionAttributeCopyParams.js +36 -0
  16. package/dist/modules/attributes/CreateSharedConsumptionAttributeCopyParams.js.map +1 -0
  17. package/dist/modules/attributes/SuccedConsumptionAttributeParams.d.ts +12 -0
  18. package/dist/modules/attributes/SuccedConsumptionAttributeParams.js +32 -0
  19. package/dist/modules/attributes/SuccedConsumptionAttributeParams.js.map +1 -0
  20. package/dist/modules/attributes/UpdateConsumptionAttributeParams.d.ts +12 -0
  21. package/dist/modules/attributes/UpdateConsumptionAttributeParams.js +32 -0
  22. package/dist/modules/attributes/UpdateConsumptionAttributeParams.js.map +1 -0
  23. package/dist/modules/attributes/local/ConsumptionAttribute.d.ts +19 -10
  24. package/dist/modules/attributes/local/ConsumptionAttribute.js +20 -14
  25. package/dist/modules/attributes/local/ConsumptionAttribute.js.map +1 -1
  26. package/dist/modules/attributes/local/ConsumptionAttributeShareInfo.d.ts +17 -0
  27. package/dist/modules/attributes/local/ConsumptionAttributeShareInfo.js +36 -0
  28. package/dist/modules/attributes/local/ConsumptionAttributeShareInfo.js.map +1 -0
  29. package/dist/modules/index.d.ts +4 -0
  30. package/dist/modules/index.js +4 -0
  31. package/dist/modules/index.js.map +1 -1
  32. package/dist/modules/requests/outgoing/OutgoingRequestsController.js +13 -3
  33. package/dist/modules/requests/outgoing/OutgoingRequestsController.js.map +1 -1
  34. package/lib-web/nmshd.consumption.js +349 -85
  35. package/lib-web/nmshd.consumption.js.map +1 -1
  36. package/lib-web/nmshd.consumption.min.js +1 -1
  37. package/lib-web/nmshd.consumption.min.js.map +1 -1
  38. package/package.json +3 -3
@@ -17,10 +17,10 @@ const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
17
17
  const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
18
18
  const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
19
19
  exports.buildInformation = {
20
- version: "2.0.0-alpha.11",
21
- build: "29",
22
- date: "2022-05-12T09:29:07+00:00",
23
- commit: "688f3bbc1efcb29fc9ef8e983de9f30f62174c79",
20
+ version: "2.0.0-alpha.14",
21
+ build: "32",
22
+ date: "2022-05-18T13:56:33+00:00",
23
+ commit: "6e1e22cfd79e7f43c9143c4ae5b2db57b0f4a92b",
24
24
  dependencies: {},
25
25
  libraries: {
26
26
  transport: transport_1.buildInformation,
@@ -153,8 +153,11 @@ Object.defineProperty(exports, "__esModule", ({ value: true }));
153
153
  exports.ConsumptionErrors = void 0;
154
154
  const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
155
155
  class Attributes {
156
- attributeExists(name) {
157
- return new transport_1.CoreError("error.consumption.attributes.attributeExists", `Attribute with name ${name} already exists. Please use succeed instead.`);
156
+ attributeExists(id) {
157
+ return new transport_1.CoreError("error.consumption.attributes.attributeExists", `Attribute with id '${id}' already exists. Please use succeed instead.`);
158
+ }
159
+ predecessorNotFound(id) {
160
+ return new transport_1.CoreError("error.consumption.attributes.predecessorNotFound", `Attribute with id '${id}' does not exist. Please use create instead.`);
158
161
  }
159
162
  }
160
163
  class Requests {
@@ -283,7 +286,10 @@ exports.ConsumptionAttributesController = void 0;
283
286
  const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
284
287
  const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
285
288
  const consumption_1 = __webpack_require__(/*! ../../consumption */ "./dist/consumption/index.js");
289
+ const CreateSharedConsumptionAttributeCopyParams_1 = __webpack_require__(/*! ./CreateSharedConsumptionAttributeCopyParams */ "./dist/modules/attributes/CreateSharedConsumptionAttributeCopyParams.js");
286
290
  const ConsumptionAttribute_1 = __webpack_require__(/*! ./local/ConsumptionAttribute */ "./dist/modules/attributes/local/ConsumptionAttribute.js");
291
+ const ConsumptionAttributeShareInfo_1 = __webpack_require__(/*! ./local/ConsumptionAttributeShareInfo */ "./dist/modules/attributes/local/ConsumptionAttributeShareInfo.js");
292
+ const SuccedConsumptionAttributeParams_1 = __webpack_require__(/*! ./SuccedConsumptionAttributeParams */ "./dist/modules/attributes/SuccedConsumptionAttributeParams.js");
287
293
  class ConsumptionAttributesController extends consumption_1.ConsumptionBaseController {
288
294
  constructor(parent) {
289
295
  super(consumption_1.ConsumptionControllerName.ConsumptionAttributesController, parent);
@@ -305,13 +311,13 @@ class ConsumptionAttributesController extends consumption_1.ConsumptionBaseContr
305
311
  }
306
312
  else if (!attribute.content.validFrom &&
307
313
  attribute.content.validTo &&
308
- attribute.content.validTo.isAfter(now)) {
314
+ attribute.content.validTo.isSameOrAfter(now)) {
309
315
  return true;
310
316
  }
311
317
  else if (attribute.content.validFrom &&
312
318
  attribute.content.validTo &&
313
319
  attribute.content.validFrom.isSameOrBefore(now) &&
314
- attribute.content.validTo.isAfter(now)) {
320
+ attribute.content.validTo.isSameOrAfter(now)) {
315
321
  return true;
316
322
  }
317
323
  return false;
@@ -340,77 +346,93 @@ class ConsumptionAttributesController extends consumption_1.ConsumptionBaseContr
340
346
  }
341
347
  return items;
342
348
  }
343
- async getAttribute(id) {
344
- const result = await this.attributes.find({
349
+ async getConsumptionAttribute(id) {
350
+ const result = await this.attributes.findOne({
345
351
  [(0, ts_simple_nameof_1.nameof)((c) => c.id)]: id.toString()
346
352
  });
347
- const attributes = await this.parseArray(result, ConsumptionAttribute_1.ConsumptionAttribute);
348
- return this.findCurrent(attributes);
349
- }
350
- async getAttributeByName(name) {
351
- const result = await this.attributes.find({
352
- [`${(0, ts_simple_nameof_1.nameof)((c) => c.content)}.${(0, ts_simple_nameof_1.nameof)((a) => a.name)}`]: name
353
- });
354
- const attributes = await this.parseArray(result, ConsumptionAttribute_1.ConsumptionAttribute);
355
- return this.findCurrent(attributes);
356
- }
357
- async getAttributeHistoryByName(name) {
358
- const result = await this.attributes.find({
359
- [`${(0, ts_simple_nameof_1.nameof)((c) => c.content)}.${(0, ts_simple_nameof_1.nameof)((a) => a.name)}`]: name
360
- });
361
- const attributes = await this.parseArray(result, ConsumptionAttribute_1.ConsumptionAttribute);
362
- const sorted = attributes.sort((a, b) => {
363
- return a.createdAt.compare(b.createdAt);
364
- });
365
- return sorted;
353
+ if (!result)
354
+ return;
355
+ return ConsumptionAttribute_1.ConsumptionAttribute.from(result);
366
356
  }
367
- async getAttributes(query) {
368
- const items = await this.attributes.find(query);
369
- return await this.parseArray(items, ConsumptionAttribute_1.ConsumptionAttribute);
357
+ async getConsumptionAttributes(query) {
358
+ const attributes = await this.attributes.find(query);
359
+ return await this.parseArray(attributes, ConsumptionAttribute_1.ConsumptionAttribute);
370
360
  }
371
- async getValidAttributes(query) {
372
- const docs = await this.attributes.find(query);
373
- const items = await this.parseArray(docs, ConsumptionAttribute_1.ConsumptionAttribute);
361
+ async getValidConsumptionAttributes(query) {
362
+ const attributes = await this.attributes.find(query);
363
+ const items = await this.parseArray(attributes, ConsumptionAttribute_1.ConsumptionAttribute);
374
364
  return this.filterCurrent(items);
375
365
  }
376
- async getAttributesByName(query) {
377
- const attributes = await this.getValidAttributes(query);
378
- const mapper = (result, attribute) => {
379
- result[attribute.content.name] = attribute;
380
- return result;
381
- };
382
- return attributes.reduce(mapper, {});
366
+ async createConsumptionAttribute(params) {
367
+ const consumptionAttribute = await ConsumptionAttribute_1.ConsumptionAttribute.fromAttribute(params.content);
368
+ await this.attributes.create(consumptionAttribute);
369
+ return consumptionAttribute;
383
370
  }
384
- async createAttribute(attribute) {
385
- const current = await this.getAttributeByName(attribute.content.name);
386
- if (current) {
387
- throw consumption_1.ConsumptionErrors.attributes.attributeExists(attribute.content.name);
388
- }
389
- await this.attributes.create(attribute);
390
- return attribute;
391
- }
392
- async succeedAttribute(attribute, validFrom) {
393
- const current = await this.getAttributeByName(attribute.content.name);
394
- if (current && !validFrom) {
395
- validFrom = transport_1.CoreDate.utc();
396
- }
397
- if (current) {
398
- attribute.content.validFrom = validFrom;
399
- current.content.validTo = validFrom;
400
- await this.updateAttribute(current);
401
- }
402
- await this.attributes.create(attribute);
403
- return attribute;
371
+ async succeedConsumptionAttribute(params) {
372
+ const parsedParams = SuccedConsumptionAttributeParams_1.SucceedConsumptionAttributeParams.from(params);
373
+ const current = await this.attributes.findOne({
374
+ [(0, ts_simple_nameof_1.nameof)((c) => c.id)]: params.succeeds.toString()
375
+ });
376
+ if (!current) {
377
+ throw consumption_1.ConsumptionErrors.attributes.predecessorNotFound(parsedParams.succeeds.toString());
378
+ }
379
+ if (!parsedParams.successorContent.validFrom) {
380
+ parsedParams.successorContent.validFrom = transport_1.CoreDate.utc();
381
+ }
382
+ const validFrom = parsedParams.successorContent.validFrom;
383
+ const currentUpdated = ConsumptionAttribute_1.ConsumptionAttribute.from(current);
384
+ currentUpdated.content.validTo = validFrom.subtract(1);
385
+ await this.attributes.update(current, currentUpdated);
386
+ const successor = await ConsumptionAttribute_1.ConsumptionAttribute.fromAttribute(parsedParams.successorContent, parsedParams.succeeds);
387
+ await this.attributes.create(successor);
388
+ return successor;
389
+ }
390
+ async createSharedConsumptionAttributeCopy(params) {
391
+ const parsedParams = CreateSharedConsumptionAttributeCopyParams_1.CreateSharedConsumptionAttributeCopyParams.from(params);
392
+ const sourceAttribute = await this.getConsumptionAttribute(parsedParams.attributeId);
393
+ if (!sourceAttribute) {
394
+ throw consumption_1.ConsumptionErrors.attributes.predecessorNotFound(parsedParams.attributeId.toString());
395
+ }
396
+ const shareInfo = ConsumptionAttributeShareInfo_1.ConsumptionAttributeShareInfo.from({
397
+ peer: parsedParams.peer,
398
+ requestReference: parsedParams.requestReference,
399
+ sourceAttribute: parsedParams.attributeId
400
+ });
401
+ const sharedConsumptionAttributeCopy = await ConsumptionAttribute_1.ConsumptionAttribute.fromAttribute(sourceAttribute.content, undefined, shareInfo);
402
+ await this.attributes.create(sharedConsumptionAttributeCopy);
403
+ return sharedConsumptionAttributeCopy;
404
+ }
405
+ async createPeerConsumptionAttribute(params) {
406
+ const shareInfo = ConsumptionAttributeShareInfo_1.ConsumptionAttributeShareInfo.from({
407
+ peer: params.peer,
408
+ requestReference: params.requestReference
409
+ });
410
+ const peerConsumptionAttribute = ConsumptionAttribute_1.ConsumptionAttribute.from({
411
+ id: params.id,
412
+ content: params.content,
413
+ shareInfo: shareInfo,
414
+ createdAt: transport_1.CoreDate.utc()
415
+ });
416
+ await this.attributes.create(peerConsumptionAttribute);
417
+ return peerConsumptionAttribute;
404
418
  }
405
- async updateAttribute(attribute) {
419
+ async updateConsumptionAttribute(params) {
406
420
  const current = await this.attributes.findOne({
407
- [(0, ts_simple_nameof_1.nameof)((c) => c.id)]: attribute.id.toString()
421
+ [(0, ts_simple_nameof_1.nameof)((c) => c.id)]: params.id.toString()
408
422
  });
409
423
  if (!current) {
410
- throw transport_1.TransportErrors.general.recordNotFound(ConsumptionAttribute_1.ConsumptionAttribute, attribute.id.toString());
411
- }
412
- await this.attributes.update(current, attribute);
413
- return attribute;
424
+ throw transport_1.TransportErrors.general.recordNotFound(ConsumptionAttribute_1.ConsumptionAttribute, params.id.toString());
425
+ }
426
+ const updatedConsumptionAttribute = ConsumptionAttribute_1.ConsumptionAttribute.from({
427
+ id: current.id,
428
+ content: params.content,
429
+ createdAt: current.createdAt,
430
+ shareInfo: current.shareInfo,
431
+ succeededBy: current.succeededBy,
432
+ succeeds: current.succeeds
433
+ });
434
+ await this.attributes.update(current, updatedConsumptionAttribute);
435
+ return updatedConsumptionAttribute;
414
436
  }
415
437
  async deleteAttribute(attribute) {
416
438
  await this.attributes.delete(attribute);
@@ -421,6 +443,182 @@ exports.ConsumptionAttributesController = ConsumptionAttributesController;
421
443
 
422
444
  /***/ }),
423
445
 
446
+ /***/ "./dist/modules/attributes/CreateConsumptionAttributeParams.js":
447
+ /*!*********************************************************************!*\
448
+ !*** ./dist/modules/attributes/CreateConsumptionAttributeParams.js ***!
449
+ \*********************************************************************/
450
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
451
+
452
+ "use strict";
453
+
454
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
455
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
456
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
457
+ 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;
458
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
459
+ };
460
+ var __metadata = (this && this.__metadata) || function (k, v) {
461
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
462
+ };
463
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
464
+ exports.CreateConsumptionAttributeParams = void 0;
465
+ const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
466
+ const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
467
+ class CreateConsumptionAttributeParams extends ts_serval_1.Serializable {
468
+ static from(value) {
469
+ return this.fromAny(value);
470
+ }
471
+ }
472
+ __decorate([
473
+ (0, ts_serval_1.serialize)({ unionTypes: [content_1.IdentityAttribute, content_1.RelationshipAttribute] }),
474
+ (0, ts_serval_1.validate)(),
475
+ __metadata("design:type", Object)
476
+ ], CreateConsumptionAttributeParams.prototype, "content", void 0);
477
+ exports.CreateConsumptionAttributeParams = CreateConsumptionAttributeParams;
478
+ //# sourceMappingURL=CreateConsumptionAttributeParams.js.map
479
+
480
+ /***/ }),
481
+
482
+ /***/ "./dist/modules/attributes/CreatePeerConsumptionAttributeParams.js":
483
+ /*!*************************************************************************!*\
484
+ !*** ./dist/modules/attributes/CreatePeerConsumptionAttributeParams.js ***!
485
+ \*************************************************************************/
486
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
487
+
488
+ "use strict";
489
+
490
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
491
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
492
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
493
+ 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;
494
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
495
+ };
496
+ var __metadata = (this && this.__metadata) || function (k, v) {
497
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
498
+ };
499
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
500
+ exports.CreatePeerConsumptionAttributeParams = void 0;
501
+ const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
502
+ const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
503
+ const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
504
+ class CreatePeerConsumptionAttributeParams extends ts_serval_1.Serializable {
505
+ static from(value) {
506
+ return this.fromAny(value);
507
+ }
508
+ }
509
+ __decorate([
510
+ (0, ts_serval_1.serialize)(),
511
+ (0, ts_serval_1.validate)(),
512
+ __metadata("design:type", transport_1.CoreId)
513
+ ], CreatePeerConsumptionAttributeParams.prototype, "id", void 0);
514
+ __decorate([
515
+ (0, ts_serval_1.serialize)({ unionTypes: [content_1.IdentityAttribute, content_1.RelationshipAttribute] }),
516
+ (0, ts_serval_1.validate)(),
517
+ __metadata("design:type", Object)
518
+ ], CreatePeerConsumptionAttributeParams.prototype, "content", void 0);
519
+ __decorate([
520
+ (0, ts_serval_1.serialize)(),
521
+ (0, ts_serval_1.validate)(),
522
+ __metadata("design:type", transport_1.CoreId)
523
+ ], CreatePeerConsumptionAttributeParams.prototype, "requestReference", void 0);
524
+ __decorate([
525
+ (0, ts_serval_1.serialize)(),
526
+ (0, ts_serval_1.validate)(),
527
+ __metadata("design:type", transport_1.CoreAddress)
528
+ ], CreatePeerConsumptionAttributeParams.prototype, "peer", void 0);
529
+ exports.CreatePeerConsumptionAttributeParams = CreatePeerConsumptionAttributeParams;
530
+ //# sourceMappingURL=CreatePeerConsumptionAttributeParams.js.map
531
+
532
+ /***/ }),
533
+
534
+ /***/ "./dist/modules/attributes/CreateSharedConsumptionAttributeCopyParams.js":
535
+ /*!*******************************************************************************!*\
536
+ !*** ./dist/modules/attributes/CreateSharedConsumptionAttributeCopyParams.js ***!
537
+ \*******************************************************************************/
538
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
539
+
540
+ "use strict";
541
+
542
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
543
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
544
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
545
+ 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;
546
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
547
+ };
548
+ var __metadata = (this && this.__metadata) || function (k, v) {
549
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
550
+ };
551
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
552
+ exports.CreateSharedConsumptionAttributeCopyParams = void 0;
553
+ const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
554
+ const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
555
+ class CreateSharedConsumptionAttributeCopyParams extends ts_serval_1.Serializable {
556
+ static from(value) {
557
+ return this.fromAny(value);
558
+ }
559
+ }
560
+ __decorate([
561
+ (0, ts_serval_1.serialize)(),
562
+ (0, ts_serval_1.validate)(),
563
+ __metadata("design:type", transport_1.CoreId)
564
+ ], CreateSharedConsumptionAttributeCopyParams.prototype, "attributeId", void 0);
565
+ __decorate([
566
+ (0, ts_serval_1.serialize)(),
567
+ (0, ts_serval_1.validate)(),
568
+ __metadata("design:type", transport_1.CoreAddress)
569
+ ], CreateSharedConsumptionAttributeCopyParams.prototype, "peer", void 0);
570
+ __decorate([
571
+ (0, ts_serval_1.serialize)(),
572
+ (0, ts_serval_1.validate)(),
573
+ __metadata("design:type", transport_1.CoreId)
574
+ ], CreateSharedConsumptionAttributeCopyParams.prototype, "requestReference", void 0);
575
+ exports.CreateSharedConsumptionAttributeCopyParams = CreateSharedConsumptionAttributeCopyParams;
576
+ //# sourceMappingURL=CreateSharedConsumptionAttributeCopyParams.js.map
577
+
578
+ /***/ }),
579
+
580
+ /***/ "./dist/modules/attributes/SuccedConsumptionAttributeParams.js":
581
+ /*!*********************************************************************!*\
582
+ !*** ./dist/modules/attributes/SuccedConsumptionAttributeParams.js ***!
583
+ \*********************************************************************/
584
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
585
+
586
+ "use strict";
587
+
588
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
589
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
590
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
591
+ 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;
592
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
593
+ };
594
+ var __metadata = (this && this.__metadata) || function (k, v) {
595
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
596
+ };
597
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
598
+ exports.SucceedConsumptionAttributeParams = void 0;
599
+ const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
600
+ const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
601
+ const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
602
+ class SucceedConsumptionAttributeParams extends ts_serval_1.Serializable {
603
+ static from(value) {
604
+ return this.fromAny(value);
605
+ }
606
+ }
607
+ __decorate([
608
+ (0, ts_serval_1.serialize)({ unionTypes: [content_1.IdentityAttribute, content_1.RelationshipAttribute] }),
609
+ (0, ts_serval_1.validate)(),
610
+ __metadata("design:type", Object)
611
+ ], SucceedConsumptionAttributeParams.prototype, "successorContent", void 0);
612
+ __decorate([
613
+ (0, ts_serval_1.serialize)(),
614
+ (0, ts_serval_1.validate)(),
615
+ __metadata("design:type", transport_1.CoreId)
616
+ ], SucceedConsumptionAttributeParams.prototype, "succeeds", void 0);
617
+ exports.SucceedConsumptionAttributeParams = SucceedConsumptionAttributeParams;
618
+ //# sourceMappingURL=SuccedConsumptionAttributeParams.js.map
619
+
620
+ /***/ }),
621
+
424
622
  /***/ "./dist/modules/attributes/local/ConsumptionAttribute.js":
425
623
  /*!***************************************************************!*\
426
624
  !*** ./dist/modules/attributes/local/ConsumptionAttribute.js ***!
@@ -445,35 +643,36 @@ const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
445
643
  const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
446
644
  const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
447
645
  const consumption_1 = __webpack_require__(/*! ../../../consumption */ "./dist/consumption/index.js");
646
+ const ConsumptionAttributeShareInfo_1 = __webpack_require__(/*! ./ConsumptionAttributeShareInfo */ "./dist/modules/attributes/local/ConsumptionAttributeShareInfo.js");
448
647
  let ConsumptionAttribute = class ConsumptionAttribute extends transport_1.CoreSynchronizable {
449
648
  constructor() {
450
649
  super(...arguments);
451
650
  this.technicalProperties = [
452
651
  "@type",
453
652
  "@context",
653
+ (0, ts_simple_nameof_1.nameof)((r) => r.createdAt),
654
+ (0, ts_simple_nameof_1.nameof)((r) => r.succeeds),
454
655
  (0, ts_simple_nameof_1.nameof)((r) => r.createdAt)
455
656
  ];
456
657
  this.userdataProperties = [(0, ts_simple_nameof_1.nameof)((r) => r.content)];
457
- this.metadataProperties = [
458
- (0, ts_simple_nameof_1.nameof)((r) => r.metadata),
459
- (0, ts_simple_nameof_1.nameof)((r) => r.metadataModifiedAt)
460
- ];
461
658
  }
462
659
  static from(value) {
463
660
  return this.fromAny(value);
464
661
  }
465
- static async fromAttribute(attribute) {
662
+ static async fromAttribute(attribute, succeeds, shareInfo) {
466
663
  return this.from({
467
- content: content_1.Attribute.from(attribute),
664
+ content: attribute,
468
665
  id: await consumption_1.ConsumptionIds.attribute.generate(),
469
- createdAt: transport_1.CoreDate.utc()
666
+ createdAt: transport_1.CoreDate.utc(),
667
+ succeeds: succeeds,
668
+ shareInfo: shareInfo
470
669
  });
471
670
  }
472
671
  };
473
672
  __decorate([
474
673
  (0, ts_serval_1.validate)(),
475
- (0, ts_serval_1.serialize)({ type: content_1.Attribute }),
476
- __metadata("design:type", content_1.Attribute)
674
+ (0, ts_serval_1.serialize)({ unionTypes: [content_1.IdentityAttribute, content_1.RelationshipAttribute] }),
675
+ __metadata("design:type", Object)
477
676
  ], ConsumptionAttribute.prototype, "content", void 0);
478
677
  __decorate([
479
678
  (0, ts_serval_1.validate)(),
@@ -482,14 +681,19 @@ __decorate([
482
681
  ], ConsumptionAttribute.prototype, "createdAt", void 0);
483
682
  __decorate([
484
683
  (0, ts_serval_1.validate)({ nullable: true }),
485
- (0, ts_serval_1.serialize)({ any: true }),
486
- __metadata("design:type", Object)
487
- ], ConsumptionAttribute.prototype, "metadata", void 0);
684
+ (0, ts_serval_1.serialize)(),
685
+ __metadata("design:type", transport_1.CoreId)
686
+ ], ConsumptionAttribute.prototype, "succeeds", void 0);
488
687
  __decorate([
489
688
  (0, ts_serval_1.validate)({ nullable: true }),
490
689
  (0, ts_serval_1.serialize)(),
491
- __metadata("design:type", transport_1.CoreDate)
492
- ], ConsumptionAttribute.prototype, "metadataModifiedAt", void 0);
690
+ __metadata("design:type", transport_1.CoreId)
691
+ ], ConsumptionAttribute.prototype, "succeededBy", void 0);
692
+ __decorate([
693
+ (0, ts_serval_1.validate)({ nullable: true }),
694
+ (0, ts_serval_1.serialize)(),
695
+ __metadata("design:type", ConsumptionAttributeShareInfo_1.ConsumptionAttributeShareInfo)
696
+ ], ConsumptionAttribute.prototype, "shareInfo", void 0);
493
697
  ConsumptionAttribute = __decorate([
494
698
  (0, ts_serval_1.type)("ConsumptionAttribute")
495
699
  ], ConsumptionAttribute);
@@ -498,6 +702,52 @@ exports.ConsumptionAttribute = ConsumptionAttribute;
498
702
 
499
703
  /***/ }),
500
704
 
705
+ /***/ "./dist/modules/attributes/local/ConsumptionAttributeShareInfo.js":
706
+ /*!************************************************************************!*\
707
+ !*** ./dist/modules/attributes/local/ConsumptionAttributeShareInfo.js ***!
708
+ \************************************************************************/
709
+ /***/ (function(__unused_webpack_module, exports, __webpack_require__) {
710
+
711
+ "use strict";
712
+
713
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
714
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
715
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
716
+ 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;
717
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
718
+ };
719
+ var __metadata = (this && this.__metadata) || function (k, v) {
720
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
721
+ };
722
+ Object.defineProperty(exports, "__esModule", ({ value: true }));
723
+ exports.ConsumptionAttributeShareInfo = void 0;
724
+ const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
725
+ const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
726
+ class ConsumptionAttributeShareInfo extends transport_1.CoreSerializable {
727
+ static from(value) {
728
+ return super.fromAny(value);
729
+ }
730
+ }
731
+ __decorate([
732
+ (0, ts_serval_1.validate)(),
733
+ (0, ts_serval_1.serialize)(),
734
+ __metadata("design:type", transport_1.CoreId)
735
+ ], ConsumptionAttributeShareInfo.prototype, "requestReference", void 0);
736
+ __decorate([
737
+ (0, ts_serval_1.validate)(),
738
+ (0, ts_serval_1.serialize)(),
739
+ __metadata("design:type", transport_1.CoreAddress)
740
+ ], ConsumptionAttributeShareInfo.prototype, "peer", void 0);
741
+ __decorate([
742
+ (0, ts_serval_1.validate)({ nullable: true }),
743
+ (0, ts_serval_1.serialize)(),
744
+ __metadata("design:type", transport_1.CoreId)
745
+ ], ConsumptionAttributeShareInfo.prototype, "sourceAttribute", void 0);
746
+ exports.ConsumptionAttributeShareInfo = ConsumptionAttributeShareInfo;
747
+ //# sourceMappingURL=ConsumptionAttributeShareInfo.js.map
748
+
749
+ /***/ }),
750
+
501
751
  /***/ "./dist/modules/drafts/DraftsController.js":
502
752
  /*!*************************************************!*\
503
753
  !*** ./dist/modules/drafts/DraftsController.js ***!
@@ -659,7 +909,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
659
909
  };
660
910
  Object.defineProperty(exports, "__esModule", ({ value: true }));
661
911
  __exportStar(__webpack_require__(/*! ./attributes/ConsumptionAttributesController */ "./dist/modules/attributes/ConsumptionAttributesController.js"), exports);
912
+ __exportStar(__webpack_require__(/*! ./attributes/CreateConsumptionAttributeParams */ "./dist/modules/attributes/CreateConsumptionAttributeParams.js"), exports);
913
+ __exportStar(__webpack_require__(/*! ./attributes/CreatePeerConsumptionAttributeParams */ "./dist/modules/attributes/CreatePeerConsumptionAttributeParams.js"), exports);
914
+ __exportStar(__webpack_require__(/*! ./attributes/CreateSharedConsumptionAttributeCopyParams */ "./dist/modules/attributes/CreateSharedConsumptionAttributeCopyParams.js"), exports);
662
915
  __exportStar(__webpack_require__(/*! ./attributes/local/ConsumptionAttribute */ "./dist/modules/attributes/local/ConsumptionAttribute.js"), exports);
916
+ __exportStar(__webpack_require__(/*! ./attributes/SuccedConsumptionAttributeParams */ "./dist/modules/attributes/SuccedConsumptionAttributeParams.js"), exports);
663
917
  __exportStar(__webpack_require__(/*! ./drafts/DraftsController */ "./dist/modules/drafts/DraftsController.js"), exports);
664
918
  __exportStar(__webpack_require__(/*! ./drafts/local/Draft */ "./dist/modules/drafts/local/Draft.js"), exports);
665
919
  __exportStar(__webpack_require__(/*! ./requests/incoming/checkPrerequisites/CheckPrerequisitesOfIncomingRequestParameters */ "./dist/modules/requests/incoming/checkPrerequisites/CheckPrerequisitesOfIncomingRequestParameters.js"), exports);
@@ -1868,10 +2122,20 @@ class OutgoingRequestsController extends consumption_1.ConsumptionBaseController
1868
2122
  async createFromRelationshipCreationChange(params) {
1869
2123
  const parsedParams = CreateOutgoingRequestFromRelationshipCreationChangeParameters_1.CreateOutgoingRequestFromRelationshipCreationChangeParameters.from(params);
1870
2124
  const peer = parsedParams.creationChange.request.createdBy;
1871
- const id = parsedParams.creationChange.request.content.requestId;
1872
- await this._create(id, parsedParams.template.cache.content, peer);
2125
+ const requestBody = parsedParams.creationChange.request.content;
2126
+ if (!(requestBody instanceof content_1.RelationshipCreationChangeRequestBody)) {
2127
+ throw new Error("the body of the request is not supported as is is not type of RelationshipCreationChangeRequestBody");
2128
+ }
2129
+ const receivedResponse = requestBody.response;
2130
+ const id = receivedResponse.requestId;
2131
+ const templateContent = parsedParams.template.cache.content;
2132
+ if (!(templateContent instanceof content_1.RelationshipTemplateBody)) {
2133
+ throw new Error("the body of the template is not supported as is is not type of RelationshipTemplateBody");
2134
+ }
2135
+ // TODO: is this the correct request (=> could be RelationshipTemplateBody#existingRelationshipRequest)
2136
+ await this._create(id, templateContent.onNewRelationship, peer);
1873
2137
  await this._sent(id, parsedParams.template);
1874
- const consumptionRequest = await this._complete(id, parsedParams.creationChange, parsedParams.creationChange.request.content);
2138
+ const consumptionRequest = await this._complete(id, parsedParams.creationChange, receivedResponse);
1875
2139
  return consumptionRequest;
1876
2140
  }
1877
2141
  async sent(params) {