tango-app-api-audit 3.4.61 → 3.4.63

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/README.md CHANGED
@@ -1,29 +1,29 @@
1
- # README #
2
-
3
- This README would normally document whatever steps are necessary to get your application up and running.
4
-
5
- ### What is this repository for? ###
6
-
7
- * Quick summary
8
- * Version
9
- * [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
10
-
11
- ### How do I get set up? ###
12
-
13
- * Summary of set up
14
- * Configuration
15
- * Dependencies
16
- * Database configuration
17
- * How to run tests
18
- * Deployment instructions
19
-
20
- ### Contribution guidelines ###
21
-
22
- * Writing tests
23
- * Code review
24
- * Other guidelines
25
-
26
- ### Who do I talk to? ###
27
-
28
- * Repo owner or admin
1
+ # README #
2
+
3
+ This README would normally document whatever steps are necessary to get your application up and running.
4
+
5
+ ### What is this repository for? ###
6
+
7
+ * Quick summary
8
+ * Version
9
+ * [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
10
+
11
+ ### How do I get set up? ###
12
+
13
+ * Summary of set up
14
+ * Configuration
15
+ * Dependencies
16
+ * Database configuration
17
+ * How to run tests
18
+ * Deployment instructions
19
+
20
+ ### Contribution guidelines ###
21
+
22
+ * Writing tests
23
+ * Code review
24
+ * Other guidelines
25
+
26
+ ### Who do I talk to? ###
27
+
28
+ * Repo owner or admin
29
29
  * Other community or team contact
package/app.js ADDED
@@ -0,0 +1,40 @@
1
+ import express from 'express';
2
+ import { auditRouter } from './index.js';
3
+ import dotenv from 'dotenv';
4
+ import { logger } from 'tango-app-api-middleware';
5
+ import { connectdb } from './config/database/database.js';
6
+ import responseMiddleware from './config/response/response.js';
7
+ import errorMiddleware from './config/response/error.js';
8
+ import pkg from 'body-parser';
9
+ import { swaggerConfig } from './config/swagger/swagger.js';
10
+ import swagger from 'swagger-ui-express';
11
+ import { traxAuditRouter } from './src/routes/traxAudit.routes.js';
12
+ import cors from 'cors';
13
+ const { json, urlencoded } = pkg;
14
+ const env=dotenv.config();
15
+
16
+ const app = express();
17
+ const PORT = process.env.PORT || 3000;
18
+ app.use( cors() );
19
+
20
+ app.use( json( { limit: '500mb' } ) );
21
+ app.use(
22
+ urlencoded( {
23
+ extended: true,
24
+ } ),
25
+ );
26
+ app.use( responseMiddleware );
27
+ app.use( errorMiddleware );
28
+ if ( env.error ) {
29
+ logger.error( '.env not found' );
30
+ process.exit( 1 );
31
+ }
32
+
33
+ app.use( '/api-docs', swagger.serve, swagger.setup( swaggerConfig ) );
34
+ app.use( '/v3/audit', auditRouter );
35
+ app.use( '/trax-audit', traxAuditRouter );
36
+
37
+ app.listen( PORT, async () => {
38
+ connectdb();
39
+ logger.info( `server is running on port= ${PORT} ` );
40
+ } );
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "tango-app-api-audit",
3
- "version": "3.4.61",
3
+ "version": "3.4.63",
4
4
  "description": "audit & audit metrics apis",
5
- "main": "index.js",
5
+ "main": "app.js",
6
6
  "type": "module",
7
7
  "scripts": {
8
- "start": "nodemon --exec \"eslint --fix . && node index.js\""
8
+ "start": "nodemon --exec \"eslint --fix . && node app.js\""
9
9
  },
10
10
  "engines": {
11
11
  "node": ">=18.10.0"
@@ -507,7 +507,6 @@ export async function getAuditFile( req, res ) {
507
507
  const userDetails = await aggregateBinaryAudit( userQuery );
508
508
  logger.info( { userDetails: userDetails, function: 'userDetails' } );
509
509
  const auditStatus = userDetails && userDetails.length > 0 ? userDetails[0].auditStatus : null;
510
-
511
510
  switch ( auditStatus ) {
512
511
  case null:
513
512
 
@@ -523,6 +522,7 @@ export async function getAuditFile( req, res ) {
523
522
  }
524
523
  msg = JSON.parse( consumer );
525
524
 
525
+
526
526
  break;
527
527
 
528
528
  case 'inprogress':
@@ -580,6 +580,7 @@ export async function getAuditFile( req, res ) {
580
580
  default:
581
581
  return res.sendError( 'Please give valid moduleType', 400 );
582
582
  }
583
+
583
584
  const traxInfo = await findOneTraxAuditData( query );
584
585
  if ( !traxInfo ) {
585
586
  return res.sendError( 'The source record not found', 400 );
@@ -714,17 +715,17 @@ export async function getAuditFile( req, res ) {
714
715
  } );
715
716
  break;
716
717
  case 'anomaly-audit':
717
- for ( let i =0; i< msg.fileDetails.length; i++ ) {
718
- const files = [];
719
- const data = msg.fileDetails[i].folderPath;
720
- files.push(
721
- data,
722
- );
723
- result.push( {
724
- type: msg.fileDetails[i].type,
725
- file: files,
726
- } );
727
- }
718
+ const BucketCDN = url.traxAuditInput;
719
+ const data = `${BucketCDN}${ msg.path}`;
720
+ let files = [];
721
+ files.push(
722
+ data,
723
+ );
724
+ result.push( {
725
+ type: 'video',
726
+ file: files,
727
+ } );
728
+
728
729
  break;
729
730
  default:
730
731
  return res.sendError( 'Please given valid moduleType', 400 );
@@ -1716,10 +1717,18 @@ export async function saveBinary( req, res ) {
1716
1717
  Answer: inputData.answer,
1717
1718
  configTime: getData?.sqs?.Body?.configTime,
1718
1719
  inputBucketName: getData?.sqs?.Body?.inputBucketName,
1719
- incidentType: getData?.sqs?.Body?.incidentType,
1720
- incidentId: getData?.sqs?.Body?.incidentId,
1721
- incidentTime: getData?.sqs?.Body?.incidentTime,
1722
- thumnailImage: getData?.sqs?.Body?.thumnailImage,
1720
+ entry_time: getData?.sqs?.Body?.entry_time,
1721
+ exit_time: getData?.sqs?.Body?.exit_time,
1722
+ address: getData?.sqs?.Body?.address,
1723
+ country: getData?.sqs?.Body?.country,
1724
+ state: getData?.sqs?.Body?.state,
1725
+ city: getData?.sqs?.Body?.city,
1726
+ pincode: getData?.sqs?.Body?.pincode,
1727
+ date_timestamp: getData?.sqs?.Body?.date_timestamp,
1728
+ timestamp: getData?.sqs?.Body?.timestamp,
1729
+ time_spend: getData?.sqs?.Body?.time_spend,
1730
+ temp_id: getData?.sqs?.Body?.temp_id,
1731
+ zone_name: getData?.sqs?.Body?.zone_name,
1723
1732
  folderPath: getData?.sqs?.Body?.fileDetails[0]?.outputFilePath,
1724
1733
  createdAt: new Date(),
1725
1734
  };
@@ -4939,12 +4948,31 @@ export async function getDetectionAuditFile( req, res ) {
4939
4948
  startTime: new Date(),
4940
4949
  moduleType: inputData.moduleType,
4941
4950
  };
4942
- const query = {
4943
- storeId: msg.storeId,
4944
- zoneName: msg.zoneName,
4945
- fileDate: msg.fileDate,
4946
- moduleType: inputData.moduleType,
4947
- };
4951
+ let query ={};
4952
+ switch ( inputData.moduleType ) {
4953
+ case 'open-time':
4954
+
4955
+ case 'close-time':
4956
+
4957
+ case 'mobile-detection':
4958
+
4959
+ case 'uniform-detection':
4960
+ query = {
4961
+ storeId: msg.storeId,
4962
+ fileDate: msg.fileDate,
4963
+ moduleType: inputData.moduleType,
4964
+ };
4965
+ break;
4966
+ case 'hygiene':
4967
+ query = {
4968
+ storeId: msg.storeId,
4969
+ zoneName: msg.zoneName,
4970
+ fileDate: msg.fileDate,
4971
+ moduleType: inputData.moduleType,
4972
+ };
4973
+ break;
4974
+ }
4975
+
4948
4976
  const storeRecord = {
4949
4977
  userId: req.user._id,
4950
4978
  storeId: msg.storeId,
@@ -5147,6 +5175,7 @@ export async function getDraftedData( req, res ) {
5147
5175
 
5148
5176
  export async function save( req, res ) {
5149
5177
  try {
5178
+ const url = JSON.parse( process.env.URL );
5150
5179
  const openSearch = JSON.parse( process.env.OPENSEARCH );
5151
5180
  const bucket = JSON.parse( process.env.BUCKET );
5152
5181
  const sqs = JSON.parse( process.env.SQS );
@@ -5292,6 +5321,21 @@ export async function save( req, res ) {
5292
5321
  await copyImage( copyParams );
5293
5322
  }
5294
5323
 
5324
+ if ( inputData.moduleType == 'hygiene' && inputData.employeeCount> 0 ) {
5325
+ const hygieneTaskData = {
5326
+ storeName: getStore?.storeName,
5327
+ taskName: 'Store Hygiene Check',
5328
+ question: 'A store hygiene issue has been detected. Upload a new image showing the current store condition.',
5329
+ answerType: 'descriptiveImage',
5330
+ referenceImage: [ `${output.folderPath}${tempId[0]}` ],
5331
+ zoneName: inputData?.zoneName,
5332
+ };
5333
+ await axios.post( `${url.apiDomain}/v3/task/StoreHygienetask`, hygieneTaskData, { headers: {
5334
+ 'Content-Type': 'application/json',
5335
+ 'Authorization': 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f55' },
5336
+ } );
5337
+ }
5338
+
5295
5339
  const logData = {
5296
5340
  userId: req.user._id,
5297
5341
  userName: req.user.userName,