@nmshd/consumption 3.9.4 → 3.9.5

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.
@@ -28293,10 +28293,10 @@ const content_1 = __webpack_require__(/*! @nmshd/content */ "@nmshd/content");
28293
28293
  const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
28294
28294
  const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
28295
28295
  exports.buildInformation = {
28296
- version: "3.9.4",
28297
- build: "30",
28298
- date: "2024-02-23T11:56:17+00:00",
28299
- commit: "f595da4c58bfeccdfa4911aa46532be9b0898a44",
28296
+ version: "3.9.5",
28297
+ build: "32",
28298
+ date: "2024-02-28T10:30:30+00:00",
28299
+ commit: "13d2b9e8adee7914ff4bd293fa2a353bbf5b7768",
28300
28300
  dependencies: {"@js-soft/docdb-querytranslator":"^1.1.2","@nmshd/iql":"^1.0.2","ts-simple-nameof":"^1.3.1"},
28301
28301
  libraries: {
28302
28302
  transport: transport_1.buildInformation,
@@ -28504,8 +28504,8 @@ exports.CoreErrors = void 0;
28504
28504
  const ts_utils_1 = __webpack_require__(/*! @js-soft/ts-utils */ "../../node_modules/@js-soft/ts-utils/dist/index.js");
28505
28505
  const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
28506
28506
  class Attributes {
28507
- genericValidationError(error) {
28508
- return new transport_1.CoreError("error.consumption.attributes.genericValidationError", "Validation failed during creation of object.", error, undefined, error instanceof Error ? error : undefined);
28507
+ successorIsNotAValidAttribute(error) {
28508
+ return new transport_1.CoreError("error.consumption.attributes.successorIsNotAValidAttribute", "Validation failed during creation of successor.", error, undefined, error instanceof Error ? error : undefined);
28509
28509
  }
28510
28510
  successionMustNotChangeKey() {
28511
28511
  return new transport_1.CoreError("error.consumption.attributes.successionMustNotChangeKey", "The predecessor attribute's key does not match that of the successor. The succession of a relationship attribute must not change the key.");
@@ -28513,11 +28513,17 @@ class Attributes {
28513
28513
  successionPeerIsNotOwner() {
28514
28514
  return new transport_1.CoreError("error.consumption.attributes.successionPeerIsNotOwner", "The peer of the succeeded attribute is not its owner. This may be an attempt of spoofing.");
28515
28515
  }
28516
- invalidSuccessionOfOwnSharedIdentityAttribute(comment) {
28517
- let errorMessage = "Invalid succession of own shared identity attribute.";
28518
- if (comment)
28519
- errorMessage += ` ${comment}`;
28520
- return new transport_1.CoreError("error.consumption.attributes.invalidSuccessionOfOwnSharedIdentityAttribute", errorMessage);
28516
+ predecessorSourceAttributeIsNotRepositoryAttribute() {
28517
+ return new transport_1.CoreError("error.consumption.attributes.predecessorSourceAttributeIsNotRepositoryAttribute", "Predecessor source attribute is not a repository attribute.");
28518
+ }
28519
+ successorSourceAttributeIsNotRepositoryAttribute() {
28520
+ return new transport_1.CoreError("error.consumption.attributes.successorSourceAttributeIsNotRepositoryAttribute", "Successor source attribute is not a repository attribute.");
28521
+ }
28522
+ successorSourceDoesNotSucceedPredecessorSource() {
28523
+ return new transport_1.CoreError("error.consumption.attributes.successorSourceDoesNotSucceedPredecessorSource", "Predecessor source attribute is not succeeded by successor source attribute.");
28524
+ }
28525
+ sourceContentIsNotEqualToCopyContent() {
28526
+ return new transport_1.CoreError("error.consumption.attributes.sourceContentIsNotEqualToCopyContent", "Successor source attribute contents don't match successor shared attribute copy.");
28521
28527
  }
28522
28528
  cannotSucceedChildOfComplexAttribute(parentId) {
28523
28529
  return new transport_1.CoreError("error.consumption.attributes.cannotSucceedChildOfComplexAttribute", `The attribute you want to succeed is child attribute of a complex attribute (id: ${parentId}), and cannot be succeeded on its own. Instead, succeed the parent which will implicitly succeed all its children.`);
@@ -28531,17 +28537,38 @@ class Attributes {
28531
28537
  errorMessage += ` ${comment}`;
28532
28538
  return new transport_1.CoreError("error.consumption.attributes.successorMustNotHaveASuccessor", errorMessage);
28533
28539
  }
28534
- invalidPredecessor(comment) {
28535
- let errorMessage = "Invalid predecessor.";
28536
- if (comment)
28537
- errorMessage += ` ${comment}`;
28538
- return new transport_1.CoreError("error.consumption.attributes.invalidPredecessor", errorMessage);
28540
+ predecessorIsNotRepositoryAttribute() {
28541
+ return new transport_1.CoreError("error.consumption.attributes.predecessorIsNotRepositoryAttribute", "Predecessor is not a repository attribute.");
28539
28542
  }
28540
- invalidSuccessor(comment) {
28541
- let errorMessage = "Invalid successor.";
28542
- if (comment)
28543
- errorMessage += ` ${comment}`;
28544
- return new transport_1.CoreError("error.consumption.attributes.invalidSuccessor", errorMessage);
28543
+ predecessorIsNotOwnSharedIdentityAttribute() {
28544
+ return new transport_1.CoreError("error.consumption.attributes.predecessorIsNotOwnSharedIdentityAttribute", "Predecessor is not an own shared identity attribute.");
28545
+ }
28546
+ predecessorIsNotPeerSharedIdentityAttribute() {
28547
+ return new transport_1.CoreError("error.consumption.attributes.predecessorIsNotPeerSharedIdentityAttribute", "Predecessor is not a peer shared identity attribute.");
28548
+ }
28549
+ predecessorIsNotOwnSharedRelationshipAttribute() {
28550
+ return new transport_1.CoreError("error.consumption.attributes.predecessorIsNotOwnSharedRelationshipAttribute", "Predecessor is not an own shared relationship attribute.");
28551
+ }
28552
+ predecessorIsNotPeerSharedRelationshipAttribute() {
28553
+ return new transport_1.CoreError("error.consumption.attributes.predecessorIsNotPeerSharedRelationshipAttribute", "Predecessor is not a peer shared relationship attribute.");
28554
+ }
28555
+ successorIsNotRepositoryAttribute() {
28556
+ return new transport_1.CoreError("error.consumption.attributes.successorIsNotRepositoryAttribute", "Successor is not a repository attribute.");
28557
+ }
28558
+ successorIsNotOwnSharedIdentityAttribute() {
28559
+ return new transport_1.CoreError("error.consumption.attributes.successorIsNotOwnSharedIdentityAttribute", "Successor is not an own shared identity attribute.");
28560
+ }
28561
+ successorIsNotPeerSharedIdentityAttribute() {
28562
+ return new transport_1.CoreError("error.consumption.attributes.successorIsNotPeerSharedIdentityAttribute", "Successor is not a peer shared identity attribute.");
28563
+ }
28564
+ successorIsNotOwnSharedRelationshipAttribute() {
28565
+ return new transport_1.CoreError("error.consumption.attributes.successorIsNotOwnSharedRelationshipAttribute", "Successor is not an own shared relationship attribute.");
28566
+ }
28567
+ successorIsNotPeerSharedRelationshipAttribute() {
28568
+ return new transport_1.CoreError("error.consumption.attributes.successorIsNotPeerSharedRelationshipAttribute", "Successor is not a peer shared relationship attribute.");
28569
+ }
28570
+ setPredecessorIdDoesNotMatchActualPredecessorId() {
28571
+ return new transport_1.CoreError("error.consumption.attributes.setPredecessorIdDoesNotMatchActualPredecessorId", "The predecessor's id and the explicitly set value for the successor's succeeds field don't match.");
28545
28572
  }
28546
28573
  predecessorDoesNotExist() {
28547
28574
  return new transport_1.CoreError("error.consumption.attributes.predecessorDoesNotExist", "The predecessor does not exist.");
@@ -29314,7 +29341,7 @@ class AttributesController extends ConsumptionBaseController_1.ConsumptionBaseCo
29314
29341
  parsedSuccessorParams = AttributeSuccessorParams_1.AttributeSuccessorParams.from(successorParams);
29315
29342
  }
29316
29343
  catch (e) {
29317
- return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.genericValidationError(e));
29344
+ return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successorIsNotAValidAttribute(e));
29318
29345
  }
29319
29346
  const commonValidation = await this.validateAttributeSuccessionCommon(predecessorId, parsedSuccessorParams);
29320
29347
  if (commonValidation.isError())
@@ -29330,10 +29357,10 @@ class AttributesController extends ConsumptionBaseController_1.ConsumptionBaseCo
29330
29357
  parentId: parsedSuccessorParams.parentId
29331
29358
  });
29332
29359
  if (!predecessor.isRepositoryAttribute(this.identity.address)) {
29333
- return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidPredecessor("Predecessor is not a valid repository attribute."));
29360
+ return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.predecessorIsNotRepositoryAttribute());
29334
29361
  }
29335
29362
  if (!successor.isRepositoryAttribute(this.identity.address)) {
29336
- return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidSuccessor("Successor is not a valid repository attribute."));
29363
+ return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successorIsNotRepositoryAttribute());
29337
29364
  }
29338
29365
  return common_1.ValidationResult.success();
29339
29366
  }
@@ -29343,7 +29370,7 @@ class AttributesController extends ConsumptionBaseController_1.ConsumptionBaseCo
29343
29370
  parsedSuccessorParams = AttributeSuccessorParams_1.AttributeSuccessorParams.from(successorParams);
29344
29371
  }
