@carbonbox/domain 0.7.24 → 0.7.25

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.
@@ -1,79 +1,35 @@
1
1
  "use strict";
2
- var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
3
- if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
4
- if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
5
- return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
6
- };
7
- var _CalculationWorkflowAllowedExecutors_instances, _a, _CalculationWorkflowAllowedExecutors_guardAgainstInvalidStakeholderRoles;
8
2
  Object.defineProperty(exports, "__esModule", { value: true });
9
3
  exports.CalculationWorkflowAllowedExecutors = void 0;
10
- const StringList_1 = require("../../../../shared/domain/value-objects/StringList");
11
- const StakeholderRole_1 = require("../../../../shared/domain/enums/StakeholderRole");
12
- const InvalidPropertyValueError_1 = require("../../../../shared/domain/exceptions/InvalidPropertyValueError");
13
- class CalculationWorkflowAllowedExecutors extends StringList_1.StringList {
4
+ const AggregateIdList_1 = require("../../../../shared/domain/value-objects/AggregateIdList");
5
+ class CalculationWorkflowAllowedExecutors extends AggregateIdList_1.AggregateIdList {
14
6
  constructor(value, skipDomainValidation) {
15
- super(value, skipDomainValidation, _a.PROPERTY_NAME, { allowEmpty: false });
16
- _CalculationWorkflowAllowedExecutors_instances.add(this);
17
- if (skipDomainValidation === false) {
18
- __classPrivateFieldGet(this, _CalculationWorkflowAllowedExecutors_instances, "m", _CalculationWorkflowAllowedExecutors_guardAgainstInvalidStakeholderRoles).call(this, value);
19
- }
7
+ super(value, skipDomainValidation, CalculationWorkflowAllowedExecutors.PROPERTY_NAME, { allowEmpty: false });
20
8
  }
21
9
  static create(value) {
22
- StringList_1.StringList.guardAgainstInvalidStringList(value, _a.PROPERTY_NAME);
23
- return new _a(value, false);
10
+ AggregateIdList_1.AggregateIdList.guardAgainstInvalidStringList(value, CalculationWorkflowAllowedExecutors.PROPERTY_NAME);
11
+ AggregateIdList_1.AggregateIdList.guardAgainstInvalidIds(value, CalculationWorkflowAllowedExecutors.PROPERTY_NAME);
12
+ return new CalculationWorkflowAllowedExecutors(value, false);
24
13
  }
25
14
  static fromPrimitives(primitives) {
26
15
  const value = primitives.map((primitive) => primitive);
27
- return new _a(value, true);
16
+ return new CalculationWorkflowAllowedExecutors(value, true);
28
17
  }
29
- static isValidRole(role) {
30
- return _a.VALID_ROLES.includes(role);
18
+ hasExecutor(stakeholderId) {
19
+ return this.value.includes(stakeholderId);
31
20
  }
32
- toEnums() {
33
- return [...this.value];
21
+ hasAnyExecutor(stakeholderIds) {
22
+ return stakeholderIds.some((id) => this.hasExecutor(id));
34
23
  }
35
- hasRole(role) {
36
- return this.value.includes(role);
24
+ hasAllExecutors(stakeholderIds) {
25
+ return stakeholderIds.every((id) => this.hasExecutor(id));
37
26
  }
38
- hasAnyRole(roles) {
39
- return roles.some((role) => this.hasRole(role));
40
- }
41
- hasAllRoles(roles) {
42
- return roles.every((role) => this.hasRole(role));
43
- }
44
- hasCarbonHost() {
45
- return this.hasRole(StakeholderRole_1.StakeholderRole.CARBON_HOST);
46
- }
47
- hasCarbonManager() {
48
- return this.hasRole(StakeholderRole_1.StakeholderRole.CARBON_MANAGER);
49
- }
50
- hasCarbonCoordinator() {
51
- return this.hasRole(StakeholderRole_1.StakeholderRole.CARBON_COORDINATOR);
52
- }
53
- hasCarbonClient() {
54
- return this.hasRole(StakeholderRole_1.StakeholderRole.CARBON_CLIENT);
55
- }
56
- allowsManagementRoles() {
57
- return this.hasCarbonHost() || this.hasCarbonManager();
58
- }
59
- allowsOperationalRoles() {
60
- return this.hasCarbonCoordinator() || this.hasCarbonClient();
27
+ getExecutorCount() {
28
+ return this.value.length;
61
29
  }
62
30
  toPrimitives() {
63
31
  return this.value;
64
32
  }
65
33
  }
66
34
  exports.CalculationWorkflowAllowedExecutors = CalculationWorkflowAllowedExecutors;
67
- _a = CalculationWorkflowAllowedExecutors, _CalculationWorkflowAllowedExecutors_instances = new WeakSet(), _CalculationWorkflowAllowedExecutors_guardAgainstInvalidStakeholderRoles = function _CalculationWorkflowAllowedExecutors_guardAgainstInvalidStakeholderRoles(value) {
68
- const invalidRoles = [];
69
- value.forEach((role, index) => {
70
- if (!_a.VALID_ROLES.includes(role)) {
71
- invalidRoles.push(`[${index}]: ${role}`);
72
- }
73
- });
74
- if (invalidRoles.length > 0) {
75
- throw InvalidPropertyValueError_1.InvalidPropertyValueError.create(_a.PROPERTY_NAME, `valid StakeholderRole enum values (${_a.VALID_ROLES.join(', ')})`, invalidRoles.join(', '));
76
- }
77
- };
78
35
  CalculationWorkflowAllowedExecutors.PROPERTY_NAME = 'allowedExecutors';
79
- CalculationWorkflowAllowedExecutors.VALID_ROLES = Object.values(StakeholderRole_1.StakeholderRole);
@@ -1,23 +1,13 @@
1
- import { StringList } from '../../../../shared/domain/value-objects/StringList';
2
- import { StakeholderRole } from '../../../../shared/domain/enums/StakeholderRole';
3
- export declare class CalculationWorkflowAllowedExecutors extends StringList {
4
- #private;
1
+ import { AggregateIdList } from '../../../../shared/domain/value-objects/AggregateIdList';
2
+ export declare class CalculationWorkflowAllowedExecutors extends AggregateIdList {
5
3
  private static readonly PROPERTY_NAME;
6
- private static readonly VALID_ROLES;
7
4
  private constructor();
8
5
  static create(value: string[]): CalculationWorkflowAllowedExecutors;
9
6
  static fromPrimitives(primitives: string[]): CalculationWorkflowAllowedExecutors;
10
- static isValidRole(role: string): boolean;
11
- toEnums(): StakeholderRole[];
12
- hasRole(role: StakeholderRole): boolean;
13
- hasAnyRole(roles: StakeholderRole[]): boolean;
14
- hasAllRoles(roles: StakeholderRole[]): boolean;
15
- hasCarbonHost(): boolean;
16
- hasCarbonManager(): boolean;
17
- hasCarbonCoordinator(): boolean;
18
- hasCarbonClient(): boolean;
19
- allowsManagementRoles(): boolean;
20
- allowsOperationalRoles(): boolean;
7
+ hasExecutor(stakeholderId: string): boolean;
8
+ hasAnyExecutor(stakeholderIds: string[]): boolean;
9
+ hasAllExecutors(stakeholderIds: string[]): boolean;
10
+ getExecutorCount(): number;
21
11
  toPrimitives(): string[];
22
12
  }
23
13
  //# sourceMappingURL=CalculationWorkflowAllowedExecutors.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"CalculationWorkflowAllowedExecutors.d.ts","sourceRoot":"","sources":["../../../../../../../src/carbonbox/emission-calculation-process/calculation-workflows/domain/value-objects/CalculationWorkflowAllowedExecutors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,oDAAoD,CAAC;AAChF,OAAO,EAAE,eAAe,EAAE,MAAM,iDAAiD,CAAC;AAGlF,qBAAa,mCACX,SAAQ,UAAU;;IAClB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAsB;IAE3D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAkC;IAErE,OAAO;WAagB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,mCAAmC;WAM5D,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,mCAAmC;WAwBlF,WAAW,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO;IAIzC,OAAO,IAAI,eAAe,EAAE;IAI5B,OAAO,CAAC,IAAI,EAAE,eAAe,GAAG,OAAO;IAIvC,UAAU,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,OAAO;IAI7C,WAAW,CAAC,KAAK,EAAE,eAAe,EAAE,GAAG,OAAO;IAI9C,aAAa,IAAI,OAAO;IAIxB,gBAAgB,IAAI,OAAO;IAI3B,oBAAoB,IAAI,OAAO;IAI/B,eAAe,IAAI,OAAO;IAI1B,qBAAqB,IAAI,OAAO;IAIhC,sBAAsB,IAAI,OAAO;IAIxB,YAAY,IAAI,MAAM,EAAE;CAGzC"}
1
+ {"version":3,"file":"CalculationWorkflowAllowedExecutors.d.ts","sourceRoot":"","sources":["../../../../../../../src/carbonbox/emission-calculation-process/calculation-workflows/domain/value-objects/CalculationWorkflowAllowedExecutors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,yDAAyD,CAAC;AAE1F,qBAAa,mCACX,SAAQ,eAAe;IACvB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAsB;IAE3D,OAAO;WASgB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,mCAAmC;WAO5D,cAAc,CAAC,UAAU,EAAE,MAAM,EAAE,GAAG,mCAAmC;IAMzF,WAAW,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO;IAI3C,cAAc,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,OAAO;IAIjD,eAAe,CAAC,cAAc,EAAE,MAAM,EAAE,GAAG,OAAO;IAIlD,gBAAgB,IAAI,MAAM;IAIjB,YAAY,IAAI,MAAM,EAAE;CAGzC"}
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "browser": false
4
4
  },
5
5
  "name": "@carbonbox/domain",
6
- "version": "0.7.24",
6
+ "version": "0.7.25",
7
7
  "description": "Domain package for CarbonBox Project",
8
8
  "main": "build/main/index.js",
9
9
  "types": "build/types/main/index.d.ts",