tango-app-api-client 3.1.13 → 3.1.15
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 +3 -3
- package/src/controllers/client.controllers.js +213 -35
- package/src/docs/client.docs.js +0 -16
- 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.1.
|
|
3
|
+
"version": "3.1.15",
|
|
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.
|
|
29
|
-
"tango-app-api-middleware": "^3.1.
|
|
28
|
+
"tango-api-schema": "^2.0.104",
|
|
29
|
+
"tango-app-api-middleware": "^3.1.11",
|
|
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';
|
|
@@ -180,6 +180,44 @@ export async function create( req, res ) {
|
|
|
180
180
|
|
|
181
181
|
await postApi( `${appConfig.url.oldapidomain}/oldDefaultRoleInsert`, oldDefaultRolesInsertData );
|
|
182
182
|
|
|
183
|
+
const logObj = {
|
|
184
|
+
clientId: insertedClientRecord.clientId,
|
|
185
|
+
userName: req.user?.userName,
|
|
186
|
+
email: req.user?.email,
|
|
187
|
+
date: new Date(),
|
|
188
|
+
logType: 'brandDetails',
|
|
189
|
+
logSubType: 'brandApproval',
|
|
190
|
+
changes: [ insertedClientRecord.clientName ],
|
|
191
|
+
showTo: [],
|
|
192
|
+
eventType: 'approve',
|
|
193
|
+
showTo: [ 'client', 'tango' ],
|
|
194
|
+
};
|
|
195
|
+
|
|
196
|
+
await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
197
|
+
|
|
198
|
+
for ( let index = 0; index < leadRecord?.planDetails?.product?.length; index++ ) {
|
|
199
|
+
const logObj = {
|
|
200
|
+
userName: req.user?.userName,
|
|
201
|
+
email: req.user?.email,
|
|
202
|
+
clientId: insertedClientRecord.clientId,
|
|
203
|
+
clientNotification: false,
|
|
204
|
+
adminNotification: true,
|
|
205
|
+
logSubType: 'startTrial',
|
|
206
|
+
description: 'Subscription - Your 14 Days free trial has been started',
|
|
207
|
+
title: 'Subscription',
|
|
208
|
+
alertCta: [],
|
|
209
|
+
markasRead: false,
|
|
210
|
+
logType: 'subscription',
|
|
211
|
+
showPushNotification: true,
|
|
212
|
+
date: new Date(),
|
|
213
|
+
changes: [ `${convertTitleCase( leadRecord?.planDetails?.product[index] )} trial started` ],
|
|
214
|
+
eventType: '',
|
|
215
|
+
showTo: [ 'client', 'tango' ],
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
219
|
+
}
|
|
220
|
+
|
|
183
221
|
|
|
184
222
|
if ( insertClient ) {
|
|
185
223
|
const userRecord = {
|
|
@@ -200,6 +238,13 @@ export async function create( req, res ) {
|
|
|
200
238
|
}
|
|
201
239
|
}
|
|
202
240
|
|
|
241
|
+
function convertTitleCase( data ) {
|
|
242
|
+
let [ firstWord, secondWord ] = data.replace( /([a-z])([A-Z])/g, '$1 $2' ).split( ' ' );
|
|
243
|
+
firstWord = firstWord.charAt( 0 ).toUpperCase() + firstWord.slice( 1 );
|
|
244
|
+
data = firstWord + ' ' + secondWord;
|
|
245
|
+
return data;
|
|
246
|
+
}
|
|
247
|
+
|
|
203
248
|
export const sendEmail = ( data ) => {
|
|
204
249
|
try {
|
|
205
250
|
const attachments = null;
|
|
@@ -249,6 +294,16 @@ export async function getClients( req, res ) {
|
|
|
249
294
|
$match: {
|
|
250
295
|
userEmail: req?.user?.email,
|
|
251
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
|
+
},
|
|
252
307
|
},
|
|
253
308
|
},
|
|
254
309
|
{
|
|
@@ -382,9 +437,18 @@ export async function detailedAllClientCount( req, res ) {
|
|
|
382
437
|
{
|
|
383
438
|
$project: {
|
|
384
439
|
activeClient: { $cond: [ { $eq: [ '$status', 'active' ] }, 1, 0 ] },
|
|
385
|
-
paidClient: { $cond: [ { $
|
|
386
|
-
|
|
387
|
-
|
|
440
|
+
paidClient: { $cond: [ { $and: [
|
|
441
|
+
{ $eq: [ '$status', 'active' ] },
|
|
442
|
+
{ $in: [ '$planDetails.paymentStatus', [ 'paid', 'unbilled', 'due' ] ] },
|
|
443
|
+
] }, 1, 0 ] },
|
|
444
|
+
trialClient: { $cond: [ { $and: [
|
|
445
|
+
{ $eq: [ '$status', 'active' ] },
|
|
446
|
+
{ $eq: [ '$planDetails.paymentStatus', 'trial' ] },
|
|
447
|
+
] }, 1, 0 ] },
|
|
448
|
+
|
|
449
|
+
freeClient: { $cond: [ { $and: [
|
|
450
|
+
{ $eq: [ '$status', 'active' ] }, { $eq: [ '$planDetails.paymentStatus', 'free' ] },
|
|
451
|
+
] }, 1, 0 ] },
|
|
388
452
|
holdClient: { $cond: [ { $eq: [ '$status', 'hold' ] }, 1, 0 ] },
|
|
389
453
|
suspendClient: { $cond: [ { $eq: [ '$status', 'suspended' ] }, 1, 0 ] },
|
|
390
454
|
deactiveClient: { $cond: [ { $eq: [ '$status', 'deactive' ] }, 1, 0 ] },
|
|
@@ -404,11 +468,30 @@ export async function detailedAllClientCount( req, res ) {
|
|
|
404
468
|
|
|
405
469
|
},
|
|
406
470
|
},
|
|
471
|
+
{
|
|
472
|
+
$project: {
|
|
473
|
+
_id: 0,
|
|
474
|
+
totalCount: 1,
|
|
475
|
+
activeClient: 1,
|
|
476
|
+
paidClient: 1,
|
|
477
|
+
trialClient: 1,
|
|
478
|
+
freeClient: 1,
|
|
479
|
+
holdClient: 1,
|
|
480
|
+
suspendClient: 1,
|
|
481
|
+
deactiveClient: 1,
|
|
482
|
+
activeStoresCount: { $ifNull: [ 0, 0 ] },
|
|
483
|
+
activeCameraCount: { $ifNull: [ 0, 0 ] },
|
|
484
|
+
},
|
|
485
|
+
},
|
|
407
486
|
];
|
|
408
487
|
const result = await aggregateClient( query );
|
|
409
|
-
|
|
488
|
+
const activeStores = await countDocumentsStore( { 'status': 'active', 'edge.firstFile': true } );
|
|
489
|
+
const activeCameras = await countDocumentsCamera( { isUp: true, isActivated: true } );
|
|
490
|
+
if ( result.length == 0 ) {
|
|
410
491
|
return res.sendError( 'No Data Found', 204 );
|
|
411
492
|
}
|
|
493
|
+
result[0].activeStoresCount = activeStores;
|
|
494
|
+
result[0].activeCameraCount = activeCameras;
|
|
412
495
|
return res.sendSuccess( { result: result } );
|
|
413
496
|
} catch ( error ) {
|
|
414
497
|
logger.error( { error: error, function: 'detailedAllClientCount' } );
|
|
@@ -456,9 +539,12 @@ export async function updateBrandInfo( req, res ) {
|
|
|
456
539
|
logSubType: 'brandInfo',
|
|
457
540
|
changes: updateKeys,
|
|
458
541
|
eventType: 'update',
|
|
542
|
+
showTo: [ 'client', 'tango' ],
|
|
459
543
|
};
|
|
460
544
|
|
|
461
|
-
|
|
545
|
+
if ( updateKeys.length ) {
|
|
546
|
+
await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
547
|
+
}
|
|
462
548
|
|
|
463
549
|
|
|
464
550
|
const updateAck = await brandInfoUpdate( {
|
|
@@ -550,9 +636,13 @@ export async function updateBillingDetails( req, res ) {
|
|
|
550
636
|
logSubType: 'billingDetails',
|
|
551
637
|
changes: updateKeys,
|
|
552
638
|
eventType: 'update',
|
|
639
|
+
showTo: [ 'client', 'tango' ],
|
|
553
640
|
};
|
|
554
641
|
|
|
555
|
-
|
|
642
|
+
if ( updateKeys.length ) {
|
|
643
|
+
await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
644
|
+
}
|
|
645
|
+
|
|
556
646
|
|
|
557
647
|
const updateAck = await billingDetailsUpdate( {
|
|
558
648
|
clientId: req.params?.id, tradeName: req.body?.tradeName, gstNumber: req.body?.gstNumber,
|
|
@@ -588,9 +678,13 @@ export async function updateSignatoryDetails( req, res ) {
|
|
|
588
678
|
logSubType: 'signatoryDetails',
|
|
589
679
|
changes: updateKeys,
|
|
590
680
|
eventType: 'update',
|
|
681
|
+
showTo: [ 'client', 'tango' ],
|
|
591
682
|
};
|
|
592
683
|
|
|
593
|
-
|
|
684
|
+
if ( updateKeys.length ) {
|
|
685
|
+
await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
686
|
+
}
|
|
687
|
+
|
|
594
688
|
const updateAck = await signatoryDetailsUpdate( {
|
|
595
689
|
clientId: req.params?.id, name: req.body?.name, email: req.body?.email,
|
|
596
690
|
number: req.body?.number, designation: req.body?.designation,
|
|
@@ -631,8 +725,12 @@ export async function updateTicketConfiguration( req, res ) {
|
|
|
631
725
|
logSubType: 'ticketConfig',
|
|
632
726
|
changes: updateKeys,
|
|
633
727
|
eventType: 'update',
|
|
728
|
+
showTo: [ 'tango' ],
|
|
634
729
|
};
|
|
635
|
-
|
|
730
|
+
|
|
731
|
+
if ( updateKeys.length ) {
|
|
732
|
+
await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
733
|
+
}
|
|
636
734
|
|
|
637
735
|
if ( updateAck ) {
|
|
638
736
|
res.sendSuccess( { result: 'Updated Successfully' } );
|
|
@@ -716,8 +814,11 @@ export async function updateFeatureConfiguration( req, res ) {
|
|
|
716
814
|
logSubType: 'featureConfig',
|
|
717
815
|
changes: updateKeys,
|
|
718
816
|
eventType: 'update',
|
|
817
|
+
showTo: [ 'client', 'tango' ],
|
|
719
818
|
};
|
|
720
|
-
|
|
819
|
+
if ( updateKeys.length ) {
|
|
820
|
+
await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
821
|
+
}
|
|
721
822
|
|
|
722
823
|
if ( updateAck ) {
|
|
723
824
|
res.sendSuccess( { result: 'Updated Successfully' } );
|
|
@@ -755,9 +856,13 @@ export async function domainDetailsConfiguration( req, res ) {
|
|
|
755
856
|
logSubType: 'domainDetails',
|
|
756
857
|
changes: updateKeys,
|
|
757
858
|
eventType: 'update',
|
|
859
|
+
showTo: [ 'client', 'tango' ],
|
|
758
860
|
};
|
|
759
861
|
|
|
760
|
-
|
|
862
|
+
if ( updateKeys.length ) {
|
|
863
|
+
await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
864
|
+
}
|
|
865
|
+
|
|
761
866
|
if ( updateAck ) {
|
|
762
867
|
res.sendSuccess( { result: 'Updated Successfully' } );
|
|
763
868
|
}
|
|
@@ -865,9 +970,12 @@ export async function updateDocuments( req, res ) {
|
|
|
865
970
|
logSubType: 'documentUpload',
|
|
866
971
|
changes: updateKeys,
|
|
867
972
|
eventType: 'update',
|
|
973
|
+
showTo: [ 'client', 'tango' ],
|
|
868
974
|
};
|
|
869
975
|
|
|
870
|
-
|
|
976
|
+
if ( updateKeys.length ) {
|
|
977
|
+
await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
978
|
+
}
|
|
871
979
|
|
|
872
980
|
if ( updateAck ) {
|
|
873
981
|
res.sendSuccess( { result: 'Updated Successfully' } );
|
|
@@ -903,35 +1011,37 @@ export async function getAuditConfiguration( req, res ) {
|
|
|
903
1011
|
export async function auditConfiguration( req, res ) {
|
|
904
1012
|
try {
|
|
905
1013
|
for ( let i = 0; i < req.body?.length; i++ ) {
|
|
1014
|
+
const previousStore = await findOneStore( { storeId: req.body[i].storeId }, { auditConfigs: 1, _id: 0 } );
|
|
906
1015
|
await auditConfigurationUpdate( {
|
|
907
1016
|
storeId: req.body[i].storeId,
|
|
908
1017
|
count: req.body[i].count,
|
|
909
1018
|
iteration: req.body[i].iteration,
|
|
910
1019
|
ratio: normalizeNumber( req.body[i].ratio, 0, 100 ),
|
|
911
1020
|
} );
|
|
912
|
-
}
|
|
913
|
-
|
|
914
|
-
const user = await getUserNameEmailById( req.userId );
|
|
915
|
-
|
|
916
|
-
const logObj = {
|
|
917
|
-
clientId: req.params?.id,
|
|
918
|
-
userName: user.userName,
|
|
919
|
-
email: user.email,
|
|
920
|
-
date: new Date(),
|
|
921
|
-
logType: 'configuration',
|
|
922
|
-
logSubType: 'auditConfig',
|
|
923
|
-
eventType: 'update',
|
|
924
|
-
};
|
|
925
1021
|
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
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
|
+
};
|
|
929
1041
|
|
|
930
|
-
|
|
931
|
-
logObj.changes = [ `Audit config bulk` ];
|
|
1042
|
+
await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
|
|
932
1043
|
}
|
|
933
1044
|
|
|
934
|
-
await insertOpenSearchData( 'tango-retail-activity-logs', logObj );
|
|
935
1045
|
|
|
936
1046
|
res.sendSuccess( { result: 'Updated Successfully' } );
|
|
937
1047
|
} catch ( error ) {
|
|
@@ -969,6 +1079,15 @@ export async function clientList( req, res ) {
|
|
|
969
1079
|
$match: {
|
|
970
1080
|
userEmail: { $eq: req?.user?.email },
|
|
971
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
|
+
},
|
|
972
1091
|
|
|
973
1092
|
},
|
|
974
1093
|
}, {
|
|
@@ -994,6 +1113,10 @@ export async function clientList( req, res ) {
|
|
|
994
1113
|
);
|
|
995
1114
|
}
|
|
996
1115
|
if ( inputData.filterByPaymentStatus ) {
|
|
1116
|
+
if ( inputData.filterByPaymentStatus.includes( 'paid' ) ) {
|
|
1117
|
+
inputData.filterByPaymentStatus.push( ...[ 'unbilled', 'due' ] );
|
|
1118
|
+
}
|
|
1119
|
+
|
|
997
1120
|
clientQuery.push(
|
|
998
1121
|
{
|
|
999
1122
|
$match: {
|
|
@@ -1244,8 +1367,13 @@ export async function clientList( req, res ) {
|
|
|
1244
1367
|
list.push( {
|
|
1245
1368
|
'client Name': chunk[i]?.clientName,
|
|
1246
1369
|
'client Id': chunk[i]?.clientId,
|
|
1370
|
+
'Installation Stores Count': chunk[i]?.installedStores || 0,
|
|
1371
|
+
'Onboarded Stores Count': chunk[i]?.totalStores,
|
|
1372
|
+
'Store Progress': chunk[i]?.installedStores? `${ ( ( chunk[i]?.installedStores/ chunk[i]?.totalStores )* 100 ).toFixed( 0 )}%`: '0%',
|
|
1247
1373
|
'Active Store': chunk[i]?.activeStoreCount || 0,
|
|
1248
1374
|
'Active Camera': chunk[i]?.activeCameraCount && chunk[i]?.activeCameraCount != undefined ? chunk[i]?.activeCameraCount : 0,
|
|
1375
|
+
'Pending Stores': chunk[i]?.pendingStores || 0,
|
|
1376
|
+
'Failed Stores': chunk[i]?.failedStores || 0,
|
|
1249
1377
|
'Payment Status': chunk[i]?.paymentStatus,
|
|
1250
1378
|
'Subs Plan': chunk[i]?.subscriptionType,
|
|
1251
1379
|
'Status': chunk[i]?.status,
|
|
@@ -1317,7 +1445,10 @@ export async function detailedClientCount( req, res ) {
|
|
|
1317
1445
|
export async function getActivityLogs( req, res ) {
|
|
1318
1446
|
try {
|
|
1319
1447
|
const query = {
|
|
1320
|
-
'_source': [
|
|
1448
|
+
'_source': [
|
|
1449
|
+
'userId', 'userName', 'email', 'date', 'logType', 'logSubType',
|
|
1450
|
+
'changes', 'eventType',
|
|
1451
|
+
],
|
|
1321
1452
|
'query': {
|
|
1322
1453
|
'bool': {
|
|
1323
1454
|
'must': [
|
|
@@ -1331,6 +1462,13 @@ export async function getActivityLogs( req, res ) {
|
|
|
1331
1462
|
},
|
|
1332
1463
|
'from': ( req.body.offset - 1 ) * req.body.limit,
|
|
1333
1464
|
'size': req.body.limit,
|
|
1465
|
+
'sort': [
|
|
1466
|
+
{
|
|
1467
|
+
'date': {
|
|
1468
|
+
'order': 'desc',
|
|
1469
|
+
},
|
|
1470
|
+
},
|
|
1471
|
+
],
|
|
1334
1472
|
};
|
|
1335
1473
|
|
|
1336
1474
|
if ( req.body?.logTypeFilters?.length ) {
|
|
@@ -1354,7 +1492,15 @@ export async function getActivityLogs( req, res ) {
|
|
|
1354
1492
|
} );
|
|
1355
1493
|
}
|
|
1356
1494
|
|
|
1357
|
-
|
|
1495
|
+
query.query.bool.must.push(
|
|
1496
|
+
{
|
|
1497
|
+
'terms': {
|
|
1498
|
+
'showTo.keyword': [ req.user.userType ],
|
|
1499
|
+
},
|
|
1500
|
+
},
|
|
1501
|
+
);
|
|
1502
|
+
|
|
1503
|
+
const logs = await getOpenSearchData( appConfig.opensearch.activityLog, query );
|
|
1358
1504
|
|
|
1359
1505
|
const hits = logs?.body?.hits?.hits;
|
|
1360
1506
|
const totalDocuments = logs?.body?.hits?.total?.value;
|
|
@@ -1370,6 +1516,7 @@ export async function getActivityLogs( req, res ) {
|
|
|
1370
1516
|
}
|
|
1371
1517
|
}
|
|
1372
1518
|
|
|
1519
|
+
|
|
1373
1520
|
async function postApi( url, data ) {
|
|
1374
1521
|
const requestOptions = {
|
|
1375
1522
|
method: 'POST',
|
|
@@ -1406,3 +1553,34 @@ async function getApi( url ) {
|
|
|
1406
1553
|
}
|
|
1407
1554
|
}
|
|
1408
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/docs/client.docs.js
CHANGED
|
@@ -40,14 +40,6 @@ export const clientDocs = {
|
|
|
40
40
|
description: 'Get list of clients',
|
|
41
41
|
operationId: 'get-clients',
|
|
42
42
|
parameters: [
|
|
43
|
-
{
|
|
44
|
-
in: 'path',
|
|
45
|
-
name: 'id',
|
|
46
|
-
required: true,
|
|
47
|
-
schema: {
|
|
48
|
-
type: 'string',
|
|
49
|
-
},
|
|
50
|
-
},
|
|
51
43
|
],
|
|
52
44
|
responses: {
|
|
53
45
|
200: { description: 'Success' },
|
|
@@ -455,14 +447,6 @@ export const clientDocs = {
|
|
|
455
447
|
description: 'Get toatal info about overall clients',
|
|
456
448
|
operationId: 'detailed-all-client-count',
|
|
457
449
|
parameters: [
|
|
458
|
-
{
|
|
459
|
-
in: 'path',
|
|
460
|
-
name: 'id',
|
|
461
|
-
required: true,
|
|
462
|
-
schema: {
|
|
463
|
-
type: 'string',
|
|
464
|
-
},
|
|
465
|
-
},
|
|
466
450
|
],
|
|
467
451
|
responses: {
|
|
468
452
|
200: { description: 'Success' },
|
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
|
+
}
|