onroute-policy-engine 2.24.2 → 2.25.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.
- package/dist/enum/policy-check.d.ts +3 -2
- package/dist/enum/policy-check.js +3 -2
- package/dist/helper/policy-check.helper.d.ts +5 -0
- package/dist/helper/policy-check.helper.js +98 -4
- package/dist/policy-engine.js +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -7,15 +7,16 @@ export declare enum PolicyCheckId {
|
|
|
7
7
|
AxleGroupMaximumLegalWeightThreshold = "axle-group-maximum-legal-weight-threshold",
|
|
8
8
|
BoosterAxleLimit = "booster-axle-limit",
|
|
9
9
|
BridgeFormula = "bridge-formula",
|
|
10
|
-
CheckLegalWeight = "check-legal-weight",
|
|
11
|
-
CheckPermittableWeight = "check-permittable-weight",
|
|
12
10
|
DriveJeepLoadEqualization = "drive-jeep-load-equalization",
|
|
11
|
+
LegalInteraxleSpacing = "legal-interaxle-spacing",
|
|
12
|
+
LegalWeight = "legal-weight",
|
|
13
13
|
MaxTireLoad = "max-tire-load",
|
|
14
14
|
MinDriveAxleWeight = "minimum-drive-axle-weight",
|
|
15
15
|
MinSteerAxleWeight = "minimum-steer-axle-weight",
|
|
16
16
|
MinTandemSteerAxleWeight = "minimum-tandem-steer-axle-weight",
|
|
17
17
|
NumberOfAxles = "number-of-axles",
|
|
18
18
|
NumberOfWheelsPerAxle = "number-of-wheels",
|
|
19
|
+
PermittableWeight = "permittable-weight",
|
|
19
20
|
PickerTruckTractorWeightRestrictions = "picker-truck-tractor-weight-restrictions",
|
|
20
21
|
WheelbaseLegalLimits = "wheelbase-legal-limits"
|
|
21
22
|
}
|
|
@@ -12,15 +12,16 @@ var PolicyCheckId;
|
|
|
12
12
|
PolicyCheckId["AxleGroupMaximumLegalWeightThreshold"] = "axle-group-maximum-legal-weight-threshold";
|
|
13
13
|
PolicyCheckId["BoosterAxleLimit"] = "booster-axle-limit";
|
|
14
14
|
PolicyCheckId["BridgeFormula"] = "bridge-formula";
|
|
15
|
-
PolicyCheckId["CheckLegalWeight"] = "check-legal-weight";
|
|
16
|
-
PolicyCheckId["CheckPermittableWeight"] = "check-permittable-weight";
|
|
17
15
|
PolicyCheckId["DriveJeepLoadEqualization"] = "drive-jeep-load-equalization";
|
|
16
|
+
PolicyCheckId["LegalInteraxleSpacing"] = "legal-interaxle-spacing";
|
|
17
|
+
PolicyCheckId["LegalWeight"] = "legal-weight";
|
|
18
18
|
PolicyCheckId["MaxTireLoad"] = "max-tire-load";
|
|
19
19
|
PolicyCheckId["MinDriveAxleWeight"] = "minimum-drive-axle-weight";
|
|
20
20
|
PolicyCheckId["MinSteerAxleWeight"] = "minimum-steer-axle-weight";
|
|
21
21
|
PolicyCheckId["MinTandemSteerAxleWeight"] = "minimum-tandem-steer-axle-weight";
|
|
22
22
|
PolicyCheckId["NumberOfAxles"] = "number-of-axles";
|
|
23
23
|
PolicyCheckId["NumberOfWheelsPerAxle"] = "number-of-wheels";
|
|
24
|
+
PolicyCheckId["PermittableWeight"] = "permittable-weight";
|
|
24
25
|
PolicyCheckId["PickerTruckTractorWeightRestrictions"] = "picker-truck-tractor-weight-restrictions";
|
|
25
26
|
PolicyCheckId["WheelbaseLegalLimits"] = "wheelbase-legal-limits";
|
|
26
27
|
})(PolicyCheckId || (exports.PolicyCheckId = PolicyCheckId = {}));
|
|
@@ -298,6 +298,11 @@ export declare function CheckWheelbaseLegalLimits(policy: Policy, vehicleConfigu
|
|
|
298
298
|
* @returns Array of AxleGroupPolicyCheckResult objects for the applicable drive/jeep pair
|
|
299
299
|
*/
|
|
300
300
|
export declare function CheckDriveJeepLoadEqualization(_policy: Policy, vehicleConfiguration: Array<string>, axleConfiguration: Array<AxleConfiguration>): Array<PolicyCheckResult>;
|
|
301
|
+
/**
|
|
302
|
+
* Validates each axle unit against the minimum interaxle spacing for its
|
|
303
|
+
* current axle unit and the next axle unit, per Table II.
|
|
304
|
+
*/
|
|
305
|
+
export declare function CheckLegalInteraxleSpacing(_policy: Policy, _vehicleConfiguration: Array<string>, axleConfiguration: Array<AxleConfiguration>): Array<PolicyCheckResult>;
|
|
301
306
|
/**
|
|
302
307
|
* Map of policy check functions keyed by their corresponding PolicyCheckId.
|
|
303
308
|
*
|
|
@@ -16,6 +16,7 @@ exports.CheckMaxTireLoad = CheckMaxTireLoad;
|
|
|
16
16
|
exports.CheckBoosterAxleLimit = CheckBoosterAxleLimit;
|
|
17
17
|
exports.CheckWheelbaseLegalLimits = CheckWheelbaseLegalLimits;
|
|
18
18
|
exports.CheckDriveJeepLoadEqualization = CheckDriveJeepLoadEqualization;
|
|
19
|
+
exports.CheckLegalInteraxleSpacing = CheckLegalInteraxleSpacing;
|
|
19
20
|
const dimensions_helper_1 = require("./dimensions.helper");
|
|
20
21
|
const ctr_717_helper_1 = require("./ctr-717.helper");
|
|
21
22
|
const enum_1 = require("../enum");
|
|
@@ -40,6 +41,23 @@ const QUALIFYING_TRIDEM_SPREAD_CM = {
|
|
|
40
41
|
MINIMUM: 240,
|
|
41
42
|
MAXIMUM: 370,
|
|
42
43
|
};
|
|
44
|
+
const INTERAXLE_SPACING_MINIMUM_CM = {
|
|
45
|
+
SINGLE: {
|
|
46
|
+
SINGLE: 300,
|
|
47
|
+
TANDEM: 300,
|
|
48
|
+
TRIDEM: 300,
|
|
49
|
+
},
|
|
50
|
+
TANDEM: {
|
|
51
|
+
SINGLE: 300,
|
|
52
|
+
TANDEM: 500,
|
|
53
|
+
TRIDEM: 550,
|
|
54
|
+
},
|
|
55
|
+
TRIDEM: {
|
|
56
|
+
SINGLE: 300,
|
|
57
|
+
TANDEM: 550,
|
|
58
|
+
TRIDEM: 600,
|
|
59
|
+
},
|
|
60
|
+
};
|
|
43
61
|
/** Applies the standard lower-of rule or the exact 7.16(g) exception. */
|
|
44
62
|
function getMaximumLegalAxleGroupWeightThreshold(individualLegalWeightSum, ctr717TableValue, isTandemDriveSingleJeepException) {
|
|
45
63
|
const tandemDriveSingleJeepMinimumKg = 24000;
|
|
@@ -64,6 +82,10 @@ function getApplicableLegalWeightThreshold(policy, vehicleConfiguration, axleCon
|
|
|
64
82
|
}
|
|
65
83
|
return (_a = policy.selectCorrectWeightDimension(weights, vehicleConfiguration, axleConfiguration, axleIndex)) === null || _a === void 0 ? void 0 : _a.legal;
|
|
66
84
|
}
|
|
85
|
+
/**
|
|
86
|
+
* Returns an array of vehicle indexes for each axle unit.
|
|
87
|
+
* Each entry maps an axle unit to the vehicle in vehicleConfiguration that it belongs to.
|
|
88
|
+
*/
|
|
67
89
|
function getAxleUnitVehicleIndexLookup(policy, vehicleConfiguration, axleConfiguration) {
|
|
68
90
|
return axleConfiguration.some((axleUnit) => axleUnit.vehicleIndex !== undefined)
|
|
69
91
|
? (0, dimensions_helper_1.getAxleUnitVehicleIndexes)(policy, vehicleConfiguration, axleConfiguration)
|
|
@@ -135,7 +157,7 @@ function getFeatureLegalPowerUnitWeightThreshold(vehicleType, axleConfiguration,
|
|
|
135
157
|
* their configured legal weight lookup.
|
|
136
158
|
*/
|
|
137
159
|
function CheckLegalWeight(policy, vehicleConfiguration, axleConfiguration) {
|
|
138
|
-
const policyId = enum_1.PolicyCheckId.
|
|
160
|
+
const policyId = enum_1.PolicyCheckId.LegalWeight;
|
|
139
161
|
const powerUnitType = vehicleConfiguration[0];
|
|
140
162
|
const axleUnitVehicleIndexes = getAxleUnitVehicleIndexLookup(policy, vehicleConfiguration, axleConfiguration);
|
|
141
163
|
return axleConfiguration.map((axleUnit, axleIndex) => {
|
|
@@ -487,7 +509,7 @@ function CheckNumTiresPerAxle(_policy, _vehicleConfiguration, axleConfiguration)
|
|
|
487
509
|
* @see SingleAxleDimension
|
|
488
510
|
*/
|
|
489
511
|
function CheckPermittableWeight(policy, vehicleConfiguration, axleConfiguration) {
|
|
490
|
-
const policyId = enum_1.PolicyCheckId.
|
|
512
|
+
const policyId = enum_1.PolicyCheckId.PermittableWeight;
|
|
491
513
|
const axleUnitVehicleIndexes = getAxleUnitVehicleIndexLookup(policy, vehicleConfiguration, axleConfiguration);
|
|
492
514
|
return axleConfiguration.map((axleUnit, axleIndex) => {
|
|
493
515
|
const vehicleIndex = axleUnitVehicleIndexes[axleIndex];
|
|
@@ -1204,6 +1226,77 @@ function CheckDriveJeepLoadEqualization(_policy, vehicleConfiguration, axleConfi
|
|
|
1204
1226
|
});
|
|
1205
1227
|
return policyCheckResults;
|
|
1206
1228
|
}
|
|
1229
|
+
function getAxleUnitType(numberOfAxles) {
|
|
1230
|
+
if (numberOfAxles === 1) {
|
|
1231
|
+
return 'SINGLE';
|
|
1232
|
+
}
|
|
1233
|
+
if (numberOfAxles === 2) {
|
|
1234
|
+
return 'TANDEM';
|
|
1235
|
+
}
|
|
1236
|
+
return 'TRIDEM';
|
|
1237
|
+
}
|
|
1238
|
+
function getInteraxleSpacingRequirement(axleConfiguration, axleIndex) {
|
|
1239
|
+
// the first axle unit will never have an interaxle spacing value or previous axle unit to compare against
|
|
1240
|
+
if (axleIndex === 0) {
|
|
1241
|
+
return undefined;
|
|
1242
|
+
}
|
|
1243
|
+
const axleUnit = axleConfiguration[axleIndex];
|
|
1244
|
+
const previousAxleUnit = axleConfiguration[axleIndex - 1];
|
|
1245
|
+
if (!Number.isFinite(axleUnit.interaxleSpacing) ||
|
|
1246
|
+
!Number.isFinite(previousAxleUnit.numberOfAxles)) {
|
|
1247
|
+
return undefined;
|
|
1248
|
+
}
|
|
1249
|
+
const previousAxleUnitType = getAxleUnitType(previousAxleUnit.numberOfAxles);
|
|
1250
|
+
const currentAxleUnitType = getAxleUnitType(axleUnit.numberOfAxles);
|
|
1251
|
+
return {
|
|
1252
|
+
min: INTERAXLE_SPACING_MINIMUM_CM[previousAxleUnitType][currentAxleUnitType],
|
|
1253
|
+
};
|
|
1254
|
+
}
|
|
1255
|
+
function formatMeters(cm) {
|
|
1256
|
+
return (cm / 100).toFixed(2).replace(/\.0+$/u, '');
|
|
1257
|
+
}
|
|
1258
|
+
function getFailedInteraxleSpacingMessage(requirement, previousAxleUnitNumber, currentAxleUnitNumber) {
|
|
1259
|
+
if (requirement.groupLabel) {
|
|
1260
|
+
if (requirement.min && requirement.max) {
|
|
1261
|
+
return `Interaxle Spacing for ${requirement.groupLabel} must be between ${formatMeters(requirement.min)} m and ${formatMeters(requirement.max)} m.`;
|
|
1262
|
+
}
|
|
1263
|
+
if (requirement.min) {
|
|
1264
|
+
return `Interaxle Spacing for ${requirement.groupLabel} must be at least ${formatMeters(requirement.min)} m.`;
|
|
1265
|
+
}
|
|
1266
|
+
}
|
|
1267
|
+
if (requirement.min) {
|
|
1268
|
+
return `Interaxle Spacing between Axle Unit ${previousAxleUnitNumber} and Axle Unit ${currentAxleUnitNumber} must be at least ${formatMeters(requirement.min)} m.`;
|
|
1269
|
+
}
|
|
1270
|
+
return '';
|
|
1271
|
+
}
|
|
1272
|
+
/**
|
|
1273
|
+
* Validates each axle unit against the minimum interaxle spacing for its
|
|
1274
|
+
* current axle unit and the next axle unit, per Table II.
|
|
1275
|
+
*/
|
|
1276
|
+
function CheckLegalInteraxleSpacing(_policy, _vehicleConfiguration, axleConfiguration) {
|
|
1277
|
+
const policyId = enum_1.PolicyCheckId.LegalInteraxleSpacing;
|
|
1278
|
+
return axleConfiguration.map((axleUnit, axleIndex) => {
|
|
1279
|
+
const requirement = getInteraxleSpacingRequirement(axleConfiguration, axleIndex);
|
|
1280
|
+
// Pass when no requirement exists, interaxle spacing is missing, or interaxle spacing falls within the requirement's min/max bounds.
|
|
1281
|
+
const shouldPass = !requirement ||
|
|
1282
|
+
!axleUnit.interaxleSpacing ||
|
|
1283
|
+
((!requirement.min || axleUnit.interaxleSpacing >= requirement.min) &&
|
|
1284
|
+
(!requirement.max || axleUnit.interaxleSpacing <= requirement.max));
|
|
1285
|
+
const axleUnitNumber = axleIndex + 1;
|
|
1286
|
+
const previousAxleUnitNumber = axleIndex;
|
|
1287
|
+
const message = shouldPass
|
|
1288
|
+
? ''
|
|
1289
|
+
: getFailedInteraxleSpacingMessage(requirement, previousAxleUnitNumber, axleUnitNumber);
|
|
1290
|
+
return {
|
|
1291
|
+
id: policyId,
|
|
1292
|
+
message,
|
|
1293
|
+
result: shouldPass
|
|
1294
|
+
? enum_1.PolicyCheckResultType.Pass
|
|
1295
|
+
: enum_1.PolicyCheckResultType.Fail,
|
|
1296
|
+
axleUnit: axleUnitNumber,
|
|
1297
|
+
};
|
|
1298
|
+
});
|
|
1299
|
+
}
|
|
1207
1300
|
/**
|
|
1208
1301
|
* Map of policy check functions keyed by their corresponding PolicyCheckId.
|
|
1209
1302
|
*
|
|
@@ -1240,8 +1333,8 @@ exports.policyCheckMap = new Map([
|
|
|
1240
1333
|
enum_1.PolicyCheckId.AxleGroupMaximumLegalWeightThreshold,
|
|
1241
1334
|
CheckAxleGroupMaximumLegalWeightThreshold,
|
|
1242
1335
|
],
|
|
1243
|
-
[enum_1.PolicyCheckId.
|
|
1244
|
-
[enum_1.PolicyCheckId.
|
|
1336
|
+
[enum_1.PolicyCheckId.LegalWeight, CheckLegalWeight],
|
|
1337
|
+
[enum_1.PolicyCheckId.PermittableWeight, CheckPermittableWeight],
|
|
1245
1338
|
[enum_1.PolicyCheckId.MaxTireLoad, CheckMaxTireLoad],
|
|
1246
1339
|
[enum_1.PolicyCheckId.MinDriveAxleWeight, CheckMinDriveAxleWeight],
|
|
1247
1340
|
[enum_1.PolicyCheckId.MinSteerAxleWeight, CheckMinSteerAxleWeight],
|
|
@@ -1251,6 +1344,7 @@ exports.policyCheckMap = new Map([
|
|
|
1251
1344
|
CheckPickerTruckTractorWeightRestrictions,
|
|
1252
1345
|
],
|
|
1253
1346
|
[enum_1.PolicyCheckId.NumberOfWheelsPerAxle, CheckNumTiresPerAxle],
|
|
1347
|
+
[enum_1.PolicyCheckId.LegalInteraxleSpacing, CheckLegalInteraxleSpacing],
|
|
1254
1348
|
[enum_1.PolicyCheckId.BoosterAxleLimit, CheckBoosterAxleLimit],
|
|
1255
1349
|
[enum_1.PolicyCheckId.DriveJeepLoadEqualization, CheckDriveJeepLoadEqualization],
|
|
1256
1350
|
[enum_1.PolicyCheckId.WheelbaseLegalLimits, CheckWheelbaseLegalLimits],
|
package/dist/policy-engine.js
CHANGED
|
@@ -93,7 +93,7 @@ class Policy {
|
|
|
93
93
|
// has a no fee flag set.
|
|
94
94
|
if ((_d = this.specialAuthorizations) === null || _d === void 0 ? void 0 : _d.noFeeType) {
|
|
95
95
|
const originalPermitCost = validationResults === null || validationResults === void 0 ? void 0 : validationResults.cost.reduce((accumulator, { cost }) => accumulator + (cost !== null && cost !== void 0 ? cost : 0), 0);
|
|
96
|
-
if (permit.permitType !==
|
|
96
|
+
if (permit.permitType !== 'STWSE') {
|
|
97
97
|
// Clear the cost array and replace with zero cost
|
|
98
98
|
validationResults.cost.length = 0;
|
|
99
99
|
const newPermitCostResult = new validation_result_1.ValidationResult(enum_1.ValidationResultType.Cost, enum_1.ValidationResultCode.CostValue, cost_1.DEFAULT_COST_DESCRIPTION);
|
|
@@ -102,7 +102,7 @@ class Policy {
|
|
|
102
102
|
}
|
|
103
103
|
else {
|
|
104
104
|
// If permit type is STWSE, keep each of the cost objects, but set their costs to zero
|
|
105
|
-
const newPermitCosts = validationResults.cost.map(cost => {
|
|
105
|
+
const newPermitCosts = validationResults.cost.map((cost) => {
|
|
106
106
|
const newPermitCostResult = new validation_result_1.ValidationResult(enum_1.ValidationResultType.Cost, enum_1.ValidationResultCode.CostValue, cost.message);
|
|
107
107
|
newPermitCostResult.cost = 0;
|
|
108
108
|
return newPermitCostResult;
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "v2.
|
|
1
|
+
export declare const version = "v2.25.0";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED