import Client , { File , Folder , CommandResultMetaData , CommandStatus , GetFilesRecursivelyCommand , GetFilesRecursivelyCommandOptions , } from "../client" ; ( async ( ) => { const client = new Client ( ) ; const sourceFolder = await client . getFolder ( "/Borstenson/Company Information" ) ; if ( ! sourceFolder ) { console . log ( "source folder not found" ) ; process . exit ( 1 ) ; } const fileFilterFunction = ( file ) : File | null => { if ( file . mime === "application/pdf" || file . mime === "image/jpeg" ) { return file ; } return null ; } ; const options = { sourceFolder , filterFile : fileFilterFunction , } ; const command = new GetFilesRecursivelyCommand ( client , options ) ; command . execute ( ) ; while ( command . isFinished ( ) !== true ) { await ( async ( ) => { return new Promise ( resolve => setTimeout ( resolve , 1000 ) ) ; } ) ( ) ; console . log ( command . getPercentCompleted ( ) + "%" ) ; } const commandResult = command . getResultMetaData ( ) ; if ( command . getStatus ( ) === CommandStatus . success ) { console . log ( commandResult . messages ) ; for ( const file of command . getFiles ( ) ) { console . log ( file . name ) ; } } else { console . log ( commandResult . errors ) ; } } ) ( ) ;