tango-app-api-trax 3.7.13-qid-halfshutter-12 → 3.7.13-qid-halfshutter-13

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.7.13-qid-halfshutter-12",
3
+ "version": "3.7.13-qid-halfshutter-13",
4
4
  "description": "Trax",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -27,7 +27,7 @@
27
27
  "mongodb": "^6.8.0",
28
28
  "nodemon": "^3.1.4",
29
29
  "path": "^0.12.7",
30
- "tango-api-schema": "^2.4.15",
30
+ "tango-api-schema": "^2.4.11",
31
31
  "tango-app-api-middleware": "^3.5.2",
32
32
  "url": "^0.11.4",
33
33
  "winston": "^3.13.1",
@@ -290,6 +290,7 @@ export async function PCLconfigCreation( req, res ) {
290
290
  insertdata.rawImageUpload = getCLconfig.rawImageUpload || false;
291
291
  insertdata.rawVideoUpload = getCLconfig.rawVideoUpload || false;
292
292
  insertdata.videoUploadTimeLimit = getCLconfig.videoUploadTimeLimit || 0;
293
+ insertdata.coverage = getCLconfig?.coverage ?? 'store';
293
294
  let collectSections = [];
294
295
  let sectionQuery = [];
295
296
  sectionQuery.push( {
@@ -2623,59 +2624,3 @@ export async function getRunAIQuestions( req, res ) {
2623
2624
  return res.sendError( e, 500 );
2624
2625
  }
2625
2626
  }
2626
-
2627
- export async function getRunAIList( req, res ) {
2628
- try {
2629
- let getChecklistDetails = await CLconfig.find( { publish: true } );
2630
- if ( !getChecklistDetails.length ) {
2631
- return res.sendError( 'No data found', 204 );
2632
- }
2633
- let runAIList=new Set();
2634
- await Promise.all( getChecklistDetails.map( async ( check ) => {
2635
- let getQuestionList = await CLquestions.find( { checkListId: check._id } );
2636
- if ( getQuestionList.length ) {
2637
- getQuestionList.forEach( ( sec ) => {
2638
- sec.question.forEach( ( qn ) => {
2639
- if ( qn.answers.some( ( ele ) => ele.runAI ) ) {
2640
- runAIList.add( check._id );
2641
- }
2642
- } );
2643
- } );
2644
- }
2645
- } ) );
2646
- return res.sendSuccess( Array.from( runAIList ) );
2647
- } catch ( e ) {
2648
- logger.error( { functionName: 'getRunAIList', error: e } );
2649
- return res.sendError( e, 500 );
2650
- }
2651
- }
2652
-
2653
- export async function updateChecklistConfig( req, res ) {
2654
- try {
2655
- if ( req.body.type == 'checklist' ) {
2656
- let checklistDetails = await CLconfig.findOne( { _id: req.body.id } );
2657
- if ( !checklistDetails ) {
2658
- return res.sendError( 'No data found', 204 );
2659
- }
2660
- await CLconfig.updateOne( { _id: req.body.id }, req.body.data );
2661
-
2662
- if ( req.body?.updateStore ) {
2663
- await processedchecklist.updateMany( { date_string: dayjs().format( 'YYYY-MM-DD' ), sourceCheckList_id: req.body.id, ...( req.body.store?.length && { storeName: { $in: req.body.store } } ) }, req.body.data );
2664
- }
2665
- } else {
2666
- let taskDetails = await taskService.findOne( { _id: req.body.id } );
2667
- if ( !taskDetails ) {
2668
- return res.sendError( 'No data found', 204 );
2669
- }
2670
- await taskService.updateOne( { _id: req.body.id }, req.body.data );
2671
-
2672
- if ( req.body?.updateStore ) {
2673
- await processedTaskService.updateMany( { date_string: dayjs().format( 'YYYY-MM-DD' ), sourceCheckList_id: req.body.id, ...( req.body.store?.length && { storeName: { $in: req.body.store } } ) }, req.body.data );
2674
- }
2675
- }
2676
- return res.sendSuccess( 'updated successfully' );
2677
- } catch ( e ) {
2678
- logger.error( { functionName: 'updateChecklist', error: e } );
2679
- return res.sendError( e, 500 );
2680
- }
2681
- }
@@ -1,4 +1,4 @@
1
- import { logger, signedUrl, fileUpload, getOtp, sendEmailWithSES, getUuid, insertOpenSearchData, listFileByPath, getObject, deleteFiles } from 'tango-app-api-middleware';
1
+ import { logger, signedUrl, fileUpload, getOtp, sendEmailWithSES, getUuid, insertOpenSearchData } from 'tango-app-api-middleware';
2
2
  import * as processedchecklist from '../services/processedchecklist.services.js';
3
3
  import * as processedtask from '../services/processedTaskList.service.js';
4
4
  import * as PCLconfig from '../services/processedchecklistconfig.services.js';
@@ -19,6 +19,7 @@ import timeZone from 'dayjs/plugin/timezone.js';
19
19
  import { findOTP, updateOneOTP } from '../services/otp.service.js';
20
20
  import * as clientService from '../services/clients.services.js';
21
21
  import { create } from '../services/authentication.service.js';
22
+ import { readFileSync } from 'fs';
22
23
  import { join } from 'path';
23
24
  import handlebars from 'handlebars';
24
25
  dayjs.extend( customParseFormat );
@@ -3570,9 +3571,6 @@ export async function taskQuestionList( req, res ) {
3570
3571
  userEmail: { $ifNull: [ '$userEmail', '' ] },
3571
3572
  storeName: { $ifNull: [ '$storeName', '' ] },
3572
3573
  redoStatus: { $ifNull: [ '$redoStatus', false ] },
3573
- rawImageUpload: { $ifNull: [ '$rawImageUpload', false ] },
3574
- rawVideoUpload: { $ifNull: [ '$rawVideoUpload', false ] },
3575
- videoUploadTimeLimit: { $ifNull: [ '$videoUploadTimeLimit', 0 ] },
3576
3574
  },
3577
3575
  } );
