@nmshd/content 2.0.0-alpha.33 → 2.0.0-alpha.34

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.
@@ -5,10 +5,10 @@ const ts_serval_1 = require("@js-soft/ts-serval");
5
5
  const crypto_1 = require("@nmshd/crypto");
6
6
  const transport_1 = require("@nmshd/transport");
7
7
  exports.buildInformation = {
8
- version: "2.0.0-alpha.33",
9
- build: "63",
10
- date: "2022-06-07T13:00:13+00:00",
11
- commit: "5de28c400ead3ef3ca61ca44c7d6063044692350",
8
+ version: "2.0.0-alpha.34",
9
+ build: "64",
10
+ date: "2022-06-10T13:31:36+00:00",
11
+ commit: "9b6c65f0648fc110c4b010147ad54f59d972436d",
12
12
  dependencies: {"@js-soft/logging-abstractions":"^1.0.0"},
13
13
  libraries: {
14
14
  serval: ts_serval_1.buildInformation,
@@ -1,3 +1,4 @@
1
+ import { Serializable } from "@js-soft/ts-serval";
1
2
  import { IdentityAttribute, IdentityAttributeJSON, IdentityAttributeQuery, IdentityAttributeQueryJSON, IIdentityAttribute, IIdentityAttributeQuery, IRelationshipAttribute, IRelationshipAttributeQuery, RelationshipAttribute, RelationshipAttributeJSON, RelationshipAttributeQuery, RelationshipAttributeQueryJSON } from "../../../attributes";
2
3
  import { IRequestItem, RequestItem, RequestItemJSON } from "../../RequestItem";
3
4
  export interface ProposeAttributeRequestItemJSON extends RequestItemJSON {
@@ -12,4 +13,5 @@ export declare class ProposeAttributeRequestItem extends RequestItem implements
12
13
  query: IdentityAttributeQuery | RelationshipAttributeQuery;
13
14
  attribute: IdentityAttribute | RelationshipAttribute;
14
15
  static from(value: IProposeAttributeRequestItem): ProposeAttributeRequestItem;
16
+ protected static postFrom<T extends Serializable>(value: T): T;
15
17
  }
@@ -8,15 +8,33 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
8
8
  var __metadata = (this && this.__metadata) || function (k, v) {
9
9
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
10
  };
11
+ var ProposeAttributeRequestItem_1;
11
12
  Object.defineProperty(exports, "__esModule", { value: true });
12
13
  exports.ProposeAttributeRequestItem = void 0;
13
14
  const ts_serval_1 = require("@js-soft/ts-serval");
15
+ const ts_simple_nameof_1 = require("ts-simple-nameof");
14
16
  const attributes_1 = require("../../../attributes");
15
17
  const RequestItem_1 = require("../../RequestItem");
16
- let ProposeAttributeRequestItem = class ProposeAttributeRequestItem extends RequestItem_1.RequestItem {
18
+ let ProposeAttributeRequestItem = ProposeAttributeRequestItem_1 = class ProposeAttributeRequestItem extends RequestItem_1.RequestItem {
17
19
  static from(value) {
18
20
  return this.fromAny(value);
19
21
  }
22
+ static postFrom(value) {
23
+ if (!(value instanceof ProposeAttributeRequestItem_1))
24
+ throw new Error("this should never happen");
25
+ const attributeValueType = value.attribute.value.toJSON()["@type"];
26
+ const queryValueType = value.query.valueType;
27
+ if (attributeValueType !== queryValueType) {
28
+ throw new ts_serval_1.ValidationError(ProposeAttributeRequestItem_1.name, `${(0, ts_simple_nameof_1.nameof)((x) => x.query)}.${(0, ts_simple_nameof_1.nameof)((x) => x.valueType)}`, `You cannot propose an Attribute whose type of the value ('${attributeValueType}') is different from the value type of the query ('${queryValueType}').`);
29
+ }
30
+ if (value.attribute instanceof attributes_1.RelationshipAttribute && !(value.query instanceof attributes_1.RelationshipAttributeQuery)) {
31
+ throw new ts_serval_1.ValidationError(ProposeAttributeRequestItem_1.name, "", "When proposing a RelationshipAttribute, the corresponding query has to be a RelationshipAttributeQuery.");
32
+ }
33
+ if (value.attribute instanceof attributes_1.IdentityAttribute && !(value.query instanceof attributes_1.IdentityAttributeQuery)) {
34
+ throw new ts_serval_1.ValidationError(ProposeAttributeRequestItem_1.name, "", "When proposing an IdentityAttribute, the corresponding query has to be a IdentityAttributeQuery.");
35
+ }
36
+ return value;
37
+ }
20
38
  };
21
39
  __decorate([
22
40
  (0, ts_serval_1.serialize)({ unionTypes: [attributes_1.IdentityAttributeQuery, attributes_1.RelationshipAttributeQuery] }),
@@ -28,7 +46,7 @@ __decorate([
28
46
  (0, ts_serval_1.validate)(),
29
47
  __metadata("design:type", Object)
30
48
  ], ProposeAttributeRequestItem.prototype, "attribute", void 0);
31
- ProposeAttributeRequestItem = __decorate([
49
+ ProposeAttributeRequestItem = ProposeAttributeRequestItem_1 = __decorate([
32
50
  (0, ts_serval_1.type)("ProposeAttributeRequestItem")
33
51
  ], ProposeAttributeRequestItem);
34
52
  exports.ProposeAttributeRequestItem = ProposeAttributeRequestItem;
@@ -1 +1 @@
1
- {"version":3,"file":"ProposeAttributeRequestItem.js","sourceRoot":"","sources":["../../../../src/requests/items/proposeAttribute/ProposeAttributeRequestItem.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA8D;AAC9D,oDAa4B;AAC5B,mDAA8E;AAY9E,IAAa,2BAA2B,GAAxC,MAAa,2BAA4B,SAAQ,yBAAW;IASjD,MAAM,CAAC,IAAI,CAAC,KAAmC;QAClD,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;IAC9B,CAAC;CACJ,CAAA;AATG;IAFC,IAAA,qBAAS,EAAC,EAAE,UAAU,EAAE,CAAC,mCAAsB,EAAE,uCAA0B,CAAC,EAAE,CAAC;IAC/E,IAAA,oBAAQ,GAAE;;0DACsD;AAIjE;IAFC,IAAA,qBAAS,EAAC,EAAE,UAAU,EAAE,CAAC,8BAAiB,EAAE,kCAAqB,CAAC,EAAE,CAAC;IACrE,IAAA,oBAAQ,GAAE;;8DACgD;AAPlD,2BAA2B;IADvC,IAAA,gBAAI,EAAC,6BAA6B,CAAC;GACvB,2BAA2B,CAYvC;AAZY,kEAA2B"}
1
+ {"version":3,"file":"ProposeAttributeRequestItem.js","sourceRoot":"","sources":["../../../../src/requests/items/proposeAttribute/ProposeAttributeRequestItem.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,kDAA6F;AAC7F,uDAAyC;AACzC,oDAc4B;AAC5B,m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CAAC;CACJ,CAAA;AA5CG;IAFC,IAAA,qBAAS,EAAC,EAAE,UAAU,EAAE,CAAC,mCAAsB,EAAE,uCAA0B,CAAC,EAAE,CAAC;IAC/E,IAAA,oBAAQ,GAAE;;0DACsD;AAIjE;IAFC,IAAA,qBAAS,EAAC,EAAE,UAAU,EAAE,CAAC,8BAAiB,EAAE,kCAAqB,CAAC,EAAE,CAAC;IACrE,IAAA,oBAAQ,GAAE;;8DACgD;AAPlD,2BAA2B;IADvC,IAAA,gBAAI,EAAC,6BAA6B,CAAC;GACvB,2BAA2B,CA+CvC;AA/CY,kEAA2B"}
@@ -4929,10 +4929,10 @@ const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-s
4929
4929
  const crypto_1 = __webpack_require__(/*! @nmshd/crypto */ "@nmshd/crypto");
4930
4930
  const transport_1 = __webpack_require__(/*! @nmshd/transport */ "@nmshd/transport");
4931
4931
  exports.buildInformation = {
4932
- version: "2.0.0-alpha.33",
4933
- build: "63",
4934
- date: "2022-06-07T13:00:13+00:00",
4935
- commit: "5de28c400ead3ef3ca61ca44c7d6063044692350",
4932
+ version: "2.0.0-alpha.34",
4933
+ build: "64",
4934
+ date: "2022-06-10T13:31:36+00:00",
4935
+ commit: "9b6c65f0648fc110c4b010147ad54f59d972436d",
4936
4936
  dependencies: {"@js-soft/logging-abstractions":"^1.0.0"},
4937
4937
  libraries: {
4938
4938
  serval: ts_serval_1.buildInformation,
@@ -6025,15 +6025,33 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
6025
6025
  var __metadata = (this && this.__metadata) || function (k, v) {
6026
6026
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
6027
6027
  };
6028
+ var ProposeAttributeRequestItem_1;
6028
6029
  Object.defineProperty(exports, "__esModule", ({ value: true }));
6029
6030
  exports.ProposeAttributeRequestItem = void 0;
6030
6031
  const ts_serval_1 = __webpack_require__(/*! @js-soft/ts-serval */ "@js-soft/ts-serval");
6032
+ const ts_simple_nameof_1 = __webpack_require__(/*! ts-simple-nameof */ "./node_modules/ts-simple-nameof/index.js");
6031
6033
  const attributes_1 = __webpack_require__(/*! ../../../attributes */ "./dist/attributes/index.js");
6032
6034
  const RequestItem_1 = __webpack_require__(/*! ../../RequestItem */ "./dist/requests/RequestItem.js");
6033
- let ProposeAttributeRequestItem = class ProposeAttributeRequestItem extends RequestItem_1.RequestItem {
6035
+ let ProposeAttributeRequestItem = ProposeAttributeRequestItem_1 = class ProposeAttributeRequestItem extends RequestItem_1.RequestItem {
6034
6036
  static from(value) {
6035
6037
  return this.fromAny(value);
6036
6038
  }
6039
+ static postFrom(value) {
6040
+ if (!(value instanceof ProposeAttributeRequestItem_1))
6041
+ throw new Error("this should never happen");
6042
+ const attributeValueType = value.attribute.value.toJSON()["@type"];
6043
+ const queryValueType = value.query.valueType;
6044
+ if (attributeValueType !== queryValueType) {
6045
+ throw new ts_serval_1.ValidationError(ProposeAttributeRequestItem_1.name, `${(0, ts_simple_nameof_1.nameof)((x) => x.query)}.${(0, ts_simple_nameof_1.nameof)((x) => x.valueType)}`, `You cannot propose an Attribute whose type of the value ('${attributeValueType}') is different from the value type of the query ('${queryValueType}').`);
6046
+ }
6047
+ if (value.attribute instanceof attributes_1.RelationshipAttribute && !(value.query instanceof attributes_1.RelationshipAttributeQuery)) {
6048
+ throw new ts_serval_1.ValidationError(ProposeAttributeRequestItem_1.name, "", "When proposing a RelationshipAttribute, the corresponding query has to be a RelationshipAttributeQuery.");
6049
+ }
6050
+ if (value.attribute instanceof attributes_1.IdentityAttribute && !(value.query instanceof attributes_1.IdentityAttributeQuery)) {
6051
+ throw new ts_serval_1.ValidationError(ProposeAttributeRequestItem_1.name, "", "When proposing an IdentityAttribute, the corresponding query has to be a IdentityAttributeQuery.");
6052
+ }
6053
+ return value;
6054
+ }
6037
6055
  };
6038
6056
  __decorate([
6039
6057
  (0, ts_serval_1.serialize)({ unionTypes: [attributes_1.IdentityAttributeQuery, attributes_1.RelationshipAttributeQuery] }),
@@ -6045,7 +6063,7 @@ __decorate([
6045
6063
  (0, ts_serval_1.validate)(),
6046
6064
  __metadata("design:type", Object)
6047
6065
  ], ProposeAttributeRequestItem.prototype, "attribute", void 0);
6048
- ProposeAttributeRequestItem = __decorate([
6066
+ ProposeAttributeRequestItem = ProposeAttributeRequestItem_1 = __decorate([
6049
6067
  (0, ts_serval_1.type)("ProposeAttributeRequestItem")
6050
6068
  ], ProposeAttributeRequestItem);
6051
6069
  exports.ProposeAttributeRequestItem = ProposeAttributeRequestItem;