grm-shared-library 1.0.121 → 1.0.123

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,5 +1,8 @@
1
1
  import { CreateVehicleUnitCrewDto } from './create-vehicle-unit-crew.dto';
2
+ import { VehicleUnitType } from '../../../enums/vehicle-unit/vehicle-unit-type.enum';
2
3
  declare const UpdateVehicleUnitCrewDto_base: import("@nestjs/mapped-types").MappedType<Partial<CreateVehicleUnitCrewDto>>;
3
4
  export declare class UpdateVehicleUnitCrewDto extends UpdateVehicleUnitCrewDto_base {
5
+ role?: string;
6
+ vehicleType?: VehicleUnitType;
4
7
  }
5
8
  export {};
@@ -1,8 +1,31 @@
1
1
  "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
2
11
  Object.defineProperty(exports, "__esModule", { value: true });
3
12
  exports.UpdateVehicleUnitCrewDto = void 0;
4
13
  const mapped_types_1 = require("@nestjs/mapped-types");
5
14
  const create_vehicle_unit_crew_dto_1 = require("./create-vehicle-unit-crew.dto");
15
+ const class_validator_1 = require("class-validator");
16
+ const valid_vehicle_role_decorator_1 = require("../../../validators/valid-vehicle-role.decorator");
17
+ const vehicle_unit_type_enum_1 = require("../../../enums/vehicle-unit/vehicle-unit-type.enum");
6
18
  class UpdateVehicleUnitCrewDto extends (0, mapped_types_1.PartialType)(create_vehicle_unit_crew_dto_1.CreateVehicleUnitCrewDto) {
7
19
  }
8
20
  exports.UpdateVehicleUnitCrewDto = UpdateVehicleUnitCrewDto;
21
+ __decorate([
22
+ (0, class_validator_1.IsString)(),
23
+ (0, class_validator_1.IsOptional)(),
24
+ (0, valid_vehicle_role_decorator_1.IsValidVehicleRole)({ message: 'Invalid role for the specified vehicle type' }),
25
+ __metadata("design:type", String)
26
+ ], UpdateVehicleUnitCrewDto.prototype, "role", void 0);
27
+ __decorate([
28
+ (0, class_validator_1.IsEnum)(vehicle_unit_type_enum_1.VehicleUnitType),
29
+ (0, class_validator_1.IsOptional)(),
30
+ __metadata("design:type", String)
31
+ ], UpdateVehicleUnitCrewDto.prototype, "vehicleType", void 0);
@@ -1,4 +1,5 @@
1
1
  import { PersonUnitStatus } from "../../../enums/person-unit/person-unit-status.enum";