3578
3576
 
@@ -3774,7 +3772,7 @@ export async function uploadAnswerImage( req, res ) {
3774
3772
  let imageUrl;
3775
3773
  let filePath = `${folder}/${req.user.clientId}/${date}/${input.checklistId}/${input.sectionName.replace( ' ', '' )}/${input.questionNo}/`;
3776
3774
  let params = {
3777
- fileName: `${Date.now()}-${Math.floor( 1000 + Math.random() * 9000 )}-${req.files.answerImage.name}`,
3775
+ fileName: `${Date.now()}-${Math.floor( 1000 + Math.random() * 9000 )}.${req.files.answerImage.name.split( '.' )[1]}`,
3778
3776
  Key: filePath,
3779
3777
  Bucket: bucket.sop,
3780
3778
  body: req.files.answerImage.data,
@@ -4391,58 +4389,3 @@ export async function questionListV1( req, res ) {
4391
4389
  }
4392
4390
  }
4393
4391
 
4394
-
4395
- export async function chunkUpload( req, res ) {
4396
- try {
4397
- const { chunkIndex, totalChunks } = req.body;
4398
- if ( chunkIndex === undefined || !totalChunks || !req.files || !req.files.answerImage ) {
4399
- return res.status( 400 ).json( { error: 'Missing required params or file.' } );
4400
- }
4401
- const chunkNum = Number( chunkIndex );
4402
- const chunkTotal = Number( totalChunks );
4403
- const chunkFile = req.files.answerImage;
4404
- const chunkKey = `traxVideoChunks/${req.user._id}/${chunkNum}`;
4405
- let bucket;
4406
- try {
4407
- bucket = JSON.parse( process.env.BUCKET )?.sop;
4408
- } catch {
4409
- return res.sendError( 'Bucket config error', 500 );
4410
- }
4411
- await fileUpload( {
4412
- fileName: '',
4413
- Key: chunkKey,
4414
- Bucket: bucket,
4415
- ContentType: chunkFile.mimetype,
4416
- body: chunkFile.data,
4417
- } );
4418
- if ( chunkNum < chunkTotal ) {
4419
- return res.sendSuccess( { message: 'Chunk uploaded to S3', chunkIndex: chunkNum } );
4420
- }
4421
- const prefix = `traxVideoChunks/${req.user._id}/`;
4422
- const s3FilesResp = await listFileByPath( { Bucket: bucket, file_path: prefix, MaxKeys: chunkTotal } );
4423
- const chunkObjs = s3FilesResp?.data || [];
4424
- chunkObjs.sort( ( a, b ) => {
4425
- const ai = Number( a.Key.split( '/' ).pop() );
4426
- const bi = Number( b.Key.split( '/' ).pop() );
4427
- return ai - bi;
4428
- } );
4429
- const buffers = [];
4430
- for ( const obj of chunkObjs ) {
4431
- const s3Obj = await getObject( { Bucket: bucket, Key: obj.Key } );
4432
- buffers.push( Buffer.from( s3Obj.Body ) );
4433
- }
4434
- const finalBuffer = Buffer.concat( buffers );
4435
- try {
4436
- await deleteFiles( bucket, prefix );
4437
- } catch ( e ) {}
4438
- req.files.answerImage = {
4439
- data: finalBuffer,
4440
- name: chunkFile.name,
4441
- mimetype: chunkFile.mimetype,
4442
- };
4443
- return uploadAnswerImage( req, res );
4444
- } catch ( e ) {
4445
- logger.error( { functionName: 'chunkUpload', error: e } );
4446
- return res.sendError( e, 500 );
4447
- }
4448
- }
@@ -28,8 +28,6 @@ internalTraxRouter
28
28
  .post( '/insertAINotification', isAllowedInternalAPIHandler, internalController.insertAINotification )
29
29
  .post( '/updateRunAI', isAllowedInternalAPIHandler, internalController.updateRunAI )
30
30
  .post( '/countUpdateRunAI', isAllowedInternalAPIHandler, internalController.countUpdateRunAI )
31
- .post( '/getRunAIQuestions', isAllowedInternalAPIHandler, internalController.getRunAIQuestions )
32
- .get( '/getRunAIList', isAllowedInternalAPIHandler, internalController.getRunAIList )
33
- .post( '/updateChecklistConfig', isAllowedInternalAPIHandler, internalController.updateChecklistConfig );
31
+ .post( '/getRunAIQuestions', isAllowedInternalAPIHandler, internalController.getRunAIQuestions );
34
32
 
35
33
 
@@ -29,6 +29,5 @@ mobileRouter
29
29
  .post( '/checkUpdateVersion', mobileController.checkVersion )
30
30
  .post( '/checkUpdateVersionv1', mobileController.checkVersionV1 )
31
31
  .post( '/checkClientConfig', isAllowedSessionHandler, mobileController.clientConfig )
32
- .post( '/updatePlanoStatus', isAllowedSessionHandler, mobileController.updatePlanoStatus )
33
- .post( '/chunkUpload', isAllowedSessionHandler, mobileController.chunkUpload );
32
+ .post( '/updatePlanoStatus', isAllowedSessionHandler, mobileController.updatePlanoStatus );
34
33