onroute-policy-engine 2.17.0 → 2.18.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.
@@ -276,7 +276,9 @@ function CheckPermittableWeight(policy, vehicleConfiguration, axleConfiguration)
276
276
  ? policy.getDefaultPowerUnitWeight(vehicleType, axleConfiguration[0].numberOfAxles * 10 +
277
277
  axleConfiguration[1].numberOfAxles)
278
278
  : policy.getDefaultTrailerWeight(vehicleType, ac.numberOfAxles);
279
- const axleDimension = policy.selectCorrectWeightDimension(weight, vehicleConfiguration, axleConfiguration, i) || {};
279
+ const axleDimension = weight.length > 0
280
+ ? policy.selectCorrectWeightDimension(weight, vehicleConfiguration, axleConfiguration, i) || {}
281
+ : {};
280
282
  const actualWeight = ac.axleUnitWeight;
281
283
  const permittableWeight = axleDimension.permittable || 0;
282
284
  const result = actualWeight <= permittableWeight;
@@ -68,10 +68,3 @@ export declare function getSimplifiedVehicleConfigurationHelper(vehicleDetails:
68
68
  * represents the power unit and trailer indexes start at 1.
69
69
  */
70
70
  export declare function combineAxleConfigurationsHelper(powerUnitAxleConfiguration: Array<AxleConfiguration>, trailers: Array<VehicleInConfiguration>): Array<IndexedAxleConfiguration>;
71
- /**
72
- * Calculates the Gross Combined Vehicle Weight (GCVW) from axle unit weights.
73
- *
74
- * @param axleConfiguration - Axle configuration to total
75
- * @returns Sum of axle unit weights, treating missing weights as 0.
76
- */
77
- export declare function calculateGCVWHelper(axleConfiguration: Array<AxleConfiguration>): number;
@@ -4,7 +4,6 @@ exports.filterOutLcv = filterOutLcv;
4
4
  exports.filterVehiclesByType = filterVehiclesByType;
5
5
  exports.getSimplifiedVehicleConfigurationHelper = getSimplifiedVehicleConfigurationHelper;
6
6
  exports.combineAxleConfigurationsHelper = combineAxleConfigurationsHelper;
7
- exports.calculateGCVWHelper = calculateGCVWHelper;
8
7
  const enum_1 = require("onroute-policy-engine/enum");
9
8
  /**
10
9
  * Filters out all LCV vehicles from a supplied list of vehicle IDs.
@@ -136,16 +135,3 @@ function combineAxleConfigurationsHelper(powerUnitAxleConfiguration, trailers) {
136
135
  });
137
136
  return [...powerUnitAxles, ...trailerAxles];
138
137
  }
139
- /**
140
- * Calculates the Gross Combined Vehicle Weight (GCVW) from axle unit weights.
141
- *
142
- * @param axleConfiguration - Axle configuration to total
143
- * @returns Sum of axle unit weights, treating missing weights as 0.
144
- */
145
- function calculateGCVWHelper(axleConfiguration) {
146
- return axleConfiguration.reduce((totalWeight, axleUnit) => {
147
- var _a;
148
- const axleUnitWeight = (_a = axleUnit.axleUnitWeight) !== null && _a !== void 0 ? _a : 0;
149
- return totalWeight + axleUnitWeight;
150
- }, 0);
151
- }
@@ -204,7 +204,8 @@ export declare class Policy {
204
204
  * @param licensedGVW Licensed GVW of the vehicle being permitted.
205
205
  * @returns AxleCalcResults object containing:
206
206
  * - results: Array of PolicyCheckResult objects, each representing the outcome of a specific policy check
207
- * - totalOverload: Numeric value representing the total overload across all axle calculations
207
+ * - overload: Numeric value representing the total overload across all axle calculations
208
+ * - totalGCVW: Total Gross Combined Vehicle Weight across all axles
208
209
  *
209
210
  * @example
210
211
  * // For a truck-tractor with 2-axle steer, 3-axle drive, and a 3-axle semi-trailer
@@ -351,13 +352,6 @@ export declare class Policy {
351
352
  * represents the power unit and trailer indexes start at 1.
352
353
  */
353
354
  combineAxleConfigurations(powerUnitAxleConfiguration: Array<AxleConfiguration>, trailers: Array<VehicleInConfiguration>): Array<IndexedAxleConfiguration>;
354
- /**
355
- * Calculates the Gross Combined Vehicle Weight (GCVW) from axle unit weights.
356
- *
357
- * @param axleConfiguration - Axle configuration to total
358
- * @returns Sum of axle unit weights, treating missing weights as 0.
359
- */
360
- calculateGCVW(axleConfiguration: Array<AxleConfiguration>): number;
361
355
  /**
362
356
  * Given a commodity and selected power unit subtype for a permit type,
363
357
  * return whether or not axle units can be added to the power unit.
@@ -682,7 +682,8 @@ class Policy {
682
682
  * @param licensedGVW Licensed GVW of the vehicle being permitted.
683
683
  * @returns AxleCalcResults object containing:
684
684
  * - results: Array of PolicyCheckResult objects, each representing the outcome of a specific policy check
685
- * - totalOverload: Numeric value representing the total overload across all axle calculations
685
+ * - overload: Numeric value representing the total overload across all axle calculations
686
+ * - totalGCVW: Total Gross Combined Vehicle Weight across all axles
686
687
  *
687
688
  * @example
688
689
  * // For a truck-tractor with 2-axle steer, 3-axle drive, and a 3-axle semi-trailer
@@ -701,7 +702,11 @@ class Policy {
701
702
  * @see AxleConfiguration
702
703
  */
703
704
  runAxleCalculation(vehicleConfiguration, axleConfiguration, licensedGVW) {
704
- const axleCalcResults = { results: [], totalOverload: 0 };
705
+ const axleCalcResults = {
706
+ results: [],
707
+ overload: 0,
708
+ totalGCVW: 0,
709
+ };
705
710
  // This is a little helper closure that just converts any PolicyCheckResult into an AxleGroupPolicyCheckResult,
706
711
  // basically giving us startAxleUnit and endAxleUnit, which can help with frontend form highlighting.
707
712
  const toAxleGroupPolicyCheckResult = (result) => {
@@ -714,7 +719,8 @@ class Policy {
714
719
  return Object.assign(Object.assign({}, result), { startAxleUnit: 1, endAxleUnit: axleConfiguration.length });
715
720
  };
716
721
  const gvcw = axleConfiguration.reduce((w, curr) => w + curr.axleUnitWeight, 0);
717
- axleCalcResults.totalOverload = Math.max(axleCalcResults.totalOverload, gvcw - licensedGVW);
722
+ axleCalcResults.overload = Math.max(axleCalcResults.overload, gvcw - licensedGVW);
723
+ axleCalcResults.totalGCVW = gvcw;
718
724
  const axleCountResults = (0, policy_check_helper_1.CheckNumberOfAxles)(this, vehicleConfiguration, axleConfiguration);
719
725
  axleCalcResults.results.push(...axleCountResults.map(toAxleGroupPolicyCheckResult));
720
726
  if (axleCountResults.some((r) => r.result === enum_1.PolicyCheckResultType.Fail)) {
@@ -895,15 +901,6 @@ class Policy {
895
901
  combineAxleConfigurations(powerUnitAxleConfiguration, trailers) {
896
902
  return (0, vehicles_helper_1.combineAxleConfigurationsHelper)(powerUnitAxleConfiguration, trailers);
897
903
  }
898
- /**
899
- * Calculates the Gross Combined Vehicle Weight (GCVW) from axle unit weights.
900
- *
901
- * @param axleConfiguration - Axle configuration to total
902
- * @returns Sum of axle unit weights, treating missing weights as 0.
903
- */
904
- calculateGCVW(axleConfiguration) {
905
- return (0, vehicles_helper_1.calculateGCVWHelper)(axleConfiguration);
906
- }
907
904
  /**
908
905
  * Given a commodity and selected power unit subtype for a permit type,
909
906
  * return whether or not axle units can be added to the power unit.
@@ -969,7 +966,7 @@ class Policy {
969
966
  trailerSubtype === enum_1.AccessoryVehicleType.Booster) {
970
967
  return false;
971
968
  }
972
- const trailer = powerUnit.trailers.find(trailer => trailer.type === trailerSubtype);
969
+ const trailer = powerUnit.trailers.find((trailer) => trailer.type === trailerSubtype);
973
970
  if (!trailer) {
974
971
  throw new Error(`Invalid trailer: '${trailerSubtype}'`);
975
972
  }
@@ -12,7 +12,9 @@ export type AxleCalcResults = {
12
12
  /** Array of individual axle group policy check results */
13
13
  results: Array<AxleGroupPolicyCheckResult>;
14
14
  /** Total weight overload across all axles in kilograms */
15
- totalOverload: number;
15
+ overload: number;
16
+ /** Total Gross Combined Vehicle Weight across all axles in kilograms */
17
+ totalGCVW: number;
16
18
  };
17
19
  /**
18
20
  * Individual policy check result for a specific validation rule
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "v2.17.0";
1
+ export declare const version = "v2.18.0";
package/dist/version.js CHANGED
@@ -2,4 +2,4 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.version = void 0;
4
4
  // Generated by genversion.
5
- exports.version = 'v2.17.0';
5
+ exports.version = 'v2.18.0';
package/package.json CHANGED
@@ -91,5 +91,5 @@
91
91
  ],
92
92
  "testEnvironment": "node"
93
93
  },
94
- "version": "v2.17.0"
94
+ "version": "v2.18.0"
95
95
  }