File

src/metrics/dto/metrics.dto.ts

Index

Properties

Constructor

constructor(partial: Partial<MetricDataObject>)
Parameters :
Name Type Optional
partial Partial<MetricDataObject> No

Properties

metricId
Type : number
Decorators :
@IsNotEmpty()
@IsNumber()
@ApiProperty({required: true})
timestamp
Type : Date
Decorators :
@IsNotEmpty()
@IsDate()
@ApiProperty({required: true})
value
Type : number
Decorators :
@IsNotEmpty()
@IsNumber()
@ApiProperty({required: true})
import { ApiProperty } from "@nestjs/swagger";
import {
  IsDate,
  IsEnum,
  IsNotEmpty,
  IsNumber,
  IsString,
  IsOptional,
} from "class-validator";
import { MetricSources, MetricStatus, MetricTrend } from "../entities/metrics.entity";

export class MetricsDto {
  @IsNotEmpty()
  @IsNumber()
  @ApiProperty({ required: true })
  projectId: number;

  @IsNotEmpty()
  @IsString()
  @ApiProperty({ required: true })
  name: string;

  @IsNotEmpty()
  @IsString()
  @ApiProperty({ required: true })
  type: string;

  @IsNotEmpty()
  @IsNumber()
  @ApiProperty({ required: true })
  sourceId: number;

  @IsNotEmpty()
  @IsEnum(MetricSources, { each: true })
  @ApiProperty({ required: true })
  sourceType: string;

  constructor(partial: Partial<MetricsDto>) {
    Object.assign(this, partial);
  }
}

export class MetricDataObject {
  @IsNotEmpty()
  @IsNumber()
  @ApiProperty({ required: true })
  metricId: number;

  @IsNotEmpty()
  @IsNumber()
  @ApiProperty({ required: true })
  value: number;

  @IsNotEmpty()
  @IsDate()
  @ApiProperty({ required: true })
  timestamp: Date;

  constructor(partial: Partial<MetricDataObject>) {
    Object.assign(this, partial);
  }
}

export class MetricMetadataDto {
  @IsOptional()
  @IsEnum(MetricTrend, { message: "Invalid metrics trend" })
  trend?: MetricTrend | null;

  @IsOptional()
  @IsString({ message: "Description must be a string" })
  description?: string;

  @IsOptional()
  @IsEnum(MetricStatus, { message: "Invalid metrics source", each: true })
  status?: MetricStatus;
}

results matching ""

    No results matching ""