tango-app-api-client 3.1.15 → 3.1.16

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-client",
3
- "version": "3.1.15",
3
+ "version": "3.1.16",
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",
29
- "tango-app-api-middleware": "^3.1.11",
28
+ "tango-api-schema": "^2.0.113",
29
+ "tango-app-api-middleware": "^3.1.19",
30
30
  "winston": "^3.11.0",
31
31
  "winston-daily-rotate-file": "^5.0.0"
32
32
  },
@@ -1,8 +1,8 @@
1
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
- import { checkFileExist, fileUpload, signedUrl, chunkArray, download, logger, getOpenSearchData, insertOpenSearchData, appConfig, sendEmailWithSES } from 'tango-app-api-middleware';
2
+ import { checkFileExist, fileUpload, signedUrl, chunkArray, download, logger, getOpenSearchData, insertOpenSearchData, sendEmailWithSES } from 'tango-app-api-middleware';
3
3
  import { countDocumentsUser, findOneAndUpdateUser, findOneUser, getUserNameEmailById, updateManyUser } from '../service/user.service.js';
4
- import { aggregateStore, countDocumentsStore, findOneStore, updateManyStore } from '../service/store.service.js';
5
- import { aggregateCamera, countDocumentsCamera, updateManyCamera } from '../service/camera.service.js';
4
+ import { aggregateStore, countDocumentsStore, findStore, findOneStore, updateManyStore } from '../service/store.service.js';
5
+ import { aggregateCamera, countDocumentsCamera } from '../service/camera.service.js';
6
6
  import _ from 'lodash';
7
7
  import { findOneStandaredRole } from '../service/standaredRole.service.js';
8
8
  import { aggregateUserAssignedStore, deleteOneAssignedStore, updateOneUserAssignedStore } from '../service/userAssignedStore.service.js';
@@ -10,12 +10,14 @@ import { aggregateTickets } from '../service/tangoticket.service.js';
10
10
  import { join } from 'path';
11
11
  import { readFileSync } from 'fs';
12
12
  import handlebars from 'handlebars';
13
- import { countDocumentsGroup } from '../service/group.service.js';
13
+ import { countDocumentsGroup, createGroupModel, findOneGroup } from '../service/group.service.js';
14
14
  import { deleteOneAuthentication } from '../service/authentication.service.js';
15
15
 
16
16
 
