@@ -5,10 +5,10 @@ import { join } from 'path';
55import { Job } from 'bullmq' ;
66import { BackendConfigV1Dto } from '../_dto/backend-config-v1.dto' ;
77import { BackendResultInfoInterface , BackendResultInterface } from '../_interfaces/backend-result.interface' ;
8- import { BackendCodesEnum } from '../_interfaces/backend-codes.enum' ;
98import { ValidationError , validateOrReject } from 'class-validator' ;
10- import { BackendResultInfoDto } from '../_dto/backend-result-info.dto' ;
9+ import { BackendResultInfoErrorDto , BackendResultInfoSuccessDto } from '../_dto/backend-result-info.dto' ;
1110import { plainToInstance } from 'class-transformer' ;
11+ import { BackendCodesEnumError } from '../_interfaces/backend-codes.enum' ;
1212
1313interface ValidationRecursive {
1414 [ key : string ] : string ;
@@ -58,7 +58,7 @@ export class CatchAllExecutor implements ExecutorInterface {
5858 if ( process . status !== 0 ) {
5959 this . service . logger . error ( `Error executing backend ${ backend . name } ` ) ;
6060 const error = this . extractLastJsonImproved ( process . error || process . output ) ;
61- const errorSchema = plainToInstance ( BackendResultInfoDto , error ) ;
61+ const errorSchema = plainToInstance ( BackendResultInfoErrorDto , error ) ;
6262 await validateOrReject ( errorSchema ) ;
6363
6464 return {
@@ -70,7 +70,7 @@ export class CatchAllExecutor implements ExecutorInterface {
7070
7171 this . service . logger . log ( `Backend ${ backend . name } executed successfully` ) ;
7272 const output = this . extractLastJsonImproved ( process . output ) ;
73- const outputSchema = plainToInstance ( BackendResultInfoDto , output ) ;
73+ const outputSchema = plainToInstance ( BackendResultInfoSuccessDto , output ) ;
7474 await validateOrReject ( outputSchema ) ;
7575
7676 return {
@@ -89,10 +89,10 @@ export class CatchAllExecutor implements ExecutorInterface {
8989
9090 return {
9191 backend : backend . name ,
92- status : BackendCodesEnum . INVALID_JSON_RESPONSE ,
92+ status : BackendCodesEnumError . INVALID_JSON_RESPONSE ,
9393 message : `Erreur de validation : ${ Object . keys ( validations ) . join ( ', ' ) } ` . trim ( ) ,
9494 error : {
95- status : BackendCodesEnum . INVALID_JSON_RESPONSE ,
95+ status : BackendCodesEnumError . INVALID_JSON_RESPONSE ,
9696 message : `Erreur de validation : ${ Object . keys ( validations ) . join ( ', ' ) } ` . trim ( ) ,
9797 data : validations ,
9898 } ,
@@ -102,7 +102,7 @@ export class CatchAllExecutor implements ExecutorInterface {
102102
103103 private extractLastJsonImproved ( stdout : string ) : BackendResultInfoInterface {
104104 if ( ! stdout ) return {
105- status : BackendCodesEnum . INVALID_JSON_RESPONSE ,
105+ status : BackendCodesEnumError . INVALID_JSON_RESPONSE ,
106106 message : 'No output' ,
107107 }
108108
@@ -138,7 +138,7 @@ export class CatchAllExecutor implements ExecutorInterface {
138138 }
139139
140140 if ( jsonCandidates . length === 0 ) return {
141- status : BackendCodesEnum . INVALID_JSON_RESPONSE ,
141+ status : BackendCodesEnumError . INVALID_JSON_RESPONSE ,
142142 message : 'No JSON output' ,
143143 }
144144
0 commit comments