grm-shared-library 1.0.121 → 1.0.122
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/dist/modules/response-unit/dtos/vehicle-unit/crew/vehicle-unit-crew.dto.d.ts +2 -0
- package/dist/modules/response-unit/dtos/vehicle-unit/crew/vehicle-unit-crew.dto.js +8 -0
- package/dist/modules/response-unit/interfaces/vehicle-unit/vehicle-unit-crew.d.ts +4 -2
- package/dist/modules/response-unit/validators/valid-vehicle-role.decorator.d.ts +2 -0
- package/dist/modules/response-unit/validators/valid-vehicle-role.decorator.js +43 -0
- package/package.json +1 -1
|
@@ -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
|
-
|
|
11
|
-
|
|
11
|
+
vehicleType?: VehicleUnitType;
|
|
12
|
+
createdAt: Date;
|
|
13
|
+
updatedAt: Date;
|
|
12
14
|
vehicleUnit?: VehicleUnit;
|
|
13
15
|
}
|
|
@@ -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
|
+
}
|