@carbonbox/domain 0.40.0 → 0.42.0
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/carbon-footprint-configurations/corporate-configurations/domain/entity/CorporateCarbonFootprintConfiguration.js +11 -2
- package/build/carbonbox/carbon-footprint-configurations/corporate-configurations/domain/value-objects/CorporateCarbonFootprintConfigurationBaseYear.js +32 -0
- package/build/carbonbox/emission-calculation-results/emission-aggregations/domain/value-objects/EmissionAggregationUncertaintyPercentage.js +4 -2
- package/build/carbonbox/emission-calculation-results/shared/domain/enums/UncertaintyLevel.js +17 -0
- package/build/carbonbox/emission-calculation-results/shared/domain/services/contracts/IUncertaintyPropagationDomainService.js +2 -0
- package/build/carbonbox/emission-calculation-results/shared/domain/services/implementations/UncertaintyPropagationDomainService.js +55 -0
- package/build/carbonbox/emission-calculation-results/shared/domain/types/UncertaintyBounds.js +2 -0
- package/build/carbonbox/emission-calculation-results/shared/domain/types/UncertaintyWeightedContribution.js +2 -0
- package/build/carbonbox/reporting/shared/domain/enums/DataBindingSource.js +17 -0
- package/build/carbonbox/shared/domain/types/BaseYear.js +2 -0
- package/build/carbonbox/shared/domain/types/BaseYearPrimitives.js +2 -0
- package/build/carbonbox/shared/domain/value-objects/BaseYear.js +156 -0
- package/build/main/index.js +26 -18
- package/build/types/carbonbox/carbon-footprint-configurations/corporate-configurations/domain/entity/CorporateCarbonFootprintConfiguration.d.ts +2 -0
- package/build/types/carbonbox/carbon-footprint-configurations/corporate-configurations/domain/entity/CorporateCarbonFootprintConfiguration.d.ts.map +1 -1
- package/build/types/carbonbox/carbon-footprint-configurations/corporate-configurations/domain/entity/ICorporateCarbonFootprintConfiguration.d.ts +2 -0
- package/build/types/carbonbox/carbon-footprint-configurations/corporate-configurations/domain/entity/ICorporateCarbonFootprintConfiguration.d.ts.map +1 -1
- package/build/types/carbonbox/carbon-footprint-configurations/corporate-configurations/domain/types/CorporateCarbonFootprintConfigurationPrimitives.d.ts +2 -0
- package/build/types/carbonbox/carbon-footprint-configurations/corporate-configurations/domain/types/CorporateCarbonFootprintConfigurationPrimitives.d.ts.map +1 -1
- package/build/types/carbonbox/carbon-footprint-configurations/corporate-configurations/domain/types/CorporateCarbonFootprintConfigurationProps.d.ts +2 -0
- package/build/types/carbonbox/carbon-footprint-configurations/corporate-configurations/domain/types/CorporateCarbonFootprintConfigurationProps.d.ts.map +1 -1
- package/build/types/carbonbox/carbon-footprint-configurations/corporate-configurations/domain/value-objects/CorporateCarbonFootprintConfigurationBaseYear.d.ts +10 -0
- package/build/types/carbonbox/carbon-footprint-configurations/corporate-configurations/domain/value-objects/CorporateCarbonFootprintConfigurationBaseYear.d.ts.map +1 -0
- package/build/types/carbonbox/emission-calculation-results/emission-aggregations/domain/value-objects/EmissionAggregationUncertaintyPercentage.d.ts.map +1 -1
- package/build/types/carbonbox/emission-calculation-results/shared/domain/enums/UncertaintyLevel.d.ts +14 -0
- package/build/types/carbonbox/emission-calculation-results/shared/domain/enums/UncertaintyLevel.d.ts.map +1 -0
- package/build/types/carbonbox/emission-calculation-results/shared/domain/services/contracts/IUncertaintyPropagationDomainService.d.ts +37 -0
- package/build/types/carbonbox/emission-calculation-results/shared/domain/services/contracts/IUncertaintyPropagationDomainService.d.ts.map +1 -0
- package/build/types/carbonbox/emission-calculation-results/shared/domain/services/implementations/UncertaintyPropagationDomainService.d.ts +24 -0
- package/build/types/carbonbox/emission-calculation-results/shared/domain/services/implementations/UncertaintyPropagationDomainService.d.ts.map +1 -0
- package/build/types/carbonbox/emission-calculation-results/shared/domain/types/UncertaintyBounds.d.ts +9 -0
- package/build/types/carbonbox/emission-calculation-results/shared/domain/types/UncertaintyBounds.d.ts.map +1 -0
- package/build/types/carbonbox/emission-calculation-results/shared/domain/types/UncertaintyWeightedContribution.d.ts +11 -0
- package/build/types/carbonbox/emission-calculation-results/shared/domain/types/UncertaintyWeightedContribution.d.ts.map +1 -0
- package/build/types/carbonbox/reporting/shared/domain/enums/DataBindingSource.d.ts +14 -0
- package/build/types/carbonbox/reporting/shared/domain/enums/DataBindingSource.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/types/BaseYear.d.ts +8 -0
- package/build/types/carbonbox/shared/domain/types/BaseYear.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/types/BaseYearPrimitives.d.ts +8 -0
- package/build/types/carbonbox/shared/domain/types/BaseYearPrimitives.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/value-objects/BaseYear.d.ts +46 -0
- package/build/types/carbonbox/shared/domain/value-objects/BaseYear.d.ts.map +1 -0
- package/build/types/main/index.d.ts +9 -0
- package/build/types/main/index.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -10,7 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
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");
|
|
11
11
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
12
|
};
|
|
13
|
-
var _CorporateCarbonFootprintConfiguration_facility, _CorporateCarbonFootprintConfiguration_executionPeriod, _CorporateCarbonFootprintConfiguration_segmentConfigurations;
|
|
13
|
+
var _CorporateCarbonFootprintConfiguration_facility, _CorporateCarbonFootprintConfiguration_executionPeriod, _CorporateCarbonFootprintConfiguration_baseYear, _CorporateCarbonFootprintConfiguration_segmentConfigurations;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.CorporateCarbonFootprintConfiguration = void 0;
|
|
16
16
|
const CarbonFootprintConfiguration_1 = require("../../../shared/domain/entities/CarbonFootprintConfiguration");
|
|
@@ -19,6 +19,7 @@ const CorporateCarbonFootprintConfigurationCollectionPeriod_1 = require("../valu
|
|
|
19
19
|
const CorporateCarbonFootprintConfigurationName_1 = require("../value-objects/CorporateCarbonFootprintConfigurationName");
|
|
20
20
|
const CorporateCarbonFootprintConfigurationCreatedByStakeholder_1 = require("../value-objects/CorporateCarbonFootprintConfigurationCreatedByStakeholder");
|
|
21
21
|
const CorporateCarbonFootprintConfigurationExecutionPeriod_1 = require("../value-objects/CorporateCarbonFootprintConfigurationExecutionPeriod");
|
|
22
|
+
const CorporateCarbonFootprintConfigurationBaseYear_1 = require("../value-objects/CorporateCarbonFootprintConfigurationBaseYear");
|
|
22
23
|
const CorporateCarbonFootprintConfigurationFacility_1 = require("../value-objects/CorporateCarbonFootprintConfigurationFacility");
|
|
23
24
|
const CorporateCarbonFootprintConfigurationFootprintType_1 = require("../value-objects/CorporateCarbonFootprintConfigurationFootprintType");
|
|
24
25
|
const CorporateCarbonFootprintConfigurationIntensityIndicatorConfigurations_1 = require("../value-objects/CorporateCarbonFootprintConfigurationIntensityIndicatorConfigurations");
|
|
@@ -73,17 +74,20 @@ class CorporateCarbonFootprintConfiguration extends CarbonFootprintConfiguration
|
|
|
73
74
|
}, skipDomainValidation);
|
|
74
75
|
_CorporateCarbonFootprintConfiguration_facility.set(this, void 0);
|
|
75
76
|
_CorporateCarbonFootprintConfiguration_executionPeriod.set(this, void 0);
|
|
77
|
+
_CorporateCarbonFootprintConfiguration_baseYear.set(this, void 0);
|
|
76
78
|
_CorporateCarbonFootprintConfiguration_segmentConfigurations.set(this, void 0);
|
|
77
79
|
if (skipDomainValidation === false) {
|
|
78
80
|
// Initialize with domain validation
|
|
79
81
|
__classPrivateFieldSet(this, _CorporateCarbonFootprintConfiguration_facility, CorporateCarbonFootprintConfigurationFacility_1.CorporateCarbonFootprintConfigurationFacility.create(props.facility), "f");
|
|
80
82
|
__classPrivateFieldSet(this, _CorporateCarbonFootprintConfiguration_executionPeriod, CorporateCarbonFootprintConfigurationExecutionPeriod_1.CorporateCarbonFootprintConfigurationExecutionPeriod.create(props.executionPeriod), "f");
|
|
83
|
+
__classPrivateFieldSet(this, _CorporateCarbonFootprintConfiguration_baseYear, CorporateCarbonFootprintConfigurationBaseYear_1.CorporateCarbonFootprintConfigurationBaseYear.create(props.baseYear), "f");
|
|
81
84
|
__classPrivateFieldSet(this, _CorporateCarbonFootprintConfiguration_segmentConfigurations, CorporateCarbonFootprintConfigurationSegmentConfigurations_1.CorporateCarbonFootprintConfigurationSegmentConfigurations.create(props.segmentConfigurations), "f");
|
|
82
85
|
}
|
|
83
86
|
else {
|
|
84
87
|
// Initialize from primitives (no domain validation)
|
|
85
88
|
__classPrivateFieldSet(this, _CorporateCarbonFootprintConfiguration_facility, CorporateCarbonFootprintConfigurationFacility_1.CorporateCarbonFootprintConfigurationFacility.fromPrimitives(props.facility), "f");
|
|
86
89
|
__classPrivateFieldSet(this, _CorporateCarbonFootprintConfiguration_executionPeriod, CorporateCarbonFootprintConfigurationExecutionPeriod_1.CorporateCarbonFootprintConfigurationExecutionPeriod.fromPrimitives(props.executionPeriod), "f");
|
|
90
|
+
__classPrivateFieldSet(this, _CorporateCarbonFootprintConfiguration_baseYear, CorporateCarbonFootprintConfigurationBaseYear_1.CorporateCarbonFootprintConfigurationBaseYear.fromPrimitives(props.baseYear), "f");
|
|
87
91
|
__classPrivateFieldSet(this, _CorporateCarbonFootprintConfiguration_segmentConfigurations, CorporateCarbonFootprintConfigurationSegmentConfigurations_1.CorporateCarbonFootprintConfigurationSegmentConfigurations.fromPrimitives(props.segmentConfigurations), "f");
|
|
88
92
|
}
|
|
89
93
|
}
|
|
@@ -104,6 +108,7 @@ class CorporateCarbonFootprintConfiguration extends CarbonFootprintConfiguration
|
|
|
104
108
|
createdByStakeholder: primitives.createdByStakeholder,
|
|
105
109
|
facility: primitives.facility,
|
|
106
110
|
executionPeriod: primitives.executionPeriod,
|
|
111
|
+
baseYear: primitives.baseYear,
|
|
107
112
|
segmentConfigurations: primitives.segmentConfigurations,
|
|
108
113
|
};
|
|
109
114
|
return new CorporateCarbonFootprintConfiguration(props, true);
|
|
@@ -122,6 +127,7 @@ class CorporateCarbonFootprintConfiguration extends CarbonFootprintConfiguration
|
|
|
122
127
|
createdByStakeholder: this.createdByStakeholder.toPrimitives(),
|
|
123
128
|
facility: this.facility.toPrimitives(),
|
|
124
129
|
executionPeriod: this.executionPeriod.toPrimitives(),
|
|
130
|
+
baseYear: this.baseYear.toPrimitives(),
|
|
125
131
|
segmentConfigurations: this.segmentConfigurations.toPrimitives(),
|
|
126
132
|
};
|
|
127
133
|
}
|
|
@@ -131,9 +137,12 @@ class CorporateCarbonFootprintConfiguration extends CarbonFootprintConfiguration
|
|
|
131
137
|
get executionPeriod() {
|
|
132
138
|
return __classPrivateFieldGet(this, _CorporateCarbonFootprintConfiguration_executionPeriod, "f");
|
|
133
139
|
}
|
|
140
|
+
get baseYear() {
|
|
141
|
+
return __classPrivateFieldGet(this, _CorporateCarbonFootprintConfiguration_baseYear, "f");
|
|
142
|
+
}
|
|
134
143
|
get segmentConfigurations() {
|
|
135
144
|
return __classPrivateFieldGet(this, _CorporateCarbonFootprintConfiguration_segmentConfigurations, "f");
|
|
136
145
|
}
|
|
137
146
|
}
|
|
138
147
|
exports.CorporateCarbonFootprintConfiguration = CorporateCarbonFootprintConfiguration;
|
|
139
|
-
_CorporateCarbonFootprintConfiguration_facility = new WeakMap(), _CorporateCarbonFootprintConfiguration_executionPeriod = new WeakMap(), _CorporateCarbonFootprintConfiguration_segmentConfigurations = new WeakMap();
|
|
148
|
+
_CorporateCarbonFootprintConfiguration_facility = new WeakMap(), _CorporateCarbonFootprintConfiguration_executionPeriod = new WeakMap(), _CorporateCarbonFootprintConfiguration_baseYear = new WeakMap(), _CorporateCarbonFootprintConfiguration_segmentConfigurations = new WeakMap();
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CorporateCarbonFootprintConfigurationBaseYear = void 0;
|
|
4
|
+
const BaseYear_1 = require("../../../../shared/domain/value-objects/BaseYear");
|
|
5
|
+
class CorporateCarbonFootprintConfigurationBaseYear extends BaseYear_1.BaseYear {
|
|
6
|
+
constructor(value, skipDomainValidation) {
|
|
7
|
+
super(value, skipDomainValidation);
|
|
8
|
+
}
|
|
9
|
+
static create(value) {
|
|
10
|
+
return new CorporateCarbonFootprintConfigurationBaseYear(value, false);
|
|
11
|
+
}
|
|
12
|
+
static fromPrimitives(primitives) {
|
|
13
|
+
const value = {
|
|
14
|
+
startDate: primitives.startDate,
|
|
15
|
+
endDate: primitives.endDate,
|
|
16
|
+
justification: primitives.justification,
|
|
17
|
+
recalculationPolicy: primitives.recalculationPolicy,
|
|
18
|
+
significanceThresholdPercentage: primitives.significanceThresholdPercentage,
|
|
19
|
+
};
|
|
20
|
+
return new CorporateCarbonFootprintConfigurationBaseYear(value, true);
|
|
21
|
+
}
|
|
22
|
+
toPrimitives() {
|
|
23
|
+
return {
|
|
24
|
+
startDate: this.startDate,
|
|
25
|
+
endDate: this.endDate,
|
|
26
|
+
justification: this.justification,
|
|
27
|
+
recalculationPolicy: this.recalculationPolicy,
|
|
28
|
+
significanceThresholdPercentage: this.significanceThresholdPercentage,
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.CorporateCarbonFootprintConfigurationBaseYear = CorporateCarbonFootprintConfigurationBaseYear;
|
|
@@ -7,10 +7,12 @@ class EmissionAggregationUncertaintyPercentage extends Numeric_1.Numeric {
|
|
|
7
7
|
super(value, skipDomainValidation, EmissionAggregationUncertaintyPercentage.PROPERTY_NAME, {
|
|
8
8
|
minValue: 0,
|
|
9
9
|
maxValue: 100,
|
|
10
|
-
allowDecimals:
|
|
10
|
+
allowDecimals: true,
|
|
11
11
|
allowNegative: false,
|
|
12
12
|
allowZero: true,
|
|
13
|
-
|
|
13
|
+
// GAP 4: same precision as the per-calculation uncertainty VOs, so a propagated
|
|
14
|
+
// value (e.g. 11.18034 %) is not truncated to an integer when aggregated.
|
|
15
|
+
maxDecimalPlaces: 5,
|
|
14
16
|
});
|
|
15
17
|
}
|
|
16
18
|
static create(value) {
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UncertaintyLevel = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Qualitative band of an uncertainty percentage (GAP 4).
|
|
6
|
+
*
|
|
7
|
+
* Thresholds follow the scale used by verified ISO 14064-1 inventories (GHG Protocol
|
|
8
|
+
* uncertainty tool): LOW ≤ 5 %, REGULAR ≤ 15 %, FAIR ≤ 30 %, HIGH > 30 %.
|
|
9
|
+
* `UncertaintyPropagationDomainService.classify` is the single place that applies them.
|
|
10
|
+
*/
|
|
11
|
+
var UncertaintyLevel;
|
|
12
|
+
(function (UncertaintyLevel) {
|
|
13
|
+
UncertaintyLevel["LOW"] = "LOW";
|
|
14
|
+
UncertaintyLevel["REGULAR"] = "REGULAR";
|
|
15
|
+
UncertaintyLevel["FAIR"] = "FAIR";
|
|
16
|
+
UncertaintyLevel["HIGH"] = "HIGH";
|
|
17
|
+
})(UncertaintyLevel || (exports.UncertaintyLevel = UncertaintyLevel = {}));
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.UncertaintyPropagationDomainService = void 0;
|
|
4
|
+
const UncertaintyLevel_1 = require("../../enums/UncertaintyLevel");
|
|
5
|
+
/**
|
|
6
|
+
* Domain Service for uncertainty propagation across the emission-calculation-results
|
|
7
|
+
* context (GAP 4). Centralizes the GHG Protocol "Method 1" arithmetic that used to live
|
|
8
|
+
* in the calculation worker, so the worker, the report snapshot builder and any future
|
|
9
|
+
* aggregation job apply the same formulas and the same qualitative scale.
|
|
10
|
+
*
|
|
11
|
+
* Stateless: created through the factory and registered as a singleton.
|
|
12
|
+
*/
|
|
13
|
+
class UncertaintyPropagationDomainService {
|
|
14
|
+
constructor() {
|
|
15
|
+
// Private constructor to enforce factory pattern
|
|
16
|
+
}
|
|
17
|
+
static create() {
|
|
18
|
+
return new UncertaintyPropagationDomainService();
|
|
19
|
+
}
|
|
20
|
+
combineIndependent(uncertaintyPercentages) {
|
|
21
|
+
const sumOfSquares = uncertaintyPercentages.reduce((sum, percentage) => sum + percentage ** 2, 0);
|
|
22
|
+
return Math.sqrt(sumOfSquares);
|
|
23
|
+
}
|
|
24
|
+
combineWeighted(contributions) {
|
|
25
|
+
const totalMagnitude = contributions.reduce((sum, contribution) => sum + Math.abs(contribution.value), 0);
|
|
26
|
+
if (totalMagnitude === 0) {
|
|
27
|
+
return 0;
|
|
28
|
+
}
|
|
29
|
+
const sumOfSquaredAbsoluteUncertainties = contributions.reduce((sum, contribution) => sum + (contribution.value * contribution.uncertaintyPercentage) ** 2, 0);
|
|
30
|
+
return Math.sqrt(sumOfSquaredAbsoluteUncertainties) / totalMagnitude;
|
|
31
|
+
}
|
|
32
|
+
classify(uncertaintyPercentage) {
|
|
33
|
+
if (uncertaintyPercentage <= UncertaintyPropagationDomainService.LOW_UPPER_BOUND_PERCENTAGE) {
|
|
34
|
+
return UncertaintyLevel_1.UncertaintyLevel.LOW;
|
|
35
|
+
}
|
|
36
|
+
if (uncertaintyPercentage <= UncertaintyPropagationDomainService.REGULAR_UPPER_BOUND_PERCENTAGE) {
|
|
37
|
+
return UncertaintyLevel_1.UncertaintyLevel.REGULAR;
|
|
38
|
+
}
|
|
39
|
+
if (uncertaintyPercentage <= UncertaintyPropagationDomainService.FAIR_UPPER_BOUND_PERCENTAGE) {
|
|
40
|
+
return UncertaintyLevel_1.UncertaintyLevel.FAIR;
|
|
41
|
+
}
|
|
42
|
+
return UncertaintyLevel_1.UncertaintyLevel.HIGH;
|
|
43
|
+
}
|
|
44
|
+
boundsOf(centralValue, uncertaintyPercentage) {
|
|
45
|
+
const absoluteUncertainty = (centralValue * uncertaintyPercentage) / 100;
|
|
46
|
+
return {
|
|
47
|
+
min: Math.max(0, centralValue - absoluteUncertainty),
|
|
48
|
+
max: centralValue + absoluteUncertainty,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.UncertaintyPropagationDomainService = UncertaintyPropagationDomainService;
|
|
53
|
+
UncertaintyPropagationDomainService.LOW_UPPER_BOUND_PERCENTAGE = 5;
|
|
54
|
+
UncertaintyPropagationDomainService.REGULAR_UPPER_BOUND_PERCENTAGE = 15;
|
|
55
|
+
UncertaintyPropagationDomainService.FAIR_UPPER_BOUND_PERCENTAGE = 30;
|
|
@@ -46,6 +46,20 @@ var DataBindingSource;
|
|
|
46
46
|
// Aggregations - Biogenic
|
|
47
47
|
DataBindingSource["AGGREGATION_BIOGENIC"] = "aggregation.biogenic";
|
|
48
48
|
DataBindingSource["AGGREGATION_BIOGENIC_CO2"] = "aggregation.biogenicCO2";
|
|
49
|
+
// Aggregations - Uncertainty (GAP 4): inventory-level propagated uncertainty
|
|
50
|
+
DataBindingSource["AGGREGATION_UNCERTAINTY_PERCENTAGE"] = "aggregation.uncertainty.percentage";
|
|
51
|
+
DataBindingSource["AGGREGATION_UNCERTAINTY_LEVEL"] = "aggregation.uncertainty.level";
|
|
52
|
+
DataBindingSource["AGGREGATION_UNCERTAINTY_RANGE_MIN_TCO2E"] = "aggregation.uncertainty.rangeMinTCO2e";
|
|
53
|
+
DataBindingSource["AGGREGATION_UNCERTAINTY_RANGE_MAX_TCO2E"] = "aggregation.uncertainty.rangeMaxTCO2e";
|
|
54
|
+
DataBindingSource["AGGREGATION_UNCERTAINTY_BY_SOURCE"] = "aggregation.uncertainty.bySource";
|
|
55
|
+
// Base year and recalculation policy (GAP 3, ISO 14064-1 §6.4): declared on the corporate
|
|
56
|
+
// configuration and frozen into the snapshot with the base-year total and the variation
|
|
57
|
+
DataBindingSource["BASE_YEAR_PERIOD"] = "baseYear.period";
|
|
58
|
+
DataBindingSource["BASE_YEAR_TOTAL_TCO2E"] = "baseYear.totalTCO2e";
|
|
59
|
+
DataBindingSource["BASE_YEAR_VARIATION_PERCENTAGE"] = "baseYear.variationPercentage";
|
|
60
|
+
DataBindingSource["BASE_YEAR_JUSTIFICATION"] = "baseYear.justification";
|
|
61
|
+
DataBindingSource["BASE_YEAR_RECALCULATION_POLICY"] = "baseYear.recalculationPolicy";
|
|
62
|
+
DataBindingSource["BASE_YEAR_SIGNIFICANCE_THRESHOLD_PERCENTAGE"] = "baseYear.significanceThresholdPercentage";
|
|
49
63
|
// Emission Factors
|
|
50
64
|
DataBindingSource["EMISSION_FACTOR_VALUE"] = "emissionFactor.value";
|
|
51
65
|
DataBindingSource["EMISSION_FACTOR_UNIT"] = "emissionFactor.unit";
|
|
@@ -55,6 +69,7 @@ var DataBindingSource;
|
|
|
55
69
|
DataBindingSource["EMISSION_FACTOR_IPCC_CODE"] = "emissionFactor.ipccCode";
|
|
56
70
|
DataBindingSource["EMISSION_FACTOR_IPCC_SUBCATEGORY"] = "emissionFactor.ipccSubcategory";
|
|
57
71
|
DataBindingSource["EMISSION_FACTOR_METHODOLOGICAL_TIER"] = "emissionFactor.methodologicalTier";
|
|
72
|
+
DataBindingSource["EMISSION_FACTOR_UNCERTAINTY_PERCENTAGE"] = "emissionFactor.uncertaintyPercentage";
|
|
58
73
|
// Global Warming Potential (GWP)
|
|
59
74
|
DataBindingSource["GWP_PROTOCOL_VERSION"] = "gwp.protocolVersion";
|
|
60
75
|
DataBindingSource["GWP_POTENTIAL"] = "gwp.potential";
|
|
@@ -72,6 +87,8 @@ var DataBindingSource;
|
|
|
72
87
|
DataBindingSource["CHART_BY_SEGMENT"] = "chart.bySegment";
|
|
73
88
|
DataBindingSource["CHART_BY_GAS"] = "chart.byGas";
|
|
74
89
|
DataBindingSource["CHART_TREND_ANALYSIS"] = "chart.trendAnalysis";
|
|
90
|
+
DataBindingSource["CHART_UNCERTAINTY_BY_SOURCE"] = "chart.uncertaintyBySource";
|
|
91
|
+
DataBindingSource["CHART_BASE_YEAR_COMPARISON"] = "chart.baseYearComparison";
|
|
75
92
|
// Facilities/Locations
|
|
76
93
|
DataBindingSource["FACILITIES_COUNT"] = "facilities.count";
|
|
77
94
|
DataBindingSource["FACILITIES_LIST"] = "facilities.list";
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
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");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _BaseYear_startDate, _BaseYear_endDate, _BaseYear_justification, _BaseYear_recalculationPolicy, _BaseYear_significanceThresholdPercentage;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.BaseYear = void 0;
|
|
16
|
+
const InvalidPropertyTypeError_1 = require("../exceptions/InvalidPropertyTypeError");
|
|
17
|
+
const InvalidPropertyValueError_1 = require("../exceptions/InvalidPropertyValueError");
|
|
18
|
+
const DateString_1 = require("./DateString");
|
|
19
|
+
const ObjectValueObject_1 = require("./ObjectValueObject");
|
|
20
|
+
const String_1 = require("./String");
|
|
21
|
+
/**
|
|
22
|
+
* Base year of a GHG inventory (ISO 14064-1 §6.4 / GHG Protocol "base year and recalculation
|
|
23
|
+
* policy", GAP 3). Modelled as a DATE RANGE rather than a calendar year so fiscal years
|
|
24
|
+
* (e.g. 1 July 2025 – 30 June 2026) are first-class. Carries the organization's justification
|
|
25
|
+
* for the choice, its recalculation policy and the significance threshold that triggers a
|
|
26
|
+
* recalculation. Immutable; subclasses give it an aggregate-specific name.
|
|
27
|
+
*/
|
|
28
|
+
class BaseYear extends ObjectValueObject_1.ObjectValueObject {
|
|
29
|
+
/**
|
|
30
|
+
* Constructor protegido para que solo clases hijas puedan instanciar.
|
|
31
|
+
* Aplica todas las validaciones de dominio al momento de construcción.
|
|
32
|
+
*/
|
|
33
|
+
constructor(value, skipDomainValidation, propertyName = BaseYear.DEFAULT_PROPERTY_NAME) {
|
|
34
|
+
super(value, skipDomainValidation, propertyName, 'The provided value must be of type BaseYear from the domain layer', { allowNull: false, allowUndefined: false });
|
|
35
|
+
_BaseYear_startDate.set(this, void 0);
|
|
36
|
+
_BaseYear_endDate.set(this, void 0);
|
|
37
|
+
_BaseYear_justification.set(this, void 0);
|
|
38
|
+
_BaseYear_recalculationPolicy.set(this, void 0);
|
|
39
|
+
_BaseYear_significanceThresholdPercentage.set(this, void 0);
|
|
40
|
+
if (skipDomainValidation === false) {
|
|
41
|
+
this.guardAgainstInvalidBaseYear(value);
|
|
42
|
+
}
|
|
43
|
+
__classPrivateFieldSet(this, _BaseYear_startDate, value.startDate, "f");
|
|
44
|
+
__classPrivateFieldSet(this, _BaseYear_endDate, value.endDate, "f");
|
|
45
|
+
__classPrivateFieldSet(this, _BaseYear_justification, value.justification, "f");
|
|
46
|
+
__classPrivateFieldSet(this, _BaseYear_recalculationPolicy, value.recalculationPolicy, "f");
|
|
47
|
+
__classPrivateFieldSet(this, _BaseYear_significanceThresholdPercentage, value.significanceThresholdPercentage, "f");
|
|
48
|
+
}
|
|
49
|
+
guardAgainstInvalidBaseYear(value) {
|
|
50
|
+
this.guardAgainstInvalidDate(value.startDate, 'startDate');
|
|
51
|
+
this.guardAgainstInvalidDate(value.endDate, 'endDate');
|
|
52
|
+
this.guardAgainstInvalidDateRange(value.startDate, value.endDate);
|
|
53
|
+
this.guardAgainstInvalidText(value.justification, 'justification');
|
|
54
|
+
this.guardAgainstInvalidText(value.recalculationPolicy, 'recalculationPolicy');
|
|
55
|
+
this.guardAgainstInvalidSignificanceThreshold(value.significanceThresholdPercentage);
|
|
56
|
+
}
|
|
57
|
+
guardAgainstInvalidDate(date, propertyName) {
|
|
58
|
+
this.guardAgainstNullOrUndefinedValue(date, propertyName);
|
|
59
|
+
String_1.String.guardAgainstInvalidType(date, propertyName);
|
|
60
|
+
String_1.String.guardAgainstEmptyValue(date, propertyName);
|
|
61
|
+
DateString_1.DateString.guardAgainstInvalidDateFormat(date);
|
|
62
|
+
}
|
|
63
|
+
guardAgainstInvalidText(text, propertyName) {
|
|
64
|
+
this.guardAgainstNullOrUndefinedValue(text, propertyName);
|
|
65
|
+
String_1.String.guardAgainstInvalidType(text, propertyName);
|
|
66
|
+
String_1.String.guardAgainstEmptyValue(text, propertyName);
|
|
67
|
+
}
|
|
68
|
+
guardAgainstInvalidDateRange(startDate, endDate) {
|
|
69
|
+
const start = this.parseDate(startDate);
|
|
70
|
+
const end = this.parseDate(endDate);
|
|
71
|
+
if (start >= end) {
|
|
72
|
+
throw InvalidPropertyValueError_1.InvalidPropertyValueError.create('endDate', 'date after start date', `start: ${startDate}, end: ${endDate}`);
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
guardAgainstInvalidSignificanceThreshold(percentage) {
|
|
76
|
+
this.guardAgainstNullOrUndefinedValue(percentage, 'significanceThresholdPercentage');
|
|
77
|
+
if (typeof percentage !== 'number' || Number.isNaN(percentage) || !Number.isFinite(percentage)) {
|
|
78
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create('significanceThresholdPercentage', 'finite number', typeof percentage);
|
|
79
|
+
}
|
|
80
|
+
if (percentage < BaseYear.MIN_SIGNIFICANCE_THRESHOLD_PERCENTAGE || percentage > BaseYear.MAX_SIGNIFICANCE_THRESHOLD_PERCENTAGE) {
|
|
81
|
+
throw InvalidPropertyValueError_1.InvalidPropertyValueError.create('significanceThresholdPercentage', `percentage between ${BaseYear.MIN_SIGNIFICANCE_THRESHOLD_PERCENTAGE} and ${BaseYear.MAX_SIGNIFICANCE_THRESHOLD_PERCENTAGE}`, `${percentage}`);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
guardAgainstNullOrUndefinedValue(value, propertyName) {
|
|
85
|
+
if (value === null || value === undefined) {
|
|
86
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(propertyName, 'non-null value', typeof value);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
parseDate(dateString) {
|
|
90
|
+
const [day, month, year] = dateString.split('/').map(Number);
|
|
91
|
+
return new Date(year, month - 1, day);
|
|
92
|
+
}
|
|
93
|
+
// Getters
|
|
94
|
+
get startDate() {
|
|
95
|
+
return __classPrivateFieldGet(this, _BaseYear_startDate, "f");
|
|
96
|
+
}
|
|
97
|
+
get endDate() {
|
|
98
|
+
return __classPrivateFieldGet(this, _BaseYear_endDate, "f");
|
|
99
|
+
}
|
|
100
|
+
get justification() {
|
|
101
|
+
return __classPrivateFieldGet(this, _BaseYear_justification, "f");
|
|
102
|
+
}
|
|
103
|
+
get recalculationPolicy() {
|
|
104
|
+
return __classPrivateFieldGet(this, _BaseYear_recalculationPolicy, "f");
|
|
105
|
+
}
|
|
106
|
+
get significanceThresholdPercentage() {
|
|
107
|
+
return __classPrivateFieldGet(this, _BaseYear_significanceThresholdPercentage, "f");
|
|
108
|
+
}
|
|
109
|
+
toPrimitives() {
|
|
110
|
+
return {
|
|
111
|
+
startDate: __classPrivateFieldGet(this, _BaseYear_startDate, "f"),
|
|
112
|
+
endDate: __classPrivateFieldGet(this, _BaseYear_endDate, "f"),
|
|
113
|
+
justification: __classPrivateFieldGet(this, _BaseYear_justification, "f"),
|
|
114
|
+
recalculationPolicy: __classPrivateFieldGet(this, _BaseYear_recalculationPolicy, "f"),
|
|
115
|
+
significanceThresholdPercentage: __classPrivateFieldGet(this, _BaseYear_significanceThresholdPercentage, "f"),
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
// Domain methods
|
|
119
|
+
getStartDateAsDate() {
|
|
120
|
+
return this.parseDate(__classPrivateFieldGet(this, _BaseYear_startDate, "f"));
|
|
121
|
+
}
|
|
122
|
+
getEndDateAsDate() {
|
|
123
|
+
return this.parseDate(__classPrivateFieldGet(this, _BaseYear_endDate, "f"));
|
|
124
|
+
}
|
|
125
|
+
/** `DD/MM/YYYY to DD/MM/YYYY`, the label reports print next to the base-year figures. */
|
|
126
|
+
getShortFormattedRange() {
|
|
127
|
+
return `${__classPrivateFieldGet(this, _BaseYear_startDate, "f")} to ${__classPrivateFieldGet(this, _BaseYear_endDate, "f")}`;
|
|
128
|
+
}
|
|
129
|
+
/** True when the base year is not a calendar year (starts on a day other than 1 January). */
|
|
130
|
+
isFiscalYear() {
|
|
131
|
+
const start = this.getStartDateAsDate();
|
|
132
|
+
return start.getMonth() !== 0 || start.getDate() !== 1;
|
|
133
|
+
}
|
|
134
|
+
/** Whether a change of the given magnitude (± %) must trigger a base-year recalculation. */
|
|
135
|
+
requiresRecalculation(changePercentage) {
|
|
136
|
+
return Math.abs(changePercentage) >= __classPrivateFieldGet(this, _BaseYear_significanceThresholdPercentage, "f");
|
|
137
|
+
}
|
|
138
|
+
containsDate(date) {
|
|
139
|
+
return date >= this.getStartDateAsDate() && date <= this.getEndDateAsDate();
|
|
140
|
+
}
|
|
141
|
+
coversSamePeriodAs(startDate, endDate) {
|
|
142
|
+
return __classPrivateFieldGet(this, _BaseYear_startDate, "f") === startDate && __classPrivateFieldGet(this, _BaseYear_endDate, "f") === endDate;
|
|
143
|
+
}
|
|
144
|
+
equals(other) {
|
|
145
|
+
return __classPrivateFieldGet(this, _BaseYear_startDate, "f") === __classPrivateFieldGet(other, _BaseYear_startDate, "f")
|
|
146
|
+
&& __classPrivateFieldGet(this, _BaseYear_endDate, "f") === __classPrivateFieldGet(other, _BaseYear_endDate, "f")
|
|
147
|
+
&& __classPrivateFieldGet(this, _BaseYear_justification, "f") === __classPrivateFieldGet(other, _BaseYear_justification, "f")
|
|
148
|
+
&& __classPrivateFieldGet(this, _BaseYear_recalculationPolicy, "f") === __classPrivateFieldGet(other, _BaseYear_recalculationPolicy, "f")
|
|
149
|
+
&& __classPrivateFieldGet(this, _BaseYear_significanceThresholdPercentage, "f") === __classPrivateFieldGet(other, _BaseYear_significanceThresholdPercentage, "f");
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
exports.BaseYear = BaseYear;
|
|
153
|
+
_BaseYear_startDate = new WeakMap(), _BaseYear_endDate = new WeakMap(), _BaseYear_justification = new WeakMap(), _BaseYear_recalculationPolicy = new WeakMap(), _BaseYear_significanceThresholdPercentage = new WeakMap();
|
|
154
|
+
BaseYear.DEFAULT_PROPERTY_NAME = 'baseYear';
|
|
155
|
+
BaseYear.MIN_SIGNIFICANCE_THRESHOLD_PERCENTAGE = 0;
|
|
156
|
+
BaseYear.MAX_SIGNIFICANCE_THRESHOLD_PERCENTAGE = 100;
|