src/notification/dto/create-notification.dto.ts
Properties |
| body |
Type : string
|
Decorators :
@ApiProperty({example: 'ABC has requested a project review for DEF', description: 'Body of the notification'})
|
| channel |
Type : NotificationChannel
|
Decorators :
@ApiProperty({example: 'EMAIL', enum: NotificationChannel, description: 'Channel of the notification'})
|
| entityId |
Type : number
|
Decorators :
@ApiProperty({example: 1, description: 'Entity ID associated with the notification'})
|
| entityType |
Type : NotificationEntityType
|
Decorators :
@ApiProperty({example: 'PROJECT', enum: NotificationEntityType, description: 'Type of the entity associated with the notification'})
|
| eventIdentifier |
Type : EventIdentifiers
|
Decorators :
@ApiProperty({example: 'METRIC_BREACH_MAX', enum: EventIdentifiers, description: 'Identifier of the event'})
|
| eventType |
Type : EventType
|
Decorators :
@ApiProperty({example: undefined, enum: EventType, description: 'Type of the event'})
|
| Optional notifier |
Type : string
|
Decorators :
@ApiProperty({example: 'test@email.com', description: 'User ID associated with the notifier'})
|
| projectId |
Type : number
|
Decorators :
@IsNotEmpty()
|
| severity |
Type : NotificationSeverity
|
Decorators :
@ApiProperty({example: 'INFO', enum: NotificationSeverity, description: 'Severity of the notification'})
|
| subject |
Type : string
|
Decorators :
@ApiProperty({example: 'Project review required', description: 'Subject of the notification'})
|
| userId |
Type : string
|
Decorators :
@ApiProperty({example: 'test@email.com', description: 'User ID associated with the notification'})
|
import { ApiProperty } from "@nestjs/swagger";
import {
IsEnum,
IsInt,
IsNotEmpty,
IsNumber,
IsOptional,
IsString,
} from "class-validator";
import {
NotificationSeverity,
NotificationChannel,
NotificationEntityType,
} from "../types/notification.enums";
import { EventIdentifiers, EventType } from "../../common/events";
export class CreateNotificationDto {
@IsNotEmpty()
@IsNumber()
@ApiProperty({ required: true })
projectId: number;
@ApiProperty({
example: "Project review required",
description: "Subject of the notification",
})
@IsString()
@IsNotEmpty()
subject: string;
@ApiProperty({
example: "ABC has requested a project review for DEF",
description: "Body of the notification",
})
@IsString()
@IsNotEmpty()
body: string;
@ApiProperty({
example: "INFO",
enum: NotificationSeverity,
description: "Severity of the notification",
})
@IsEnum(NotificationSeverity)
@IsNotEmpty()
severity: NotificationSeverity;
@ApiProperty({
example: "EMAIL",
enum: NotificationChannel,
description: "Channel of the notification",
})
@IsEnum(NotificationChannel)
@IsNotEmpty()
channel: NotificationChannel;
@ApiProperty({
example: "test@email.com",
description: "User ID associated with the notifier",
})
@IsString()
@IsOptional()
notifier?: string;
@ApiProperty({
example: "test@email.com",
description: "User ID associated with the notification",
})
@IsString()
@IsNotEmpty()
userId: string;
@ApiProperty({
example: 1,
description: "Entity ID associated with the notification",
})
@IsInt()
@IsNotEmpty()
entityId: number;
@ApiProperty({
example: "PROJECT",
enum: NotificationEntityType,
description: "Type of the entity associated with the notification",
})
@IsEnum(NotificationEntityType)
@IsNotEmpty()
entityType: NotificationEntityType;
@ApiProperty({
example: EventType.ALERT,
enum: EventType,
description: "Type of the event",
})
@IsEnum(EventType)
@IsNotEmpty()
eventType: EventType;
@ApiProperty({
example: "METRIC_BREACH_MAX",
enum: EventIdentifiers,
description: "Identifier of the event",
})
@IsEnum(EventIdentifiers)
@IsNotEmpty()
eventIdentifier: EventIdentifiers;
}