bot-functions 1.3.5 → 1.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +25 -1
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1344,6 +1344,28 @@ function diferenciaHoras(tiempo1, tiempo2) {
1344
1344
  return `${horas.toString().padStart(2, "0")}:${minutos.toString().padStart(2, "0")}`;
1345
1345
  }
1346
1346
 
1347
+ const insertCatspecs = async ({ db, area, cadena, nivel, fecha, val1, val5 }) => {
1348
+ try {
1349
+ const insertCatspecsResponse = await axios.post(process.env.POST_CATSPECS, {
1350
+ db, area, cadena, nivel, fecha, val1, val5
1351
+ });
1352
+ return insertCatspecsResponse.data;
1353
+ } catch (e) {
1354
+ log.error(e.message);
1355
+ throw new Error("No se pudo insertar la información de catspecs");
1356
+ }
1357
+ }
1358
+
1359
+ const uploadImageToS3 = async (filePath, key) => {
1360
+ const fileData = fs.readFileSync(filePath);
1361
+ const regs = await axios.post(process.env.AUTH_PATH, { email: process.env.EMAIL_API });
1362
+ const body = { type: 1, bucketName: process.env.S3_BUCKET, file: fileData.toString('base64'), key };
1363
+ const uploadFileResponse = await axios.post(process.env.S3_UPLOAD_FILE, body,
1364
+ { maxBodyLength: Infinity, headers: { 'Authorization': regs.data.data, 'Content-Type': 'application/json' } }
1365
+ );
1366
+ return uploadFileResponse.data.data;
1367
+ }
1368
+
1347
1369
 
1348
1370
  module.exports = {
1349
1371
  waitNtype,
@@ -1397,5 +1419,7 @@ module.exports = {
1397
1419
  manageEmails,
1398
1420
  insertLogExec,
1399
1421
  sendDataCH,
1400
- processDataDaily
1422
+ processDataDaily,
1423
+ uploadImageToS3,
1424
+ insertCatspecs,
1401
1425
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bot-functions",
3
- "version": "1.3.5",
3
+ "version": "1.5.0",
4
4
  "description": "Bot functions",
5
5
  "main": "index.js",
6
6
  "scripts": {