import Client , { File , Folder , DownloadFolderCommand , DownloadFolderCommandOptions , SourceTargetFileNames , CommandStatus , CommandResultMetaData , } from "../client" ; ( async ( ) => { const client = new Client ( ) ; const sourceFolder = await client . getFolder ( "Borstenson/Company" ) ; const options = { sourceFolder : sourceFolder ! , filterFile : ( file ) : File | null => { if ( file . mime === "application/pdf" ) { return file ; } return null ; } , getTargetFileNameBeforeDownload : ( fileNames ) : string => { return "./tmp/" + fileNames . targetFileName ; } } ; const command = new DownloadFolderCommand ( client , options ) ; command . execute ( ) ; while ( command . isFinished ( ) !== true ) { console . log ( command . getPercentCompleted ( ) + " %" ) ; await ( async ( ) => { return new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ; } ) ( ) ; } const uploadResult = command . getResultMetaData ( ) ; if ( command . getStatus ( ) === CommandStatus . success ) { console . log ( uploadResult . messages ) ; console . log ( command . getBytesDownloaded ( ) ) ; } else { console . log ( uploadResult . errors ) ; } } ) ( ) ;