/*
Function that returned the uuid of the directory that contains the jobID.json file
@directoryPath : path to the directory that contain a jobID.json file, waiting to be inserted in couchDB
#uuidregexV4 : regex that check if uuid is written in V4.
#uuidArray : array that contai all uuid find in one path.
#uuidDir : contain the last uuid of a uuidArray, that means it is the directory (uuid) that contains the jobID.json file.
function directorySearch(directoryPath) {
    let uuidregexV4 = /[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}/ig;
    let uuidArray = directoryPath.match(uuidregexV4);
    let uuidDir = null;
    logger_1.logger.log('debug', `list of all uuid pattern inside a jobID.json path \n ${JSON.stringify(uuidArray)}`);
    if (uuidArray != null) {
        uuidDir = uuidArray.pop(); // retrieving the last element of uuidArray
    }
    else {
        logger_1.logger.log('warn', `no uuid key found in: ${directoryPath}`);
    }
    logger_1.logger.log('debug', `uuid of the directory that contain a jobID.json file ${uuidDir}`);
    return uuidDir;
}