import type { MigrationLog , Progress } from '../types' ; /**
 * Returns an initial state of the progress object (everything undefined)
 */ export function createInitialProgress ( ) { return { processed : undefined , total : undefined , } ; } param previousProgress param total export function setProgressTotal ( previousProgress , total = previousProgress . total ) { return { ... previousProgress , total , } ; } param previousLogs param progress export function logProgress ( previousLogs , progress ) { const logs = [ ... previousLogs ] ; if ( progress . total ) { if ( typeof progress . processed === 'undefined' ) { logs . push ( { level : 'info' , message : `Starting to process ${ progress . total } documents.` , } ) ; } else { logs . push ( { level : 'info' , message : `Processed ${ progress . processed } documents out of ${ progress . total }.` , } ) ; } } return logs ; } param previousProgress param incrementProcessedBy export function incrementProcessedProgress ( previousProgress , incrementProcessedBy = 0 ) { return { ... previousProgress , processed : ( previousProgress . processed ?? 0 ) + incrementProcessedBy , } ; }