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.
Files changed (80) hide show
  1. package/.github/workflows/pipeline.yml +25 -6
  2. package/dist/enum/custom-operator.d.ts +6 -0
  3. package/dist/enum/custom-operator.js +10 -0
  4. package/dist/enum/facts.d.ts +8 -4
  5. package/dist/enum/facts.js +8 -4
  6. package/dist/enum/index.d.ts +2 -0
  7. package/dist/enum/index.js +6 -1
  8. package/dist/enum/permit-app-info.d.ts +8 -5
  9. package/dist/enum/permit-app-info.js +8 -5
  10. package/dist/enum/policy-check.d.ts +11 -0
  11. package/dist/enum/policy-check.js +16 -0
  12. package/dist/enum/validation-result-code.d.ts +1 -0
  13. package/dist/enum/validation-result-code.js +1 -0
  14. package/dist/helper/dimensions.helper.js +7 -3
  15. package/dist/helper/display-code-helper.d.ts +42 -0
  16. package/dist/helper/display-code-helper.js +73 -1
  17. package/dist/helper/facts.helper.js +64 -0
  18. package/dist/helper/policy-check.helper.d.ts +183 -0
  19. package/dist/helper/policy-check.helper.js +337 -0
  20. package/dist/helper/vehicles.helper.d.ts +45 -1
  21. package/dist/helper/vehicles.helper.js +61 -0
  22. package/dist/policy-engine.d.ts +95 -1
  23. package/dist/policy-engine.js +103 -0
  24. package/dist/rule-operator/custom-operators.d.ts +7 -0
  25. package/dist/rule-operator/custom-operators.js +57 -3
  26. package/dist/types/axle-calculation-results.d.ts +49 -0
  27. package/dist/types/axle-calculation-results.js +8 -0
  28. package/dist/types/axle-configuration.d.ts +12 -0
  29. package/dist/types/axle-configuration.js +6 -0
  30. package/dist/types/bridge-calculation-constants.d.ts +8 -0
  31. package/dist/types/bridge-calculation-result.d.ts +11 -0
  32. package/dist/types/commodity.d.ts +10 -0
  33. package/dist/types/commodity.js +6 -0
  34. package/dist/types/cost-rule.d.ts +8 -0
  35. package/dist/types/cost-rule.js +6 -0
  36. package/dist/types/dimension-modifier.d.ts +27 -0
  37. package/dist/types/dimension-modifier.js +6 -0
  38. package/dist/types/display-code-defaults.d.ts +22 -0
  39. package/dist/types/display-code-defaults.js +6 -0
  40. package/dist/types/facts.d.ts +14 -0
  41. package/dist/types/facts.js +6 -0
  42. package/dist/types/geographic-region.d.ts +10 -0
  43. package/dist/types/geographic-region.js +6 -0
  44. package/dist/types/identified-object.d.ts +8 -0
  45. package/dist/types/identified-object.js +6 -0
  46. package/dist/types/index.d.ts +1 -0
  47. package/dist/types/permit-application.d.ts +109 -0
  48. package/dist/types/permit-application.js +6 -0
  49. package/dist/types/permit-condition.d.ts +18 -0
  50. package/dist/types/permit-condition.js +6 -0
  51. package/dist/types/permit-type.d.ts +18 -0
  52. package/dist/types/permit-type.js +6 -0
  53. package/dist/types/policy-definition.d.ts +24 -0
  54. package/dist/types/policy-definition.js +7 -0
  55. package/dist/types/range-matrix.d.ts +17 -0
  56. package/dist/types/range-matrix.js +6 -0
  57. package/dist/types/region-size-override.d.ts +10 -0
  58. package/dist/types/region-size-override.js +6 -0
  59. package/dist/types/self-issuable.d.ts +7 -0
  60. package/dist/types/self-issuable.js +6 -0
  61. package/dist/types/size-dimension.d.ts +17 -0
  62. package/dist/types/size-dimension.js +6 -0
  63. package/dist/types/special-authorizations.d.ts +9 -0
  64. package/dist/types/special-authorizations.js +6 -0
  65. package/dist/types/standard-tire-size.d.ts +8 -0
  66. package/dist/types/standard-tire-size.js +6 -0
  67. package/dist/types/vehicle-category.d.ts +27 -0
  68. package/dist/types/vehicle-category.js +6 -0
  69. package/dist/types/vehicle-type.d.ts +36 -0
  70. package/dist/types/vehicle-type.js +6 -0
  71. package/dist/types/vehicle.d.ts +27 -0
  72. package/dist/types/vehicle.js +6 -0
  73. package/dist/types/weight-dimension.d.ts +34 -0
  74. package/dist/types/weight-dimension.js +6 -0
  75. package/dist/validation-result.d.ts +1 -0
  76. package/dist/validation-results.js +2 -1
  77. package/dist/version.d.ts +1 -1
  78. package/dist/version.js +1 -1
  79. package/eslint.config.mjs +1 -1
  80. package/package.json +2 -1
