feat: reconcile hourly investment resource states
This commit is contained in:
@@ -1,9 +1,21 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { IsIn, IsOptional } from 'class-validator';
|
||||
|
||||
export const availabilityValues = ['missing', 'partial', 'complete'] as const;
|
||||
export const availabilityValues = [
|
||||
'available',
|
||||
'initial-loading',
|
||||
'temporarily-unavailable',
|
||||
'connection-unavailable',
|
||||
] as const;
|
||||
export const completenessValues = ['complete', 'incomplete'] as const;
|
||||
export const freshnessValues = ['unknown', 'fresh', 'stale'] as const;
|
||||
export const syncStateValues = ['idle', 'running', 'failed'] as const;
|
||||
export const attemptStateValues = [
|
||||
'none',
|
||||
'running',
|
||||
'succeeded',
|
||||
'partial',
|
||||
'failed',
|
||||
] as const;
|
||||
|
||||
export class InvestmentReadQueryDto {
|
||||
@ApiPropertyOptional({ enum: ['observe'] })
|
||||
@@ -12,17 +24,31 @@ export class InvestmentReadQueryDto {
|
||||
declare sync?: 'observe';
|
||||
}
|
||||
|
||||
export class InvestmentSyncDto {
|
||||
@ApiProperty({ type: String, nullable: true })
|
||||
declare id: null | string;
|
||||
export class InvestmentAttemptProblemDto {
|
||||
@ApiProperty({ enum: ['membership', 'portfolio', 'operations', 'events'] })
|
||||
declare section: 'events' | 'membership' | 'operations' | 'portfolio';
|
||||
|
||||
@ApiProperty({ enum: syncStateValues })
|
||||
declare state: (typeof syncStateValues)[number];
|
||||
@ApiProperty({ type: String, nullable: true })
|
||||
declare accountId: null | string;
|
||||
|
||||
@ApiProperty({ type: String, nullable: true })
|
||||
declare errorCode: null | string;
|
||||
}
|
||||
|
||||
export class InvestmentAttemptDto {
|
||||
@ApiProperty({ enum: attemptStateValues })
|
||||
declare state: (typeof attemptStateValues)[number];
|
||||
|
||||
@ApiProperty({ type: String, nullable: true, format: 'date-time' })
|
||||
declare startedAt: null | string;
|
||||
|
||||
@ApiProperty({ type: String, nullable: true, format: 'date-time' })
|
||||
declare finishedAt: null | string;
|
||||
|
||||
@ApiProperty({ type: InvestmentAttemptProblemDto, isArray: true })
|
||||
declare problems: InvestmentAttemptProblemDto[];
|
||||
}
|
||||
|
||||
export class InvestmentRangeDto {
|
||||
@ApiPropertyOptional()
|
||||
accountId?: string;
|
||||
@@ -73,14 +99,21 @@ export class InvestmentDependencyDto {
|
||||
@ApiProperty({ enum: availabilityValues })
|
||||
declare availability: (typeof availabilityValues)[number];
|
||||
|
||||
@ApiProperty({ enum: completenessValues })
|
||||
declare completeness: (typeof completenessValues)[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;
|
||||
@ApiProperty({ type: InvestmentAttemptDto })
|
||||
declare lastAttempt: InvestmentAttemptDto;
|
||||
|
||||
// Internal resource-source work remains available to existing source owners.
|
||||
// It is deliberately undecorated and therefore not part of the HTTP schema.
|
||||
declare sync: { errorCode: null | string; id: null | string; state: 'failed' | 'idle' | 'running' };
|
||||
}
|
||||
|
||||
export class InvestmentResourceMetaDto extends InvestmentDependencyDto {
|
||||
|
||||
Reference in New Issue
Block a user