onroute-policy-engine 2.20.0 → 2.20.1
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/dist/helper/dimensions.helper.js +7 -5
- package/dist/helper/policy-check.helper.d.ts +1 -1
- package/dist/helper/policy-check.helper.js +16 -10
- package/dist/helper/vehicles.helper.js +1 -4
- package/dist/validation-results.js +8 -7
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -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
|
|
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);
|
|
@@ -444,7 +445,8 @@ function selectCorrectWeightDimensionHelper(policy, weightDimensions, configurat
|
|
|
444
445
|
* @returns VehicleRelatives for the axle at the indicated axleIndex
|
|
445
446
|
*/
|
|
446
447
|
function getVehicleRelatives(policy, configuration, axleIndex, axleUnitVehicleIndexes) {
|
|
447
|
-
var _a, _b
|
|
448
|
+
var _a, _b;
|
|
449
|
+
var _c;
|
|
448
450
|
if (!configuration || configuration.length === 0) {
|
|
449
451
|
throw new Error('Cannot get relatives with an empty configuration');
|
|
450
452
|
}
|
|
@@ -459,7 +461,7 @@ function getVehicleRelatives(policy, configuration, axleIndex, axleUnitVehicleIn
|
|
|
459
461
|
firstCategory: firstVehicle === null || firstVehicle === void 0 ? void 0 : firstVehicle.category,
|
|
460
462
|
lastCategory: lastVehicle === null || lastVehicle === void 0 ? void 0 : lastVehicle.category,
|
|
461
463
|
};
|
|
462
|
-
const vehicleIndex = (
|
|
464
|
+
const vehicleIndex = (_c = axleUnitVehicleIndexes === null || axleUnitVehicleIndexes === void 0 ? void 0 : axleUnitVehicleIndexes[axleIndex]) !== null && _c !== void 0 ? _c : axleIndex - 1;
|
|
463
465
|
if (vehicleIndex <= 0) {
|
|
464
466
|
// First two axles are for the power unit which has no
|
|
465
467
|
// previous type (it is first in the configuration always)
|
|
@@ -469,7 +471,7 @@ function getVehicleRelatives(policy, configuration, axleIndex, axleUnitVehicleIn
|
|
|
469
471
|
else {
|
|
470
472
|
const prevVehicleType = walk(policy, configuration, vehicleIndex - 1, -1);
|
|
471
473
|
vehicleRelatives.prevType = prevVehicleType === null || prevVehicleType === void 0 ? void 0 : prevVehicleType.id;
|
|
472
|
-
vehicleRelatives.prevCategory = (
|
|
474
|
+
vehicleRelatives.prevCategory = (_a = policy.getVehicleDefinition(vehicleRelatives.prevType)) === null || _a === void 0 ? void 0 : _a.category;
|
|
473
475
|
}
|
|
474
476
|
if (configuration.length === 1 || vehicleIndex >= configuration.length - 1) {
|
|
475
477
|
// The axleIndex is for the last vehicle in the configuration,
|
|
@@ -482,7 +484,7 @@ function getVehicleRelatives(policy, configuration, axleIndex, axleUnitVehicleIn
|
|
|
482
484
|
// pseudo vehicle in the line.
|
|
483
485
|
const nextVehicleType = walk(policy, configuration, vehicleIndex + 1, 1);
|
|
484
486
|
vehicleRelatives.nextType = nextVehicleType === null || nextVehicleType === void 0 ? void 0 : nextVehicleType.id;
|
|
485
|
-
vehicleRelatives.nextCategory = (
|
|
487
|
+
vehicleRelatives.nextCategory = (_b = policy.getVehicleDefinition(vehicleRelatives.nextType)) === null || _b === void 0 ? void 0 : _b.category;
|
|
486
488
|
}
|
|
487
489
|
return vehicleRelatives;
|
|
488
490
|
}
|
|
@@ -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,
|
|
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
|
-
|
|
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
|
-
|
|
628
|
-
|
|
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 (
|
|
637
|
+
if (isTandemDrive) {
|
|
631
638
|
targetMinWeight = Math.min(targetMinWeight, 23000);
|
|
632
639
|
}
|
|
633
|
-
else if (
|
|
640
|
+
else if (isTridemDrive) {
|
|
634
641
|
targetMinWeight = Math.min(targetMinWeight, 28000);
|
|
635
642
|
}
|
|
636
|
-
if (
|
|
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:
|
|
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
|
|
40
|
-
|
|
41
|
-
const
|
|
42
|
-
const
|
|
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 = (
|
|
45
|
-
result.cost = (
|
|
46
|
-
result.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.
|
|
1
|
+
export declare const version = "v2.20.1";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED