@carbonbox/domain 0.27.0 → 0.28.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/emission-calculation-formulas/domain/entity/EmissionCalculationFormula.js +1 -1
- package/build/carbonbox/emission-calculation-formulas/domain/value-objects/EmissionCalculationFormulaApplicableGreenhouseGases.js +30 -215
- package/build/carbonbox/emission-calculation-formulas/emission-factors/domain/value-objects/EmissionFactorGreenhouseGasValues.js +16 -11
- package/build/carbonbox/emission-calculation-formulas/global-warming-potentials/domain/value-objects/GlobalWarmingPotentialGreenhouseGasPotentials.js +18 -13
- package/build/carbonbox/emission-calculation-results/emission-aggregations/domain/value-objects/EmissionAggregationGhgBreakdown.js +52 -109
- package/build/carbonbox/emission-calculation-results/ghg-emission-results/domain/entity/GHGEmissionResult.js +9 -4
- package/build/carbonbox/emission-calculation-results/ghg-emission-results/domain/value-objects/GHGEmissionResultGreenhouseGas.js +44 -160
- package/build/carbonbox/shared/domain/enums/GreenhouseGasCategory.js +15 -0
- package/build/carbonbox/shared/domain/value-objects/GreenhouseGasSpecies.js +50 -0
- package/build/main/index.js +15 -13
- package/build/types/carbonbox/emission-calculation-formulas/domain/types/EmissionCalculationFormulaPrimitives.d.ts +1 -2
- package/build/types/carbonbox/emission-calculation-formulas/domain/types/EmissionCalculationFormulaPrimitives.d.ts.map +1 -1
- package/build/types/carbonbox/emission-calculation-formulas/domain/types/EmissionCalculationFormulaProps.d.ts +1 -2
- package/build/types/carbonbox/emission-calculation-formulas/domain/types/EmissionCalculationFormulaProps.d.ts.map +1 -1
- package/build/types/carbonbox/emission-calculation-formulas/domain/value-objects/EmissionCalculationFormulaApplicableGreenhouseGases.d.ts +11 -105
- package/build/types/carbonbox/emission-calculation-formulas/domain/value-objects/EmissionCalculationFormulaApplicableGreenhouseGases.d.ts.map +1 -1
- package/build/types/carbonbox/emission-calculation-formulas/emission-factors/domain/types/GHGFactorValue.d.ts +3 -2
- package/build/types/carbonbox/emission-calculation-formulas/emission-factors/domain/types/GHGFactorValue.d.ts.map +1 -1
- package/build/types/carbonbox/emission-calculation-formulas/emission-factors/domain/types/GHGFactorValuePrimitives.d.ts +3 -2
- package/build/types/carbonbox/emission-calculation-formulas/emission-factors/domain/types/GHGFactorValuePrimitives.d.ts.map +1 -1
- package/build/types/carbonbox/emission-calculation-formulas/emission-factors/domain/value-objects/EmissionFactorGreenhouseGasValues.d.ts +1 -1
- package/build/types/carbonbox/emission-calculation-formulas/emission-factors/domain/value-objects/EmissionFactorGreenhouseGasValues.d.ts.map +1 -1
- package/build/types/carbonbox/emission-calculation-formulas/global-warming-potentials/domain/types/GHGPotentialValue.d.ts +3 -2
- package/build/types/carbonbox/emission-calculation-formulas/global-warming-potentials/domain/types/GHGPotentialValue.d.ts.map +1 -1
- package/build/types/carbonbox/emission-calculation-formulas/global-warming-potentials/domain/types/GHGPotentialValuePrimitives.d.ts +3 -2
- package/build/types/carbonbox/emission-calculation-formulas/global-warming-potentials/domain/types/GHGPotentialValuePrimitives.d.ts.map +1 -1
- package/build/types/carbonbox/emission-calculation-formulas/global-warming-potentials/domain/value-objects/GlobalWarmingPotentialGreenhouseGasPotentials.d.ts +2 -2
- package/build/types/carbonbox/emission-calculation-formulas/global-warming-potentials/domain/value-objects/GlobalWarmingPotentialGreenhouseGasPotentials.d.ts.map +1 -1
- package/build/types/carbonbox/emission-calculation-results/emission-aggregations/domain/types/GHGBreakdown.d.ts +3 -2
- package/build/types/carbonbox/emission-calculation-results/emission-aggregations/domain/types/GHGBreakdown.d.ts.map +1 -1
- package/build/types/carbonbox/emission-calculation-results/emission-aggregations/domain/types/GHGBreakdownPrimitives.d.ts +3 -2
- package/build/types/carbonbox/emission-calculation-results/emission-aggregations/domain/types/GHGBreakdownPrimitives.d.ts.map +1 -1
- package/build/types/carbonbox/emission-calculation-results/emission-aggregations/domain/value-objects/EmissionAggregationGhgBreakdown.d.ts +9 -80
- package/build/types/carbonbox/emission-calculation-results/emission-aggregations/domain/value-objects/EmissionAggregationGhgBreakdown.d.ts.map +1 -1
- package/build/types/carbonbox/emission-calculation-results/ghg-emission-results/domain/entity/GHGEmissionResult.d.ts.map +1 -1
- package/build/types/carbonbox/emission-calculation-results/ghg-emission-results/domain/types/GHGEmissionResultPrimitives.d.ts +3 -2
- package/build/types/carbonbox/emission-calculation-results/ghg-emission-results/domain/types/GHGEmissionResultPrimitives.d.ts.map +1 -1
- package/build/types/carbonbox/emission-calculation-results/ghg-emission-results/domain/types/GHGEmissionResultProps.d.ts +3 -2
- package/build/types/carbonbox/emission-calculation-results/ghg-emission-results/domain/types/GHGEmissionResultProps.d.ts.map +1 -1
- package/build/types/carbonbox/emission-calculation-results/ghg-emission-results/domain/value-objects/GHGEmissionResultGreenhouseGas.d.ts +22 -89
- package/build/types/carbonbox/emission-calculation-results/ghg-emission-results/domain/value-objects/GHGEmissionResultGreenhouseGas.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/enums/GreenhouseGasCategory.d.ts +12 -0
- package/build/types/carbonbox/shared/domain/enums/GreenhouseGasCategory.d.ts.map +1 -0
- package/build/types/carbonbox/shared/domain/value-objects/GreenhouseGasSpecies.d.ts +24 -0
- package/build/types/carbonbox/shared/domain/value-objects/GreenhouseGasSpecies.d.ts.map +1 -0
- package/build/types/main/index.d.ts +3 -1
- package/build/types/main/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/build/carbonbox/shared/domain/enums/GreenhouseGas.js +0 -14
- package/build/types/carbonbox/shared/domain/enums/GreenhouseGas.d.ts +0 -11
- package/build/types/carbonbox/shared/domain/enums/GreenhouseGas.d.ts.map +0 -1
|
@@ -10,143 +10,97 @@ 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 _a, _EmissionAggregationGhgBreakdown_ghgBreakdowns, _EmissionAggregationGhgBreakdown_guardAgainstInvalidArrayType, _EmissionAggregationGhgBreakdown_guardAgainstInvalidEmptyArray,
|
|
13
|
+
var _a, _EmissionAggregationGhgBreakdown_ghgBreakdowns, _EmissionAggregationGhgBreakdown_guardAgainstInvalidArrayType, _EmissionAggregationGhgBreakdown_guardAgainstInvalidEmptyArray, _EmissionAggregationGhgBreakdown_guardAgainstDuplicateSpecies, _EmissionAggregationGhgBreakdown_guardAgainstInvalidTotalPercentage, _EmissionAggregationGhgBreakdown_guardAgainstInvalidGhgBreakdown, _EmissionAggregationGhgBreakdown_guardAgainstInvalidGhgStructure, _EmissionAggregationGhgBreakdown_guardAgainstInvalidCategory, _EmissionAggregationGhgBreakdown_guardAgainstInvalidCo2Equivalent, _EmissionAggregationGhgBreakdown_guardAgainstInvalidPercentage, _EmissionAggregationGhgBreakdown_guardAgainstInvalidUnit;
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
15
|
exports.EmissionAggregationGhgBreakdown = void 0;
|
|
16
16
|
const InvalidPropertyTypeError_1 = require("../../../../shared/domain/exceptions/InvalidPropertyTypeError");
|
|
17
17
|
const InvalidPropertyValueError_1 = require("../../../../shared/domain/exceptions/InvalidPropertyValueError");
|
|
18
18
|
const String_1 = require("../../../../shared/domain/value-objects/String");
|
|
19
19
|
const Numeric_1 = require("../../../../shared/domain/value-objects/Numeric");
|
|
20
|
-
const
|
|
20
|
+
const GreenhouseGasCategory_1 = require("../../../../shared/domain/enums/GreenhouseGasCategory");
|
|
21
|
+
const GreenhouseGasSpecies_1 = require("../../../../shared/domain/value-objects/GreenhouseGasSpecies");
|
|
21
22
|
const ValueObject_1 = require("../../../../shared/domain/value-objects/ValueObject");
|
|
22
23
|
class EmissionAggregationGhgBreakdown extends ValueObject_1.ValueObject {
|
|
23
|
-
/**
|
|
24
|
-
* Constructor privado para controlar la creación de instancias.
|
|
25
|
-
* Aplica todas las validaciones de dominio al momento de construcción.
|
|
26
|
-
*/
|
|
27
24
|
constructor(value, skipDomainValidation) {
|
|
28
25
|
super(value, skipDomainValidation, _a.PROPERTY_NAME, 'The provided value must be of type GHGBreakdown[] from the domain layer');
|
|
29
26
|
_EmissionAggregationGhgBreakdown_ghgBreakdowns.set(this, void 0);
|
|
30
27
|
if (skipDomainValidation === false) {
|
|
31
28
|
_a.validateGhgBreakdowns(value, _a.OPTIONS, _a.PROPERTY_NAME);
|
|
32
29
|
}
|
|
33
|
-
__classPrivateFieldSet(this, _EmissionAggregationGhgBreakdown_ghgBreakdowns, [...value], "f");
|
|
30
|
+
__classPrivateFieldSet(this, _EmissionAggregationGhgBreakdown_ghgBreakdowns, [...value], "f");
|
|
34
31
|
}
|
|
35
|
-
/**
|
|
36
|
-
* Factory method para crear una nueva instancia de EmissionAggregationGhgBreakdown.
|
|
37
|
-
*/
|
|
38
32
|
static create(value) {
|
|
39
33
|
return new _a(value, false);
|
|
40
34
|
}
|
|
41
|
-
/**
|
|
42
|
-
* Factory method para crear desde primitivos.
|
|
43
|
-
*/
|
|
44
35
|
static fromPrimitives(primitives) {
|
|
45
36
|
const ghgBreakdowns = primitives.map((primitive) => ({
|
|
46
|
-
|
|
37
|
+
greenhouseGasCategory: primitive.greenhouseGasCategory,
|
|
38
|
+
greenhouseGasSpecies: primitive.greenhouseGasSpecies,
|
|
47
39
|
co2Equivalent: primitive.co2Equivalent,
|
|
48
40
|
percentage: primitive.percentage,
|
|
49
41
|
unit: primitive.unit,
|
|
50
42
|
}));
|
|
51
43
|
return new _a(ghgBreakdowns, true);
|
|
52
44
|
}
|
|
53
|
-
/**
|
|
54
|
-
* Validación estática para reutilización en factory methods y constructores.
|
|
55
|
-
*/
|
|
56
45
|
static validateGhgBreakdowns(value, options, propertyName) {
|
|
57
46
|
__classPrivateFieldGet(this, _a, "m", _EmissionAggregationGhgBreakdown_guardAgainstInvalidArrayType).call(this, value, propertyName);
|
|
58
47
|
__classPrivateFieldGet(this, _a, "m", _EmissionAggregationGhgBreakdown_guardAgainstInvalidEmptyArray).call(this, value, options, propertyName);
|
|
59
|
-
__classPrivateFieldGet(this, _a, "m",
|
|
48
|
+
__classPrivateFieldGet(this, _a, "m", _EmissionAggregationGhgBreakdown_guardAgainstDuplicateSpecies).call(this, value, propertyName);
|
|
60
49
|
__classPrivateFieldGet(this, _a, "m", _EmissionAggregationGhgBreakdown_guardAgainstInvalidTotalPercentage).call(this, value, propertyName);
|
|
61
50
|
value.forEach((ghgBreakdown, index) => {
|
|
62
51
|
__classPrivateFieldGet(this, _a, "m", _EmissionAggregationGhgBreakdown_guardAgainstInvalidGhgBreakdown).call(this, ghgBreakdown, index, propertyName);
|
|
63
52
|
});
|
|
64
53
|
}
|
|
65
|
-
/**
|
|
66
|
-
* Breakdowns de GHG (inmutable).
|
|
67
|
-
*/
|
|
68
54
|
get ghgBreakdowns() {
|
|
69
55
|
return Object.freeze([...__classPrivateFieldGet(this, _EmissionAggregationGhgBreakdown_ghgBreakdowns, "f")]);
|
|
70
56
|
}
|
|
71
|
-
/**
|
|
72
|
-
* Número de breakdowns en la colección.
|
|
73
|
-
*/
|
|
74
57
|
get length() {
|
|
75
58
|
return __classPrivateFieldGet(this, _EmissionAggregationGhgBreakdown_ghgBreakdowns, "f").length;
|
|
76
59
|
}
|
|
77
|
-
/**
|
|
78
|
-
* Verifica si la colección está vacía.
|
|
79
|
-
*/
|
|
80
60
|
isEmpty() {
|
|
81
61
|
return __classPrivateFieldGet(this, _EmissionAggregationGhgBreakdown_ghgBreakdowns, "f").length === 0;
|
|
82
62
|
}
|
|
83
|
-
/**
|
|
84
|
-
* Verifica si la colección tiene breakdowns.
|
|
85
|
-
*/
|
|
86
63
|
hasBreakdowns() {
|
|
87
64
|
return !this.isEmpty();
|
|
88
65
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
getBreakdownByGas(greenhouseGas) {
|
|
93
|
-
const breakdown = __classPrivateFieldGet(this, _EmissionAggregationGhgBreakdown_ghgBreakdowns, "f").find((b) => b.greenhouseGas === greenhouseGas);
|
|
66
|
+
getBreakdownBySpecies(species) {
|
|
67
|
+
const normalized = GreenhouseGasSpecies_1.GreenhouseGasSpecies.normalize(species);
|
|
68
|
+
const breakdown = __classPrivateFieldGet(this, _EmissionAggregationGhgBreakdown_ghgBreakdowns, "f").find((b) => b.greenhouseGasSpecies === normalized);
|
|
94
69
|
return breakdown || null;
|
|
95
70
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
*/
|
|
99
|
-
hasBreakdownForGas(greenhouseGas) {
|
|
100
|
-
return this.getBreakdownByGas(greenhouseGas) !== null;
|
|
71
|
+
hasBreakdownForSpecies(species) {
|
|
72
|
+
return this.getBreakdownBySpecies(species) !== null;
|
|
101
73
|
}
|
|
102
|
-
/**
|
|
103
|
-
* Obtiene un breakdown por su índice.
|
|
104
|
-
*/
|
|
105
74
|
getBreakdownAt(index) {
|
|
106
75
|
if (index < 0 || index >= __classPrivateFieldGet(this, _EmissionAggregationGhgBreakdown_ghgBreakdowns, "f").length) {
|
|
107
76
|
return null;
|
|
108
77
|
}
|
|
109
78
|
return __classPrivateFieldGet(this, _EmissionAggregationGhgBreakdown_ghgBreakdowns, "f")[index];
|
|
110
79
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
return __classPrivateFieldGet(this, _EmissionAggregationGhgBreakdown_ghgBreakdowns, "f").map((breakdown) => breakdown.
|
|
80
|
+
getAllSpecies() {
|
|
81
|
+
return __classPrivateFieldGet(this, _EmissionAggregationGhgBreakdown_ghgBreakdowns, "f").map((breakdown) => breakdown.greenhouseGasSpecies);
|
|
82
|
+
}
|
|
83
|
+
getAllCategories() {
|
|
84
|
+
return __classPrivateFieldGet(this, _EmissionAggregationGhgBreakdown_ghgBreakdowns, "f").map((breakdown) => breakdown.greenhouseGasCategory);
|
|
116
85
|
}
|
|
117
|
-
/**
|
|
118
|
-
* Obtiene el total de CO2 equivalente.
|
|
119
|
-
*/
|
|
120
86
|
getTotalCo2Equivalent() {
|
|
121
87
|
return __classPrivateFieldGet(this, _EmissionAggregationGhgBreakdown_ghgBreakdowns, "f").reduce((total, breakdown) => total + breakdown.co2Equivalent, 0);
|
|
122
88
|
}
|
|
123
|
-
/**
|
|
124
|
-
* Obtiene el breakdown con mayor CO2 equivalente.
|
|
125
|
-
*/
|
|
126
89
|
getHighestCo2EquivalentBreakdown() {
|
|
127
90
|
if (this.isEmpty()) {
|
|
128
91
|
return null;
|
|
129
92
|
}
|
|
130
93
|
return __classPrivateFieldGet(this, _EmissionAggregationGhgBreakdown_ghgBreakdowns, "f").reduce((max, current) => (current.co2Equivalent > max.co2Equivalent ? current : max));
|
|
131
94
|
}
|
|
132
|
-
/**
|
|
133
|
-
* Obtiene el breakdown con menor CO2 equivalente.
|
|
134
|
-
*/
|
|
135
95
|
getLowestCo2EquivalentBreakdown() {
|
|
136
96
|
if (this.isEmpty()) {
|
|
137
97
|
return null;
|
|
138
98
|
}
|
|
139
99
|
return __classPrivateFieldGet(this, _EmissionAggregationGhgBreakdown_ghgBreakdowns, "f").reduce((min, current) => (current.co2Equivalent < min.co2Equivalent ? current : min));
|
|
140
100
|
}
|
|
141
|
-
/**
|
|
142
|
-
* Filtra breakdowns por umbral mínimo de porcentaje.
|
|
143
|
-
*/
|
|
144
101
|
getBreakdownsAbovePercentage(threshold) {
|
|
145
102
|
return __classPrivateFieldGet(this, _EmissionAggregationGhgBreakdown_ghgBreakdowns, "f").filter((breakdown) => breakdown.percentage >= threshold);
|
|
146
103
|
}
|
|
147
|
-
/**
|
|
148
|
-
* Obtiene los N breakdowns con mayor CO2 equivalente.
|
|
149
|
-
*/
|
|
150
104
|
getTopNBreakdowns(count) {
|
|
151
105
|
if (count <= 0) {
|
|
152
106
|
return [];
|
|
@@ -155,30 +109,21 @@ class EmissionAggregationGhgBreakdown extends ValueObject_1.ValueObject {
|
|
|
155
109
|
.sort((a, b) => b.co2Equivalent - a.co2Equivalent)
|
|
156
110
|
.slice(0, count);
|
|
157
111
|
}
|
|
158
|
-
/**
|
|
159
|
-
* Verifica si contiene todos los gases principales (CO2, CH4, N2O).
|
|
160
|
-
*/
|
|
161
112
|
hasMainGreenhouseGases() {
|
|
162
|
-
const
|
|
163
|
-
return
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
getMissingGases(requiredGases) {
|
|
169
|
-
return requiredGases.filter((gas) => !this.hasBreakdownForGas(gas));
|
|
170
|
-
}
|
|
171
|
-
/**
|
|
172
|
-
* Obtiene estadísticas de los breakdowns.
|
|
173
|
-
*/
|
|
113
|
+
const presentCategories = new Set(this.getAllCategories());
|
|
114
|
+
return _a.MAIN_GAS_CATEGORIES.every((category) => presentCategories.has(category));
|
|
115
|
+
}
|
|
116
|
+
getMissingSpecies(requiredSpecies) {
|
|
117
|
+
return requiredSpecies.filter((species) => !this.hasBreakdownForSpecies(species));
|
|
118
|
+
}
|
|
174
119
|
getStatistics() {
|
|
175
120
|
if (this.isEmpty()) {
|
|
176
121
|
return {
|
|
177
122
|
totalCo2Equivalent: 0,
|
|
178
123
|
averagePercentage: 0,
|
|
179
124
|
gasCount: 0,
|
|
180
|
-
|
|
181
|
-
|
|
125
|
+
highestSpecies: null,
|
|
126
|
+
lowestSpecies: null,
|
|
182
127
|
};
|
|
183
128
|
}
|
|
184
129
|
const highest = this.getHighestCo2EquivalentBreakdown();
|
|
@@ -187,36 +132,25 @@ class EmissionAggregationGhgBreakdown extends ValueObject_1.ValueObject {
|
|
|
187
132
|
totalCo2Equivalent: this.getTotalCo2Equivalent(),
|
|
188
133
|
averagePercentage: __classPrivateFieldGet(this, _EmissionAggregationGhgBreakdown_ghgBreakdowns, "f").reduce((sum, b) => sum + b.percentage, 0) / this.length,
|
|
189
134
|
gasCount: this.length,
|
|
190
|
-
|
|
191
|
-
|
|
135
|
+
highestSpecies: highest?.greenhouseGasSpecies || null,
|
|
136
|
+
lowestSpecies: lowest?.greenhouseGasSpecies || null,
|
|
192
137
|
};
|
|
193
138
|
}
|
|
194
|
-
/**
|
|
195
|
-
* Convierte a representación primitiva para persistencia.
|
|
196
|
-
*/
|
|
197
139
|
toPrimitives() {
|
|
198
140
|
return __classPrivateFieldGet(this, _EmissionAggregationGhgBreakdown_ghgBreakdowns, "f").map((breakdown) => ({
|
|
199
|
-
|
|
141
|
+
greenhouseGasCategory: breakdown.greenhouseGasCategory,
|
|
142
|
+
greenhouseGasSpecies: breakdown.greenhouseGasSpecies,
|
|
200
143
|
co2Equivalent: breakdown.co2Equivalent,
|
|
201
144
|
percentage: breakdown.percentage,
|
|
202
145
|
unit: breakdown.unit,
|
|
203
146
|
}));
|
|
204
147
|
}
|
|
205
|
-
/**
|
|
206
|
-
* Representación JSON para serialización.
|
|
207
|
-
*/
|
|
208
148
|
toJSON() {
|
|
209
149
|
return this.toPrimitives();
|
|
210
150
|
}
|
|
211
|
-
/**
|
|
212
|
-
* Convierte a tipos de dominio.
|
|
213
|
-
*/
|
|
214
151
|
toEnums() {
|
|
215
152
|
return [...__classPrivateFieldGet(this, _EmissionAggregationGhgBreakdown_ghgBreakdowns, "f")];
|
|
216
153
|
}
|
|
217
|
-
/**
|
|
218
|
-
* Método estático para validar si un array es válido.
|
|
219
|
-
*/
|
|
220
154
|
static isValidGhgBreakdowns(value, options = _a.OPTIONS) {
|
|
221
155
|
try {
|
|
222
156
|
const finalOptions = { ..._a.OPTIONS, ...options };
|
|
@@ -237,25 +171,26 @@ _a = EmissionAggregationGhgBreakdown, _EmissionAggregationGhgBreakdown_ghgBreakd
|
|
|
237
171
|
if (!options.allowEmpty && value.length === 0) {
|
|
238
172
|
throw InvalidPropertyValueError_1.InvalidPropertyValueError.create(propertyName, 'non-empty array', 'empty array');
|
|
239
173
|
}
|
|
240
|
-
},
|
|
241
|
-
const
|
|
242
|
-
const
|
|
243
|
-
if (
|
|
244
|
-
throw InvalidPropertyValueError_1.InvalidPropertyValueError.create(`${propertyName}.
|
|
174
|
+
}, _EmissionAggregationGhgBreakdown_guardAgainstDuplicateSpecies = function _EmissionAggregationGhgBreakdown_guardAgainstDuplicateSpecies(value, propertyName) {
|
|
175
|
+
const species = value.map((breakdown) => GreenhouseGasSpecies_1.GreenhouseGasSpecies.normalize(breakdown.greenhouseGasSpecies));
|
|
176
|
+
const uniqueSpecies = new Set(species);
|
|
177
|
+
if (species.length !== uniqueSpecies.size) {
|
|
178
|
+
throw InvalidPropertyValueError_1.InvalidPropertyValueError.create(`${propertyName}.greenhouseGasSpecies`, 'unique greenhouse gas species', 'duplicate species found');
|
|
245
179
|
}
|
|
246
180
|
}, _EmissionAggregationGhgBreakdown_guardAgainstInvalidTotalPercentage = function _EmissionAggregationGhgBreakdown_guardAgainstInvalidTotalPercentage(value, propertyName) {
|
|
247
181
|
if (value.length === 0) {
|
|
248
|
-
return;
|
|
182
|
+
return;
|
|
249
183
|
}
|
|
250
184
|
const totalPercentage = value.reduce((sum, breakdown) => sum + breakdown.percentage, 0);
|
|
251
|
-
const tolerance = 0.01;
|
|
185
|
+
const tolerance = 0.01;
|
|
252
186
|
if (Math.abs(totalPercentage - 100) > tolerance) {
|
|
253
187
|
throw InvalidPropertyValueError_1.InvalidPropertyValueError.create(`${propertyName}.percentage`, 'total percentage should be approximately 100%', `total percentage is ${totalPercentage.toFixed(2)}%`);
|
|
254
188
|
}
|
|
255
189
|
}, _EmissionAggregationGhgBreakdown_guardAgainstInvalidGhgBreakdown = function _EmissionAggregationGhgBreakdown_guardAgainstInvalidGhgBreakdown(ghgBreakdown, index, basePropertyName) {
|
|
256
190
|
const propertyName = `${basePropertyName}[${index}]`;
|
|
257
191
|
__classPrivateFieldGet(this, _a, "m", _EmissionAggregationGhgBreakdown_guardAgainstInvalidGhgStructure).call(this, ghgBreakdown, propertyName);
|
|
258
|
-
__classPrivateFieldGet(this, _a, "m",
|
|
192
|
+
__classPrivateFieldGet(this, _a, "m", _EmissionAggregationGhgBreakdown_guardAgainstInvalidCategory).call(this, ghgBreakdown.greenhouseGasCategory, `${propertyName}.greenhouseGasCategory`);
|
|
193
|
+
GreenhouseGasSpecies_1.GreenhouseGasSpecies.create(ghgBreakdown.greenhouseGasSpecies);
|
|
259
194
|
__classPrivateFieldGet(this, _a, "m", _EmissionAggregationGhgBreakdown_guardAgainstInvalidCo2Equivalent).call(this, ghgBreakdown.co2Equivalent, `${propertyName}.co2Equivalent`);
|
|
260
195
|
__classPrivateFieldGet(this, _a, "m", _EmissionAggregationGhgBreakdown_guardAgainstInvalidPercentage).call(this, ghgBreakdown.percentage, `${propertyName}.percentage`);
|
|
261
196
|
__classPrivateFieldGet(this, _a, "m", _EmissionAggregationGhgBreakdown_guardAgainstInvalidUnit).call(this, ghgBreakdown.unit, `${propertyName}.unit`);
|
|
@@ -263,8 +198,11 @@ _a = EmissionAggregationGhgBreakdown, _EmissionAggregationGhgBreakdown_ghgBreakd
|
|
|
263
198
|
if (!ghgBreakdown || typeof ghgBreakdown !== 'object') {
|
|
264
199
|
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(propertyName, 'GHGBreakdown object', typeof ghgBreakdown);
|
|
265
200
|
}
|
|
266
|
-
if (typeof ghgBreakdown.
|
|
267
|
-
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(`${propertyName}.
|
|
201
|
+
if (typeof ghgBreakdown.greenhouseGasCategory !== 'string') {
|
|
202
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(`${propertyName}.greenhouseGasCategory`, 'string', typeof ghgBreakdown.greenhouseGasCategory);
|
|
203
|
+
}
|
|
204
|
+
if (typeof ghgBreakdown.greenhouseGasSpecies !== 'string') {
|
|
205
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(`${propertyName}.greenhouseGasSpecies`, 'string', typeof ghgBreakdown.greenhouseGasSpecies);
|
|
268
206
|
}
|
|
269
207
|
if (typeof ghgBreakdown.co2Equivalent !== 'number') {
|
|
270
208
|
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(`${propertyName}.co2Equivalent`, 'number', typeof ghgBreakdown.co2Equivalent);
|
|
@@ -275,10 +213,10 @@ _a = EmissionAggregationGhgBreakdown, _EmissionAggregationGhgBreakdown_ghgBreakd
|
|
|
275
213
|
if (typeof ghgBreakdown.unit !== 'string') {
|
|
276
214
|
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(`${propertyName}.unit`, 'string', typeof ghgBreakdown.unit);
|
|
277
215
|
}
|
|
278
|
-
},
|
|
279
|
-
const
|
|
280
|
-
if (!
|
|
281
|
-
throw InvalidPropertyValueError_1.InvalidPropertyValueError.create(propertyName, 'valid
|
|
216
|
+
}, _EmissionAggregationGhgBreakdown_guardAgainstInvalidCategory = function _EmissionAggregationGhgBreakdown_guardAgainstInvalidCategory(category, propertyName) {
|
|
217
|
+
const validCategories = Object.values(GreenhouseGasCategory_1.GreenhouseGasCategory);
|
|
218
|
+
if (!validCategories.includes(category)) {
|
|
219
|
+
throw InvalidPropertyValueError_1.InvalidPropertyValueError.create(propertyName, 'valid GreenhouseGasCategory', category);
|
|
282
220
|
}
|
|
283
221
|
}, _EmissionAggregationGhgBreakdown_guardAgainstInvalidCo2Equivalent = function _EmissionAggregationGhgBreakdown_guardAgainstInvalidCo2Equivalent(co2Equivalent, propertyName) {
|
|
284
222
|
Numeric_1.Numeric.guardAgainstInvalidType(co2Equivalent, propertyName);
|
|
@@ -296,3 +234,8 @@ EmissionAggregationGhgBreakdown.PROPERTY_NAME = 'ghgBreakdown';
|
|
|
296
234
|
EmissionAggregationGhgBreakdown.OPTIONS = {
|
|
297
235
|
allowEmpty: true,
|
|
298
236
|
};
|
|
237
|
+
EmissionAggregationGhgBreakdown.MAIN_GAS_CATEGORIES = [
|
|
238
|
+
GreenhouseGasCategory_1.GreenhouseGasCategory.CO2,
|
|
239
|
+
GreenhouseGasCategory_1.GreenhouseGasCategory.CH4,
|
|
240
|
+
GreenhouseGasCategory_1.GreenhouseGasCategory.N2O,
|
|
241
|
+
];
|
|
@@ -40,7 +40,7 @@ class GHGEmissionResult extends AggregateRoot_1.AggregateRoot {
|
|
|
40
40
|
if (skipDomainValidation === false) {
|
|
41
41
|
// Initialize with domain validation
|
|
42
42
|
__classPrivateFieldSet(this, _GHGEmissionResult_emissionCalculation, GHGEmissionResultEmissionCalculation_1.GHGEmissionResultEmissionCalculation.create(props.emissionCalculation), "f");
|
|
43
|
-
__classPrivateFieldSet(this, _GHGEmissionResult_greenhouseGas, GHGEmissionResultGreenhouseGas_1.GHGEmissionResultGreenhouseGas.create(props.
|
|
43
|
+
__classPrivateFieldSet(this, _GHGEmissionResult_greenhouseGas, GHGEmissionResultGreenhouseGas_1.GHGEmissionResultGreenhouseGas.create(props.greenhouseGasCategory, props.greenhouseGasSpecies), "f");
|
|
44
44
|
__classPrivateFieldSet(this, _GHGEmissionResult_activityValue, GHGEmissionResultActivityValue_1.GHGEmissionResultActivityValue.create(props.activityValue), "f");
|
|
45
45
|
__classPrivateFieldSet(this, _GHGEmissionResult_emissionFactor, GHGEmissionResultEmissionFactor_1.GHGEmissionResultEmissionFactor.create(props.emissionFactor), "f");
|
|
46
46
|
__classPrivateFieldSet(this, _GHGEmissionResult_globalWarmingPotential, GHGEmissionResultGlobalWarmingPotential_1.GHGEmissionResultGlobalWarmingPotential.create(props.globalWarmingPotential), "f");
|
|
@@ -51,7 +51,10 @@ class GHGEmissionResult extends AggregateRoot_1.AggregateRoot {
|
|
|
51
51
|
else {
|
|
52
52
|
// Initialize from primitives (no domain validation)
|
|
53
53
|
__classPrivateFieldSet(this, _GHGEmissionResult_emissionCalculation, GHGEmissionResultEmissionCalculation_1.GHGEmissionResultEmissionCalculation.fromPrimitives(props.emissionCalculation), "f");
|
|
54
|
-
__classPrivateFieldSet(this, _GHGEmissionResult_greenhouseGas, GHGEmissionResultGreenhouseGas_1.GHGEmissionResultGreenhouseGas.fromPrimitives(
|
|
54
|
+
__classPrivateFieldSet(this, _GHGEmissionResult_greenhouseGas, GHGEmissionResultGreenhouseGas_1.GHGEmissionResultGreenhouseGas.fromPrimitives({
|
|
55
|
+
greenhouseGasCategory: props.greenhouseGasCategory,
|
|
56
|
+
greenhouseGasSpecies: props.greenhouseGasSpecies,
|
|
57
|
+
}), "f");
|
|
55
58
|
__classPrivateFieldSet(this, _GHGEmissionResult_activityValue, GHGEmissionResultActivityValue_1.GHGEmissionResultActivityValue.fromPrimitives(props.activityValue), "f");
|
|
56
59
|
__classPrivateFieldSet(this, _GHGEmissionResult_emissionFactor, GHGEmissionResultEmissionFactor_1.GHGEmissionResultEmissionFactor.fromPrimitives(props.emissionFactor), "f");
|
|
57
60
|
__classPrivateFieldSet(this, _GHGEmissionResult_globalWarmingPotential, GHGEmissionResultGlobalWarmingPotential_1.GHGEmissionResultGlobalWarmingPotential.fromPrimitives(props.globalWarmingPotential), "f");
|
|
@@ -67,7 +70,8 @@ class GHGEmissionResult extends AggregateRoot_1.AggregateRoot {
|
|
|
67
70
|
const props = {
|
|
68
71
|
id: primitives.id,
|
|
69
72
|
emissionCalculation: primitives.emissionCalculation,
|
|
70
|
-
|
|
73
|
+
greenhouseGasCategory: primitives.greenhouseGasCategory,
|
|
74
|
+
greenhouseGasSpecies: primitives.greenhouseGasSpecies,
|
|
71
75
|
activityValue: primitives.activityValue,
|
|
72
76
|
emissionFactor: primitives.emissionFactor,
|
|
73
77
|
globalWarmingPotential: primitives.globalWarmingPotential,
|
|
@@ -81,7 +85,8 @@ class GHGEmissionResult extends AggregateRoot_1.AggregateRoot {
|
|
|
81
85
|
return {
|
|
82
86
|
id: this.id.toPrimitives(),
|
|
83
87
|
emissionCalculation: __classPrivateFieldGet(this, _GHGEmissionResult_emissionCalculation, "f").toPrimitives(),
|
|
84
|
-
|
|
88
|
+
greenhouseGasCategory: __classPrivateFieldGet(this, _GHGEmissionResult_greenhouseGas, "f").category,
|
|
89
|
+
greenhouseGasSpecies: __classPrivateFieldGet(this, _GHGEmissionResult_greenhouseGas, "f").species,
|
|
85
90
|
activityValue: __classPrivateFieldGet(this, _GHGEmissionResult_activityValue, "f").toPrimitives(),
|
|
86
91
|
emissionFactor: __classPrivateFieldGet(this, _GHGEmissionResult_emissionFactor, "f").toPrimitives(),
|
|
87
92
|
globalWarmingPotential: __classPrivateFieldGet(this, _GHGEmissionResult_globalWarmingPotential, "f").toPrimitives(),
|
|
@@ -1,184 +1,68 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.GHGEmissionResultGreenhouseGas = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
4
|
+
const ValueObject_1 = require("../../../../shared/domain/value-objects/ValueObject");
|
|
5
|
+
const GreenhouseGasCategory_1 = require("../../../../shared/domain/enums/GreenhouseGasCategory");
|
|
6
|
+
const GreenhouseGasSpecies_1 = require("../../../../shared/domain/value-objects/GreenhouseGasSpecies");
|
|
6
7
|
const InvalidGreenhouseGasTypeError_1 = require("../../../../emission-calculation-formulas/domain/exceptions/InvalidGreenhouseGasTypeError");
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
/**
|
|
9
|
+
* Identidad del gas en un resultado de emisión: categoría (canasta de Kyoto) + especie concreta.
|
|
10
|
+
* El cálculo produce un resultado por especie; la categoría viaja al lado para agregación/reporte.
|
|
11
|
+
* La lógica de categorización (fluorinated/main-gases) opera sobre categoría, no sobre la especie.
|
|
12
|
+
*/
|
|
13
|
+
class GHGEmissionResultGreenhouseGas extends ValueObject_1.ValueObject {
|
|
9
14
|
constructor(value, skipDomainValidation) {
|
|
10
|
-
super(value, skipDomainValidation, GHGEmissionResultGreenhouseGas.PROPERTY_NAME);
|
|
15
|
+
super(value, skipDomainValidation, GHGEmissionResultGreenhouseGas.PROPERTY_NAME, 'The provided value must be a { greenhouseGasCategory, greenhouseGasSpecies } from the domain layer', { allowNull: false, allowUndefined: false });
|
|
11
16
|
if (skipDomainValidation === false) {
|
|
12
|
-
|
|
17
|
+
GHGEmissionResultGreenhouseGas.guardAgainstInvalidCategory(value.greenhouseGasCategory);
|
|
13
18
|
}
|
|
14
19
|
}
|
|
15
|
-
static create(
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
return new GHGEmissionResultGreenhouseGas(
|
|
20
|
+
static create(category, species) {
|
|
21
|
+
GHGEmissionResultGreenhouseGas.guardAgainstInvalidCategory(category);
|
|
22
|
+
const normalizedSpecies = GreenhouseGasSpecies_1.GreenhouseGasSpecies.create(species).toPrimitives();
|
|
23
|
+
return new GHGEmissionResultGreenhouseGas({ greenhouseGasCategory: category, greenhouseGasSpecies: normalizedSpecies }, false);
|
|
19
24
|
}
|
|
20
|
-
static fromPrimitives(
|
|
21
|
-
|
|
22
|
-
return new GHGEmissionResultGreenhouseGas(value, true);
|
|
25
|
+
static fromPrimitives(primitives) {
|
|
26
|
+
return new GHGEmissionResultGreenhouseGas(primitives, true);
|
|
23
27
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
validateGreenhouseGas(value) {
|
|
28
|
-
if (!GHGEmissionResultGreenhouseGas.VALID_GREENHOUSE_GASES.includes(value)) {
|
|
29
|
-
throw InvalidGreenhouseGasTypeError_1.InvalidGreenhouseGasTypeError.create(GHGEmissionResultGreenhouseGas.PROPERTY_NAME, GHGEmissionResultGreenhouseGas.VALID_GREENHOUSE_GASES, value);
|
|
28
|
+
static guardAgainstInvalidCategory(category) {
|
|
29
|
+
if (!Object.values(GreenhouseGasCategory_1.GreenhouseGasCategory).includes(category)) {
|
|
30
|
+
throw InvalidGreenhouseGasTypeError_1.InvalidGreenhouseGasTypeError.create(GHGEmissionResultGreenhouseGas.PROPERTY_NAME, Object.values(GreenhouseGasCategory_1.GreenhouseGasCategory), category);
|
|
30
31
|
}
|
|
31
32
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
*/
|
|
35
|
-
isCO2() {
|
|
36
|
-
return this.value === GreenhouseGas_1.GreenhouseGas.CO2;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Verifica si es CH4 (Metano).
|
|
40
|
-
*/
|
|
41
|
-
isCH4() {
|
|
42
|
-
return this.value === GreenhouseGas_1.GreenhouseGas.CH4;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Verifica si es N2O (Óxido Nitroso).
|
|
46
|
-
*/
|
|
47
|
-
isN2O() {
|
|
48
|
-
return this.value === GreenhouseGas_1.GreenhouseGas.N2O;
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Verifica si es HFC (Hidrofluorocarbonos).
|
|
52
|
-
*/
|
|
53
|
-
isHFC() {
|
|
54
|
-
return this.value === GreenhouseGas_1.GreenhouseGas.HFC;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* Verifica si es PFC (Perfluorocarbonos).
|
|
58
|
-
*/
|
|
59
|
-
isPFC() {
|
|
60
|
-
return this.value === GreenhouseGas_1.GreenhouseGas.PFC;
|
|
33
|
+
get category() {
|
|
34
|
+
return this.value.greenhouseGasCategory;
|
|
61
35
|
}
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
*/
|
|
65
|
-
isSF6() {
|
|
66
|
-
return this.value === GreenhouseGas_1.GreenhouseGas.SF6;
|
|
36
|
+
get species() {
|
|
37
|
+
return this.value.greenhouseGasSpecies;
|
|
67
38
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
*/
|
|
71
|
-
isNF3() {
|
|
72
|
-
return this.value === GreenhouseGas_1.GreenhouseGas.NF3;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Verifica si es HFC134a (Hidrofluorocarbono específico).
|
|
76
|
-
*/
|
|
77
|
-
isHFC134a() {
|
|
78
|
-
return this.value === GreenhouseGas_1.GreenhouseGas.HFC134a;
|
|
79
|
-
}
|
|
80
|
-
/**
|
|
81
|
-
* Obtiene los gases de efecto invernadero válidos.
|
|
82
|
-
*/
|
|
83
|
-
static getValidGreenhouseGases() {
|
|
84
|
-
return Object.freeze([...GHGEmissionResultGreenhouseGas.VALID_GREENHOUSE_GASES]);
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Verifica si un valor es un gas de efecto invernadero válido.
|
|
88
|
-
*/
|
|
89
|
-
static isValidGreenhouseGas(value) {
|
|
90
|
-
return GHGEmissionResultGreenhouseGas.VALID_GREENHOUSE_GASES.includes(value);
|
|
39
|
+
isCO2() {
|
|
40
|
+
return this.category === GreenhouseGasCategory_1.GreenhouseGasCategory.CO2;
|
|
91
41
|
}
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
*/
|
|
95
|
-
isKyotoProtocolGas() {
|
|
96
|
-
return this.isCO2() || this.isCH4() || this.isN2O() || this.isHFC() || this.isPFC() || this.isSF6();
|
|
42
|
+
isMainGas() {
|
|
43
|
+
return GHGEmissionResultGreenhouseGas.MAIN_GAS_CATEGORIES.includes(this.category);
|
|
97
44
|
}
|
|
98
|
-
/**
|
|
99
|
-
* Verifica si es un gas fluorado (HFC, PFC, SF6, NF3, HFC134a).
|
|
100
|
-
*/
|
|
101
45
|
isFluorinatedGas() {
|
|
102
|
-
return
|
|
103
|
-
}
|
|
104
|
-
/**
|
|
105
|
-
* Verifica si es un gas con alto potencial de calentamiento global (todos excepto CO2).
|
|
106
|
-
*/
|
|
107
|
-
isHighGWPGas() {
|
|
108
|
-
return !this.isCO2();
|
|
109
|
-
}
|
|
110
|
-
/**
|
|
111
|
-
* Obtiene el tipo de gas según su categoría.
|
|
112
|
-
*/
|
|
113
|
-
getGasCategory() {
|
|
114
|
-
if (this.isCO2() || this.isCH4() || this.isN2O())
|
|
115
|
-
return 'natural';
|
|
116
|
-
if (this.isHFC134a())
|
|
117
|
-
return 'specific_hfc';
|
|
118
|
-
if (this.isFluorinatedGas())
|
|
119
|
-
return 'fluorinated';
|
|
120
|
-
// Este caso nunca debería ocurrir debido a las validaciones
|
|
121
|
-
throw UnknownGreenhouseGasCategoryError_1.UnknownGreenhouseGasCategoryError.create(this.value);
|
|
122
|
-
}
|
|
123
|
-
/**
|
|
124
|
-
* Verifica si requiere medición específica de GWP.
|
|
125
|
-
*/
|
|
126
|
-
requiresSpecificGWP() {
|
|
127
|
-
// Los gases fluorados generalmente requieren GWP específico
|
|
128
|
-
return this.isFluorinatedGas();
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Obtiene la descripción del gas de efecto invernadero.
|
|
132
|
-
*/
|
|
133
|
-
getDescription() {
|
|
134
|
-
const descriptions = {
|
|
135
|
-
[GreenhouseGas_1.GreenhouseGas.CO2]: 'Dióxido de Carbono - Principal gas de efecto invernadero',
|
|
136
|
-
[GreenhouseGas_1.GreenhouseGas.CH4]: 'Metano - Gas de efecto invernadero con alto potencial de calentamiento',
|
|
137
|
-
[GreenhouseGas_1.GreenhouseGas.N2O]: 'Óxido Nitroso - Gas de efecto invernadero de larga duración',
|
|
138
|
-
[GreenhouseGas_1.GreenhouseGas.HFC]: 'Hidrofluorocarbonos - Gases sintéticos con alto GWP',
|
|
139
|
-
[GreenhouseGas_1.GreenhouseGas.PFC]: 'Perfluorocarbonos - Gases sintéticos de muy larga duración',
|
|
140
|
-
[GreenhouseGas_1.GreenhouseGas.SF6]: 'Hexafluoruro de Azufre - Gas con el GWP más alto',
|
|
141
|
-
[GreenhouseGas_1.GreenhouseGas.NF3]: 'Trifluoruro de Nitrógeno - Gas industrial con alto GWP',
|
|
142
|
-
[GreenhouseGas_1.GreenhouseGas.HFC134a]: 'HFC-134a - Hidrofluorocarbono específico usado en refrigeración',
|
|
143
|
-
};
|
|
144
|
-
return descriptions[this.value] || this.value;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Obtiene las características principales del gas.
|
|
148
|
-
*/
|
|
149
|
-
getCharacteristics() {
|
|
150
|
-
return {
|
|
151
|
-
isKyotoProtocolGas: this.isKyotoProtocolGas(),
|
|
152
|
-
isFluorinatedGas: this.isFluorinatedGas(),
|
|
153
|
-
isHighGWPGas: this.isHighGWPGas(),
|
|
154
|
-
requiresSpecificGWP: this.requiresSpecificGWP(),
|
|
155
|
-
category: this.getGasCategory(),
|
|
156
|
-
};
|
|
46
|
+
return GHGEmissionResultGreenhouseGas.FLUORINATED_CATEGORIES.includes(this.category);
|
|
157
47
|
}
|
|
158
48
|
toPrimitives() {
|
|
159
|
-
return
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
return this.value;
|
|
163
|
-
}
|
|
164
|
-
/**
|
|
165
|
-
* Representación como string descriptiva.
|
|
166
|
-
*/
|
|
167
|
-
toString() {
|
|
168
|
-
const gasNames = {
|
|
169
|
-
[GreenhouseGas_1.GreenhouseGas.CO2]: 'CO₂',
|
|
170
|
-
[GreenhouseGas_1.GreenhouseGas.CH4]: 'CH₄',
|
|
171
|
-
[GreenhouseGas_1.GreenhouseGas.N2O]: 'N₂O',
|
|
172
|
-
[GreenhouseGas_1.GreenhouseGas.HFC]: 'HFC',
|
|
173
|
-
[GreenhouseGas_1.GreenhouseGas.PFC]: 'PFC',
|
|
174
|
-
[GreenhouseGas_1.GreenhouseGas.SF6]: 'SF₆',
|
|
175
|
-
[GreenhouseGas_1.GreenhouseGas.NF3]: 'NF₃',
|
|
176
|
-
[GreenhouseGas_1.GreenhouseGas.HFC134a]: 'HFC-134a',
|
|
49
|
+
return {
|
|
50
|
+
greenhouseGasCategory: this.value.greenhouseGasCategory,
|
|
51
|
+
greenhouseGasSpecies: this.value.greenhouseGasSpecies,
|
|
177
52
|
};
|
|
178
|
-
return gasNames[this.value] || this.value;
|
|
179
53
|
}
|
|
180
54
|
}
|
|
181
55
|
exports.GHGEmissionResultGreenhouseGas = GHGEmissionResultGreenhouseGas;
|
|
182
56
|
GHGEmissionResultGreenhouseGas.PROPERTY_NAME = 'greenhouseGas';
|
|
183
|
-
|
|
184
|
-
|
|
57
|
+
GHGEmissionResultGreenhouseGas.MAIN_GAS_CATEGORIES = [
|
|
58
|
+
GreenhouseGasCategory_1.GreenhouseGasCategory.CO2,
|
|
59
|
+
GreenhouseGasCategory_1.GreenhouseGasCategory.CH4,
|
|
60
|
+
GreenhouseGasCategory_1.GreenhouseGasCategory.N2O,
|
|
61
|
+
];
|
|
62
|
+
GHGEmissionResultGreenhouseGas.FLUORINATED_CATEGORIES = [
|
|
63
|
+
GreenhouseGasCategory_1.GreenhouseGasCategory.HFC,
|
|
64
|
+
GreenhouseGasCategory_1.GreenhouseGasCategory.PFC,
|
|
65
|
+
GreenhouseGasCategory_1.GreenhouseGasCategory.SF6,
|
|
66
|
+
GreenhouseGasCategory_1.GreenhouseGasCategory.NF3,
|
|
67
|
+
GreenhouseGasCategory_1.GreenhouseGasCategory.HCFC,
|
|
68
|
+
];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.GreenhouseGasCategory = void 0;
|
|
4
|
+
var GreenhouseGasCategory;
|
|
5
|
+
(function (GreenhouseGasCategory) {
|
|
6
|
+
GreenhouseGasCategory["CO2"] = "CO2";
|
|
7
|
+
GreenhouseGasCategory["CH4"] = "CH4";
|
|
8
|
+
GreenhouseGasCategory["N2O"] = "N2O";
|
|
9
|
+
GreenhouseGasCategory["HFC"] = "HFC";
|
|
10
|
+
GreenhouseGasCategory["PFC"] = "PFC";
|
|
11
|
+
GreenhouseGasCategory["SF6"] = "SF6";
|
|
12
|
+
GreenhouseGasCategory["NF3"] = "NF3";
|
|
13
|
+
GreenhouseGasCategory["HCFC"] = "HCFC";
|
|
14
|
+
GreenhouseGasCategory["OTHER"] = "OTHER";
|
|
15
|
+
})(GreenhouseGasCategory || (exports.GreenhouseGasCategory = GreenhouseGasCategory = {}));
|