tango-app-api-trax 3.6.2-bulktask-12 → 3.7.2-multireff-1

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-trax",
3
- "version": "3.6.2-bulktask-12",
3
+ "version": "3.7.2-multireff-1",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -17,7 +17,6 @@
17
17
  "body-parser": "^1.20.3",
18
18
  "dayjs": "^1.11.13",
19
19
  "dotenv": "^16.4.5",
20
- "exceljs": "^4.4.0",
21
20
  "express": "^4.21.1",
22
21
  "express-fileupload": "^1.5.1",
23
22
  "firebase-admin": "^13.0.0",
@@ -27,7 +26,7 @@
27
26
  "mongodb": "^6.8.0",
28
27
  "nodemon": "^3.1.4",
29
28
  "path": "^0.12.7",
30
- "tango-api-schema": "^2.2.198",
29
+ "tango-api-schema": "^2.2.197",
31
30
  "tango-app-api-middleware": "^3.1.77",
32
31
  "url": "^0.11.4",
33
32
  "winston": "^3.13.1",
@@ -8,11 +8,11 @@ import * as processedchecklistconfigService from '../services/processedchecklist
8
8
  import * as processedChecklist from '../services/processedchecklist.services.js';
9
9
  import * as checklistLogs from '../services/checklistlog.service.js';
10
10
  import * as ApproverModel from '../services/approver.service.js';
11
- import ExcelJS from 'exceljs';
11
+
12
12
  import mongoose from 'mongoose';
13
13
  import dayjs from 'dayjs';
14
14
  import { aggregateTeams, findteams } from '../services/teams.service.js';
15
- import { aggregate, findOne } from '../services/user.service.js';
15
+ import { aggregate } from '../services/user.service.js';
16
16
  // import axios from 'axios';
17
17
  import timeZone from 'dayjs/plugin/timezone.js';
18
18
  import customParseFormat from 'dayjs/plugin/customParseFormat.js';