29345
29372
  catch (e) {
29346
- return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.genericValidationError(e));
29373
+ return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successorIsNotAValidAttribute(e));
29347
29374
  }
29348
29375
  const commonValidation = await this.validateAttributeSuccessionCommon(predecessorId, parsedSuccessorParams);
29349
29376
  if (commonValidation.isError())
@@ -29359,10 +29386,10 @@ class AttributesController extends ConsumptionBaseController_1.ConsumptionBaseCo
29359
29386
  parentId: parsedSuccessorParams.parentId
29360
29387
  });
29361
29388
  if (!predecessor.isOwnSharedIdentityAttribute(this.identity.address)) {
29362
- return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidPredecessor("Predecessor is not a valid own shared identity attribute."));
29389
+ return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.predecessorIsNotOwnSharedIdentityAttribute());
29363
29390
  }
29364
29391
  if (!successor.isOwnSharedIdentityAttribute(this.identity.address)) {
29365
- return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidSuccessor("Successor is not a valid peer shared identity attribute."));
29392
+ return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successorIsNotOwnSharedIdentityAttribute());
29366
29393
  }
29367
29394
  if (!predecessor.shareInfo.peer.equals(successor.shareInfo.peer)) {
29368
29395
  return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successionMustNotChangePeer());
@@ -29374,20 +29401,20 @@ class AttributesController extends ConsumptionBaseController_1.ConsumptionBaseCo
29374
29401
  const predecessorSourceVersionIds = (await this.getVersionsOfAttribute(predecessor.shareInfo.sourceAttribute)).map((x) => x.id.toString());
