93 lines
2.6 KiB
TypeScript
93 lines
2.6 KiB
TypeScript
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
|
import { IsIn, IsOptional } from 'class-validator';
|
|
|
|
export const availabilityValues = ['missing', 'partial', 'complete'] as const;
|
|
export const freshnessValues = ['unknown', 'fresh', 'stale'] as const;
|
|
export const syncStateValues = ['idle', 'queued', 'running', 'failed'] as const;
|
|
|
|
export class InvestmentReadQueryDto {
|
|
@ApiPropertyOptional({ enum: ['observe'] })
|
|
@IsOptional()
|
|
@IsIn(['observe'])
|
|
declare sync?: 'observe';
|
|
}
|
|
|
|
export class InvestmentSyncDto {
|
|
@ApiProperty({ type: String, nullable: true })
|
|
declare id: null | string;
|
|
|
|
@ApiProperty({ enum: syncStateValues })
|
|
declare state: (typeof syncStateValues)[number];
|
|
|
|
@ApiProperty({ type: String, nullable: true })
|
|
declare errorCode: null | string;
|
|
}
|
|
|
|
export class InvestmentRangeDto {
|
|
@ApiPropertyOptional()
|
|
accountId?: string;
|
|
|
|
@ApiProperty({ format: 'date-time' })
|
|
declare from: string;
|
|
|
|
@ApiProperty({ format: 'date-time' })
|
|
declare to: string;
|
|
}
|
|
|
|
export class InvestmentCoverageDto {
|
|
@ApiProperty({ type: InvestmentRangeDto, isArray: true })
|
|
declare requested: InvestmentRangeDto[];
|
|
|
|
@ApiProperty({ type: InvestmentRangeDto, isArray: true })
|
|
declare completeRanges: InvestmentRangeDto[];
|
|
|
|
@ApiProperty({ type: InvestmentRangeDto, isArray: true })
|
|
declare missingRanges: InvestmentRangeDto[];
|
|
|
|
@ApiProperty({ type: String, nullable: true, format: 'date-time' })
|
|
declare asOf: null | string;
|
|
|
|
@ApiProperty({ enum: ['known', 'unknown'] })
|
|
declare historyBoundary: 'known' | 'unknown';
|
|
|
|
@ApiProperty({
|
|
enum: ['missing', 'loading', 'partial', 'complete', 'failed'],
|
|
})
|
|
declare historyState:
|
|
'complete' | 'failed' | 'loading' | 'missing' | 'partial';
|
|
}
|
|
|
|
export class InvestmentDependencyDto {
|
|
@ApiProperty()
|
|
declare dataRevision: string;
|
|
|
|
@ApiProperty()
|
|
declare stateVersion: string;
|
|
|
|
@ApiPropertyOptional({ type: String })
|
|
unavailableReason?: string;
|
|
|
|
@ApiPropertyOptional({ type: () => InvestmentCoverageDto })
|
|
coverage?: InvestmentCoverageDto;
|
|
|
|
@ApiProperty()
|
|
declare resourceKey: string;
|
|
|
|
@ApiProperty({ enum: availabilityValues })
|
|
declare availability: (typeof availabilityValues)[number];
|
|
|
|
@ApiProperty({ enum: freshnessValues })
|
|
declare freshness: (typeof freshnessValues)[number];
|
|
|
|
@ApiProperty({ type: String, format: 'date-time', nullable: true })
|
|
declare lastSuccessfulAt: null | string;
|
|
|
|
@ApiProperty({ type: InvestmentSyncDto })
|
|
declare sync: InvestmentSyncDto;
|
|
}
|
|
|
|
export class InvestmentResourceMetaDto extends InvestmentDependencyDto {
|
|
@ApiPropertyOptional({ type: InvestmentDependencyDto, isArray: true })
|
|
declare dependencies?: InvestmentDependencyDto[];
|
|
}
|