import * as uuid from 'uuid' ; import { ProjectUpdatePayload } from '@meetalva/message' ; import { revert } from './revert' ; export class EditHistoryCommit { public readonly id : string ; public readonly changes : ProjectUpdatePayload [ ] ; public readonly reverted : boolean ; public constructor ( init ) { this . id = init . id ; this . changes = init . changes ; this . reverted = init . reverted ; } public revert ( ) { return new EditHistoryCommit ( { id : uuid . v4 ( ) , changes : this . changes . map ( revert ) . reverse ( ) , reverted : ! this . reverted } ) ; } public amend ( b ) { return new EditHistoryCommit ( { id : uuid . v4 ( ) , changes : [ ... b . changes , ... this . changes ] , reverted : ! this . reverted } ) ; } }