onroute-policy-engine 1.8.1 → 1.8.3

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,5 @@
1
1
  export declare enum VehicleCategory {
2
2
  PowerUnit = "powerUnit",
3
- Trailer = "trailer"
3
+ Trailer = "trailer",
4
+ Pseudo = "pseudo"
4
5
  }
@@ -5,4 +5,5 @@ var VehicleCategory;
5
5
  (function (VehicleCategory) {
6
6
  VehicleCategory["PowerUnit"] = "powerUnit";
7
7
  VehicleCategory["Trailer"] = "trailer";
8
+ VehicleCategory["Pseudo"] = "pseudo";
8
9
  })(VehicleCategory || (exports.VehicleCategory = VehicleCategory = {}));
@@ -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
@@ -135,7 +135,7 @@ export declare class Policy {
135
135
  * Gets a list of all configured trailer types in the policy definition.
136
136
  * @returns Map of trailer type IDs to trailer type names.
137
137
  */
138
- getTrailerTypes(): Map<string, string>;
138
+ getTrailerTypes(includePseudo?: boolean): Map<string, string>;
139
139
  /**
140
140
  * Gets a full PermitType definition by ID.
141
141
  * @param type Type ID of the permit definition to return.
@@ -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);
@@ -512,9 +522,12 @@ class Policy {
512
522
  * Gets a list of all configured trailer types in the policy definition.
513
523
  * @returns Map of trailer type IDs to trailer type names.
514
524
  */
515
- getTrailerTypes() {
516
- const trailerTypes = (0, lists_helper_1.extractIdentifiedObjects)(this.policyDefinition.vehicleTypes.trailerTypes);
517
- return trailerTypes;
525
+ getTrailerTypes(includePseudo) {
526
+ let allTypes = this.policyDefinition.vehicleTypes.trailerTypes;
527
+ if (!includePseudo) {
528
+ allTypes = allTypes.filter((t) => t.category !== enum_1.VehicleCategory.Pseudo.toString());
529
+ }
530
+ return (0, lists_helper_1.extractIdentifiedObjects)(allTypes);
518
531
  }
519
532
  /**
520
533
  * Gets a full PermitType definition by ID.
@@ -1,4 +1,4 @@
1
- import { IdentifiedObject, VehicleSizeConfiguration, PowerUnitWeight, TrailerWeight } from 'onroute-policy-engine/types';
1
+ import { IdentifiedObject, VehicleSizeConfiguration, VehicleWeightConfiguration } from 'onroute-policy-engine/types';
2
2
  export type Commodity = IdentifiedObject & {
3
3
  size?: CommoditySize;
4
4
  weight?: CommodityWeight;
@@ -7,6 +7,5 @@ export type CommoditySize = {
7
7
  powerUnits?: Array<VehicleSizeConfiguration>;
8
8
  };
9
9
  export type CommodityWeight = {
10
- powerUnits?: Array<PowerUnitWeight>;
11
- trailers?: Array<TrailerWeight>;
10
+ powerUnits?: Array<VehicleWeightConfiguration>;
12
11
  };
@@ -19,5 +19,5 @@ export { SpecialAuthorizations } from './special-authorizations';
19
19
  export { StandardTireSize } from './standard-tire-size';
20
20
  export { VehicleCategory, PowerUnitCategory, TrailerCategory, VehicleCategories, } from './vehicle-category';
21
21
  export { VehicleType, PowerUnitType, TrailerType, VehicleTypes, } from './vehicle-type';
22
- export { Vehicle, VehicleSizeConfiguration, TrailerSize, PowerUnitWeight, TrailerWeight, } from './vehicle';
22
+ export { Vehicle, VehicleSizeConfiguration, VehicleWeightConfiguration, TrailerSize, TrailerWeight, } from './vehicle';
23
23
  export { WeightDimension, PowerUnitWeightDimension, TrailerWeightDimension, DefaultWeightDimensions, SingleAxleDimension, } from './weight-dimension';
@@ -5,14 +5,19 @@ export type Vehicle = SelfIssuable & {
5
5
  export type VehicleSizeConfiguration = Vehicle & {
6
6
  trailers: Array<TrailerSize>;
7
7
  };
8
+ export type VehicleWeightConfiguration = Vehicle & {
9
+ weightDimensions?: Array<PowerUnitWeightDimension>;
10
+ additionalAxleSubType?: string;
11
+ trailers: Array<TrailerWeight>;
12
+ };
8
13
  export type TrailerSize = Vehicle & {
9
14
  sizeDimensions?: Array<SizeDimension>;
10
15
  jeep: boolean;
11
16
  booster: boolean;
12
17
  };
13
- export type PowerUnitWeight = Vehicle & {
14
- weightDimensions?: Array<PowerUnitWeightDimension>;
15
- };
16
18
  export type TrailerWeight = Vehicle & {
17
19
  weightDimensions?: Array<TrailerWeightDimension>;
20
+ additionalAxleSubType?: string;
21
+ jeep: boolean;
22
+ booster: boolean;
18
23
  };
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "v1.8.1";
1
+ export declare const version = "v1.8.3";
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.1';
5
+ exports.version = 'v1.8.3';
package/package.json CHANGED
@@ -89,5 +89,5 @@
89
89
  ],
90
90
  "testEnvironment": "node"
91
91
  },
92
- "version": "v1.8.1"
92
+ "version": "v1.8.3"
93
93
  }