@@ -1,24 +1,60 @@
1
+ /**
2
+ * Vehicle Type Types
3
+ *
4
+ * Defines the structure for vehicle types including power units and trailers.
5
+ * Extends IdentifiedObject with category, dimensions, and special configurations.
6
+ */
1
7
  import { ConditionRequirement, IdentifiedObject, SizeDimension, PowerUnitWeightDimension, TrailerWeightDimension } from 'onroute-policy-engine/types';
8
+ /**
9
+ * Base vehicle type with identification and configuration options
10
+ * Extends IdentifiedObject with vehicle-specific properties
11
+ */
2
12
  export type VehicleType = IdentifiedObject & {
13
+ /** Category identifier for this vehicle type */
3
14
  category: string;
15
+ /** Default size dimensions for this vehicle type (optional) */
4
16
  defaultSizeDimensions?: SizeDimension;
17
+ /** Whether to ignore this vehicle type for size dimension calculations (optional) */
5
18
  ignoreForSizeDimensions?: boolean;
19
+ /** Whether to ignore this vehicle type for axle calculations (optional) */
6
20
  ignoreForAxleCalculation?: boolean;
21
+ /** Whether this vehicle type is an LCV (Long Combination Vehicle) (optional) */
7
22
  isLcv?: boolean;
23
+ /** Array of conditions required for this vehicle type (optional) */
8
24
  conditions?: Array<ConditionRequirement>;
25
+ /** Additional axle subtype identifier (optional) */
9
26
  additionalAxleSubType?: string;
10
27
  };
28
+ /**
29
+ * Power unit type with power unit specific configurations
30
+ * Extends VehicleType with power unit specific properties
31
+ */
11
32
  export type PowerUnitType = VehicleType & {
33
+ /** Default weight dimensions specific to power units (optional) */
12
34
  defaultWeightDimensions?: Array<PowerUnitWeightDimension>;
35
+ /** Display code prefix for this power unit type (optional) */
13
36
  displayCodePrefix?: string;
37
+ /** Display code for steer axle (optional) */
14
38
  displayCodeSteerAxle?: string;
39
+ /** Display code for drive axle (optional) */
15
40
  displayCodeDriveAxle?: string;
16
41
  };
42
+ /**
43
+ * Trailer type with trailer specific configurations
44
+ * Extends VehicleType with trailer specific properties
45
+ */
17
46
  export type TrailerType = VehicleType & {
47
+ /** Default weight dimensions specific to trailers (optional) */
18
48
  defaultWeightDimensions?: Array<TrailerWeightDimension>;
49
+ /** Display code for this trailer type (optional) */
19
50
  displayCode?: string;
20
51
  };
52
+ /**
53
+ * Complete vehicle types configuration
54
+ */
21
55
  export type VehicleTypes = {
56
+ /** Array of power unit types */
22
57
  powerUnitTypes: Array<PowerUnitType>;
58
+ /** Array of trailer types */
23
59
  trailerTypes: Array<TrailerType>;
24
60
  };
@@ -1,2 +1,8 @@
1
1
  "use strict";
