All files / src/EventStatusFilter EventStatusFilter.ts

100% Statements 11/11
100% Branches 2/2
100% Functions 3/3
100% Lines 11/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 471x   1x   1x   1x   1x 1x       1x       2x 2x 1x     2x                                                
import ACommonNode from '@orchesty/nodejs-sdk/dist/lib/Commons/ACommonNode';
import ProcessDto from '@orchesty/nodejs-sdk/dist/lib/Utils/ProcessDto';
import ResultCode from '@orchesty/nodejs-sdk/dist/lib/Utils/ResultCode';
 
export const NAME = 'event-status-filter';
 
export default class EventStatusFilter extends ACommonNode {
 
    public constructor(private readonly type: string) {
        super();
    }
 
    public getName(): string {
        return `${NAME}-${this.type}`;
    }
 
    public processAction(dto: ProcessDto<IInput>): ProcessDto<IInput> {
        const data = dto.getJsonData();
        if (data.type !== this.type) {
            dto.setStopProcess(ResultCode.DO_NOT_CONTINUE, 'Filtered out!');
        }
 
        return dto;
    }
 
}
 
export interface IInput {
    type: string;
    data: {
        topologyId: string;
        topologyName: string;
        topologyVersion: string;
        correlationId: string;
        processId: string;
        user: string;
        timestampMs: number;
        resultMessage: string;
    };
    contents: IStatusMessageContent[];
}
 
export interface IStatusMessageContent {
    body: string;
    trashId?: string;
}