tango-app-api-trax 3.3.1-airtelai-0 → 3.3.1-airtelai-3
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.3.1-airtelai-
|
|
3
|
+
"version": "3.3.1-airtelai-3",
|
|
4
4
|
"description": "Trax",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"nodemon": "^3.1.4",
|
|
28
28
|
"path": "^0.12.7",
|
|
29
29
|
"tango-api-schema": "^2.2.93",
|
|
30
|
-
"tango-app-api-middleware": "^3.1.
|
|
30
|
+
"tango-app-api-middleware": "^3.1.72",
|
|
31
31
|
"url": "^0.11.4",
|
|
32
32
|
"winston": "^3.13.1",
|
|
33
33
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { signedUrl, fileUpload, chunkArray, logger, sendPushNotification } from 'tango-app-api-middleware';
|
|
1
|
+
import { signedUrl, fileUpload, chunkArray, logger, sendPushNotification, sendTeamsNotification } 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';
|
|
@@ -283,6 +283,12 @@ export const create = async ( req, res ) => {
|
|
|
283
283
|
};
|
|
284
284
|
await questionService.create( sectionList ).then( async ( data ) => {
|
|
285
285
|
if ( i == inputBody.sections.length - 1 ) {
|
|
286
|
+
let actionType = 'created';
|
|
287
|
+
let teamsMsg;
|
|
288
|
+
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
289
|
+
actionType = 'Create';
|
|
290
|
+
teamsMsg = 'ClientId: '+ req.body.clientId + ', Action: '+ actionType + ', ChecklistId: '+ checkListId + ', Checklist Name: '+ inputBody.checklistName + ', UpDatedBy: '+ req.user.email;
|
|
291
|
+
sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
|
|
286
292
|
return res.sendSuccess( { checklistId: checkListId, msg: 'CheckList Created Successfully' } );
|
|
287
293
|
}
|
|
288
294
|
} ).catch( ( e ) => {
|
|
@@ -606,6 +612,11 @@ export const deleteChecklist = async ( req, res ) => {
|
|
|
606
612
|
await processedchecklist.deleteMany( { date_string: { $ne: date }, date_iso: { $gt: date }, sourceCheckList_id: req.params.checklistId, checklistStatus: { $ne: 'submit' } } );
|
|
607
613
|
logger.info( { function: 'deleteChecklist', query: { date_string: { $ne: date }, date_iso: { $gt: date }, sourceCheckList_id: req.params.checklistId, checklistStatus: { $ne: 'submit' } } } );
|
|
608
614
|
checklistDetails.save().then( () => {
|
|
615
|
+
let actionType = 'Deleted';
|
|
616
|
+
let teamsMsg;
|
|
617
|
+
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
618
|
+
teamsMsg = 'ClientId: '+ checklistDetails.client_id + ', Action: '+ actionType + ', ChecklistId: '+ req.params.checklistId + ', Checklist Name: '+ checklistDetails.checkListName + ', UpDatedBy: '+ req.user.email;
|
|
619
|
+
sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
|
|
609
620
|
return res.sendSuccess( { message: 'Checklist Deleted Successfully' } );
|
|
610
621
|
} ).catch( ( e ) => {
|
|
611
622
|
return res.sendError( e, 500 );
|
|
@@ -679,6 +690,11 @@ export const duplicateChecklist = async ( req, res ) => {
|
|
|
679
690
|
sections.push( sectionDetails );
|
|
680
691
|
}
|
|
681
692
|
await questionService.insertMany( sections );
|
|
693
|
+
let actionType = 'Duplicated';
|
|
694
|
+
let teamsMsg;
|
|
695
|
+
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
696
|
+
teamsMsg = 'ClientId: '+ checkDetails.client_id + ', Action: '+ actionType + ', ChecklistId: '+ data._id + ', Checklist Name: '+ checkDetails.checkListName + ', UpDatedBy: '+ req.user.email;
|
|
697
|
+
sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
|
|
682
698
|
return res.sendSuccess( { message: 'CheckList Duplicated Successfully' } );
|
|
683
699
|
} else {
|
|
684
700
|
return res.sendSuccess( { message: 'duplicated Successfully' } );
|
|
@@ -814,6 +830,11 @@ export const update = async ( req, res ) => {
|
|
|
814
830
|
await questionService.create( sectionList ).then( async ( data ) => {
|
|
815
831
|
sectionId.push( data._id );
|
|
816
832
|
if ( i == inputBody.sections.length - 1 ) {
|
|
833
|
+
let actionType = 'Checklist Updated';
|
|
834
|
+
let teamsMsg;
|
|
835
|
+
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
836
|
+
teamsMsg = 'ClientId: '+ req.body.clientId + ', Action: '+ actionType + ', ChecklistId: '+ checkListId + ', Checklist Name: '+ inputBody.checklistName + ', UpDatedBy: '+ req.user.email;
|
|
837
|
+
sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
|
|
817
838
|
await questionService.deleteMany( { checkListId: checkListId, client_id: req.body.clientId, _id: { $nin: sectionId } } );
|
|
818
839
|
await assignedService.updateMany( { checkListId: checkListId }, { checkListName: inputBody.checklistName } );
|
|
819
840
|
return res.sendSuccess( { checklistId: checkListId, msg: 'CheckList Created Successfully' } );
|
|
@@ -1614,6 +1635,12 @@ export const updateConfigurev1 =async ( req, res ) => {
|
|
|
1614
1635
|
futureDaysDataRemove( currentDate, req.params.checklistId, checklistDetails.checkListName, '333' );
|
|
1615
1636
|
}
|
|
1616
1637
|
}
|
|
1638
|
+
let actionType;
|
|
1639
|
+
let teamsMsg;
|
|
1640
|
+
actionType = inputBody.checkListDetails.publish ? 'configPublish' : 'configDraft';
|
|
1641
|
+
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
1642
|
+
teamsMsg = 'ClientId: '+ checklistDetails.client_id + ', Action: '+ actionType + ', ChecklistId: '+ checklistDetails._id + ', Checklist Name: '+ checklistDetails.checkListName + ', UpDatedBy: '+ req.user.email;
|
|
1643
|
+
sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
|
|
1617
1644
|
if ( response?.modifiedCount || response?.matchedCount || response?.upsertedCount ) {
|
|
1618
1645
|
return res.sendSuccess( { id, message: 'Configured Updated Successfully' } );
|
|
1619
1646
|
}
|
|
@@ -1770,6 +1797,12 @@ export const updatePublish = async ( req, res ) => {
|
|
|
1770
1797
|
createdByEmail: req.user.email,
|
|
1771
1798
|
};
|
|
1772
1799
|
await checklistLogs.create( logInsertData );
|
|
1800
|
+
let actionType;
|
|
1801
|
+
let teamsMsg;
|
|
1802
|
+
actionType = req.body.publish ? 'publish' : 'unpublish';
|
|
1803
|
+
let teamsAlertUrls = process.env.teamsAlertURL ? JSON.parse( process.env.teamsAlertURL ) : '';
|
|
1804
|
+
teamsMsg = 'ClientId: '+ getCheckDetails.client_id + ', Action: '+ actionType + ', ChecklistId: '+ getCheckDetails._id + ', Checklist Name: '+ getCheckDetails.checkListName + ', UpDatedBy: '+ req.user.email;
|
|
1805
|
+
sendTeamsNotification( teamsAlertUrls.checklist, teamsMsg );
|
|
1773
1806
|
return res.sendSuccess( { checklistName: getCheckDetails.checkListName, message: 'Updated Successfully' } );
|
|
1774
1807
|
} catch ( e ) {
|
|
1775
1808
|
logger.error( 'updatePublish erroe =>', e );
|
|
@@ -2112,11 +2145,11 @@ export const validateUserv1 = async ( req, res ) => {
|
|
|
2112
2145
|
} );
|
|
2113
2146
|
}
|
|
2114
2147
|
|
|
2148
|
+
newStoreList = [ ...new Set( newStoreList.map( ( item ) => item ) ) ];
|
|
2149
|
+
newUserList = [ ...new Set( newUserList.map( ( item ) => item ) ) ];
|
|
2150
|
+
existEmail = [ ...new Set( existEmail.map( ( item ) => item ) ) ];
|
|
2151
|
+
inActiveStores = [ ...new Set( inActiveStores.map( ( item ) => item ) ) ];
|
|
2115
2152
|
if ( ( newUserList.length || newStoreList.length || existEmail.length || inActiveStores.length ) && !req.body?.addUser ) {
|
|
2116
|
-
newStoreList = [ ...new Set( newStoreList.map( ( item ) => item ) ) ];
|
|
2117
|
-
newUserList = [ ...new Set( newUserList.map( ( item ) => item ) ) ];
|
|
2118
|
-
existEmail = [ ...new Set( existEmail.map( ( item ) => item ) ) ];
|
|
2119
|
-
inActiveStores = [ ...new Set( inActiveStores.map( ( item ) => item ) ) ];
|
|
2120
2153
|
return res.sendError( { validate: false, user: newUserList, store: newStoreList, existEmail, inActiveStores, data: assignDetails }, 400 );
|
|
2121
2154
|
}
|
|
2122
2155
|
await Promise.all( newUserList.map( async ( ele ) => {
|
|
@@ -3905,6 +3938,7 @@ export async function updateAiConfigure( req, res ) {
|
|
|
3905
3938
|
scheduleRepeatedDay: [ '01' ],
|
|
3906
3939
|
scheduleStartTime: '06:00 AM',
|
|
3907
3940
|
scheduleEndTime: '11:59 PM',
|
|
3941
|
+
enableNewDeployedStore: req.body.enableNewDeployedStore,
|
|
3908
3942
|
};
|
|
3909
3943
|
let aiResponse = await checklistService.updateOne( { checkListType: aiChecklistDetails.checkListType, client_id: req.body.clientId }, details );
|
|
3910
3944
|
let checklistId = req.body?.id || aiResponse?.upsertedId;
|
|
@@ -3916,9 +3950,11 @@ export async function updateAiConfigure( req, res ) {
|
|
|
3916
3950
|
let keyValue ={};
|
|
3917
3951
|
if ( req.body.aiConfig?.assignConfig && req.body.aiConfig?.assignConfig == 'store' && key.includes( 'startTime' ) ) {
|
|
3918
3952
|
let num = key.slice( -1 );
|
|
3919
|
-
|
|
3920
|
-
|
|
3921
|
-
|
|
3953
|
+
if ( ele[key] && ele[`configTime${num}`] ) {
|
|
3954
|
+
keyValue['time'] = ele[key];
|
|
3955
|
+
keyValue['duration'] = ele[`configTime${num}`];
|
|
3956
|
+
eventTime.push( keyValue );
|
|
3957
|
+
}
|
|
3922
3958
|
}
|
|
3923
3959
|
} );
|
|
3924
3960
|
if ( req.body.aiConfig?.assignConfig && req.body.aiConfig?.assignConfig == 'global' ) {
|
|
@@ -3988,13 +4024,13 @@ export async function updateAiConfigure( req, res ) {
|
|
|
3988
4024
|
createdByName: req.user.userName,
|
|
3989
4025
|
sourceCheckList_id: checklistId,
|
|
3990
4026
|
checkListType: aiChecklistDetails.checkListType,
|
|
3991
|
-
storeCount:
|
|
4027
|
+
storeCount: storeData.length,
|
|
3992
4028
|
questionCount: 0,
|
|
3993
4029
|
publishDate: new Date(),
|
|
3994
4030
|
locationCount: 0,
|
|
3995
4031
|
scheduleRepeatedType: 'daily',
|
|
3996
4032
|
client_id: req.body.clientId,
|
|
3997
|
-
aiStoreList:
|
|
4033
|
+
aiStoreList: storeData?.length ? storeData.map( ( store ) => store.store_id ) : [],
|
|
3998
4034
|
};
|
|
3999
4035
|
await processedchecklist.updateOne( { date_string: dayjs().format( 'YYYY-MM-DD' ), sourceCheckList_id: checklistId, checkListType: aiChecklistDetails.checkListType }, data );
|
|
4000
4036
|
}
|