All files / libs/reporting/dashboards-v2/api/src/lib/dtos get-chart-data.dto.ts

100% Statements 66/66
100% Branches 0/0
100% Functions 0/0
100% Lines 66/66

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 671x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
import { Type } from 'class-transformer';
import { IsArray, IsIn, IsOptional, IsString, IsUUID, ValidateNested } from 'class-validator';
 
import { Period } from '@amalia/payout-definition/periods/types';
import { Plan } from '@amalia/payout-definition/plans/types';
import {
  DashboardChartFilters,
  DashboardChartFiltersOverride,
  DashboardChartSort,
} from '@amalia/reporting/dashboards-v2/types';
import { TeamContract } from '@amalia/tenants/teams/types';
import { UserContract } from '@amalia/tenants/users/types';
 
export class DashboardChartFiltersDto implements DashboardChartFilters {
  @IsString({ each: true })
  public readonly periods!: Period['id'][];
 
  @IsUUID('4', { each: true })
  public readonly plans!: Plan['id'][];
 
  @IsUUID('4', { each: true })
  public readonly teams!: TeamContract['id'][];
 
  @IsUUID('4', { each: true })
  public readonly users!: UserContract['id'][];
}
 
export class DashboardChartFiltersOverrideDto implements DashboardChartFiltersOverride {
  @ValidateNested()
  @Type(() => DashboardChartFiltersDto)
  public readonly chartFilters!: DashboardChartFiltersDto;
 
  @ValidateNested()
  @Type(() => DashboardChartFiltersDto)
  public readonly dashboardFilters!: DashboardChartFiltersDto;
}
 
class DashboardChartSortFieldDto {
  @IsString()
  public identifier!: string;
 
  @IsOptional()
  @IsArray()
  @IsString({ each: true })
  public joins?: string[];
}
 
export class DashboardChartSortDto implements DashboardChartSort {
  @ValidateNested()
  @Type(() => DashboardChartSortFieldDto)
  public field!: DashboardChartSortFieldDto;
 
  @IsIn(['ASC', 'DESC'])
  public direction!: 'ASC' | 'DESC';
}
 
export class GetChartDataDto {
  @ValidateNested()
  @Type(() => DashboardChartFiltersOverrideDto)
  public filters!: DashboardChartFiltersOverrideDto;
 
  @IsOptional()
  @ValidateNested()
  @Type(() => DashboardChartSortDto)
  public sort!: DashboardChartSortDto | null;
}