export interface IScmAnnotation {
    readonly type: string;
    readonly pages: number[];
    readonly ruleNumber: number;
    readonly reason: string;
}

export interface IRssResult {
    readonly value: string;
    readonly originalValue: string;
    readonly scmAnnotations: IScmAnnotation[];
    readonly transformation: string;
}

export type RssResultAnnotation = IScmAnnotation & { readonly displayName: string };

export class RssResult implements IRssResult {
    readonly value: string;
    readonly originalValue: string;
    readonly scmAnnotations: RssResultAnnotation[];
    readonly transformation: string;

    constructor(result: IRssResult, readonly originalKey: string) {
        this.value = result.value;
        this.originalValue = result.originalValue;
        const scmAnnotations = result.scmAnnotations ?? [];
        this.scmAnnotations = scmAnnotations.map(annotation => ({
            ...annotation,
            displayName: annotation.reason.split('found')?.[0]?.trim(),
        }));
        this.transformation = result.transformation;
    }
}