2
+ /**
3
+ * Vehicle Type Types
4
+ *
5
+ * Defines the structure for vehicle types including power units and trailers.
6
+ * Extends IdentifiedObject with category, dimensions, and special configurations.
7
+ */
2
8
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,16 +1,43 @@
1
+ /**
2
+ * Vehicle Types
3
+ *
4
+ * Defines the structure for vehicles including power units and trailers.
5
+ * Extends SelfIssuable for self-issuance capability and includes dimension configurations.
6
+ */
1
7
  import { SelfIssuable, SizeDimension, PowerUnitWeightDimension, TrailerWeightDimension } from 'onroute-policy-engine/types';
8
+ /**
9
+ * Base vehicle with type identification and self-issuance capability
10
+ * Extends SelfIssuable to include self-issuance capability
11
+ */
2
12
  export type Vehicle = SelfIssuable & {
13
+ /** Type identifier for this vehicle */
3
14
  type: string;
4
15
  };
16
+ /**
17
+ * Power unit with trailer configuration and weight dimensions
18
+ * Extends Vehicle with trailer and weight dimension arrays
19
+ */
5
20
  export type VehicleDimensions = Vehicle & {
21
+ /** Array of trailers attached to this power unit */
6
22
  trailers: Array<TrailerDimensions>;
23
+ /** Array of weight dimensions for this power unit (optional) */
7
24
  weightDimensions?: Array<PowerUnitWeightDimension>;
8
25
  };
26
+ /**
27
+ * Trailer with booster/jeep configuration and dimension capabilities
28
+ * Extends Vehicle with trailer-specific properties
29
+ */
9
30
  export type TrailerDimensions = Vehicle & {
31
+ /** Whether this trailer is allowed a booster */
10
32
  booster: boolean;
33
+ /** Whether this trailer is allowed a jeep */
11
34
  jeep: boolean;
35
+ /** Array of size dimensions for this trailer (optional) */
12
36
  sizeDimensions?: Array<SizeDimension>;
37
+ /** Whether size is permittable for this trailer (optional) */
13
38
  sizePermittable?: boolean;
39
+ /** Array of weight dimensions for this trailer (optional) */
14
40
  weightDimensions?: Array<TrailerWeightDimension>;
41
+ /** Whether weight is permittable for this trailer (optional) */
15
42
  weightPermittable?: boolean;
16
43
  };
@@ -1,2 +1,8 @@
1
1
  "use strict";
2
+ /**
3
+ * Vehicle Types
4
+ *
5
+ * Defines the structure for vehicles including power units and trailers.
6
+ * Extends SelfIssuable for self-issuance capability and includes dimension configurations.
7
+ */
2
8
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -1,20 +1,54 @@
1
+ /**
2
+ * Weight Dimension Types
3
+ *
4
+ * Defines the structure for weight dimensions including single axles, power units,
5
+ * and trailers. Extends SelfIssuable for self-issuance capability.
6
+ */
1
7
  import { DimensionModifier, SelfIssuable } from 'onroute-policy-engine/types';
8
+ /**
9
+ * Weight limits for a single axle unit
10
+ */
2
11
  export type SingleAxleDimension = {
12
+ /** Legal weight limit in kilograms (optional) */
3
13
  legal?: number;
14
+ /** Permittable weight limit in kilograms (optional) */
4
15
  permittable?: number;
5
16
  };
17
+ /**
18
+ * Base weight dimension with axle count and modifier
19
+ * Extends SelfIssuable to include self-issuance capability
20
+ */
6
21
  export type WeightDimension = SelfIssuable & {
22
+ /** Number of axles applicable to this weight dimension */
7
23
  axles: number;
24
+ /** Dimension modifier for special configurations (optional) */
8
25
  modifier?: DimensionModifier;
9
26
  };
27
+ /**
28
+ * Weight dimension specific to power units with steer and drive axle limits
29
+ * Extends WeightDimension with power unit specific weight limits
30
+ */
10
31
  export type PowerUnitWeightDimension = WeightDimension & {
32
+ /** Single axle legal weight limit in kilograms (optional) */
11
33
  saLegal?: number;
34
+ /** Single axle permittable weight limit in kilograms (optional) */
12
35
  saPermittable?: number;
36
+ /** Drive axle legal weight limit in kilograms (optional) */
13
37
  daLegal?: number;
38
+ /** Drive axle permittable weight limit in kilograms (optional) */
14
39
  daPermittable?: number;
15
40
  };
