Files
backend/src/modules/investments/upcoming-events/upcoming-events.dto.ts
T
ksv741 afdb6b15fd
Backend verify / commits (pull_request) Successful in 1m28s
Backend verify / security (pull_request) Successful in 1m7s
Backend verify / verify (pull_request) Successful in 6m6s
refactor: replace deep imports with native node aliases (WealthLedger/backend#165)
2026-11-04 22:58:36 +03:00

105 lines
2.9 KiB
TypeScript

import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { IsDateString, IsOptional, Matches } from 'class-validator';
import { MoneyDto } from '#src/common/money.dto';
import { AccountReferenceDto } from '../account-reference.dto';
import {
InvestmentReadQueryDto,
InvestmentResourceMetaDto,
} from '../investment-resource.dto';
export class UpcomingEventsQueryDto extends InvestmentReadQueryDto {
@ApiPropertyOptional({
format: 'date',
description:
'Inclusive UTC calendar start date (YYYY-MM-DD). May be supplied independently; defaults to today in UTC.',
})
@IsOptional()
@Matches(/^\d{4}-\d{2}-\d{2}$/)
@IsDateString({ strict: true })
from?: string;
@ApiPropertyOptional({
format: 'date',
description:
'Inclusive UTC calendar end date (YYYY-MM-DD). May be supplied independently; defaults to 30 days after from. Timestamp queries use the start of the following UTC day as the exclusive end.',
})
@IsOptional()
@Matches(/^\d{4}-\d{2}-\d{2}$/)
@IsDateString({ strict: true })
to?: string;
}
export class UpcomingEventDto {
@ApiPropertyOptional({ type: AccountReferenceDto })
account?: AccountReferenceDto;
@ApiProperty({ enum: ['coupon', 'dividend', 'maturity', 'offer'] })
declare type: 'coupon' | 'dividend' | 'maturity' | 'offer';
@ApiProperty({ format: 'date' })
declare date: string;
@ApiProperty({ enum: ['event', 'registry'] })
declare dateKind: 'event' | 'registry';
@ApiProperty({ type: String, nullable: true })
declare figi: null | string;
@ApiProperty({ type: String, nullable: true })
declare instrumentUid: null | string;
@ApiProperty()
declare ticker: string;
@ApiProperty()
declare displayName: string;
@ApiProperty({ type: String, nullable: true })
declare isin: null | string;
@ApiProperty({ type: String, nullable: true })
declare logoName: null | string;
@ApiProperty({ type: MoneyDto, nullable: true })
declare projectedAmount: MoneyDto | null;
}
export class UpcomingEventsWindowDto {
@ApiProperty({ format: 'date' })
declare from: string;
@ApiProperty({ format: 'date' })
declare to: string;
}
export class UpcomingEventsDto {
@ApiProperty()
declare accountId: string;
@ApiProperty({ format: 'date-time' })
declare calculatedAt: string;
@ApiProperty({
type: UpcomingEventsWindowDto,
description:
'Inclusive UTC window the saved forecast was calculated for. Unchanged by the requested from/to filter.',
})
declare window: UpcomingEventsWindowDto;
@ApiProperty({ type: UpcomingEventDto, isArray: true })
declare events: UpcomingEventDto[];
@ApiProperty({ type: MoneyDto, isArray: true })
declare incomeTotalsByCurrency: MoneyDto[];
}
export class UpcomingEventsResourceDto {
@ApiProperty({ type: UpcomingEventsDto, nullable: true })
declare data: null | UpcomingEventsDto;
@ApiProperty({ type: InvestmentResourceMetaDto })
declare meta: InvestmentResourceMetaDto;
}