onroute-policy-engine 2.32.2 → 2.32.4

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.
@@ -133,7 +133,7 @@ function CheckLegalWeight(policy, vehicleConfiguration, axleConfiguration) {
133
133
  const axleUnitNumber = axleIndex + 1;
134
134
  return {
135
135
  id: policyId,
136
- message: `Weight for axle unit ${axleUnitNumber} ${result ? 'is legal' : `must not exceed ${legalWeight} kgs`}`,
136
+ message: `Axle Unit Weight for Axle Unit ${axleUnitNumber} ${result ? 'is legal' : `must not exceed ${legalWeight} kg.`}`,
137
137
  // We intentionally only return Pass/Warning, as we should never
138
138
  // show an error for being above legal amount, only permitable
139
139
  // amount. But it's still useful info for things like OCD table.
@@ -277,36 +277,37 @@ function CheckNumberOfAxles(_policy, _vehicleConfiguration, axleConfiguration) {
277
277
  });
278
278
  return policyCheckResults;
279
279
  }
280
- function getBridgeFormulaInputFailure(axleConfiguration) {
280
+ /**
281
+ * This function basically lets us skip Bridge Formula if we know it'll crash.
282
+ *
283
+ * This function is a 'necessary evil.' The Bridge Formula calculation is
284
+ * important legacy code, but with certain inputs it would throw an
285
+ * exception and crash the entire calculation, especially in the ASW table.
286
+ *
287
+ * These "crashing inputs" are always STOW eval errors, so even if we don't
288
+ * run bridge formula the user should be seeing seperate errors, so once they
289
+ * fix those errors then re-run it should include Bridge Formula.
290
+ *
291
+ */
292
+ function hasInvalidBridgeFormulaInput(axleConfiguration) {
281
293
  for (let axleIndex = 0; axleIndex < axleConfiguration.length; axleIndex++) {
282
294
  const axleUnit = axleConfiguration[axleIndex];
283
- const axleUnitNumber = axleIndex + 1;
284
- let message;
285
295
  if (!Number.isFinite(axleUnit.axleUnitWeight) ||
286
296
  axleUnit.axleUnitWeight <= 0) {
287
- message = `Axle unit weight for axle unit ${axleUnitNumber} must be a finite number greater than 0.`;
297
+ return true;
288
298
  }
289
299
  else if (axleUnit.numberOfAxles > 1 &&
290
300
  (!Number.isFinite(axleUnit.axleSpread) ||
291
301
  axleUnit.axleSpread <= 0)) {
292
- message = `Axle spread for axle unit ${axleUnitNumber} must be a finite number greater than 0 when the unit has multiple axles.`;
302
+ return true;
293
303
  }
294
304
  else if (axleIndex > 0 &&
295
305
  (!Number.isFinite(axleUnit.interaxleSpacing) ||
296
306
  axleUnit.interaxleSpacing <= 0)) {
297
- message = `Axle spacing before axle unit ${axleUnitNumber} must be a finite number greater than 0.`;
298
- }
299
- if (message) {
300
- return {
301
- id: enum_1.PolicyCheckId.BridgeFormula,
302
- message,
303
- result: enum_1.PolicyCheckResultType.Fail,
304
- startAxleUnit: axleUnitNumber,
305
- endAxleUnit: axleUnitNumber,
306
- };
307
+ return true;
307
308
  }
308
309
  }
309
- return undefined;
310
+ return false;
310
311
  }
311
312
  /**
312
313
  * Performs bridge formula calculations on axle groups and returns policy check results.
@@ -337,9 +338,12 @@ function getBridgeFormulaInputFailure(axleConfiguration) {
337
338
  function CheckBridgeFormula(policy, vehicleConfiguration, axleConfiguration) {
338
339
  const policyCheckResults = new Array();
339
340
  const policyId = enum_1.PolicyCheckId.BridgeFormula;
340
- const inputFailure = getBridgeFormulaInputFailure(axleConfiguration);
341
- if (inputFailure) {
342
- return [inputFailure];
341
+ // This basically skips Bridge Formula if the input is invalid.
342
+ // This is important for STOW, which in the ASW runs this as well as STOW evals
343
+ // Some of those STOW evals can accept inputs that would make Bridge Formula throw
344
+ // errors and crash.
345
+ if (hasInvalidBridgeFormulaInput(axleConfiguration)) {
346
+ return [];
343
347
  }
344
348
  const bridgeCalcResults = policy.calculateBridge(axleConfiguration, vehicleConfiguration);
345
349
  bridgeCalcResults.forEach((br) => {
@@ -1252,7 +1256,7 @@ function CheckLegalAxleSpread(policy, vehicleConfiguration, axleConfiguration) {
1252
1256
  const axleUnitVehicleIndexes = (0, dimensions_helper_1.getAxleUnitVehicleIndexLookup)(policy, vehicleConfiguration, axleConfiguration);
1253
1257
  return axleConfiguration.flatMap((axleUnit, axleIndex) => {
1254
1258
  const threshold = (0, axle_spread_helper_1.getAxleSpreadThreshold)(vehicleConfiguration, axleUnitVehicleIndexes, axleConfiguration, axleIndex);
1255
- if (!axleUnit.axleSpread ||
1259
+ if (axleUnit.axleSpread === undefined ||
1256
1260
  !threshold ||
1257
1261
  !Number.isFinite(axleUnit.axleSpread)) {
1258
1262
  return [];
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "v2.32.2";
1
+ export declare const version = "v2.32.4";
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.32.2';
5
+ exports.version = 'v2.32.4';
package/package.json CHANGED
@@ -91,5 +91,5 @@
91
91
  ],
92
92
  "testEnvironment": "node"
93
93
  },
94
- "version": "v2.32.2"
94
+ "version": "v2.32.4"
95
95
  }