41
+ /**
42
+ * Weight dimension specific to trailers
43
+ * Extends WeightDimension with single axle dimension limits
44
+ */
16
45
  export type TrailerWeightDimension = WeightDimension & SingleAxleDimension;
46
+ /**
47
+ * Default weight dimensions for all vehicle types
48
+ */
17
49
  export type DefaultWeightDimensions = {
50
+ /** Array of power unit weight dimensions */
18
51
  powerUnits: Array<PowerUnitWeightDimension>;
52
+ /** Array of trailer weight dimensions */
19
53
  trailers: Array<TrailerWeightDimension>;
20
54
  };
@@ -1,2 +1,8 @@
1
1
  "use strict";
2
+ /**
3
+ * Weight Dimension Types
4
+ *
5
+ * Defines the structure for weight dimensions including single axles, power units,
6
+ * and trailers. Extends SelfIssuable for self-issuance capability.
7
+ */
2
8
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -17,4 +17,5 @@ export declare class ValidationResult {
17
17
  message: string;
18
18
  fieldReference?: string;
19
19
  cost?: number;
20
+ details?: Array<string>;
20
21
  }
@@ -36,13 +36,14 @@ class ValidationResults {
36
36
  this.cost = [];
37
37
  if (engineResult) {
38
38
  engineResult.events.forEach((e) => {
39
- var _a, _b, _c, _d, _e, _f, _g;
39
+ var _a, _b, _c, _d, _e, _f, _g, _h;
40
40
  const message = (_b = (_a = e.params) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : `Unknown message: params=${JSON.stringify(e.params)}`;
41
41
  const code = (_d = (_c = e.params) === null || _c === void 0 ? void 0 : _c.code) !== null && _d !== void 0 ? _d : validation_result_code_1.ValidationResultCode.GeneralResult;
42
42
  const type = (_e = e.type) !== null && _e !== void 0 ? _e : validation_result_type_1.ValidationResultType.Violation.toString();
43
43
  const result = new validation_result_1.ValidationResult(type, code, message);
44
44
  result.fieldReference = (_f = e.params) === null || _f === void 0 ? void 0 : _f.fieldReference;
45
45
  result.cost = (_g = e.params) === null || _g === void 0 ? void 0 : _g.cost;
46
+ result.details = (_h = e.params) === null || _h === void 0 ? void 0 : _h.details;
46
47
  switch (type) {
47
48
  case validation_result_type_1.ValidationResultType.Violation:
48
49
  this.violations.push(result);
package/dist/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const version = "v2.1.0";
1
+ export declare const version = "v2.2.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.1.0';
5
+ exports.version = 'v2.2.0';
package/eslint.config.mjs CHANGED
@@ -15,7 +15,7 @@ const compat = new FlatCompat({
15
15
  });
16
16
 
17
17
  export default [{
18
- ignores: ["**/.eslintrc.cjs", "**/node_modules/", "**/dist/", "**/.eslintrc.cjs"],
18
+ ignores: ["**/.eslintrc.cjs", "**/node_modules/", "**/dist/", "**/.eslintrc.cjs,", "src/_examples/usage"],
19
19
  }, ...compat.extends("eslint:recommended", "plugin:@typescript-eslint/recommended", "prettier"), {
20
20
  plugins: {
21
21
  "@typescript-eslint": typescriptEslint,
package/package.json CHANGED
@@ -84,11 +84,12 @@
84
84
  "coveragePathIgnorePatterns": [
85
85
  "/node_modules/",
86
86
  "/src/_test/",
87
+ "/src/_examples/",
87
88
  ".enum.ts",
88
89
  ".interface.ts",
89
90
  "index.ts"
90
91
  ],
91
92
  "testEnvironment": "node"
92
93
  },
93
- "version": "v2.1.0"
94
+ "version": "v2.2.0"
94
95
  }