29375
29402
  const successorSourceVersionIds = (await this.getVersionsOfAttribute(successor.shareInfo.sourceAttribute)).map((x) => x.id.toString());
29376
29403
  if (typeof predecessorSource === "undefined" || !predecessorSource.isRepositoryAttribute(this.identity.address)) {
29377
- return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidSuccessionOfOwnSharedIdentityAttribute());
29404
+ return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.predecessorSourceAttributeIsNotRepositoryAttribute());
29378
29405
  }
29379
29406
  if (typeof successorSource === "undefined" || !successorSource.isRepositoryAttribute(this.identity.address)) {
29380
- return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidSuccessionOfOwnSharedIdentityAttribute("Source attribute is not a valid repository attribute."));
29407
+ return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successorSourceAttributeIsNotRepositoryAttribute());
29381
29408
  }
29382
29409
  if (typeof successorSource.succeeds === "undefined" ||
29383
29410
  !predecessorSourceVersionIds.some((id) => id === successorSource.succeeds?.toString()) ||
29384
29411
  typeof predecessorSource.succeededBy === "undefined" ||
29385
29412
  !successorSourceVersionIds.some((id) => id === predecessorSource.succeededBy?.toString())) {
29386
- return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidSuccessionOfOwnSharedIdentityAttribute("Predecessor source attribute is not succeeded by successor source attribute."));
29413
+ return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successorSourceDoesNotSucceedPredecessorSource());
29387
29414
  }
