onroute-policy-engine 2.6.0 → 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.
@@ -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.6.0";
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.6.0';
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.6.0"
94
+ "version": "v2.7.0"
95
95
  }