2
+ import { VehicleUnitType } from "../../../enums/vehicle-unit/vehicle-unit-type.enum";
2
3
  export declare class VehicleUnitCrewDto {
3
4
  id: number;
4
5
  name: string;
@@ -6,6 +7,7 @@ export declare class VehicleUnitCrewDto {
6
7
  role: string;
7
8
  status: PersonUnitStatus;
8
9
  vehicleUnitId: number;
10
+ vehicleType?: VehicleUnitType;
9
11
  createdAt?: Date;
10
12
  updatedAt?: Date;
11
13
  }
@@ -12,6 +12,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
12
12
  exports.VehicleUnitCrewDto = void 0;
13
13
  const class_validator_1 = require("class-validator");
14
14
  const person_unit_status_enum_1 = require("../../../enums/person-unit/person-unit-status.enum");
15
+ const vehicle_unit_type_enum_1 = require("../../../enums/vehicle-unit/vehicle-unit-type.enum");
16
+ const valid_vehicle_role_decorator_1 = require("../../../validators/valid-vehicle-role.decorator");
15
17
  class VehicleUnitCrewDto {
16
18
  }
17
19
  exports.VehicleUnitCrewDto = VehicleUnitCrewDto;
@@ -29,6 +31,7 @@ __decorate([
29
31
  ], VehicleUnitCrewDto.prototype, "phoneNumber", void 0);
30
32
  __decorate([
31
33
  (0, class_validator_1.IsString)(),
34
+ (0, valid_vehicle_role_decorator_1.IsValidVehicleRole)({ message: 'Invalid role for the specified vehicle type' }),
32
35
  __metadata("design:type", String)
33
36
  ], VehicleUnitCrewDto.prototype, "role", void 0);
34
37
  __decorate([
@@ -39,6 +42,11 @@ __decorate([
39
42
  (0, class_validator_1.IsNumber)(),
40
43
  __metadata("design:type", Number)
41
44
  ], VehicleUnitCrewDto.prototype, "vehicleUnitId", void 0);
45
+ __decorate([
46
+ (0, class_validator_1.IsEnum)(vehicle_unit_type_enum_1.VehicleUnitType),
47
+ (0, class_validator_1.IsOptional)(),
48
+ __metadata("design:type", String)
49
+ ], VehicleUnitCrewDto.prototype, "vehicleType", void 0);
42
50
  __decorate([
43
51
  (0, class_validator_1.IsDate)(),
44
52
  (0, class_validator_1.IsOptional)(),
@@ -1,4 +1,5 @@
1
1
  import { PersonUnitStatus } from "../../enums/person-unit/person-unit-status.enum";
2
+ import { VehicleUnitType } from "../../enums/vehicle-unit/vehicle-unit-type.enum";
2
3
  import { VehicleUnit } from "./vehicle-unit";
3
4
  export interface VehicleUnitCrew {
4
5
  id: number;
@@ -7,7 +8,8 @@ export interface VehicleUnitCrew {
7
8
  role: string;
8
9
  status: PersonUnitStatus;
9
10
  vehicleUnitId: number;
10
- createdAt: string;
11
- updatedAt: string;
11
+ vehicleType?: VehicleUnitType;
12
+ createdAt: Date;
13
+ updatedAt: Date;
12
14
  vehicleUnit?: VehicleUnit;
13
15
  }
@@ -0,0 +1,2 @@
1
+ import { ValidationOptions } from "class-validator";
2
+ export declare function IsValidVehicleRole(validationOptions?: ValidationOptions): (object: Object, propertyName: string) => void;
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.IsValidVehicleRole = IsValidVehicleRole;
4
+ const class_validator_1 = require("class-validator");
5
+ const vehicle_unit_type_enum_1 = require("../enums/vehicle-unit/vehicle-unit-type.enum");
6
+ const ambulance_vehicle_role_enum_1 = require("../enums/vehicle-unit/vehicle-crew/ambulance-vehicle-role.enum");
7
+ const security_vehicle_role_enum_1 = require("../enums/vehicle-unit/vehicle-crew/security-vehicle-role.enum");
8
+ const fire_vehicle_role_enum_1 = require("../enums/vehicle-unit/vehicle-crew/fire-vehicle-role.enum");
9
+ const road_rescue_vehicle_role_enum_1 = require("../enums/vehicle-unit/vehicle-crew/road-rescue-vehicle-role.enum");
10
+ function IsValidVehicleRole(validationOptions) {
11
+ return function (object, propertyName) {
12
+ (0, class_validator_1.registerDecorator)({
13
+ name: 'isValidVehicleRole',
14
+ target: object.constructor,
15
+ propertyName: propertyName,
16
+ options: validationOptions,
17
+ validator: {
18
+ validate(value, args) {
19
+ const vehicleType = args.object.vehicleType;
20
+ if (!vehicleType) {
21
+ return true;
22
+ }
23
+ switch (vehicleType) {
24
+ case vehicle_unit_type_enum_1.VehicleUnitType.AMBULANCE:
25
+ return Object.values(ambulance_vehicle_role_enum_1.AmbulanceVehicleRole).includes(value);
26
+ case vehicle_unit_type_enum_1.VehicleUnitType.SECURITY:
27
+ return Object.values(security_vehicle_role_enum_1.SecurityVehicleRole).includes(value);
28
+ case vehicle_unit_type_enum_1.VehicleUnitType.FIRE:
29
+ return Object.values(fire_vehicle_role_enum_1.FireVehicleRole).includes(value);
30
+ case vehicle_unit_type_enum_1.VehicleUnitType.ROAD_RESCUE:
31
+ return Object.values(road_rescue_vehicle_role_enum_1.RoadRescueVehicleRole).includes(value);
32
+ default:
33
+ return true;
34
+ }
35
+ },
36
+ defaultMessage(args) {
37
+ const vehicleType = args.object.vehicleType;
38
+ return `Role must be a valid role for vehicle type: ${vehicleType}`;
39
+ }
40
+ }
41
+ });
42
+ };
43
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "grm-shared-library",
3
- "version": "1.0.121",
3
+ "version": "1.0.123",
4
4
  "main": "dist/index.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "files": [