@trafficgroup/knex-rel 0.1.5 → 0.1.6

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.
@@ -200,6 +200,11 @@ export class ReportConfigurationDAO implements IBaseDAO<IReportConfiguration> {
200
200
  if (!cls.name || cls.name.length === 0) {
201
201
  errors.push(`Custom class ${idx + 1}: name cannot be empty`);
202
202
  }
203
+ if (cls.name && cls.name.toLowerCase() === "total") {
204
+ errors.push(
205
+ `Custom class ${idx + 1}: "Total" is a reserved name and cannot be used`,
206
+ );
207
+ }
203
208
  if (cls.name && cls.name.length > 30) {
204
209
  errors.push(`Custom class ${idx + 1}: name exceeds 30 characters`);
205
210
  }
@@ -336,6 +341,9 @@ export class ReportConfigurationDAO implements IBaseDAO<IReportConfiguration> {
336
341
  );
337
342
  }
338
343
 
344
+ // Add "Total" class that aggregates all custom classes
345
+ result["Total"] = this._createTotalClass(result);
346
+
339
347
  return result;
340
348
  }
341
349
 
@@ -374,6 +382,23 @@ export class ReportConfigurationDAO implements IBaseDAO<IReportConfiguration> {
374
382
  return target;
375
383
  }
376
384
 
385
+ /**
386
+ * Create "Total" vehicle class by summing all custom classes
387
+ * Works for both ATR and TMC formats through structure-agnostic deep merge
388
+ *
389
+ * @param customClassesData - Object with custom class names as keys
390
+ * @returns Aggregated nested structure summing all classes
391
+ */
392
+ private _createTotalClass(customClassesData: Record<string, any>): any {
393
+ let total: any = {};
394
+
395
+ for (const [className, nestedData] of Object.entries(customClassesData)) {
396
+ total = this._deepMergeNumericData(total, nestedData);
397
+ }
398
+
399
+ return total;
400
+ }
401
+
377
402
  /**
378
403
  * Get the FHWA mapping constant (for reference/debugging)
379
404
  */