@carbonbox/domain 0.7.24 → 0.7.26
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.
- package/build/carbonbox/emission-calculation-process/calculation-workflows/domain/value-objects/CalculationWorkflowAllowedExecutors.js +15 -59
- package/build/carbonbox/emission-calculation-process/calculation-workflows/domain/value-objects/CalculationWorkflowFailedExecutions.js +1 -1
- package/build/carbonbox/emission-calculation-process/calculation-workflows/domain/value-objects/CalculationWorkflowSuccessfulExecutions.js +1 -1
- package/build/carbonbox/emission-calculation-process/calculation-workflows/domain/value-objects/CalculationWorkflowTotalExecutions.js +1 -1
- package/build/types/carbonbox/emission-calculation-process/calculation-workflows/domain/value-objects/CalculationWorkflowAllowedExecutors.d.ts +6 -16
- package/build/types/carbonbox/emission-calculation-process/calculation-workflows/domain/value-objects/CalculationWorkflowAllowedExecutors.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
11
|
-
|
|
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,
|
|
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
|
-
|
|
23
|
-
|
|
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
|
|
16
|
+
return new CalculationWorkflowAllowedExecutors(value, true);
|
|
28
17
|
}
|
|
29
|
-
|
|
30
|
-
return
|
|
18
|
+
hasExecutor(stakeholderId) {
|
|
19
|
+
return this.value.includes(stakeholderId);
|
|
31
20
|
}
|
|
32
|
-
|
|
33
|
-
return
|
|
21
|
+
hasAnyExecutor(stakeholderIds) {
|
|
22
|
+
return stakeholderIds.some((id) => this.hasExecutor(id));
|
|
34
23
|
}
|
|
35
|
-
|
|
36
|
-
return this.
|
|
24
|
+
hasAllExecutors(stakeholderIds) {
|
|
25
|
+
return stakeholderIds.every((id) => this.hasExecutor(id));
|
|
37
26
|
}
|
|
38
|
-
|
|
39
|
-
return
|
|
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);
|
|
@@ -9,7 +9,7 @@ class CalculationWorkflowFailedExecutions extends PositiveInteger_1.PositiveInte
|
|
|
9
9
|
static create(value) {
|
|
10
10
|
PositiveInteger_1.PositiveInteger.guardAgainstInvalidType(value, CalculationWorkflowFailedExecutions.PROPERTY_NAME);
|
|
11
11
|
PositiveInteger_1.PositiveInteger.guardAgainstNegativeValue(value, CalculationWorkflowFailedExecutions.PROPERTY_NAME);
|
|
12
|
-
|
|
12
|
+
// Allow zero value for new workflows that haven't been executed yet
|
|
13
13
|
return new CalculationWorkflowFailedExecutions(value, false);
|
|
14
14
|
}
|
|
15
15
|
static fromPrimitives(primitive) {
|
|
@@ -9,7 +9,7 @@ class CalculationWorkflowSuccessfulExecutions extends PositiveInteger_1.Positive
|
|
|
9
9
|
static create(value) {
|
|
10
10
|
PositiveInteger_1.PositiveInteger.guardAgainstInvalidType(value, CalculationWorkflowSuccessfulExecutions.PROPERTY_NAME);
|
|
11
11
|
PositiveInteger_1.PositiveInteger.guardAgainstNegativeValue(value, CalculationWorkflowSuccessfulExecutions.PROPERTY_NAME);
|
|
12
|
-
|
|
12
|
+
// Allow zero value for new workflows that haven't been executed yet
|
|
13
13
|
return new CalculationWorkflowSuccessfulExecutions(value, false);
|
|
14
14
|
}
|
|
15
15
|
static fromPrimitives(primitive) {
|
|
@@ -9,7 +9,7 @@ class CalculationWorkflowTotalExecutions extends PositiveInteger_1.PositiveInteg
|
|
|
9
9
|
static create(value) {
|
|
10
10
|
PositiveInteger_1.PositiveInteger.guardAgainstInvalidType(value, CalculationWorkflowTotalExecutions.PROPERTY_NAME);
|
|
11
11
|
PositiveInteger_1.PositiveInteger.guardAgainstNegativeValue(value, CalculationWorkflowTotalExecutions.PROPERTY_NAME);
|
|
12
|
-
|
|
12
|
+
// Allow zero value for new workflows that haven't been executed yet
|
|
13
13
|
return new CalculationWorkflowTotalExecutions(value, false);
|
|
14
14
|
}
|
|
15
15
|
static fromPrimitives(primitive) {
|
|
@@ -1,23 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
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
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
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,
|
|
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"}
|