@@ -289,7 +289,7 @@ export async function approveChecklist( req, res ) {
289
289
  toDate = new Date( toDate.getTime() - userTimezoneOffset );
290
290
  toDate.setUTCHours( 23, 59, 59, 59 );
291
291
  let query = { sourceCheckList_id: req.body.sourceCheckList_id, date_iso: { $gte: req.body.fromDate, $lte: toDate }, $or: [ { checklistStatus: 'submit' }, { redoStatus: true } ], approvalEnable: true };
292
- if ( !( req.body.assignedStores && req.body.assignedStores.length > 0 ) ) {
292
+ if ( !( req.body.assignedStores && req.body.assignedStores.length >0 ) ) {
293
293
  req.body.assignedStores = req.body.storeId;
294
294
  }
295
295
  if ( req.body?.storeId?.length ) {
@@ -318,13 +318,13 @@ export async function approveChecklist( req, res ) {
318
318
 
319
319
  let teamsMsg;
320
320
  let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
321
- teamsMsg = 'ClientId: ' + checklistDetails[0].client_id + ', Type: Checklist, Process: started, Action: Approval, ChecklistId: ' + checklistDetails[0].sourceCheckList_id + ', Checklist Name: ' + checklistDetails[0].checkListName + ', UpDatedBy: ' + req.user.email;
321
+ teamsMsg = 'ClientId: '+ checklistDetails[0].client_id + ', Type: Checklist, Process: started, Action: Approval, ChecklistId: '+ checklistDetails[0].sourceCheckList_id + ', Checklist Name: '+ checklistDetails[0].checkListName +', UpDatedBy: '+ req.user.email;
322
322
  if ( teamsAlertUrls && teamsAlertUrls.approvalAlert ) {
323
323
  sendTeamsNotification( teamsAlertUrls.approvalAlert, teamsMsg );
324
324
  }
325
325
 
326
326
  if ( updateResponse.modifiedCount || updateResponse.matchedCount ) {
327
- teamsMsg = 'ClientId: ' + checklistDetails[0].client_id + ', Type: Checklist, Process: Completed, Updated Count: ' + updateResponse.modifiedCount + ' Action: Approval, ChecklistId: ' + checklistDetails[0].sourceCheckList_id + ', Checklist Name: ' + checklistDetails[0].checkListName + ', UpDatedBy: ' + req.user.email;
327
+ teamsMsg = 'ClientId: '+ checklistDetails[0].client_id + ', Type: Checklist, Process: Completed, Updated Count: '+updateResponse.modifiedCount+' Action: Approval, ChecklistId: '+ checklistDetails[0].sourceCheckList_id + ', Checklist Name: '+ checklistDetails[0].checkListName +', UpDatedBy: '+ req.user.email;
328
328
  if ( teamsAlertUrls && teamsAlertUrls.approvalAlert ) {
329
329
  sendTeamsNotification( teamsAlertUrls.approvalAlert, teamsMsg );
330
330
  }
@@ -360,7 +360,7 @@ export async function approveChecklist( req, res ) {
360
360
  let searchResponse = await fetch( url.approveChecklist, requestOptions );
361
361
  // console.log( searchResponse );
362
362
  const filteredStoreIds = req.body.storeId.filter( ( store ) => req.body.assignedStores.includes( store ) );
363
- let logData = {
363
+ let logData= {
364
364
  'client_id': checklistDetails[0].client_id,
365
365
  'createAt': new Date(),
366
366
  'sourceCheckList_id': req.body.sourceCheckList_id,
@@ -469,13 +469,13 @@ export async function redoChecklist( req, res ) {
469
469
  let response = await processedChecklist.updateOne( { _id: req.body.payload._id }, updateData );
470
470
  // console.log( response );
471
471
  if ( response.modifiedCount || response.matchedCount ) {
472
- // let storeTimeZone = await storeService.findOne( { storeName: checklistDetails.storeName }, { 'storeProfile.timeZone': 1 } );
473
- // let currentDateTime;
474
- // if ( storeTimeZone?.storeProfile?.timeZone ) {
475
- // currentDateTime = dayjs().tz( storeTimeZone?.storeProfile?.timeZone );
476
- // } else {
477
- // currentDateTime = dayjs();
478
- // }
472
+ let storeTimeZone = await storeService.findOne( { storeName: checklistDetails.storeName }, { 'storeProfile.timeZone': 1 } );
473
+ let currentDateTime;
474
+ if ( storeTimeZone?.storeProfile?.timeZone ) {
475
+ currentDateTime = dayjs().tz( storeTimeZone?.storeProfile?.timeZone );
476
+ } else {
477
+ currentDateTime = dayjs();
478
+ }
479
479
  data = {
480
480
  checklistId: checklistDetails.sourceCheckList_id,
481
481
  checkListName: checklistDetails.checkListName,
@@ -491,10 +491,10 @@ export async function redoChecklist( req, res ) {
491
491
  type: checklistDetails.checkListType,
492
492
  userAnswer: userAnswer,
493
493
  initiatedBy: req.user.userName,
494
- initiatedTime: dayjs.utc( ).format(),
494
+ initiatedTime: dayjs.utc( currentDateTime.format( 'hh:mm:ss A, DD MMM YYYY' ), 'hh:mm:ss A, DD MMM YYYY' ).format(),
495
495
  answerType: question[sectionIndex].questions[findQuestion].answerType,
496
496
  submitedBy: checklistDetails.userName,
497
- submitTime: dayjs.utc( checklistDetails.submitTime ).format(),
497
+ submitTime: checklistDetails.submitTime,
498
498
  };
499
499
  await checklistLogs.create( data );
500
500
 
@@ -547,7 +547,7 @@ export async function redomultiChecklist( req, res ) {
547
547
  try {
548
548
  let inputData = req.body.payload.coverage === 'user' ? req.body.payload.userEmail : req.body.payload.storeName;
549
549
 
550
- let inputBody = req.body;
550
+
551
551
  for ( let originalData of inputData ) {
552
552
  if ( !originalData.checklistId ) {
553
553
  return res.sendError( 'Id is Required', 400 );
@@ -559,15 +559,6 @@ export async function redomultiChecklist( req, res ) {
559
559
  return res.sendError( 'Question number is Required', 400 );
560
560
  }
561
561
 
562
- let findcomment = {};
563
- if ( !inputBody.payload.showcomment ) {
564
- if ( inputBody.payload?.coverage === 'store' ) {
565
- findcomment = inputBody.payload.excelData.find( ( ele ) => ele['Store Name'] === originalData.storeName );
566
- } else if ( inputBody.payload?.coverage === 'users' ) {
567
- findcomment = inputBody.payload.excelData.find( ( ele ) => ele['User Email'] === originalData.userEmail );
568
- }
569
- }
570
- console.log( '****************', findcomment );
571
562
 
572
563
  let checklistDetails = await processedChecklist.findOne( { _id: originalData.checklistId }, { questionAnswers: 1, redoStatus: 1, checklistStatus: 1, client_id: 1, store_id: 1, storeName: 1, checkListType: 1, sourceCheckList_id: 1, checkListName: 1, submitTime: 1, userName: 1, answerType: 1 } );
573
564
  if ( !checklistDetails ) {
@@ -583,7 +574,7 @@ export async function redomultiChecklist( req, res ) {
583
574
 
584
575
  let findQuestion = question[sectionIndex].questions.findIndex( ( ele ) => ele.qno == req.body.payload.qno );
585
576
 
586
- let data = { ...question[sectionIndex].questions[findQuestion], redo: true, redoComment: req.body.payload?.showcomment ? req.body.payload?.checklistDescription : findcomment?.Comments };
577
+ let data = { ...question[sectionIndex].questions[findQuestion], redo: true, redoComment: req.body.payload?.checklistDescription || '' };
587
578
  // if ( checklistDetails.client_id == '458' ) {
588
579
  data.answers.forEach( ( item ) => {
589
580
  if ( item.showLinked ) {
@@ -620,17 +611,17 @@ export async function redomultiChecklist( req, res ) {
620
611
  let response = await processedChecklist.updateOne( { _id: originalData.checklistId }, updateData );
621
612
  // console.log( response );
622
613
  if ( response.modifiedCount || response.matchedCount ) {
623
- // let storeTimeZone = await storeService.findOne( { storeName: checklistDetails.storeName }, { 'storeProfile.timeZone': 1 } );
624
- // let currentDateTime;
625
- // if ( storeTimeZone?.storeProfile?.timeZone ) {
626
- // currentDateTime = dayjs().tz( storeTimeZone?.storeProfile?.timeZone );
627
- // } else {
628
- // currentDateTime = dayjs();
629
- // }
614
+ let storeTimeZone = await storeService.findOne( { storeName: checklistDetails.storeName }, { 'storeProfile.timeZone': 1 } );
615
+ let currentDateTime;
616
+ if ( storeTimeZone?.storeProfile?.timeZone ) {
617
+ currentDateTime = dayjs().tz( storeTimeZone?.storeProfile?.timeZone );
618
+ } else {
619
+ currentDateTime = dayjs();
620
+ }
630
621
  data = {
631
622
  checklistId: checklistDetails.sourceCheckList_id,
632
623
  checkListName: checklistDetails.checkListName,
633
- checklistDescription: req.body.payload?.showcomment ? req.body.payload?.checklistDescription : findcomment?.comments,
624
+ checklistDescription: req.body.payload.checklistDescription,
634
625
  sectionId: originalData.section_id,
635
626
  sectionName: question[sectionIndex].sectionName,
636
627
  questionName: question[sectionIndex].questions[findQuestion].qname,
@@ -642,10 +633,10 @@ export async function redomultiChecklist( req, res ) {
642
633
  type: checklistDetails.checkListType,
643
634
  userAnswer: userAnswer,
644
635
  initiatedBy: req.user.userName,
645
- initiatedTime: dayjs.utc( ).format(),
636
+ initiatedTime: dayjs.utc( currentDateTime.format( 'hh:mm:ss A, DD MMM YYYY' ), 'hh:mm:ss A, DD MMM YYYY' ).format(),
646
637
  answerType: question[sectionIndex].questions[findQuestion].answerType,
647
638
  submitedBy: checklistDetails.userName,
648
- submitTime: dayjs.utc( checklistDetails.submitTime ).format(),
639
+ submitTime: checklistDetails.submitTime,
649
640
  };
650
641
  await checklistLogs.create( data );
651
642
 
@@ -653,9 +644,7 @@ export async function redomultiChecklist( req, res ) {
653
644
  req.body.payload._id = originalData.checklistId;
654
645
  req.body.payload.section_id = originalData.section_id;
655
646
  req.body.payload.uniqueNo = originalData.uniqueNo;
656
- console.log( req.body );
657
-
658
- // return;
647
+ // console.log( req.body );
659
648
 
660
649
 
661
650
  const requestOptions = {
@@ -666,7 +655,6 @@ export async function redomultiChecklist( req, res ) {
666
655
  body: JSON.stringify( req.body ),
667
656
  };
668
657
  let url = JSON.parse( process.env.LAMBDAURL );
669
- console.log( url.redoChecklist );
670
658
  let searchResponse = await fetch( url.redoChecklist, requestOptions );
671
659
  console.log( searchResponse.ok );
672
660
  let logData = {
@@ -761,37 +749,6 @@ export async function approvalstatus( req, res ) {
761
749
  }
762
750
 
763
751
 
764
- let url = JSON.parse( process.env.LAMBDAURL );
765
- let resultData = await LamdaServiceCall( url.approvalstatus, req.body );
766
-
767
- if ( resultData ) {
768
- if ( resultData.status_code == '200' ) {
769
- return res.sendSuccess( resultData );
770
- } else {
771
- return res.sendError( 'No Content', 204 );
772
- }
773
- } else {
774
- return res.sendError( 'No Content', 204 );
775
- }
776
- } catch ( error ) {
777
- logger.error( error, 'approvalstatus' );
778
- return res.sendError( error, 500 );
779
- }
780
- }
781
- export async function allapprovalstatus( req, res ) {
782
- try {
783
- if ( ( req?.user?.userType == 'client' && req.user.role == 'superadmin' ) ) {
784
- let url = JSON.parse( process.env.LAMBDAURL );
785
- let resultData = await LamdaServiceCall( url.approvalstatus, req.body );
786
- if ( resultData ) {
787
- if ( resultData.status_code == '200' ) {
788
- return res.sendSuccess( resultData );
789
- }
790
- }
791
- return res.sendError( 'No Content', 204 );
792
- }
793
-
794
-
795
752
  let url = JSON.parse( process.env.LAMBDAURL );
796
753
  let resultData = await LamdaServiceCall( url.approvalstatus, req.body );
797
754
 
@@ -1191,35 +1148,7 @@ export async function checkNotificationCount( req, res ) {
1191
1148
  return res.sendError( { error: error }, 500 );
1192
1149
  }
1193
1150
  }
1194
- export async function taskvalidateUserData( req, res ) {
1195
- try {
1196
- let error = [];
1197
- if ( req.body.coverage === 'store' ) {
1198
- for ( let [ index, store ] of req.body.assignedData.entries() ) {
1199
- let findstore = await storeService.findOne( { clientId: req.body.clientId, storeName: store['Store Name'] } );
1200
- console.log( findstore );
1201
- if ( !findstore ) {
1202
- error.push( `Invalid StoreName - C${index + 2}` );
1203
- }
1204
- }
1205
- }
1206
- if ( req.body.coverage === 'users' ) {
1207
- for ( let [ index, user ] of req.body.assignedData.entries() ) {
1208
- let finduser = await findOne( { clientId: req.body.clientId, email: user['User Email'] } );
1209
- if ( !finduser ) {
1210
- error.push( `Invalid userEmail - C${index + 2}` );
1211
- }
1212
- }
1213
- }
1214
- if ( error.length ) {
1215
- return res.sendError( error, 400 );
1216
- }
1217
1151
 
1218
- res.sendSuccess( 'success' );
1219
- } catch ( error ) {
1220
- logger.error( { error: error, function: 'taskvalidateUserData' } );
1221
- }
1222
- }
1223
1152
  export async function vehicleCheckInUpdate( req, res ) {
1224
1153
  try {
1225
1154
  let requestData = req.body;
@@ -1241,71 +1170,3 @@ export async function vehicleCheckInUpdate( req, res ) {
1241
1170
  return res.sendError( { error: error }, 500 );
1242
1171
  }
1243
1172
  }
1244
- export async function getallchecklist( req, res ) {
1245
- try {
1246
- let url = JSON.parse( process.env.LAMBDAURL );
1247
- console.log( url.getallchecklist );
1248
-
1249
- let resultData = await LamdaServiceCall( url.getallchecklist, req.body );
1250
- console.log( resultData );
1251
- if ( resultData ) {
1252
- if ( resultData.status_code == '200' ) {
1253
- resultData.message = '';
1254
- return res.sendSuccess( resultData );
1255
- } else {
1256
- return res.sendError( 'No Content', 204 );
1257
- }
1258
- } else {
1259
- return res.sendError( 'No Content', 204 );
1260
- }
1261
- } catch ( error ) {
1262
- logger.error( { error: error, function: 'getallchecklist' } );
1263
- return res.sendError( { error: error }, 500 );
1264
- }
1265
- }
1266
- export async function exportTemplate( req, res ) {
1267
- try {
1268
- const workbook = new ExcelJS.Workbook();
1269
- const worksheet = workbook.addWorksheet( 'Sheet1' );
1270
- if ( req.body.coverage === 'store' ) {
1271
- worksheet.addRow( [ 'Checklist Name', 'Question Name', 'Store Name', 'Comments' ] );
1272
- } else {
1273
- worksheet.addRow( [ 'Checklist Name', 'Question Name', 'User Email', 'Comments' ] );
1274
- }
1275
- for ( let data of req.body.excelData ) {
1276
- worksheet.addRow( [ data.checklistName, data.questionName, req.body.coverage === 'store'?data.storeName:data.userEmail, '' ] );
1277
- }
1278
- worksheet.eachRow( ( row, rowNumber ) => {
1279
- row.eachCell( { includeEmpty: true }, ( cell, colNumber ) => {
1280
- if ( colNumber === 1 || colNumber === 2 || colNumber === 3 ) {
1281
- cell.protection = { locked: true }; // Lock Name & Email
1282
- } else {
1283
- cell.protection = { locked: false }; // Unlock Phone
1284
- }
1285
- } );
1286
- } );
1287
-
1288
- // Protect the worksheet
1289
- await worksheet.protect( 'yourPassword123', {
1290
- selectLockedCells: true,
1291
- selectUnlockedCells: true,
1292
- formatCells: false,
1293
- formatColumns: false,
1294
- formatRows: false,
1295
- insertColumns: false,
1296
- insertRows: false,
1297
- insertHyperlinks: false,
1298
- deleteColumns: false,
1299
- deleteRows: false,
1300
- } );
1301
-
1302
-
1303
- const buffer = await workbook.xlsx.writeBuffer();
1304
- res.setHeader( 'Content-Type', 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' );
1305
- res.setHeader( 'Content-Disposition', 'attachment; filename="Fixture Library.xlsx"' );
1306
- return res.send( buffer );
1307
- } catch ( error ) {
1308
- logger.error( { error: error, function: 'exportTemplate' } );
1309
- return res.sendError( { error: error }, 500 );
1310
- }
1311
- }
@@ -377,7 +377,7 @@ export async function startTask( req, res ) {
377
377
 
378
378
 
379
379
  let updatedNewData;
380
- if ( task.checkListFrom && [ 'api', 'gallery' ].includes( task.checkListFrom ) ) {
380
+ if ( task.checkListFrom && task.checkListFrom == 'api' ) {
381
381
  updatedNewData = {
382
382
  checklistStatus: 'inprogress',
383
383
  startMobileTime: requestData?.currentTime,
@@ -1516,9 +1516,6 @@ export async function sopMobileTaskMultiSectionFormatter( req, res, next ) {
1516
1516
  let structure = {};
1517
1517
  structure.qno = qaAnswers[j].qno;
1518
1518
  structure.qname = qaAnswers[j].qname;
1519
- if ( qaAnswers[j].qcomment && qaAnswers[j].qcomment!='' ) {
1520
- structure.qcomment = qaAnswers[j].qcomment;
1521
- }
1522
1519
  structure.answerType = qaAnswers[j].answerType;
1523
1520
  structure.runAI = qaAnswers[j].runAI;
1524
1521
  structure.runAIDescription = qaAnswers[j].runAIDescription;
@@ -1567,9 +1564,6 @@ export async function sopMobileTaskMultiSectionFormatter( req, res, next ) {
1567
1564
  let structure = {};
1568
1565
  structure.qno = qaAnswers[j].qno;
1569
1566
  structure.qname = qaAnswers[j].qname;
1570
- if ( qaAnswers[j].qcomment && qaAnswers[j].qcomment!='' ) {
1571
- structure.qcomment = qaAnswers[j].qcomment;
1572
- }
1573
1567
  structure.answerType = qaAnswers[j].answerType;
1574
1568
  structure.runAI = qaAnswers[j].runAI;
1575
1569
  structure.runAIDescription = qaAnswers[j].runAIDescription;
@@ -1621,9 +1615,6 @@ export async function sopMobileTaskMultiSectionFormatter( req, res, next ) {
1621
1615
  let structure = {};
1622
1616
  structure.qno = qaAnswers[j].qno;
1623
1617
  structure.qname = qaAnswers[j].qname;
1624
- if ( qaAnswers[j].qcomment && qaAnswers[j].qcomment!='' ) {
1625
- structure.qcomment = qaAnswers[j].qcomment;
1626
- }
1627
1618
  structure.answerType = qaAnswers[j].answerType;
1628
1619
  structure.runAI = qaAnswers[j].runAI;
1629
1620
  structure.runAIDescription = qaAnswers[j].runAIDescription;
@@ -1680,9 +1671,6 @@ export async function sopMobileTaskMultiSectionFormatter( req, res, next ) {
1680
1671
  let structure = {};
1681
1672
  structure.qno = qaAnswers[j].qno;
1682
1673
  structure.qname = qaAnswers[j].qname;
1683
- if ( qaAnswers[j].qcomment && qaAnswers[j].qcomment!='' ) {
1684
- structure.qcomment = qaAnswers[j].qcomment;
1685
- }
1686
1674
  structure.answerType = qaAnswers[j].answerType;
1687
1675
  structure.runAI = qaAnswers[j].runAI;
1688
1676
  structure.runAIDescription = qaAnswers[j].runAIDescription;
@@ -1737,9 +1725,6 @@ export async function sopMobileTaskMultiSectionFormatter( req, res, next ) {
1737
1725
  let structure = {};
1738
1726
  structure.qno = qaAnswers[j].qno;
1739
1727
  structure.qname = qaAnswers[j].qname;
1740
- if ( qaAnswers[j].qcomment && qaAnswers[j].qcomment!='' ) {
1741
- structure.qcomment = qaAnswers[j].qcomment;
1742
- }
1743
1728
  structure.answerType = qaAnswers[j].answerType;
1744
1729
  structure.runAI = qaAnswers[j].runAI;
1745
1730
  structure.runAIDescription = qaAnswers[j].runAIDescription;
@@ -1,4 +1,4 @@
1
- import { signedUrl, fileUpload, chunkArray, logger, sendPushNotification, sendTeamsNotification, insertOpenSearchData } from 'tango-app-api-middleware';
1
+ import { fileUpload, chunkArray, logger, sendPushNotification, sendTeamsNotification, insertOpenSearchData } from 'tango-app-api-middleware';
2
2
  import * as checklistService from '../services/checklist.service.js';
3
3
  import * as questionService from '../services/checklistQuestion.service.js';
4
4
  import * as assignedService from '../services/checklistAssign.service.js';
@@ -222,24 +222,24 @@ export const create = async ( req, res ) => {
222
222
  if ( inputBody.sections.length ) {
223
223
  for ( let i = 0; i < inputBody?.sections?.length; i++ ) {
224
224
  let section = inputBody.sections[i];
225
- section.questions.forEach( ( section ) => {
226
- if ( section.questionReferenceImage && section.questionReferenceImage !='' ) {
227
- let imgUrl = decodeURIComponent( section.questionReferenceImage.split( '?' )[0] );
228
- let url = imgUrl.split( '/' );
229
- url.splice( 0, 3 );
230
- section.questionReferenceImage = url.join( '/' );
231
- }
232
- // if (['image', 'descriptiveImage'].includes(section.answerType) ) {
233
- section.answers.forEach( ( answer ) => {
234
- if ( answer.referenceImage != '' ) {
235
- let imgUrl = decodeURIComponent( answer.referenceImage.split( '?' )[0] );
236
- let url = imgUrl.split( '/' );
237
- url.splice( 0, 3 );
238
- answer.referenceImage = url.join( '/' );
239
- }
240
- } );
241
- // }
242
- } );
225
+ // section.questions.forEach( ( section ) => {
226
+ // if ( section.questionReferenceImage && section.questionReferenceImage !='' ) {
227
+ // let imgUrl = decodeURIComponent( section.questionReferenceImage.split( '?' )[0] );
228
+ // let url = imgUrl.split( '/' );
229
+ // url.splice( 0, 3 );
230
+ // section.questionReferenceImage = url.join( '/' );
231
+ // }
232
+ // // if (['image', 'descriptiveImage'].includes(section.answerType) ) {
233
+ // section.answers.forEach( ( answer ) => {
234
+ // if ( answer.referenceImage != '' ) {
235
+ // let imgUrl = decodeURIComponent( answer.referenceImage.split( '?' )[0] );
236
+ // let url = imgUrl.split( '/' );
237
+ // url.splice( 0, 3 );
238
+ // answer.referenceImage = url.join( '/' );
239
+ // }
240
+ // } );
241
+ // // }
242
+ // } );
243
243
 
244
244
  for ( let [ index, question ] of section.questions.entries() ) {
245
245
  await processNested( index, question );
@@ -411,26 +411,26 @@ export const getConfigDetails = async ( req, res ) => {
411
411
  let questionDetails = await questionService.findSort( query, {}, sectionSort );
412
412
  if ( questionDetails.length ) {
413
413
  let sections = [];
414
- let bucket = JSON.parse( process.env.BUCKET );
414
+ // let bucket = JSON.parse( process.env.BUCKET );
415
415
  questionDetails.forEach( ( item ) => {
416
- item.question.forEach( async ( question ) => {
417
- if ( question.questionReferenceImage && question.questionReferenceImage !='' ) {
418
- let inputData = {
419
- Bucket: bucket.sop,
420
- file_path: decodeURIComponent( question.questionReferenceImage ),
421
- };
422
- question.questionReferenceImage = await signedUrl( inputData );
423
- }
424
- question.answers.forEach( async ( answer ) => {
425
- if ( answer.referenceImage != '' ) {
426
- let inputData = {
427
- Bucket: bucket.sop,
428
- file_path: decodeURIComponent( answer.referenceImage ),
429
- };
430
- answer.referenceImage = await signedUrl( inputData );
431
- }
432
- } );
433
- } );
416
+ // item.question.forEach( async ( question ) => {
417
+ // if ( question.questionReferenceImage && question.questionReferenceImage !='' ) {
418
+ // let inputData = {
419
+ // Bucket: bucket.sop,
420
+ // file_path: decodeURIComponent( question.questionReferenceImage ),
421
+ // };
422
+ // question.questionReferenceImage = await signedUrl( inputData );
423
+ // }
424
+ // question.answers.forEach( async ( answer ) => {
425
+ // if ( answer.referenceImage != '' ) {
426
+ // let inputData = {
427
+ // Bucket: bucket.sop,
428
+ // file_path: decodeURIComponent( answer.referenceImage ),
429
+ // };
430
+ // answer.referenceImage = await signedUrl( inputData );
431
+ // }
432
+ // } );
433
+ // } );
434
434
  sections.push( {
435
435
  id: item._id,
436
436
  name: item.section,
@@ -855,22 +855,22 @@ export const update = async ( req, res ) => {
855
855
  if ( inputBody.sections.length ) {
856
856
  for ( let i = 0; i < inputBody?.sections?.length; i++ ) {
857
857
  let section = inputBody.sections[i];
858
- section.questions.forEach( ( section ) => {
859
- if ( section.questionReferenceImage && section.questionReferenceImage !='' ) {
860
- let imgUrl = section.questionReferenceImage.split( '?' )[0];
861
- let url = imgUrl.split( '/' );
862
- url.splice( 0, 3 );
863
- section.questionReferenceImage = url.join( '/' );
864
- }
865
- section.answers.forEach( ( answer ) => {
866
- if ( answer.referenceImage != '' ) {
867
- let imgUrl = answer.referenceImage.split( '?' )[0];
868
- let url = imgUrl.split( '/' );
869
- url.splice( 0, 3 );
870
- answer.referenceImage = url.join( '/' );
871
- }
872
- } );
873
- } );
858
+ // section.questions.forEach( ( section ) => {
859
+ // if ( section.questionReferenceImage && section.questionReferenceImage !='' ) {
860
+ // let imgUrl = section.questionReferenceImage.split( '?' )[0];
861
+ // let url = imgUrl.split( '/' );
862
+ // url.splice( 0, 3 );
863
+ // section.questionReferenceImage = url.join( '/' );
864
+ // }
865
+ // section.answers.forEach( ( answer ) => {
866
+ // if ( answer.referenceImage != '' ) {
867
+ // let imgUrl = answer.referenceImage.split( '?' )[0];
868
+ // let url = imgUrl.split( '/' );
869
+ // url.splice( 0, 3 );
870
+ // answer.referenceImage = url.join( '/' );
871
+ // }
872
+ // } );
873
+ // } );
874
874
 
875
875
  for ( let [ index, question ] of section.questions.entries() ) {
876
876
  await processNested( index, question );
@@ -1097,16 +1097,16 @@ export const uploadImage = async ( req, res ) => {
1097
1097
  };
1098
1098
  imgUrl = await fileUpload( params );
1099
1099
 
1100
- let inputData = {
1101
- Bucket: bucket.sop,
1102
- file_path: imgUrl.Key,
1103
- };
1104
- imgUrl = await signedUrl( inputData );
1105
- if ( !imgUrl ) {
1106
- return res.sendError( { message: 'Something went Wrong' }, 500 );
1107
- }
1100
+ // let inputData = {
1101
+ // Bucket: bucket.sop,
1102
+ // file_path: imgUrl.Key,
1103
+ // };
1104
+ // imgUrl = await signedUrl( inputData );
1105
+ // if ( !imgUrl ) {
1106
+ // return res.sendError( { message: 'Something went Wrong' }, 500 );
1107
+ // }
1108
1108
 
1109
- return res.sendSuccess( { message: 'Uploaded Successfully', imgUrl: imgUrl } );
1109
+ return res.sendSuccess( { message: 'Uploaded Successfully', imgUrl: imgUrl.Key } );
1110
1110
  } catch ( e ) {
1111
1111
  logger.error( 'uploadImage =>', e );
1112
1112
  return res.sendError( e, 500 );
@@ -57,7 +57,7 @@ export const runaiSchema = joi.object( {
57
57
  questionName: joi.string().optional().allow( '' ),
58
58
  runAIDescription: joi.string().optional().allow( '' ),
59
59
  answerType: joi.string().optional().allow( '' ),
60
- referenceImage: joi.string().optional().allow( '' ),
60
+ referenceImage: joi.array().items( joi.any() ).min( 0 ),
61
61
  clientId: joi.string().optional().allow( '' ),
62
62
  } );
63
63