onroute-policy-engine 2.5.2 → 2.7.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.
@@ -3,6 +3,7 @@ export declare enum PolicyCheckResultType {
3
3
  Fail = "fail"
4
4
  }
5
5
  export declare enum PolicyCheckId {
6
+ BoosterAxleLimit = "booster-axle-limit",
6
7
  BridgeFormula = "bridge-formula",
7
8
  CheckPermittableWeight = "check-permittable-weight",
8
9
  MaxTireLoad = "max-tire-load",
@@ -8,6 +8,7 @@ var PolicyCheckResultType;
8
8
  })(PolicyCheckResultType || (exports.PolicyCheckResultType = PolicyCheckResultType = {}));
9
9
  var PolicyCheckId;
10
10
  (function (PolicyCheckId) {
11
+ PolicyCheckId["BoosterAxleLimit"] = "booster-axle-limit";
11
12
  PolicyCheckId["BridgeFormula"] = "bridge-formula";
12
13
  PolicyCheckId["CheckPermittableWeight"] = "check-permittable-weight";
13
14
  PolicyCheckId["MaxTireLoad"] = "max-tire-load";
@@ -222,6 +222,19 @@ export declare function CheckMinDriveAxleWeight(_policy: Policy, _vehicleConfigu
222
222
  * @see AxleConfiguration
223
223
  */
224
224
  export declare function CheckMaxTireLoad(_policy: Policy, _vehicleConfiguration: Array<string>, axleConfiguration: Array<AxleConfiguration>): Array<PolicyCheckResult>;
225
+ /**
226
+ * Validates that each booster has no more axles than the trailer it follows.
227
+ *
228
+ * Vehicle configuration has one power unit entry, while axle configuration has
229
+ * separate steer and drive entries for the power unit. For vehicle entries after
230
+ * the power unit, the matching axle unit index is therefore vehicle index + 1.
231
+ *
232
+ * @param _policy - The policy instance (unused in this check, but required by PolicyCheck type)
233
+ * @param vehicleConfiguration - Array of vehicle type identifiers representing the vehicle configuration
234
+ * @param axleConfiguration - Array of axle configurations containing axle count information
235
+ * @returns Array of AxleGroupPolicyCheckResult objects, one for each booster tested
236
+ */
237
+ export declare function CheckBoosterAxleLimit(_policy: Policy, vehicleConfiguration: Array<string>, axleConfiguration: Array<AxleConfiguration>): Array<PolicyCheckResult>;
225
238
  /**
226
239
  * Map of policy check functions keyed by their corresponding PolicyCheckId.
227
240
  *
@@ -238,6 +251,7 @@ export declare function CheckMaxTireLoad(_policy: Policy, _vehicleConfiguration:
238
251
  * - MinSteerAxleWeight: Validates minimum weight requirements for steer axles
239
252
  * - NumberOfAxles: Validates axle count per axle unit
240
253
  * - NumberOfWheelsPerAxle: Validates tire count per axle unit
254
+ * - BoosterAxleLimit: Validates booster axle count against the preceding trailer
241
255
  *
242
256
  * @see PolicyCheck
243
257
  * @see PolicyCheckId
@@ -8,6 +8,7 @@ exports.CheckPermittableWeight = CheckPermittableWeight;
8
8
  exports.CheckMinSteerAxleWeight = CheckMinSteerAxleWeight;
9
9
  exports.CheckMinDriveAxleWeight = CheckMinDriveAxleWeight;
10
10
  exports.CheckMaxTireLoad = CheckMaxTireLoad;
11
+ exports.CheckBoosterAxleLimit = CheckBoosterAxleLimit;
11
12
  const enum_1 = require("../enum");
12
13
  /**
13
14
  * Validates the number of axles in each axle unit.
@@ -493,6 +494,62 @@ function CheckMaxTireLoad(_policy, _vehicleConfiguration, axleConfiguration) {
493
494
  }
494
495
  return policyCheckResults;
495
496
  }
497
+ /**
498
+ * Validates that each booster has no more axles than the trailer it follows.
499
+ *
500
+ * Vehicle configuration has one power unit entry, while axle configuration has
501
+ * separate steer and drive entries for the power unit. For vehicle entries after
502
+ * the power unit, the matching axle unit index is therefore vehicle index + 1.
503
+ *
504
+ * @param _policy - The policy instance (unused in this check, but required by PolicyCheck type)
505
+ * @param vehicleConfiguration - Array of vehicle type identifiers representing the vehicle configuration
506
+ * @param axleConfiguration - Array of axle configurations containing axle count information
507
+ * @returns Array of AxleGroupPolicyCheckResult objects, one for each booster tested
508
+ */
509
+ function CheckBoosterAxleLimit(_policy, vehicleConfiguration, axleConfiguration) {
510
+ const policyCheckResults = new Array();
511
+ const policyId = enum_1.PolicyCheckId.BoosterAxleLimit;
512
+ let trailerAxleConfigIndex;
513
+ vehicleConfiguration.forEach((vehicleSubType, vehicleIndex) => {
514
+ if (vehicleIndex === 0) {
515
+ return;
516
+ }
517
+ const axleConfigIndex = vehicleIndex + 1;
518
+ if (axleConfigIndex >= axleConfiguration.length) {
519
+ return;
520
+ }
521
+ if (vehicleSubType === enum_1.AccessoryVehicleType.Booster) {
522
+ if (trailerAxleConfigIndex === undefined) {
523
+ return;
524
+ }
525
+ const boosterAxleUnit = axleConfigIndex + 1;
526
+ const trailerAxleUnit = trailerAxleConfigIndex + 1;
527
+ const result = axleConfiguration[axleConfigIndex].numberOfAxles <=
528
+ axleConfiguration[trailerAxleConfigIndex].numberOfAxles;
529
+ policyCheckResults.push({
530
+ id: policyId,
531
+ result: result
532
+ ? enum_1.PolicyCheckResultType.Pass
533
+ : enum_1.PolicyCheckResultType.Fail,
534
+ message: result
535
+ ? ''
536
+ : `No. of Axles for Axle Unit ${boosterAxleUnit} must be less than or equal to No. of Axles for Axle Unit ${trailerAxleUnit}`,
537
+ startAxleUnit: trailerAxleUnit,
538
+ endAxleUnit: boosterAxleUnit,
539
+ });
540
+ return;
541
+ }
542
+ const vehicleDefinition = _policy.getTrailerDefinition(vehicleSubType);
543
+ // Trailer definitions mark additionalAxleSubType entries as category "pseudo"
544
+ // (for example PFMAXLE), so keep comparing boosters to the last real trailer.
545
+ // Basically, skip pseudo axle units when deciding which trailer the booster follows.
546
+ if (vehicleSubType !== enum_1.AccessoryVehicleType.Jeep &&
547
+ (vehicleDefinition === null || vehicleDefinition === void 0 ? void 0 : vehicleDefinition.category) !== enum_1.VehicleCategory.Pseudo) {
548
+ trailerAxleConfigIndex = axleConfigIndex;
549
+ }
550
+ });
551
+ return policyCheckResults;
552
+ }
496
553
  /**
497
554
  * Map of policy check functions keyed by their corresponding PolicyCheckId.
498
555
  *
@@ -509,6 +566,7 @@ function CheckMaxTireLoad(_policy, _vehicleConfiguration, axleConfiguration) {
509
566
  * - MinSteerAxleWeight: Validates minimum weight requirements for steer axles
510
567
  * - NumberOfAxles: Validates axle count per axle unit
511
568
  * - NumberOfWheelsPerAxle: Validates tire count per axle unit
569
+ * - BoosterAxleLimit: Validates booster axle count against the preceding trailer
512
570
  *
513
571
  * @see PolicyCheck
514
572
  * @see PolicyCheckId
@@ -522,4 +580,5 @@ exports.policyCheckMap = new Map([
522
580
  [enum_1.PolicyCheckId.MinDriveAxleWeight, CheckMinDriveAxleWeight],
523
581
  [enum_1.PolicyCheckId.MinSteerAxleWeight, CheckMinSteerAxleWeight],
524
582
  [enum_1.PolicyCheckId.NumberOfWheelsPerAxle, CheckNumTiresPerAxle],
583
+ [enum_1.PolicyCheckId.BoosterAxleLimit, CheckBoosterAxleLimit],
525
584
  ]);
@@ -1,4 +1,4 @@
1
- import { PermitVehicleDetails, VehicleConfiguration, VehicleTypes } from 'onroute-policy-engine/types';
1
+ import { AxleConfiguration, IndexedAxleConfiguration, PermitVehicleDetails, VehicleConfiguration, VehicleInConfiguration, VehicleTypes } from 'onroute-policy-engine/types';
2
2
  /**
3
3
  * Filters out all LCV vehicles from a supplied list of vehicle IDs.
4
4
  * @param vehicleList List of vehicle IDs to filter
@@ -58,3 +58,20 @@ export declare function filterVehiclesByType(vehicleList: Array<string>, vehicle
58
58
  * // Returns: ['TRKTRAC', 'SEMITRL', 'BOOSTER']
59
59
  */
60
60
  export declare function getSimplifiedVehicleConfigurationHelper(vehicleDetails: PermitVehicleDetails, vehicleConfiguration: VehicleConfiguration): string[];
61
+ /**
62
+ * Combines axle configurations from a power unit and its trailers into a single
63
+ * array, adding the vehicle index to each axle configuration.
64
+ *
65
+ * @param powerUnitAxleConfiguration - Axle configuration for the power unit
66
+ * @param trailers - Trailer configurations that may include axle configuration
67
+ * @returns Combined axle configurations in vehicle order, where vehicleIndex 0
68
+ * represents the power unit and trailer indexes start at 1.
69
+ */
70
+ export declare function combineAxleConfigurationsHelper(powerUnitAxleConfiguration: Array<AxleConfiguration>, trailers: Array<VehicleInConfiguration>): Array<IndexedAxleConfiguration>;
71
+ /**
72
+ * Calculates the Gross Combined Vehicle Weight (GCVW) from axle unit weights.
73
+ *
74
+ * @param axleConfiguration - Axle configuration to total
75
+ * @returns Sum of axle unit weights, treating missing weights as 0.
76
+ */
77
+ export declare function calculateGCVWHelper(axleConfiguration: Array<AxleConfiguration>): number;
@@ -3,6 +3,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.filterOutLcv = filterOutLcv;
4
4
  exports.filterVehiclesByType = filterVehiclesByType;
5
5
  exports.getSimplifiedVehicleConfigurationHelper = getSimplifiedVehicleConfigurationHelper;
6
+ exports.combineAxleConfigurationsHelper = combineAxleConfigurationsHelper;
7
+ exports.calculateGCVWHelper = calculateGCVWHelper;
6
8
  const enum_1 = require("onroute-policy-engine/enum");
7
9
  /**
8
10
  * Filters out all LCV vehicles from a supplied list of vehicle IDs.
@@ -117,3 +119,33 @@ function getSimplifiedVehicleConfigurationHelper(vehicleDetails, vehicleConfigur
117
119
  }
118
120
  return fullVehicleConfiguration;
119
121
  }
122
+ /**
123
+ * Combines axle configurations from a power unit and its trailers into a single
124
+ * array, adding the vehicle index to each axle configuration.
125
+ *
126
+ * @param powerUnitAxleConfiguration - Axle configuration for the power unit
127
+ * @param trailers - Trailer configurations that may include axle configuration
128
+ * @returns Combined axle configurations in vehicle order, where vehicleIndex 0
129
+ * represents the power unit and trailer indexes start at 1.
130
+ */
131
+ function combineAxleConfigurationsHelper(powerUnitAxleConfiguration, trailers) {
132
+ const powerUnitAxles = powerUnitAxleConfiguration.map((axle) => (Object.assign(Object.assign({}, axle), { vehicleIndex: 0 })));
133
+ const trailerAxles = trailers.flatMap((trailer, trailerIndex) => {
134
+ var _a;
135
+ return ((_a = trailer.axleConfiguration) !== null && _a !== void 0 ? _a : []).map((axle) => (Object.assign(Object.assign({}, axle), { vehicleIndex: trailerIndex + 1 })));
136
+ });
137
+ return [...powerUnitAxles, ...trailerAxles];
138
+ }
139
+ /**
140
+ * Calculates the Gross Combined Vehicle Weight (GCVW) from axle unit weights.
141
+ *
142
+ * @param axleConfiguration - Axle configuration to total
143
+ * @returns Sum of axle unit weights, treating missing weights as 0.
144
+ */
145
+ function calculateGCVWHelper(axleConfiguration) {
146
+ return axleConfiguration.reduce((totalWeight, axleUnit) => {
147
+ var _a;
148
+ const axleUnitWeight = (_a = axleUnit.axleUnitWeight) !== null && _a !== void 0 ? _a : 0;
149
+ return totalWeight + axleUnitWeight;
150
+ }, 0);
151
+ }
@@ -1,4 +1,4 @@
1
- import { PolicyDefinition, PermitType, Commodity, VehicleType, SizeDimension, AxleConfiguration, BridgeCalculationResult, ConditionForPermit, TrailerType, PowerUnitType, TrailerWeightDimension, PowerUnitWeightDimension, WeightDimension, SingleAxleDimension, StandardTireSize, TrailerDimensions, AxleCalcResults, PermitVehicleDetails, VehicleConfiguration } from 'onroute-policy-engine/types';
1
+ import { PolicyDefinition, PermitType, Commodity, VehicleType, SizeDimension, AxleConfiguration, IndexedAxleConfiguration, BridgeCalculationResult, ConditionForPermit, TrailerType, PowerUnitType, TrailerWeightDimension, PowerUnitWeightDimension, WeightDimension, SingleAxleDimension, StandardTireSize, TrailerDimensions, AxleCalcResults, PermitVehicleDetails, VehicleConfiguration, VehicleInConfiguration } from 'onroute-policy-engine/types';
2
2
  import { Engine } from 'json-rules-engine';
3
3
  import { ValidationResults } from './validation-results';
4
4
  import { SpecialAuthorizations } from './types/special-authorizations';
@@ -341,6 +341,23 @@ export declare class Policy {
341
341
  * // Returns: ['TRKTRAC']
342
342
  */
343
343
  getSimplifiedVehicleConfiguration(vehicleDetails: PermitVehicleDetails, vehicleConfiguration: VehicleConfiguration): string[];
344
+ /**
345
+ * Combines axle configurations from a power unit and its trailers into a
346
+ * single axle configuration array, adding a vehicle index to each axle unit.
347
+ *
348
+ * @param powerUnitAxleConfiguration - Axle configuration for the power unit
349
+ * @param trailers - Trailer configurations that may include axle configuration
350
+ * @returns Combined axle configurations in vehicle order, where vehicleIndex 0
351
+ * represents the power unit and trailer indexes start at 1.
352
+ */
353
+ combineAxleConfigurations(powerUnitAxleConfiguration: Array<AxleConfiguration>, trailers: Array<VehicleInConfiguration>): Array<IndexedAxleConfiguration>;
354
+ /**
355
+ * Calculates the Gross Combined Vehicle Weight (GCVW) from axle unit weights.
356
+ *
357
+ * @param axleConfiguration - Axle configuration to total
358
+ * @returns Sum of axle unit weights, treating missing weights as 0.
359
+ */
360
+ calculateGCVW(axleConfiguration: Array<AxleConfiguration>): number;
344
361
  /**
345
362
  * Given a commodity and selected power unit subtype for a permit type,
346
363
  * return whether or not axle units can be added to the power unit.
@@ -877,6 +877,27 @@ class Policy {
877
877
  getSimplifiedVehicleConfiguration(vehicleDetails, vehicleConfiguration) {
878
878
  return (0, vehicles_helper_1.getSimplifiedVehicleConfigurationHelper)(vehicleDetails, vehicleConfiguration);
879
879
  }
880
+ /**
881
+ * Combines axle configurations from a power unit and its trailers into a
882
+ * single axle configuration array, adding a vehicle index to each axle unit.
883
+ *
884
+ * @param powerUnitAxleConfiguration - Axle configuration for the power unit
885
+ * @param trailers - Trailer configurations that may include axle configuration
886
+ * @returns Combined axle configurations in vehicle order, where vehicleIndex 0
887
+ * represents the power unit and trailer indexes start at 1.
888
+ */
889
+ combineAxleConfigurations(powerUnitAxleConfiguration, trailers) {
890
+ return (0, vehicles_helper_1.combineAxleConfigurationsHelper)(powerUnitAxleConfiguration, trailers);
891
+ }
892
+ /**
893
+ * Calculates the Gross Combined Vehicle Weight (GCVW) from axle unit weights.
894
+ *
895
+ * @param axleConfiguration - Axle configuration to total
896
+ * @returns Sum of axle unit weights, treating missing weights as 0.
897
+ */
898
+ calculateGCVW(axleConfiguration) {
899
+ return (0, vehicles_helper_1.calculateGCVWHelper)(axleConfiguration);
900
+ }
880
901
  /**
881
902
  * Given a commodity and selected power unit subtype for a permit type,
882
903
  * return whether or not axle units can be added to the power unit.
@@ -18,3 +18,7 @@ export type AxleConfiguration = {
18
18
  /** Tire size in centimetres */
19
19
  tireSize?: number;
20
20
  };
21
+ export type IndexedAxleConfiguration = AxleConfiguration & {
22
+ /** Index of the vehicle carrying this axle unit, where 0 is the power unit */
23
+ vehicleIndex: number;
24
+ };
@@ -1,5 +1,5 @@
1
1
  export { AxleCalcResults, PolicyCheckResult, AxleUnitPolicyCheckResult, AxleGroupPolicyCheckResult, } from './axle-calculation-results';
2
- export { AxleConfiguration } from './axle-configuration';
2
+ export { AxleConfiguration, IndexedAxleConfiguration, } from './axle-configuration';
3
3
  export { BridgeCalculationConstants } from './bridge-calculation-constants';
4
4
  export { BridgeCalculationResult } from './bridge-calculation-result';
5
5
  export { Commodity } from './commodity';
@@ -143,6 +143,8 @@ export type PermittedCommodity = {
143
143
  export type VehicleInConfiguration = {
144
144
  /** Subtype of the vehicle */
145
145
  vehicleSubType: string;
146
+ /** Axle configuration details for this vehicle (optional) */
147
+ axleConfiguration?: Array<AxleConfiguration> | null;
146
148
  };
147
149
  /**
148
150
  * Complete vehicle configuration including dimensions and axles
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "v2.5.2";
1
+ export declare const version = "v2.7.0";
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.5.2';
5
+ exports.version = 'v2.7.0';
package/package.json CHANGED
@@ -91,5 +91,5 @@
91
91
  ],
92
92
  "testEnvironment": "node"
93
93
  },
94
- "version": "v2.5.2"
94
+ "version": "v2.7.0"
95
95
  }