From 398a6be82b3136e1d5c1245c1e763fbe47a725e8 Mon Sep 17 00:00:00 2001 From: adriano Date: Mon, 24 Jul 2023 12:21:36 -0300 Subject: [PATCH 1/6] =?UTF-8?q?Atualiza=C3=A7=C3=A3o=20na=20api=20de=20ses?= =?UTF-8?q?s=C3=A3o=20remota=20para=20centralizar=20informa=C3=A7=C3=B5es?= =?UTF-8?q?=20de=20banco=20de=20dados?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TEST_SERVER1/api/.env | 6 +- TEST_SERVER1/api/app.js | 817 ++++++++-------- TEST_SERVER1/api/db/connMongo.js | 11 + TEST_SERVER1/api/helpers/PassHash.js | 20 + TEST_SERVER1/api/model/db_conn.js | 33 + TEST_SERVER1/api/package-lock.json | 1328 ++++++++++++++++++++++++++ TEST_SERVER1/api/package.json | 2 + 7 files changed, 1810 insertions(+), 407 deletions(-) create mode 100644 TEST_SERVER1/api/db/connMongo.js create mode 100644 TEST_SERVER1/api/helpers/PassHash.js create mode 100644 TEST_SERVER1/api/model/db_conn.js diff --git a/TEST_SERVER1/api/.env b/TEST_SERVER1/api/.env index 1109bfc..8e97f45 100644 --- a/TEST_SERVER1/api/.env +++ b/TEST_SERVER1/api/.env @@ -1,3 +1,7 @@ PORT=8019 PORT_START=8020 -BASE_URL=http://localhost \ No newline at end of file +BASE_URL=http://localhost +PASS="strongpassword, strongpassword32" +DB_MONGO_URL=mongodb://localhost:27017 +DB_MONGO_NAME=session_out_omnihit_db + \ No newline at end of file diff --git a/TEST_SERVER1/api/app.js b/TEST_SERVER1/api/app.js index c84b124..c68f564 100644 --- a/TEST_SERVER1/api/app.js +++ b/TEST_SERVER1/api/app.js @@ -1,486 +1,491 @@ -const express = require('express'); -const bodyparser = require('body-parser'); -const dotenv = require('dotenv'); -dotenv.config({ path: '.env' }); +const express = require('express') +const bodyparser = require('body-parser') +const dotenv = require('dotenv') +dotenv.config({ path: '.env' }) const copyFolder = require('./helpers/copyFolder') const createDir = require('./helpers/createDir') const createFile = require('./helpers/createFile') -const path = require('path'); +const path = require('path') const db_info = require('./db_conn') -const fs = require('fs'); -let mysql_conn = require('./helpers/mysql_conn.js'); -const { exec, execSync, spawn } = require("child_process"); +const fs = require('fs') +let mysql_conn = require('./helpers/mysql_conn.js') +const { exec, execSync, spawn } = require('child_process') -const startPm2Process = require('./helpers/startPm2Process'); -const removeDir = require('./helpers/remove_dir'); +const startPm2Process = require('./helpers/startPm2Process') +const removeDir = require('./helpers/remove_dir') const setSessionName = require('./helpers/setSessionNumber') const getNumberFromName = require('./helpers/getNumberSequence') -const pm2 = require('pm2'); +const pm2 = require('pm2') +const bcrypt = require('bcrypt') +const OmnihitDBConn = require('./model/db_conn') -const app = express(); +const app = express() -app.use(bodyparser.json()); +app.use(bodyparser.json()) -app.get('/', function (req, res) { return res.send('Express + TypeScript Server'); }); +app.get('/', function (req, res) { + return res.send('Express + TypeScript Server') +}) app.post('/api/session', async function (req, res) { + let { app_name, whatsappId, client_url, number } = req.body - let { app_name, whatsappId, client_url, number } = req.body + if (app_name) { + app_name = app_name.trim() + } - if(app_name){ - app_name = app_name.trim() + console.log('__dirname: ', path.join(__dirname, '..', app_name)) + + console.log( + 'app_name: ', + app_name, + ' | whatsappId: ', + whatsappId, + ' | client_url: ', + client_url + ) + + const sessionsPath = path.join(__dirname, '..', 'sessions') + + const directoriesInDIrectory = fs + .readdirSync(sessionsPath, { withFileTypes: true }) + .filter((item) => item.isDirectory()) + .map((item) => item.name) + + console.log('directoriesInDIrectory: ', directoriesInDIrectory) + + const dirExist = directoriesInDIrectory.filter((e) => e.trim() == app_name) + + let dirSessionsApp = path.join(sessionsPath, app_name) + + if (dirExist.length == 0) { + let create = createDir(dirSessionsApp) + + if (!create) { + res.status(500).json({ message: 'Cannot create the directory path!' }) + return } + } - console.log('__dirname: ', path.join(__dirname, '..', app_name)) + let appPort = [] - console.log('app_name: ', app_name, ' | whatsappId: ', whatsappId, ' | client_url: ',client_url) + let existSubDir = false - const sessionsPath = path.join(__dirname, '..', 'sessions') + for (let i = 0; i < directoriesInDIrectory.length; i++) { + console.log('directoriesInDIrectory[i]', directoriesInDIrectory[i]) - const directoriesInDIrectory = fs.readdirSync(sessionsPath, { withFileTypes: true }) - .filter((item) => item.isDirectory()) - .map((item) => item.name); + const subDir = fs + .readdirSync(path.join(sessionsPath, directoriesInDIrectory[i]), { + withFileTypes: true, + }) + .filter((item) => item.isDirectory()) + .map((item) => item.name) - console.log('directoriesInDIrectory: ', directoriesInDIrectory) + for (let x = 0; x < subDir.length; x++) { + console.log('subdir: ', subDir[x]) - const dirExist = directoriesInDIrectory.filter((e) => e.trim() == app_name) + let whatsId = subDir[x].split('_')[0] - let dirSessionsApp = path.join(sessionsPath, app_name) + if (whatsId == whatsappId && app_name == directoriesInDIrectory[i]) { + let currPath = path.join( + sessionsPath, + directoriesInDIrectory[i], + subDir[x] + ) - if (dirExist.length == 0) { + console.log( + 'PATH: ', + path.join(sessionsPath, directoriesInDIrectory[i], subDir[x]) + ) - let create = createDir(dirSessionsApp) + let oldNumber = subDir[x].split('_')[1] - if (!create) { - - res.status(500).json({ message: 'Cannot create the directory path!' }) - return + if (oldNumber != number) { + deletePm2Process(subDir[x], currPath) + removeDir(currPath) + } else { + res.send('ok') + return } - } + } - let appPort = [] + let auxPort = subDir[x].split('_')[3] + console.log('---------> auxPort: ' + auxPort) + if (auxPort) { + auxPort = +auxPort.trim() - let existSubDir = false - - for (let i = 0; i < directoriesInDIrectory.length; i++) { - - console.log('directoriesInDIrectory[i]', directoriesInDIrectory[i]) - - const subDir = fs.readdirSync(path.join(sessionsPath, directoriesInDIrectory[i]), { withFileTypes: true }) - .filter((item) => item.isDirectory()) - .map((item) => item.name); - - for (let x = 0; x < subDir.length; x++) { - - console.log('subdir: ', subDir[x]) - - let whatsId = subDir[x].split('_')[0] - - if (whatsId == whatsappId && app_name == directoriesInDIrectory[i]) { - - let currPath = path.join(sessionsPath, directoriesInDIrectory[i], subDir[x]) - - console.log('PATH: ', path.join(sessionsPath, directoriesInDIrectory[i], subDir[x])) - - let oldNumber = subDir[x].split('_')[1] - // let sessionNum = subDir[x].split('_')[2] - // let sessionPort = subDir[x].split('_')[3] - // let newSessionAppName = `${whatsId}_${number}_${sessionNum}_${sessionPort}` - - // let newPath = path.join(sessionsPath, directoriesInDIrectory[i], newSessionAppName) - - // console.log(`number: ${number}\noldNumber: ${oldNumber}\nsessionNum: ${sessionNum}\nsessionPort: ${sessionPort}\nnewSessionAppName:${newSessionAppName}`) - - if (oldNumber != number) { - - deletePm2Process(subDir[x], currPath) - - removeDir(currPath) - } - else { - res.send('ok') - return - } - - - - - // try { - - // // - - // fs.renameSync(currPath, newPath) - - // console.log("Successfully renamed the directory.") - - // const data = fs.readFileSync(path.join(`${newPath}`, '.env'), 'utf-8'); - - // // console.log('Data: ', data) - - // const newValue = data.replace(`MOBILEUID=${oldNumber}`, `MOBILEUID=${number}`) - - // fs.writeFileSync(path.join(`${newPath}`, '.env'), newValue, 'utf-8'); - - // if (oldNumber != number) { - // removeDir(path.join(newPath, '.wwebjs_auth')) - // } - - // startPm2Process(newSessionAppName, 'app.js', newPath, sessionPort) - - - // } catch (err) { - // console.log(err) - // } - - - // res.send('ok') - // return - } - - appPort.push(+subDir[x].split('_')[3]) - - console.log('---------> appPort: '+appPort) - - existSubDir = true - + if (!isNaN(auxPort)) { + appPort.push(auxPort) } + } + existSubDir = true } + } - appPort = existSubDir ? Math.max(...appPort) + 1 : process.env.PORT_START + appPort = existSubDir ? Math.max(...appPort) + 1 : process.env.PORT_START - console.log('new port: ', appPort) + console.log('new port: ', appPort) + let dirSessionAppName + let numberSession = 1 - let dirSessionAppName + let lstPass = process.env.PASS - let numberSession = 1 + if (!lstPass) { + console.log('PASS VARIABLE NOT FOUND INTO .ENV!') + return res.send('OK') + } - // const dirSessionsNumberAppDirectories = fs.readdirSync(dirSessionsApp, { withFileTypes: true }) - // .filter((item) => item.isDirectory() && item.name.includes(`${number}`)) - // .map((item) => item.name); + let db_credentials + try { + db_credentials = await OmnihitDBConn.findOne({ client_url }) - // console.log('dirSessionsNumberAppDirectories', dirSessionsNumberAppDirectories, ' | dirSessionsApp: ', dirSessionsApp) - - console.log('client_url: ', client_url) - - let db = db_info.filter((e) => e.client_url == client_url) - - if (db && db.length > 0) { - - db = db[0].db_conf + if (!db_credentials) { + db_credentials = new OmnihitDBConn({ + client_url: client_url, + db_conf: { + DB: '', + DB_HOST: '', + DB_USER: '', + DB_PASS: '', + DB_PORT: '', + }, + }) + await db_credentials.save() + return res.send('ok') } + } catch (error) { + console.log(error) + } - // if (dirSessionsNumberAppDirectories.length > 0) { - - if (db && Object.keys(db).length > 0) { - - const whatsapp_numbers = await new Promise((resolve, reject) => { - mysql_conn(db).query('SELECT name FROM Whatsapps WHERE name LIKE ?', [`%${number}%`], (err, result) => { - if (err) { - reject(err) - } - else { - resolve(result) - } - }); - }) - - console.log('whatsapp_numbers: ', whatsapp_numbers) - - let session_num = [] - - if (whatsapp_numbers && whatsapp_numbers.length > 0) { - - console.log('whatsapp_numbers.length: ', whatsapp_numbers.length) - - if (whatsapp_numbers.length == 5) { - res.status(400).json({ message: 'Cannot create more than 4 sessions from the same number' }) - return - } - - let regex = /-> [a-zA-Z]\d$/ - - let numbered_sessions = whatsapp_numbers.filter((e) => regex.test(e.name)) - - console.log('numbered_sessions: ', numbered_sessions) - - session_num = numbered_sessions.map((e) => parseInt((e.name.split('->')[e.name.split('->').length - 1]).trim().match(/\d+/)[0])) - - console.log('session_num', session_num) - - } - - let index = 1; - - while (index <= 4) { - - if (!session_num.includes(index)) { - console.log(index) - numberSession = index - break - } - index++ - } + if (db_credentials && db_credentials.db_conf.DB.trim().length > 0) { + lstPass = lstPass.split(',') + let password = null + password = await lstPass.find( + async (pass) => + await bcrypt.compare(pass.trim(), db_credentials.db_conf.DB_PASS) + ) + if (password) { + db_credentials.db_conf.DB_PASS = password + } else { + return res.send('ok') + } + } + if ( + db_credentials.db_conf && + Object.keys(db_credentials.db_conf).length > 0 + ) { + const whatsapp_numbers = await new Promise((resolve, reject) => { + mysql_conn(db_credentials.db_conf).query( + 'SELECT name FROM Whatsapps WHERE name LIKE ?', + [`%${number}%`], + (err, result) => { + if (err) { + reject(err) + } else { + resolve(result) + } } + ) + }) + console.log('whatsapp_numbers: ', whatsapp_numbers) - // numberSession = Math.max(...session_number) + 1 + let session_num = [] - console.log('Number session: ', numberSession) - - // } - - dirSessionAppName = `${whatsappId}_${number}_${numberSession}_${appPort}` - - - - destDir = path.join(dirSessionsApp, dirSessionAppName) - - originDir = path.join(__dirname, '..', 'whats') - - copyFolder(originDir, destDir) - - - if (db && Object.keys(db).length > 0) { - - console.log('kkkkkkkkkkkkkkk') - - let whatsName - - const whatsapp = await new Promise((resolve, reject) => { - - mysql_conn(db).query("SELECT name from Whatsapps where id = ?", [whatsappId], (err, result) => { - - if (err) { - reject(err) - } - else { - resolve(result) - } - }); + if (whatsapp_numbers && whatsapp_numbers.length > 0) { + console.log('whatsapp_numbers.length: ', whatsapp_numbers.length) + if (whatsapp_numbers.length == 5) { + res.status(400).json({ + message: 'Cannot create more than 4 sessions from the same number', }) + return + } - if (whatsapp[0]["name"].split('->').length > 0) { - whatsName = `${whatsapp[0]["name"].split('->')[0]} -> S${numberSession}` - } - else { - whatsName = `${whatsapp[0]["name"]} -> S${numberSession}` - } + let regex = /-> [a-zA-Z]\d$/ - console.log('whatsName: ', whatsName) + let numbered_sessions = whatsapp_numbers.filter((e) => regex.test(e.name)) - console.log(`url: ${process.env.BASE_URL}:${appPort}\n whatsname: ${whatsName}\n whatsappId: ${whatsappId}`) + console.log('numbered_sessions: ', numbered_sessions) - await new Promise((resolve, reject) => { - mysql_conn(db).query("UPDATE Whatsapps SET url = ?, name = ? where id = ?", [`${process.env.BASE_URL}:${appPort}`, `${whatsName}`, whatsappId], - - function (err, result) { - if (err) { - reject(err) - console.log("===> ERROR: " + err); - } - else { - resolve(result) - // console.log('RESULT: ', result) - } - // else - // console.log('myslq result: ', result); - }); - }) - - let whatsappName = `${number} - s${numberSession}` - - console.log('-------------- numberSession', numberSession) - - if (whatsapp.length > 0) { - - if (whatsapp[0]['name'].split(' ').length > 0) { - - whatsappName = `${whatsapp[0]['name'].split(' ')[0]} - S${numberSession}` - - } - - } - - console.log('whatsapp: ', whatsapp) - console.log("whatsapp[0]['name']: ", whatsapp[0]['name']) - - const keys = Object.keys(db); - - var stream = fs.createWriteStream(path.join(destDir, '.env')); - stream.once('open', function (fd) { - stream.write("# NUMBER AND NAME THAT WILL BE DISPLAYED ON CONSOLE\n"); - stream.write(`MOBILEUID=${number}\n`); - stream.write(`MOBILENAME=${whatsappName}\n`); - stream.write("\n"); - - stream.write("# PORT NUMBER FOR THIS API\n"); - stream.write(`PORT=${appPort}\n`); - stream.write("\n"); - - stream.write("# URL FROM THE OMNIHIT BACKEND API\n"); - stream.write(`CLIENT_URL=${client_url}\n`); - stream.write("\n"); - - stream.write("# OMNIHIT DATABASE\n"); - keys.forEach((key, index) => { - stream.write(`${key}=${db[key]}\n`); - }); - stream.write("\n"); - - stream.write(`# WHATSAPP ID OF THE TABLE Whatsapps FROM THE OMNIHIT DATABASE\n`); - stream.write(`WHATSAPP_ID=${whatsappId}`); - - stream.end(); - }); - - - - console.log('----------------destDir: ', destDir) - - - execSync(`npm install`, { cwd: destDir }, (error, stdout, stderr) => { - if (error) { - console.log(`error: ${error.message}`); - return; - } - if (stderr) { - console.log(`stderr: ${stderr}`); - return; - } - console.log(`stdout: ${stdout}`); - }); - - startPm2Process(dirSessionAppName, 'app.js', destDir, appPort) + session_num = numbered_sessions.map((e) => + parseInt( + e.name + .split('->') + [e.name.split('->').length - 1].trim() + .match(/\d+/)[0] + ) + ) + console.log('session_num', session_num) } - res.send("OK"); + let index = 1 -}); + while (index <= 4) { + if (!session_num.includes(index)) { + console.log(index) + numberSession = index + break + } + index++ + } + } + + // numberSession = Math.max(...session_number) + 1 + + console.log('Number session: ', numberSession) + + // } + + dirSessionAppName = `${whatsappId}_${number}_${numberSession}_${appPort}` + + destDir = path.join(dirSessionsApp, dirSessionAppName) + + originDir = path.join(__dirname, '..', 'whats') + + copyFolder(originDir, destDir) + + if ( + db_credentials.db_conf && + Object.keys(db_credentials.db_conf).length > 0 + ) { + console.log('***SUCCESS SEED DIRECTORY CREATED***') + + let whatsName + + const whatsapp = await new Promise((resolve, reject) => { + mysql_conn(db_credentials.db_conf).query( + 'SELECT name from Whatsapps where id = ?', + [whatsappId], + (err, result) => { + if (err) { + reject(err) + } else { + resolve(result) + } + } + ) + }) + + if (whatsapp[0]['name'].split('->').length > 0) { + whatsName = `${whatsapp[0]['name'].split('->')[0]} -> S${numberSession}` + } else { + whatsName = `${whatsapp[0]['name']} -> S${numberSession}` + } + + console.log('whatsName: ', whatsName) + + console.log( + `url: ${process.env.BASE_URL}:${appPort}\n whatsname: ${whatsName}\n whatsappId: ${whatsappId}` + ) + + await new Promise((resolve, reject) => { + mysql_conn(db_credentials.db_conf).query( + 'UPDATE Whatsapps SET url = ?, name = ? where id = ?', + [`${process.env.BASE_URL}:${appPort}`, `${whatsName}`, whatsappId], + + function (err, result) { + if (err) { + reject(err) + console.log('===> ERROR: ' + err) + } else { + resolve(result) + // console.log('RESULT: ', result) + } + // else + // console.log('myslq result: ', result); + } + ) + }) + + let whatsappName = `${number} - s${numberSession}` + + console.log('-------------- numberSession', numberSession) + + if (whatsapp.length > 0) { + if (whatsapp[0]['name'].split(' ').length > 0) { + whatsappName = `${ + whatsapp[0]['name'].split(' ')[0] + } - S${numberSession}` + } + } + + console.log('whatsapp: ', whatsapp) + console.log("whatsapp[0]['name']: ", whatsapp[0]['name']) + + const keys = Object.keys(db_credentials.db_conf) + + var stream = fs.createWriteStream(path.join(destDir, '.env')) + stream.once('open', function (fd) { + stream.write('# NUMBER AND NAME THAT WILL BE DISPLAYED ON CONSOLE\n') + stream.write(`MOBILEUID=${number}\n`) + stream.write(`MOBILENAME=${whatsappName}\n`) + stream.write('\n') + + stream.write('# PORT NUMBER FOR THIS API\n') + stream.write(`PORT=${appPort}\n`) + stream.write('\n') + + stream.write('# URL FROM THE OMNIHIT BACKEND API\n') + stream.write(`CLIENT_URL=${client_url}\n`) + stream.write('\n') + + stream.write('# OMNIHIT DATABASE\n') + keys.forEach((key, index) => { + stream.write(`${key}=${db_credentials.db_conf[key]}\n`) + }) + stream.write('\n') + + stream.write( + `# WHATSAPP ID OF THE TABLE Whatsapps FROM THE OMNIHIT DATABASE\n` + ) + stream.write(`WHATSAPP_ID=${whatsappId}`) + + stream.end() + }) + + console.log('----------------destDir: ', destDir) + + execSync(`npm install`, { cwd: destDir }, (error, stdout, stderr) => { + if (error) { + console.log(`error: ${error.message}`) + return + } + if (stderr) { + console.log(`stderr: ${stderr}`) + return + } + console.log(`stdout: ${stdout}`) + }) + + startPm2Process(dirSessionAppName, 'app.js', destDir, appPort) + } + + res.send('OK') +}) app.post('/api/session/edit', async function (req, res) { - - const { app_name, whatsappId, client_url, number } = req.body - + const { app_name, whatsappId, client_url, number } = req.body }) app.post('/api/session/del', async function (req, res) { + let { whatsappId, app_name } = req.body - let { whatsappId, app_name } = req.body + if (app_name) { + app_name = app_name.trim() + } - if(app_name){ - app_name = app_name.trim() + const sessionsPath = path.join(__dirname, '..', 'sessions') + + const directoriesInDIrectory = fs + .readdirSync(sessionsPath, { withFileTypes: true }) + .filter((item) => item.isDirectory()) + .map((item) => item.name) + + console.log('directoriesInDIrectory: ', directoriesInDIrectory) + + const dirExist = directoriesInDIrectory.filter((e) => e.trim() == app_name) + + console.log('dirExist: ', dirExist) + + if (dirExist.length == 0) res.send('ok') + + for (let i = 0; i < directoriesInDIrectory.length; i++) { + console.log('directoriesInDIrectory[i]', directoriesInDIrectory[i]) + + const subDir = fs + .readdirSync(path.join(sessionsPath, directoriesInDIrectory[i]), { + withFileTypes: true, + }) + .filter((item) => item.isDirectory()) + .map((item) => item.name) + + for (let x = 0; x < subDir.length; x++) { + console.log('subdir: ', subDir[x]) + + let whatsId = subDir[x].split('_')[0] + + if (whatsId == whatsappId && app_name == directoriesInDIrectory[i]) { + let currPath = path.join( + sessionsPath, + directoriesInDIrectory[i], + subDir[x] + ) + + deletePm2Process(subDir[x], currPath) + + console.log('currPath: ', currPath) + + removeDir(currPath) + + return res.send('ok') + } } + } - const sessionsPath = path.join(__dirname, '..', 'sessions') - - const directoriesInDIrectory = fs.readdirSync(sessionsPath, { withFileTypes: true }) - .filter((item) => item.isDirectory()) - .map((item) => item.name); - - console.log('directoriesInDIrectory: ', directoriesInDIrectory) - - const dirExist = directoriesInDIrectory.filter((e) => e.trim() == app_name) - - console.log('dirExist: ', dirExist) - - if (dirExist.length == 0) - res.send('ok') - - - for (let i = 0; i < directoriesInDIrectory.length; i++) { - - console.log('directoriesInDIrectory[i]', directoriesInDIrectory[i]) - - const subDir = fs.readdirSync(path.join(sessionsPath, directoriesInDIrectory[i]), { withFileTypes: true }) - .filter((item) => item.isDirectory()) - .map((item) => item.name); - - for (let x = 0; x < subDir.length; x++) { - - console.log('subdir: ', subDir[x]) - - let whatsId = subDir[x].split('_')[0] - - if (whatsId == whatsappId && app_name == directoriesInDIrectory[i]) { - - let currPath = path.join(sessionsPath, directoriesInDIrectory[i], subDir[x]) - - deletePm2Process(subDir[x], currPath); - - console.log('currPath: ', currPath) - - removeDir(currPath) - - return res.send('ok') - - } - - } - - } - - res.send('ok') - + res.send('ok') }) - - app.listen(process.env.PORT || 8003, function () { - console.log("\u26A1[server]: Server is running at Port ::: " + process.env.PORT || 8003); -}); + console.log( + '\u26A1[server]: Server is running at Port ::: ' + process.env.PORT || 8003 + ) +}) process.on('uncaughtException', function (err) { - console.error(' '); - console.error('----- ' + (new Date).toUTCString() + ' ----------------------------------') - console.error('Erro uncaughtException: ', err.message) - console.error(err.stack) - console.error(' '); - return -}); + console.error(' ') + console.error( + '----- ' + new Date().toUTCString() + ' ----------------------------------' + ) + console.error('Erro uncaughtException: ', err.message) + console.error(err.stack) + console.error(' ') + return +}) function deletePm2Process(process_name, currPath) { - pm2.connect(function (err) { - if (err) { - console.error(err); - } + pm2.connect(function (err) { + if (err) { + console.error(err) + } - pm2.list(function (err, processes) { - if (err) { - console.error(err); + pm2.list(function (err, processes) { + if (err) { + console.error(err) + } + + processes.forEach(function (process) { + console.log('.........process.name: ', process.name) + + if (process.name === process_name) { + execSync( + `pm2 delete ${process_name} && pm2 save --force`, + { cwd: currPath }, + (error, stdout, stderr) => { + if (error) { + console.log(`error: ${error.message}`) + return + } + if (stderr) { + console.log(`stderr: ${stderr}`) + return + } + console.log(`stdout: ${stdout}`) } + ) + } + }) - processes.forEach(function (process) { - - console.log(".........process.name: ", process.name); - - if (process.name === process_name) { - execSync(`pm2 delete ${process_name} && pm2 save --force`, { cwd: currPath }, (error, stdout, stderr) => { - if (error) { - console.log(`error: ${error.message}`); - return; - } - if (stderr) { - console.log(`stderr: ${stderr}`); - return; - } - console.log(`stdout: ${stdout}`); - }); - } - - }); - - pm2.disconnect(); - }); - }); + pm2.disconnect() + }) + }) } - diff --git a/TEST_SERVER1/api/db/connMongo.js b/TEST_SERVER1/api/db/connMongo.js new file mode 100644 index 0000000..2026782 --- /dev/null +++ b/TEST_SERVER1/api/db/connMongo.js @@ -0,0 +1,11 @@ +const mongoose = require('mongoose') +require('dotenv').config({ path: `${process.cwd()}/.env` }) + +async function main(){ + await mongoose.connect(process.env.DB_MONGO_URL, { dbName: process.env.DB_MONGO_NAME }) + console.log('Conectou ao Mongoose!') +} + +main().catch((err)=>console.log(err)) + +module.exports = mongoose \ No newline at end of file diff --git a/TEST_SERVER1/api/helpers/PassHash.js b/TEST_SERVER1/api/helpers/PassHash.js new file mode 100644 index 0000000..7b15e55 --- /dev/null +++ b/TEST_SERVER1/api/helpers/PassHash.js @@ -0,0 +1,20 @@ +const bcrypt = require('bcrypt') + +const pass = async () => { + // create a password + const salt = await bcrypt.genSalt(12) + const passwordHash = await bcrypt.hash('strongpassword', salt) + console.log(passwordHash) +} +pass() + +// const passDec = async () => { +// const _pass = await bcrypt.compare( +// 'strongpassword', +// '$2b$12$R/bpS7b9FzdXlHAijmP.3.gJqgeUjwQVSuK6q.G0PZbb0wowCnrN.' +// ) +// console.log('_pass: ', _pass) +// } +// passDec() + +console.log('process.cwd(): ', process.cwd()) diff --git a/TEST_SERVER1/api/model/db_conn.js b/TEST_SERVER1/api/model/db_conn.js new file mode 100644 index 0000000..5f677b3 --- /dev/null +++ b/TEST_SERVER1/api/model/db_conn.js @@ -0,0 +1,33 @@ +const mongoose = require('../db/connMongo') +const { Schema } = mongoose + +const OmnihitDBConn = mongoose.model( + 'Omnihit_db_conn', + new Schema( + { + client_url: { + type: String, + }, + db_conf: { + DB: { + type: String, + }, + DB_HOST: { + type: String, + }, + DB_USER: { + type: String, + }, + DB_PASS: { + type: String, + }, + DB_PORT: { + type: String, + }, + }, + }, + { timestamps: true } + ) +) + +module.exports = OmnihitDBConn diff --git a/TEST_SERVER1/api/package-lock.json b/TEST_SERVER1/api/package-lock.json index 34fb6eb..06387b3 100644 --- a/TEST_SERVER1/api/package-lock.json +++ b/TEST_SERVER1/api/package-lock.json @@ -9,15 +9,64 @@ "version": "1.0.0", "license": "MIT", "dependencies": { + "bcrypt": "^5.1.0", "body-parser": "^1.20.1", "dotenv": "^16.0.3", "express": "^4.18.2", "fs-extra": "^11.1.0", + "mongoose": "^7.4.0", "mysql": "^2.18.1", "nodemon": "^2.0.20", "socket.io": "^4.5.4" } }, + "node_modules/@mapbox/node-pre-gyp": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.11.tgz", + "integrity": "sha512-Yhlar6v9WQgUp/He7BdgzOz8lqMQ8sU+jkCq7Wx8Myc5YFJLbEe7lgui/V7G1qB1DJykHSGwreceSaD60Y0PUQ==", + "dependencies": { + "detect-libc": "^2.0.0", + "https-proxy-agent": "^5.0.0", + "make-dir": "^3.1.0", + "node-fetch": "^2.6.7", + "nopt": "^5.0.0", + "npmlog": "^5.0.1", + "rimraf": "^3.0.2", + "semver": "^7.3.5", + "tar": "^6.1.11" + }, + "bin": { + "node-pre-gyp": "bin/node-pre-gyp" + } + }, + "node_modules/@mapbox/node-pre-gyp/node_modules/nopt": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz", + "integrity": "sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==", + "dependencies": { + "abbrev": "1" + }, + "bin": { + "nopt": "bin/nopt.js" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/@mapbox/node-pre-gyp/node_modules/semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "dependencies": { + "lru-cache": "^6.0.0" + }, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/@socket.io/component-emitter": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz", @@ -41,6 +90,20 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz", "integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==" }, + "node_modules/@types/webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-xTE1E+YF4aWPJJeUzaZI5DRntlkY3+BCVJi0axFptnjGmAoWxkyREIh/XMrfxVLejwQxMCfDXdICo0VLxThrog==" + }, + "node_modules/@types/whatwg-url": { + "version": "8.2.2", + "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-8.2.2.tgz", + "integrity": "sha512-FtQu10RWgn3D9U4aazdwIE2yzphmTJREDqNdODHrbrZmmMqI0vMheC/6NE/J1Yveaj8H+ela+YwWTjq5PGmuhA==", + "dependencies": { + "@types/node": "*", + "@types/webidl-conversions": "*" + } + }, "node_modules/abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -58,6 +121,46 @@ "node": ">= 0.6" } }, + "node_modules/agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "dependencies": { + "debug": "4" + }, + "engines": { + "node": ">= 6.0.0" + } + }, + "node_modules/agent-base/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/agent-base/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, + "node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, "node_modules/anymatch": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", @@ -70,6 +173,36 @@ "node": ">= 8" } }, + "node_modules/aproba": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", + "integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==" + }, + "node_modules/are-we-there-yet": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-2.0.0.tgz", + "integrity": "sha512-Ci/qENmwHnsYo9xKIcUJN5LeDKdJ6R1Z1j9V/J5wyq8nh/mYPEpIKJbBZXtZjG04HiK7zV/p6Vs9952MrMeUIw==", + "dependencies": { + "delegates": "^1.0.0", + "readable-stream": "^3.6.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/are-we-there-yet/node_modules/readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "dependencies": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + }, + "engines": { + "node": ">= 6" + } + }, "node_modules/array-flatten": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", @@ -88,6 +221,19 @@ "node": "^4.5.0 || >= 5.9" } }, + "node_modules/bcrypt": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-5.1.0.tgz", + "integrity": "sha512-RHBS7HI5N5tEnGTmtR/pppX0mmDSBpQ4aCBsj7CEQfYXDcO74A8sIBYcJMuCsis2E81zDxeENYhv66oZwLiA+Q==", + "hasInstallScript": true, + "dependencies": { + "@mapbox/node-pre-gyp": "^1.0.10", + "node-addon-api": "^5.0.0" + }, + "engines": { + "node": ">= 10.0.0" + } + }, "node_modules/bignumber.js": { "version": "9.0.0", "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.0.tgz", @@ -147,6 +293,14 @@ "node": ">=8" } }, + "node_modules/bson": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/bson/-/bson-5.4.0.tgz", + "integrity": "sha512-WRZ5SQI5GfUuKnPTNmAYPiKIof3ORXAF4IRU5UcgmivNIon01rWQlw5RUH954dpu8yGL8T59YShVddIPaU/gFA==", + "engines": { + "node": ">=14.20.1" + } + }, "node_modules/bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", @@ -193,11 +347,32 @@ "fsevents": "~2.3.2" } }, + "node_modules/chownr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==", + "engines": { + "node": ">=10" + } + }, + "node_modules/color-support": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", + "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==", + "bin": { + "color-support": "bin.js" + } + }, "node_modules/concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" }, + "node_modules/console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ==" + }, "node_modules/content-disposition": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", @@ -255,6 +430,11 @@ "ms": "2.0.0" } }, + "node_modules/delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==" + }, "node_modules/depd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", @@ -272,6 +452,14 @@ "npm": "1.2.8000 || >= 1.4.16" } }, + "node_modules/detect-libc": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.2.tgz", + "integrity": "sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw==", + "engines": { + "node": ">=8" + } + }, "node_modules/dotenv": { "version": "16.0.3", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", @@ -285,6 +473,11 @@ "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, + "node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, "node_modules/encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", @@ -461,6 +654,33 @@ "node": ">=14.14" } }, + "node_modules/fs-minipass": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", + "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", + "dependencies": { + "minipass": "^3.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/fs-minipass/node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" + }, "node_modules/fsevents": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", @@ -479,6 +699,25 @@ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, + "node_modules/gauge": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-3.0.2.tgz", + "integrity": "sha512-+5J6MS/5XksCuXq++uFRsnUd7Ovu1XenbeuIuNRJxYWjgQbPuFhT14lAvsWfqfAmnwluf1OwMjz39HjfLPci0Q==", + "dependencies": { + "aproba": "^1.0.3 || ^2.0.0", + "color-support": "^1.1.2", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.1", + "object-assign": "^4.1.1", + "signal-exit": "^3.0.0", + "string-width": "^4.2.3", + "strip-ansi": "^6.0.1", + "wide-align": "^1.1.2" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/get-intrinsic": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.0.tgz", @@ -492,6 +731,25 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "dependencies": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + }, + "engines": { + "node": "*" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/glob-parent": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", @@ -538,6 +796,11 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==" + }, "node_modules/http-errors": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", @@ -553,6 +816,39 @@ "node": ">= 0.8" } }, + "node_modules/https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "dependencies": { + "agent-base": "6", + "debug": "4" + }, + "engines": { + "node": ">= 6" + } + }, + "node_modules/https-proxy-agent/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/https-proxy-agent/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, "node_modules/iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -569,11 +865,25 @@ "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==" }, + "node_modules/inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "dependencies": { + "once": "^1.3.0", + "wrappy": "1" + } + }, "node_modules/inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, + "node_modules/ip": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz", + "integrity": "sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==" + }, "node_modules/ipaddr.js": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", @@ -601,6 +911,14 @@ "node": ">=0.10.0" } }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, "node_modules/is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", @@ -636,6 +954,47 @@ "graceful-fs": "^4.1.6" } }, + "node_modules/kareem": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.5.1.tgz", + "integrity": "sha512-7jFxRVm+jD+rkq3kY0iZDJfsO2/t4BBPeEb2qKn2lR/9KhuksYk5hxzfRYWMPV8P/x2d0kHD306YyWLzjjH+uA==", + "engines": { + "node": ">=12.0.0" + } + }, + "node_modules/lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dependencies": { + "semver": "^6.0.0" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/make-dir/node_modules/semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==", + "bin": { + "semver": "bin/semver.js" + } + }, "node_modules/media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -644,6 +1003,12 @@ "node": ">= 0.6" } }, + "node_modules/memory-pager": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz", + "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==", + "optional": true + }, "node_modules/merge-descriptors": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", @@ -698,6 +1063,163 @@ "node": "*" } }, + "node_modules/minipass": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/minizlib": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", + "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", + "dependencies": { + "minipass": "^3.0.0", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/minizlib/node_modules/minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "dependencies": { + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==", + "bin": { + "mkdirp": "bin/cmd.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/mongodb": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-5.7.0.tgz", + "integrity": "sha512-zm82Bq33QbqtxDf58fLWBwTjARK3NSvKYjyz997KSy6hpat0prjeX/kxjbPVyZY60XYPDNETaHkHJI2UCzSLuw==", + "dependencies": { + "bson": "^5.4.0", + "mongodb-connection-string-url": "^2.6.0", + "socks": "^2.7.1" + }, + "engines": { + "node": ">=14.20.1" + }, + "optionalDependencies": { + "saslprep": "^1.0.3" + }, + "peerDependencies": { + "@aws-sdk/credential-providers": "^3.201.0", + "@mongodb-js/zstd": "^1.1.0", + "kerberos": "^2.0.1", + "mongodb-client-encryption": ">=2.3.0 <3", + "snappy": "^7.2.2" + }, + "peerDependenciesMeta": { + "@aws-sdk/credential-providers": { + "optional": true + }, + "@mongodb-js/zstd": { + "optional": true + }, + "kerberos": { + "optional": true + }, + "mongodb-client-encryption": { + "optional": true + }, + "snappy": { + "optional": true + } + } + }, + "node_modules/mongodb-connection-string-url": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-2.6.0.tgz", + "integrity": "sha512-WvTZlI9ab0QYtTYnuMLgobULWhokRjtC7db9LtcVfJ+Hsnyr5eo6ZtNAt3Ly24XZScGMelOcGtm7lSn0332tPQ==", + "dependencies": { + "@types/whatwg-url": "^8.2.1", + "whatwg-url": "^11.0.0" + } + }, + "node_modules/mongoose": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-7.4.0.tgz", + "integrity": "sha512-oHE1eqodfKzugXRlQxpo+msIea7jPcRoayDuEMr50+bYwM/juA5f+1stjkWlXcg6vo1PdJFVA6DGaKOPLuG5mA==", + "dependencies": { + "bson": "^5.4.0", + "kareem": "2.5.1", + "mongodb": "5.7.0", + "mpath": "0.9.0", + "mquery": "5.0.0", + "ms": "2.1.3", + "sift": "16.0.1" + }, + "engines": { + "node": ">=14.20.1" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/mongoose" + } + }, + "node_modules/mongoose/node_modules/ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + }, + "node_modules/mpath": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.9.0.tgz", + "integrity": "sha512-ikJRQTk8hw5DEoFVxHG1Gn9T/xcjtdnOKIU1JTmGjZZlg9LST2mBLmcX3/ICIbgJydT2GOc15RnNy5mHmzfSew==", + "engines": { + "node": ">=4.0.0" + } + }, + "node_modules/mquery": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/mquery/-/mquery-5.0.0.tgz", + "integrity": "sha512-iQMncpmEK8R8ncT8HJGsGc9Dsp8xcgYMVSbs5jgnm1lFHTZqMJTUWTDx1LBO8+mK3tPNZWFLBghQEIOULSTHZg==", + "dependencies": { + "debug": "4.x" + }, + "engines": { + "node": ">=14.0.0" + } + }, + "node_modules/mquery/node_modules/debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "dependencies": { + "ms": "2.1.2" + }, + "engines": { + "node": ">=6.0" + }, + "peerDependenciesMeta": { + "supports-color": { + "optional": true + } + } + }, + "node_modules/mquery/node_modules/ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + }, "node_modules/ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -730,6 +1252,49 @@ "node": ">= 0.6" } }, + "node_modules/node-addon-api": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-5.1.0.tgz", + "integrity": "sha512-eh0GgfEkpnoWDq+VY8OyvYhFEzBk6jIYbRKdIlyTiAXIVJ8PyBaKb0rp7oDtoddbdoHWhq8wwr+XZ81F1rpNdA==" + }, + "node_modules/node-fetch": { + "version": "2.6.12", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.12.tgz", + "integrity": "sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, + "engines": { + "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } + } + }, + "node_modules/node-fetch/node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "node_modules/node-fetch/node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "node_modules/node-fetch/node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, "node_modules/nodemon": { "version": "2.0.20", "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.20.tgz", @@ -792,6 +1357,17 @@ "node": ">=0.10.0" } }, + "node_modules/npmlog": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-5.0.1.tgz", + "integrity": "sha512-AqZtDUWOMKs1G/8lwylVjrdYgqA4d9nu8hc+0gzRxlDb1I10+FHBGMXs6aiQHFdCUUlqH99MUMuLfzWDNDtfxw==", + "dependencies": { + "are-we-there-yet": "^2.0.0", + "console-control-strings": "^1.1.0", + "gauge": "^3.0.0", + "set-blocking": "^2.0.0" + } + }, "node_modules/object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -819,6 +1395,14 @@ "node": ">= 0.8" } }, + "node_modules/once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "dependencies": { + "wrappy": "1" + } + }, "node_modules/parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", @@ -827,6 +1411,14 @@ "node": ">= 0.8" } }, + "node_modules/path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==", + "engines": { + "node": ">=0.10.0" + } + }, "node_modules/path-to-regexp": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", @@ -865,6 +1457,14 @@ "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==" }, + "node_modules/punycode": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", + "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==", + "engines": { + "node": ">=6" + } + }, "node_modules/qs": { "version": "6.11.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", @@ -931,6 +1531,20 @@ "node": ">=8.10.0" } }, + "node_modules/rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dependencies": { + "glob": "^7.1.3" + }, + "bin": { + "rimraf": "bin.js" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -955,6 +1569,18 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "node_modules/saslprep": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.3.tgz", + "integrity": "sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag==", + "optional": true, + "dependencies": { + "sparse-bitfield": "^3.0.3" + }, + "engines": { + "node": ">=6" + } + }, "node_modules/semver": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", @@ -1005,6 +1631,11 @@ "node": ">= 0.8.0" } }, + "node_modules/set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==" + }, "node_modules/setprototypeof": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", @@ -1023,6 +1654,16 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/sift": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/sift/-/sift-16.0.1.tgz", + "integrity": "sha512-Wv6BjQ5zbhW7VFefWusVP33T/EM0vYikCaQ2qR8yULbsilAT8/wQaXvuQ3ptGLpoKx+lihJE3y2UTgKDyyNHZQ==" + }, + "node_modules/signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" + }, "node_modules/simple-update-notifier": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-1.1.0.tgz", @@ -1042,6 +1683,15 @@ "semver": "bin/semver.js" } }, + "node_modules/smart-buffer": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", + "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==", + "engines": { + "node": ">= 6.0.0", + "npm": ">= 3.0.0" + } + }, "node_modules/socket.io": { "version": "4.5.4", "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.5.4.tgz", @@ -1117,6 +1767,28 @@ "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" }, + "node_modules/socks": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz", + "integrity": "sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==", + "dependencies": { + "ip": "^2.0.0", + "smart-buffer": "^4.2.0" + }, + "engines": { + "node": ">= 10.13.0", + "npm": ">= 3.0.0" + } + }, + "node_modules/sparse-bitfield": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", + "integrity": "sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ==", + "optional": true, + "dependencies": { + "memory-pager": "^1.0.2" + } + }, "node_modules/sqlstring": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.1.tgz", @@ -1146,6 +1818,30 @@ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" }, + "node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -1157,6 +1853,22 @@ "node": ">=4" } }, + "node_modules/tar": { + "version": "6.1.15", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.15.tgz", + "integrity": "sha512-/zKt9UyngnxIT/EAGYuxaMYgOIJiP81ab9ZfkILq4oNLPFX50qyYmu7jRj9qeXoxmJHjGlbH0+cm2uy1WCs10A==", + "dependencies": { + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "minipass": "^5.0.0", + "minizlib": "^2.1.1", + "mkdirp": "^1.0.3", + "yallist": "^4.0.0" + }, + "engines": { + "node": ">=10" + } + }, "node_modules/to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -1187,6 +1899,17 @@ "nodetouch": "bin/nodetouch.js" } }, + "node_modules/tr46": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-3.0.0.tgz", + "integrity": "sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==", + "dependencies": { + "punycode": "^2.1.1" + }, + "engines": { + "node": ">=12" + } + }, "node_modules/type-is": { "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", @@ -1241,6 +1964,39 @@ "node": ">= 0.8" } }, + "node_modules/webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==", + "engines": { + "node": ">=12" + } + }, + "node_modules/whatwg-url": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-11.0.0.tgz", + "integrity": "sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ==", + "dependencies": { + "tr46": "^3.0.0", + "webidl-conversions": "^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/wide-align": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz", + "integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==", + "dependencies": { + "string-width": "^1.0.2 || 2 || 3 || 4" + } + }, + "node_modules/wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, "node_modules/ws": { "version": "8.2.3", "resolved": "https://registry.npmjs.org/ws/-/ws-8.2.3.tgz", @@ -1260,9 +2016,48 @@ "optional": true } } + }, + "node_modules/yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" } }, "dependencies": { + "@mapbox/node-pre-gyp": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/@mapbox/node-pre-gyp/-/node-pre-gyp-1.0.11.tgz", + "integrity": "sha512-Yhlar6v9WQgUp/He7BdgzOz8lqMQ8sU+jkCq7Wx8Myc5YFJLbEe7lgui/V7G1qB1DJykHSGwreceSaD60Y0PUQ==", + "requires": { + "detect-libc": "^2.0.0", + "https-proxy-agent": "^5.0.0", + "make-dir": "^3.1.0", + "node-fetch": "^2.6.7", + "nopt": "^5.0.0", + "npmlog": "^5.0.1", + "rimraf": "^3.0.2", + "semver": "^7.3.5", + "tar": "^6.1.11" + }, + "dependencies": { + "nopt": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/nopt/-/nopt-5.0.0.tgz", + "integrity": "sha512-Tbj67rffqceeLpcRXrT7vKAN8CwfPeIBgM7E6iBkmKLV7bEMwpGgYLGv0jACUsECaa/vuxP0IjEont6umdMgtQ==", + "requires": { + "abbrev": "1" + } + }, + "semver": { + "version": "7.5.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.5.4.tgz", + "integrity": "sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA==", + "requires": { + "lru-cache": "^6.0.0" + } + } + } + }, "@socket.io/component-emitter": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/@socket.io/component-emitter/-/component-emitter-3.1.0.tgz", @@ -1286,6 +2081,20 @@ "resolved": "https://registry.npmjs.org/@types/node/-/node-18.11.18.tgz", "integrity": "sha512-DHQpWGjyQKSHj3ebjFI/wRKcqQcdR+MoFBygntYOZytCqNfkd2ZC4ARDJ2DQqhjH5p85Nnd3jhUJIXrszFX/JA==" }, + "@types/webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/@types/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-xTE1E+YF4aWPJJeUzaZI5DRntlkY3+BCVJi0axFptnjGmAoWxkyREIh/XMrfxVLejwQxMCfDXdICo0VLxThrog==" + }, + "@types/whatwg-url": { + "version": "8.2.2", + "resolved": "https://registry.npmjs.org/@types/whatwg-url/-/whatwg-url-8.2.2.tgz", + "integrity": "sha512-FtQu10RWgn3D9U4aazdwIE2yzphmTJREDqNdODHrbrZmmMqI0vMheC/6NE/J1Yveaj8H+ela+YwWTjq5PGmuhA==", + "requires": { + "@types/node": "*", + "@types/webidl-conversions": "*" + } + }, "abbrev": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.1.1.tgz", @@ -1300,6 +2109,34 @@ "negotiator": "0.6.3" } }, + "agent-base": { + "version": "6.0.2", + "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-6.0.2.tgz", + "integrity": "sha512-RZNwNclF7+MS/8bDg70amg32dyeZGZxiDuQmZxKLAlQjr3jGyLx+4Kkk58UO7D2QdgFIQCovuSuZESne6RG6XQ==", + "requires": { + "debug": "4" + }, + "dependencies": { + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" + }, "anymatch": { "version": "3.1.3", "resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz", @@ -1309,6 +2146,32 @@ "picomatch": "^2.0.4" } }, + "aproba": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/aproba/-/aproba-2.0.0.tgz", + "integrity": "sha512-lYe4Gx7QT+MKGbDsA+Z+he/Wtef0BiwDOlK/XkBrdfsh9J/jPPXbX0tE9x9cl27Tmu5gg3QUbUrQYa/y+KOHPQ==" + }, + "are-we-there-yet": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-2.0.0.tgz", + "integrity": "sha512-Ci/qENmwHnsYo9xKIcUJN5LeDKdJ6R1Z1j9V/J5wyq8nh/mYPEpIKJbBZXtZjG04HiK7zV/p6Vs9952MrMeUIw==", + "requires": { + "delegates": "^1.0.0", + "readable-stream": "^3.6.0" + }, + "dependencies": { + "readable-stream": { + "version": "3.6.2", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.6.2.tgz", + "integrity": "sha512-9u/sniCrY3D5WdsERHzHE4G2YCXqoG5FTHUiCC4SIbr6XcLZBY05ya9EKjYek9O5xOAwjGq+1JdGBAS7Q9ScoA==", + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + } + } + }, "array-flatten": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", @@ -1324,6 +2187,15 @@ "resolved": "https://registry.npmjs.org/base64id/-/base64id-2.0.0.tgz", "integrity": "sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog==" }, + "bcrypt": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/bcrypt/-/bcrypt-5.1.0.tgz", + "integrity": "sha512-RHBS7HI5N5tEnGTmtR/pppX0mmDSBpQ4aCBsj7CEQfYXDcO74A8sIBYcJMuCsis2E81zDxeENYhv66oZwLiA+Q==", + "requires": { + "@mapbox/node-pre-gyp": "^1.0.10", + "node-addon-api": "^5.0.0" + } + }, "bignumber.js": { "version": "9.0.0", "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-9.0.0.tgz", @@ -1370,6 +2242,11 @@ "fill-range": "^7.0.1" } }, + "bson": { + "version": "5.4.0", + "resolved": "https://registry.npmjs.org/bson/-/bson-5.4.0.tgz", + "integrity": "sha512-WRZ5SQI5GfUuKnPTNmAYPiKIof3ORXAF4IRU5UcgmivNIon01rWQlw5RUH954dpu8yGL8T59YShVddIPaU/gFA==" + }, "bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", @@ -1399,11 +2276,26 @@ "readdirp": "~3.6.0" } }, + "chownr": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/chownr/-/chownr-2.0.0.tgz", + "integrity": "sha512-bIomtDF5KGpdogkLd9VspvFzk9KfpyyGlS8YFVZl7TGPBHL5snIOnxeshwVgPteQ9b4Eydl+pVbIyE1DcvCWgQ==" + }, + "color-support": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-support/-/color-support-1.1.3.tgz", + "integrity": "sha512-qiBjkpbMLO/HL68y+lh4q0/O1MZFj2RX6X/KmMa3+gJD3z+WwI1ZzDHysvqHGS3mP6mznPckpXmw1nI9cJjyRg==" + }, "concat-map": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", "integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==" }, + "console-control-strings": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/console-control-strings/-/console-control-strings-1.1.0.tgz", + "integrity": "sha512-ty/fTekppD2fIwRvnZAVdeOiGd1c7YXEixbgJTNzqcxJWKQnjJ/V1bNEEE6hygpM3WjwHFUVK6HTjWSzV4a8sQ==" + }, "content-disposition": { "version": "0.5.4", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.4.tgz", @@ -1449,6 +2341,11 @@ "ms": "2.0.0" } }, + "delegates": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/delegates/-/delegates-1.0.0.tgz", + "integrity": "sha512-bd2L678uiWATM6m5Z1VzNCErI3jiGzt6HGY8OVICs40JQq/HALfbyNJmp0UDakEY4pMMaN0Ly5om/B1VI/+xfQ==" + }, "depd": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz", @@ -1459,6 +2356,11 @@ "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.2.0.tgz", "integrity": "sha512-2sJGJTaXIIaR1w4iJSNoN0hnMY7Gpc/n8D4qSCJw8QqFWXf7cuAgnEHxBpweaVcPevC2l3KpjYCx3NypQQgaJg==" }, + "detect-libc": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/detect-libc/-/detect-libc-2.0.2.tgz", + "integrity": "sha512-UX6sGumvvqSaXgdKGUsgZWqcUyIXZ/vZTrlRT/iobiKhGL0zL4d3osHj3uqllWJK+i+sixDS/3COVEOFbupFyw==" + }, "dotenv": { "version": "16.0.3", "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.0.3.tgz", @@ -1469,6 +2371,11 @@ "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", "integrity": "sha512-WMwm9LhRUo+WUaRN+vRuETqG89IgZphVSNkdFgeb6sS/E4OrDIN7t48CAewSHXc6C8lefD8KKfr5vY61brQlow==" }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, "encodeurl": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", @@ -1606,6 +2513,29 @@ "universalify": "^2.0.0" } }, + "fs-minipass": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/fs-minipass/-/fs-minipass-2.1.0.tgz", + "integrity": "sha512-V/JgOLFCS+R6Vcq0slCuaeWEdNC3ouDlJMNIsacH2VtALiu9mV4LPrHc5cDl8k5aw6J8jwgWWpiTo5RYhmIzvg==", + "requires": { + "minipass": "^3.0.0" + }, + "dependencies": { + "minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "requires": { + "yallist": "^4.0.0" + } + } + } + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==" + }, "fsevents": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz", @@ -1617,6 +2547,22 @@ "resolved": "https://registry.npmjs.org/function-bind/-/function-bind-1.1.1.tgz", "integrity": "sha512-yIovAzMX49sF8Yl58fSCWJ5svSLuaibPxXQJFLmBObTuCr0Mf1KiPopGM9NiFjiYBCbfaa2Fh6breQ6ANVTI0A==" }, + "gauge": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/gauge/-/gauge-3.0.2.tgz", + "integrity": "sha512-+5J6MS/5XksCuXq++uFRsnUd7Ovu1XenbeuIuNRJxYWjgQbPuFhT14lAvsWfqfAmnwluf1OwMjz39HjfLPci0Q==", + "requires": { + "aproba": "^1.0.3 || ^2.0.0", + "color-support": "^1.1.2", + "console-control-strings": "^1.0.0", + "has-unicode": "^2.0.1", + "object-assign": "^4.1.1", + "signal-exit": "^3.0.0", + "string-width": "^4.2.3", + "strip-ansi": "^6.0.1", + "wide-align": "^1.1.2" + } + }, "get-intrinsic": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.2.0.tgz", @@ -1627,6 +2573,19 @@ "has-symbols": "^1.0.3" } }, + "glob": { + "version": "7.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.2.3.tgz", + "integrity": "sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.1.1", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, "glob-parent": { "version": "5.1.2", "resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz", @@ -1658,6 +2617,11 @@ "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.3.tgz", "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==" }, + "has-unicode": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", + "integrity": "sha512-8Rf9Y83NBReMnx0gFzA8JImQACstCYWUplepDa9xprwwtmgEZUF0h/i5xSA625zB/I37EtrswSST6OXxwaaIJQ==" + }, "http-errors": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz", @@ -1670,6 +2634,30 @@ "toidentifier": "1.0.1" } }, + "https-proxy-agent": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-5.0.1.tgz", + "integrity": "sha512-dFcAjpTQFgoLMzC2VwU+C/CbS7uRL0lWmxDITmqm7C+7F0Odmj6s9l6alZc6AELXhrnggM2CeWSXHGOdX2YtwA==", + "requires": { + "agent-base": "6", + "debug": "4" + }, + "dependencies": { + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, "iconv-lite": { "version": "0.4.24", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", @@ -1683,11 +2671,25 @@ "resolved": "https://registry.npmjs.org/ignore-by-default/-/ignore-by-default-1.0.1.tgz", "integrity": "sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA==" }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, "inherits": { "version": "2.0.4", "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" }, + "ip": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/ip/-/ip-2.0.0.tgz", + "integrity": "sha512-WKa+XuLG1A1R0UWhl2+1XQSi+fZWMsYKffMZTTYsiZaUD8k2yDAj5atimTUD2TZkyCkNEeYE5NhFZmupOGtjYQ==" + }, "ipaddr.js": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", @@ -1706,6 +2708,11 @@ "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==" }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" + }, "is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", @@ -1733,11 +2740,45 @@ "universalify": "^2.0.0" } }, + "kareem": { + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/kareem/-/kareem-2.5.1.tgz", + "integrity": "sha512-7jFxRVm+jD+rkq3kY0iZDJfsO2/t4BBPeEb2qKn2lR/9KhuksYk5hxzfRYWMPV8P/x2d0kHD306YyWLzjjH+uA==" + }, + "lru-cache": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-6.0.0.tgz", + "integrity": "sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==", + "requires": { + "yallist": "^4.0.0" + } + }, + "make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "requires": { + "semver": "^6.0.0" + }, + "dependencies": { + "semver": { + "version": "6.3.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.1.tgz", + "integrity": "sha512-BR7VvDCVHO+q2xBEWskxS6DJE1qRnb7DxzUrogb71CWoSficBxYsiAGd+Kl0mmq/MprG9yArRkyrQxTO6XjMzA==" + } + } + }, "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", "integrity": "sha512-dq+qelQ9akHpcOl/gUVRTxVIOkAJ1wR3QAvb4RsVjS8oVoFjDGTc679wJYmUmknUF5HwMLOgb5O+a3KxfWapPQ==" }, + "memory-pager": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/memory-pager/-/memory-pager-1.5.0.tgz", + "integrity": "sha512-ZS4Bp4r/Zoeq6+NLJpP+0Zzm0pR8whtGPf1XExKLJBAczGMnSi3It14OiNCStjQjM6NU1okjQGSxgEZN8eBYKg==", + "optional": true + }, "merge-descriptors": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", @@ -1774,6 +2815,104 @@ "brace-expansion": "^1.1.7" } }, + "minipass": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==" + }, + "minizlib": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/minizlib/-/minizlib-2.1.2.tgz", + "integrity": "sha512-bAxsR8BVfj60DWXHE3u30oHzfl4G7khkSuPW+qvpd7jFRHm7dLxOjUk1EHACJ/hxLY8phGJ0YhYHZo7jil7Qdg==", + "requires": { + "minipass": "^3.0.0", + "yallist": "^4.0.0" + }, + "dependencies": { + "minipass": { + "version": "3.3.6", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-3.3.6.tgz", + "integrity": "sha512-DxiNidxSEK+tHG6zOIklvNOwm3hvCrbUrdtzY74U6HKTJxvIDfOUL5W5P2Ghd3DTkhhKPYGqeNUIh5qcM4YBfw==", + "requires": { + "yallist": "^4.0.0" + } + } + } + }, + "mkdirp": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-1.0.4.tgz", + "integrity": "sha512-vVqVZQyf3WLx2Shd0qJ9xuvqgAyKPLAiqITEtqW0oIUjzo3PePDd6fW9iFz30ef7Ysp/oiWqbhszeGWW2T6Gzw==" + }, + "mongodb": { + "version": "5.7.0", + "resolved": "https://registry.npmjs.org/mongodb/-/mongodb-5.7.0.tgz", + "integrity": "sha512-zm82Bq33QbqtxDf58fLWBwTjARK3NSvKYjyz997KSy6hpat0prjeX/kxjbPVyZY60XYPDNETaHkHJI2UCzSLuw==", + "requires": { + "bson": "^5.4.0", + "mongodb-connection-string-url": "^2.6.0", + "saslprep": "^1.0.3", + "socks": "^2.7.1" + } + }, + "mongodb-connection-string-url": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/mongodb-connection-string-url/-/mongodb-connection-string-url-2.6.0.tgz", + "integrity": "sha512-WvTZlI9ab0QYtTYnuMLgobULWhokRjtC7db9LtcVfJ+Hsnyr5eo6ZtNAt3Ly24XZScGMelOcGtm7lSn0332tPQ==", + "requires": { + "@types/whatwg-url": "^8.2.1", + "whatwg-url": "^11.0.0" + } + }, + "mongoose": { + "version": "7.4.0", + "resolved": "https://registry.npmjs.org/mongoose/-/mongoose-7.4.0.tgz", + "integrity": "sha512-oHE1eqodfKzugXRlQxpo+msIea7jPcRoayDuEMr50+bYwM/juA5f+1stjkWlXcg6vo1PdJFVA6DGaKOPLuG5mA==", + "requires": { + "bson": "^5.4.0", + "kareem": "2.5.1", + "mongodb": "5.7.0", + "mpath": "0.9.0", + "mquery": "5.0.0", + "ms": "2.1.3", + "sift": "16.0.1" + }, + "dependencies": { + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==" + } + } + }, + "mpath": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/mpath/-/mpath-0.9.0.tgz", + "integrity": "sha512-ikJRQTk8hw5DEoFVxHG1Gn9T/xcjtdnOKIU1JTmGjZZlg9LST2mBLmcX3/ICIbgJydT2GOc15RnNy5mHmzfSew==" + }, + "mquery": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/mquery/-/mquery-5.0.0.tgz", + "integrity": "sha512-iQMncpmEK8R8ncT8HJGsGc9Dsp8xcgYMVSbs5jgnm1lFHTZqMJTUWTDx1LBO8+mK3tPNZWFLBghQEIOULSTHZg==", + "requires": { + "debug": "4.x" + }, + "dependencies": { + "debug": { + "version": "4.3.4", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", + "integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==", + "requires": { + "ms": "2.1.2" + } + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" + } + } + }, "ms": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", @@ -1802,6 +2941,40 @@ "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", "integrity": "sha512-+EUsqGPLsM+j/zdChZjsnX51g4XrHFOIXwfnCVPGlQk/k5giakcKsuxCObBRu6DSm9opw/O6slWbJdghQM4bBg==" }, + "node-addon-api": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-5.1.0.tgz", + "integrity": "sha512-eh0GgfEkpnoWDq+VY8OyvYhFEzBk6jIYbRKdIlyTiAXIVJ8PyBaKb0rp7oDtoddbdoHWhq8wwr+XZ81F1rpNdA==" + }, + "node-fetch": { + "version": "2.6.12", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.12.tgz", + "integrity": "sha512-C/fGU2E8ToujUivIO0H+tpQ6HWo4eEmchoPIoXtxCrVghxdKq+QOHqEZW7tuP3KlV3bC8FRMO5nMCC7Zm1VP6g==", + "requires": { + "whatwg-url": "^5.0.0" + }, + "dependencies": { + "tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==" + }, + "webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==" + }, + "whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", + "requires": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + } + } + }, "nodemon": { "version": "2.0.20", "resolved": "https://registry.npmjs.org/nodemon/-/nodemon-2.0.20.tgz", @@ -1847,6 +3020,17 @@ "resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz", "integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==" }, + "npmlog": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/npmlog/-/npmlog-5.0.1.tgz", + "integrity": "sha512-AqZtDUWOMKs1G/8lwylVjrdYgqA4d9nu8hc+0gzRxlDb1I10+FHBGMXs6aiQHFdCUUlqH99MUMuLfzWDNDtfxw==", + "requires": { + "are-we-there-yet": "^2.0.0", + "console-control-strings": "^1.1.0", + "gauge": "^3.0.0", + "set-blocking": "^2.0.0" + } + }, "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -1865,11 +3049,24 @@ "ee-first": "1.1.1" } }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==", + "requires": { + "wrappy": "1" + } + }, "parseurl": { "version": "1.3.3", "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==" + }, "path-to-regexp": { "version": "0.1.7", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", @@ -1899,6 +3096,11 @@ "resolved": "https://registry.npmjs.org/pstree.remy/-/pstree.remy-1.1.8.tgz", "integrity": "sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w==" }, + "punycode": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.0.tgz", + "integrity": "sha512-rRV+zQD8tVFys26lAGR9WUuS4iUAngJScM+ZRSKtvl5tKeZ2t5bvdNFdNHBW9FWR4guGHlgmsZ1G7BSm2wTbuA==" + }, "qs": { "version": "6.11.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz", @@ -1952,6 +3154,14 @@ "picomatch": "^2.2.1" } }, + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "requires": { + "glob": "^7.1.3" + } + }, "safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -1962,6 +3172,15 @@ "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, + "saslprep": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/saslprep/-/saslprep-1.0.3.tgz", + "integrity": "sha512-/MY/PEMbk2SuY5sScONwhUDsV2p77Znkb/q3nSVstq/yQzYJOH/Azh29p9oJLsl3LnQwSvZDKagDGBsBwSooag==", + "optional": true, + "requires": { + "sparse-bitfield": "^3.0.3" + } + }, "semver": { "version": "5.7.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", @@ -2005,6 +3224,11 @@ "send": "0.18.0" } }, + "set-blocking": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/set-blocking/-/set-blocking-2.0.0.tgz", + "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==" + }, "setprototypeof": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", @@ -2020,6 +3244,16 @@ "object-inspect": "^1.9.0" } }, + "sift": { + "version": "16.0.1", + "resolved": "https://registry.npmjs.org/sift/-/sift-16.0.1.tgz", + "integrity": "sha512-Wv6BjQ5zbhW7VFefWusVP33T/EM0vYikCaQ2qR8yULbsilAT8/wQaXvuQ3ptGLpoKx+lihJE3y2UTgKDyyNHZQ==" + }, + "signal-exit": { + "version": "3.0.7", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.7.tgz", + "integrity": "sha512-wnD2ZE+l+SPC/uoS0vXeE9L1+0wuaMqKlfz9AMUo38JsyLSBWSFcHR1Rri62LZc12vLr1gb3jl7iwQhgwpAbGQ==" + }, "simple-update-notifier": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/simple-update-notifier/-/simple-update-notifier-1.1.0.tgz", @@ -2035,6 +3269,11 @@ } } }, + "smart-buffer": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/smart-buffer/-/smart-buffer-4.2.0.tgz", + "integrity": "sha512-94hK0Hh8rPqQl2xXc3HsaBoOXKV20MToPkcXvwbISWLEs+64sBq5kFgn2kJDHb1Pry9yrP0dxrCI9RRci7RXKg==" + }, "socket.io": { "version": "4.5.4", "resolved": "https://registry.npmjs.org/socket.io/-/socket.io-4.5.4.tgz", @@ -2092,6 +3331,24 @@ } } }, + "socks": { + "version": "2.7.1", + "resolved": "https://registry.npmjs.org/socks/-/socks-2.7.1.tgz", + "integrity": "sha512-7maUZy1N7uo6+WVEX6psASxtNlKaNVMlGQKkG/63nEDdLOWNbiUMoLK7X4uYoLhQstau72mLgfEWcXcwsaHbYQ==", + "requires": { + "ip": "^2.0.0", + "smart-buffer": "^4.2.0" + } + }, + "sparse-bitfield": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/sparse-bitfield/-/sparse-bitfield-3.0.3.tgz", + "integrity": "sha512-kvzhi7vqKTfkh0PZU+2D2PIllw2ymqJKujUcyPMd9Y75Nv4nPbGJZXNhxsgdQab2BmlDct1YnfQCguEvHr7VsQ==", + "optional": true, + "requires": { + "memory-pager": "^1.0.2" + } + }, "sqlstring": { "version": "2.3.1", "resolved": "https://registry.npmjs.org/sqlstring/-/sqlstring-2.3.1.tgz", @@ -2117,6 +3374,24 @@ } } }, + "string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + } + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "requires": { + "ansi-regex": "^5.0.1" + } + }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -2125,6 +3400,19 @@ "has-flag": "^3.0.0" } }, + "tar": { + "version": "6.1.15", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.1.15.tgz", + "integrity": "sha512-/zKt9UyngnxIT/EAGYuxaMYgOIJiP81ab9ZfkILq4oNLPFX50qyYmu7jRj9qeXoxmJHjGlbH0+cm2uy1WCs10A==", + "requires": { + "chownr": "^2.0.0", + "fs-minipass": "^2.0.0", + "minipass": "^5.0.0", + "minizlib": "^2.1.1", + "mkdirp": "^1.0.3", + "yallist": "^4.0.0" + } + }, "to-regex-range": { "version": "5.0.1", "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz", @@ -2146,6 +3434,14 @@ "nopt": "~1.0.10" } }, + "tr46": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-3.0.0.tgz", + "integrity": "sha512-l7FvfAHlcmulp8kr+flpQZmVwtu7nfRV7NZujtN0OqES8EL4O4e0qqzL0DC5gAvx/ZC/9lk6rhcUwYvkBnBnYA==", + "requires": { + "punycode": "^2.1.1" + } + }, "type-is": { "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", @@ -2185,10 +3481,42 @@ "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", "integrity": "sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg==" }, + "webidl-conversions": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-7.0.0.tgz", + "integrity": "sha512-VwddBukDzu71offAQR975unBIGqfKZpM+8ZX6ySk8nYhVoo5CYaZyzt3YBvYtRtO+aoGlqxPg/B87NGVZ/fu6g==" + }, + "whatwg-url": { + "version": "11.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-11.0.0.tgz", + "integrity": "sha512-RKT8HExMpoYx4igMiVMY83lN6UeITKJlBQ+vR/8ZJ8OCdSiN3RwCq+9gH0+Xzj0+5IrM6i4j/6LuvzbZIQgEcQ==", + "requires": { + "tr46": "^3.0.0", + "webidl-conversions": "^7.0.0" + } + }, + "wide-align": { + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/wide-align/-/wide-align-1.1.5.tgz", + "integrity": "sha512-eDMORYaPNZ4sQIuuYPDHdQvf4gyCF9rEEV/yPxGfwPkRodwEgiMUUXTx/dex+Me0wxx53S+NgUHaP7y3MGlDmg==", + "requires": { + "string-width": "^1.0.2 || 2 || 3 || 4" + } + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==" + }, "ws": { "version": "8.2.3", "resolved": "https://registry.npmjs.org/ws/-/ws-8.2.3.tgz", "integrity": "sha512-wBuoj1BDpC6ZQ1B7DWQBYVLphPWkm8i9Y0/3YdHjHKHiohOJ1ws+3OccDWtH+PoC9DZD5WOTrJvNbWvjS6JWaA==" + }, + "yallist": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz", + "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==" } } } diff --git a/TEST_SERVER1/api/package.json b/TEST_SERVER1/api/package.json index ba0a368..389f14b 100644 --- a/TEST_SERVER1/api/package.json +++ b/TEST_SERVER1/api/package.json @@ -11,10 +11,12 @@ "author": "Adriano ", "license": "MIT", "dependencies": { + "bcrypt": "^5.1.0", "body-parser": "^1.20.1", "dotenv": "^16.0.3", "express": "^4.18.2", "fs-extra": "^11.1.0", + "mongoose": "^7.4.0", "mysql": "^2.18.1", "nodemon": "^2.0.20", "socket.io": "^4.5.4" From 417f9472633c204c12ae9831818ffab98c18fc20 Mon Sep 17 00:00:00 2001 From: adriano Date: Mon, 24 Jul 2023 17:29:41 -0300 Subject: [PATCH 2/6] =?UTF-8?q?Atualiza=C3=A7=C3=A3o=20para=20descriptogra?= =?UTF-8?q?far=20hash?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TEST_SERVER1/api/app.js | 21 +++++++++++++++---- TEST_SERVER1/api/helpers/PassHash.js | 30 ++++++++++++++-------------- 2 files changed, 32 insertions(+), 19 deletions(-) diff --git a/TEST_SERVER1/api/app.js b/TEST_SERVER1/api/app.js index c68f564..540f988 100644 --- a/TEST_SERVER1/api/app.js +++ b/TEST_SERVER1/api/app.js @@ -167,10 +167,23 @@ app.post('/api/session', async function (req, res) { lstPass = lstPass.split(',') let password = null - password = await lstPass.find( - async (pass) => - await bcrypt.compare(pass.trim(), db_credentials.db_conf.DB_PASS) - ) + // password = await lstPass.find( + // async (pass) => + // await bcrypt.compare(pass.trim(), db_credentials.db_conf.DB_PASS) + // ) + + for (let i = 0; i < lstPass.length; i++) { + const hasPass = await bcrypt.compare( + lstPass[i].trim(), + db_credentials.db_conf.DB_PASS + ) + + if (hasPass) { + password = lstPass[i].trim() + break + } + } + if (password) { db_credentials.db_conf.DB_PASS = password } else { diff --git a/TEST_SERVER1/api/helpers/PassHash.js b/TEST_SERVER1/api/helpers/PassHash.js index 7b15e55..81d1be1 100644 --- a/TEST_SERVER1/api/helpers/PassHash.js +++ b/TEST_SERVER1/api/helpers/PassHash.js @@ -1,20 +1,20 @@ const bcrypt = require('bcrypt') -const pass = async () => { - // create a password - const salt = await bcrypt.genSalt(12) - const passwordHash = await bcrypt.hash('strongpassword', salt) - console.log(passwordHash) -} -pass() - -// const passDec = async () => { -// const _pass = await bcrypt.compare( -// 'strongpassword', -// '$2b$12$R/bpS7b9FzdXlHAijmP.3.gJqgeUjwQVSuK6q.G0PZbb0wowCnrN.' -// ) -// console.log('_pass: ', _pass) +// const pass = async () => { +// // create a password +// const salt = await bcrypt.genSalt(12) +// const passwordHash = await bcrypt.hash('7901228899', salt) +// console.log(passwordHash) // } -// passDec() +// pass() + +const passDec = async () => { + const _pass = await bcrypt.compare( + 'strongpassword', + '$2b$12$PZ8N1jU77nnNUCCGyKTMNOi2QI7X/SgPsISVQfr.cQ/jgdx5Z7AqC' + ) + console.log('_pass: ', _pass) +} +passDec() console.log('process.cwd(): ', process.cwd()) From c8ea53a4bcf299da25a638c0641f22a879e6acee Mon Sep 17 00:00:00 2001 From: adriano Date: Tue, 8 Aug 2023 12:09:03 -0300 Subject: [PATCH 3/6] =?UTF-8?q?finaliza=C3=A7=C3=A3o=20do=20recurso=20de?= =?UTF-8?q?=20encerramento=20de=20ticket=20automatico=20e=20expira=C3=A7?= =?UTF-8?q?=C3=A3o=20de=20ticket?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/controllers/SettingController.ts | 33 +- backend/src/database/index.ts | 4 +- .../20230807152412-setting-tickets.ts | 46 + .../20230807154146-add-setting-tickets.ts | 34 + backend/src/helpers/AutoCloseTickets.ts | 84 ++ backend/src/models/SettingTicket.ts | 40 + backend/src/routes/settingRoutes.ts | 10 +- backend/src/server.ts | 1 + .../SettingServices/UpdateSettingTicket.ts | 35 + .../TicketServices/ListTicketTimeLife.ts | 47 + .../TicketServices/UpdateTicketService.ts | 2 +- .../WbotServices/wbotMessageListener.ts | 1044 +++++++++-------- frontend/package.json | 1 + frontend/src/components/ConfigModal/index.js | 304 +++++ frontend/src/hooks/useAuth.js/index.js | 2 +- frontend/src/pages/Connections/index.js | 54 +- frontend/src/pages/Queues/index.js | 2 +- frontend/src/pages/Settings/index.js | 2 +- 18 files changed, 1257 insertions(+), 488 deletions(-) create mode 100644 backend/src/database/migrations/20230807152412-setting-tickets.ts create mode 100644 backend/src/database/seeds/20230807154146-add-setting-tickets.ts create mode 100644 backend/src/helpers/AutoCloseTickets.ts create mode 100644 backend/src/models/SettingTicket.ts create mode 100644 backend/src/services/SettingServices/UpdateSettingTicket.ts create mode 100644 backend/src/services/TicketServices/ListTicketTimeLife.ts create mode 100644 frontend/src/components/ConfigModal/index.js diff --git a/backend/src/controllers/SettingController.ts b/backend/src/controllers/SettingController.ts index 7144a89..c8cb940 100644 --- a/backend/src/controllers/SettingController.ts +++ b/backend/src/controllers/SettingController.ts @@ -5,6 +5,8 @@ import AppError from "../errors/AppError"; import UpdateSettingService from "../services/SettingServices/UpdateSettingService"; import ListSettingsService from "../services/SettingServices/ListSettingsService"; +import updateSettingTicket from "../services/SettingServices/UpdateSettingTicket"; +import SettingTicket from "../models/SettingTicket"; export const index = async (req: Request, res: Response): Promise => { // if (req.user.profile !== "master") { @@ -12,8 +14,37 @@ export const index = async (req: Request, res: Response): Promise => { // } const settings = await ListSettingsService(); + const outBusinessHours = await SettingTicket.findOne({ + where: { key: "outBusinessHours" } + }); + const ticketExpiration = await SettingTicket.findOne({ + where: { key: "ticketExpiration" } + }); - return res.status(200).json(settings); + return res.status(200).json({ settings, outBusinessHours, ticketExpiration }); +}; + +export const updateTicketSettings = async ( + req: Request, + res: Response +): Promise => { + const { outBusinessHours, ticketExpiration } = req.body; + + if (outBusinessHours && Object.keys(outBusinessHours).length > 0) { + await updateSettingTicket({ + ...outBusinessHours, + key: "outBusinessHours" + }); + } + + if (ticketExpiration && Object.keys(ticketExpiration).length > 0) { + await updateSettingTicket({ + ...ticketExpiration, + key: "ticketExpiration" + }); + } + + return res.status(200).json({ outBusinessHours, ticketExpiration }); }; export const update = async ( diff --git a/backend/src/database/index.ts b/backend/src/database/index.ts index 9749831..f5bf45d 100644 --- a/backend/src/database/index.ts +++ b/backend/src/database/index.ts @@ -14,6 +14,7 @@ import QuickAnswer from "../models/QuickAnswer"; import SchedulingNotify from "../models/SchedulingNotify"; import StatusChatEnd from "../models/StatusChatEnd"; import UserOnlineTime from "../models/UserOnlineTime"; +import SettingTicket from "../models/SettingTicket"; // eslint-disable-next-line const dbConfig = require("../config/database"); // import dbConfig from "../config/database"; @@ -35,7 +36,8 @@ const models = [ SchedulingNotify, StatusChatEnd, - UserOnlineTime, + UserOnlineTime, + SettingTicket ]; sequelize.addModels(models); diff --git a/backend/src/database/migrations/20230807152412-setting-tickets.ts b/backend/src/database/migrations/20230807152412-setting-tickets.ts new file mode 100644 index 0000000..b2581c8 --- /dev/null +++ b/backend/src/database/migrations/20230807152412-setting-tickets.ts @@ -0,0 +1,46 @@ +import { QueryInterface, DataTypes } from "sequelize" + +module.exports = { + up: (queryInterface: QueryInterface) => { + return queryInterface.createTable("SettingTickets", { + id: { + type: DataTypes.INTEGER, + autoIncrement: true, + primaryKey: true, + allowNull: false + }, + message: { + type: DataTypes.STRING, + allowNull: true + }, + startTime: { + type: DataTypes.DATE, + allowNull: true + }, + endTime: { + type: DataTypes.DATE, + allowNull: true + }, + value: { + type: DataTypes.STRING, + allowNull: false + }, + key: { + type: DataTypes.STRING, + allowNull: false + }, + createdAt: { + type: DataTypes.DATE, + allowNull: false + }, + updatedAt: { + type: DataTypes.DATE, + allowNull: false + } + }); + }, + + down: (queryInterface: QueryInterface) => { + return queryInterface.dropTable("SettingTickets"); + } +} diff --git a/backend/src/database/seeds/20230807154146-add-setting-tickets.ts b/backend/src/database/seeds/20230807154146-add-setting-tickets.ts new file mode 100644 index 0000000..9d40d31 --- /dev/null +++ b/backend/src/database/seeds/20230807154146-add-setting-tickets.ts @@ -0,0 +1,34 @@ +import { QueryInterface } from "sequelize"; + +module.exports = { + up: (queryInterface: QueryInterface) => { + return queryInterface.bulkInsert( + "SettingTickets", + [ + { + message: "", + startTime: new Date(), + endTime: new Date(), + value: "disabled", + key: "outBusinessHours", + createdAt: new Date(), + updatedAt: new Date() + }, + { + message: "", + startTime: new Date(), + endTime: new Date(), + value: "disabled", + key: "ticketExpiration", + createdAt: new Date(), + updatedAt: new Date() + } + ], + {} + ); + }, + + down: (queryInterface: QueryInterface) => { + return queryInterface.bulkDelete("SettingTickets", {}); + } +}; diff --git a/backend/src/helpers/AutoCloseTickets.ts b/backend/src/helpers/AutoCloseTickets.ts new file mode 100644 index 0000000..2948035 --- /dev/null +++ b/backend/src/helpers/AutoCloseTickets.ts @@ -0,0 +1,84 @@ +import SettingTicket from "../models/SettingTicket"; +import ListTicketTimeLife from "../services/TicketServices/ListTicketTimeLife"; +import UpdateTicketService from "../services/TicketServices/UpdateTicketService"; +import BotIsOnQueue from "./BotIsOnQueue"; + +import { + format as _format, + isWithinInterval, + parse, + subMinutes +} from "date-fns"; + +import ptBR from "date-fns/locale/pt-BR"; +import { splitDateTime } from "./SplitDateTime"; + +const fsPromises = require("fs/promises"); +const fs = require("fs"); + +let timer: any; + +const AutoCloseTickets = async () => { + try { + // const botInfo = await BotIsOnQueue('botqueue') + + // if (!botInfo.userIdBot) return + + const ticketExpiration = await SettingTicket.findOne({ + where: { key: "ticketExpiration" } + }); + + if (ticketExpiration && ticketExpiration.value == "enabled") { + const startTime = splitDateTime( + new Date( + _format(new Date(ticketExpiration.startTime), "yyyy-MM-dd HH:mm:ss", { + locale: ptBR + }) + ) + ); + + const seconds = timeStringToSeconds(startTime.fullTime); + + console.log("Ticket seconds: ", seconds); + + let tickets: any = await ListTicketTimeLife({ + timeseconds: seconds, + status: "open" + }); + + console.log("tickets: ", tickets); + + for (let i = 0; i < tickets.length; i++) { + + await UpdateTicketService({ + ticketData: { status: "closed", statusChatEnd: "FINALIZADO" }, + ticketId: tickets[i].ticket_id, + msg: ticketExpiration.message + }); + } + } + } catch (error) { + console.log("There was an error on try close the bot tickets: ", error); + } +}; + +function timeStringToSeconds(timeString: any) { + const [hours, minutes, seconds] = timeString.split(":").map(Number); + return hours * 3600 + minutes * 60 + seconds; +} + +const schedule = async () => { + try { + clearInterval(timer); + + await AutoCloseTickets(); + } catch (error) { + console.log("error on schedule: ", error); + } finally { + timer = setInterval(schedule, 60000); + } +}; + +timer = setInterval(schedule, 60000); + +export default schedule; diff --git a/backend/src/models/SettingTicket.ts b/backend/src/models/SettingTicket.ts new file mode 100644 index 0000000..10ef6c2 --- /dev/null +++ b/backend/src/models/SettingTicket.ts @@ -0,0 +1,40 @@ +import { + Table, + Column, + CreatedAt, + UpdatedAt, + Model, + PrimaryKey, + AutoIncrement +} from "sequelize-typescript"; + +@Table +class SettingTicket extends Model { + @PrimaryKey + @AutoIncrement + @Column + id: number; + + @Column + message: string; + + @Column + startTime: Date; + + @Column + endTime: Date; + + @Column + value: string; + + @Column + key: string; + + @CreatedAt + createdAt: Date; + + @UpdatedAt + updatedAt: Date; +} + +export default SettingTicket; diff --git a/backend/src/routes/settingRoutes.ts b/backend/src/routes/settingRoutes.ts index 7047a63..dc361fb 100644 --- a/backend/src/routes/settingRoutes.ts +++ b/backend/src/routes/settingRoutes.ts @@ -3,13 +3,21 @@ import isAuth from "../middleware/isAuth"; import * as SettingController from "../controllers/SettingController"; -const settingRoutes = Router(); +const settingRoutes = Router(); settingRoutes.get("/settings", SettingController.index); // routes.get("/settings/:settingKey", isAuth, SettingsController.show); +settingRoutes.put( + "/settings/ticket", + isAuth, + SettingController.updateTicketSettings +); + + // change setting key to key in future settingRoutes.put("/settings/:settingKey", isAuth, SettingController.update); + export default settingRoutes; diff --git a/backend/src/server.ts b/backend/src/server.ts index 2ab92c0..3e7b7ac 100644 --- a/backend/src/server.ts +++ b/backend/src/server.ts @@ -10,6 +10,7 @@ import { cacheSize, flushCache, loadTicketsCache } from "./helpers/TicketCache"; import { loadContactsCache } from "./helpers/ContactsCache"; import { loadSchedulesCache } from "./helpers/SchedulingNotifyCache"; import { delRestoreControllFile } from "./helpers/RestoreControll"; +import "./helpers/AutoCloseTickets"; import "./helpers/SchedulingNotifySendMessage" import axios from "axios"; diff --git a/backend/src/services/SettingServices/UpdateSettingTicket.ts b/backend/src/services/SettingServices/UpdateSettingTicket.ts new file mode 100644 index 0000000..5319c10 --- /dev/null +++ b/backend/src/services/SettingServices/UpdateSettingTicket.ts @@ -0,0 +1,35 @@ +import AppError from "../../errors/AppError"; +import SettingTicket from "../../models/SettingTicket"; + +interface Request { + key: string; + startTime: string; + endTime: string; + value: string; + message: string; +} + +const updateSettingTicket = async ({ + key, + startTime, + endTime, + value, + message +}: Request): Promise => { + try { + const businessHours = await SettingTicket.findOne({ where: { key } }); + + if (!businessHours) { + throw new AppError("ERR_NO_SETTING_FOUND", 404); + } + + await businessHours.update({ startTime, endTime, message, value }); + + return businessHours; + } catch (error: any) { + console.error("===> Error on UpdateSettingService.ts file: \n", error); + throw new AppError(error.message); + } +}; + +export default updateSettingTicket; diff --git a/backend/src/services/TicketServices/ListTicketTimeLife.ts b/backend/src/services/TicketServices/ListTicketTimeLife.ts new file mode 100644 index 0000000..bcaa0c8 --- /dev/null +++ b/backend/src/services/TicketServices/ListTicketTimeLife.ts @@ -0,0 +1,47 @@ + +import { Sequelize, } from "sequelize"; + +const dbConfig = require("../../config/database"); +const sequelize = new Sequelize(dbConfig); +const { QueryTypes } = require('sequelize'); + +import { splitDateTime } from "../../helpers/SplitDateTime"; +import format from 'date-fns/format'; +import ptBR from 'date-fns/locale/pt-BR'; + + +interface Request { + timeseconds: string | number; + status: string; + userId?: string | number; +} + +const ListTicketTimeLife = async ({timeseconds, status, userId }: Request): Promise => { + + let tickets = [] + + let currentDate = format(new Date(), 'yyyy-MM-dd HH:mm:ss', { locale: ptBR }) + + // console.log('------------------> currentDate: ', currentDate) + + if (userId) { + // CONSULTANDO FILAS PELO ID DO USUARIO + tickets = await sequelize.query(`select user.id as user_id, user.name as user_name, t.id as ticket_id from Tickets as t inner join Users as user on + t.userId = user.id and user.name = 'botqueue' and t.status='${status}' and (TIMESTAMPDIFF(SECOND, t.updatedAt, '${currentDate}')) >= ${timeseconds};`, { type: QueryTypes.SELECT }); + + } else { + + // CONSULTANDO FILAS PELO USUARIO + tickets = await sequelize.query(`select id as ticket_id from Tickets where status='${status}' and + (TIMESTAMPDIFF(SECOND, updatedAt, '${currentDate}')) >= ${timeseconds};`, { type: QueryTypes.SELECT }); + + } + + return tickets; +}; + +export default ListTicketTimeLife; + + + + diff --git a/backend/src/services/TicketServices/UpdateTicketService.ts b/backend/src/services/TicketServices/UpdateTicketService.ts index eed34da..b4181d5 100644 --- a/backend/src/services/TicketServices/UpdateTicketService.ts +++ b/backend/src/services/TicketServices/UpdateTicketService.ts @@ -63,7 +63,7 @@ const UpdateTicketService = async ({ await ticket.reload(); - if (msg.length > 0) { + if (msg?.trim().length > 0) { setTimeout(async () => { diff --git a/backend/src/services/WbotServices/wbotMessageListener.ts b/backend/src/services/WbotServices/wbotMessageListener.ts index 053b625..c85e2ab 100644 --- a/backend/src/services/WbotServices/wbotMessageListener.ts +++ b/backend/src/services/WbotServices/wbotMessageListener.ts @@ -5,12 +5,15 @@ import * as Sentry from "@sentry/node"; import { copyFolder } from "../../helpers/CopyFolder"; import { removeDir } from "../../helpers/DeleteDirectory"; -import path from 'path'; - -import { format } from "date-fns"; -import ptBR from 'date-fns/locale/pt-BR'; - +import path from "path"; +import { + format as _format, + isWithinInterval, + parse, + subMinutes +} from "date-fns"; +import ptBR from "date-fns/locale/pt-BR"; import { Contact as WbotContact, @@ -34,38 +37,42 @@ import UpdateTicketService from "../TicketServices/UpdateTicketService"; import { date } from "faker"; import ShowQueueService from "../QueueService/ShowQueueService"; -import ShowTicketMessage from "../TicketServices/ShowTicketMessage" -import BotIsOnQueue from "../../helpers/BotIsOnQueue" +import ShowTicketMessage from "../TicketServices/ShowTicketMessage"; +import BotIsOnQueue from "../../helpers/BotIsOnQueue"; import Queue from "../../models/Queue"; -import fs from 'fs'; +import fs from "fs"; import { StartWhatsAppSession } from "../../services/WbotServices/StartWhatsAppSession"; -import { removeWbot } from '../../libs/wbot' +import { removeWbot } from "../../libs/wbot"; import { restartWhatsSession } from "../../helpers/RestartWhatsSession"; -// test del -import data_ura from './ura' -import msg_client_transfer from './ura_msg_transfer' +// test del +import data_ura from "./ura"; +import msg_client_transfer from "./ura_msg_transfer"; import final_message from "./ura_final_message"; import SendWhatsAppMessage from "./SendWhatsAppMessage"; import Whatsapp from "../../models/Whatsapp"; import { splitDateTime } from "../../helpers/SplitDateTime"; -// +// -import { updateTicketCacheByTicketId } from '../../helpers/TicketCache' -import { insertMessageContactCache, getLastId } from '../../helpers/LastMessageIdByContactCache' +import { updateTicketCacheByTicketId } from "../../helpers/TicketCache"; +import { + insertMessageContactCache, + getLastId +} from "../../helpers/LastMessageIdByContactCache"; import autoRestore from "../../helpers/AutoRestore"; import { _restore } from "../../helpers/RestoreControll"; import sendWhatsAppMessageSocket from "../../helpers/SendWhatsappMessageSocket"; -import { getWhatsappIds, setWhatsappId } from "../../helpers/WhatsappIdMultiSessionControl"; +import { + getWhatsappIds, + setWhatsappId +} from "../../helpers/WhatsappIdMultiSessionControl"; import AppError from "../../errors/AppError"; import { setMessageAsRead } from "../../helpers/SetMessageAsRead"; +import SettingTicket from "../../models/SettingTicket"; - - -var lst: any[] = getWhatsappIds() - +var lst: any[] = getWhatsappIds(); interface Session extends Client { id?: number; @@ -113,7 +120,7 @@ const verifyMediaMessage = async ( ticket: Ticket, contact: Contact, media: any, - quotedMsg?: any, + quotedMsg?: any ): Promise => { // const quotedMsg = await verifyQuotedMessage(msg); @@ -123,12 +130,15 @@ const verifyMediaMessage = async ( throw new Error("ERR_WAPP_DOWNLOAD_MEDIA"); } - console.log('MEDIA.FILENAME: ', media.fileName, ' | msg.fromMe: ', msg.fromMe) + console.log( + "MEDIA.FILENAME: ", + media.fileName, + " | msg.fromMe: ", + msg.fromMe + ); if (!media.filename) { - - console.log('No file name -----------------------------------------') - + console.log("No file name -----------------------------------------"); const ext = media.mimetype.split("/")[1].split(";")[0]; media.filename = `${new Date().getTime()}.${ext}`; @@ -141,15 +151,13 @@ const verifyMediaMessage = async ( // "base64" // ); - console.log('FROM wbotMessageListener.ts media.filename: ', media.filename) - + console.log("FROM wbotMessageListener.ts media.filename: ", media.filename); await writeFileAsync( join(__dirname, "..", "..", "..", "..", "..", "public", media.filename), media.data, "base64" ); - } catch (err) { Sentry.captureException(err); logger.error(`There was an error: wbotMessageLitener.ts: ${err}`); @@ -178,11 +186,8 @@ const verifyMessage = async ( msg: WbotMessage, ticket: Ticket, contact: Contact, - quotedMsg?: any, + quotedMsg?: any ) => { - - - // const quotedMsg = await verifyQuotedMessage(msg); // const quotedMsg = await verifyQuotedMessage(msg); @@ -199,21 +204,17 @@ const verifyMessage = async ( // quotedMsgId: quotedMsg?.id }; - await ticket.update({ lastMessage: msg.body }); await CreateMessageService({ messageData }); }; - - const verifyQueue = async ( wbot: Session, msg: WbotMessage, ticket: Ticket, contact: Contact ) => { - const { queues, greetingMessage } = await ShowWhatsAppService(wbot.id!); /*if (queues.length === 1) { @@ -224,45 +225,32 @@ const verifyQueue = async ( return; }*/ - - let selectedOption = null; - let choosenQueue = null + let choosenQueue = null; //Habilitar esse caso queira usar o bot - // const botInfo = await BotIsOnQueue('botqueue') - const botInfo = { isOnQueue: false, botQueueId: 0, userIdBot: 0 } + // const botInfo = await BotIsOnQueue('botqueue') + const botInfo = { isOnQueue: false, botQueueId: 0, userIdBot: 0 }; if (botInfo.isOnQueue) { - choosenQueue = await ShowQueueService(botInfo.botQueueId); - - } - - else if (queues.length === 1) { + } else if (queues.length === 1) { selectedOption = 1; choosenQueue = queues[+selectedOption - 1]; - } - else { - + } else { selectedOption = msg.body; //////////////// EXTRAIR APENAS O NÚMERO /////////////////// - selectedOption = selectedOption.replace(/[^1-9]/g, '') + selectedOption = selectedOption.replace(/[^1-9]/g, ""); /////////////////////////////////// choosenQueue = queues[+selectedOption - 1]; } - - if (choosenQueue) { - // Atualizando o status do ticket para mostrar notificação para o atendente da fila escolhida pelo usuário. De queueChoice para pending if (queues.length > 1 && !botInfo.isOnQueue) { - await ticket.update({ status: "pending" }); - } // @@ -271,48 +259,42 @@ const verifyQueue = async ( ticketId: ticket.id }); - - let botOptions = '' + let botOptions = ""; // O bot abre a mensagem na fila para atender o usuario if (botInfo.isOnQueue) { - await UpdateTicketService({ - ticketData: { status: 'open', userId: botInfo.userIdBot }, + ticketData: { status: "open", userId: botInfo.userIdBot }, ticketId: ticket.id }); - data_ura.forEach((s, index) => { botOptions += `*${index + 1}* - ${s.option}\n` }); + data_ura.forEach((s, index) => { + botOptions += `*${index + 1}* - ${s.option}\n`; + }); } // - let body = '' + let body = ""; if (botOptions.length > 0) { body = `\u200e${choosenQueue.greetingMessage}\n\n${botOptions}\n${final_message.msg}`; - } - else { + } else { body = `\u200e${choosenQueue.greetingMessage}`; } - // const sentMessage = await wbot.sendMessage(`${contact.number}@c.us`, body); - // await verifyMessage(sentMessage, ticket, contact); + // const sentMessage = await wbot.sendMessage(`${contact.number}@c.us`, body); + // await verifyMessage(sentMessage, ticket, contact); - sendWhatsAppMessageSocket(ticket, body) - - } - else { - - - //test del transfere o atendimento se entrar na ura infinita + sendWhatsAppMessageSocket(ticket, body); + } else { + //test del transfere o atendimento se entrar na ura infinita let ticket_message = await ShowTicketMessage(ticket.id, false); if (ticket_message.length > 10) { - - await UpdateTicketService({ ticketData: { status: 'pending', queueId: queues[0].id }, ticketId: ticket.id }); - - } - else { - + await UpdateTicketService({ + ticketData: { status: "pending", queueId: queues[0].id }, + ticketId: ticket.id + }); + } else { let options = ""; queues.forEach((queue, index) => { @@ -323,24 +305,17 @@ const verifyQueue = async ( const debouncedSentMessage = debounce( async () => { - - // const sentMessage = await wbot.sendMessage(`${contact.number}@c.us`, body); + // const sentMessage = await wbot.sendMessage(`${contact.number}@c.us`, body); // verifyMessage(sentMessage, ticket, contact); - sendWhatsAppMessageSocket(ticket, body) - - + sendWhatsAppMessageSocket(ticket, body); }, 3000, ticket.id ); debouncedSentMessage(); - } - - - } }; @@ -360,106 +335,123 @@ const isValidMsg = (msg: WbotMessage): boolean => { return false; }; - const queuesOutBot = async (wbot: Session, botId: string | number) => { - const { queues, greetingMessage } = await ShowWhatsAppService(wbot.id!); - const indexQueue = queues.findIndex((q) => q.id == botId) + const indexQueue = queues.findIndex(q => q.id == botId); if (indexQueue != -1) { - queues.splice(indexQueue, 1) + queues.splice(indexQueue, 1); } - return { queues, greetingMessage } - -} - -const botTransferTicket = async (queues: Queue, ticket: Ticket, contact: Contact, wbot: Session) => { + return { queues, greetingMessage }; +}; +const botTransferTicket = async ( + queues: Queue, + ticket: Ticket, + contact: Contact, + wbot: Session +) => { await ticket.update({ userId: null }); - await UpdateTicketService({ ticketData: { status: 'pending', queueId: queues.id }, ticketId: ticket.id }); - -} - - -const botSendMessage = (ticket: Ticket, contact: Contact, wbot: Session, msg: string) => { + await UpdateTicketService({ + ticketData: { status: "pending", queueId: queues.id }, + ticketId: ticket.id + }); +}; +const botSendMessage = (ticket: Ticket, msg: string) => { const debouncedSentMessage = debounce( - async () => { - const sentMessage = await wbot.sendMessage(`${contact.number}@c.us`, `${msg}`); - verifyMessage(sentMessage, ticket, contact); + //OLD + // const sentMessage = await wbot.sendMessage(`${contact.number}@c.us`, `${msg}`); + // verifyMessage(sentMessage, ticket, contact); + + //NEW + await SendWhatsAppMessage({ body: msg, ticket }); }, 3000, ticket.id ); debouncedSentMessage(); +}; -} +// const botSendMessage = ( +// ticket: Ticket, +// contact: Contact, +// wbot: Session, +// msg: string +// ) => { +// const debouncedSentMessage = debounce( +// async () => { +// const sentMessage = await wbot.sendMessage( +// `${contact.number}@c.us`, +// `${msg}` +// ); +// verifyMessage(sentMessage, ticket, contact); +// }, +// 3000, +// ticket.id +// ); + +// debouncedSentMessage(); +// }; const _clear_lst = () => { + console.log("THE lst.length: ", lst.length); - console.log('THE lst.length: ', lst.length) + if (lst.length <= 199) return; - if (lst.length <= 199) return - - const chunk: any = Math.floor((lst.length / 2)) + const chunk: any = Math.floor(lst.length / 2); lst = lst.slice(chunk, chunk + lst.length); - let whatsappIdsSplited = lst.map((e) => `${e.id}`).toString() + let whatsappIdsSplited = lst.map(e => `${e.id}`).toString(); - setWhatsappId(whatsappIdsSplited, true) - -} - -const handleMessage = async ( - msg: any, - wbot: any -): Promise => { + setWhatsappId(whatsappIdsSplited, true); +}; +const handleMessage = async (msg: any, wbot: any): Promise => { if (!msg.fromMe) { + _clear_lst(); - _clear_lst() + let index = lst.findIndex((x: any) => x.id == msg.id.id); - let index = lst.findIndex((x: any) => x.id == msg.id.id) - - console.log('INDEX: ', index) + console.log("INDEX: ", index); if (index == -1) { - // console.log('-----------------> LST: ', lst):q - lst.push({ id: msg.id.id }) + lst.push({ id: msg.id.id }); - setWhatsappId(msg.id.id) + setWhatsappId(msg.id.id); + } else { + console.log("IGNORED ID: ", msg.id.id); - } - else { - console.log('IGNORED ID: ', msg.id.id) - - return + return; } // console.log('LIST OF ID MESSAGE lst: ', lst) - console.log('PASSOU.................................FROM: ', msg.from.split("@")[0], ' | ID: ', msg.id.id) + console.log( + "PASSOU.................................FROM: ", + msg.from.split("@")[0], + " | ID: ", + msg.id.id + ); } - if (!isValidMsg(msg)) { return; } try { - let msgContact: any = wbot.msgContact + let msgContact: any = wbot.msgContact; // let groupContact: Contact | undefined; if (msg.fromMe) { - // console.log('FROM ME: ', msg.fromMe, ' | /\u200e/.test(msg.body[0]: ', (/\u200e/.test(msg.body[0]))) // messages sent automatically by wbot have a special character in front of it @@ -479,14 +471,12 @@ const handleMessage = async ( // console.log('1 --------------> msgContat: ', JSON.parse(JSON.stringify(msgContact))) // console.log(' # msg.type: ', msg.type ) - } else { - // msgContact = await msg.getContact(); // console.log('2 --------------> msgContat: ', JSON.parse(JSON.stringify(msgContact))) - // + // console.log(`\n <<<<<<<<<< RECEIVING MESSAGE: Parcial msg and msgContact info: msgContact.name: ${msgContact.name} @@ -497,15 +487,13 @@ const handleMessage = async ( msg.body: ${msg.body} msg.type: ${msg.type} msg.from: ${msg.from} - msg.to: ${msg.to}\n`) - + msg.to: ${msg.to}\n`); } - // const chat = await msg.getChat(); - const chat = wbot.chat + const chat = wbot.chat; // if(chat.isGroup){ - + // console.log('This message is from a Group and will be ignored!') // return // } @@ -524,8 +512,6 @@ const handleMessage = async ( // groupContact = await verifyContact(msgGroupContact); // } - - const whatsapp = await ShowWhatsAppService(wbot.id!); // const whatsapp = await ShowWhatsAppService(46); @@ -536,47 +522,53 @@ const handleMessage = async ( // console.log('----------> contact: ', JSON.parse(JSON.stringify(contact))) - - - if (unreadMessages === 0 && whatsapp.farewellMessage && whatsapp.farewellMessage === msg.body) return; + if ( + unreadMessages === 0 && + whatsapp.farewellMessage && + whatsapp.farewellMessage === msg.body + ) + return; const ticket = await FindOrCreateTicketService( contact, wbot.id!, - unreadMessages, + unreadMessages // groupContact ); - // + // // await updateTicketCacheByTicketId(ticket.id, {'contact.profilePicUrl': ticket.contact.profilePicUrl}) // Para responder para o cliente pelo mesmo whatsapp que ele enviou a mensagen if (wbot.id != ticket.whatsappId) { - // console.log('PARA RESPONDER PELO MEMOS WHATSAPP wbot.id: ', wbot.id, ' | wbot.status: ', wbot.status) // console.log('WHATSAPP STATUS ticket.whatsappId: ', ticket.whatsappId) try { await ticket.update({ whatsappId: wbot.id }); } catch (error: any) { - console.error('===> Error on wbotMessageListener.ts into handleMessage fuction file: \n', error) + console.error( + "===> Error on wbotMessageListener.ts into handleMessage fuction file: \n", + error + ); throw new AppError(error.message); } - - - } - // + // if (msg.hasMedia) { - await verifyMediaMessage(msg, ticket, contact, wbot.media, wbot.quotedMsg); + await verifyMediaMessage( + msg, + ticket, + contact, + wbot.media, + wbot.quotedMsg + ); } else { - // console.log('>>>>>>> msg.fromMe: ',msg.fromMe ) await verifyMessage(msg, ticket, contact, wbot.quotedMsg); } - if ( !ticket.queue && !chat.isGroup && @@ -587,324 +579,442 @@ const handleMessage = async ( await verifyQueue(wbot, msg, ticket, contact); } + if (msg.fromMe) { + const ticketExpiration = await SettingTicket.findOne({ + where: { key: "ticketExpiration" } + }); + if ( + ticketExpiration && + ticketExpiration.value == "enabled" && + ticketExpiration?.message.trim() == msg.body.trim() + ) { + console.log("*********** TICKET EXPIRATION"); + return; + } + } // O bot interage com o cliente e encaminha o atendimento para fila de atendende quando o usuário escolhe a opção falar com atendente //Habilitar esse caso queira usar o bot // const botInfo = await BotIsOnQueue('botqueue') - const botInfo = { isOnQueue: false, botQueueId: 0, userIdBot: 0 } - - if (botInfo.isOnQueue && !msg.fromMe && ticket.userId == botInfo.userIdBot) { - - - if (msg.body === '0') { - - const queue = await ShowQueueService(ticket.queue.id); - - const greetingMessage = `\u200e${queue.greetingMessage}`; - - let options = ""; - - data_ura.forEach((s, index) => { options += `*${index + 1}* - ${s.option}\n` }); - - botSendMessage(ticket, contact, wbot, `${greetingMessage}\n\n${options}\n${final_message.msg}`) - - } - else { - - - // Pega as ultimas 9 opções numericas digitadas pelo cliente em orde DESC - // Consulta apenas mensagens do usuári - - - let lastOption = '' - - let ura_length = data_ura.length - - let indexAttendant = data_ura.findIndex((u) => u.atendente) - - let opt_user_attendant = '-1' - - if (indexAttendant != -1) { - opt_user_attendant = data_ura[indexAttendant].id - } - - // - - let ticket_message = await ShowTicketMessage(ticket.id, true, ura_length, `^[0-${ura_length}}]$`); - - if (ticket_message.length > 1) { - - lastOption = ticket_message[1].body - - const queuesWhatsGreetingMessage = await queuesOutBot(wbot, botInfo.botQueueId) - - const queues = queuesWhatsGreetingMessage.queues - - if (queues.length > 1) { - - const index_opt_user_attendant = ticket_message.findIndex((q) => q.body == opt_user_attendant) - const index0 = ticket_message.findIndex((q) => q.body == '0') - - if (index_opt_user_attendant != -1) { - - if (index0 > -1 && index0 < index_opt_user_attendant) { - lastOption = '' - } - else { - lastOption = opt_user_attendant - } - } - - } - - } - - - - - // - - // - - // È numero - if (!Number.isNaN(Number(msg.body.trim())) && (+msg.body >= 0 && +msg.body <= data_ura.length)) { - - const indexUra = data_ura.findIndex((ura) => ura.id == msg.body.trim()) - - - - if (indexUra != -1) { - - if (data_ura[indexUra].id != opt_user_attendant && lastOption != opt_user_attendant) { - - - - - - // test del - let next = true - - let indexAux = ticket_message.findIndex((e) => e.body == '0') - - let listMessage = null - - if (indexAux != -1) { - - listMessage = ticket_message.slice(0, indexAux) - } - else { - - listMessage = ticket_message - - } - - let id = '' - let subUra = null - - if (listMessage.length > 1) { - - id = listMessage[listMessage.length - 1].body - subUra = data_ura.filter((e) => e.id == id)[0] - - if (subUra && (!subUra.subOptions || subUra.subOptions.length == 0)) { - - listMessage.pop() - - } - - } - - - if (listMessage.length > 1) { - - id = listMessage[listMessage.length - 1].body - subUra = data_ura.filter((e) => e.id == id)[0] - - if (subUra.subOptions && subUra.subOptions.length > 0) { - - if (!Number.isNaN(Number(msg.body.trim())) && (+msg.body >= 0 && +msg.body <= subUra.subOptions?.length) && subUra.subOptions) { - - - if (subUra.subOptions[+msg.body - 1].responseToClient) { - - botSendMessage(ticket, contact, wbot, `*${subUra.option}*\n\n${subUra.subOptions[+msg.body - 1].responseToClient}`) - - } - else { - botSendMessage(ticket, contact, wbot, `*${subUra.option}*\n\n${subUra.subOptions[+msg.body - 1].subOpt}`) - } - - const queuesWhatsGreetingMessage = await queuesOutBot(wbot, botInfo.botQueueId) - - const queues = queuesWhatsGreetingMessage.queues - - if (queues.length > 0) { - await botTransferTicket(queues[0], ticket, contact, wbot) - } - else { - console.log('NO QUEUE!') - } - - } - else { - - let options = ""; - let subOptions: any[] = subUra.subOptions - - subOptions?.forEach((s, index) => { options += `*${index + 1}* - ${s.subOpt}\n` }); - - botSendMessage(ticket, contact, wbot, `*${subUra.option}*\n\nDigite um número válido disponível no menu de opções de atendimento abaixo: \n${options}\n\n*0* - Voltar ao menu principal`) - - } - - next = false - - } - - } - - - // - if (next) { - if (data_ura[indexUra].subOptions && data_ura[indexUra].subOptions.length > 0) { - - let options = ""; - let option = data_ura[indexUra].option - let subOptions: any[] = data_ura[indexUra].subOptions - let description = data_ura[indexUra].description - - subOptions?.forEach((s, index) => { options += `*${index + 1}* - ${s.subOpt}\n` }); - - const body = `\u200e${description}:\n${options}` - - botSendMessage(ticket, contact, wbot, `*${option}*\n\n${body}\n\n *0* - Voltar ao menu principal`) - - } - else { - - //test del deletar isso (Usar somente na hit) - if (data_ura[indexUra].closeChat) { - - - const { ticket: res } = await UpdateTicketService({ - ticketData: { 'status': 'closed', 'userId': botInfo.userIdBot }, ticketId: ticket.id - }); - - /////////////////////////////// - const whatsapp = await ShowWhatsAppService(ticket.whatsappId); - - const { farewellMessage } = whatsapp; - - if (farewellMessage) { - await SendWhatsAppMessage({ body: farewellMessage, ticket: res }); - } - /////////////////////////////// - - } - else { - botSendMessage(ticket, contact, wbot, `${data_ura[indexUra].description}\n\n *0* - Voltar ao menu principal`) - } - // - - - // botSendMessage(ticket, contact, wbot, `${data_ura[indexUra].description}\n\n *0* - Voltar ao menu principal`) - - } - } - - } - else if (data_ura[indexUra].id == opt_user_attendant) { - - const queuesWhatsGreetingMessage = await queuesOutBot(wbot, botInfo.botQueueId) - - const queues = queuesWhatsGreetingMessage.queues - - // Se fila for maior que 1 exibi as opções fila para atendimento humano - if (queues.length > 1) { - - let options = ""; - - queues.forEach((queue, index) => { - - options += `*${index + 1}* - ${queue.name}\n`; - - }); - - const body = `\u200eSelecione uma das opções de atendimento abaixo:\n${options}`; - - botSendMessage(ticket, contact, wbot, body) - - } // Para situações onde há apenas uma fila com exclusão da fila do bot, já direciona o cliente para essa fila de atendimento humano - else if (queues.length == 1) { - - await botTransferTicket(queues[0], ticket, contact, wbot) - - botSendMessage(ticket, contact, wbot, `${msg_client_transfer.msg}`) - - } - } - else if (lastOption == opt_user_attendant) { - - const queuesWhatsGreetingMessage = await queuesOutBot(wbot, botInfo.botQueueId) - - const queues = queuesWhatsGreetingMessage.queues - - // É numero - if (!Number.isNaN(Number(msg.body.trim())) && (+msg.body >= 0 && +msg.body <= queues.length)) { - - await botTransferTicket(queues[+msg.body - 1], ticket, contact, wbot) - - botSendMessage(ticket, contact, wbot, `${msg_client_transfer.msg}`) - } - else { - - botSendMessage(ticket, contact, wbot, `Digite um número válido disponível no menu de opções de atendimento\n\n*0* - Voltar ao menu principal`) - - } - } - - - } - - } - else { - - // É numero - if (!Number.isNaN(Number(msg.body.trim()))) { - - botSendMessage(ticket, contact, wbot, `Opção numérica inválida!\nDigite um dos números mostrados no menu de opções\n\n*0* - Voltar ao menu principal`) - - } - else { - - botSendMessage(ticket, contact, wbot, `Digite um número válido disponível no menu de opções\n\n*0* - Voltar ao menu principal`) - - } - - } - - } - - - } - - - if (msg && !msg.fromMe && ticket.status == 'pending') { - - await setMessageAsRead(ticket) - + const botInfo = { isOnQueue: false, botQueueId: 0, userIdBot: 0 }; + + // if ( + // botInfo.isOnQueue && + // !msg.fromMe && + // ticket.userId == botInfo.userIdBot + // ) { + // if (msg.body === "0") { + // const queue = await ShowQueueService(ticket.queue.id); + + // const greetingMessage = `\u200e${queue.greetingMessage}`; + + // let options = ""; + + // data_ura.forEach((s, index) => { + // options += `*${index + 1}* - ${s.option}\n`; + // }); + + // botSendMessage( + // ticket, + // contact, + // wbot, + // `${greetingMessage}\n\n${options}\n${final_message.msg}` + // ); + // } else { + // // Pega as ultimas 9 opções numericas digitadas pelo cliente em orde DESC + // // Consulta apenas mensagens do usuári + + // let lastOption = ""; + + // let ura_length = data_ura.length; + + // let indexAttendant = data_ura.findIndex(u => u.atendente); + + // let opt_user_attendant = "-1"; + + // if (indexAttendant != -1) { + // opt_user_attendant = data_ura[indexAttendant].id; + // } + + // // + + // let ticket_message = await ShowTicketMessage( + // ticket.id, + // true, + // ura_length, + // `^[0-${ura_length}}]$` + // ); + + // if (ticket_message.length > 1) { + // lastOption = ticket_message[1].body; + + // const queuesWhatsGreetingMessage = await queuesOutBot( + // wbot, + // botInfo.botQueueId + // ); + + // const queues = queuesWhatsGreetingMessage.queues; + + // if (queues.length > 1) { + // const index_opt_user_attendant = ticket_message.findIndex( + // q => q.body == opt_user_attendant + // ); + // const index0 = ticket_message.findIndex(q => q.body == "0"); + + // if (index_opt_user_attendant != -1) { + // if (index0 > -1 && index0 < index_opt_user_attendant) { + // lastOption = ""; + // } else { + // lastOption = opt_user_attendant; + // } + // } + // } + // } + + // // + + // // + + // // È numero + // if ( + // !Number.isNaN(Number(msg.body.trim())) && + // +msg.body >= 0 && + // +msg.body <= data_ura.length + // ) { + // const indexUra = data_ura.findIndex(ura => ura.id == msg.body.trim()); + + // if (indexUra != -1) { + // if ( + // data_ura[indexUra].id != opt_user_attendant && + // lastOption != opt_user_attendant + // ) { + // // test del + // let next = true; + + // let indexAux = ticket_message.findIndex(e => e.body == "0"); + + // let listMessage = null; + + // if (indexAux != -1) { + // listMessage = ticket_message.slice(0, indexAux); + // } else { + // listMessage = ticket_message; + // } + + // let id = ""; + // let subUra = null; + + // if (listMessage.length > 1) { + // id = listMessage[listMessage.length - 1].body; + // subUra = data_ura.filter(e => e.id == id)[0]; + + // if ( + // subUra && + // (!subUra.subOptions || subUra.subOptions.length == 0) + // ) { + // listMessage.pop(); + // } + // } + + // if (listMessage.length > 1) { + // id = listMessage[listMessage.length - 1].body; + // subUra = data_ura.filter(e => e.id == id)[0]; + + // if (subUra.subOptions && subUra.subOptions.length > 0) { + // if ( + // !Number.isNaN(Number(msg.body.trim())) && + // +msg.body >= 0 && + // +msg.body <= subUra.subOptions?.length && + // subUra.subOptions + // ) { + // if (subUra.subOptions[+msg.body - 1].responseToClient) { + // botSendMessage( + // ticket, + // contact, + // wbot, + // `*${subUra.option}*\n\n${ + // subUra.subOptions[+msg.body - 1].responseToClient + // }` + // ); + // } else { + // botSendMessage( + // ticket, + // contact, + // wbot, + // `*${subUra.option}*\n\n${ + // subUra.subOptions[+msg.body - 1].subOpt + // }` + // ); + // } + + // const queuesWhatsGreetingMessage = await queuesOutBot( + // wbot, + // botInfo.botQueueId + // ); + + // const queues = queuesWhatsGreetingMessage.queues; + + // if (queues.length > 0) { + // await botTransferTicket(queues[0], ticket, contact, wbot); + // } else { + // console.log("NO QUEUE!"); + // } + // } else { + // let options = ""; + // let subOptions: any[] = subUra.subOptions; + + // subOptions?.forEach((s, index) => { + // options += `*${index + 1}* - ${s.subOpt}\n`; + // }); + + // botSendMessage( + // ticket, + // contact, + // wbot, + // `*${subUra.option}*\n\nDigite um número válido disponível no menu de opções de atendimento abaixo: \n${options}\n\n*0* - Voltar ao menu principal` + // ); + // } + + // next = false; + // } + // } + + // // + // if (next) { + // if ( + // data_ura[indexUra].subOptions && + // data_ura[indexUra].subOptions.length > 0 + // ) { + // let options = ""; + // let option = data_ura[indexUra].option; + // let subOptions: any[] = data_ura[indexUra].subOptions; + // let description = data_ura[indexUra].description; + + // subOptions?.forEach((s, index) => { + // options += `*${index + 1}* - ${s.subOpt}\n`; + // }); + + // const body = `\u200e${description}:\n${options}`; + + // botSendMessage( + // ticket, + // contact, + // wbot, + // `*${option}*\n\n${body}\n\n *0* - Voltar ao menu principal` + // ); + // } else { + // //test del deletar isso (Usar somente na hit) + // if (data_ura[indexUra].closeChat) { + // const { ticket: res } = await UpdateTicketService({ + // ticketData: { + // status: "closed", + // userId: botInfo.userIdBot + // }, + // ticketId: ticket.id + // }); + + // /////////////////////////////// + // const whatsapp = await ShowWhatsAppService( + // ticket.whatsappId + // ); + + // const { farewellMessage } = whatsapp; + + // if (farewellMessage) { + // await SendWhatsAppMessage({ + // body: farewellMessage, + // ticket: res + // }); + // } + // /////////////////////////////// + // } else { + // botSendMessage( + // ticket, + // contact, + // wbot, + // `${data_ura[indexUra].description}\n\n *0* - Voltar ao menu principal` + // ); + // } + // // + + // // botSendMessage(ticket, contact, wbot, `${data_ura[indexUra].description}\n\n *0* - Voltar ao menu principal`) + // } + // } + // } else if (data_ura[indexUra].id == opt_user_attendant) { + // const queuesWhatsGreetingMessage = await queuesOutBot( + // wbot, + // botInfo.botQueueId + // ); + + // const queues = queuesWhatsGreetingMessage.queues; + + // // Se fila for maior que 1 exibi as opções fila para atendimento humano + // if (queues.length > 1) { + // let options = ""; + + // queues.forEach((queue, index) => { + // options += `*${index + 1}* - ${queue.name}\n`; + // }); + + // const body = `\u200eSelecione uma das opções de atendimento abaixo:\n${options}`; + + // botSendMessage(ticket, contact, wbot, body); + // } // Para situações onde há apenas uma fila com exclusão da fila do bot, já direciona o cliente para essa fila de atendimento humano + // else if (queues.length == 1) { + // await botTransferTicket(queues[0], ticket, contact, wbot); + + // botSendMessage( + // ticket, + // contact, + // wbot, + // `${msg_client_transfer.msg}` + // ); + // } + // } else if (lastOption == opt_user_attendant) { + // const queuesWhatsGreetingMessage = await queuesOutBot( + // wbot, + // botInfo.botQueueId + // ); + + // const queues = queuesWhatsGreetingMessage.queues; + + // // É numero + // if ( + // !Number.isNaN(Number(msg.body.trim())) && + // +msg.body >= 0 && + // +msg.body <= queues.length + // ) { + // await botTransferTicket( + // queues[+msg.body - 1], + // ticket, + // contact, + // wbot + // ); + + // botSendMessage( + // ticket, + // contact, + // wbot, + // `${msg_client_transfer.msg}` + // ); + // } else { + // botSendMessage( + // ticket, + // contact, + // wbot, + // `Digite um número válido disponível no menu de opções de atendimento\n\n*0* - Voltar ao menu principal` + // ); + // } + // } + // } + // } else { + // // É numero + // if (!Number.isNaN(Number(msg.body.trim()))) { + // botSendMessage( + // ticket, + // contact, + // wbot, + // `Opção numérica inválida!\nDigite um dos números mostrados no menu de opções\n\n*0* - Voltar ao menu principal` + // ); + // } else { + // botSendMessage( + // ticket, + // contact, + // wbot, + // `Digite um número válido disponível no menu de opções\n\n*0* - Voltar ao menu principal` + // ); + // } + // } + // } + // } + + if (msg && !msg.fromMe && ticket.status == "pending") { + await setMessageAsRead(ticket); } + const businessTime: any = await BusinessTime(); + + if ( + msg.fromMe && + businessTime && + !businessTime.isWithinRange && + businessTime.message.trim() == msg.body.trim() + ) { + console.log("BUSINESS TIME OUT"); + return; + } + + if (!businessTime.isWithinRange && businessTime.message.trim().length > 0) { + botSendMessage(ticket, businessTime.message); + } } catch (err) { Sentry.captureException(err); - logger.error(`Error handling whatsapp message: Err: ${err}`); + console.log("Error handling whatsapp message: Err: ", err); + logger.error(`Error handling whatsapp message: Err: ${err}`); + } + + async function BusinessTime() { + const outBusinessHours = await SettingTicket.findOne({ + where: { key: "outBusinessHours" } + }); + + let isWithinRange = false; + + if (outBusinessHours && outBusinessHours.value == "enabled") { + const ticketDateTimeUpdate = splitDateTime( + new Date( + _format(new Date(), "yyyy-MM-dd HH:mm:ss", { + locale: ptBR + }) + ) + ); + + const startTime = splitDateTime( + new Date( + _format(new Date(outBusinessHours.startTime), "yyyy-MM-dd HH:mm:ss", { + locale: ptBR + }) + ) + ); + + const endTime = splitDateTime( + new Date( + _format(new Date(outBusinessHours.endTime), "yyyy-MM-dd HH:mm:ss", { + locale: ptBR + }) + ) + ); + + const format = "HH:mm:ss"; + const parsedStartTime = parse( + ticketDateTimeUpdate.fullTime, + format, + new Date() + ); + const parsedEndTime = parse(startTime.fullTime, format, new Date()); + const parsedTimeToCheck = parse(endTime.fullTime, format, new Date()); + + const timeInterval = { start: parsedStartTime, end: parsedEndTime }; + + // If the time range spans across different days, handle the date part + if (parsedEndTime < parsedStartTime) { + const nextDay = new Date(parsedStartTime); + nextDay.setDate(nextDay.getDate() + 1); + timeInterval.end = nextDay; + } + + isWithinRange = isWithinInterval(parsedTimeToCheck, timeInterval); + + console.log("Is the time within the range?", isWithinRange); + + return { isWithinRange, message: outBusinessHours.message }; + } } }; const handleMsgAck = async (msg_id: any, ack: any) => { - await new Promise(r => setTimeout(r, 4000)); const io = getIO(); @@ -921,16 +1031,17 @@ const handleMsgAck = async (msg_id: any, ack: any) => { ] }); if (!messageToUpdate) { - console.log(`Not found the MESSAGE ID ${msg_id}to change the ACK into the Message table`) + console.log( + `Not found the MESSAGE ID ${msg_id}to change the ACK into the Message table` + ); return; } await messageToUpdate.update({ ack }); - + io.to(messageToUpdate.ticketId.toString()).emit("appMessage", { action: "update", message: messageToUpdate }); - } catch (err) { Sentry.captureException(err); logger.error(`Error handling message ack. Err: ${err}`); @@ -938,7 +1049,6 @@ const handleMsgAck = async (msg_id: any, ack: any) => { }; const wbotMessageListener = (wbot: Session): void => { - wbot.on("message_create", async msg => { handleMessage(msg, wbot); }); diff --git a/frontend/package.json b/frontend/package.json index a077e60..50b81dc 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -20,6 +20,7 @@ "dotenv": "^16.0.1", "emoji-mart": "^3.0.1", "formik": "^2.2.0", + "formik-material-ui-pickers": "^1.0.0-alpha.1", "i18next": "^19.8.2", "i18next-browser-languagedetector": "^6.0.1", "js-file-download": "^0.4.12", diff --git a/frontend/src/components/ConfigModal/index.js b/frontend/src/components/ConfigModal/index.js new file mode 100644 index 0000000..7c08118 --- /dev/null +++ b/frontend/src/components/ConfigModal/index.js @@ -0,0 +1,304 @@ +import React, { useState, useEffect, } from 'react' +// import * as Yup from 'yup' +import { Formik, Form, Field, } from 'formik' +import { toast } from 'react-toastify' + +import { makeStyles } from '@material-ui/core/styles' +import { green } from '@material-ui/core/colors' + +import { TimePicker } from 'formik-material-ui-pickers' + +import DateFnsUtils from '@date-io/date-fns' + +import ptBrLocale from "date-fns/locale/pt-BR" + + +import { + MuiPickersUtilsProvider, +} from '@material-ui/pickers' + +import { + Dialog, + DialogContent, + DialogTitle, + Button, + DialogActions, + CircularProgress, + TextField, + Switch, + FormControlLabel, +} from '@material-ui/core' + +import api from '../../services/api' +import { i18n } from '../../translate/i18n' +import toastError from '../../errors/toastError' + +const useStyles = makeStyles((theme) => ({ + root: { + display: 'flex', + flexWrap: 'wrap', + }, + + multFieldLine: { + display: 'flex', + '& > *:not(:last-child)': { + marginRight: theme.spacing(1), + }, + }, + + btnWrapper: { + position: 'relative', + }, + + buttonProgress: { + color: green[500], + position: 'absolute', + top: '50%', + left: '50%', + marginTop: -12, + marginLeft: -12, + }, +})) + +// const SessionSchema = Yup.object().shape({ +// name: Yup.string() +// .min(2, 'Too Short!') +// .max(100, 'Too Long!') +// .required('Required'), +// }) + +const ConfigModal = ({ open, onClose, change }) => { + const classes = useStyles() + const initialState = { + startTimeBus: new Date(), + endTimeBus: new Date(), + messageBus: '', + businessTimeEnalbe: false, + ticketTimeExpiration: new Date(), + ticketExpirationMsg: '', + ticketExpirationEnable: false, + } + + const [config, setConfig] = useState(initialState) + + useEffect(() => { + const fetchSession = async () => { + + try { + const { data } = await api.get('/settings') + + setConfig({ + startTimeBus: data.outBusinessHours.startTime, + endTimeBus: data.outBusinessHours.endTime, + messageBus: data.outBusinessHours.message, + businessTimeEnalbe: data.outBusinessHours.value === 'enabled' ? true : false, + ticketTimeExpiration: data.ticketExpiration.startTime, + ticketExpirationMsg: data.ticketExpiration.message, + ticketExpirationEnable: data.ticketExpiration.value === 'enabled' ? true : false + }) + + } catch (err) { + toastError(err) + } + } + fetchSession() + }, [change]) + + const handleSaveConfig = async (values) => { + + values = { + outBusinessHours: { + startTime: values.startTimeBus, + endTime: values.endTimeBus, + message: values.messageBus, + value: values.businessTimeEnalbe ? 'enabled' : 'disabled' + }, + ticketExpiration: { + startTime: values.ticketTimeExpiration, + message: values.ticketExpirationMsg, + value: values.ticketExpirationEnable ? 'enabled' : 'disabled' + } + } + + + try { + + await api.put(`/settings/ticket`, values) + + toast.success('Atualização realizada com sucesso!') + handleClose() + + } catch (err) { + toastError(err) + } + } + + const handleClose = () => { + onClose() + // setConfig(initialState) + } + + return ( +
+ + + Configurações + + + + { + + setTimeout(() => { + handleSaveConfig(values) + actions.setSubmitting(false) + }, 100) + }} + > + {({ values, touched, errors, isSubmitting }) => ( + +
+ + + +
+ + {' '} + + + + } + label={'Ativar/Desativar'} /> +
+ +
+ +
+ +
+
+ + + + } + label={'Ativar/Desativar'} + /> +
+
+ +
+ +
+ + + + +
+
+ )} +
+
+
+ ) +} + +export default React.memo(ConfigModal) diff --git a/frontend/src/hooks/useAuth.js/index.js b/frontend/src/hooks/useAuth.js/index.js index 70ffe21..6e26b05 100644 --- a/frontend/src/hooks/useAuth.js/index.js +++ b/frontend/src/hooks/useAuth.js/index.js @@ -76,7 +76,7 @@ const useAuth = () => { const fetchSession = async () => { try { const { data } = await api.get('/settings') - setSetting(data) + setSetting(data.settings) } catch (err) { toastError(err) } diff --git a/frontend/src/pages/Connections/index.js b/frontend/src/pages/Connections/index.js index a8c5fe4..3e188ee 100644 --- a/frontend/src/pages/Connections/index.js +++ b/frontend/src/pages/Connections/index.js @@ -6,6 +6,9 @@ import openSocket from 'socket.io-client' import { makeStyles } from '@material-ui/core/styles' import { green } from '@material-ui/core/colors' + +import Settings from "@material-ui/icons/Settings"; + import { Button, TableBody, @@ -47,6 +50,7 @@ import toastError from '../../errors/toastError' //-------- import { AuthContext } from '../../context/Auth/AuthContext' import { Can } from '../../components/Can' +import ConfigModal from '../../components/ConfigModal' const useStyles = makeStyles((theme) => ({ mainPaper: { @@ -107,6 +111,7 @@ const Connections = () => { const { whatsApps, loading } = useContext(WhatsAppsContext) const [whatsAppModalOpen, setWhatsAppModalOpen] = useState(false) + const [configModalOpen, setConfigModalOpen] = useState(false) const [qrModalOpen, setQrModalOpen] = useState(false) const [selectedWhatsApp, setSelectedWhatsApp] = useState(null) const [confirmModalOpen, setConfirmModalOpen] = useState(false) @@ -134,7 +139,7 @@ const Connections = () => { const fetchSession = async () => { try { const { data } = await api.get('/settings') - setSettings(data) + setSettings(data.settings) } catch (err) { toastError(err) } @@ -205,6 +210,13 @@ const Connections = () => { setWhatsAppModalOpen(true) } + const handleOpenConfigModal = () => { + setConfigModalOpen(true) + } + + const handleCloseConfigModal = () => { + setConfigModalOpen(false) + } const handleCloseWhatsAppModal = useCallback(() => { setWhatsAppModalOpen(false) setSelectedWhatsApp(null) @@ -307,17 +319,17 @@ const Connections = () => { {(whatsApp.status === 'CONNECTED' || whatsApp.status === 'PAIRING' || whatsApp.status === 'TIMEOUT') && ( - - )} + + )} {whatsApp.status === 'OPENING' && ( { settings.length > 0 && getSettingValue('editURA') && getSettingValue('editURA') === - 'enabled') | - (user.profile === 'master') ? ( + 'enabled') | + (user.profile === 'master') ? ( diff --git a/frontend/src/pages/Queues/index.js b/frontend/src/pages/Queues/index.js index 99b6eab..85144e2 100644 --- a/frontend/src/pages/Queues/index.js +++ b/frontend/src/pages/Queues/index.js @@ -121,7 +121,7 @@ const Queues = () => { const fetchSession = async () => { try { const { data } = await api.get('/settings') - setSettings(data) + setSettings(data.settings) } catch (err) { toastError(err) } diff --git a/frontend/src/pages/Settings/index.js b/frontend/src/pages/Settings/index.js index ab79873..2dc8891 100644 --- a/frontend/src/pages/Settings/index.js +++ b/frontend/src/pages/Settings/index.js @@ -52,7 +52,7 @@ const Settings = () => { const fetchSession = async () => { try { const { data } = await api.get('/settings') - setSettings(data) + setSettings(data.settings) } catch (err) { toastError(err) } From f778a928c815e499ccb2d32e9fc52b4370c415f6 Mon Sep 17 00:00:00 2001 From: adriano Date: Tue, 8 Aug 2023 12:31:25 -0300 Subject: [PATCH 4/6] =?UTF-8?q?Corre=C3=A7=C3=A3o=20para=20evitar=20que=20?= =?UTF-8?q?o=20ticket=20expiration=20gere=20um=20novo=20ticket?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WbotServices/wbotMessageListener.ts | 28 +++++++++---------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/backend/src/services/WbotServices/wbotMessageListener.ts b/backend/src/services/WbotServices/wbotMessageListener.ts index c85e2ab..b6b0a8e 100644 --- a/backend/src/services/WbotServices/wbotMessageListener.ts +++ b/backend/src/services/WbotServices/wbotMessageListener.ts @@ -452,6 +452,19 @@ const handleMessage = async (msg: any, wbot: any): Promise => { // let groupContact: Contact | undefined; if (msg.fromMe) { + const ticketExpiration = await SettingTicket.findOne({ + where: { key: "ticketExpiration" } + }); + + if ( + ticketExpiration && + ticketExpiration.value == "enabled" && + ticketExpiration?.message.trim() == msg.body.trim() + ) { + console.log("*********** TICKET EXPIRATION"); + return; + } + // console.log('FROM ME: ', msg.fromMe, ' | /\u200e/.test(msg.body[0]: ', (/\u200e/.test(msg.body[0]))) // messages sent automatically by wbot have a special character in front of it @@ -579,21 +592,6 @@ const handleMessage = async (msg: any, wbot: any): Promise => { await verifyQueue(wbot, msg, ticket, contact); } - if (msg.fromMe) { - const ticketExpiration = await SettingTicket.findOne({ - where: { key: "ticketExpiration" } - }); - - if ( - ticketExpiration && - ticketExpiration.value == "enabled" && - ticketExpiration?.message.trim() == msg.body.trim() - ) { - console.log("*********** TICKET EXPIRATION"); - return; - } - } - // O bot interage com o cliente e encaminha o atendimento para fila de atendende quando o usuário escolhe a opção falar com atendente //Habilitar esse caso queira usar o bot From 4ee662f4ff1004a1a841b45ec21f08ff23c58e0d Mon Sep 17 00:00:00 2001 From: adriano Date: Tue, 8 Aug 2023 14:01:02 -0300 Subject: [PATCH 5/6] =?UTF-8?q?remo=C3=A7=C3=A3o=20de=20codigo=20desativad?= =?UTF-8?q?o=20de=20bot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../WbotServices/wbotMessageListener.ts | 333 +----------------- 1 file changed, 2 insertions(+), 331 deletions(-) diff --git a/backend/src/services/WbotServices/wbotMessageListener.ts b/backend/src/services/WbotServices/wbotMessageListener.ts index b6b0a8e..e6bd9de 100644 --- a/backend/src/services/WbotServices/wbotMessageListener.ts +++ b/backend/src/services/WbotServices/wbotMessageListener.ts @@ -596,337 +596,8 @@ const handleMessage = async (msg: any, wbot: any): Promise => { //Habilitar esse caso queira usar o bot // const botInfo = await BotIsOnQueue('botqueue') - const botInfo = { isOnQueue: false, botQueueId: 0, userIdBot: 0 }; - - // if ( - // botInfo.isOnQueue && - // !msg.fromMe && - // ticket.userId == botInfo.userIdBot - // ) { - // if (msg.body === "0") { - // const queue = await ShowQueueService(ticket.queue.id); - - // const greetingMessage = `\u200e${queue.greetingMessage}`; - - // let options = ""; - - // data_ura.forEach((s, index) => { - // options += `*${index + 1}* - ${s.option}\n`; - // }); - - // botSendMessage( - // ticket, - // contact, - // wbot, - // `${greetingMessage}\n\n${options}\n${final_message.msg}` - // ); - // } else { - // // Pega as ultimas 9 opções numericas digitadas pelo cliente em orde DESC - // // Consulta apenas mensagens do usuári - - // let lastOption = ""; - - // let ura_length = data_ura.length; - - // let indexAttendant = data_ura.findIndex(u => u.atendente); - - // let opt_user_attendant = "-1"; - - // if (indexAttendant != -1) { - // opt_user_attendant = data_ura[indexAttendant].id; - // } - - // // - - // let ticket_message = await ShowTicketMessage( - // ticket.id, - // true, - // ura_length, - // `^[0-${ura_length}}]$` - // ); - - // if (ticket_message.length > 1) { - // lastOption = ticket_message[1].body; - - // const queuesWhatsGreetingMessage = await queuesOutBot( - // wbot, - // botInfo.botQueueId - // ); - - // const queues = queuesWhatsGreetingMessage.queues; - - // if (queues.length > 1) { - // const index_opt_user_attendant = ticket_message.findIndex( - // q => q.body == opt_user_attendant - // ); - // const index0 = ticket_message.findIndex(q => q.body == "0"); - - // if (index_opt_user_attendant != -1) { - // if (index0 > -1 && index0 < index_opt_user_attendant) { - // lastOption = ""; - // } else { - // lastOption = opt_user_attendant; - // } - // } - // } - // } - - // // - - // // - - // // È numero - // if ( - // !Number.isNaN(Number(msg.body.trim())) && - // +msg.body >= 0 && - // +msg.body <= data_ura.length - // ) { - // const indexUra = data_ura.findIndex(ura => ura.id == msg.body.trim()); - - // if (indexUra != -1) { - // if ( - // data_ura[indexUra].id != opt_user_attendant && - // lastOption != opt_user_attendant - // ) { - // // test del - // let next = true; - - // let indexAux = ticket_message.findIndex(e => e.body == "0"); - - // let listMessage = null; - - // if (indexAux != -1) { - // listMessage = ticket_message.slice(0, indexAux); - // } else { - // listMessage = ticket_message; - // } - - // let id = ""; - // let subUra = null; - - // if (listMessage.length > 1) { - // id = listMessage[listMessage.length - 1].body; - // subUra = data_ura.filter(e => e.id == id)[0]; - - // if ( - // subUra && - // (!subUra.subOptions || subUra.subOptions.length == 0) - // ) { - // listMessage.pop(); - // } - // } - - // if (listMessage.length > 1) { - // id = listMessage[listMessage.length - 1].body; - // subUra = data_ura.filter(e => e.id == id)[0]; - - // if (subUra.subOptions && subUra.subOptions.length > 0) { - // if ( - // !Number.isNaN(Number(msg.body.trim())) && - // +msg.body >= 0 && - // +msg.body <= subUra.subOptions?.length && - // subUra.subOptions - // ) { - // if (subUra.subOptions[+msg.body - 1].responseToClient) { - // botSendMessage( - // ticket, - // contact, - // wbot, - // `*${subUra.option}*\n\n${ - // subUra.subOptions[+msg.body - 1].responseToClient - // }` - // ); - // } else { - // botSendMessage( - // ticket, - // contact, - // wbot, - // `*${subUra.option}*\n\n${ - // subUra.subOptions[+msg.body - 1].subOpt - // }` - // ); - // } - - // const queuesWhatsGreetingMessage = await queuesOutBot( - // wbot, - // botInfo.botQueueId - // ); - - // const queues = queuesWhatsGreetingMessage.queues; - - // if (queues.length > 0) { - // await botTransferTicket(queues[0], ticket, contact, wbot); - // } else { - // console.log("NO QUEUE!"); - // } - // } else { - // let options = ""; - // let subOptions: any[] = subUra.subOptions; - - // subOptions?.forEach((s, index) => { - // options += `*${index + 1}* - ${s.subOpt}\n`; - // }); - - // botSendMessage( - // ticket, - // contact, - // wbot, - // `*${subUra.option}*\n\nDigite um número válido disponível no menu de opções de atendimento abaixo: \n${options}\n\n*0* - Voltar ao menu principal` - // ); - // } - - // next = false; - // } - // } - - // // - // if (next) { - // if ( - // data_ura[indexUra].subOptions && - // data_ura[indexUra].subOptions.length > 0 - // ) { - // let options = ""; - // let option = data_ura[indexUra].option; - // let subOptions: any[] = data_ura[indexUra].subOptions; - // let description = data_ura[indexUra].description; - - // subOptions?.forEach((s, index) => { - // options += `*${index + 1}* - ${s.subOpt}\n`; - // }); - - // const body = `\u200e${description}:\n${options}`; - - // botSendMessage( - // ticket, - // contact, - // wbot, - // `*${option}*\n\n${body}\n\n *0* - Voltar ao menu principal` - // ); - // } else { - // //test del deletar isso (Usar somente na hit) - // if (data_ura[indexUra].closeChat) { - // const { ticket: res } = await UpdateTicketService({ - // ticketData: { - // status: "closed", - // userId: botInfo.userIdBot - // }, - // ticketId: ticket.id - // }); - - // /////////////////////////////// - // const whatsapp = await ShowWhatsAppService( - // ticket.whatsappId - // ); - - // const { farewellMessage } = whatsapp; - - // if (farewellMessage) { - // await SendWhatsAppMessage({ - // body: farewellMessage, - // ticket: res - // }); - // } - // /////////////////////////////// - // } else { - // botSendMessage( - // ticket, - // contact, - // wbot, - // `${data_ura[indexUra].description}\n\n *0* - Voltar ao menu principal` - // ); - // } - // // - - // // botSendMessage(ticket, contact, wbot, `${data_ura[indexUra].description}\n\n *0* - Voltar ao menu principal`) - // } - // } - // } else if (data_ura[indexUra].id == opt_user_attendant) { - // const queuesWhatsGreetingMessage = await queuesOutBot( - // wbot, - // botInfo.botQueueId - // ); - - // const queues = queuesWhatsGreetingMessage.queues; - - // // Se fila for maior que 1 exibi as opções fila para atendimento humano - // if (queues.length > 1) { - // let options = ""; - - // queues.forEach((queue, index) => { - // options += `*${index + 1}* - ${queue.name}\n`; - // }); - - // const body = `\u200eSelecione uma das opções de atendimento abaixo:\n${options}`; - - // botSendMessage(ticket, contact, wbot, body); - // } // Para situações onde há apenas uma fila com exclusão da fila do bot, já direciona o cliente para essa fila de atendimento humano - // else if (queues.length == 1) { - // await botTransferTicket(queues[0], ticket, contact, wbot); - - // botSendMessage( - // ticket, - // contact, - // wbot, - // `${msg_client_transfer.msg}` - // ); - // } - // } else if (lastOption == opt_user_attendant) { - // const queuesWhatsGreetingMessage = await queuesOutBot( - // wbot, - // botInfo.botQueueId - // ); - - // const queues = queuesWhatsGreetingMessage.queues; - - // // É numero - // if ( - // !Number.isNaN(Number(msg.body.trim())) && - // +msg.body >= 0 && - // +msg.body <= queues.length - // ) { - // await botTransferTicket( - // queues[+msg.body - 1], - // ticket, - // contact, - // wbot - // ); - - // botSendMessage( - // ticket, - // contact, - // wbot, - // `${msg_client_transfer.msg}` - // ); - // } else { - // botSendMessage( - // ticket, - // contact, - // wbot, - // `Digite um número válido disponível no menu de opções de atendimento\n\n*0* - Voltar ao menu principal` - // ); - // } - // } - // } - // } else { - // // É numero - // if (!Number.isNaN(Number(msg.body.trim()))) { - // botSendMessage( - // ticket, - // contact, - // wbot, - // `Opção numérica inválida!\nDigite um dos números mostrados no menu de opções\n\n*0* - Voltar ao menu principal` - // ); - // } else { - // botSendMessage( - // ticket, - // contact, - // wbot, - // `Digite um número válido disponível no menu de opções\n\n*0* - Voltar ao menu principal` - // ); - // } - // } - // } - // } + const botInfo = { isOnQueue: false, botQueueId: 0, userIdBot: 0 }; + if (msg && !msg.fromMe && ticket.status == "pending") { await setMessageAsRead(ticket); From 18db49c88cf3d726f7fa612ce62e06ceff544ab2 Mon Sep 17 00:00:00 2001 From: adriano Date: Tue, 8 Aug 2023 14:02:51 -0300 Subject: [PATCH 6/6] =?UTF-8?q?desativa=C3=A7ao=20de=20codigo=20de=20bot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/src/services/WbotServices/wbotMessageListener.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/src/services/WbotServices/wbotMessageListener.ts b/backend/src/services/WbotServices/wbotMessageListener.ts index e6bd9de..426b119 100644 --- a/backend/src/services/WbotServices/wbotMessageListener.ts +++ b/backend/src/services/WbotServices/wbotMessageListener.ts @@ -596,7 +596,7 @@ const handleMessage = async (msg: any, wbot: any): Promise => { //Habilitar esse caso queira usar o bot // const botInfo = await BotIsOnQueue('botqueue') - const botInfo = { isOnQueue: false, botQueueId: 0, userIdBot: 0 }; + // const botInfo = { isOnQueue: false, botQueueId: 0, userIdBot: 0 }; if (msg && !msg.fromMe && ticket.status == "pending") {