onroute-policy-engine 2.20.0 → 2.20.2

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.
@@ -68,7 +68,8 @@ function getSizeDimensionHelper(policy, permitTypeId, commodityId, configuration
68
68
  }
69
69
  const valueOverrides = [];
70
70
  regions === null || regions === void 0 ? void 0 : regions.forEach((r) => {
71
- var _a, _b, _c, _d;
71
+ var _a;
72
+ var _b, _c, _d;
72
73
  let valueOverride;
73
74
  // Check to see if this region has specific size dimensions
74
75
  const regionOverride = (_a = sizeDimensionConfigured.regions) === null || _a === void 0 ? void 0 : _a.find((cr) => cr.region == r);
@@ -396,6 +397,9 @@ function selectCorrectWeightDimensionHelper(policy, weightDimensions, configurat
396
397
  isMatch =
397
398
  matcher ==
398
399
  (isTypeMatch ? relatives.nextType : relatives.nextCategory);
400
+ if (!isMatch) {
401
+ break;
402
+ }
399
403
  if (isMatch && m.axles) {
400
404
  isMatch =
401
405
  m.axles == axleConfiguration[axleIndex + 1].numberOfAxles;
@@ -444,7 +448,8 @@ function selectCorrectWeightDimensionHelper(policy, weightDimensions, configurat
444
448
  * @returns VehicleRelatives for the axle at the indicated axleIndex
445
449
  */
446
450
  function getVehicleRelatives(policy, configuration, axleIndex, axleUnitVehicleIndexes) {
447
- var _a, _b, _c;
451
+ var _a, _b;
452
+ var _c;
448
453
  if (!configuration || configuration.length === 0) {
449
454
  throw new Error('Cannot get relatives with an empty configuration');
450
455
  }
@@ -459,7 +464,7 @@ function getVehicleRelatives(policy, configuration, axleIndex, axleUnitVehicleIn
459
464
  firstCategory: firstVehicle === null || firstVehicle === void 0 ? void 0 : firstVehicle.category,
460
465
  lastCategory: lastVehicle === null || lastVehicle === void 0 ? void 0 : lastVehicle.category,
461
466
  };
462
- const vehicleIndex = (_a = axleUnitVehicleIndexes === null || axleUnitVehicleIndexes === void 0 ? void 0 : axleUnitVehicleIndexes[axleIndex]) !== null && _a !== void 0 ? _a : axleIndex - 1;
467
+ const vehicleIndex = (_c = axleUnitVehicleIndexes === null || axleUnitVehicleIndexes === void 0 ? void 0 : axleUnitVehicleIndexes[axleIndex]) !== null && _c !== void 0 ? _c : axleIndex - 1;
463
468
  if (vehicleIndex <= 0) {
464
469
  // First two axles are for the power unit which has no
465
470
  // previous type (it is first in the configuration always)
@@ -469,7 +474,7 @@ function getVehicleRelatives(policy, configuration, axleIndex, axleUnitVehicleIn
469
474
  else {
470
475
  const prevVehicleType = walk(policy, configuration, vehicleIndex - 1, -1);
471
476
  vehicleRelatives.prevType = prevVehicleType === null || prevVehicleType === void 0 ? void 0 : prevVehicleType.id;
472
- vehicleRelatives.prevCategory = (_b = policy.getVehicleDefinition(vehicleRelatives.prevType)) === null || _b === void 0 ? void 0 : _b.category;
477
+ vehicleRelatives.prevCategory = (_a = policy.getVehicleDefinition(vehicleRelatives.prevType)) === null || _a === void 0 ? void 0 : _a.category;
473
478
  }
474
479
  if (configuration.length === 1 || vehicleIndex >= configuration.length - 1) {
475
480
  // The axleIndex is for the last vehicle in the configuration,
@@ -482,7 +487,7 @@ function getVehicleRelatives(policy, configuration, axleIndex, axleUnitVehicleIn
482
487
  // pseudo vehicle in the line.
483
488
  const nextVehicleType = walk(policy, configuration, vehicleIndex + 1, 1);
484
489
  vehicleRelatives.nextType = nextVehicleType === null || nextVehicleType === void 0 ? void 0 : nextVehicleType.id;
485
- vehicleRelatives.nextCategory = (_c = policy.getVehicleDefinition(vehicleRelatives.nextType)) === null || _c === void 0 ? void 0 : _c.category;
490
+ vehicleRelatives.nextCategory = (_b = policy.getVehicleDefinition(vehicleRelatives.nextType)) === null || _b === void 0 ? void 0 : _b.category;
486
491
  }
487
492
  return vehicleRelatives;
488
493
  }
@@ -212,7 +212,7 @@ export declare function CheckPickerTruckTractorWeightRestrictions(policy: Policy
212
212
  * @see PolicyCheck
213
213
  * @see AxleGroupPolicyCheckResult
214
214
  */
215
- export declare function CheckMinDriveAxleWeight(_policy: Policy, _vehicleConfiguration: Array<string>, axleConfiguration: Array<AxleConfiguration>): Array<PolicyCheckResult>;
215
+ export declare function CheckMinDriveAxleWeight(_policy: Policy, vehicleConfiguration: Array<string>, axleConfiguration: Array<AxleConfiguration>): Array<PolicyCheckResult>;
216
216
  /**
217
217
  * Validates maximum tire load capacity for each axle unit based on tire size and count.
218
218
  *
@@ -618,22 +618,29 @@ function CheckPickerTruckTractorWeightRestrictions(policy, vehicleConfiguration,
618
618
  * @see PolicyCheck
619
619
  * @see AxleGroupPolicyCheckResult
620
620
  */
621
- // TODO this evaluation should only be applied to certain vehicle subtypes, await spec update
622
- function CheckMinDriveAxleWeight(_policy, _vehicleConfiguration, axleConfiguration) {
621
+ function CheckMinDriveAxleWeight(_policy, vehicleConfiguration, axleConfiguration) {
623
622
  const policyCheckResults = new Array();
624
623
  const policyId = enum_1.PolicyCheckId.MinDriveAxleWeight;
625
624
  const gvcw = axleConfiguration.reduce((w, curr) => w + curr.axleUnitWeight, 0);
626
625
  let message, result;
627
- if (axleConfiguration[1].numberOfAxles === 2 ||
628
- axleConfiguration[1].numberOfAxles === 3) {
626
+ const powerUnitSubtype = vehicleConfiguration[0];
627
+ const driveAxle = axleConfiguration[1];
628
+ const isTandemDrive = driveAxle.numberOfAxles === 2;
629
+ const isTridemDrive = driveAxle.numberOfAxles === 3;
630
+ // TODO we need to add Truck with PME and Truck Tractor with PME when ready
631
+ const isSupportedVehicleSubtype = (value) => {
632
+ return value === 'REGTRCK' || value === 'TRKTRAC' || value === 'PICKRTT';
633
+ };
634
+ if ((isTandemDrive || isTridemDrive) &&
635
+ isSupportedVehicleSubtype(powerUnitSubtype)) {
629
636
  let targetMinWeight = gvcw * 0.2;
630
- if (axleConfiguration[1].numberOfAxles === 2) {
637
+ if (isTandemDrive) {
631
638
  targetMinWeight = Math.min(targetMinWeight, 23000);
632
639
  }
633
- else if (axleConfiguration[1].numberOfAxles === 3) {
640
+ else if (isTridemDrive) {
634
641
  targetMinWeight = Math.min(targetMinWeight, 28000);
635
642
  }
636
- if (axleConfiguration[1].axleUnitWeight >= targetMinWeight) {
643
+ if (driveAxle.axleUnitWeight >= targetMinWeight) {
637
644
  message = 'Drive axle meets minimum weight requirements';
638
645
  result = enum_1.PolicyCheckResultType.Pass;
639
646
  }
@@ -643,7 +650,7 @@ function CheckMinDriveAxleWeight(_policy, _vehicleConfiguration, axleConfigurati
643
650
  }
644
651
  }
645
652
  else {
646
- // This policy check is only for tandem or tridem drive power units
653
+ // This policy check is only for tandem or tridem drive power units with supported vehicle sub-type
647
654
  message = 'Policy check does not apply to this configuration';
648
655
  result = enum_1.PolicyCheckResultType.Pass;
649
656
  }
@@ -651,9 +658,8 @@ function CheckMinDriveAxleWeight(_policy, _vehicleConfiguration, axleConfigurati
651
658
  id: policyId,
652
659
  message: message,
653
660
  result: result,
654
- // TODO both start and end axle units should be the drive axle, is this always the second axle unit in the configuration? Or is it the last axle unit of the power unit configuration?
655
661
  startAxleUnit: 1,
656
- endAxleUnit: axleConfiguration.length,
662
+ endAxleUnit: 1,
657
663
  });
658
664
  return policyCheckResults;
659
665
  }
@@ -129,9 +129,6 @@ function getSimplifiedVehicleConfigurationHelper(vehicleDetails, vehicleConfigur
129
129
  */
130
130
  function combineAxleConfigurationsHelper(powerUnitAxleConfiguration, trailers) {
131
131
  const powerUnitAxles = powerUnitAxleConfiguration.map((axle) => (Object.assign(Object.assign({}, axle), { vehicleIndex: 0 })));
132
- const trailerAxles = trailers.flatMap((trailer, trailerIndex) => {
133
- var _a;
134
- return ((_a = trailer.axleConfiguration) !== null && _a !== void 0 ? _a : []).map((axle) => (Object.assign(Object.assign({}, axle), { vehicleIndex: trailerIndex + 1 })));
135
- });
132
+ const trailerAxles = trailers.flatMap((trailer, trailerIndex) => { var _a; return ((_a = trailer.axleConfiguration) !== null && _a !== void 0 ? _a : []).map((axle) => (Object.assign(Object.assign({}, axle), { vehicleIndex: trailerIndex + 1 }))); });
136
133
  return [...powerUnitAxles, ...trailerAxles];
137
134
  }
@@ -36,14 +36,15 @@ class ValidationResults {
36
36
  this.cost = [];
37
37
  if (engineResult) {
38
38
  engineResult.events.forEach((e) => {
39
- var _a, _b, _c, _d, _e, _f, _g, _h;
40
- const message = (_b = (_a = e.params) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : `Unknown message: params=${JSON.stringify(e.params)}`;
41
- const code = (_d = (_c = e.params) === null || _c === void 0 ? void 0 : _c.code) !== null && _d !== void 0 ? _d : validation_result_code_1.ValidationResultCode.GeneralResult;
42
- const type = (_e = e.type) !== null && _e !== void 0 ? _e : validation_result_type_1.ValidationResultType.Violation.toString();
39
+ var _a, _b, _c, _d, _e;
40
+ var _f, _g, _h;
41
+ const message = (_f = (_a = e.params) === null || _a === void 0 ? void 0 : _a.message) !== null && _f !== void 0 ? _f : `Unknown message: params=${JSON.stringify(e.params)}`;
42
+ const code = (_g = (_b = e.params) === null || _b === void 0 ? void 0 : _b.code) !== null && _g !== void 0 ? _g : validation_result_code_1.ValidationResultCode.GeneralResult;
43
+ const type = (_h = e.type) !== null && _h !== void 0 ? _h : validation_result_type_1.ValidationResultType.Violation.toString();
43
44
  const result = new validation_result_1.ValidationResult(type, code, message);
44
- result.fieldReference = (_f = e.params) === null || _f === void 0 ? void 0 : _f.fieldReference;
45
- result.cost = (_g = e.params) === null || _g === void 0 ? void 0 : _g.cost;
46
- result.details = (_h = e.params) === null || _h === void 0 ? void 0 : _h.details;
45
+ result.fieldReference = (_c = e.params) === null || _c === void 0 ? void 0 : _c.fieldReference;
46
+ result.cost = (_d = e.params) === null || _d === void 0 ? void 0 : _d.cost;
47
+ result.details = (_e = e.params) === null || _e === void 0 ? void 0 : _e.details;
47
48
  switch (type) {
48
49
  case validation_result_type_1.ValidationResultType.Violation:
49
50
  this.violations.push(result);
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "v2.20.0";
1
+ export declare const version = "v2.20.2";
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.20.0';
5
+ exports.version = 'v2.20.2';
package/package.json CHANGED
@@ -91,5 +91,5 @@
91
91
  ],
92
92
  "testEnvironment": "node"
93
93
  },
94
- "version": "v2.20.0"
94
+ "version": "v2.20.2"
95
95
  }