onroute-policy-engine 2.1.0 → 2.2.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/.github/workflows/pipeline.yml +25 -6
- package/dist/enum/custom-operator.d.ts +6 -0
- package/dist/enum/custom-operator.js +10 -0
- package/dist/enum/facts.d.ts +8 -4
- package/dist/enum/facts.js +8 -4
- package/dist/enum/index.d.ts +2 -0
- package/dist/enum/index.js +6 -1
- package/dist/enum/permit-app-info.d.ts +8 -5
- package/dist/enum/permit-app-info.js +8 -5
- package/dist/enum/policy-check.d.ts +11 -0
- package/dist/enum/policy-check.js +16 -0
- package/dist/enum/validation-result-code.d.ts +1 -0
- package/dist/enum/validation-result-code.js +1 -0
- package/dist/helper/dimensions.helper.js +7 -3
- package/dist/helper/display-code-helper.d.ts +42 -0
- package/dist/helper/display-code-helper.js +73 -1
- package/dist/helper/facts.helper.js +64 -0
- package/dist/helper/policy-check.helper.d.ts +183 -0
- package/dist/helper/policy-check.helper.js +337 -0
- package/dist/helper/vehicles.helper.d.ts +45 -1
- package/dist/helper/vehicles.helper.js +61 -0
- package/dist/policy-engine.d.ts +95 -1
- package/dist/policy-engine.js +103 -0
- package/dist/rule-operator/custom-operators.d.ts +7 -0
- package/dist/rule-operator/custom-operators.js +57 -3
- package/dist/types/axle-calculation-results.d.ts +49 -0
- package/dist/types/axle-calculation-results.js +8 -0
- package/dist/types/axle-configuration.d.ts +12 -0
- package/dist/types/axle-configuration.js +6 -0
- package/dist/types/bridge-calculation-constants.d.ts +8 -0
- package/dist/types/bridge-calculation-result.d.ts +11 -0
- package/dist/types/commodity.d.ts +10 -0
- package/dist/types/commodity.js +6 -0
- package/dist/types/cost-rule.d.ts +8 -0
- package/dist/types/cost-rule.js +6 -0
- package/dist/types/dimension-modifier.d.ts +27 -0
- package/dist/types/dimension-modifier.js +6 -0
- package/dist/types/display-code-defaults.d.ts +22 -0
- package/dist/types/display-code-defaults.js +6 -0
- package/dist/types/facts.d.ts +14 -0
- package/dist/types/facts.js +6 -0
- package/dist/types/geographic-region.d.ts +10 -0
- package/dist/types/geographic-region.js +6 -0
- package/dist/types/identified-object.d.ts +8 -0
- package/dist/types/identified-object.js +6 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/permit-application.d.ts +109 -0
- package/dist/types/permit-application.js +6 -0
- package/dist/types/permit-condition.d.ts +18 -0
- package/dist/types/permit-condition.js +6 -0
- package/dist/types/permit-type.d.ts +18 -0
- package/dist/types/permit-type.js +6 -0
- package/dist/types/policy-definition.d.ts +24 -0
- package/dist/types/policy-definition.js +7 -0
- package/dist/types/range-matrix.d.ts +17 -0
- package/dist/types/range-matrix.js +6 -0
- package/dist/types/region-size-override.d.ts +10 -0
- package/dist/types/region-size-override.js +6 -0
- package/dist/types/self-issuable.d.ts +7 -0
- package/dist/types/self-issuable.js +6 -0
- package/dist/types/size-dimension.d.ts +17 -0
- package/dist/types/size-dimension.js +6 -0
- package/dist/types/special-authorizations.d.ts +9 -0
- package/dist/types/special-authorizations.js +6 -0
- package/dist/types/standard-tire-size.d.ts +8 -0
- package/dist/types/standard-tire-size.js +6 -0
- package/dist/types/vehicle-category.d.ts +27 -0
- package/dist/types/vehicle-category.js +6 -0
- package/dist/types/vehicle-type.d.ts +36 -0
- package/dist/types/vehicle-type.js +6 -0
- package/dist/types/vehicle.d.ts +27 -0
- package/dist/types/vehicle.js +6 -0
- package/dist/types/weight-dimension.d.ts +34 -0
- package/dist/types/weight-dimension.js +6 -0
- package/dist/validation-result.d.ts +1 -0
- package/dist/validation-results.js +2 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/eslint.config.mjs +1 -1
- package/package.json +2 -1
package/dist/policy-engine.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { PolicyDefinition, PermitType, Commodity, VehicleType, SizeDimension, AxleConfiguration, BridgeCalculationResult, ConditionForPermit, TrailerType, PowerUnitType, TrailerWeightDimension, PowerUnitWeightDimension, WeightDimension, SingleAxleDimension, StandardTireSize, TrailerDimensions } from 'onroute-policy-engine/types';
|
|
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';
|
|
2
2
|
import { Engine } from 'json-rules-engine';
|
|
3
3
|
import { ValidationResults } from './validation-results';
|
|
4
4
|
import { SpecialAuthorizations } from './types/special-authorizations';
|
|
@@ -186,6 +186,42 @@ export declare class Policy {
|
|
|
186
186
|
* axle group in the vehicle configuration
|
|
187
187
|
*/
|
|
188
188
|
calculateBridge(axleConfig: Array<AxleConfiguration>): Array<BridgeCalculationResult>;
|
|
189
|
+
/**
|
|
190
|
+
* Runs all configured axle calculation policy checks against a vehicle configuration.
|
|
191
|
+
*
|
|
192
|
+
* This method iterates through all registered policy check functions (such as bridge formula
|
|
193
|
+
* calculations and tire count validations) and applies them to the provided vehicle and axle
|
|
194
|
+
* configurations. The results are aggregated into a single AxleCalcResults object containing
|
|
195
|
+
* all policy check outcomes and a total overload calculation.
|
|
196
|
+
*
|
|
197
|
+
* @param vehicleConfiguration Array of vehicle type identifiers representing the vehicle configuration.
|
|
198
|
+
* The first element should be a power unit type, followed by trailer types.
|
|
199
|
+
* Example: ['TRKTRAC', 'SEMITRL'] for a truck tractor with semi-trailer.
|
|
200
|
+
* @param axleConfiguration Array of axle configurations corresponding to each vehicle in the configuration.
|
|
201
|
+
* Each axle configuration contains details like number of axles, spacing, tire count, etc.
|
|
202
|
+
* The length should match the vehicleConfiguration array plus one (since the first
|
|
203
|
+
* vehicle in the configuration is a power unit with two axle units).
|
|
204
|
+
* @returns AxleCalcResults object containing:
|
|
205
|
+
* - results: Array of PolicyCheckResult objects, each representing the outcome of a specific policy check
|
|
206
|
+
* - totalOverload: Numeric value representing the total overload across all axle calculations
|
|
207
|
+
*
|
|
208
|
+
* @example
|
|
209
|
+
* // For a truck-tractor with 2-axle steer, 3-axle drive, and a 3-axle semi-trailer
|
|
210
|
+
* const results = policy.runAxleCalculation(
|
|
211
|
+
* ['TRKTRAC', 'SEMITRL'],
|
|
212
|
+
* [
|
|
213
|
+
* { numberOfAxles: 2, axleSpread: 1.8, numberOfTires: 4 },
|
|
214
|
+
* { numberOfAxles: 3, axleSpread: 4.2, numberOfTires: 12 },
|
|
215
|
+
* { numberOfAxles: 3, axleSpread: 3.0, numberOfTires: 12 }
|
|
216
|
+
* ]
|
|
217
|
+
* );
|
|
218
|
+
* // Returns results with bridge formula checks, tire count validations, etc.
|
|
219
|
+
*
|
|
220
|
+
* @see AxleCalcResults
|
|
221
|
+
* @see PolicyCheckResult
|
|
222
|
+
* @see AxleConfiguration
|
|
223
|
+
*/
|
|
224
|
+
runAxleCalculation(vehicleConfiguration: Array<string>, axleConfiguration: Array<AxleConfiguration>): AxleCalcResults;
|
|
189
225
|
/**
|
|
190
226
|
* Gets the list of allowed vehicles separated into two maps, one
|
|
191
227
|
* for trailers and one for power units. This will filter out LCV
|
|
@@ -245,5 +281,63 @@ export declare class Policy {
|
|
|
245
281
|
* none are configured
|
|
246
282
|
*/
|
|
247
283
|
getStandardTireSizes(): Array<StandardTireSize>;
|
|
284
|
+
/**
|
|
285
|
+
* Generates a vehicle display code based on the vehicle configuration and axle configuration.
|
|
286
|
+
*
|
|
287
|
+
* The display code is a string representation that describes the vehicle configuration
|
|
288
|
+
* in a standardized format. It can generate either a standard display code (for known
|
|
289
|
+
* vehicle types with configured display codes) or a universal display code (for complex
|
|
290
|
+
* or unknown configurations).
|
|
291
|
+
*
|
|
292
|
+
* @param configuration Array of vehicle type identifiers representing the vehicle configuration.
|
|
293
|
+
* The first element should be a power unit type, followed by trailer types.
|
|
294
|
+
* @param axleConfiguration Array of axle configurations corresponding to each vehicle in the configuration.
|
|
295
|
+
* Each axle configuration contains details like number of axles, spacing, etc.
|
|
296
|
+
* @returns A string representing the vehicle display code, or an empty string if the configuration is empty.
|
|
297
|
+
*
|
|
298
|
+
* @example
|
|
299
|
+
* // For a truck-tractor with 2-axle steer, 3-axle drive, and a 3-axle semi-trailer
|
|
300
|
+
* const code = policy.getVehicleDisplayCode(['TRKTRAC'], [
|
|
301
|
+
* { numberOfAxles: 2, axleSpread: 1.8, ... },
|
|
302
|
+
* { numberOfAxles: 3, axleSpread: 4.2, ... },
|
|
303
|
+
* { numberOfAxles: 3, axleSpread: 3.0, ... }
|
|
304
|
+
* ]);
|
|
305
|
+
* // Returns something like "TT2S13D23T3"
|
|
306
|
+
*
|
|
307
|
+
* @throws {Error} If vehicleDisplayCodeDefaults is not configured in the policy definition.
|
|
308
|
+
*/
|
|
248
309
|
getVehicleDisplayCode(configuration: Array<string>, axleConfiguration: Array<AxleConfiguration>): string;
|
|
310
|
+
/**
|
|
311
|
+
* Converts detailed vehicle information into a simplified vehicle configuration array.
|
|
312
|
+
*
|
|
313
|
+
* This method takes the vehicle details (which contain the power unit information) and
|
|
314
|
+
* the vehicle configuration (which contains trailer information) and combines them into
|
|
315
|
+
* a single array of vehicle type identifiers. The resulting array represents the complete
|
|
316
|
+
* vehicle configuration in the order: [powerUnit, trailer1, trailer2, ...].
|
|
317
|
+
*
|
|
318
|
+
* @param vehicleDetails - The vehicle details containing power unit information including
|
|
319
|
+
* the vehicle subtype (e.g., 'TRKTRAC' for truck-tractor)
|
|
320
|
+
* @param vehicleConfiguration - The vehicle configuration containing trailer information
|
|
321
|
+
* and other vehicle configuration details
|
|
322
|
+
* @returns An array of vehicle type identifiers representing the complete vehicle configuration.
|
|
323
|
+
* The first element is always the power unit type, followed by any attached trailer types.
|
|
324
|
+
* Returns an empty array if no power unit type is found in vehicle details.
|
|
325
|
+
*
|
|
326
|
+
* @example
|
|
327
|
+
* // For a truck-tractor with a semi-trailer
|
|
328
|
+
* const config = policy.getSimplifiedVehicleConfiguration(
|
|
329
|
+
* { vehicleSubType: 'TRKTRAC', ... },
|
|
330
|
+
* { trailers: [{ vehicleSubType: 'SEMITRL' }] }
|
|
331
|
+
* );
|
|
332
|
+
* // Returns: ['TRKTRAC', 'SEMITRL']
|
|
333
|
+
*
|
|
334
|
+
* @example
|
|
335
|
+
* // For a single power unit with no trailers
|
|
336
|
+
* const config = policy.getSimplifiedVehicleConfiguration(
|
|
337
|
+
* { vehicleSubType: 'TRKTRAC', ... },
|
|
338
|
+
* { trailers: [] }
|
|
339
|
+
* );
|
|
340
|
+
* // Returns: ['TRKTRAC']
|
|
341
|
+
*/
|
|
342
|
+
getSimplifiedVehicleConfiguration(vehicleDetails: PermitVehicleDetails, vehicleConfiguration: VehicleConfiguration): string[];
|
|
249
343
|
}
|
package/dist/policy-engine.js
CHANGED
|
@@ -20,6 +20,7 @@ const conditions_helper_1 = require("./helper/conditions.helper");
|
|
|
20
20
|
const dimensions_helper_1 = require("./helper/dimensions.helper");
|
|
21
21
|
const dimensions_helper_2 = require("./helper/dimensions.helper");
|
|
22
22
|
const display_code_helper_1 = require("./helper/display-code-helper");
|
|
23
|
+
const policy_check_helper_1 = require("./helper/policy-check.helper");
|
|
23
24
|
/** Class representing commercial vehicle policy. */
|
|
24
25
|
class Policy {
|
|
25
26
|
/**
|
|
@@ -657,6 +658,48 @@ class Policy {
|
|
|
657
658
|
}
|
|
658
659
|
return bridgeResults;
|
|
659
660
|
}
|
|
661
|
+
/**
|
|
662
|
+
* Runs all configured axle calculation policy checks against a vehicle configuration.
|
|
663
|
+
*
|
|
664
|
+
* This method iterates through all registered policy check functions (such as bridge formula
|
|
665
|
+
* calculations and tire count validations) and applies them to the provided vehicle and axle
|
|
666
|
+
* configurations. The results are aggregated into a single AxleCalcResults object containing
|
|
667
|
+
* all policy check outcomes and a total overload calculation.
|
|
668
|
+
*
|
|
669
|
+
* @param vehicleConfiguration Array of vehicle type identifiers representing the vehicle configuration.
|
|
670
|
+
* The first element should be a power unit type, followed by trailer types.
|
|
671
|
+
* Example: ['TRKTRAC', 'SEMITRL'] for a truck tractor with semi-trailer.
|
|
672
|
+
* @param axleConfiguration Array of axle configurations corresponding to each vehicle in the configuration.
|
|
673
|
+
* Each axle configuration contains details like number of axles, spacing, tire count, etc.
|
|
674
|
+
* The length should match the vehicleConfiguration array plus one (since the first
|
|
675
|
+
* vehicle in the configuration is a power unit with two axle units).
|
|
676
|
+
* @returns AxleCalcResults object containing:
|
|
677
|
+
* - results: Array of PolicyCheckResult objects, each representing the outcome of a specific policy check
|
|
678
|
+
* - totalOverload: Numeric value representing the total overload across all axle calculations
|
|
679
|
+
*
|
|
680
|
+
* @example
|
|
681
|
+
* // For a truck-tractor with 2-axle steer, 3-axle drive, and a 3-axle semi-trailer
|
|
682
|
+
* const results = policy.runAxleCalculation(
|
|
683
|
+
* ['TRKTRAC', 'SEMITRL'],
|
|
684
|
+
* [
|
|
685
|
+
* { numberOfAxles: 2, axleSpread: 1.8, numberOfTires: 4 },
|
|
686
|
+
* { numberOfAxles: 3, axleSpread: 4.2, numberOfTires: 12 },
|
|
687
|
+
* { numberOfAxles: 3, axleSpread: 3.0, numberOfTires: 12 }
|
|
688
|
+
* ]
|
|
689
|
+
* );
|
|
690
|
+
* // Returns results with bridge formula checks, tire count validations, etc.
|
|
691
|
+
*
|
|
692
|
+
* @see AxleCalcResults
|
|
693
|
+
* @see PolicyCheckResult
|
|
694
|
+
* @see AxleConfiguration
|
|
695
|
+
*/
|
|
696
|
+
runAxleCalculation(vehicleConfiguration, axleConfiguration) {
|
|
697
|
+
const axleCalcResults = { results: [], totalOverload: 0 };
|
|
698
|
+
for (const [, func] of policy_check_helper_1.policyCheckMap) {
|
|
699
|
+
axleCalcResults.results.push(...func(this, vehicleConfiguration, axleConfiguration));
|
|
700
|
+
}
|
|
701
|
+
return axleCalcResults;
|
|
702
|
+
}
|
|
660
703
|
/**
|
|
661
704
|
* Gets the list of allowed vehicles separated into two maps, one
|
|
662
705
|
* for trailers and one for power units. This will filter out LCV
|
|
@@ -749,8 +792,68 @@ class Policy {
|
|
|
749
792
|
return new Array();
|
|
750
793
|
}
|
|
751
794
|
}
|
|
795
|
+
/**
|
|
796
|
+
* Generates a vehicle display code based on the vehicle configuration and axle configuration.
|
|
797
|
+
*
|
|
798
|
+
* The display code is a string representation that describes the vehicle configuration
|
|
799
|
+
* in a standardized format. It can generate either a standard display code (for known
|
|
800
|
+
* vehicle types with configured display codes) or a universal display code (for complex
|
|
801
|
+
* or unknown configurations).
|
|
802
|
+
*
|
|
803
|
+
* @param configuration Array of vehicle type identifiers representing the vehicle configuration.
|
|
804
|
+
* The first element should be a power unit type, followed by trailer types.
|
|
805
|
+
* @param axleConfiguration Array of axle configurations corresponding to each vehicle in the configuration.
|
|
806
|
+
* Each axle configuration contains details like number of axles, spacing, etc.
|
|
807
|
+
* @returns A string representing the vehicle display code, or an empty string if the configuration is empty.
|
|
808
|
+
*
|
|
809
|
+
* @example
|
|
810
|
+
* // For a truck-tractor with 2-axle steer, 3-axle drive, and a 3-axle semi-trailer
|
|
811
|
+
* const code = policy.getVehicleDisplayCode(['TRKTRAC'], [
|
|
812
|
+
* { numberOfAxles: 2, axleSpread: 1.8, ... },
|
|
813
|
+
* { numberOfAxles: 3, axleSpread: 4.2, ... },
|
|
814
|
+
* { numberOfAxles: 3, axleSpread: 3.0, ... }
|
|
815
|
+
* ]);
|
|
816
|
+
* // Returns something like "TT2S13D23T3"
|
|
817
|
+
*
|
|
818
|
+
* @throws {Error} If vehicleDisplayCodeDefaults is not configured in the policy definition.
|
|
819
|
+
*/
|
|
752
820
|
getVehicleDisplayCode(configuration, axleConfiguration) {
|
|
753
821
|
return (0, display_code_helper_1.getVehicleDisplayCodeHelper)(this, configuration, axleConfiguration);
|
|
754
822
|
}
|
|
823
|
+
/**
|
|
824
|
+
* Converts detailed vehicle information into a simplified vehicle configuration array.
|
|
825
|
+
*
|
|
826
|
+
* This method takes the vehicle details (which contain the power unit information) and
|
|
827
|
+
* the vehicle configuration (which contains trailer information) and combines them into
|
|
828
|
+
* a single array of vehicle type identifiers. The resulting array represents the complete
|
|
829
|
+
* vehicle configuration in the order: [powerUnit, trailer1, trailer2, ...].
|
|
830
|
+
*
|
|
831
|
+
* @param vehicleDetails - The vehicle details containing power unit information including
|
|
832
|
+
* the vehicle subtype (e.g., 'TRKTRAC' for truck-tractor)
|
|
833
|
+
* @param vehicleConfiguration - The vehicle configuration containing trailer information
|
|
834
|
+
* and other vehicle configuration details
|
|
835
|
+
* @returns An array of vehicle type identifiers representing the complete vehicle configuration.
|
|
836
|
+
* The first element is always the power unit type, followed by any attached trailer types.
|
|
837
|
+
* Returns an empty array if no power unit type is found in vehicle details.
|
|
838
|
+
*
|
|
839
|
+
* @example
|
|
840
|
+
* // For a truck-tractor with a semi-trailer
|
|
841
|
+
* const config = policy.getSimplifiedVehicleConfiguration(
|
|
842
|
+
* { vehicleSubType: 'TRKTRAC', ... },
|
|
843
|
+
* { trailers: [{ vehicleSubType: 'SEMITRL' }] }
|
|
844
|
+
* );
|
|
845
|
+
* // Returns: ['TRKTRAC', 'SEMITRL']
|
|
846
|
+
*
|
|
847
|
+
* @example
|
|
848
|
+
* // For a single power unit with no trailers
|
|
849
|
+
* const config = policy.getSimplifiedVehicleConfiguration(
|
|
850
|
+
* { vehicleSubType: 'TRKTRAC', ... },
|
|
851
|
+
* { trailers: [] }
|
|
852
|
+
* );
|
|
853
|
+
* // Returns: ['TRKTRAC']
|
|
854
|
+
*/
|
|
855
|
+
getSimplifiedVehicleConfiguration(vehicleDetails, vehicleConfiguration) {
|
|
856
|
+
return (0, vehicles_helper_1.getSimplifiedVehicleConfigurationHelper)(vehicleDetails, vehicleConfiguration);
|
|
857
|
+
}
|
|
755
858
|
}
|
|
756
859
|
exports.Policy = Policy;
|
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Custom Operators for JSON Rules Engine
|
|
3
|
+
*
|
|
4
|
+
* This module defines custom operators that extend the functionality of the json-rules-engine
|
|
5
|
+
* library. These operators provide specialized validation and comparison logic for the
|
|
6
|
+
* onRouteBC policy engine.
|
|
7
|
+
*/
|
|
1
8
|
import { Operator } from 'json-rules-engine';
|
|
2
9
|
declare const CustomOperators: Array<Operator>;
|
|
3
10
|
export { CustomOperators };
|
|
@@ -1,4 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Custom Operators for JSON Rules Engine
|
|
4
|
+
*
|
|
5
|
+
* This module defines custom operators that extend the functionality of the json-rules-engine
|
|
6
|
+
* library. These operators provide specialized validation and comparison logic for the
|
|
7
|
+
* onRouteBC policy engine.
|
|
8
|
+
*/
|
|
2
9
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
10
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
11
|
};
|
|
@@ -7,23 +14,70 @@ exports.CustomOperators = void 0;
|
|
|
7
14
|
const json_rules_engine_1 = require("json-rules-engine");
|
|
8
15
|
const enum_1 = require("onroute-policy-engine/enum");
|
|
9
16
|
const dayjs_1 = __importDefault(require("dayjs"));
|
|
17
|
+
/**
|
|
18
|
+
* Validates that the input is a string type
|
|
19
|
+
* @param a - The value to validate
|
|
20
|
+
* @returns True if the value is a string, false otherwise
|
|
21
|
+
*/
|
|
10
22
|
function stringValidator(a) {
|
|
11
23
|
return typeof a === 'string';
|
|
12
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* Validates that the input is a valid date string in the permit application format
|
|
27
|
+
* @param a - The date string to validate
|
|
28
|
+
* @returns True if the date string is valid, false otherwise
|
|
29
|
+
*/
|
|
13
30
|
function dateStringValidator(a) {
|
|
14
31
|
const d = (0, dayjs_1.default)(a, enum_1.PermitAppInfo.PermitDateFormat.toString());
|
|
15
32
|
return d.isValid();
|
|
16
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Validates that the input is an array
|
|
36
|
+
* @param a - The value to validate
|
|
37
|
+
* @returns True if the value is an array, false otherwise
|
|
38
|
+
*/
|
|
39
|
+
function arrayValidator(a) {
|
|
40
|
+
return Array.isArray(a);
|
|
41
|
+
}
|
|
42
|
+
// Array to store all custom operators
|
|
17
43
|
const CustomOperators = [];
|
|
18
44
|
exports.CustomOperators = CustomOperators;
|
|
19
|
-
|
|
45
|
+
/**
|
|
46
|
+
* String Minimum Length Operator
|
|
47
|
+
*
|
|
48
|
+
* Checks if a string has a minimum length after trimming whitespace.
|
|
49
|
+
* Returns false if the input is falsy (null, undefined, empty string).
|
|
50
|
+
*/
|
|
51
|
+
CustomOperators.push(new json_rules_engine_1.Operator(enum_1.CustomOperator.StringMinimumLength, (a, b) => {
|
|
52
|
+
// Return false for falsy values
|
|
20
53
|
if (!a)
|
|
21
54
|
return false;
|
|
55
|
+
// Check if trimmed string length meets minimum requirement
|
|
22
56
|
return a.trim().length >= b;
|
|
23
57
|
}, stringValidator));
|
|
24
|
-
|
|
58
|
+
/**
|
|
59
|
+
* Date Less Than Operator
|
|
60
|
+
*
|
|
61
|
+
* Compares two date strings in permit application format.
|
|
62
|
+
* Returns true if the first date is before the second date.
|
|
63
|
+
*/
|
|
64
|
+
CustomOperators.push(new json_rules_engine_1.Operator(enum_1.CustomOperator.DateLessThan, (a, b) => {
|
|
65
|
+
// Parse both dates using the permit application date format
|
|
25
66
|
const firstDate = (0, dayjs_1.default)(a, enum_1.PermitAppInfo.PermitDateFormat.toString());
|
|
26
67
|
const secondDate = (0, dayjs_1.default)(b, enum_1.PermitAppInfo.PermitDateFormat.toString());
|
|
68
|
+
// Return true if first date is before second date (difference is negative)
|
|
27
69
|
return firstDate.diff(secondDate) < 0;
|
|
28
70
|
}, dateStringValidator));
|
|
29
|
-
|
|
71
|
+
/**
|
|
72
|
+
* Regular Expression Operator
|
|
73
|
+
*
|
|
74
|
+
* Tests if a string matches a regular expression pattern.
|
|
75
|
+
* Uses RegExp.exec() to check for matches.
|
|
76
|
+
*/
|
|
77
|
+
CustomOperators.push(new json_rules_engine_1.Operator(enum_1.CustomOperator.Regex, (a, b) => RegExp(b).exec(a) !== null, stringValidator));
|
|
78
|
+
/**
|
|
79
|
+
* Is Empty Array Operator
|
|
80
|
+
*
|
|
81
|
+
* Checks if an array is empty (has length 0).
|
|
82
|
+
*/
|
|
83
|
+
CustomOperators.push(new json_rules_engine_1.Operator(enum_1.CustomOperator.IsEmptyArray, (arr) => arr.length === 0, arrayValidator));
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Axle Calculation Results Types
|
|
3
|
+
*
|
|
4
|
+
* These types define the structure for axle calculation results and policy check outcomes.
|
|
5
|
+
* Used for validating vehicle configurations against weight and axle requirements.
|
|
6
|
+
*/
|
|
7
|
+
import { PolicyCheckResultType } from 'onroute-policy-engine/enum';
|
|
8
|
+
/**
|
|
9
|
+
* Complete results from axle calculations including all policy checks and total overload
|
|
10
|
+
*/
|
|
11
|
+
export type AxleCalcResults = {
|
|
12
|
+
/** Array of individual policy check results */
|
|
13
|
+
results: Array<PolicyCheckResult>;
|
|
14
|
+
/** Total weight overload across all axles in kilograms */
|
|
15
|
+
totalOverload: number;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Individual policy check result for a specific validation rule
|
|
19
|
+
*/
|
|
20
|
+
export type PolicyCheckResult = {
|
|
21
|
+
/** Actual weight measured/calculated in kilograms */
|
|
22
|
+
actualWeight?: number;
|
|
23
|
+
/** Maximum allowed weight threshold in kilograms */
|
|
24
|
+
thresholdWeight?: number;
|
|
25
|
+
/** Unique identifier for the policy check */
|
|
26
|
+
id: string;
|
|
27
|
+
/** Result of the policy check (pass/fail) */
|
|
28
|
+
result: PolicyCheckResultType;
|
|
29
|
+
/** Human-readable message describing the check result */
|
|
30
|
+
message: string;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Policy check result for a single axle unit
|
|
34
|
+
* Extends PolicyCheckResult with axle unit identification
|
|
35
|
+
*/
|
|
36
|
+
export type AxleUnitPolicyCheckResult = PolicyCheckResult & {
|
|
37
|
+
/** The axle unit number being checked */
|
|
38
|
+
axleUnit: number;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Policy check result for a group of axles
|
|
42
|
+
* Extends PolicyCheckResult with axle group range
|
|
43
|
+
*/
|
|
44
|
+
export type AxleGroupPolicyCheckResult = PolicyCheckResult & {
|
|
45
|
+
/** Starting axle unit number in the group */
|
|
46
|
+
startAxleUnit: number;
|
|
47
|
+
/** Ending axle unit number in the group */
|
|
48
|
+
endAxleUnit: number;
|
|
49
|
+
};
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Axle Calculation Results Types
|
|
4
|
+
*
|
|
5
|
+
* These types define the structure for axle calculation results and policy check outcomes.
|
|
6
|
+
* Used for validating vehicle configurations against weight and axle requirements.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,8 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Axle Configuration Type
|
|
3
|
+
*
|
|
4
|
+
* Defines the structure for individual axle configurations within a vehicle.
|
|
5
|
+
* Used for weight calculations, spacing requirements, and compliance validation.
|
|
6
|
+
*/
|
|
1
7
|
export type AxleConfiguration = {
|
|
8
|
+
/** Number of axles in this configuration (1 for single, 2+ for groups) */
|
|
2
9
|
numberOfAxles: number;
|
|
10
|
+
/** Total spread between first and last axle in centimeters */
|
|
3
11
|
axleSpread?: number;
|
|
12
|
+
/** Spacing from the previous axle unit in centimeters */
|
|
4
13
|
interaxleSpacing?: number;
|
|
14
|
+
/** Weight carried by this axle unit in kilograms */
|
|
5
15
|
axleUnitWeight: number;
|
|
16
|
+
/** Number of tires on this axle unit */
|
|
6
17
|
numberOfTires?: number;
|
|
18
|
+
/** Tire size in inches */
|
|
7
19
|
tireSize?: number;
|
|
8
20
|
};
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Axle Configuration Type
|
|
4
|
+
*
|
|
5
|
+
* Defines the structure for individual axle configurations within a vehicle.
|
|
6
|
+
* Used for weight calculations, spacing requirements, and compliance validation.
|
|
7
|
+
*/
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
@@ -1,4 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge Calculation Constants Type
|
|
3
|
+
*
|
|
4
|
+
* Defines constants used in bridge formula calculations for determining
|
|
5
|
+
* maximum allowable weights based on axle spacing and configuration.
|
|
6
|
+
*/
|
|
1
7
|
export type BridgeCalculationConstants = {
|
|
8
|
+
/** Multiplier factor for bridge formula calculations */
|
|
2
9
|
multiplier: number;
|
|
10
|
+
/** Minimum weight threshold in kilograms */
|
|
3
11
|
minWeight: number;
|
|
4
12
|
};
|
|
@@ -1,7 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge Calculation Result Type
|
|
3
|
+
*
|
|
4
|
+
* Defines the result structure for bridge formula calculations.
|
|
5
|
+
* Used to determine if a vehicle configuration meets bridge weight requirements.
|
|
6
|
+
*/
|
|
1
7
|
export type BridgeCalculationResult = {
|
|
8
|
+
/** Starting axle unit number in the calculation */
|
|
2
9
|
startAxleUnit: number;
|
|
10
|
+
/** Ending axle unit number in the calculation */
|
|
3
11
|
endAxleUnit: number;
|
|
12
|
+
/** Maximum allowable weight according to bridge formula in kilograms */
|
|
4
13
|
maxBridge: number;
|
|
14
|
+
/** Actual weight being carried in kilograms */
|
|
5
15
|
actualWeight: number;
|
|
16
|
+
/** Whether the configuration passes bridge formula requirements */
|
|
6
17
|
success: boolean;
|
|
7
18
|
};
|
|
@@ -1,4 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Commodity Type
|
|
3
|
+
*
|
|
4
|
+
* Defines the structure for permitted commodities that can be transported.
|
|
5
|
+
* Extends IdentifiedObject with vehicle dimension requirements.
|
|
6
|
+
*/
|
|
1
7
|
import { IdentifiedObject, VehicleDimensions } from 'onroute-policy-engine/types';
|
|
8
|
+
/**
|
|
9
|
+
* A permitted commodity that can be transported with specific vehicle requirements
|
|
10
|
+
*/
|
|
2
11
|
export type Commodity = IdentifiedObject & {
|
|
12
|
+
/** Array of power unit dimensions required for this commodity */
|
|
3
13
|
powerUnits: Array<VehicleDimensions>;
|
|
4
14
|
};
|
package/dist/types/commodity.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cost Rule Type
|
|
3
|
+
*
|
|
4
|
+
* Defines the structure for cost calculation rules used in permit pricing.
|
|
5
|
+
* Maps facts to parameters for dynamic cost calculations.
|
|
6
|
+
*/
|
|
1
7
|
export type CostRule = {
|
|
8
|
+
/** The fact identifier used in the cost calculation */
|
|
2
9
|
fact: string;
|
|
10
|
+
/** Parameters passed to the cost calculation function */
|
|
3
11
|
params: Record<string, any>;
|
|
4
12
|
};
|
package/dist/types/cost-rule.js
CHANGED
|
@@ -1,19 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dimension Modifier Types
|
|
3
|
+
*
|
|
4
|
+
* Defines structures for modifying vehicle dimensions based on configuration
|
|
5
|
+
* and relationships between vehicle components.
|
|
6
|
+
*/
|
|
1
7
|
import { SelfIssuable } from 'onroute-policy-engine/types';
|
|
8
|
+
/**
|
|
9
|
+
* Modifier for adjusting vehicle dimensions based on configuration
|
|
10
|
+
* Extends SelfIssuable to include self-issuance capability
|
|
11
|
+
*/
|
|
2
12
|
export type DimensionModifier = SelfIssuable & {
|
|
13
|
+
/** Position identifier for the modifier (e.g., 'first', 'last', 'next') */
|
|
3
14
|
position: string;
|
|
15
|
+
/** Type of vehicle component being modified */
|
|
4
16
|
type?: string;
|
|
17
|
+
/** Category of vehicle component being modified */
|
|
5
18
|
category?: string;
|
|
19
|
+
/** Number of axles in the axle unit affected by this modifier */
|
|
6
20
|
axles?: number;
|
|
21
|
+
/** Minimum interaxle spacing in millimeters */
|
|
7
22
|
minInterAxleSpacing?: number;
|
|
23
|
+
/** Maximum interaxle spacing in millimeters */
|
|
8
24
|
maxInterAxleSpacing?: number;
|
|
9
25
|
};
|
|
26
|
+
/**
|
|
27
|
+
* Defines relationships between vehicle components for dimension calculations
|
|
28
|
+
*/
|
|
10
29
|
export type VehicleRelatives = {
|
|
30
|
+
/** First vehicle type in the configuration */
|
|
11
31
|
firstType: string;
|
|
32
|
+
/** Last vehicle type in the configuration */
|
|
12
33
|
lastType?: string;
|
|
34
|
+
/** Next vehicle type in sequence */
|
|
13
35
|
nextType?: string | null;
|
|
36
|
+
/** Previous vehicle type in sequence */
|
|
14
37
|
prevType?: string | null;
|
|
38
|
+
/** First vehicle category in the configuration */
|
|
15
39
|
firstCategory?: string | null;
|
|
40
|
+
/** Last vehicle category in the configuration */
|
|
16
41
|
lastCategory?: string | null;
|
|
42
|
+
/** Next vehicle category in sequence */
|
|
17
43
|
nextCategory?: string | null;
|
|
44
|
+
/** Previous vehicle category in sequence */
|
|
18
45
|
prevCategory?: string | null;
|
|
19
46
|
};
|
|
@@ -1,18 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Vehicle Display Code Defaults Type
|
|
3
|
+
*
|
|
4
|
+
* Defines default values and formatting rules for generating vehicle display codes.
|
|
5
|
+
* Used for creating standardized vehicle identification codes across the system.
|
|
6
|
+
*/
|
|
1
7
|
export type VehicleDisplayCodeDefaults = {
|
|
8
|
+
/** Standard prefix for display codes */
|
|
2
9
|
prefixStandard: string;
|
|
10
|
+
/** Universal prefix for display codes */
|
|
3
11
|
prefixUniversal: string;
|
|
12
|
+
/** Standard padding character for display codes */
|
|
4
13
|
paddingStandard: string;
|
|
14
|
+
/** Universal padding character for display codes */
|
|
5
15
|
paddingUniversal: string;
|
|
16
|
+
/** Default spacing for universal display codes */
|
|
6
17
|
spacingUniversalDefault: string;
|
|
18
|
+
/** Spacing for small universal display codes */
|
|
7
19
|
spacingUniversalSmall: string;
|
|
20
|
+
/** Spacing for large universal display codes */
|
|
8
21
|
spacingUniversalLarge: string;
|
|
22
|
+
/** Maximum threshold for small universal spacing */
|
|
9
23
|
spacingUniversalSmallMax: number;
|
|
24
|
+
/** Minimum threshold for large universal spacing */
|
|
10
25
|
spacingUniversalLargeMin: number;
|
|
26
|
+
/** Code for extra axles in universal format */
|
|
11
27
|
extraAxleUniversal: string;
|
|
28
|
+
/** Code for end axles in universal format */
|
|
12
29
|
endAxleUniversal: string;
|
|
30
|
+
/** Maximum number of axles for standard format */
|
|
13
31
|
maxAxlesStandard: number;
|
|
32
|
+
/** Threshold number of axles for universal format */
|
|
14
33
|
thresholdAxlesUniversal: number;
|
|
34
|
+
/** Code for over-threshold axles in universal format */
|
|
15
35
|
overAxlesCodeUniversal: string;
|
|
36
|
+
/** Universal axle code format */
|
|
16
37
|
universalAxleCode: string;
|
|
38
|
+
/** Prefix for multi-digit axle codes */
|
|
17
39
|
multiDigitPrefix: string;
|
|
18
40
|
};
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Vehicle Display Code Defaults Type
|
|
4
|
+
*
|
|
5
|
+
* Defines default values and formatting rules for generating vehicle display codes.
|
|
6
|
+
* Used for creating standardized vehicle identification codes across the system.
|
|
7
|
+
*/
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
package/dist/types/facts.d.ts
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Permit Facts Type
|
|
3
|
+
*
|
|
4
|
+
* Defines the structure for permit application facts used in policy validation.
|
|
5
|
+
* Contains essential information about the permit application and vehicle.
|
|
6
|
+
*/
|
|
1
7
|
export type PermitFacts = {
|
|
8
|
+
/** Company name applying for the permit */
|
|
2
9
|
companyName?: string;
|
|
10
|
+
/** Duration of the permit in days */
|
|
3
11
|
duration?: number;
|
|
12
|
+
/** Type of permit being applied for */
|
|
4
13
|
permitType?: string;
|
|
14
|
+
/** Start date of the permit (YYYY-MM-DD format) */
|
|
5
15
|
startDate?: string;
|
|
16
|
+
/** Vehicle Identification Number */
|
|
6
17
|
vehicleIdentificationNumber?: string;
|
|
18
|
+
/** Vehicle license plate number */
|
|
7
19
|
vehiclePlate?: string;
|
|
20
|
+
/** Type of vehicle permitted (primary vehicle) (e.g., 'TRKTRAC') */
|
|
8
21
|
vehicleType?: string;
|
|
22
|
+
/** Additional application data as a generic object */
|
|
9
23
|
app?: object;
|
|
10
24
|
};
|
package/dist/types/facts.js
CHANGED
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Permit Facts Type
|
|
4
|
+
*
|
|
5
|
+
* Defines the structure for permit application facts used in policy validation.
|
|
6
|
+
* Contains essential information about the permit application and vehicle.
|
|
7
|
+
*/
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|