17
17
  export async function create( req, res ) {
18
18
  try {
19
+ const url = JSON.parse( process.env.URL );
20
+ const openSearch = JSON.parse( process.env.OPENSEARCH );
19
21
  const inputData = req.body;
20
22
  const countQuery = [
21
23
  {
@@ -71,9 +73,33 @@ export async function create( req, res ) {
71
73
 
72
74
  const insertClient = await insert( record );
73
75
 
76
+ const insertedClientRecord = await findOneClient( { clientId: record.clientId }, {} );
77
+
78
+ const defaultGroup = {
79
+ 'groupName': 'All stores',
80
+ 'description': 'Contains all the onboarded stores',
81
+ 'storeList': [],
82
+ 'clientId': insertedClientRecord.clientId,
83
+ 'isDefault': true,
84
+ };
85
+
86
+ await createGroupModel( defaultGroup );
87
+
88
+ const createdGroup = await findOneGroup( { clientId: insertedClientRecord.clientId, isDefault: true }, {} );
89
+
90
+ let oldGroup = {
91
+ '_id': createdGroup._id,
92
+ 'client_id': createdGroup.clientId,
93
+ 'groupName': createdGroup.groupName,
94
+ 'description': createdGroup.description,
95
+ 'storeList': createdGroup.storeList,
96
+ };
97
+
98
+
99
+ await postApi( `${url.oldapidomain}/oldGroupAdd`, [ oldGroup ] );
100
+
74
101
  // For old dashboard insert
75
102
 
76
- const insertedClientRecord = await findOneClient( { clientId: record.clientId }, {} );
77
103
 
78
104
  const oldBrandInsertData = {
79
105
  '_id': insertedClientRecord._id,
@@ -93,9 +119,7 @@ export async function create( req, res ) {
93
119
  'birdsEye',
94
120
  'tangoZone',
95
121
  'tangoTraffic',
96
- 'Support',
97
- 'footFallDirectory',
98
- 'tangoSOP',
122
+ 'support',
99
123
  ],
100
124
  'planType': insertedClientRecord.planDetails.subscriptionPeriod,
101
125
  'storeCount': insertedClientRecord.planDetails.totalStores,
@@ -176,9 +200,9 @@ export async function create( req, res ) {
176
200
  'role': 'storesuperadmin',
177
201
  };
178
202
 
179
- await postApi( `${appConfig.url.oldapidomain}/oldBrandAdd`, oldBrandInsertData );
203
+ await postApi( `${url.oldapidomain}/oldBrandAdd`, oldBrandInsertData );
180
204
 
181
- await postApi( `${appConfig.url.oldapidomain}/oldDefaultRoleInsert`, oldDefaultRolesInsertData );
205
+ await postApi( `${url.oldapidomain}/oldDefaultRoleInsert`, oldDefaultRolesInsertData );
182
206
 
183
207
  const logObj = {
184
208
  clientId: insertedClientRecord.clientId,
@@ -193,7 +217,7 @@ export async function create( req, res ) {
193
217
  showTo: [ 'client', 'tango' ],
194
218
  };
195
219
 
196
- await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
220
+ await insertOpenSearchData( openSearch.activityLog, logObj );
197
221
 
198
222
  for ( let index = 0; index < leadRecord?.planDetails?.product?.length; index++ ) {
199
223
  const logObj = {
@@ -215,7 +239,7 @@ export async function create( req, res ) {
215
239
  showTo: [ 'client', 'tango' ],
216
240
  };
217
241
 
218
- await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
242
+ await insertOpenSearchData( openSearch.activityLog, logObj );
219
243
  }
220
244
 
221
245
 
@@ -247,12 +271,14 @@ function convertTitleCase( data ) {
247
271
 
248
272
  export const sendEmail = ( data ) => {
249
273
  try {
274
+ const url = JSON.parse( process.env.URL );
275
+ const ses = JSON.parse( process.env.SES );
250
276
  const attachments = null;
251
277
  const subject = data.subject;
252
278
  const fileContent = readFileSync( join() + data.path, 'utf8' );
253
279
  const htmlContent = handlebars.compile( fileContent );
254
- const html = htmlContent( { url: appConfig.url.store, logo: `${appConfig.url.domain}/logo.png` } );
255
- return sendEmailWithSES( data.email, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
280
+ const html = htmlContent( { url: url.store, logo: `${url.apiDomain}/logo.png` } );
281
+ return sendEmailWithSES( data.email, subject, html, attachments, ses.adminEmail );
256
282
  } catch ( error ) {
257
283
  return error;
258
284
  }
@@ -296,10 +322,12 @@ export async function getClients( req, res ) {
296
322
  assignedType: { $eq: 'client' },
297
323
  $expr: {
298
324
  $cond: {
299
- if: { $and: [
300
- { $eq: [ '$userType', 'tango' ] },
301
- { $eq: [ '$tangoUserType', 'csm' ] },
302
- ] },
325
+ if: {
326
+ $and: [
327
+ { $eq: [ '$userType', 'tango' ] },
328
+ { $eq: [ '$tangoUserType', 'csm' ] },
329
+ ],
330
+ },
303
331
  then: { $eq: [ '$isClientApproved', true ] },
304
332
  else: true,
305
333
  },
@@ -357,61 +385,62 @@ export async function getClients( req, res ) {
357
385
 
358
386
  export async function clientDetails( req, res ) {
359
387
  try {
388
+ const bucket = JSON.parse( process.env.BUCKET );
360
389
  const client = await getClientData( { id: req.params.id } );
361
390
  if ( client ) {
362
- const isLogoExist = await checkFileExist( { Bucket: appConfig.cloud.aws.bucket.assets, Key: `${client.clientId}/logo/${client.profileDetails?.logo}` } );
363
- const isGstCertificateExist = await checkFileExist( { Bucket: appConfig.cloud.aws.bucket.assets, Key: `${client.clientId}/documents/${client.document?.gst?.path}` } );
364
- const isAddressCertificateExist = await checkFileExist( { Bucket: appConfig.cloud.aws.bucket.assets, Key: `${client.clientId}/documents/${client.document?.addressProof?.path}` } );
365
- const isPanCertificateExist = await checkFileExist( { Bucket: appConfig.cloud.aws.bucket.assets, Key: `${client.clientId}/documents/${client.document?.pan?.path}` } );
366
- const isCinCertificateExist = await checkFileExist( { Bucket: appConfig.cloud.aws.bucket.assets, Key: `${client.clientId}/documents/${client.document?.cin?.path}` } );
367
- const isContractCertificateExist = await checkFileExist( { Bucket: appConfig.cloud.aws.bucket.assets, Key: `documents/contract.pdf` } );
368
- const isTermsAndConditionsExist = await checkFileExist( { Bucket: appConfig.cloud.aws.bucket.assets, Key: `documents/terms&conditions.pdf` } );
391
+ const isLogoExist = await checkFileExist( { Bucket: bucket.assets, Key: `${client.clientId}/logo/${client.profileDetails?.logo}` } );
392
+ const isGstCertificateExist = await checkFileExist( { Bucket: bucket.assets, Key: `${client.clientId}/documents/${client.document?.gst?.path}` } );
393
+ const isAddressCertificateExist = await checkFileExist( { Bucket: bucket.assets, Key: `${client.clientId}/documents/${client.document?.addressProof?.path}` } );
394
+ const isPanCertificateExist = await checkFileExist( { Bucket: bucket.assets, Key: `${client.clientId}/documents/${client.document?.pan?.path}` } );
395
+ const isCinCertificateExist = await checkFileExist( { Bucket: bucket.assets, Key: `${client.clientId}/documents/${client.document?.cin?.path}` } );
396
+ const isContractCertificateExist = await checkFileExist( { Bucket: bucket.assets, Key: `documents/contract.pdf` } );
397
+ const isTermsAndConditionsExist = await checkFileExist( { Bucket: bucket.assets, Key: `documents/terms&conditions.pdf` } );
369
398
 
370
399
 
371
400
  if ( isLogoExist ) {
372
- const signedFilUrl = await signedUrl( { Bucket: appConfig.cloud.aws.bucket.assets, file_path: `${client.clientId}/logo/${client.profileDetails?.logo}` } );
401
+ const signedFilUrl = await signedUrl( { Bucket: bucket.assets, file_path: `${client.clientId}/logo/${client.profileDetails?.logo}` } );
373
402
  client.profileDetails.logo = signedFilUrl;
374
403
  } else {
375
404
  client.profileDetails.logo = '';
376
405
  }
377
406
 
378
407
  if ( isGstCertificateExist ) {
379
- const signedFilUrl = await signedUrl( { Bucket: appConfig.cloud.aws.bucket.assets, file_path: `${client.clientId}/documents/${client.document?.gst?.path}` } );
408
+ const signedFilUrl = await signedUrl( { Bucket: bucket.assets, file_path: `${client.clientId}/documents/${client.document?.gst?.path}` } );
380
409
  client.document.gst.path = signedFilUrl;
381
410
  } else {
382
411
  client.document.gst.path = '';
383
412
  }
384
413
 
385
414
  if ( isAddressCertificateExist ) {
386
- const signedFilUrl = await signedUrl( { Bucket: appConfig.cloud.aws.bucket.assets, file_path: `${client.clientId}/documents/${client.document?.addressProof?.path}` } );
415
+ const signedFilUrl = await signedUrl( { Bucket: bucket.assets, file_path: `${client.clientId}/documents/${client.document?.addressProof?.path}` } );
387
416
  client.document.addressProof.path = signedFilUrl;
388
417
  } else {
389
418
  client.document.addressProof.path = '';
390
419
  }
391
420
 
392
421
  if ( isPanCertificateExist ) {
393
- const signedFilUrl = await signedUrl( { Bucket: appConfig.cloud.aws.bucket.assets, file_path: `${client.clientId}/documents/${client.document?.pan?.path}` } );
422
+ const signedFilUrl = await signedUrl( { Bucket: bucket.assets, file_path: `${client.clientId}/documents/${client.document?.pan?.path}` } );
394
423
  client.document.pan.path = signedFilUrl;
395
424
  } else {
396
425
  client.document.pan.path = '';
397
426
  }
398
427
 
399
428
  if ( isCinCertificateExist ) {
400
- const signedFilUrl = await signedUrl( { Bucket: appConfig.cloud.aws.bucket.assets, file_path: `${client.clientId}/documents/${client.document?.cin?.path}` } );
429
+ const signedFilUrl = await signedUrl( { Bucket: bucket.assets, file_path: `${client.clientId}/documents/${client.document?.cin?.path}` } );
401
430
  client.document.cin.path = signedFilUrl;
402
431
  } else {
403
432
  client.document.cin.path = '';
404
433
  }
405
434
 
406
435
  if ( isContractCertificateExist ) {
407
- const signedFilUrl = await signedUrl( { Bucket: appConfig.cloud.aws.bucket.assets, file_path: `documents/contract.pdf` } );
436
+ const signedFilUrl = await signedUrl( { Bucket: bucket.assets, file_path: `documents/contract.pdf` } );
408
437
  client._doc.document.contract = signedFilUrl;
409
438
  } else {
410
439
  client._doc.document.contract = '';
411
440
  }
412
441
 
413
442
  if ( isTermsAndConditionsExist ) {
414
- const signedFilUrl = await signedUrl( { Bucket: appConfig.cloud.aws.bucket.assets, file_path: `documents/terms&conditions.pdf` } );
443
+ const signedFilUrl = await signedUrl( { Bucket: bucket.assets, file_path: `documents/terms&conditions.pdf` } );
415
444
  client._doc.document.termsAndconditions = signedFilUrl;
416
445
  } else {
417
446
  client._doc.document.termsAndconditions = '';
@@ -437,18 +466,30 @@ export async function detailedAllClientCount( req, res ) {
437
466
  {
438
467
  $project: {
439
468
  activeClient: { $cond: [ { $eq: [ '$status', 'active' ] }, 1, 0 ] },
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 ] },
469
+ paidClient: {
470
+ $cond: [ {
471
+ $and: [
472
+ { $eq: [ '$status', 'active' ] },
473
+ { $in: [ '$planDetails.paymentStatus', [ 'paid', 'unbilled', 'due' ] ] },
474
+ ],
475
+ }, 1, 0 ],
476
+ },
477
+ trialClient: {
478
+ $cond: [ {
479
+ $and: [
480
+ { $eq: [ '$status', 'active' ] },
481
+ { $eq: [ '$planDetails.paymentStatus', 'trial' ] },
482
+ ],
483
+ }, 1, 0 ],
484
+ },
485
+
486
+ freeClient: {
487
+ $cond: [ {
488
+ $and: [
489
+ { $eq: [ '$status', 'active' ] }, { $eq: [ '$planDetails.paymentStatus', 'free' ] },
490
+ ],
491
+ }, 1, 0 ],
492
+ },
452
493
  holdClient: { $cond: [ { $eq: [ '$status', 'hold' ] }, 1, 0 ] },
453
494
  suspendClient: { $cond: [ { $eq: [ '$status', 'suspended' ] }, 1, 0 ] },
454
495
  deactiveClient: { $cond: [ { $eq: [ '$status', 'deactive' ] }, 1, 0 ] },
@@ -485,12 +526,16 @@ export async function detailedAllClientCount( req, res ) {
485
526
  },
486
527
  ];
487
528
  const result = await aggregateClient( query );
488
- const activeStores = await countDocumentsStore( { 'status': 'active', 'edge.firstFile': true } );
489
- const activeCameras = await countDocumentsCamera( { isUp: true, isActivated: true } );
529
+ const activeStores = await findStore( { 'status': 'active', 'edge.firstFile': true }, { storeId: 1 } );
530
+ let storesList = [];
531
+ for ( let store of activeStores ) {
532
+ storesList.push( store.storeId );
533
+ }
534
+ const activeCameras = await countDocumentsCamera( { storeId: { $in: storesList }, isUp: true, isActivated: true } );
490
535
  if ( result.length == 0 ) {
491
536
  return res.sendError( 'No Data Found', 204 );
492
537
  }
493
- result[0].activeStoresCount = activeStores;
538
+ result[0].activeStoresCount = activeStores.length;
494
539
  result[0].activeCameraCount = activeCameras;
495
540
  return res.sendSuccess( { result: result } );
496
541
  } catch ( error ) {
@@ -507,11 +552,14 @@ function camelCaseToWords( camelCaseString ) {
507
552
 
508
553
  export async function updateBrandInfo( req, res ) {
509
554
  try {
555
+ const bucket = JSON.parse( process.env.BUCKET );
556
+ const openSearch = JSON.parse( process.env.OPENSEARCH );
557
+ const url = JSON.parse( process.env.URL );
510
558
  let updateKeys = [];
511
559
 
512
560
  if ( req.files?.logo ) {
513
561
  const uploadDataParams = {
514
- Bucket: appConfig.cloud.aws.bucket.assets,
562
+ Bucket: bucket.assets,
515
563
  Key: `${req.params.id}/logo/`,
516
564
  fileName: `brandLogo.${req.files.logo.name.split( '.' )[1]}`,
517
565
  ContentType: req.files.logo.mimetype,
@@ -543,7 +591,7 @@ export async function updateBrandInfo( req, res ) {
543
591
  };
544
592
 
545
593
  if ( updateKeys.length ) {
546
- await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
594
+ await insertOpenSearchData( openSearch.activityLog, logObj );
547
595
  }
548
596
 
549
597
 
@@ -569,11 +617,11 @@ export async function updateBrandInfo( req, res ) {
569
617
 
570
618
  if ( req.body?.status === 'deactive' ) {
571
619
  await updateManyStore( { clientId: req.params?.id }, { status: 'deactive' } );
572
- await updateManyCamera( { clientId: req.params?.id }, { isUp: false, isActivated: false } );
620
+ // await updateManyCamera( { clientId: req.params?.id }, { isUp: false, isActivated: false } );
573
621
  await updateManyUser( { clientId: req.params?.id }, { isActive: false } );
574
622
  }
575
623
 
576
- const { data } = await getApi( `${appConfig.url.oldapidomain}/oldBrandGet/${req.params?.id}` );
624
+ const { data } = await getApi( `${url.oldapidomain}/oldBrandGet/${req.params?.id}` );
577
625
 
578
626
  switch ( req.body?.status ) {
579
627
  case 'active':
@@ -592,7 +640,7 @@ export async function updateBrandInfo( req, res ) {
592
640
  data.clientStatus = 'live';
593
641
  }
594
642
 
595
- await postApi( `${appConfig.url.oldapidomain}/oldBrandUpdate/${data?._id}`, { clientStatus: data.clientStatus } );
643
+ await postApi( `${url.oldapidomain}/oldBrandUpdate/${data?._id}`, { clientStatus: data.clientStatus } );
596
644
 
597
645
  if ( updateAck ) {
598
646
  res.sendSuccess( { result: 'Updated Successfully' } );
@@ -605,11 +653,13 @@ export async function updateBrandInfo( req, res ) {
605
653
 
606
654
  export async function updateBillingDetails( req, res ) {
607
655
  try {
656
+ const bucket = JSON.parse( process.env.BUCKET );
657
+ const openSearch = JSON.parse( process.env.OPENSEARCH );
608
658
  let updateKeys = [];
609
659
 
610
660
  if ( req.files?.gstCertificate ) {
611
661
  const uploadDataParams = {
612
- Bucket: appConfig.cloud.aws.bucket.assets,
662
+ Bucket: bucket.assets,
613
663
  Key: `${req.params.id}/documents/`,
614
664
  fileName: `gstCertificate.${req.files.gstCertificate.name.split( '.' )[1]}`,
615
665
  ContentType: req.files.gstCertificate.mimetype,
@@ -640,7 +690,7 @@ export async function updateBillingDetails( req, res ) {
640
690
  };
641
691
 
642
692
  if ( updateKeys.length ) {
643
- await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
693
+ await insertOpenSearchData( openSearch.activityLog, logObj );
644
694
  }
645
695
 
646
696
 
@@ -660,6 +710,7 @@ export async function updateBillingDetails( req, res ) {
660
710
 
661
711
  export async function updateSignatoryDetails( req, res ) {
662
712
  try {
713
+ const openSearch = JSON.parse( process.env.OPENSEARCH );
663
714
  let updateKeys = [];
664
715
  if ( Object.keys( req.body ).length > 0 ) {
665
716
  Object.keys( req.body ).forEach( ( element ) => {
@@ -682,7 +733,7 @@ export async function updateSignatoryDetails( req, res ) {
682
733
  };
683
734
 
684
735
  if ( updateKeys.length ) {
685
- await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
736
+ await insertOpenSearchData( openSearch.activityLog, logObj );
686
737
  }
687
738
 
688
739
  const updateAck = await signatoryDetailsUpdate( {
@@ -700,6 +751,7 @@ export async function updateSignatoryDetails( req, res ) {
700
751
 
701
752
  export async function updateTicketConfiguration( req, res ) {
702
753
  try {
754
+ const openSearch = JSON.parse( process.env.OPENSEARCH );
703
755
  const updateAck = await ticketConfigurationUpdate( {
704
756
  clientId: req.params?.id, MinFilesCount: req.body?.MinFilesCount, accuracyPercentage: req.body?.accuracyPercentage, downTimeType: req.body?.downTimeType,
705
757
  infraDownTime: req.body?.infraDownTime, installationReAssign: req.body?.installationReAssign, isRcaTicketAssign: req.body?.isRcaTicketAssign,
@@ -729,7 +781,7 @@ export async function updateTicketConfiguration( req, res ) {
729
781
  };
730
782
 
731
783
  if ( updateKeys.length ) {
732
- await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
784
+ await insertOpenSearchData( openSearch.activityLog, logObj );
733
785
  }
734
786
 
735
787
  if ( updateAck ) {
@@ -743,11 +795,14 @@ export async function updateTicketConfiguration( req, res ) {
743
795
 
744
796
  export async function updateFeatureConfiguration( req, res ) {
745
797
  try {
798
+ const openSearch = JSON.parse( process.env.OPENSEARCH );
799
+ const url = JSON.parse( process.env.URL );
746
800
  const updateAck = await featureConfigurationUpdate( {
747
801
  clientId: req.params?.id, billableCalculation: req.body?.billableCalculation, bouncedLimitCondition: req.body?.bouncedLimitCondition, bouncedLimitValue: req.body?.bouncedLimitValue,
748
802
  close: req.body?.close, conversionCalculation: req.body?.conversionCalculation, conversionCondition: req.body?.conversionCondition,
749
803
  conversionValue: req.body?.conversionValue, infraAlertCondition: req.body?.infraAlertCondition, infraAlertValue: req.body?.infraAlertValue, isFootfallDirectory: req.body?.isFootfallDirectory,
750
804
  isNormalized: req.body?.isNormalized, isPasserByData: req.body?.isPasserByData, missedOpportunityCalculation: req.body?.missedOpportunityCalculation, open: req.body?.open,
805
+ isExcludedArea: req.body?.isExcludedArea,
751
806
  } );
752
807
 
753
808
  let updateKeys = [];
@@ -760,7 +815,7 @@ export async function updateFeatureConfiguration( req, res ) {
760
815
 
761
816
  const user = await getUserNameEmailById( req.userId );
762
817
 
763
- const { data } = await getApi( `${appConfig.url.oldapidomain}/oldBrandGet/${req.params?.id}` );
818
+ const { data } = await getApi( `${url.oldapidomain}/oldBrandGet/${req.params?.id}` );
764
819
 
765
820
  if ( req.body?.open ) {
766
821
  data.brandConfigs.storeOpenTime = req.body?.open;
@@ -802,7 +857,7 @@ export async function updateFeatureConfiguration( req, res ) {
802
857
  data.brandConfigs.missedOpportunityEndTime = data.brandConfigs.missedOpportunityEndTime.replace( /\d+/, req.body?.conversionValue );
803
858
  }
804
859
 
805
- await postApi( `${appConfig.url.oldapidomain}/oldBrandUpdate/${data?._id}`, { brandConfigs: data.brandConfigs } );
860
+ await postApi( `${url.oldapidomain}/oldBrandUpdate/${data?._id}`, { brandConfigs: data.brandConfigs } );
806
861
 
807
862
 
808
863
  const logObj = {
@@ -817,7 +872,7 @@ export async function updateFeatureConfiguration( req, res ) {
817
872
  showTo: [ 'client', 'tango' ],
818
873
  };
819
874
  if ( updateKeys.length ) {
820
- await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
875
+ await insertOpenSearchData( openSearch.activityLog, logObj );
821
876
  }
822
877
 
823
878
  if ( updateAck ) {
@@ -831,6 +886,7 @@ export async function updateFeatureConfiguration( req, res ) {
831
886
 
832
887
  export async function domainDetailsConfiguration( req, res ) {
833
888
  try {
889
+ const openSearch = JSON.parse( process.env.OPENSEARCH );
834
890
  const updateAck = await domainDetailsConfigurationUpdate( {
835
891
  clientId: req.params?.id, domainName: req.body?.domainName, isEnable: req.body?.isEnable,
836
892
  } );
@@ -860,7 +916,7 @@ export async function domainDetailsConfiguration( req, res ) {
860
916
  };
861
917
 
862
918
  if ( updateKeys.length ) {
863
- await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
919
+ await insertOpenSearchData( openSearch.activityLog, logObj );
864
920
  }
865
921
 
866
922
  if ( updateAck ) {
@@ -888,11 +944,13 @@ export async function userConfiguration( req, res ) {
888
944
 
889
945
  export async function updateDocuments( req, res ) {
890
946
  try {
947
+ const bucket = JSON.parse( process.env.BUCKET );
948
+ const openSearch = JSON.parse( process.env.OPENSEARCH );
891
949
  let updateKeys = [];
892
950
 
893
951
  if ( req.files?.addressDoc ) {
894
952
  const uploadDataParams = {
895
- Bucket: appConfig.cloud.aws.bucket.assets,
953
+ Bucket: bucket.assets,
896
954
  Key: `${req.params.id}/documents/`,
897
955
  fileName: `addressCertificate.${req.files.addressDoc.name.split( '.' )[1]}`,
898
956
  ContentType: req.files.addressDoc.mimetype,
@@ -905,7 +963,7 @@ export async function updateDocuments( req, res ) {
905
963
  }
906
964
  if ( req.files?.gstDoc ) {
907
965
  const uploadDataParams = {
908
- Bucket: appConfig.cloud.aws.bucket.assets,
966
+ Bucket: bucket.assets,
909
967
  Key: `${req.params.id}/documents/`,
910
968
  fileName: `gstCertificate.${req.files.gstDoc.name.split( '.' )[1]}`,
911
969
  ContentType: req.files.gstDoc.mimetype,
@@ -918,7 +976,7 @@ export async function updateDocuments( req, res ) {
918
976
  }
919
977
  if ( req.files?.panDoc ) {
920
978
  const uploadDataParams = {
921
- Bucket: appConfig.cloud.aws.bucket.assets,
979
+ Bucket: bucket.assets,
922
980
  Key: `${req.params.id}/documents/`,
923
981
  fileName: `panCertificate.${req.files.panDoc.name.split( '.' )[1]}`,
924
982
  ContentType: req.files.panDoc.mimetype,
@@ -931,7 +989,7 @@ export async function updateDocuments( req, res ) {
931
989
  }
932
990
  if ( req.files?.cinDoc ) {
933
991
  const uploadDataParams = {
934
- Bucket: appConfig.cloud.aws.bucket.assets,
992
+ Bucket: bucket.assets,
935
993
  Key: `${req.params.id}/documents/`,
936
994
  fileName: `cinCertificate.${req.files.cinDoc.name.split( '.' )[1]}`,
937
995
  ContentType: req.files.cinDoc.mimetype,
@@ -974,7 +1032,7 @@ export async function updateDocuments( req, res ) {
974
1032
  };
975
1033
 
976
1034
  if ( updateKeys.length ) {
977
- await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
1035
+ await insertOpenSearchData( openSearch.activityLog, logObj );
978
1036
  }
979
1037
 
980
1038
  if ( updateAck ) {
@@ -988,11 +1046,12 @@ export async function updateDocuments( req, res ) {
988
1046
 
989
1047
  export async function getAuditConfiguration( req, res ) {
990
1048
  try {
1049
+ const bucket = JSON.parse( process.env.BUCKET );
991
1050
  const auditConfig = await auditConfigurationGet( { storeId: req.params?.id } );
992
1051
  if ( auditConfig ) {
993
- const isDocExist = await checkFileExist( { Bucket: appConfig.cloud.aws.bucket.assets, Key: `templates/audit_bulk_update.xlsx` } );
1052
+ const isDocExist = await checkFileExist( { Bucket: bucket.assets, Key: `templates/audit_bulk_update.xlsx` } );
994
1053
  if ( isDocExist ) {
995
- const signedFilUrl = await signedUrl( { Bucket: appConfig.cloud.aws.bucket.assets, file_path: `templates/audit_bulk_update.xlsx` } );
1054
+ const signedFilUrl = await signedUrl( { Bucket: bucket.assets, file_path: `templates/audit_bulk_update.xlsx` } );
996
1055
  auditConfig._doc.templateUrl = signedFilUrl;
997
1056
  } else {
998
1057
  auditConfig._doc.templateUrl = '';
@@ -1010,6 +1069,7 @@ export async function getAuditConfiguration( req, res ) {
1010
1069
 
1011
1070
  export async function auditConfiguration( req, res ) {
1012
1071
  try {
1072
+ const openSearch = JSON.parse( process.env.OPENSEARCH );
1013
1073
  for ( let i = 0; i < req.body?.length; i++ ) {
1014
1074
  const previousStore = await findOneStore( { storeId: req.body[i].storeId }, { auditConfigs: 1, _id: 0 } );
1015
1075
  await auditConfigurationUpdate( {
@@ -1039,7 +1099,7 @@ export async function auditConfiguration( req, res ) {
1039
1099
  },
1040
1100
  };
1041
1101
 
1042
- await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
1102
+ await insertOpenSearchData( openSearch.activityLog, logObj );
1043
1103
  }
1044
1104
 
1045
1105
 
@@ -1081,9 +1141,11 @@ export async function clientList( req, res ) {
1081
1141
  userType: 'tango',
1082
1142
  $expr: {
1083
1143
  $cond: {
1084
- if: { $and: [
1085
- { $eq: [ '$tangoUserType', 'csm' ] },
1086
- ] },
1144
+ if: {
1145
+ $and: [
1146
+ { $eq: [ '$tangoUserType', 'csm' ] },
1147
+ ],
1148
+ },
1087
1149
  then: { $eq: [ '$isClientApproved', true ] },
1088
1150
  else: true,
1089
1151
  },
@@ -1100,7 +1162,7 @@ export async function clientList( req, res ) {
1100
1162
  ];
1101
1163
  const clientIdList = await aggregateUserAssignedStore( query );
1102
1164
  logger.info( { message: clientIdList, value: 'clientIdList' } );
1103
- if ( clientIdList.length ==0 ) {
1165
+ if ( clientIdList.length == 0 ) {
1104
1166
  return res.sendError( 'No Data Found', 204 );
1105
1167
  }
1106
1168
 
@@ -1369,7 +1431,7 @@ export async function clientList( req, res ) {
1369
1431
  'client Id': chunk[i]?.clientId,
1370
1432
  'Installation Stores Count': chunk[i]?.installedStores || 0,
1371
1433
  'Onboarded Stores Count': chunk[i]?.totalStores,
1372
- 'Store Progress': chunk[i]?.installedStores? `${ ( ( chunk[i]?.installedStores/ chunk[i]?.totalStores )* 100 ).toFixed( 0 )}%`: '0%',
1434
+ 'Store Progress': chunk[i]?.installedStores ? `${( ( chunk[i]?.installedStores / chunk[i]?.totalStores ) * 100 ).toFixed( 0 )}%` : '0%',
1373
1435
  'Active Store': chunk[i]?.activeStoreCount || 0,
1374
1436
  'Active Camera': chunk[i]?.activeCameraCount && chunk[i]?.activeCameraCount != undefined ? chunk[i]?.activeCameraCount : 0,
1375
1437
  'Pending Stores': chunk[i]?.pendingStores || 0,
@@ -1392,7 +1454,344 @@ export async function clientList( req, res ) {
1392
1454
  return res.sendError( 'Internal Server Error', 500 );
1393
1455
  }
1394
1456
  }
1457
+ export async function clientListV1( req, res ) {
1458
+ try {
1459
+ const inputData = req.body;
1460
+ let clientQuery = [];
1461
+ logger.info( { message: req?.user?.role } );
1462
+ if ( req?.user?.role !== 'superadmin' ) {
1463
+ const query = [
1464
+ {
1465
+ $match: {
1466
+ userEmail: { $eq: req?.user?.email },
1467
+ userType: 'tango',
1468
+ $expr: {
1469
+ $cond: {
1470
+ if: {
1471
+ $and: [
1472
+ { $eq: [ '$tangoUserType', 'csm' ] },
1473
+ ],
1474
+ },
1475
+ then: { $eq: [ '$isClientApproved', true ] },
1476
+ else: true,
1477
+ },
1478
+ },
1479
+
1480
+ },
1481
+ },
1482
+ {
1483
+ $group: {
1484
+ _id: null,
1485
+ clientList: { $push: '$assignedValue' },
1486
+ },
1487
+ },
1488
+ ];
1489
+ const clientIdList = await aggregateUserAssignedStore( query );
1490
+ logger.info( { message: clientIdList, value: 'clientIdList' } );
1491
+ if ( clientIdList.length == 0 ) {
1492
+ return res.sendError( 'No Data Found', 204 );
1493
+ }
1494
+ clientQuery.push(
1495
+ {
1496
+ $match: {
1497
+ clientId: { $in: clientIdList[0].clientList },
1498
+ },
1499
+ },
1500
+ );
1501
+ }
1502
+ clientQuery.push(
1503
+ {
1504
+ $project: {
1505
+ status: 1,
1506
+ clientName: 1,
1507
+ clientId: 1,
1508
+ subscriptionType: '$planDetails.subscriptionType',
1509
+ PaymentPlan: '$planDetails.paymentStatus',
1510
+ },
1511
+ },
1512
+ );
1513
+ if ( inputData.filterByPaymentStatus ) {
1514
+ if ( inputData.filterByPaymentStatus.includes( 'paid' ) ) {
1515
+ inputData.filterByPaymentStatus.push( ...[ 'unbilled', 'due' ] );
1516
+ }
1395
1517
 
1518
+ clientQuery.push(
1519
+ {
1520
+ $match: {
1521
+ 'PaymentPlan': { $in: inputData.filterByPaymentStatus },
1522
+ },
1523
+ },
1524
+ );
1525
+ }
1526
+ if ( inputData.filterBySubscription ) {
1527
+ clientQuery.push(
1528
+ {
1529
+ $match: {
1530
+ 'subscriptionType': { $in: inputData.filterBySubscription },
1531
+ },
1532
+ },
1533
+ );
1534
+ }
1535
+ if ( inputData.filterByStatus ) {
1536
+ clientQuery.push(
1537
+ {
1538
+ $match: {
1539
+ status: { $in: inputData.filterByStatus },
1540
+ },
1541
+ },
1542
+ );
1543
+ }
1544
+ if ( inputData.searchValue && inputData.searchValue != '' ) {
1545
+ clientQuery.push( {
1546
+ $match: {
1547
+ $or: [
1548
+ { clientId: { $regex: inputData.searchValue, $options: 'i' } },
1549
+ { clientName: { $regex: inputData.searchValue, $options: 'i' } },
1550
+ { subscriptionType: { $regex: inputData.searchValue, $options: 'i' } },
1551
+ { status: { $regex: inputData.searchValue, $options: 'i' } },
1552
+ ],
1553
+ },
1554
+ } );
1555
+ }
1556
+ clientQuery.push( {
1557
+ $lookup: {
1558
+ from: 'stores',
1559
+ let: { clientId: '$clientId' },
1560
+ pipeline: [
1561
+ {
1562
+ $match: {
1563
+ $expr: {
1564
+ $and: [
1565
+ { $eq: [ '$clientId', '$$clientId' ] },
1566
+ ],
1567
+ },
1568
+ },
1569
+ },
1570
+ {
1571
+ $project: {
1572
+ edge: 1,
1573
+ status: 1,
1574
+ clientId: 1,
1575
+ storeId: 1,
1576
+ },
1577
+ },
1578
+ ], as: 'stores',
1579
+ },
1580
+ },
1581
+
1582
+ {
1583
+ $unwind: { path: '$stores', preserveNullAndEmptyArrays: true },
1584
+ },
1585
+ {
1586
+ $project: {
1587
+ clientId: 1,
1588
+ status: 1,
1589
+ clientName: 1,
1590
+ subscriptionType: 1,
1591
+ PaymentPlan: 1,
1592
+ installed: {
1593
+ $cond: [ { $or: [ { $eq: [ '$stores.edge.firstFile', true ] } ] }, 1, 0,
1594
+ ],
1595
+ },
1596
+ activeStores: {
1597
+ $cond: [ { $and: [ { $eq: [ '$stores.status', 'active' ] } ] }, 1, 0,
1598
+ ],
1599
+ },
1600
+ InactiveStores: {
1601
+ $cond: [ { $and: [ { $ne: [ '$stores.status', 'active' ] } ] }, 1, 0,
1602
+ ],
1603
+ },
1604
+ },
1605
+ },
1606
+ {
1607
+ $group: {
1608
+ _id: '$clientId',
1609
+ clientId: { $first: '$clientId' },
1610
+ onboardedStores: { $sum: 1 },
1611
+ installedStore: { $sum: '$installed' },
1612
+ activeStores: { $sum: '$activeStores' },
1613
+ InactiveStores: { $sum: '$InactiveStores' },
1614
+ ProcessingStatus: { $first: '$status' },
1615
+ clientName: { $first: '$clientName' },
1616
+ subscriptionPlan: { $first: '$subscriptionType' },
1617
+ PaymentPlan: { $first: '$PaymentPlan' },
1618
+ },
1619
+ },
1620
+ {
1621
+ $lookup: {
1622
+ from: 'tangoTicket',
1623
+ let: { clientId: '$clientId' },
1624
+ pipeline: [
1625
+ {
1626
+ $match: {
1627
+ $expr: {
1628
+ $and: [
1629
+ { $eq: [ '$issueType', 'installation' ] },
1630
+ { $eq: [ '$basicDetails.clientId', '$$clientId' ] },
1631
+ ],
1632
+ },
1633
+ },
1634
+
1635
+ },
1636
+ {
1637
+ $project: {
1638
+ ticketDetails: 1,
1639
+ status: 1,
1640
+ basicDetails: 1,
1641
+ },
1642
+ },
1643
+ ], as: 'ticket',
1644
+ },
1645
+ },
1646
+ {
1647
+ $unwind: { path: '$ticket', preserveNullAndEmptyArrays: true },
1648
+ },
1649
+ {
1650
+ $project: {
1651
+ clientId: 1,
1652
+ ProcessingStatus: 1,
1653
+ onboardedStores: 1,
1654
+ clientName: 1,
1655
+ PaymentPlan: 1,
1656
+ subscriptionPlan: 1,
1657
+ installedStore: 1,
1658
+ activeStores: 1,
1659
+ InactiveStores: 1,
1660
+ installedPending: {
1661
+ $cond: [ { $and: [ { $ne: [ '$ticket.status', 'closed' ] } ] }, 1, 0 ],
1662
+ },
1663
+ installedFailed: {
1664
+ $cond: [ { $and: [ { $ne: [ '$ticket.status', 'closed' ] }, { $eq: [ '$ticket.ticketDetails.issueStatus', 'identified' ] } ] }, 1, 0 ],
1665
+ },
1666
+ },
1667
+ },
1668
+ {
1669
+ $group: {
1670
+ _id: '$clientId',
1671
+ clientId: { $first: '$clientId' },
1672
+ onboardedStores: { $first: '$onboardedStores' },
1673
+ installedStore: { $first: '$installedStore' },
1674
+ activeStores: { $first: '$activeStores' },
1675
+ InactiveStores: { $first: '$InactiveStores' },
1676
+ ProcessingStatus: { $first: '$ProcessingStatus' },
1677
+ clientName: { $first: '$clientName' },
1678
+ subscriptionPlan: { $first: '$subscriptionPlan' },
1679
+ PaymentPlan: { $first: '$PaymentPlan' },
1680
+ installedPending: { $sum: '$installedPending' },
1681
+ installedFailed: { $sum: '$installedFailed' },
1682
+ },
1683
+ },
1684
+ {
1685
+ $project: {
1686
+ clientId: { $toInt: '$clientId' },
1687
+ onboardedStores: 1,
1688
+ installedStore: 1,
1689
+ activeStores: { $max: [
1690
+ { $subtract: [ '$activeStores', '$installedPending' ] },
1691
+ 0,
1692
+ ] },
1693
+ InactiveStores: 1,
1694
+ ProcessingStatus: 1,
1695
+ clientName: 1,
1696
+ subscriptionPlan: 1,
1697
+ PaymentPlan: 1,
1698
+ PaymentPlan: {
1699
+ $cond: {
1700
+ if: { $eq: [ '$PaymentPlan', 'unbilled' ] },
1701
+ then: 'paid',
1702
+ else: {
1703
+ $cond: {
1704
+ if: { $eq: [ '$PaymentPlan', 'due' ] },
1705
+ then: 'paid',
1706
+ else: '$PaymentPlan',
1707
+ },
1708
+ },
1709
+ },
1710
+ },
1711
+ installedPending: 1,
1712
+ installedFailed: 1,
1713
+ ProgressBar: {
1714
+ $cond: {
1715
+ if: { $eq: [ '$onboardedStores', 0 ] },
1716
+ then: 0,
1717
+ else: {
1718
+ $round: [
1719
+ { $multiply: [ { $divide: [ '$installedStore', '$onboardedStores' ] }, 100 ] },
1720
+ 0,
1721
+ ],
1722
+ },
1723
+ },
1724
+ },
1725
+ },
1726
+ },
1727
+ );
1728
+
1729
+ const clientCount = await aggregateClient( clientQuery );
1730
+ if ( clientCount.length == 0 ) {
1731
+ return res.sendError( 'No Data Found', 204 );
1732
+ }
1733
+
1734
+ if ( inputData.sortColumName&&inputData.sortColumName!=''&& req.body.sortBy&&req.body.sortBy!='' ) {
1735
+ clientQuery.push( {
1736
+ $sort: { [req.body.sortColumName]: req.body.sortBy },
1737
+ },
1738
+ );
1739
+ } else {
1740
+ clientQuery.push( {
1741
+ $sort: { activeStores: -1 },
1742
+ },
1743
+ );
1744
+ }
1745
+ clientQuery.push( {
1746
+ $project: {
1747
+ clientId: { $toString: '$clientId' },
1748
+ onboardedStores: 1,
1749
+ installedStore: 1,
1750
+ activeStores: 1,
1751
+ InactiveStores: 1,
1752
+ ProcessingStatus: 1,
1753
+ clientName: 1,
1754
+ subscriptionPlan: 1,
1755
+ PaymentPlan: 1,
1756
+ installedPending: 1,
1757
+ installedFailed: 1,
1758
+ ProgressBar: 1,
1759
+ },
1760
+ } );
1761
+ if ( req.body.limit && req.body.offset && !req.body.isExport ) {
1762
+ clientQuery.push(
1763
+ { $skip: ( req.body.offset - 1 ) * req.body.limit },
1764
+ { $limit: Number( req.body.limit ) },
1765
+ );
1766
+ }
1767
+ const clientList = await aggregateClient( clientQuery );
1768
+
1769
+ if ( inputData.isExport ) {
1770
+ const exportResult = [];
1771
+ for ( let client of clientList ) {
1772
+ exportResult.push( {
1773
+ 'Brand Name': client.clientName,
1774
+ 'Brand ID': client.clientId,
1775
+ 'Onboarded Stores': client.onboardedStores||0,
1776
+ 'Installed Stores': client.installedStore || 0,
1777
+ 'Progress Status': client.ProgressBar||0,
1778
+ 'Active Stores': client.activeStores || 0,
1779
+ 'In-Active Stores': client.InactiveStores || 0,
1780
+ 'Pending Configuration': client.installedPending || 0,
1781
+ 'Payment Plan': client.PaymentPlan == 'free'?'Lifetime Free':client.PaymentPlan,
1782
+ 'Subscription Plan': client.subscriptionPlan,
1783
+ 'Processing Status': client.ProcessingStatus=='active'?'Activated':client.ProcessingStatus=='deactive'?'Deactivated':client.ProcessingStatus,
1784
+ } );
1785
+ }
1786
+ await download( exportResult, res );
1787
+ return;
1788
+ }
1789
+ return res.sendSuccess( { result: clientList, count: clientCount.length } );
1790
+ } catch ( error ) {
1791
+ logger.error( { error: error, function: 'clientList' } );
1792
+ return res.sendError( 'Internal Server Error', 500 );
1793
+ }
1794
+ }
1396
1795
  export async function getOpsUsers( req, res ) {
1397
1796
  try {
1398
1797
  const users = await OpsUsersGet();
@@ -1410,6 +1809,7 @@ export async function getOpsUsers( req, res ) {
1410
1809
 
1411
1810
  export async function detailedClientCount( req, res ) {
1412
1811
  try {
1812
+ const bucket = JSON.parse( process.env.BUCKET );
1413
1813
  const inputData = req.query;
1414
1814
  let result = {
1415
1815
  clientName: inputData.clientName,
@@ -1423,10 +1823,10 @@ export async function detailedClientCount( req, res ) {
1423
1823
  const client = await findOneClient( { clientId: inputData.clientId }, { userId: 1, clientId: 1, profileDetails: 1 } );
1424
1824
  const user = await findOneUser( { _id: client.userId }, { userName: 1, email: 1 } );
1425
1825
 
1426
- const isLogoExist = await checkFileExist( { Bucket: appConfig.cloud.aws.bucket.assets, Key: `${client.clientId}/logo/${client.profileDetails?.logo}` } );
1826
+ const isLogoExist = await checkFileExist( { Bucket: bucket.assets, Key: `${client.clientId}/logo/${client.profileDetails?.logo}` } );
1427
1827
 
1428
1828
  if ( isLogoExist ) {
1429
- const signedFilUrl = await signedUrl( { Bucket: appConfig.cloud.aws.bucket.assets, file_path: `${client.clientId}/logo/${client.profileDetails?.logo}` } );
1829
+ const signedFilUrl = await signedUrl( { Bucket: bucket.assets, file_path: `${client.clientId}/logo/${client.profileDetails?.logo}` } );
1430
1830
  result['logo'] = signedFilUrl;
1431
1831
  } else {
1432
1832
  result['logo'] = '';
@@ -1434,6 +1834,19 @@ export async function detailedClientCount( req, res ) {
1434
1834
  result['userName'] = user?.userName;
1435
1835
  result['email'] = user?.email;
1436
1836
  result['profileCompletion'] = 70;
1837
+ let findCsm = await aggregateUserAssignedStore( [
1838
+ {
1839
+ $match: {
1840
+ clientId: inputData.clientId,
1841
+ tangoUserType: 'csm',
1842
+ },
1843
+ },
1844
+ ] );
1845
+
1846
+ if ( findCsm&&findCsm.length>0 ) {
1847
+ let finduser = await findOneUser( { email: findCsm[0].userEmail }, { userName: 1, email: 1, countryCode: 1, mobileNumber: 1 } );
1848
+ result['csm'] = finduser;
1849
+ }
1437
1850
 
1438
1851
  return res.sendSuccess( { result: result } );
1439
1852
  } catch ( error ) {
@@ -1444,6 +1857,7 @@ export async function detailedClientCount( req, res ) {
1444
1857
 
1445
1858
  export async function getActivityLogs( req, res ) {
1446
1859
  try {
1860
+ const openSearch = JSON.parse( process.env.OPENSEARCH );
1447
1861
  const query = {
1448
1862
  '_source': [
1449
1863
  'userId', 'userName', 'email', 'date', 'logType', 'logSubType',
@@ -1500,7 +1914,7 @@ export async function getActivityLogs( req, res ) {
1500
1914
  },
1501
1915
  );
1502
1916
 
1503
- const logs = await getOpenSearchData( appConfig.opensearch.activityLog, query );
1917
+ const logs = await getOpenSearchData( openSearch.activityLog, query );
1504
1918
 
1505
1919
  const hits = logs?.body?.hits?.hits;
1506
1920
  const totalDocuments = logs?.body?.hits?.total?.value;
@@ -108,6 +108,7 @@ export const featureConfigurationSchemaBody = joi.object(
108
108
  isNormalized: joi.boolean().optional(),
109
109
  isPasserByData: joi.boolean().optional(),
110
110
  isFootfallDirectory: joi.boolean().optional(),
111
+ isExcludedArea: joi.boolean().optional(),
111
112
  },
112
113
  );
113
114
 
@@ -5,7 +5,7 @@ import { auditConfiguration, changeStatus, clientCsmAssignAction, clientDetails,
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';
8
- import { detailedAllClientCount, detailedClientCount, clientList } from '../controllers/client.controllers.js';
8
+ import { detailedAllClientCount, detailedClientCount, clientList, clientListV1 } from '../controllers/client.controllers.js';
9
9
 
10
10
  export const clientRouter = express.Router();
11
11
 
@@ -83,7 +83,9 @@ clientRouter.get( '/detailed-all-client-count', isAllowedSessionHandler,
83
83
  clientRouter.post( '/client-list', isAllowedSessionHandler,
84
84
  authorize( { userType: [ 'tango' ], access: [ { featureName: 'manage', name: 'brands', permissions: [ 'isView' ] } ] } ),
85
85
  validate( clientListValid ), clientList );
86
-
86
+ clientRouter.post( '/client-list_v1', isAllowedSessionHandler,
87
+ authorize( { userType: [ 'tango' ], access: [ { featureName: 'manage', name: 'brands', permissions: [ 'isView' ] } ] } ),
88
+ validate( clientListValid ), clientListV1 );
87
89
  clientRouter.get( '/detailed-client-count', isAllowedSessionHandler,
88
90
  authorize( { userType: [ 'tango', 'client' ] } ),
89
91
  validate( detailedClientCountValid ), isclientIdExists, detailedClientCount );
@@ -2,7 +2,7 @@ import clientModel from 'tango-api-schema/schema/client.model.js';
2
2
  import leadModel from 'tango-api-schema/schema/lead.model.js';
3
3
  import storeModel from 'tango-api-schema/schema/store.model.js';
4
4
  import userModel from 'tango-api-schema/schema/user.model.js';
5
- import { createQueue, getQueueUrl, appConfig, logger } from 'tango-app-api-middleware';
5
+ import { createQueue, getQueueUrl, logger } from 'tango-app-api-middleware';
6
6
 
7
7
 
8
8
  export function update( query, record ) {
@@ -27,10 +27,11 @@ export function findClient( query, field ) {
27
27
 
28
28
  export async function createAuditQueue( queueName ) {
29
29
  try {
30
- const isExist = await getQueueUrl( `${queueName}${appConfig.cloud.aws.sqs.queueType}` );
30
+ const sqs = JSON.parse( process.env.SQS );
31
+ const isExist = await getQueueUrl( `${queueName}${sqs.queueType}` );
31
32
  logger.info( { message: isExist, function: 'createAuditQueue-isExist' } );
32
33
  if ( isExist.statusCode ) {
33
- const addQueue = await createQueue( `${queueName}${appConfig.cloud.aws.sqs.queueType}` );
34
+ const addQueue = await createQueue( `${queueName}${sqs.queueType}` );
34
35
  logger.info( { message: addQueue.QueueUrl, function: 'addQueue.QueueUrl' } );
35
36
  if ( addQueue.QueueUrl ) {
36
37
  logger.info(
@@ -131,7 +132,7 @@ export function featureConfigurationUpdate( {
131
132
  clientId, billableCalculation, bouncedLimitCondition, bouncedLimitValue,
132
133
  close, conversionCalculation, conversionCondition,
133
134
  conversionValue, infraAlertCondition, infraAlertValue, isFootfallDirectory,
134
- isNormalized, isPasserByData, missedOpportunityCalculation, open,
135
+ isNormalized, isPasserByData, missedOpportunityCalculation, open, isExcludedArea,
135
136
  } ) {
136
137
  return clientModel.updateOne( { clientId: clientId },
137
138
  {
@@ -150,6 +151,8 @@ export function featureConfigurationUpdate( {
150
151
  'featureConfigs.isNormalized': isNormalized,
151
152
  'featureConfigs.isPasserByData': isPasserByData,
152
153
  'featureConfigs.isFootfallDirectory': isFootfallDirectory,
154
+ 'featureConfigs.isExcludedArea': isExcludedArea,
155
+ 'featureConfigs.updateFeatureConfig': false,
153
156
  },
154
157
  } );
155
158
  }
@@ -3,3 +3,11 @@ import groupModel from 'tango-api-schema/schema/group.model.js';
3
3
  export function countDocumentsGroup( query ) {
4
4
  return groupModel.countDocuments( query );
5
5
  }
6
+
7
+ export async function createGroupModel( query ={}, field={} ) {
8
+ return await groupModel.create( query, field );
9
+ };
10
+
11
+ export async function findOneGroup( query ={}, field={} ) {
12
+ return await groupModel.findOne( query, field );
13
+ };
@@ -3,6 +3,9 @@ import storeModel from 'tango-api-schema/schema/store.model.js';
3
3
  export function countDocumentsStore( query ) {
4
4
  return storeModel.countDocuments( query );
5
5
  }
6
+ export function findStore( query ) {
7
+ return storeModel.find( query );
8
+ }
6
9
 
7
10
  export function aggregateStore( query ) {
8
11
  return storeModel.aggregate( query );