tango-app-api-client 3.0.57-dev → 3.0.59-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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-client",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.59-dev",
|
|
4
4
|
"description": "client",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"nodemon": "^3.0.3",
|
|
27
27
|
"swagger-ui-express": "^5.0.0",
|
|
28
28
|
"tango-api-schema": "^2.0.113",
|
|
29
|
-
"tango-app-api-middleware": "^1.
|
|
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,5 +1,5 @@
|
|
|
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,
|
|
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
4
|
import { aggregateStore, countDocumentsStore, findStore, findOneStore, updateManyStore } from '../service/store.service.js';
|
|
5
5
|
import { aggregateCamera, countDocumentsCamera } from '../service/camera.service.js';
|
|
@@ -16,6 +16,8 @@ import { deleteOneAuthentication } from '../service/authentication.service.js';
|
|
|
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
|
{
|
|
@@ -94,7 +96,7 @@ export async function create( req, res ) {
|
|
|
94
96
|
};
|
|
95
97
|
|
|
96
98
|
|
|
97
|
-
await postApi( `${
|
|
99
|
+
await postApi( `${url.oldapidomain}/oldGroupAdd`, [ oldGroup ] );
|
|
98
100
|
|
|
99
101
|
// For old dashboard insert
|
|
100
102
|
|
|
@@ -198,9 +200,9 @@ export async function create( req, res ) {
|
|
|
198
200
|
'role': 'storesuperadmin',
|
|
199
201
|
};
|
|
200
202
|
|
|
201
|
-
await postApi( `${
|
|
203
|
+
await postApi( `${url.oldapidomain}/oldBrandAdd`, oldBrandInsertData );
|
|
202
204
|
|
|
203
|
-
await postApi( `${
|
|
205
|
+
await postApi( `${url.oldapidomain}/oldDefaultRoleInsert`, oldDefaultRolesInsertData );
|
|
204
206
|
|
|
205
207
|
const logObj = {
|
|
206
208
|
clientId: insertedClientRecord.clientId,
|
|
@@ -215,7 +217,7 @@ export async function create( req, res ) {
|
|
|
215
217
|
showTo: [ 'client', 'tango' ],
|
|
216
218
|
};
|
|
217
219
|
|
|
218
|
-
await insertOpenSearchData(
|
|
220
|
+
await insertOpenSearchData( openSearch.activityLog, logObj );
|
|
219
221
|
|
|
220
222
|
for ( let index = 0; index < leadRecord?.planDetails?.product?.length; index++ ) {
|
|
221
223
|
const logObj = {
|
|
@@ -237,7 +239,7 @@ export async function create( req, res ) {
|
|
|
237
239
|
showTo: [ 'client', 'tango' ],
|
|
238
240
|
};
|
|
239
241
|
|
|
240
|
-
await insertOpenSearchData(
|
|
242
|
+
await insertOpenSearchData( openSearch.activityLog, logObj );
|
|
241
243
|
}
|
|
242
244
|
|
|
243
245
|
|
|
@@ -269,12 +271,14 @@ function convertTitleCase( data ) {
|
|
|
269
271
|
|
|
270
272
|
export const sendEmail = ( data ) => {
|
|
271
273
|
try {
|
|
274
|
+
const url = JSON.parse( process.env.URL );
|
|
275
|
+
const ses = JSON.parse( process.env.SES );
|
|
272
276
|
const attachments = null;
|
|
273
277
|
const subject = data.subject;
|
|
274
278
|
const fileContent = readFileSync( join() + data.path, 'utf8' );
|
|
275
279
|
const htmlContent = handlebars.compile( fileContent );
|
|
276
|
-
const html = htmlContent( { url:
|
|
277
|
-
return sendEmailWithSES( data.email, subject, html, attachments,
|
|
280
|
+
const html = htmlContent( { url: url.store, logo: `${url.apiDomain}/logo.png` } );
|
|
281
|
+
return sendEmailWithSES( data.email, subject, html, attachments, ses.adminEmail );
|
|
278
282
|
} catch ( error ) {
|
|
279
283
|
return error;
|
|
280
284
|
}
|
|
@@ -381,61 +385,62 @@ export async function getClients( req, res ) {
|
|
|
381
385
|
|
|
382
386
|
export async function clientDetails( req, res ) {
|
|
383
387
|
try {
|
|
388
|
+
const bucket = JSON.parse( process.env.BUCKET );
|
|
384
389
|
const client = await getClientData( { id: req.params.id } );
|
|
385
390
|
if ( client ) {
|
|
386
|
-
const isLogoExist = await checkFileExist( { Bucket:
|
|
387
|
-
const isGstCertificateExist = await checkFileExist( { Bucket:
|
|
388
|
-
const isAddressCertificateExist = await checkFileExist( { Bucket:
|
|
389
|
-
const isPanCertificateExist = await checkFileExist( { Bucket:
|
|
390
|
-
const isCinCertificateExist = await checkFileExist( { Bucket:
|
|
391
|
-
const isContractCertificateExist = await checkFileExist( { Bucket:
|
|
392
|
-
const isTermsAndConditionsExist = await checkFileExist( { Bucket:
|
|
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` } );
|
|
393
398
|
|
|
394
399
|
|
|
395
400
|
if ( isLogoExist ) {
|
|
396
|
-
const signedFilUrl = await signedUrl( { Bucket:
|
|
401
|
+
const signedFilUrl = await signedUrl( { Bucket: bucket.assets, file_path: `${client.clientId}/logo/${client.profileDetails?.logo}` } );
|
|
397
402
|
client.profileDetails.logo = signedFilUrl;
|
|
398
403
|
} else {
|
|
399
404
|
client.profileDetails.logo = '';
|
|
400
405
|
}
|
|
401
406
|
|
|
402
407
|
if ( isGstCertificateExist ) {
|
|
403
|
-
const signedFilUrl = await signedUrl( { Bucket:
|
|
408
|
+
const signedFilUrl = await signedUrl( { Bucket: bucket.assets, file_path: `${client.clientId}/documents/${client.document?.gst?.path}` } );
|
|
404
409
|
client.document.gst.path = signedFilUrl;
|
|
405
410
|
} else {
|
|
406
411
|
client.document.gst.path = '';
|
|
407
412
|
}
|
|
408
413
|
|
|
409
414
|
if ( isAddressCertificateExist ) {
|
|
410
|
-
const signedFilUrl = await signedUrl( { Bucket:
|
|
415
|
+
const signedFilUrl = await signedUrl( { Bucket: bucket.assets, file_path: `${client.clientId}/documents/${client.document?.addressProof?.path}` } );
|
|
411
416
|
client.document.addressProof.path = signedFilUrl;
|
|
412
417
|
} else {
|
|
413
418
|
client.document.addressProof.path = '';
|
|
414
419
|
}
|
|
415
420
|
|
|
416
421
|
if ( isPanCertificateExist ) {
|
|
417
|
-
const signedFilUrl = await signedUrl( { Bucket:
|
|
422
|
+
const signedFilUrl = await signedUrl( { Bucket: bucket.assets, file_path: `${client.clientId}/documents/${client.document?.pan?.path}` } );
|
|
418
423
|
client.document.pan.path = signedFilUrl;
|
|
419
424
|
} else {
|
|
420
425
|
client.document.pan.path = '';
|
|
421
426
|
}
|
|
422
427
|
|
|
423
428
|
if ( isCinCertificateExist ) {
|
|
424
|
-
const signedFilUrl = await signedUrl( { Bucket:
|
|
429
|
+
const signedFilUrl = await signedUrl( { Bucket: bucket.assets, file_path: `${client.clientId}/documents/${client.document?.cin?.path}` } );
|
|
425
430
|
client.document.cin.path = signedFilUrl;
|
|
426
431
|
} else {
|
|
427
432
|
client.document.cin.path = '';
|
|
428
433
|
}
|
|
429
434
|
|
|
430
435
|
if ( isContractCertificateExist ) {
|
|
431
|
-
const signedFilUrl = await signedUrl( { Bucket:
|
|
436
|
+
const signedFilUrl = await signedUrl( { Bucket: bucket.assets, file_path: `documents/contract.pdf` } );
|
|
432
437
|
client._doc.document.contract = signedFilUrl;
|
|
433
438
|
} else {
|
|
434
439
|
client._doc.document.contract = '';
|
|
435
440
|
}
|
|
436
441
|
|
|
437
442
|
if ( isTermsAndConditionsExist ) {
|
|
438
|
-
const signedFilUrl = await signedUrl( { Bucket:
|
|
443
|
+
const signedFilUrl = await signedUrl( { Bucket: bucket.assets, file_path: `documents/terms&conditions.pdf` } );
|
|
439
444
|
client._doc.document.termsAndconditions = signedFilUrl;
|
|
440
445
|
} else {
|
|
441
446
|
client._doc.document.termsAndconditions = '';
|
|
@@ -547,11 +552,14 @@ function camelCaseToWords( camelCaseString ) {
|
|
|
547
552
|
|
|
548
553
|
export async function updateBrandInfo( req, res ) {
|
|
549
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 );
|
|
550
558
|
let updateKeys = [];
|
|
551
559
|
|
|
552
560
|
if ( req.files?.logo ) {
|
|
553
561
|
const uploadDataParams = {
|
|
554
|
-
Bucket:
|
|
562
|
+
Bucket: bucket.assets,
|
|
555
563
|
Key: `${req.params.id}/logo/`,
|
|
556
564
|
fileName: `brandLogo.${req.files.logo.name.split( '.' )[1]}`,
|
|
557
565
|
ContentType: req.files.logo.mimetype,
|
|
@@ -583,7 +591,7 @@ export async function updateBrandInfo( req, res ) {
|
|
|
583
591
|
};
|
|
584
592
|
|
|
585
593
|
if ( updateKeys.length ) {
|
|
586
|
-
await insertOpenSearchData(
|
|
594
|
+
await insertOpenSearchData( openSearch.activityLog, logObj );
|
|
587
595
|
}
|
|
588
596
|
|
|
589
597
|
|
|
@@ -613,7 +621,7 @@ export async function updateBrandInfo( req, res ) {
|
|
|
613
621
|
await updateManyUser( { clientId: req.params?.id }, { isActive: false } );
|
|
614
622
|
}
|
|
615
623
|
|
|
616
|
-
const { data } = await getApi( `${
|
|
624
|
+
const { data } = await getApi( `${url.oldapidomain}/oldBrandGet/${req.params?.id}` );
|
|
617
625
|
|
|
618
626
|
switch ( req.body?.status ) {
|
|
619
627
|
case 'active':
|
|
@@ -632,7 +640,7 @@ export async function updateBrandInfo( req, res ) {
|
|
|
632
640
|
data.clientStatus = 'live';
|
|
633
641
|
}
|
|
634
642
|
|
|
635
|
-
await postApi( `${
|
|
643
|
+
await postApi( `${url.oldapidomain}/oldBrandUpdate/${data?._id}`, { clientStatus: data.clientStatus } );
|
|
636
644
|
|
|
637
645
|
if ( updateAck ) {
|
|
638
646
|
res.sendSuccess( { result: 'Updated Successfully' } );
|
|
@@ -645,11 +653,13 @@ export async function updateBrandInfo( req, res ) {
|
|
|
645
653
|
|
|
646
654
|
export async function updateBillingDetails( req, res ) {
|
|
647
655
|
try {
|
|
656
|
+
const bucket = JSON.parse( process.env.BUCKET );
|
|
657
|
+
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
648
658
|
let updateKeys = [];
|
|
649
659
|
|
|
650
660
|
if ( req.files?.gstCertificate ) {
|
|
651
661
|
const uploadDataParams = {
|
|
652
|
-
Bucket:
|
|
662
|
+
Bucket: bucket.assets,
|
|
653
663
|
Key: `${req.params.id}/documents/`,
|
|
654
664
|
fileName: `gstCertificate.${req.files.gstCertificate.name.split( '.' )[1]}`,
|
|
655
665
|
ContentType: req.files.gstCertificate.mimetype,
|
|
@@ -680,7 +690,7 @@ export async function updateBillingDetails( req, res ) {
|
|
|
680
690
|
};
|
|
681
691
|
|
|
682
692
|
if ( updateKeys.length ) {
|
|
683
|
-
await insertOpenSearchData(
|
|
693
|
+
await insertOpenSearchData( openSearch.activityLog, logObj );
|
|
684
694
|
}
|
|
685
695
|
|
|
686
696
|
|
|
@@ -700,6 +710,7 @@ export async function updateBillingDetails( req, res ) {
|
|
|
700
710
|
|
|
701
711
|
export async function updateSignatoryDetails( req, res ) {
|
|
702
712
|
try {
|
|
713
|
+
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
703
714
|
let updateKeys = [];
|
|
704
715
|
if ( Object.keys( req.body ).length > 0 ) {
|
|
705
716
|
Object.keys( req.body ).forEach( ( element ) => {
|
|
@@ -722,7 +733,7 @@ export async function updateSignatoryDetails( req, res ) {
|
|
|
722
733
|
};
|
|
723
734
|
|
|
724
735
|
if ( updateKeys.length ) {
|
|
725
|
-
await insertOpenSearchData(
|
|
736
|
+
await insertOpenSearchData( openSearch.activityLog, logObj );
|
|
726
737
|
}
|
|
727
738
|
|
|
728
739
|
const updateAck = await signatoryDetailsUpdate( {
|
|
@@ -740,6 +751,7 @@ export async function updateSignatoryDetails( req, res ) {
|
|
|
740
751
|
|
|
741
752
|
export async function updateTicketConfiguration( req, res ) {
|
|
742
753
|
try {
|
|
754
|
+
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
743
755
|
const updateAck = await ticketConfigurationUpdate( {
|
|
744
756
|
clientId: req.params?.id, MinFilesCount: req.body?.MinFilesCount, accuracyPercentage: req.body?.accuracyPercentage, downTimeType: req.body?.downTimeType,
|
|
745
757
|
infraDownTime: req.body?.infraDownTime, installationReAssign: req.body?.installationReAssign, isRcaTicketAssign: req.body?.isRcaTicketAssign,
|
|
@@ -769,7 +781,7 @@ export async function updateTicketConfiguration( req, res ) {
|
|
|
769
781
|
};
|
|
770
782
|
|
|
771
783
|
if ( updateKeys.length ) {
|
|
772
|
-
await insertOpenSearchData(
|
|
784
|
+
await insertOpenSearchData( openSearch.activityLog, logObj );
|
|
773
785
|
}
|
|
774
786
|
|
|
775
787
|
if ( updateAck ) {
|
|
@@ -783,6 +795,8 @@ export async function updateTicketConfiguration( req, res ) {
|
|
|
783
795
|
|
|
784
796
|
export async function updateFeatureConfiguration( req, res ) {
|
|
785
797
|
try {
|
|
798
|
+
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
799
|
+
const url = JSON.parse( process.env.URL );
|
|
786
800
|
const updateAck = await featureConfigurationUpdate( {
|
|
787
801
|
clientId: req.params?.id, billableCalculation: req.body?.billableCalculation, bouncedLimitCondition: req.body?.bouncedLimitCondition, bouncedLimitValue: req.body?.bouncedLimitValue,
|
|
788
802
|
close: req.body?.close, conversionCalculation: req.body?.conversionCalculation, conversionCondition: req.body?.conversionCondition,
|
|
@@ -801,7 +815,7 @@ export async function updateFeatureConfiguration( req, res ) {
|
|
|
801
815
|
|
|
802
816
|
const user = await getUserNameEmailById( req.userId );
|
|
803
817
|
|
|
804
|
-
const { data } = await getApi( `${
|
|
818
|
+
const { data } = await getApi( `${url.oldapidomain}/oldBrandGet/${req.params?.id}` );
|
|
805
819
|
|
|
806
820
|
if ( req.body?.open ) {
|
|
807
821
|
data.brandConfigs.storeOpenTime = req.body?.open;
|
|
@@ -843,7 +857,7 @@ export async function updateFeatureConfiguration( req, res ) {
|
|
|
843
857
|
data.brandConfigs.missedOpportunityEndTime = data.brandConfigs.missedOpportunityEndTime.replace( /\d+/, req.body?.conversionValue );
|
|
844
858
|
}
|
|
845
859
|
|
|
846
|
-
await postApi( `${
|
|
860
|
+
await postApi( `${url.oldapidomain}/oldBrandUpdate/${data?._id}`, { brandConfigs: data.brandConfigs } );
|
|
847
861
|
|
|
848
862
|
|
|
849
863
|
const logObj = {
|
|
@@ -858,7 +872,7 @@ export async function updateFeatureConfiguration( req, res ) {
|
|
|
858
872
|
showTo: [ 'client', 'tango' ],
|
|
859
873
|
};
|
|
860
874
|
if ( updateKeys.length ) {
|
|
861
|
-
await insertOpenSearchData(
|
|
875
|
+
await insertOpenSearchData( openSearch.activityLog, logObj );
|
|
862
876
|
}
|
|
863
877
|
|
|
864
878
|
if ( updateAck ) {
|
|
@@ -872,6 +886,7 @@ export async function updateFeatureConfiguration( req, res ) {
|
|
|
872
886
|
|
|
873
887
|
export async function domainDetailsConfiguration( req, res ) {
|
|
874
888
|
try {
|
|
889
|
+
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
875
890
|
const updateAck = await domainDetailsConfigurationUpdate( {
|
|
876
891
|
clientId: req.params?.id, domainName: req.body?.domainName, isEnable: req.body?.isEnable,
|
|
877
892
|
} );
|
|
@@ -901,7 +916,7 @@ export async function domainDetailsConfiguration( req, res ) {
|
|
|
901
916
|
};
|
|
902
917
|
|
|
903
918
|
if ( updateKeys.length ) {
|
|
904
|
-
await insertOpenSearchData(
|
|
919
|
+
await insertOpenSearchData( openSearch.activityLog, logObj );
|
|
905
920
|
}
|
|
906
921
|
|
|
907
922
|
if ( updateAck ) {
|
|
@@ -929,11 +944,13 @@ export async function userConfiguration( req, res ) {
|
|
|
929
944
|
|
|
930
945
|
export async function updateDocuments( req, res ) {
|
|
931
946
|
try {
|
|
947
|
+
const bucket = JSON.parse( process.env.BUCKET );
|
|
948
|
+
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
932
949
|
let updateKeys = [];
|
|
933
950
|
|
|
934
951
|
if ( req.files?.addressDoc ) {
|
|
935
952
|
const uploadDataParams = {
|
|
936
|
-
Bucket:
|
|
953
|
+
Bucket: bucket.assets,
|
|
937
954
|
Key: `${req.params.id}/documents/`,
|
|
938
955
|
fileName: `addressCertificate.${req.files.addressDoc.name.split( '.' )[1]}`,
|
|
939
956
|
ContentType: req.files.addressDoc.mimetype,
|
|
@@ -946,7 +963,7 @@ export async function updateDocuments( req, res ) {
|
|
|
946
963
|
}
|
|
947
964
|
if ( req.files?.gstDoc ) {
|
|
948
965
|
const uploadDataParams = {
|
|
949
|
-
Bucket:
|
|
966
|
+
Bucket: bucket.assets,
|
|
950
967
|
Key: `${req.params.id}/documents/`,
|
|
951
968
|
fileName: `gstCertificate.${req.files.gstDoc.name.split( '.' )[1]}`,
|
|
952
969
|
ContentType: req.files.gstDoc.mimetype,
|
|
@@ -959,7 +976,7 @@ export async function updateDocuments( req, res ) {
|
|
|
959
976
|
}
|
|
960
977
|
if ( req.files?.panDoc ) {
|
|
961
978
|
const uploadDataParams = {
|
|
962
|
-
Bucket:
|
|
979
|
+
Bucket: bucket.assets,
|
|
963
980
|
Key: `${req.params.id}/documents/`,
|
|
964
981
|
fileName: `panCertificate.${req.files.panDoc.name.split( '.' )[1]}`,
|
|
965
982
|
ContentType: req.files.panDoc.mimetype,
|
|
@@ -972,7 +989,7 @@ export async function updateDocuments( req, res ) {
|
|
|
972
989
|
}
|
|
973
990
|
if ( req.files?.cinDoc ) {
|
|
974
991
|
const uploadDataParams = {
|
|
975
|
-
Bucket:
|
|
992
|
+
Bucket: bucket.assets,
|
|
976
993
|
Key: `${req.params.id}/documents/`,
|
|
977
994
|
fileName: `cinCertificate.${req.files.cinDoc.name.split( '.' )[1]}`,
|
|
978
995
|
ContentType: req.files.cinDoc.mimetype,
|
|
@@ -1015,7 +1032,7 @@ export async function updateDocuments( req, res ) {
|
|
|
1015
1032
|
};
|
|
1016
1033
|
|
|
1017
1034
|
if ( updateKeys.length ) {
|
|
1018
|
-
await insertOpenSearchData(
|
|
1035
|
+
await insertOpenSearchData( openSearch.activityLog, logObj );
|
|
1019
1036
|
}
|
|
1020
1037
|
|
|
1021
1038
|
if ( updateAck ) {
|
|
@@ -1029,11 +1046,12 @@ export async function updateDocuments( req, res ) {
|
|
|
1029
1046
|
|
|
1030
1047
|
export async function getAuditConfiguration( req, res ) {
|
|
1031
1048
|
try {
|
|
1049
|
+
const bucket = JSON.parse( process.env.BUCKET );
|
|
1032
1050
|
const auditConfig = await auditConfigurationGet( { storeId: req.params?.id } );
|
|
1033
1051
|
if ( auditConfig ) {
|
|
1034
|
-
const isDocExist = await checkFileExist( { Bucket:
|
|
1052
|
+
const isDocExist = await checkFileExist( { Bucket: bucket.assets, Key: `templates/audit_bulk_update.xlsx` } );
|
|
1035
1053
|
if ( isDocExist ) {
|
|
1036
|
-
const signedFilUrl = await signedUrl( { Bucket:
|
|
1054
|
+
const signedFilUrl = await signedUrl( { Bucket: bucket.assets, file_path: `templates/audit_bulk_update.xlsx` } );
|
|
1037
1055
|
auditConfig._doc.templateUrl = signedFilUrl;
|
|
1038
1056
|
} else {
|
|
1039
1057
|
auditConfig._doc.templateUrl = '';
|
|
@@ -1051,6 +1069,7 @@ export async function getAuditConfiguration( req, res ) {
|
|
|
1051
1069
|
|
|
1052
1070
|
export async function auditConfiguration( req, res ) {
|
|
1053
1071
|
try {
|
|
1072
|
+
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
1054
1073
|
for ( let i = 0; i < req.body?.length; i++ ) {
|
|
1055
1074
|
const previousStore = await findOneStore( { storeId: req.body[i].storeId }, { auditConfigs: 1, _id: 0 } );
|
|
1056
1075
|
await auditConfigurationUpdate( {
|
|
@@ -1080,7 +1099,7 @@ export async function auditConfiguration( req, res ) {
|
|
|
1080
1099
|
},
|
|
1081
1100
|
};
|
|
1082
1101
|
|
|
1083
|
-
await insertOpenSearchData(
|
|
1102
|
+
await insertOpenSearchData( openSearch.activityLog, logObj );
|
|
1084
1103
|
}
|
|
1085
1104
|
|
|
1086
1105
|
|
|
@@ -1676,19 +1695,6 @@ export async function clientListV1( req, res ) {
|
|
|
1676
1695
|
clientName: 1,
|
|
1677
1696
|
subscriptionPlan: 1,
|
|
1678
1697
|
PaymentPlan: 1,
|
|
1679
|
-
PaymentPlan: {
|
|
1680
|
-
$cond: {
|
|
1681
|
-
if: { $eq: [ '$PaymentPlan', 'unbilled' ] },
|
|
1682
|
-
then: 'paid',
|
|
1683
|
-
else: {
|
|
1684
|
-
$cond: {
|
|
1685
|
-
if: { $eq: [ '$PaymentPlan', 'due' ] },
|
|
1686
|
-
then: 'paid',
|
|
1687
|
-
else: '$PaymentPlan',
|
|
1688
|
-
},
|
|
1689
|
-
},
|
|
1690
|
-
},
|
|
1691
|
-
},
|
|
1692
1698
|
installedPending: 1,
|
|
1693
1699
|
installedFailed: 1,
|
|
1694
1700
|
ProgressBar: {
|
|
@@ -1752,7 +1758,7 @@ export async function clientListV1( req, res ) {
|
|
|
1752
1758
|
for ( let client of clientList ) {
|
|
1753
1759
|
exportResult.push( {
|
|
1754
1760
|
'Brand Name': client.clientName,
|
|
1755
|
-
'Brand
|
|
1761
|
+
'Brand Id': client.clientId,
|
|
1756
1762
|
'Onboarded Stores': client.onboardedStores||0,
|
|
1757
1763
|
'Installed Stores': client.installedStore || 0,
|
|
1758
1764
|
'Progress Status': client.ProgressBar||0,
|
|
@@ -1761,7 +1767,7 @@ export async function clientListV1( req, res ) {
|
|
|
1761
1767
|
'Pending Configuration': client.installedPending || 0,
|
|
1762
1768
|
'Payment Plan': client.PaymentPlan == 'free'?'Lifetime Free':client.PaymentPlan,
|
|
1763
1769
|
'Subscription Plan': client.subscriptionPlan,
|
|
1764
|
-
'Processing Status': client.ProcessingStatus=='active'?'Activated':client.ProcessingStatus
|
|
1770
|
+
'Processing Status': client.ProcessingStatus=='active'?'Activated':client.ProcessingStatus?'deactive':client.ProcessingStatus,
|
|
1765
1771
|
} );
|
|
1766
1772
|
}
|
|
1767
1773
|
await download( exportResult, res );
|
|
@@ -1790,6 +1796,7 @@ export async function getOpsUsers( req, res ) {
|
|
|
1790
1796
|
|
|
1791
1797
|
export async function detailedClientCount( req, res ) {
|
|
1792
1798
|
try {
|
|
1799
|
+
const bucket = JSON.parse( process.env.BUCKET );
|
|
1793
1800
|
const inputData = req.query;
|
|
1794
1801
|
let result = {
|
|
1795
1802
|
clientName: inputData.clientName,
|
|
@@ -1803,10 +1810,10 @@ export async function detailedClientCount( req, res ) {
|
|
|
1803
1810
|
const client = await findOneClient( { clientId: inputData.clientId }, { userId: 1, clientId: 1, profileDetails: 1 } );
|
|
1804
1811
|
const user = await findOneUser( { _id: client.userId }, { userName: 1, email: 1 } );
|
|
1805
1812
|
|
|
1806
|
-
const isLogoExist = await checkFileExist( { Bucket:
|
|
1813
|
+
const isLogoExist = await checkFileExist( { Bucket: bucket.assets, Key: `${client.clientId}/logo/${client.profileDetails?.logo}` } );
|
|
1807
1814
|
|
|
1808
1815
|
if ( isLogoExist ) {
|
|
1809
|
-
const signedFilUrl = await signedUrl( { Bucket:
|
|
1816
|
+
const signedFilUrl = await signedUrl( { Bucket: bucket.assets, file_path: `${client.clientId}/logo/${client.profileDetails?.logo}` } );
|
|
1810
1817
|
result['logo'] = signedFilUrl;
|
|
1811
1818
|
} else {
|
|
1812
1819
|
result['logo'] = '';
|
|
@@ -1837,6 +1844,7 @@ export async function detailedClientCount( req, res ) {
|
|
|
1837
1844
|
|
|
1838
1845
|
export async function getActivityLogs( req, res ) {
|
|
1839
1846
|
try {
|
|
1847
|
+
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
1840
1848
|
const query = {
|
|
1841
1849
|
'_source': [
|
|
1842
1850
|
'userId', 'userName', 'email', 'date', 'logType', 'logSubType',
|
|
@@ -1893,7 +1901,7 @@ export async function getActivityLogs( req, res ) {
|
|
|
1893
1901
|
},
|
|
1894
1902
|
);
|
|
1895
1903
|
|
|
1896
|
-
const logs = await getOpenSearchData(
|
|
1904
|
+
const logs = await getOpenSearchData( openSearch.activityLog, query );
|
|
1897
1905
|
|
|
1898
1906
|
const hits = logs?.body?.hits?.hits;
|
|
1899
1907
|
const totalDocuments = logs?.body?.hits?.total?.value;
|
|
@@ -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,
|
|
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
|
|
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}${
|
|
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(
|
|
@@ -151,6 +152,7 @@ export function featureConfigurationUpdate( {
|
|
|
151
152
|
'featureConfigs.isPasserByData': isPasserByData,
|
|
152
153
|
'featureConfigs.isFootfallDirectory': isFootfallDirectory,
|
|
153
154
|
'featureConfigs.isExcludedArea': isExcludedArea,
|
|
155
|
+
'featureConfigs.updateFeatureConfig': false,
|
|
154
156
|
},
|
|
155
157
|
} );
|
|
156
158
|
}
|