@carbonbox/domain 0.7.22 → 0.7.23
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/corporate-segment-configurations/domain/value-objects/CorporateCarbonFootprintSegmentConfigurationSegment.js +0 -2
- package/build/carbonbox/carbon-footprint-configurations/corporate-configurations/corporate-segment-configurations/segments/domain/value-objects/CorporateConfigurationCarbonFootprintSegmentIncludedSubsegments.js +0 -2
- package/build/carbonbox/carbon-footprint-configurations/event-configurations/event-edition-lifecycle-stage-configurations/domain/value-objects/EventEditionLifecycleStageConfigurationStage.js +0 -2
- package/build/carbonbox/carbon-footprint-configurations/event-configurations/event-edition-lifecycle-stage-configurations/event-edition-lifecycle-stages/domain/value-objects/EventEditionLifecycleStageIncludedSubsegments.js +0 -2
- package/build/carbonbox/carbon-footprint-configurations/product-configurations/product-segment-configurations/domain/value-objects/ProductCarbonFootprintSegmentConfigurationSegment.js +0 -2
- package/build/carbonbox/carbon-footprint-configurations/product-configurations/product-segment-configurations/segments/domain/value-objects/ProductConfigurationCarbonFootprintSegmentIncludedSubsegments.js +0 -2
- package/build/carbonbox/shared/domain/value-objects/CarbonFootprintSegmentReferences.js +16 -103
- package/build/carbonbox/shared/domain/value-objects/CorporateCarbonFootprintSegmentConfigurationReferences.js +15 -29
- package/build/carbonbox/shared/domain/value-objects/CorporateConfigurationCarbonFootprintSegmentReference.js +6 -131
- package/build/carbonbox/shared/domain/value-objects/CorporateConfigurationCarbonFootprintSubsegmentReference.js +6 -131
- package/build/carbonbox/shared/domain/value-objects/EventEditionConfigurationCarbonFootprintSubsegmentReference.js +7 -149
- package/build/carbonbox/shared/domain/value-objects/EventEditionConfigurationCarbonFootprintSubsegmentReferences.js +9 -165
- package/build/carbonbox/shared/domain/value-objects/EventEditionLifecycleStageConfigurationReferences.js +42 -50
- package/build/carbonbox/shared/domain/value-objects/EventEditionLifecycleStageReference.js +8 -112
- package/build/carbonbox/shared/domain/value-objects/NullableCorporateConfigurationCarbonFootprintSubsegmentReference.js +11 -136
- package/build/carbonbox/shared/domain/value-objects/NullableEventEditionConfigurationCarbonFootprintSubsegmentReference.js +11 -168
- package/build/carbonbox/shared/domain/value-objects/NullableProductConfigurationCarbonFootprintSubsegmentReference.js +11 -136
- package/build/carbonbox/shared/domain/value-objects/ProductCarbonFootprintSegmentConfigurationReferences.js +35 -56
- package/build/carbonbox/shared/domain/value-objects/ProductConfigurationCarbonFootprintSegmentReference.js +6 -172
- package/build/carbonbox/shared/domain/value-objects/ProductConfigurationCarbonFootprintSubsegmentReference.js +6 -172
- package/build/types/carbonbox/carbon-footprint-configurations/corporate-configurations/corporate-segment-configurations/domain/value-objects/CorporateCarbonFootprintSegmentConfigurationSegment.d.ts.map +1 -1
- package/build/types/carbonbox/carbon-footprint-configurations/corporate-configurations/corporate-segment-configurations/segments/domain/value-objects/CorporateConfigurationCarbonFootprintSegmentIncludedSubsegments.d.ts.map +1 -1
- package/build/types/carbonbox/carbon-footprint-configurations/event-configurations/event-edition-lifecycle-stage-configurations/domain/value-objects/EventEditionLifecycleStageConfigurationStage.d.ts.map +1 -1
- package/build/types/carbonbox/carbon-footprint-configurations/event-configurations/event-edition-lifecycle-stage-configurations/event-edition-lifecycle-stages/domain/value-objects/EventEditionLifecycleStageIncludedSubsegments.d.ts.map +1 -1
- package/build/types/carbonbox/carbon-footprint-configurations/product-configurations/product-segment-configurations/domain/value-objects/ProductCarbonFootprintSegmentConfigurationSegment.d.ts.map +1 -1
- package/build/types/carbonbox/carbon-footprint-configurations/product-configurations/product-segment-configurations/segments/domain/value-objects/ProductConfigurationCarbonFootprintSegmentIncludedSubsegments.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/types/CorporateConfigurationCarbonFootprintSegmentReference.d.ts +0 -2
- package/build/types/carbonbox/shared/domain/types/CorporateConfigurationCarbonFootprintSegmentReference.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/types/CorporateConfigurationCarbonFootprintSegmentReferencePrimitives.d.ts +0 -2
- package/build/types/carbonbox/shared/domain/types/CorporateConfigurationCarbonFootprintSegmentReferencePrimitives.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/types/CorporateConfigurationCarbonFootprintSubsegmentReference.d.ts +0 -2
- package/build/types/carbonbox/shared/domain/types/CorporateConfigurationCarbonFootprintSubsegmentReference.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/types/CorporateConfigurationCarbonFootprintSubsegmentReferencePrimitives.d.ts +0 -2
- package/build/types/carbonbox/shared/domain/types/CorporateConfigurationCarbonFootprintSubsegmentReferencePrimitives.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/types/EventEditionConfigurationCarbonFootprintSubsegmentReference.d.ts +0 -2
- package/build/types/carbonbox/shared/domain/types/EventEditionConfigurationCarbonFootprintSubsegmentReference.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/types/EventEditionConfigurationCarbonFootprintSubsegmentReferencePrimitives.d.ts +0 -2
- package/build/types/carbonbox/shared/domain/types/EventEditionConfigurationCarbonFootprintSubsegmentReferencePrimitives.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/types/EventEditionLifecycleStageReference.d.ts +0 -2
- package/build/types/carbonbox/shared/domain/types/EventEditionLifecycleStageReference.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/types/EventEditionLifecycleStageReferencePrimitives.d.ts +0 -2
- package/build/types/carbonbox/shared/domain/types/EventEditionLifecycleStageReferencePrimitives.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/types/ProductConfigurationCarbonFootprintSegmentReference.d.ts +0 -2
- package/build/types/carbonbox/shared/domain/types/ProductConfigurationCarbonFootprintSegmentReference.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/types/ProductConfigurationCarbonFootprintSegmentReferencePrimitives.d.ts +0 -2
- package/build/types/carbonbox/shared/domain/types/ProductConfigurationCarbonFootprintSegmentReferencePrimitives.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/types/ProductConfigurationCarbonFootprintSubsegmentReference.d.ts +0 -2
- package/build/types/carbonbox/shared/domain/types/ProductConfigurationCarbonFootprintSubsegmentReference.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/types/ProductConfigurationCarbonFootprintSubsegmentReferencePrimitives.d.ts +0 -2
- package/build/types/carbonbox/shared/domain/types/ProductConfigurationCarbonFootprintSubsegmentReferencePrimitives.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/value-objects/CarbonFootprintSegmentReferences.d.ts +7 -43
- package/build/types/carbonbox/shared/domain/value-objects/CarbonFootprintSegmentReferences.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/value-objects/CorporateCarbonFootprintSegmentConfigurationReferences.d.ts +6 -8
- package/build/types/carbonbox/shared/domain/value-objects/CorporateCarbonFootprintSegmentConfigurationReferences.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/value-objects/CorporateConfigurationCarbonFootprintSegmentReference.d.ts +1 -62
- package/build/types/carbonbox/shared/domain/value-objects/CorporateConfigurationCarbonFootprintSegmentReference.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/value-objects/CorporateConfigurationCarbonFootprintSubsegmentReference.d.ts +1 -71
- package/build/types/carbonbox/shared/domain/value-objects/CorporateConfigurationCarbonFootprintSubsegmentReference.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/value-objects/EventEditionConfigurationCarbonFootprintSubsegmentReference.d.ts +2 -78
- package/build/types/carbonbox/shared/domain/value-objects/EventEditionConfigurationCarbonFootprintSubsegmentReference.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/value-objects/EventEditionConfigurationCarbonFootprintSubsegmentReferences.d.ts +5 -68
- package/build/types/carbonbox/shared/domain/value-objects/EventEditionConfigurationCarbonFootprintSubsegmentReferences.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/value-objects/EventEditionLifecycleStageConfigurationReferences.d.ts +20 -19
- package/build/types/carbonbox/shared/domain/value-objects/EventEditionLifecycleStageConfigurationReferences.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/value-objects/EventEditionLifecycleStageReference.d.ts +2 -45
- package/build/types/carbonbox/shared/domain/value-objects/EventEditionLifecycleStageReference.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/value-objects/NullableCorporateConfigurationCarbonFootprintSubsegmentReference.d.ts +2 -62
- package/build/types/carbonbox/shared/domain/value-objects/NullableCorporateConfigurationCarbonFootprintSubsegmentReference.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/value-objects/NullableEventEditionConfigurationCarbonFootprintSubsegmentReference.d.ts +2 -77
- package/build/types/carbonbox/shared/domain/value-objects/NullableEventEditionConfigurationCarbonFootprintSubsegmentReference.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/value-objects/NullableProductConfigurationCarbonFootprintSubsegmentReference.d.ts +2 -62
- package/build/types/carbonbox/shared/domain/value-objects/NullableProductConfigurationCarbonFootprintSubsegmentReference.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/value-objects/ProductCarbonFootprintSegmentConfigurationReferences.d.ts +15 -17
- package/build/types/carbonbox/shared/domain/value-objects/ProductCarbonFootprintSegmentConfigurationReferences.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/value-objects/ProductConfigurationCarbonFootprintSegmentReference.d.ts +1 -81
- package/build/types/carbonbox/shared/domain/value-objects/ProductConfigurationCarbonFootprintSegmentReference.d.ts.map +1 -1
- package/build/types/carbonbox/shared/domain/value-objects/ProductConfigurationCarbonFootprintSubsegmentReference.d.ts +1 -90
- package/build/types/carbonbox/shared/domain/value-objects/ProductConfigurationCarbonFootprintSubsegmentReference.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -18,7 +18,6 @@ const InvalidPropertyValueError_1 = require("../exceptions/InvalidPropertyValueE
|
|
|
18
18
|
const ValueObject_1 = require("./ValueObject");
|
|
19
19
|
const String_1 = require("./String");
|
|
20
20
|
const AggregateId_1 = require("./AggregateId");
|
|
21
|
-
const Code_1 = require("./Code");
|
|
22
21
|
class EventEditionConfigurationCarbonFootprintSubsegmentReferences extends ValueObject_1.ValueObject {
|
|
23
22
|
/**
|
|
24
23
|
* Constructor protegido para que solo clases hijas puedan instanciar.
|
|
@@ -80,8 +79,6 @@ class EventEditionConfigurationCarbonFootprintSubsegmentReferences extends Value
|
|
|
80
79
|
const propertyName = `${basePropertyName}[${index}]`;
|
|
81
80
|
this.guardAgainstInvalidSubsegmentStructure(subsegmentReference, propertyName);
|
|
82
81
|
this.guardAgainstInvalidSubsegmentId(subsegmentReference.id, `${propertyName}.id`);
|
|
83
|
-
this.guardAgainstInvalidSubsegmentCode(subsegmentReference.code, `${propertyName}.code`);
|
|
84
|
-
this.guardAgainstInvalidSubsegmentName(subsegmentReference.name, `${propertyName}.name`);
|
|
85
82
|
}
|
|
86
83
|
/**
|
|
87
84
|
* Valida que el objeto de referencia de subsegmento tenga la estructura correcta.
|
|
@@ -93,12 +90,6 @@ class EventEditionConfigurationCarbonFootprintSubsegmentReferences extends Value
|
|
|
93
90
|
if (typeof subsegmentReference.id !== 'string') {
|
|
94
91
|
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(`${propertyName}.id`, 'string', typeof subsegmentReference.id);
|
|
95
92
|
}
|
|
96
|
-
if (typeof subsegmentReference.code !== 'string') {
|
|
97
|
-
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(`${propertyName}.code`, 'string', typeof subsegmentReference.code);
|
|
98
|
-
}
|
|
99
|
-
if (typeof subsegmentReference.name !== 'string') {
|
|
100
|
-
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(`${propertyName}.name`, 'string', typeof subsegmentReference.name);
|
|
101
|
-
}
|
|
102
93
|
}
|
|
103
94
|
/**
|
|
104
95
|
* Valida el ID de subsegmento usando las validaciones de AggregateId.
|
|
@@ -107,19 +98,6 @@ class EventEditionConfigurationCarbonFootprintSubsegmentReferences extends Value
|
|
|
107
98
|
String_1.String.guardAgainstEmptyValue(id, propertyName);
|
|
108
99
|
AggregateId_1.AggregateId.guardAgainstInvalidId(id, propertyName);
|
|
109
100
|
}
|
|
110
|
-
/**
|
|
111
|
-
* Valida el código de subsegmento usando las validaciones de Code.
|
|
112
|
-
*/
|
|
113
|
-
static guardAgainstInvalidSubsegmentCode(code, propertyName) {
|
|
114
|
-
String_1.String.guardAgainstEmptyValue(code, propertyName);
|
|
115
|
-
Code_1.Code.guardAgainstInvalidCode(code, propertyName);
|
|
116
|
-
}
|
|
117
|
-
/**
|
|
118
|
-
* Valida el nombre del subsegmento.
|
|
119
|
-
*/
|
|
120
|
-
static guardAgainstInvalidSubsegmentName(name, propertyName) {
|
|
121
|
-
String_1.String.guardAgainstEmptyValue(name, propertyName);
|
|
122
|
-
}
|
|
123
101
|
/**
|
|
124
102
|
* Referencias de subsegmentos de etapa de edición de evento (inmutable).
|
|
125
103
|
*/
|
|
@@ -172,34 +150,17 @@ class EventEditionConfigurationCarbonFootprintSubsegmentReferences extends Value
|
|
|
172
150
|
return true;
|
|
173
151
|
}
|
|
174
152
|
/**
|
|
175
|
-
* Obtiene un subsegmento por su
|
|
153
|
+
* Obtiene un subsegmento por su ID.
|
|
176
154
|
*/
|
|
177
155
|
getSubsegmentById(subsegmentId) {
|
|
178
156
|
const subsegmentFound = __classPrivateFieldGet(this, _EventEditionConfigurationCarbonFootprintSubsegmentReferences_subsegmentReferences, "f").find((subsegment) => subsegment.id === subsegmentId.trim());
|
|
179
157
|
return subsegmentFound || null;
|
|
180
158
|
}
|
|
181
|
-
getSubsegmentByCode(subsegmentCode) {
|
|
182
|
-
const subsegmentFound = __classPrivateFieldGet(this, _EventEditionConfigurationCarbonFootprintSubsegmentReferences_subsegmentReferences, "f").find((subsegment) => subsegment.code === subsegmentCode.trim().toUpperCase());
|
|
183
|
-
return subsegmentFound || null;
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Verifica si existe un subsegmento con el código especificado.
|
|
187
|
-
*/
|
|
188
|
-
hasSubsegmentCode(subsegmentCode) {
|
|
189
|
-
return this.getSubsegmentByCode(subsegmentCode) !== null;
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Obtiene un subsegmento por su nombre.
|
|
193
|
-
*/
|
|
194
|
-
getSubsegmentByName(subsegmentName) {
|
|
195
|
-
const subsegmentFound = __classPrivateFieldGet(this, _EventEditionConfigurationCarbonFootprintSubsegmentReferences_subsegmentReferences, "f").find((subsegment) => subsegment.name === subsegmentName.trim());
|
|
196
|
-
return subsegmentFound || null;
|
|
197
|
-
}
|
|
198
159
|
/**
|
|
199
|
-
* Verifica si existe un subsegmento con el
|
|
160
|
+
* Verifica si existe un subsegmento con el ID especificado.
|
|
200
161
|
*/
|
|
201
|
-
|
|
202
|
-
return this.
|
|
162
|
+
hasSubsegmentId(subsegmentId) {
|
|
163
|
+
return this.getSubsegmentById(subsegmentId) !== null;
|
|
203
164
|
}
|
|
204
165
|
/**
|
|
205
166
|
* Obtiene un subsegmento por su índice.
|
|
@@ -211,35 +172,17 @@ class EventEditionConfigurationCarbonFootprintSubsegmentReferences extends Value
|
|
|
211
172
|
return __classPrivateFieldGet(this, _EventEditionConfigurationCarbonFootprintSubsegmentReferences_subsegmentReferences, "f")[index];
|
|
212
173
|
}
|
|
213
174
|
/**
|
|
214
|
-
* Obtiene todos los
|
|
175
|
+
* Obtiene todos los IDs de subsegmento.
|
|
215
176
|
*/
|
|
216
177
|
getAllSubsegmentIds() {
|
|
217
178
|
return __classPrivateFieldGet(this, _EventEditionConfigurationCarbonFootprintSubsegmentReferences_subsegmentReferences, "f").map((subsegment) => subsegment.id);
|
|
218
179
|
}
|
|
219
|
-
getAllSubsegmentCodes() {
|
|
220
|
-
return __classPrivateFieldGet(this, _EventEditionConfigurationCarbonFootprintSubsegmentReferences_subsegmentReferences, "f").map((subsegment) => subsegment.code);
|
|
221
|
-
}
|
|
222
|
-
/**
|
|
223
|
-
* Obtiene todos los nombres de subsegmento.
|
|
224
|
-
*/
|
|
225
|
-
getAllSubsegmentNames() {
|
|
226
|
-
return __classPrivateFieldGet(this, _EventEditionConfigurationCarbonFootprintSubsegmentReferences_subsegmentReferences, "f").map((subsegment) => subsegment.name);
|
|
227
|
-
}
|
|
228
180
|
/**
|
|
229
|
-
* Busca subsegmentos
|
|
230
|
-
*/
|
|
231
|
-
findSubsegmentsByNameContaining(searchText) {
|
|
232
|
-
const lowerSearchText = searchText.toLowerCase().trim();
|
|
233
|
-
return __classPrivateFieldGet(this, _EventEditionConfigurationCarbonFootprintSubsegmentReferences_subsegmentReferences, "f").filter((subsegment) => subsegment.name.toLowerCase().includes(lowerSearchText));
|
|
234
|
-
}
|
|
235
|
-
/**
|
|
236
|
-
* Busca subsegmentos que coincidan con un patrón en código o nombre.
|
|
181
|
+
* Busca subsegmentos que coincidan con un patrón en el ID.
|
|
237
182
|
*/
|
|
238
183
|
findSubsegmentsMatching(searchText) {
|
|
239
184
|
const lowerSearchText = searchText.toLowerCase().trim();
|
|
240
|
-
return __classPrivateFieldGet(this, _EventEditionConfigurationCarbonFootprintSubsegmentReferences_subsegmentReferences, "f").filter((subsegment) => subsegment.id.toLowerCase().includes(lowerSearchText)
|
|
241
|
-
|| subsegment.code.toLowerCase().includes(lowerSearchText)
|
|
242
|
-
|| subsegment.name.toLowerCase().includes(lowerSearchText));
|
|
185
|
+
return __classPrivateFieldGet(this, _EventEditionConfigurationCarbonFootprintSubsegmentReferences_subsegmentReferences, "f").filter((subsegment) => subsegment.id.toLowerCase().includes(lowerSearchText));
|
|
243
186
|
}
|
|
244
187
|
/**
|
|
245
188
|
* Obtiene los primeros N subsegmentos.
|
|
@@ -259,108 +202,13 @@ class EventEditionConfigurationCarbonFootprintSubsegmentReferences extends Value
|
|
|
259
202
|
}
|
|
260
203
|
return __classPrivateFieldGet(this, _EventEditionConfigurationCarbonFootprintSubsegmentReferences_subsegmentReferences, "f").slice(-count);
|
|
261
204
|
}
|
|
262
|
-
/**
|
|
263
|
-
* Verifica si todos los subsegmentos tienen nombres únicos.
|
|
264
|
-
*/
|
|
265
|
-
hasUniqueNames() {
|
|
266
|
-
const names = this.getAllSubsegmentNames();
|
|
267
|
-
const uniqueNames = new Set(names);
|
|
268
|
-
return names.length === uniqueNames.size;
|
|
269
|
-
}
|
|
270
|
-
/**
|
|
271
|
-
* Obtiene subsegmentos con nombres duplicados.
|
|
272
|
-
*/
|
|
273
|
-
getDuplicateNameSubsegments() {
|
|
274
|
-
const nameCountMap = new Map();
|
|
275
|
-
const duplicates = [];
|
|
276
|
-
// Contar ocurrencias de nombres
|
|
277
|
-
__classPrivateFieldGet(this, _EventEditionConfigurationCarbonFootprintSubsegmentReferences_subsegmentReferences, "f").forEach((subsegment) => {
|
|
278
|
-
const count = nameCountMap.get(subsegment.name) || 0;
|
|
279
|
-
nameCountMap.set(subsegment.name, count + 1);
|
|
280
|
-
});
|
|
281
|
-
// Encontrar subsegmentos con nombres duplicados
|
|
282
|
-
__classPrivateFieldGet(this, _EventEditionConfigurationCarbonFootprintSubsegmentReferences_subsegmentReferences, "f").forEach((subsegment) => {
|
|
283
|
-
if (nameCountMap.get(subsegment.name) > 1) {
|
|
284
|
-
duplicates.push(subsegment);
|
|
285
|
-
}
|
|
286
|
-
});
|
|
287
|
-
return duplicates;
|
|
288
|
-
}
|
|
289
|
-
/**
|
|
290
|
-
* Filtra subsegmentos por tipo basado en palabras clave en el nombre.
|
|
291
|
-
*/
|
|
292
|
-
getSubsegmentsByType(typeKeyword) {
|
|
293
|
-
const lowerKeyword = typeKeyword.toLowerCase().trim();
|
|
294
|
-
return __classPrivateFieldGet(this, _EventEditionConfigurationCarbonFootprintSubsegmentReferences_subsegmentReferences, "f").filter((subsegment) => subsegment.name.toLowerCase().includes(lowerKeyword));
|
|
295
|
-
}
|
|
296
|
-
/**
|
|
297
|
-
* Verifica si hay subsegmentos de un tipo específico.
|
|
298
|
-
*/
|
|
299
|
-
hasSubsegmentsOfType(typeKeyword) {
|
|
300
|
-
return this.getSubsegmentsByType(typeKeyword).length > 0;
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Obtiene subsegmentos que contengan palabras clave relacionadas con logística.
|
|
304
|
-
*/
|
|
305
|
-
getLogisticSubsegments() {
|
|
306
|
-
const logisticKeywords = ['logística', 'transporte', 'envío', 'distribución', 'almacén', 'logistics', 'transport', 'shipping', 'distribution', 'warehouse'];
|
|
307
|
-
return __classPrivateFieldGet(this, _EventEditionConfigurationCarbonFootprintSubsegmentReferences_subsegmentReferences, "f").filter((subsegment) => {
|
|
308
|
-
const lowerName = subsegment.name.toLowerCase();
|
|
309
|
-
return logisticKeywords.some((keyword) => lowerName.includes(keyword));
|
|
310
|
-
});
|
|
311
|
-
}
|
|
312
|
-
/**
|
|
313
|
-
* Obtiene subsegmentos que contengan palabras clave relacionadas con marketing.
|
|
314
|
-
*/
|
|
315
|
-
getMarketingSubsegments() {
|
|
316
|
-
const marketingKeywords = ['marketing', 'promoción', 'publicidad', 'comunicación', 'branding', 'promotion', 'advertising', 'communication'];
|
|
317
|
-
return __classPrivateFieldGet(this, _EventEditionConfigurationCarbonFootprintSubsegmentReferences_subsegmentReferences, "f").filter((subsegment) => {
|
|
318
|
-
const lowerName = subsegment.name.toLowerCase();
|
|
319
|
-
return marketingKeywords.some((keyword) => lowerName.includes(keyword));
|
|
320
|
-
});
|
|
321
|
-
}
|
|
322
|
-
/**
|
|
323
|
-
* Obtiene subsegmentos que contengan palabras clave relacionadas con tecnología.
|
|
324
|
-
*/
|
|
325
|
-
getTechnicalSubsegments() {
|
|
326
|
-
const technicalKeywords = ['técnico', 'tecnología', 'sistema', 'digital', 'software', 'hardware', 'technical', 'technology', 'system', 'digital'];
|
|
327
|
-
return __classPrivateFieldGet(this, _EventEditionConfigurationCarbonFootprintSubsegmentReferences_subsegmentReferences, "f").filter((subsegment) => {
|
|
328
|
-
const lowerName = subsegment.name.toLowerCase();
|
|
329
|
-
return technicalKeywords.some((keyword) => lowerName.includes(keyword));
|
|
330
|
-
});
|
|
331
|
-
}
|
|
332
|
-
/**
|
|
333
|
-
* Agrupa subsegmentos por la primera palabra de su nombre.
|
|
334
|
-
*/
|
|
335
|
-
groupSubsegmentsByFirstWord() {
|
|
336
|
-
const groupMap = new Map();
|
|
337
|
-
__classPrivateFieldGet(this, _EventEditionConfigurationCarbonFootprintSubsegmentReferences_subsegmentReferences, "f").forEach((subsegment) => {
|
|
338
|
-
const firstWord = subsegment.name.split(' ')[0].toLowerCase();
|
|
339
|
-
const existing = groupMap.get(firstWord) || [];
|
|
340
|
-
existing.push(subsegment);
|
|
341
|
-
groupMap.set(firstWord, existing);
|
|
342
|
-
});
|
|
343
|
-
return groupMap;
|
|
344
|
-
}
|
|
345
205
|
/**
|
|
346
206
|
* Obtiene estadísticas de la colección.
|
|
347
207
|
*/
|
|
348
208
|
getStatistics() {
|
|
349
209
|
const totalSubsegments = __classPrivateFieldGet(this, _EventEditionConfigurationCarbonFootprintSubsegmentReferences_subsegmentReferences, "f").length;
|
|
350
|
-
const hasUniqueNames = this.hasUniqueNames();
|
|
351
|
-
const averageNameLength = totalSubsegments > 0
|
|
352
|
-
? __classPrivateFieldGet(this, _EventEditionConfigurationCarbonFootprintSubsegmentReferences_subsegmentReferences, "f").reduce((sum, subsegment) => sum + subsegment.name.length, 0) / totalSubsegments
|
|
353
|
-
: 0;
|
|
354
|
-
const logisticSubsegments = this.getLogisticSubsegments().length;
|
|
355
|
-
const marketingSubsegments = this.getMarketingSubsegments().length;
|
|
356
|
-
const technicalSubsegments = this.getTechnicalSubsegments().length;
|
|
357
210
|
return {
|
|
358
211
|
totalSubsegments,
|
|
359
|
-
hasUniqueNames,
|
|
360
|
-
averageNameLength: Math.round(averageNameLength * 100) / 100, // Redondear a 2 decimales
|
|
361
|
-
logisticSubsegments,
|
|
362
|
-
marketingSubsegments,
|
|
363
|
-
technicalSubsegments,
|
|
364
212
|
allowsEmpty: __classPrivateFieldGet(this, _EventEditionConfigurationCarbonFootprintSubsegmentReferences_options, "f").allowEmpty === true,
|
|
365
213
|
isValidState: this.isValidState(),
|
|
366
214
|
};
|
|
@@ -387,16 +235,14 @@ class EventEditionConfigurationCarbonFootprintSubsegmentReferences extends Value
|
|
|
387
235
|
* Compara si dos referencias de subsegmento son iguales.
|
|
388
236
|
*/
|
|
389
237
|
subsegmentReferencesAreEqual(subsegment1, subsegment2) {
|
|
390
|
-
return
|
|
391
|
-
&& subsegment1.code === subsegment2.code
|
|
392
|
-
&& subsegment1.name === subsegment2.name);
|
|
238
|
+
return subsegment1.id === subsegment2.id;
|
|
393
239
|
}
|
|
394
240
|
/**
|
|
395
241
|
* Genera un hash code para usar en colecciones.
|
|
396
242
|
*/
|
|
397
243
|
hashCode() {
|
|
398
244
|
const subsegmentHashes = __classPrivateFieldGet(this, _EventEditionConfigurationCarbonFootprintSubsegmentReferences_subsegmentReferences, "f")
|
|
399
|
-
.map((subsegment) =>
|
|
245
|
+
.map((subsegment) => subsegment.id)
|
|
400
246
|
.join('|');
|
|
401
247
|
const optionsHash = __classPrivateFieldGet(this, _EventEditionConfigurationCarbonFootprintSubsegmentReferences_options, "f").allowEmpty ? 'allowEmpty' : 'requireElements';
|
|
402
248
|
return `eventEditionStageSubsegments_${optionsHash}_${subsegmentHashes}`;
|
|
@@ -407,8 +253,6 @@ class EventEditionConfigurationCarbonFootprintSubsegmentReferences extends Value
|
|
|
407
253
|
toPrimitives() {
|
|
408
254
|
return __classPrivateFieldGet(this, _EventEditionConfigurationCarbonFootprintSubsegmentReferences_subsegmentReferences, "f").map((subsegment) => ({
|
|
409
255
|
id: subsegment.id,
|
|
410
|
-
code: subsegment.code,
|
|
411
|
-
name: subsegment.name,
|
|
412
256
|
}));
|
|
413
257
|
}
|
|
414
258
|
/**
|
|
@@ -19,7 +19,6 @@ const EmissionSource_1 = require("../enums/EmissionSource");
|
|
|
19
19
|
const ValueObject_1 = require("./ValueObject");
|
|
20
20
|
const String_1 = require("./String");
|
|
21
21
|
const AggregateId_1 = require("./AggregateId");
|
|
22
|
-
const Code_1 = require("./Code");
|
|
23
22
|
class EventEditionLifecycleStageConfigurationReferences extends ValueObject_1.ValueObject {
|
|
24
23
|
/**
|
|
25
24
|
* Constructor protegido para que solo clases hijas puedan instanciar.
|
|
@@ -123,7 +122,7 @@ class EventEditionLifecycleStageConfigurationReferences extends ValueObject_1.Va
|
|
|
123
122
|
*/
|
|
124
123
|
static guardAgainstInvalidEventEditionStageSubsegment(subsegment, propertyName) {
|
|
125
124
|
if (subsegment !== null) {
|
|
126
|
-
this.
|
|
125
|
+
this.guardAgainstInvalidSubsegmentReference(subsegment, propertyName);
|
|
127
126
|
}
|
|
128
127
|
}
|
|
129
128
|
/**
|
|
@@ -155,17 +154,21 @@ class EventEditionLifecycleStageConfigurationReferences extends ValueObject_1.Va
|
|
|
155
154
|
if (typeof reference.id !== 'string') {
|
|
156
155
|
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(`${propertyName}.id`, 'string', typeof reference.id);
|
|
157
156
|
}
|
|
158
|
-
|
|
159
|
-
|
|
157
|
+
String_1.String.guardAgainstEmptyValue(reference.id, `${propertyName}.id`);
|
|
158
|
+
AggregateId_1.AggregateId.guardAgainstInvalidId(reference.id, `${propertyName}.id`);
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Valida una referencia de subsegmento.
|
|
162
|
+
*/
|
|
163
|
+
static guardAgainstInvalidSubsegmentReference(reference, propertyName) {
|
|
164
|
+
if (!reference || typeof reference !== 'object') {
|
|
165
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(propertyName, 'EventEditionConfigurationCarbonFootprintSubsegmentReference object', typeof reference);
|
|
160
166
|
}
|
|
161
|
-
if (typeof reference.
|
|
162
|
-
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(`${propertyName}.
|
|
167
|
+
if (typeof reference.id !== 'string') {
|
|
168
|
+
throw InvalidPropertyTypeError_1.InvalidPropertyTypeError.create(`${propertyName}.id`, 'string', typeof reference.id);
|
|
163
169
|
}
|
|
164
170
|
String_1.String.guardAgainstEmptyValue(reference.id, `${propertyName}.id`);
|
|
165
171
|
AggregateId_1.AggregateId.guardAgainstInvalidId(reference.id, `${propertyName}.id`);
|
|
166
|
-
String_1.String.guardAgainstEmptyValue(reference.code, `${propertyName}.code`);
|
|
167
|
-
Code_1.Code.guardAgainstInvalidCode(reference.code);
|
|
168
|
-
String_1.String.guardAgainstEmptyValue(reference.name, `${propertyName}.name`);
|
|
169
172
|
}
|
|
170
173
|
/**
|
|
171
174
|
* Configuraciones de etapa del ciclo de vida de edición de evento (inmutable).
|
|
@@ -219,22 +222,17 @@ class EventEditionLifecycleStageConfigurationReferences extends ValueObject_1.Va
|
|
|
219
222
|
return true;
|
|
220
223
|
}
|
|
221
224
|
/**
|
|
222
|
-
* Obtiene una configuración por
|
|
225
|
+
* Obtiene una configuración por su ID.
|
|
223
226
|
*/
|
|
224
227
|
getConfigurationById(configurationId) {
|
|
225
228
|
const configuration = __classPrivateFieldGet(this, _EventEditionLifecycleStageConfigurationReferences_configurations, "f").find((config) => config.id === configurationId.trim());
|
|
226
229
|
return configuration || null;
|
|
227
230
|
}
|
|
228
|
-
getConfigurationByStageAndSubsegment(stageCode, subsegmentCode) {
|
|
229
|
-
const configuration = __classPrivateFieldGet(this, _EventEditionLifecycleStageConfigurationReferences_configurations, "f").find((config) => config.stage.code === stageCode.trim()
|
|
230
|
-
&& config.subsegment && config.subsegment.code === subsegmentCode.trim());
|
|
231
|
-
return configuration || null;
|
|
232
|
-
}
|
|
233
231
|
/**
|
|
234
|
-
* Verifica si existe una configuración con
|
|
232
|
+
* Verifica si existe una configuración con el ID especificado.
|
|
235
233
|
*/
|
|
236
|
-
|
|
237
|
-
return this.
|
|
234
|
+
hasConfigurationId(configurationId) {
|
|
235
|
+
return this.getConfigurationById(configurationId) !== null;
|
|
238
236
|
}
|
|
239
237
|
/**
|
|
240
238
|
* Obtiene una configuración por su índice.
|
|
@@ -246,16 +244,16 @@ class EventEditionLifecycleStageConfigurationReferences extends ValueObject_1.Va
|
|
|
246
244
|
return __classPrivateFieldGet(this, _EventEditionLifecycleStageConfigurationReferences_configurations, "f")[index];
|
|
247
245
|
}
|
|
248
246
|
/**
|
|
249
|
-
* Obtiene todas las configuraciones por
|
|
247
|
+
* Obtiene todas las configuraciones por ID de etapa.
|
|
250
248
|
*/
|
|
251
|
-
|
|
252
|
-
return __classPrivateFieldGet(this, _EventEditionLifecycleStageConfigurationReferences_configurations, "f").filter((config) => config.stage.
|
|
249
|
+
getConfigurationsByStageId(stageId) {
|
|
250
|
+
return __classPrivateFieldGet(this, _EventEditionLifecycleStageConfigurationReferences_configurations, "f").filter((config) => config.stage.id === stageId.trim());
|
|
253
251
|
}
|
|
254
252
|
/**
|
|
255
|
-
* Obtiene todas las configuraciones por
|
|
253
|
+
* Obtiene todas las configuraciones por ID de subsegmento.
|
|
256
254
|
*/
|
|
257
|
-
|
|
258
|
-
return __classPrivateFieldGet(this, _EventEditionLifecycleStageConfigurationReferences_configurations, "f").filter((config) => config.subsegment && config.subsegment.
|
|
255
|
+
getConfigurationsBySubsegmentId(subsegmentId) {
|
|
256
|
+
return __classPrivateFieldGet(this, _EventEditionLifecycleStageConfigurationReferences_configurations, "f").filter((config) => config.subsegment && config.subsegment.id === subsegmentId.trim());
|
|
259
257
|
}
|
|
260
258
|
/**
|
|
261
259
|
* Obtiene todas las configuraciones por fuente de emisión.
|
|
@@ -268,27 +266,25 @@ class EventEditionLifecycleStageConfigurationReferences extends ValueObject_1.Va
|
|
|
268
266
|
*/
|
|
269
267
|
getAllStageSubsegmentCombinations() {
|
|
270
268
|
return __classPrivateFieldGet(this, _EventEditionLifecycleStageConfigurationReferences_configurations, "f").map((config) => ({
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
subsegmentCode: config.subsegment ? config.subsegment.code : null,
|
|
274
|
-
subsegmentName: config.subsegment ? config.subsegment.name : null,
|
|
269
|
+
stageId: config.stage.id,
|
|
270
|
+
subsegmentId: config.subsegment ? config.subsegment.id : null,
|
|
275
271
|
}));
|
|
276
272
|
}
|
|
277
273
|
/**
|
|
278
|
-
* Obtiene todos los
|
|
274
|
+
* Obtiene todos los IDs únicos de etapas.
|
|
279
275
|
*/
|
|
280
|
-
|
|
281
|
-
const
|
|
282
|
-
return [...new Set(
|
|
276
|
+
getUniqueStageIds() {
|
|
277
|
+
const ids = __classPrivateFieldGet(this, _EventEditionLifecycleStageConfigurationReferences_configurations, "f").map((config) => config.stage.id);
|
|
278
|
+
return [...new Set(ids)];
|
|
283
279
|
}
|
|
284
280
|
/**
|
|
285
|
-
* Obtiene todos los
|
|
281
|
+
* Obtiene todos los IDs únicos de subsegmentos.
|
|
286
282
|
*/
|
|
287
|
-
|
|
288
|
-
const
|
|
283
|
+
getUniqueSubsegmentIds() {
|
|
284
|
+
const ids = __classPrivateFieldGet(this, _EventEditionLifecycleStageConfigurationReferences_configurations, "f")
|
|
289
285
|
.filter((config) => config.subsegment !== null)
|
|
290
|
-
.map((config) => config.subsegment.
|
|
291
|
-
return [...new Set(
|
|
286
|
+
.map((config) => config.subsegment.id);
|
|
287
|
+
return [...new Set(ids)];
|
|
292
288
|
}
|
|
293
289
|
/**
|
|
294
290
|
* Obtiene todas las fuentes de emisión únicas.
|
|
@@ -298,13 +294,13 @@ class EventEditionLifecycleStageConfigurationReferences extends ValueObject_1.Va
|
|
|
298
294
|
return [...new Set(sources)];
|
|
299
295
|
}
|
|
300
296
|
/**
|
|
301
|
-
* Busca configuraciones que coincidan con un patrón de búsqueda.
|
|
297
|
+
* Busca configuraciones que coincidan con un patrón de búsqueda por ID.
|
|
302
298
|
*/
|
|
303
299
|
findConfigurationsMatching(searchText) {
|
|
304
300
|
const lowerSearchText = searchText.toLowerCase().trim();
|
|
305
301
|
return __classPrivateFieldGet(this, _EventEditionLifecycleStageConfigurationReferences_configurations, "f").filter((config) => config.id.toLowerCase().includes(lowerSearchText)
|
|
306
|
-
|| config.stage.
|
|
307
|
-
|| (config.subsegment && config.subsegment.
|
|
302
|
+
|| config.stage.id.toLowerCase().includes(lowerSearchText)
|
|
303
|
+
|| (config.subsegment && config.subsegment.id.toLowerCase().includes(lowerSearchText))
|
|
308
304
|
|| config.emissionSources.some((source) => source.toLowerCase().includes(lowerSearchText)));
|
|
309
305
|
}
|
|
310
306
|
/**
|
|
@@ -313,7 +309,7 @@ class EventEditionLifecycleStageConfigurationReferences extends ValueObject_1.Va
|
|
|
313
309
|
groupConfigurationsByStage() {
|
|
314
310
|
const groupMap = new Map();
|
|
315
311
|
__classPrivateFieldGet(this, _EventEditionLifecycleStageConfigurationReferences_configurations, "f").forEach((config) => {
|
|
316
|
-
const stageKey =
|
|
312
|
+
const stageKey = config.stage.id;
|
|
317
313
|
const existing = groupMap.get(stageKey) || [];
|
|
318
314
|
existing.push(config);
|
|
319
315
|
groupMap.set(stageKey, existing);
|
|
@@ -357,8 +353,8 @@ class EventEditionLifecycleStageConfigurationReferences extends ValueObject_1.Va
|
|
|
357
353
|
*/
|
|
358
354
|
getStatistics() {
|
|
359
355
|
const totalConfigurations = __classPrivateFieldGet(this, _EventEditionLifecycleStageConfigurationReferences_configurations, "f").length;
|
|
360
|
-
const uniqueStages = this.
|
|
361
|
-
const uniqueSubsegments = this.
|
|
356
|
+
const uniqueStages = this.getUniqueStageIds().length;
|
|
357
|
+
const uniqueSubsegments = this.getUniqueSubsegmentIds().length;
|
|
362
358
|
const uniqueEmissionSources = this.getUniqueEmissionSources().length;
|
|
363
359
|
const averageConfigurationsPerStage = uniqueStages > 0 ? totalConfigurations / uniqueStages : 0;
|
|
364
360
|
return {
|
|
@@ -402,7 +398,7 @@ class EventEditionLifecycleStageConfigurationReferences extends ValueObject_1.Va
|
|
|
402
398
|
* Compara referencias de etapa.
|
|
403
399
|
*/
|
|
404
400
|
stageReferencesAreEqual(stage1, stage2) {
|
|
405
|
-
return stage1.id === stage2.id
|
|
401
|
+
return stage1.id === stage2.id;
|
|
406
402
|
}
|
|
407
403
|
/**
|
|
408
404
|
* Compara referencias de subsegmento.
|
|
@@ -414,7 +410,7 @@ class EventEditionLifecycleStageConfigurationReferences extends ValueObject_1.Va
|
|
|
414
410
|
if (subseg1 === null || subseg2 === null) {
|
|
415
411
|
return false;
|
|
416
412
|
}
|
|
417
|
-
return subseg1.id === subseg2.id
|
|
413
|
+
return subseg1.id === subseg2.id;
|
|
418
414
|
}
|
|
419
415
|
/**
|
|
420
416
|
* Compara arrays de fuentes de emisión.
|
|
@@ -432,7 +428,7 @@ class EventEditionLifecycleStageConfigurationReferences extends ValueObject_1.Va
|
|
|
432
428
|
*/
|
|
433
429
|
hashCode() {
|
|
434
430
|
const configHashes = __classPrivateFieldGet(this, _EventEditionLifecycleStageConfigurationReferences_configurations, "f")
|
|
435
|
-
.map((config) => `${config.id}_${config.stage.
|
|
431
|
+
.map((config) => `${config.id}_${config.stage.id}_${config.subsegment?.id || 'null'}_${config.emissionSources.sort().join(',')}`)
|
|
436
432
|
.join('|');
|
|
437
433
|
const optionsHash = __classPrivateFieldGet(this, _EventEditionLifecycleStageConfigurationReferences_options, "f").allowEmpty ? 'allowEmpty' : 'requireElements';
|
|
438
434
|
return `eventEditionLifecycleStageConfigurations_${optionsHash}_${configHashes}`;
|
|
@@ -445,13 +441,9 @@ class EventEditionLifecycleStageConfigurationReferences extends ValueObject_1.Va
|
|
|
445
441
|
id: config.id,
|
|
446
442
|
stage: {
|
|
447
443
|
id: config.stage.id,
|
|
448
|
-
code: config.stage.code,
|
|
449
|
-
name: config.stage.name,
|
|
450
444
|
},
|
|
451
445
|
subsegment: config.subsegment ? {
|
|
452
446
|
id: config.subsegment.id,
|
|
453
|
-
code: config.subsegment.code,
|
|
454
|
-
name: config.subsegment.name,
|
|
455
447
|
} : null,
|
|
456
448
|
emissionSources: config.emissionSources,
|
|
457
449
|
}));
|