tango-app-api-client 3.0.44-dev → 3.0.45-dev
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 +2 -2
- package/src/controllers/client.controllers.js +93 -23
- package/src/dtos/client.dtos.js +21 -0
- package/src/routes/client.routes.js +8 -2
- package/src/service/client.service.js +9 -0
- package/src/service/store.service.js +4 -0
- package/src/service/userAssignedStore.service.js +13 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-client",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.45-dev",
|
|
4
4
|
"description": "client",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -25,8 +25,8 @@
|
|
|
25
25
|
"mongodb": "^6.3.0",
|
|
26
26
|
"nodemon": "^3.0.3",
|
|
27
27
|
"swagger-ui-express": "^5.0.0",
|
|
28
|
+
"tango-api-schema": "^2.0.104",
|
|
28
29
|
"tango-app-api-middleware": "^1.0.72-test",
|
|
29
|
-
"tango-api-schema": "^2.0.103",
|
|
30
30
|
"winston": "^3.11.0",
|
|
31
31
|
"winston-daily-rotate-file": "^5.0.0"
|
|
32
32
|
},
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { billingDetailsUpdate, brandInfoUpdate, domainDetailsConfigurationUpdate, featureConfigurationUpdate, getClientData, signatoryDetailsUpdate, ticketConfigurationUpdate, documentsUpdate, getUserData, auditConfigurationUpdate, auditConfigurationGet, CsmUsersGet, OpsUsersGet, userConfigurationUpdate, findClient, aggregateClient, createAuditQueue, findOne, insert, update, findOneClient } from '../service/client.service.js';
|
|
1
|
+
import { billingDetailsUpdate, brandInfoUpdate, domainDetailsConfigurationUpdate, featureConfigurationUpdate, getClientData, signatoryDetailsUpdate, ticketConfigurationUpdate, documentsUpdate, getUserData, auditConfigurationUpdate, auditConfigurationGet, CsmUsersGet, OpsUsersGet, userConfigurationUpdate, findClient, aggregateClient, createAuditQueue, findOne, insert, update, findOneClient, updateOneClient } from '../service/client.service.js';
|
|
2
2
|
import { checkFileExist, fileUpload, signedUrl, chunkArray, download, logger, getOpenSearchData, insertOpenSearchData, appConfig, sendEmailWithSES } from 'tango-app-api-middleware';
|
|
3
3
|
import { countDocumentsUser, findOneAndUpdateUser, findOneUser, getUserNameEmailById, updateManyUser } from '../service/user.service.js';
|
|
4
|
-
import { aggregateStore, countDocumentsStore, updateManyStore } from '../service/store.service.js';
|
|
4
|
+
import { aggregateStore, countDocumentsStore, findOneStore, updateManyStore } from '../service/store.service.js';
|
|
5
5
|
import { aggregateCamera, countDocumentsCamera, updateManyCamera } from '../service/camera.service.js';
|
|
6
6
|
import _ from 'lodash';
|
|
7
7
|
import { findOneStandaredRole } from '../service/standaredRole.service.js';
|
|
8
|
-
import { aggregateUserAssignedStore } from '../service/userAssignedStore.service.js';
|
|
8
|
+
import { aggregateUserAssignedStore, deleteOneAssignedStore, updateOneUserAssignedStore } from '../service/userAssignedStore.service.js';
|
|
9
9
|
import { aggregateTickets } from '../service/tangoticket.service.js';
|
|
10
10
|
import { join } from 'path';
|
|
11
11
|
import { readFileSync } from 'fs';
|
|
@@ -188,7 +188,9 @@ export async function create( req, res ) {
|
|
|
188
188
|
logType: 'brandDetails',
|
|
189
189
|
logSubType: 'brandApproval',
|
|
190
190
|
changes: [ insertedClientRecord.clientName ],
|
|
191
|
+
showTo: [],
|
|
191
192
|
eventType: 'approve',
|
|
193
|
+
showTo: [ 'client', 'tango' ],
|
|
192
194
|
};
|
|
193
195
|
|
|
194
196
|
await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
@@ -210,6 +212,7 @@ export async function create( req, res ) {
|
|
|
210
212
|
date: new Date(),
|
|
211
213
|
changes: [ `${convertTitleCase( leadRecord?.planDetails?.product[index] )} trial started` ],
|
|
212
214
|
eventType: '',
|
|
215
|
+
showTo: [ 'client', 'tango' ],
|
|
213
216
|
};
|
|
214
217
|
|
|
215
218
|
await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
@@ -291,6 +294,16 @@ export async function getClients( req, res ) {
|
|
|
291
294
|
$match: {
|
|
292
295
|
userEmail: req?.user?.email,
|
|
293
296
|
assignedType: { $eq: 'client' },
|
|
297
|
+
$expr: {
|
|
298
|
+
$cond: {
|
|
299
|
+
if: { $and: [
|
|
300
|
+
{ $eq: [ '$userType', 'tango' ] },
|
|
301
|
+
{ $eq: [ '$tangoUserType', 'csm' ] },
|
|
302
|
+
] },
|
|
303
|
+
then: { $eq: [ '$isClientApproved', true ] },
|
|
304
|
+
else: true,
|
|
305
|
+
},
|
|
306
|
+
},
|
|
294
307
|
},
|
|
295
308
|
},
|
|
296
309
|
{
|
|
@@ -472,7 +485,7 @@ export async function detailedAllClientCount( req, res ) {
|
|
|
472
485
|
},
|
|
473
486
|
];
|
|
474
487
|
const result = await aggregateClient( query );
|
|
475
|
-
const activeStores = await countDocumentsStore( { status: 'active' } );
|
|
488
|
+
const activeStores = await countDocumentsStore( { 'status': 'active', 'edge.firstFile': true } );
|
|
476
489
|
const activeCameras = await countDocumentsCamera( { isUp: true, isActivated: true } );
|
|
477
490
|
if ( result.length == 0 ) {
|
|
478
491
|
return res.sendError( 'No Data Found', 204 );
|
|
@@ -526,6 +539,7 @@ export async function updateBrandInfo( req, res ) {
|
|
|
526
539
|
logSubType: 'brandInfo',
|
|
527
540
|
changes: updateKeys,
|
|
528
541
|
eventType: 'update',
|
|
542
|
+
showTo: [ 'client', 'tango' ],
|
|
529
543
|
};
|
|
530
544
|
|
|
531
545
|
if ( updateKeys.length ) {
|
|
@@ -622,6 +636,7 @@ export async function updateBillingDetails( req, res ) {
|
|
|
622
636
|
logSubType: 'billingDetails',
|
|
623
637
|
changes: updateKeys,
|
|
624
638
|
eventType: 'update',
|
|
639
|
+
showTo: [ 'client', 'tango' ],
|
|
625
640
|
};
|
|
626
641
|
|
|
627
642
|
if ( updateKeys.length ) {
|
|
@@ -663,6 +678,7 @@ export async function updateSignatoryDetails( req, res ) {
|
|
|
663
678
|
logSubType: 'signatoryDetails',
|
|
664
679
|
changes: updateKeys,
|
|
665
680
|
eventType: 'update',
|
|
681
|
+
showTo: [ 'client', 'tango' ],
|
|
666
682
|
};
|
|
667
683
|
|
|
668
684
|
if ( updateKeys.length ) {
|
|
@@ -709,6 +725,7 @@ export async function updateTicketConfiguration( req, res ) {
|
|
|
709
725
|
logSubType: 'ticketConfig',
|
|
710
726
|
changes: updateKeys,
|
|
711
727
|
eventType: 'update',
|
|
728
|
+
showTo: [ 'tango' ],
|
|
712
729
|
};
|
|
713
730
|
|
|
714
731
|
if ( updateKeys.length ) {
|
|
@@ -797,6 +814,7 @@ export async function updateFeatureConfiguration( req, res ) {
|
|
|
797
814
|
logSubType: 'featureConfig',
|
|
798
815
|
changes: updateKeys,
|
|
799
816
|
eventType: 'update',
|
|
817
|
+
showTo: [ 'client', 'tango' ],
|
|
800
818
|
};
|
|
801
819
|
if ( updateKeys.length ) {
|
|
802
820
|
await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
@@ -838,6 +856,7 @@ export async function domainDetailsConfiguration( req, res ) {
|
|
|
838
856
|
logSubType: 'domainDetails',
|
|
839
857
|
changes: updateKeys,
|
|
840
858
|
eventType: 'update',
|
|
859
|
+
showTo: [ 'client', 'tango' ],
|
|
841
860
|
};
|
|
842
861
|
|
|
843
862
|
if ( updateKeys.length ) {
|
|
@@ -951,6 +970,7 @@ export async function updateDocuments( req, res ) {
|
|
|
951
970
|
logSubType: 'documentUpload',
|
|
952
971
|
changes: updateKeys,
|
|
953
972
|
eventType: 'update',
|
|
973
|
+
showTo: [ 'client', 'tango' ],
|
|
954
974
|
};
|
|
955
975
|
|
|
956
976
|
if ( updateKeys.length ) {
|
|
@@ -991,35 +1011,37 @@ export async function getAuditConfiguration( req, res ) {
|
|
|
991
1011
|
export async function auditConfiguration( req, res ) {
|
|
992
1012
|
try {
|
|
993
1013
|
for ( let i = 0; i < req.body?.length; i++ ) {
|
|
1014
|
+
const previousStore = await findOneStore( { storeId: req.body[i].storeId }, { auditConfigs: 1, _id: 0 } );
|
|
994
1015
|
await auditConfigurationUpdate( {
|
|
995
1016
|
storeId: req.body[i].storeId,
|
|
996
1017
|
count: req.body[i].count,
|
|
997
1018
|
iteration: req.body[i].iteration,
|
|
998
1019
|
ratio: normalizeNumber( req.body[i].ratio, 0, 100 ),
|
|
999
1020
|
} );
|
|
1000
|
-
}
|
|
1001
1021
|
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1022
|
+
const logObj = {
|
|
1023
|
+
clientId: req.params?.id,
|
|
1024
|
+
userName: req.user?.userName,
|
|
1025
|
+
email: req.user?.email,
|
|
1026
|
+
date: new Date(),
|
|
1027
|
+
logType: 'configuration',
|
|
1028
|
+
logSubType: 'auditConfig',
|
|
1029
|
+
eventType: 'update',
|
|
1030
|
+
showTo: [ 'tango' ],
|
|
1031
|
+
changes: [ `Audit config for store id ${req.body[i].storeId}` ],
|
|
1032
|
+
storeId: req.body[i].storeId,
|
|
1033
|
+
previous: previousStore,
|
|
1034
|
+
current: {
|
|
1035
|
+
storeId: req.body[i].storeId,
|
|
1036
|
+
count: req.body[i].count,
|
|
1037
|
+
iteration: req.body[i].iteration,
|
|
1038
|
+
ratio: normalizeNumber( req.body[i].ratio, 0, 100 ),
|
|
1039
|
+
},
|
|
1040
|
+
};
|
|
1017
1041
|
|
|
1018
|
-
|
|
1019
|
-
logObj.changes = [ `Audit config bulk` ];
|
|
1042
|
+
await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
1020
1043
|
}
|
|
1021
1044
|
|
|
1022
|
-
await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
1023
1045
|
|
|
1024
1046
|
res.sendSuccess( { result: 'Updated Successfully' } );
|
|
1025
1047
|
} catch ( error ) {
|
|
@@ -1057,6 +1079,15 @@ export async function clientList( req, res ) {
|
|
|
1057
1079
|
$match: {
|
|
1058
1080
|
userEmail: { $eq: req?.user?.email },
|
|
1059
1081
|
userType: 'tango',
|
|
1082
|
+
$expr: {
|
|
1083
|
+
$cond: {
|
|
1084
|
+
if: { $and: [
|
|
1085
|
+
{ $eq: [ '$tangoUserType', 'csm' ] },
|
|
1086
|
+
] },
|
|
1087
|
+
then: { $eq: [ '$isClientApproved', true ] },
|
|
1088
|
+
else: true,
|
|
1089
|
+
},
|
|
1090
|
+
},
|
|
1060
1091
|
|
|
1061
1092
|
},
|
|
1062
1093
|
}, {
|
|
@@ -1461,6 +1492,14 @@ export async function getActivityLogs( req, res ) {
|
|
|
1461
1492
|
} );
|
|
1462
1493
|
}
|
|
1463
1494
|
|
|
1495
|
+
query.query.bool.must.push(
|
|
1496
|
+
{
|
|
1497
|
+
'terms': {
|
|
1498
|
+
'showTo.keyword': [ req.user.userType ],
|
|
1499
|
+
},
|
|
1500
|
+
},
|
|
1501
|
+
);
|
|
1502
|
+
|
|
1464
1503
|
const logs = await getOpenSearchData( appConfig.opensearch.activityLog, query );
|
|
1465
1504
|
|
|
1466
1505
|
const hits = logs?.body?.hits?.hits;
|
|
@@ -1514,3 +1553,34 @@ async function getApi( url ) {
|
|
|
1514
1553
|
}
|
|
1515
1554
|
}
|
|
1516
1555
|
|
|
1556
|
+
|
|
1557
|
+
export async function csmAssignConfirmation( req, res ) {
|
|
1558
|
+
try {
|
|
1559
|
+
const client = await findOneClient( { clientId: req.query.clientId }, { notifyCsmAssign: 1, _id: 0 } );
|
|
1560
|
+
if ( !client ) {
|
|
1561
|
+
res.sendError( 'No data found', 204 );
|
|
1562
|
+
}
|
|
1563
|
+
res.sendSuccess( client );
|
|
1564
|
+
} catch ( error ) {
|
|
1565
|
+
logger.error( { error: error, message: req.params, function: 'csmAssignConfirmation' } );
|
|
1566
|
+
return res.sendError( 'Internal Server Error', 500 );
|
|
1567
|
+
}
|
|
1568
|
+
}
|
|
1569
|
+
|
|
1570
|
+
export async function clientCsmAssignAction( req, res ) {
|
|
1571
|
+
try {
|
|
1572
|
+
await updateOneClient( { clientId: req.query.clientId }, { notifyCsmAssign: false } );
|
|
1573
|
+
if ( req.body.action === 'approve' ) {
|
|
1574
|
+
await updateOneUserAssignedStore( { clientId: req.query.clientId, tangoUserType: 'csm', assignedType: 'client' }, { isClientApproved: true } );
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1577
|
+
if ( req.body.action === 'decline' ) {
|
|
1578
|
+
await deleteOneAssignedStore( { clientId: req.query.clientId, tangoUserType: 'csm', assignedType: 'client' } );
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
res.sendSuccess( 'Updated Succesfully' );
|
|
1582
|
+
} catch ( error ) {
|
|
1583
|
+
logger.error( { error: error, message: req.params, function: 'csmAssignConfirmation' } );
|
|
1584
|
+
return res.sendError( 'Internal Server Error', 500 );
|
|
1585
|
+
}
|
|
1586
|
+
}
|
package/src/dtos/client.dtos.js
CHANGED
|
@@ -261,3 +261,24 @@ export const activityLogSchema = joi.object( {
|
|
|
261
261
|
export const activityLogValid = {
|
|
262
262
|
body: activityLogSchema,
|
|
263
263
|
};
|
|
264
|
+
|
|
265
|
+
export const getAssignedClientSchama = joi.object( {
|
|
266
|
+
clientId: joi.string().required(),
|
|
267
|
+
} );
|
|
268
|
+
|
|
269
|
+
export const getAssignedClientValid = {
|
|
270
|
+
query: getAssignedClientSchama,
|
|
271
|
+
};
|
|
272
|
+
|
|
273
|
+
export const postClientCamApprovalSchamaQuery = joi.object( {
|
|
274
|
+
clientId: joi.string().required(),
|
|
275
|
+
} );
|
|
276
|
+
|
|
277
|
+
export const postClientCamApprovalSchamaBody = joi.object( {
|
|
278
|
+
action: joi.string().required(),
|
|
279
|
+
} );
|
|
280
|
+
|
|
281
|
+
export const postClientCamApprovalValid = {
|
|
282
|
+
query: postClientCamApprovalSchamaQuery,
|
|
283
|
+
body: postClientCamApprovalSchamaBody,
|
|
284
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import express from 'express';
|
|
3
|
-
import { activityLogValid, auditConfigValid, billingDetailsValid, brandInfoValid, clientCreationValid, clientDetailsValid, documentsValid, domainDetailsValid, featureConfigurationValid, getAuditConfigValid, signatoryDetailsValid, ticketConfigurationValid, userConfigurationValid } from '../dtos/client.dtos.js';
|
|
4
|
-
import { auditConfiguration, changeStatus, clientDetails, create, domainDetailsConfiguration, getActivityLogs, getAuditConfiguration, getClients, getCsmUsers, getOpsUsers, updateBillingDetails, updateBrandInfo, updateDocuments, updateFeatureConfiguration, updateSignatoryDetails, updateTicketConfiguration, userConfiguration } from '../controllers/client.controllers.js';
|
|
3
|
+
import { activityLogValid, auditConfigValid, billingDetailsValid, brandInfoValid, clientCreationValid, clientDetailsValid, documentsValid, domainDetailsValid, featureConfigurationValid, getAssignedClientValid, getAuditConfigValid, postClientCamApprovalValid, signatoryDetailsValid, ticketConfigurationValid, userConfigurationValid } from '../dtos/client.dtos.js';
|
|
4
|
+
import { auditConfiguration, changeStatus, clientCsmAssignAction, clientDetails, create, csmAssignConfirmation, domainDetailsConfiguration, getActivityLogs, getAuditConfiguration, getClients, getCsmUsers, getOpsUsers, updateBillingDetails, updateBrandInfo, updateDocuments, updateFeatureConfiguration, updateSignatoryDetails, updateTicketConfiguration, userConfiguration } from '../controllers/client.controllers.js';
|
|
5
5
|
import { authorize, isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
|
|
6
6
|
import { clientListValid, detailedClientCountValid } from '../dtos/client.dtos.js';
|
|
7
7
|
import { isclientIdExists, isclientNameExists } from '../validations/client.validations.js';
|
|
@@ -93,4 +93,10 @@ clientRouter.post( '/activity-log', isAllowedSessionHandler, authorize(
|
|
|
93
93
|
{ featureName: 'settings', name: 'activityLog', permissions: [ 'isView' ] } ] } ),
|
|
94
94
|
validate( activityLogValid ), getActivityLogs );
|
|
95
95
|
|
|
96
|
+
clientRouter.get( '/show-csm-assign-confirmation', isAllowedSessionHandler,
|
|
97
|
+
validate( getAssignedClientValid ), csmAssignConfirmation );
|
|
98
|
+
|
|
99
|
+
clientRouter.post( '/client-csm-assign-action', isAllowedSessionHandler,
|
|
100
|
+
validate( postClientCamApprovalValid ), clientCsmAssignAction );
|
|
101
|
+
|
|
96
102
|
|
|
@@ -285,3 +285,12 @@ export function findOneClient( query, field ) {
|
|
|
285
285
|
return clientModel.findOne( query, field );
|
|
286
286
|
}
|
|
287
287
|
|
|
288
|
+
export async function updateOneClient( query, record ) {
|
|
289
|
+
return clientModel.updateOne(
|
|
290
|
+
query,
|
|
291
|
+
{
|
|
292
|
+
$set: record,
|
|
293
|
+
},
|
|
294
|
+
);
|
|
295
|
+
}
|
|
296
|
+
|
|
@@ -4,3 +4,16 @@ import userAssignedStoreModel from 'tango-api-schema/schema/userAssignedStore.mo
|
|
|
4
4
|
export async function aggregateUserAssignedStore( query ) {
|
|
5
5
|
return await userAssignedStoreModel.aggregate( query );
|
|
6
6
|
};
|
|
7
|
+
|
|
8
|
+
export async function updateOneUserAssignedStore( query, record ) {
|
|
9
|
+
return userAssignedStoreModel.updateOne(
|
|
10
|
+
query,
|
|
11
|
+
{
|
|
12
|
+
$set: record,
|
|
13
|
+
},
|
|
14
|
+
);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export async function deleteOneAssignedStore( query ) {
|
|
18
|
+
return userAssignedStoreModel.deleteOne( query );
|
|
19
|
+
}
|