29388
29415
  const repositoryAttributeContentMatchesItsSharedAttribute = lodash_1.default.isEqual(predecessorSource.content, predecessor.content) && lodash_1.default.isEqual(successorSource.content, successor.content);
29389
29416
  if (!repositoryAttributeContentMatchesItsSharedAttribute) {
29390
- return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidSuccessionOfOwnSharedIdentityAttribute("Successor source attribute contents don't match successor shared attribute copy."));
29417
+ return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.sourceContentIsNotEqualToCopyContent());
29391
29418
  }
29392
29419
  return common_1.ValidationResult.success();
29393
29420
  }
@@ -29397,7 +29424,7 @@ class AttributesController extends ConsumptionBaseController_1.ConsumptionBaseCo
29397
29424
  parsedSuccessorParams = AttributeSuccessorParams_1.AttributeSuccessorParams.from(successorParams);
29398
29425
  }
29399
29426
  catch (e) {
29400
- return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.genericValidationError(e));
29427
+ return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successorIsNotAValidAttribute(e));
29401
29428
  }
29402
29429
  const commonValidation = await this.validateAttributeSuccessionCommon(predecessorId, parsedSuccessorParams);
29403
29430
  if (commonValidation.isError())
@@ -29413,10 +29440,10 @@ class AttributesController extends ConsumptionBaseController_1.ConsumptionBaseCo
29413
29440
  parentId: parsedSuccessorParams.parentId
29414
29441
  });
29415
29442
  if (!predecessor.isOwnSharedRelationshipAttribute(this.identity.address)) {
29416
- return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidPredecessor("Predecessor is not a valid own shared relationship attribute."));
29443
+ return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.predecessorIsNotOwnSharedRelationshipAttribute());
29417
29444
  }
29418
29445
  if (!successor.isOwnSharedRelationshipAttribute(this.identity.address)) {
29419
- return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidSuccessor("Successor is not a valid own shared relationship attribute."));
29446
+ return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successorIsNotOwnSharedRelationshipAttribute());
29420
29447
  }
29421
29448
  if (successor.content.key !== predecessor.content.key) {
29422
29449
  return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successionMustNotChangeKey());
@@ -29432,7 +29459,7 @@ class AttributesController extends ConsumptionBaseController_1.ConsumptionBaseCo
29432
29459
  parsedSuccessorParams = AttributeSuccessorParams_1.AttributeSuccessorParams.from(successorParams);
29433
29460
  }
29434
29461
  catch (e) {
29435
- return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.genericValidationError(e));
29462
+ return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successorIsNotAValidAttribute(e));
29436
29463
  }
29437
29464
  const commonValidation = await this.validateAttributeSuccessionCommon(predecessorId, parsedSuccessorParams);
29438
29465
  if (commonValidation.isError())
@@ -29448,10 +29475,10 @@ class AttributesController extends ConsumptionBaseController_1.ConsumptionBaseCo
29448
29475
  parentId: parsedSuccessorParams.parentId
