import { IRestApiResponse } from 'superdesk-api' ; import { IVersionInformation } from '../interfaces' ; export function fixItemResponseVersionDates < T extends IVersionInformation > ( response ) { ( response . _items ?? [ ] ) . forEach ( ( item ) => { fixItemVersionDates ( item ) ; } ) ; return response ; } export function fixItemVersionDates < T extends IVersionInformation > ( item ) { if ( item . firstcreated == null ) { item . firstcreated = item . _created ; } if ( item . versioncreated == null ) { item . versioncreated = item . _updated ; } if ( item . version_creator == null && item . original_creator != null ) { item . version_creator = item . original_creator ; } return item ; }