feat: add recovery incident module entities and DTOs and implement policy engine controller endpoints
This commit is contained in:
@@ -10,13 +10,31 @@ import {
|
||||
Query,
|
||||
} from '@nestjs/common';
|
||||
import { PolicyEngineService } from './policy-engine.service';
|
||||
import { PolicyEvaluationService } from './policy-evaluation.service';
|
||||
import type { EvaluationInput } from './services/master-value-resolver.service';
|
||||
import { CreatePolicyDto } from './dto/create-policy.dto';
|
||||
import { UpdatePolicyDto } from './dto/update-policy.dto';
|
||||
import { PolicyStatus, AudienceType } from './entities/policy.enums';
|
||||
|
||||
@Controller('policy-engine')
|
||||
export class PolicyEngineController {
|
||||
constructor(private readonly policyEngineService: PolicyEngineService) { }
|
||||
constructor(
|
||||
private readonly policyEngineService: PolicyEngineService,
|
||||
private readonly policyEvaluationService: PolicyEvaluationService,
|
||||
) { }
|
||||
|
||||
@Post('evaluate')
|
||||
async evaluate(@Body() input: EvaluationInput) {
|
||||
return this.policyEvaluationService.evaluateIncident(input);
|
||||
}
|
||||
|
||||
@Post('evaluate-batch')
|
||||
async evaluateBatch(@Body() inputs: EvaluationInput[]) {
|
||||
const list = Array.isArray(inputs) ? inputs : [inputs];
|
||||
return Promise.all(
|
||||
list.map((item) => this.policyEvaluationService.evaluateIncident(item)),
|
||||
);
|
||||
}
|
||||
|
||||
@Post()
|
||||
async create(@Body() createPolicyDto: CreatePolicyDto) {
|
||||
|
||||
@@ -88,4 +88,8 @@ export class CreateRecoveryIncidentDto {
|
||||
@IsBoolean()
|
||||
@IsOptional()
|
||||
isPerksClaimed?: boolean;
|
||||
|
||||
@IsString()
|
||||
@IsOptional()
|
||||
recoverySource?: string;
|
||||
}
|
||||
|
||||
@@ -75,6 +75,9 @@ export class RecoveryIncident {
|
||||
@Column({ name: 'is_perks_claimed', type: 'boolean', default: false })
|
||||
isPerksClaimed!: boolean;
|
||||
|
||||
@Column({ name: 'recovery_source', type: 'varchar', length: 100, nullable: true, default: 'Manual Disruption Entry' })
|
||||
recoverySource?: string;
|
||||
|
||||
@OneToOne('IncidentEvaluation', 'incident', { onDelete: 'CASCADE' })
|
||||
evaluation?: IncidentEvaluation;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user