29449
29476
  });
29450
29477
  if (!predecessor.isPeerSharedIdentityAttribute()) {
29451
- return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidPredecessor("Predecessor is not a valid peer shared identity attribute."));
29478
+ return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.predecessorIsNotPeerSharedIdentityAttribute());
29452
29479
  }
29453
29480
  if (!successor.isPeerSharedIdentityAttribute()) {
29454
- return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidSuccessor("Successor is not a valid peer shared identity attribute."));
29481
+ return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successorIsNotPeerSharedIdentityAttribute());
29455
29482
  }
29456
29483
  if (!predecessor.shareInfo.peer.equals(successor.shareInfo.peer)) {
29457
29484
  return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successionMustNotChangePeer());
@@ -29464,7 +29491,7 @@ class AttributesController extends ConsumptionBaseController_1.ConsumptionBaseCo
29464
29491
  parsedSuccessorParams = AttributeSuccessorParams_1.AttributeSuccessorParams.from(successorParams);
29465
29492
  }
29466
29493
  catch (e) {
29467
- return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.genericValidationError(e));
29494
+ return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successorIsNotAValidAttribute(e));
29468
29495
  }
29469
29496
  const commonValidation = await this.validateAttributeSuccessionCommon(predecessorId, parsedSuccessorParams);
29470
29497
  if (commonValidation.isError())
@@ -29480,10 +29507,10 @@ class AttributesController extends ConsumptionBaseController_1.ConsumptionBaseCo
29480
29507
  parentId: parsedSuccessorParams.parentId
29481
29508
  });
29482
29509
  if (!predecessor.isPeerSharedRelationshipAttribute()) {
29483
- return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidPredecessor("Predecessor is not a valid peer shared relationship attribute."));
29510
+ return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.predecessorIsNotPeerSharedRelationshipAttribute());
29484
29511
  }
29485
29512
  if (!successor.isPeerSharedRelationshipAttribute()) {
29486
- return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidSuccessor("Successor is not a valid peer shared relationship attribute."));
29513
+ return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successorIsNotPeerSharedRelationshipAttribute());
29487
29514
  }
29488
29515
  if (successor.content.key !== predecessor.content.key) {
29489
29516
  return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successionMustNotChangeKey());
@@ -29499,7 +29526,7 @@ class AttributesController extends ConsumptionBaseController_1.ConsumptionBaseCo
29499
29526
  parsedSuccessorParams = AttributeSuccessorParams_1.AttributeSuccessorParams.from(successorParams);
29500
29527
  }
29501
29528
  catch (e) {
29502
- return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.genericValidationError(e));
29529
+ return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successorIsNotAValidAttribute(e));
29503
29530
  }
29504
29531
  const successor = LocalAttribute_1.LocalAttribute.from({
29505
29532
  id: transport_1.CoreId.from(parsedSuccessorParams.id ?? "dummy"),
@@ -29517,7 +29544,7 @@ class AttributesController extends ConsumptionBaseController_1.ConsumptionBaseCo
29517
29544
  }
29518
29545
  }
29519
29546
  if (typeof successor.succeeds !== "undefined" && !predecessorId.equals(successor.succeeds.toString())) {
29520
- return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.invalidPredecessor("The predecessor's id and the explicitly set value for the successor's succeeds field don't match."));
29547
+ return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.setPredecessorIdDoesNotMatchActualPredecessorId());
29521
29548
  }
29522
29549
  if (typeof successor.succeededBy !== "undefined") {
29523
29550
  return common_1.ValidationResult.error(CoreErrors_1.CoreErrors.attributes.successorMustNotHaveASuccessor());
@@ -34091,7 +34118,7 @@ exports.validate = validate;
34091
34118
  /***/ ((module) => {
34092
34119
 
34093
34120
  "use strict";
34094
- // @generated by Peggy 4.0.0.
34121
+ // @generated by Peggy 4.0.2.
34095
34122
  //
34096
34123
  // https://peggyjs.org/
34097
34124