tango-app-api-audit 3.4.43 → 3.4.45
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,42 +1,42 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "tango-app-api-audit",
|
|
3
|
-
"version": "3.4.
|
|
4
|
-
"description": "audit & audit metrics apis",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"type": "module",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"start": "nodemon --exec \"eslint --fix . && node index.js\""
|
|
9
|
-
},
|
|
10
|
-
"engines": {
|
|
11
|
-
"node": ">=18.10.0"
|
|
12
|
-
},
|
|
13
|
-
"author": "praveenraj",
|
|
14
|
-
"license": "ISC",
|
|
15
|
-
"dependencies": {
|
|
16
|
-
"adm-zip": "^0.5.15",
|
|
17
|
-
"aws-sdk": "^2.1643.0",
|
|
18
|
-
"axios": "^1.7.9",
|
|
19
|
-
"dayjs": "^1.11.11",
|
|
20
|
-
"dotenv": "^16.4.5",
|
|
21
|
-
"express": "^4.19.2",
|
|
22
|
-
"form-data": "^4.0.1",
|
|
23
|
-
"handlebars": "^4.7.8",
|
|
24
|
-
"joi-to-swagger": "^6.2.0",
|
|
25
|
-
"lodash": "^4.17.21",
|
|
26
|
-
"mongodb": "^6.7.0",
|
|
27
|
-
"nodemon": "^3.1.3",
|
|
28
|
-
"swagger-ui-express": "^5.0.1",
|
|
29
|
-
"tango-api-schema": "^2.2.45",
|
|
30
|
-
"tango-app-api-middleware": "^3.1.48",
|
|
31
|
-
"winston": "^3.13.0",
|
|
32
|
-
"winston-daily-rotate-file": "^5.0.0"
|
|
33
|
-
},
|
|
34
|
-
"devDependencies": {
|
|
35
|
-
"eslint": "^8.57.0",
|
|
36
|
-
"eslint-config-google": "^0.14.0",
|
|
37
|
-
"eslint-config-semistandard": "^17.0.0",
|
|
38
|
-
"eslint-config-standard": "^17.1.0",
|
|
39
|
-
"eslint-plugin-import": "^2.29.1",
|
|
40
|
-
"eslint-plugin-promise": "^6.2.0"
|
|
41
|
-
}
|
|
42
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "tango-app-api-audit",
|
|
3
|
+
"version": "3.4.45",
|
|
4
|
+
"description": "audit & audit metrics apis",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "nodemon --exec \"eslint --fix . && node index.js\""
|
|
9
|
+
},
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=18.10.0"
|
|
12
|
+
},
|
|
13
|
+
"author": "praveenraj",
|
|
14
|
+
"license": "ISC",
|
|
15
|
+
"dependencies": {
|
|
16
|
+
"adm-zip": "^0.5.15",
|
|
17
|
+
"aws-sdk": "^2.1643.0",
|
|
18
|
+
"axios": "^1.7.9",
|
|
19
|
+
"dayjs": "^1.11.11",
|
|
20
|
+
"dotenv": "^16.4.5",
|
|
21
|
+
"express": "^4.19.2",
|
|
22
|
+
"form-data": "^4.0.1",
|
|
23
|
+
"handlebars": "^4.7.8",
|
|
24
|
+
"joi-to-swagger": "^6.2.0",
|
|
25
|
+
"lodash": "^4.17.21",
|
|
26
|
+
"mongodb": "^6.7.0",
|
|
27
|
+
"nodemon": "^3.1.3",
|
|
28
|
+
"swagger-ui-express": "^5.0.1",
|
|
29
|
+
"tango-api-schema": "^2.2.45",
|
|
30
|
+
"tango-app-api-middleware": "^3.1.48",
|
|
31
|
+
"winston": "^3.13.0",
|
|
32
|
+
"winston-daily-rotate-file": "^5.0.0"
|
|
33
|
+
},
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"eslint": "^8.57.0",
|
|
36
|
+
"eslint-config-google": "^0.14.0",
|
|
37
|
+
"eslint-config-semistandard": "^17.0.0",
|
|
38
|
+
"eslint-config-standard": "^17.1.0",
|
|
39
|
+
"eslint-plugin-import": "^2.29.1",
|
|
40
|
+
"eslint-plugin-promise": "^6.2.0"
|
|
41
|
+
}
|
|
42
|
+
}
|
|
@@ -4956,13 +4956,47 @@ export async function auditViewLogs( req, res ) {
|
|
|
4956
4956
|
],
|
|
4957
4957
|
};
|
|
4958
4958
|
break;
|
|
4959
|
+
case 'scrum':
|
|
4960
|
+
case 'cleaning':
|
|
4961
|
+
logsQuery = {
|
|
4962
|
+
'size': 100,
|
|
4963
|
+
'query': {
|
|
4964
|
+
'bool': {
|
|
4965
|
+
'must': [
|
|
4966
|
+
{
|
|
4967
|
+
'term': {
|
|
4968
|
+
'logData.fileDate.keyword': inputData.fileDate,
|
|
4969
|
+
},
|
|
4970
|
+
},
|
|
4971
|
+
{
|
|
4972
|
+
'term': {
|
|
4973
|
+
'logData.storeId.keyword': inputData.storeId,
|
|
4974
|
+
},
|
|
4975
|
+
},
|
|
4976
|
+
{
|
|
4977
|
+
'term': {
|
|
4978
|
+
'logData.moduleType.keyword': inputData.moduleType,
|
|
4979
|
+
},
|
|
4980
|
+
},
|
|
4981
|
+
{
|
|
4982
|
+
'terms': {
|
|
4983
|
+
'logSubType.keyword': [ 'auditDone', 'reTrigger' ],
|
|
4984
|
+
},
|
|
4985
|
+
},
|
|
4986
|
+
],
|
|
4987
|
+
},
|
|
4988
|
+
},
|
|
4989
|
+
'sort': [
|
|
4990
|
+
{ createdAt: { order: 'desc' } },
|
|
4991
|
+
],
|
|
4992
|
+
};
|
|
4993
|
+
break;
|
|
4959
4994
|
default:
|
|
4960
4995
|
return res.sendError( 'Please give valid modueType', 400 );
|
|
4961
4996
|
}
|
|
4962
4997
|
}
|
|
4963
4998
|
logger.info( { query: logsQuery, message: 'unattended' } );
|
|
4964
4999
|
const logs = await getOpenSearchData( parsedOpenSearch.auditLog, logsQuery );
|
|
4965
|
-
logger.info( { logs: logs.body.hits, inputData: inputData, auditLog: parsedOpenSearch.auditLog } );
|
|
4966
5000
|
if ( logs.body.hits.hits.length > 0 ) {
|
|
4967
5001
|
const sourcesArray = logs.body.hits.hits.map( ( hit ) => hit._source );
|
|
4968
5002
|
for ( const i of sourcesArray ) { // Loop through sourcesArray
|
|
@@ -60,7 +60,17 @@ export async function workSpace( req, res ) {
|
|
|
60
60
|
$cond: [
|
|
61
61
|
{ $eq: [ inputData.moduleType, 'hygiene' ] }, '$auditConfigs.traxQueueName.hygiene', {
|
|
62
62
|
$cond: [
|
|
63
|
-
{ $eq: [ inputData.moduleType, 'camera-angle-change' ] }, '$auditConfigs.traxQueueName.cameraAngleChange',
|
|
63
|
+
{ $eq: [ inputData.moduleType, 'camera-angle-change' ] }, '$auditConfigs.traxQueueName.cameraAngleChange',
|
|
64
|
+
{
|
|
65
|
+
$cond: [
|
|
66
|
+
{ $eq: [ inputData.moduleType, 'eye-test-camera' ] }, '$auditConfigs.traxQueueName.eyeTestCamera',
|
|
67
|
+
{
|
|
68
|
+
$cond: [
|
|
69
|
+
{ $eq: [ inputData.moduleType, 'cleaning' ] }, '$auditConfigs.traxQueueName.cleaning', '$auditConfigs.traxQueueName.scrum' ],
|
|
70
|
+
},
|
|
71
|
+
],
|
|
72
|
+
},
|
|
73
|
+
],
|
|
64
74
|
},
|
|
65
75
|
|
|
66
76
|
],
|
|
@@ -466,6 +476,7 @@ export async function getAuditFile( req, res ) {
|
|
|
466
476
|
try {
|
|
467
477
|
const inputData = req.query;
|
|
468
478
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
479
|
+
const url = JSON.parse( process.env.URL );
|
|
469
480
|
const previousDate = new Date( new Date() - 1 );
|
|
470
481
|
const data = await getDate( previousDate, new Date() );
|
|
471
482
|
const start = data.start;
|
|
@@ -557,10 +568,23 @@ export async function getAuditFile( req, res ) {
|
|
|
557
568
|
moduleType: userDetails[0].moduleType,
|
|
558
569
|
};
|
|
559
570
|
break;
|
|
571
|
+
case 'cleaning':
|
|
572
|
+
query ={
|
|
573
|
+
storeId: userDetails[0].storeId,
|
|
574
|
+
fileDate: userDetails[0].fileDate,
|
|
575
|
+
moduleType: userDetails[0].moduleType,
|
|
576
|
+
};
|
|
577
|
+
break;
|
|
578
|
+
case 'scrum':
|
|
579
|
+
query ={
|
|
580
|
+
storeId: userDetails[0].storeId,
|
|
581
|
+
fileDate: userDetails[0].fileDate,
|
|
582
|
+
moduleType: userDetails[0].moduleType,
|
|
583
|
+
};
|
|
584
|
+
break;
|
|
560
585
|
default:
|
|
561
586
|
return res.sendError( 'Please give valid moduleType', 400 );
|
|
562
587
|
}
|
|
563
|
-
logger.info( { query: query } );
|
|
564
588
|
const traxInfo = await findOneTraxAuditData( query );
|
|
565
589
|
if ( !traxInfo ) {
|
|
566
590
|
return res.sendError( 'The source record not found', 400 );
|
|
@@ -636,6 +660,8 @@ export async function getAuditFile( req, res ) {
|
|
|
636
660
|
break;
|
|
637
661
|
case 'unattended-customer':
|
|
638
662
|
case 'left-in-middle':
|
|
663
|
+
case 'cleaning':
|
|
664
|
+
case 'scrum':
|
|
639
665
|
for ( let i =0; i< msg.fileDetails.length; i++ ) {
|
|
640
666
|
const files = [];
|
|
641
667
|
const params ={
|
|
@@ -645,18 +671,14 @@ export async function getAuditFile( req, res ) {
|
|
|
645
671
|
};
|
|
646
672
|
const list = await listFileByPath( params );
|
|
647
673
|
const folderPath = list.data;
|
|
648
|
-
logger.info( { folderPath: list, params: params, list: list } );
|
|
649
674
|
if ( folderPath?.length ) {
|
|
650
675
|
for ( let i = 0; i < folderPath.length; i++ ) {
|
|
651
|
-
//
|
|
652
|
-
//
|
|
653
|
-
//
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
};
|
|
658
|
-
const data = await signedUrl( signedParams );
|
|
659
|
-
|
|
676
|
+
// const signedParams ={
|
|
677
|
+
// Bucket: msg.inputBucketName,
|
|
678
|
+
// file_path: folderPath[i].Key,
|
|
679
|
+
// };
|
|
680
|
+
const BucketCDN = url.traxAuditInput;
|
|
681
|
+
const data = `${BucketCDN}${ folderPath[i].Key}`;
|
|
660
682
|
files.push(
|
|
661
683
|
data,
|
|
662
684
|
);
|
|
@@ -790,7 +812,7 @@ export async function getAuditFile( req, res ) {
|
|
|
790
812
|
address: storeInfo?.address,
|
|
791
813
|
customerId: msg.tempId,
|
|
792
814
|
moduleType: inputData.moduleType,
|
|
793
|
-
value: inputData.moduleType == 'left-in-middle'? 'Employee Left in Middle ' : ( inputData.moduleType ).split( '-' ).join( ' ' ),
|
|
815
|
+
value: inputData.moduleType == 'left-in-middle'? 'Employee Left in Middle' : inputData.moduleType == 'cleaning'? 'Store Cleaning Audit ': inputData.moduleType == 'scrum'? 'Scrum Identification':( inputData.moduleType ).split( '-' ).join( ' ' ),
|
|
794
816
|
fileDate: msg.fileDate,
|
|
795
817
|
question: msg.question,
|
|
796
818
|
questionType: msg.questionType,
|
|
@@ -864,6 +886,8 @@ export async function getUpdatedFile( req, res ) {
|
|
|
864
886
|
break;
|
|
865
887
|
case 'unattended-customer':
|
|
866
888
|
case 'left-in-middle':
|
|
889
|
+
case 'cleaning':
|
|
890
|
+
case 'scrum':
|
|
867
891
|
for ( let i =0; i< msg.fileDetails.length; i++ ) {
|
|
868
892
|
const files = [];
|
|
869
893
|
const params ={
|
|
@@ -876,9 +900,6 @@ export async function getUpdatedFile( req, res ) {
|
|
|
876
900
|
logger.info( { folderPath: list, params: params, list: list } );
|
|
877
901
|
if ( folderPath?.length ) {
|
|
878
902
|
for ( let i = 0; i < folderPath.length; i++ ) {
|
|
879
|
-
// const img = folderPath[i].Key.split( '/' );
|
|
880
|
-
// const image = img[3].split( '.' );
|
|
881
|
-
// const indexes = image[0].split( '_' );
|
|
882
903
|
const signedParams ={
|
|
883
904
|
Bucket: msg.inputBucketName,
|
|
884
905
|
file_path: folderPath[i].Key,
|
|
@@ -1000,6 +1021,8 @@ export async function saveBinary( req, res ) {
|
|
|
1000
1021
|
const value = inputData.moduleType? inputData.moduleType.replace( /-/g, ' ' ) : '';
|
|
1001
1022
|
switch ( inputData.moduleType ) {
|
|
1002
1023
|
case 'unattended-customer':
|
|
1024
|
+
case 'cleaning':
|
|
1025
|
+
case 'scrum':
|
|
1003
1026
|
let unattendedquery ={
|
|
1004
1027
|
_id: inputData.auditId,
|
|
1005
1028
|
storeId: inputData.storeId,
|
|
@@ -1019,6 +1042,65 @@ export async function saveBinary( req, res ) {
|
|
|
1019
1042
|
if ( updatDataunattended.modifiedCount==0 ) {
|
|
1020
1043
|
return res.sendError( 'Update failed, it may be invalid request', 400 );
|
|
1021
1044
|
}
|
|
1045
|
+
if ( [ 'cleaning', 'scrum' ].includes( inputData.moduleType ) ) {
|
|
1046
|
+
let filter= [
|
|
1047
|
+
{
|
|
1048
|
+
'term': {
|
|
1049
|
+
'storeId.keyword': inputData.storeId,
|
|
1050
|
+
},
|
|
1051
|
+
},
|
|
1052
|
+
{
|
|
1053
|
+
'term': {
|
|
1054
|
+
'fileDate.keyword': inputData.fileDate,
|
|
1055
|
+
},
|
|
1056
|
+
},
|
|
1057
|
+
{
|
|
1058
|
+
'term': {
|
|
1059
|
+
'moduleType.keyword': inputData.moduleType,
|
|
1060
|
+
},
|
|
1061
|
+
},
|
|
1062
|
+
];
|
|
1063
|
+
let searchQuery={
|
|
1064
|
+
'size': 1,
|
|
1065
|
+
'query': {
|
|
1066
|
+
'bool': {
|
|
1067
|
+
'must': filter,
|
|
1068
|
+
},
|
|
1069
|
+
},
|
|
1070
|
+
};
|
|
1071
|
+
const [ getStore, getClient ] = await Promise.all( [ findOneStore( { storeId: inputData.storeId }, { storeName: 1, storeProfile: 1, spocDetails: 1 } ), findOneClient( { clientId: req.userAudit?.clientId }, { clientName: 1 } ) ] );
|
|
1072
|
+
const getFilePath = await findOneTraxAuditData(
|
|
1073
|
+
{
|
|
1074
|
+
fileDate: inputData.fileDate,
|
|
1075
|
+
storeId: inputData.storeId,
|
|
1076
|
+
moduleType: inputData.moduleType,
|
|
1077
|
+
},
|
|
1078
|
+
);
|
|
1079
|
+
const output = {
|
|
1080
|
+
clientId: req.userAudit?.clientId,
|
|
1081
|
+
clientName: getClient?.clientName,
|
|
1082
|
+
storeId: inputData.storeId,
|
|
1083
|
+
storeName: getStore?.storeName,
|
|
1084
|
+
question: getFilePath?.sqs?.Body?.question,
|
|
1085
|
+
spocName: getStore?.spocDetails? getStore?.spocDetails[0]?.name : '',
|
|
1086
|
+
spocEmail: getStore?.spocDetails? getStore?.spocDetails[0]?.email:'',
|
|
1087
|
+
spocContact: getStore?.spocDetails? getStore?.spocDetails[0].contact:'',
|
|
1088
|
+
address: getStore?.storeProfile?.address,
|
|
1089
|
+
fileDate: inputData.fileDate,
|
|
1090
|
+
moduleType: inputData.moduleType,
|
|
1091
|
+
Answer: inputData.answer,
|
|
1092
|
+
inputBucketName: getFilePath?.sqs?.Body?.inputBucketName,
|
|
1093
|
+
folderPath: [ 'cleaning', 'scrum' ].includes( inputData.moduleType ) ? getFilePath?.sqs?.Body?.fileDetails[0]?.outputFilePath : folderPath.split( '/' ).slice( 0, -1 ).join( '/' ) + '/',
|
|
1094
|
+
createdAt: new Date(),
|
|
1095
|
+
};
|
|
1096
|
+
const searchData= await getOpenSearchData( openSearch.traxDetectionOutput, searchQuery );
|
|
1097
|
+
logger.info( { length: searchData?.body?.hits?.hits?.length, _id: searchData?.body?.hits?.hits[0]?._id, output: output } );
|
|
1098
|
+
if ( searchData?.body?.hits?.hits?.length >0 ) {
|
|
1099
|
+
await updateOpenSearchData( openSearch.traxDetectionOutput, searchData?.body?.hits?.hits[0]?._id, { doc: output } );
|
|
1100
|
+
} else {
|
|
1101
|
+
await insertOpenSearchData( openSearch.traxDetectionOutput, output );
|
|
1102
|
+
}
|
|
1103
|
+
}
|
|
1022
1104
|
const logData2 = {
|
|
1023
1105
|
userId: req.user._id,
|
|
1024
1106
|
userName: req.user.userName,
|
|
@@ -1258,7 +1340,7 @@ export async function saveBinary( req, res ) {
|
|
|
1258
1340
|
formData.append( 'storeName', stores?.storeName );
|
|
1259
1341
|
formData.append( 'taskName', 'EyeTest QR Verification' );
|
|
1260
1342
|
formData.append( 'answerType', 'image' );
|
|
1261
|
-
formData.append( 'question', 'Please
|
|
1343
|
+
formData.append( 'question', 'Please upload the QR image pasted in this clinic' );
|
|
1262
1344
|
formData.append( 'scheduleDate', formattedDate );
|
|
1263
1345
|
formData.append( 'scheduleEndTime', '11:00 PM' );
|
|
1264
1346
|
|
|
@@ -1612,6 +1694,8 @@ export async function userAuditHistory( req, res ) {
|
|
|
1612
1694
|
temp['User Comments'] = element.userComments;
|
|
1613
1695
|
break;
|
|
1614
1696
|
case 'left-in-middle':
|
|
1697
|
+
case 'cleaning':
|
|
1698
|
+
case 'scrum':
|
|
1615
1699
|
temp['Question'] = element.question;
|
|
1616
1700
|
temp['Result'] = element.answer;
|
|
1617
1701
|
temp['User Comments'] = element.userComments;
|
|
@@ -2549,6 +2633,8 @@ export async function storeMetrics( req, res ) {
|
|
|
2549
2633
|
temp['Result'] = element.answer;
|
|
2550
2634
|
break;
|
|
2551
2635
|
case 'left-in-middle':
|
|
2636
|
+
case 'cleaning':
|
|
2637
|
+
case 'scrum':
|
|
2552
2638
|
temp['Question'] = element.question;
|
|
2553
2639
|
temp['User Comments'] = element.userComments;
|
|
2554
2640
|
temp['Status'] = toCamelCase( element.auditStatus );
|
|
@@ -3119,6 +3205,8 @@ export async function pendingSummaryTable( req, res ) {
|
|
|
3119
3205
|
temp['Question'] = element.question;
|
|
3120
3206
|
break;
|
|
3121
3207
|
case 'left-in-middle':
|
|
3208
|
+
case 'cleaning':
|
|
3209
|
+
case 'scrum':
|
|
3122
3210
|
temp['Question'] = element.question;
|
|
3123
3211
|
break;
|
|
3124
3212
|
case 'mobile-detection':
|
|
@@ -3681,6 +3769,8 @@ export async function overviewTable( req, res ) {
|
|
|
3681
3769
|
temp['Status'] = toCamelCase( element.auditStatus );
|
|
3682
3770
|
break;
|
|
3683
3771
|
case 'left-in-middle':
|
|
3772
|
+
case 'cleaning':
|
|
3773
|
+
case 'scrum':
|
|
3684
3774
|
temp['Question'] = element.question;
|
|
3685
3775
|
temp['User Comments'] = element.userComments;
|
|
3686
3776
|
temp['Audit Type'] = element.auditType;
|
|
@@ -4316,7 +4406,7 @@ export async function save( req, res ) {
|
|
|
4316
4406
|
},
|
|
4317
4407
|
};
|
|
4318
4408
|
|
|
4319
|
-
const searchData= await getOpenSearchData( openSearch.
|
|
4409
|
+
const searchData= await getOpenSearchData( openSearch.traxDetectionOutput, searchQuery );
|
|
4320
4410
|
logger.info( { length: searchData?.body?.hits?.hits?.length, _id: searchData?.body?.hits?.hits[0]?._id, output: output } );
|
|
4321
4411
|
if ( searchData?.body?.hits?.hits?.length >0 ) {
|
|
4322
4412
|
await updateOpenSearchData( openSearch.traxDetectionOutput, searchData?.body?.hits?.hits[0]?._id, { doc: output } );
|