tango-app-api-trax 3.7.13-qid-halfshutter-11 → 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-11",
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 );
@@ -3771,7 +3772,7 @@ export async function uploadAnswerImage( req, res ) {
3771
3772
  let imageUrl;
3772
3773
  let filePath = `${folder}/${req.user.clientId}/${date}/${input.checklistId}/${input.sectionName.replace( ' ', '' )}/${input.questionNo}/`;
3773
3774
  let params = {
3774
- 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]}`,
3775
3776
  Key: filePath,
3776
3777
  Bucket: bucket.sop,
3777
3778
  body: req.files.answerImage.data,
@@ -4388,58 +4389,3 @@ export async function questionListV1( req, res ) {
4388
4389
  }
4389
4390
  }
4390
4391
 
4391
-
4392
- export async function chunkUpload( req, res ) {
4393
- try {
4394
- const { chunkIndex, totalChunks } = req.body;
4395
- if ( chunkIndex === undefined || !totalChunks || !req.files || !req.files.answerImage ) {
4396
- return res.status( 400 ).json( { error: 'Missing required params or file.' } );
4397
- }
4398
- const chunkNum = Number( chunkIndex );
4399
- const chunkTotal = Number( totalChunks );
4400
- const chunkFile = req.files.answerImage;
4401
- const chunkKey = `traxVideoChunks/${req.user._id}/${chunkNum}`;
4402
- let bucket;
4403
- try {
4404
- bucket = JSON.parse( process.env.BUCKET )?.sop;
4405
- } catch {
4406
- return res.sendError( 'Bucket config error', 500 );
4407
- }
4408
- await fileUpload( {
4409
- fileName: '',
4410
- Key: chunkKey,
4411
- Bucket: bucket,
4412
- ContentType: chunkFile.mimetype,
4413
- body: chunkFile.data,
4414
- } );
4415
- if ( chunkNum < chunkTotal ) {
4416
- return res.sendSuccess( { message: 'Chunk uploaded to S3', chunkIndex: chunkNum } );
4417
- }
4418
- const prefix = `traxVideoChunks/${req.user._id}/`;
4419
- const s3FilesResp = await listFileByPath( { Bucket: bucket, file_path: prefix, MaxKeys: chunkTotal } );
4420
- const chunkObjs = s3FilesResp?.data || [];
4421
- chunkObjs.sort( ( a, b ) => {
4422
- const ai = Number( a.Key.split( '/' ).pop() );
4423
- const bi = Number( b.Key.split( '/' ).pop() );
4424
- return ai - bi;
4425
- } );
4426
- const buffers = [];
4427
- for ( const obj of chunkObjs ) {
4428
- const s3Obj = await getObject( { Bucket: bucket, Key: obj.Key } );
4429
- buffers.push( Buffer.from( s3Obj.Body ) );
4430
- }
4431
- const finalBuffer = Buffer.concat( buffers );
4432
- try {
4433
- await deleteFiles( bucket, prefix );
4434
- } catch ( e ) {}
4435
- req.files.answerImage = {
4436
- data: finalBuffer,
4437
- name: chunkFile.name,
4438
- mimetype: chunkFile.mimetype,
4439
- };
4440
- return uploadAnswerImage( req, res );
4441
- } catch ( e ) {
4442
- logger.error( { functionName: 'chunkUpload', error: e } );
4443
- return res.sendError( e, 500 );
4444
- }
4445
- }
@@ -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