onroute-policy-engine 1.8.0 → 1.8.2

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 { PolicyDefinition, PermitType, Commodity, VehicleType, SizeDimension, AxleConfiguration, BridgeCalculationResult, ConditionForPermit, TrailerType, PowerUnitType, TrailerWeightDimension, PowerUnitWeightDimension, WeightDimension, SingleAxleDimension } from 'onroute-policy-engine/types';
1
+ import { PolicyDefinition, PermitType, Commodity, VehicleType, SizeDimension, AxleConfiguration, BridgeCalculationResult, ConditionForPermit, TrailerType, PowerUnitType, TrailerWeightDimension, PowerUnitWeightDimension, WeightDimension, SingleAxleDimension, StandardTireSize } 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';
@@ -27,7 +27,7 @@ export declare class Policy {
27
27
  * and permittable vehicles for permit types.
28
28
  * @param authorizations Special authorizations for a client
29
29
  */
30
- setSpecialAuthorizations(authorizations: SpecialAuthorizations | null): void;
30
+ setSpecialAuthorizations(authorizations?: SpecialAuthorizations | null): void;
31
31
  /**
32
32
  * Validates a permit application against the policy definition.
33
33
  * @param permit The permit application to validate against policy
@@ -227,4 +227,11 @@ export declare class Policy {
227
227
  * weights for the axle unit at the supplied axleIndex.
228
228
  */
229
229
  selectCorrectWeightDimension(weightDimensions: Array<WeightDimension>, configuration: Array<string>, axleConfiguration: Array<AxleConfiguration>, axleIndex: number): SingleAxleDimension | null;
230
+ /**
231
+ * Get the list of known standard tire sizes, used to populate
232
+ * dropdown lists in front-end interfaces.
233
+ * @returns List of known standard tire sizes, or empty array if
234
+ * none are configured
235
+ */
236
+ getStandardTireSizes(): Array<StandardTireSize>;
230
237
  }
@@ -40,7 +40,7 @@ class Policy {
40
40
  throw new Error(`Current policy config minimum version is at least one major version behind policy engine: major(${definition.minPEVersion}) < major(${version_1.version}))`);
41
41
  }
42
42
  this.policyDefinition = definition;
43
- this.specialAuthorizations = authorizations;
43
+ this.setSpecialAuthorizations(authorizations);
44
44
  this.rulesEngines = (0, rules_engine_helper_1.getRulesEngines)(this);
45
45
  }
46
46
  /**
@@ -162,8 +162,18 @@ class Policy {
162
162
  }
163
163
  return false;
164
164
  }));
165
- // TODO when implementing overweight. Stub for now.
166
- const commoditiesForOW = new Map();
165
+ // Commodities for overweight permits are those which have at least one
166
+ // power unit defined in the weight dimension object of the commodity.
167
+ const commoditiesForOW = (0, lists_helper_1.extractIdentifiedObjects)(this.policyDefinition.commodities.filter((c) => {
168
+ if (c.weight) {
169
+ if (c.weight.powerUnits) {
170
+ if (c.weight.powerUnits.length > 0) {
171
+ return true;
172
+ }
173
+ }
174
+ }
175
+ return false;
176
+ }));
167
177
  if (permitType.sizeDimensionRequired &&
168
178
  permitType.weightDimensionRequired) {
169
179
  return (0, lists_helper_1.intersectIdMaps)(commoditiesForOS, commoditiesForOW);
@@ -682,5 +692,19 @@ class Policy {
682
692
  selectCorrectWeightDimension(weightDimensions, configuration, axleConfiguration, axleIndex) {
683
693
  return (0, dimensions_helper_1.selectCorrectWeightDimensionHelper)(this, weightDimensions, configuration, axleConfiguration, axleIndex);
684
694
  }
695
+ /**
696
+ * Get the list of known standard tire sizes, used to populate
697
+ * dropdown lists in front-end interfaces.
698
+ * @returns List of known standard tire sizes, or empty array if
699
+ * none are configured
700
+ */
701
+ getStandardTireSizes() {
702
+ if (this.policyDefinition.standardTireSizes) {
703
+ return this.policyDefinition.standardTireSizes;
704
+ }
705
+ else {
706
+ return new Array();
707
+ }
708
+ }
685
709
  }
686
710
  exports.Policy = Policy;
@@ -16,6 +16,7 @@ export { RegionSizeOverride } from './region-size-override';
16
16
  export { SelfIssuable } from './self-issuable';
17
17
  export { SizeDimension } from './size-dimension';
18
18
  export { SpecialAuthorizations } from './special-authorizations';
19
+ export { StandardTireSize } from './standard-tire-size';
19
20
  export { VehicleCategory, PowerUnitCategory, TrailerCategory, VehicleCategories, } from './vehicle-category';
20
21
  export { VehicleType, PowerUnitType, TrailerType, VehicleTypes, } from './vehicle-type';
21
22
  export { Vehicle, VehicleSizeConfiguration, TrailerSize, PowerUnitWeight, TrailerWeight, } from './vehicle';
@@ -1,4 +1,4 @@
1
- import { GeographicRegion, PermitType, DefaultWeightDimensions, VehicleTypes, Commodity, SizeDimension, VehicleCategories, RangeMatrix, BridgeCalculationConstants, PermitConditionDefinition } from 'onroute-policy-engine/types';
1
+ import { GeographicRegion, PermitType, DefaultWeightDimensions, VehicleTypes, Commodity, SizeDimension, VehicleCategories, RangeMatrix, BridgeCalculationConstants, PermitConditionDefinition, StandardTireSize } from 'onroute-policy-engine/types';
2
2
  import { RuleProperties } from 'json-rules-engine';
3
3
  export type PolicyDefinition = {
4
4
  minPEVersion: string;
@@ -13,4 +13,5 @@ export type PolicyDefinition = {
13
13
  rangeMatrices?: Array<RangeMatrix>;
14
14
  bridgeCalculationConstants: BridgeCalculationConstants;
15
15
  conditions?: Array<PermitConditionDefinition>;
16
+ standardTireSizes?: Array<StandardTireSize>;
16
17
  };
@@ -0,0 +1,4 @@
1
+ export type StandardTireSize = {
2
+ name: string;
3
+ size: number;
4
+ };
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "v1.8.0";
1
+ export declare const version = "v1.8.2";
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 = 'v1.8.0';
5
+ exports.version = 'v1.8.2';
package/package.json CHANGED
@@ -89,5 +89,5 @@
89
89
  ],
90
90
  "testEnvironment": "node"
91
91
  },
92
- "version": "v1.8.0"
92
+ "version": "v1.8.2"
93
93
  }