onroute-policy-engine 2.4.1 → 2.5.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/enum/policy-check.d.ts +1 -0
- package/dist/enum/policy-check.js +1 -0
- package/dist/helper/policy-check.helper.d.ts +15 -1
- package/dist/helper/policy-check.helper.js +42 -0
- package/dist/policy-engine.js +22 -3
- package/dist/types/axle-calculation-results.d.ts +2 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
|
@@ -13,5 +13,6 @@ var PolicyCheckId;
|
|
|
13
13
|
PolicyCheckId["MaxTireLoad"] = "max-tire-load";
|
|
14
14
|
PolicyCheckId["MinDriveAxleWeight"] = "minimum-drive-axle-weight";
|
|
15
15
|
PolicyCheckId["MinSteerAxleWeight"] = "minimum-steer-axle-weight";
|
|
16
|
+
PolicyCheckId["NumberOfAxles"] = "number-of-axles";
|
|
16
17
|
PolicyCheckId["NumberOfWheelsPerAxle"] = "number-of-wheels";
|
|
17
18
|
})(PolicyCheckId || (exports.PolicyCheckId = PolicyCheckId = {}));
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PolicyCheckResult, AxleConfiguration } from 'onroute-policy-engine/types';
|
|
1
|
+
import { PolicyCheckResult, AxleConfiguration, AxleGroupPolicyCheckResult } from 'onroute-policy-engine/types';
|
|
2
2
|
import { Policy } from 'onroute-policy-engine';
|
|
3
3
|
/**
|
|
4
4
|
* Type definition for policy check functions.
|
|
@@ -14,6 +14,19 @@ import { Policy } from 'onroute-policy-engine';
|
|
|
14
14
|
* @returns Array of PolicyCheckResult objects representing the outcomes of the policy check
|
|
15
15
|
*/
|
|
16
16
|
type PolicyCheck = (policy: Policy, vehicleConfiguration: Array<string>, axleConfiguration: Array<AxleConfiguration>) => Array<PolicyCheckResult>;
|
|
17
|
+
/**
|
|
18
|
+
* Validates the number of axles in each axle unit.
|
|
19
|
+
*
|
|
20
|
+
* Axle unit counts must be whole numbers from 1 to 3. This check runs before
|
|
21
|
+
* the other axle policy checks because bridge and weight calculations assume a
|
|
22
|
+
* valid axle count.
|
|
23
|
+
*
|
|
24
|
+
* @param _policy - The policy instance (unused in this check, but required by PolicyCheck type)
|
|
25
|
+
* @param _vehicleConfiguration - Vehicle configuration (unused in this check, but required by PolicyCheck type)
|
|
26
|
+
* @param axleConfiguration - Array of axle configurations containing axle count information
|
|
27
|
+
* @returns Array of AxleGroupPolicyCheckResult objects, one for each axle unit tested
|
|
28
|
+
*/
|
|
29
|
+
export declare function CheckNumberOfAxles(_policy: Policy, _vehicleConfiguration: Array<string>, axleConfiguration: Array<AxleConfiguration>): Array<AxleGroupPolicyCheckResult>;
|
|
17
30
|
/**
|
|
18
31
|
* Performs bridge formula calculations on axle groups and returns policy check results.
|
|
19
32
|
*
|
|
@@ -223,6 +236,7 @@ export declare function CheckMaxTireLoad(_policy: Policy, _vehicleConfiguration:
|
|
|
223
236
|
* - MaxTireLoad: Validates tire load capacity for each axle unit
|
|
224
237
|
* - MinDriveAxleWeight: Validates minimum weight requirements for drive axles
|
|
225
238
|
* - MinSteerAxleWeight: Validates minimum weight requirements for steer axles
|
|
239
|
+
* - NumberOfAxles: Validates axle count per axle unit
|
|
226
240
|
* - NumberOfWheelsPerAxle: Validates tire count per axle unit
|
|
227
241
|
*
|
|
228
242
|
* @see PolicyCheck
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.policyCheckMap = void 0;
|
|
4
|
+
exports.CheckNumberOfAxles = CheckNumberOfAxles;
|
|
4
5
|
exports.CheckBridgeFormula = CheckBridgeFormula;
|
|
5
6
|
exports.CheckNumTiresPerAxle = CheckNumTiresPerAxle;
|
|
6
7
|
exports.CheckPermittableWeight = CheckPermittableWeight;
|
|
@@ -8,6 +9,45 @@ exports.CheckMinSteerAxleWeight = CheckMinSteerAxleWeight;
|
|
|
8
9
|
exports.CheckMinDriveAxleWeight = CheckMinDriveAxleWeight;
|
|
9
10
|
exports.CheckMaxTireLoad = CheckMaxTireLoad;
|
|
10
11
|
const enum_1 = require("../enum");
|
|
12
|
+
/**
|
|
13
|
+
* Validates the number of axles in each axle unit.
|
|
14
|
+
*
|
|
15
|
+
* Axle unit counts must be whole numbers from 1 to 3. This check runs before
|
|
16
|
+
* the other axle policy checks because bridge and weight calculations assume a
|
|
17
|
+
* valid axle count.
|
|
18
|
+
*
|
|
19
|
+
* @param _policy - The policy instance (unused in this check, but required by PolicyCheck type)
|
|
20
|
+
* @param _vehicleConfiguration - Vehicle configuration (unused in this check, but required by PolicyCheck type)
|
|
21
|
+
* @param axleConfiguration - Array of axle configurations containing axle count information
|
|
22
|
+
* @returns Array of AxleGroupPolicyCheckResult objects, one for each axle unit tested
|
|
23
|
+
*/
|
|
24
|
+
function CheckNumberOfAxles(_policy, _vehicleConfiguration, axleConfiguration) {
|
|
25
|
+
const policyCheckResults = new Array();
|
|
26
|
+
const policyId = enum_1.PolicyCheckId.NumberOfAxles;
|
|
27
|
+
axleConfiguration.forEach((ac, i) => {
|
|
28
|
+
const axleUnit = i + 1;
|
|
29
|
+
const numberOfAxles = ac.numberOfAxles;
|
|
30
|
+
const validNumber = Number.isFinite(numberOfAxles) && Number.isInteger(numberOfAxles);
|
|
31
|
+
let result = enum_1.PolicyCheckResultType.Pass;
|
|
32
|
+
let message = `No. of Axles for Axle Unit ${axleUnit} is permittable.`;
|
|
33
|
+
if (!validNumber || numberOfAxles < 1) {
|
|
34
|
+
result = enum_1.PolicyCheckResultType.Fail;
|
|
35
|
+
message = `No. of Axles for Axle Unit ${axleUnit} cannot be 0.`;
|
|
36
|
+
}
|
|
37
|
+
else if (numberOfAxles > 3) {
|
|
38
|
+
result = enum_1.PolicyCheckResultType.Fail;
|
|
39
|
+
message = `No. of Axles for Axle Unit ${axleUnit} is not permittable.`;
|
|
40
|
+
}
|
|
41
|
+
policyCheckResults.push({
|
|
42
|
+
id: policyId,
|
|
43
|
+
message,
|
|
44
|
+
result,
|
|
45
|
+
startAxleUnit: axleUnit,
|
|
46
|
+
endAxleUnit: axleUnit,
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
return policyCheckResults;
|
|
50
|
+
}
|
|
11
51
|
/**
|
|
12
52
|
* Performs bridge formula calculations on axle groups and returns policy check results.
|
|
13
53
|
*
|
|
@@ -467,6 +507,7 @@ function CheckMaxTireLoad(_policy, _vehicleConfiguration, axleConfiguration) {
|
|
|
467
507
|
* - MaxTireLoad: Validates tire load capacity for each axle unit
|
|
468
508
|
* - MinDriveAxleWeight: Validates minimum weight requirements for drive axles
|
|
469
509
|
* - MinSteerAxleWeight: Validates minimum weight requirements for steer axles
|
|
510
|
+
* - NumberOfAxles: Validates axle count per axle unit
|
|
470
511
|
* - NumberOfWheelsPerAxle: Validates tire count per axle unit
|
|
471
512
|
*
|
|
472
513
|
* @see PolicyCheck
|
|
@@ -474,6 +515,7 @@ function CheckMaxTireLoad(_policy, _vehicleConfiguration, axleConfiguration) {
|
|
|
474
515
|
* @see runAxleCalculation
|
|
475
516
|
*/
|
|
476
517
|
exports.policyCheckMap = new Map([
|
|
518
|
+
[enum_1.PolicyCheckId.NumberOfAxles, CheckNumberOfAxles],
|
|
477
519
|
[enum_1.PolicyCheckId.BridgeFormula, CheckBridgeFormula],
|
|
478
520
|
[enum_1.PolicyCheckId.CheckPermittableWeight, CheckPermittableWeight],
|
|
479
521
|
[enum_1.PolicyCheckId.MaxTireLoad, CheckMaxTireLoad],
|
package/dist/policy-engine.js
CHANGED
|
@@ -696,11 +696,30 @@ class Policy {
|
|
|
696
696
|
*/
|
|
697
697
|
runAxleCalculation(vehicleConfiguration, axleConfiguration, licensedGVW) {
|
|
698
698
|
const axleCalcResults = { results: [], totalOverload: 0 };
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
699
|
+
// This is a little helper closure that just converts any PolicyCheckResult into an AxleGroupPolicyCheckResult,
|
|
700
|
+
// basically giving us startAxleUnit and endAxleUnit, which can help with frontend form highlighting.
|
|
701
|
+
const toAxleGroupPolicyCheckResult = (result) => {
|
|
702
|
+
if ('startAxleUnit' in result && 'endAxleUnit' in result) {
|
|
703
|
+
return result;
|
|
704
|
+
}
|
|
705
|
+
if ('axleUnit' in result && typeof result.axleUnit === 'number') {
|
|
706
|
+
return Object.assign(Object.assign({}, result), { startAxleUnit: result.axleUnit, endAxleUnit: result.axleUnit });
|
|
707
|
+
}
|
|
708
|
+
return Object.assign(Object.assign({}, result), { startAxleUnit: 1, endAxleUnit: axleConfiguration.length });
|
|
709
|
+
};
|
|
702
710
|
const gvcw = axleConfiguration.reduce((w, curr) => w + curr.axleUnitWeight, 0);
|
|
703
711
|
axleCalcResults.totalOverload = Math.max(axleCalcResults.totalOverload, gvcw - licensedGVW);
|
|
712
|
+
const axleCountResults = (0, policy_check_helper_1.CheckNumberOfAxles)(this, vehicleConfiguration, axleConfiguration);
|
|
713
|
+
axleCalcResults.results.push(...axleCountResults.map(toAxleGroupPolicyCheckResult));
|
|
714
|
+
if (axleCountResults.some((r) => r.result === enum_1.PolicyCheckResultType.Fail)) {
|
|
715
|
+
return axleCalcResults;
|
|
716
|
+
}
|
|
717
|
+
for (const [policyCheckId, policyCheck] of policy_check_helper_1.policyCheckMap) {
|
|
718
|
+
if (policyCheckId === enum_1.PolicyCheckId.NumberOfAxles) {
|
|
719
|
+
continue;
|
|
720
|
+
}
|
|
721
|
+
axleCalcResults.results.push(...policyCheck(this, vehicleConfiguration, axleConfiguration).map(toAxleGroupPolicyCheckResult));
|
|
722
|
+
}
|
|
704
723
|
return axleCalcResults;
|
|
705
724
|
}
|
|
706
725
|
/**
|
|
@@ -9,8 +9,8 @@ import { PolicyCheckResultType } from 'onroute-policy-engine/enum';
|
|
|
9
9
|
* Complete results from axle calculations including all policy checks and total overload
|
|
10
10
|
*/
|
|
11
11
|
export type AxleCalcResults = {
|
|
12
|
-
/** Array of individual policy check results */
|
|
13
|
-
results: Array<
|
|
12
|
+
/** Array of individual axle group policy check results */
|
|
13
|
+
results: Array<AxleGroupPolicyCheckResult>;
|
|
14
14
|
/** Total weight overload across all axles in kilograms */
|
|
15
15
|
totalOverload: number;
|
|
16
16
|
};
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "v2.
|
|
1
|
+
export declare const version = "v2.5.1";
|
package/dist/version.js
CHANGED
package/package.json
CHANGED