tango-app-api-client 3.3.1-beta.2 → 3.3.2-beta.1
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.3.
|
|
3
|
+
"version": "3.3.2-beta.1",
|
|
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.1.
|
|
29
|
-
"tango-app-api-middleware": "^3.1.
|
|
28
|
+
"tango-api-schema": "^2.1.59",
|
|
29
|
+
"tango-app-api-middleware": "^3.1.43-alpha.8",
|
|
30
30
|
"winston": "^3.11.0",
|
|
31
31
|
"winston-daily-rotate-file": "^5.0.0"
|
|
32
32
|
},
|
|
@@ -515,7 +515,44 @@ export async function clientDetails( req, res ) {
|
|
|
515
515
|
}
|
|
516
516
|
export async function detailedAllClientCount( req, res ) {
|
|
517
517
|
try {
|
|
518
|
+
const field = { clientName: 1, clientId: 1 };
|
|
519
|
+
let Assinedclient = [];
|
|
520
|
+
if ( req?.user?.role === 'superadmin' ) {
|
|
521
|
+
Assinedclient = await findClient( {}, field );
|
|
522
|
+
Assinedclient = Assinedclient.map( ( data ) => data.clientId );
|
|
523
|
+
} else {
|
|
524
|
+
const clientQuery = [
|
|
525
|
+
{
|
|
526
|
+
$match: {
|
|
527
|
+
userEmail: req?.user?.email,
|
|
528
|
+
assignedType: { $eq: 'client' },
|
|
529
|
+
},
|
|
530
|
+
},
|
|
531
|
+
{
|
|
532
|
+
$group: {
|
|
533
|
+
_id: null,
|
|
534
|
+
clientId: { $addToSet: '$assignedValue' },
|
|
535
|
+
},
|
|
536
|
+
},
|
|
537
|
+
{
|
|
538
|
+
$project: {
|
|
539
|
+
_id: 0,
|
|
540
|
+
clientId: 1,
|
|
541
|
+
},
|
|
542
|
+
},
|
|
543
|
+
|
|
544
|
+
];
|
|
545
|
+
const clientList = await aggregateUserAssignedStore( clientQuery );
|
|
546
|
+
if ( clientList[0]?.clientId?.length != 0 ) {
|
|
547
|
+
Assinedclient= clientList[0]?.clientId;
|
|
548
|
+
}
|
|
549
|
+
}
|
|
518
550
|
const query = [
|
|
551
|
+
{
|
|
552
|
+
$match: {
|
|
553
|
+
clientId: { $in: Assinedclient },
|
|
554
|
+
},
|
|
555
|
+
},
|
|
519
556
|
{
|
|
520
557
|
$project: {
|
|
521
558
|
activeClient: { $cond: [ { $eq: [ '$status', 'active' ] }, 1, 0 ] },
|
|
@@ -579,11 +616,14 @@ export async function detailedAllClientCount( req, res ) {
|
|
|
579
616
|
},
|
|
580
617
|
];
|
|
581
618
|
const result = await aggregateClient( query );
|
|
582
|
-
const activeStores = await findStore( {
|
|
619
|
+
const activeStores = await findStore( {
|
|
620
|
+
'clientId': { $in: Assinedclient },
|
|
621
|
+
'status': 'active' }, { storeId: 1 } );
|
|
583
622
|
let yettoInstallCount = await aggregateTickets( [
|
|
584
623
|
{
|
|
585
624
|
$match: {
|
|
586
625
|
$and: [
|
|
626
|
+
{ 'basicDetails.clientId': { $in: Assinedclient } },
|
|
587
627
|
{ issueType: 'installation' },
|
|
588
628
|
{ 'status': { $ne: 'closed' } },
|
|
589
629
|
],
|
|
@@ -867,7 +907,7 @@ export async function updateFeatureConfiguration( req, res ) {
|
|
|
867
907
|
conversionValue: req.body?.conversionValue, infraAlertCondition: req.body?.infraAlertCondition, infraAlertValue: req.body?.infraAlertValue, isFootfallDirectory: req.body?.isFootfallDirectory,
|
|
868
908
|
isNormalized: req.body?.isNormalized, isPasserByData: req.body?.isPasserByData, missedOpportunityCalculation: req.body?.missedOpportunityCalculation, open: req.body?.open,
|
|
869
909
|
isExcludedArea: req.body?.isExcludedArea, isCameraDisabled: req.body?.isCameraDisabled, isbillingDisabled: req.body?.isbillingDisabled, isNewDashboard: req.body?.isNewDashboard,
|
|
870
|
-
isFootfallAuditStores: req.body?.isFootfallAuditStores, isNewTraffic: req.body?.isNewTraffic, isNewZone: req.body?.isNewZone, isNewReports: req.body?.isNewReports, isNOB: req.body?.isNOB, isNewZoneV2: req.body?.isNewZoneV2,
|
|
910
|
+
isFootfallAuditStores: req.body?.isFootfallAuditStores, isNewTraffic: req.body?.isNewTraffic, isNewZone: req.body?.isNewZone, isNewReports: req.body?.isNewReports, isNOB: req.body?.isNOB, isNewZoneV2: req.body?.isNewZoneV2, isTrax: req.body?.isTrax,
|
|
871
911
|
} );
|
|
872
912
|
|
|
873
913
|
let updateKeys = [];
|
package/src/dtos/client.dtos.js
CHANGED
|
@@ -2,97 +2,94 @@
|
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import { activityLogValid, auditConfigValid, billingDetailsValid, brandInfoValid, clientCreationValid, clientDetailsValid, documentsValid, domainDetailsValid, featureConfigurationValid, getAssignedClientValid, getAuditConfigValid, postClientCamApprovalValid, signatoryDetailsValid, ticketConfigurationValid, userConfigurationValid } from '../dtos/client.dtos.js';
|
|
4
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
|
-
import {
|
|
5
|
+
import { accessVerification, isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
|
|
6
6
|
import { clientListValid, detailedClientCountValid } from '../dtos/client.dtos.js';
|
|
7
|
-
import { isclientIdExists, isclientNameExists } from '../validations/client.validations.js';
|
|
7
|
+
import { isclientIdExists, isclientNameExists, roleVerification } from '../validations/client.validations.js';
|
|
8
8
|
import { detailedAllClientCount, detailedClientCount, clientList, clientListV1 } from '../controllers/client.controllers.js';
|
|
9
9
|
|
|
10
10
|
export const clientRouter = express.Router();
|
|
11
11
|
|
|
12
12
|
clientRouter.post( '/create', isAllowedSessionHandler,
|
|
13
|
-
|
|
13
|
+
accessVerification( { userType: [ 'tango' ] } ), roleVerification,
|
|
14
14
|
validate( clientCreationValid ), isclientNameExists, changeStatus, create );
|
|
15
15
|
clientRouter.get( '/get-clients', isAllowedSessionHandler,
|
|
16
|
-
|
|
16
|
+
accessVerification( { userType: [ 'tango' ] } ), getClients );
|
|
17
17
|
clientRouter.get( '/client-details/:id', isAllowedSessionHandler, validate( clientDetailsValid ), clientDetails );
|
|
18
18
|
|
|
19
|
-
clientRouter.put( '/brand-info/:id', isAllowedSessionHandler,
|
|
19
|
+
clientRouter.put( '/brand-info/:id', isAllowedSessionHandler, accessVerification(
|
|
20
20
|
{ userType: [ 'tango', 'client' ], access: [
|
|
21
|
-
{ featureName: '
|
|
21
|
+
{ featureName: 'Global', name: 'Configuration', permissions: [ 'isEdit' ] } ] } ),
|
|
22
22
|
validate( brandInfoValid ), updateBrandInfo );
|
|
23
23
|
|
|
24
|
-
clientRouter.put( '/billing-details/:id', isAllowedSessionHandler,
|
|
24
|
+
clientRouter.put( '/billing-details/:id', isAllowedSessionHandler, accessVerification(
|
|
25
25
|
{ userType: [ 'tango', 'client' ], access: [
|
|
26
|
-
{ featureName: '
|
|
26
|
+
{ featureName: 'Global', name: 'Billing', permissions: [ 'isEdit' ] } ] } ),
|
|
27
27
|
validate( billingDetailsValid ), updateBillingDetails );
|
|
28
28
|
|
|
29
|
-
clientRouter.put( '/signatory-details/:id', isAllowedSessionHandler,
|
|
29
|
+
clientRouter.put( '/signatory-details/:id', isAllowedSessionHandler, accessVerification(
|
|
30
30
|
{ userType: [ 'tango', 'client' ], access: [
|
|
31
|
-
{ featureName: '
|
|
31
|
+
{ featureName: 'Global', name: 'Configuration', permissions: [ 'isEdit' ] } ] } ),
|
|
32
32
|
validate( signatoryDetailsValid ), updateSignatoryDetails );
|
|
33
33
|
|
|
34
|
-
clientRouter.put( '/ticket-configuration/:id', isAllowedSessionHandler,
|
|
34
|
+
clientRouter.put( '/ticket-configuration/:id', isAllowedSessionHandler, accessVerification(
|
|
35
35
|
{ userType: [ 'tango' ], access: [
|
|
36
|
-
{ featureName: '
|
|
36
|
+
{ featureName: 'TangoAdmin', name: 'TicketConfiguration', permissions: [ 'isEdit' ] } ] } ),
|
|
37
37
|
validate( ticketConfigurationValid ), updateTicketConfiguration );
|
|
38
38
|
|
|
39
|
-
clientRouter.put( '/feature-configuration/:id', isAllowedSessionHandler,
|
|
39
|
+
clientRouter.put( '/feature-configuration/:id', isAllowedSessionHandler, accessVerification(
|
|
40
40
|
{ userType: [ 'tango', 'client' ], access: [
|
|
41
|
-
{ featureName: '
|
|
41
|
+
{ featureName: 'Global', name: 'Configuration', permissions: [ 'isEdit' ] } ] } ),
|
|
42
42
|
validate( featureConfigurationValid ), updateFeatureConfiguration );
|
|
43
43
|
|
|
44
|
-
clientRouter.put( '/domain-details/:id', isAllowedSessionHandler,
|
|
44
|
+
clientRouter.put( '/domain-details/:id', isAllowedSessionHandler, accessVerification(
|
|
45
45
|
{ userType: [ 'tango', 'client' ], access: [
|
|
46
|
-
{ featureName: '
|
|
46
|
+
{ featureName: 'Global', name: 'Configuration', permissions: [ 'isEdit' ] } ] } ),
|
|
47
47
|
validate( domainDetailsValid ), domainDetailsConfiguration );
|
|
48
48
|
|
|
49
|
-
clientRouter.put( '/user-configuration/:id', isAllowedSessionHandler,
|
|
49
|
+
clientRouter.put( '/user-configuration/:id', isAllowedSessionHandler, accessVerification(
|
|
50
50
|
{ userType: [ 'tango' ], access: [
|
|
51
|
-
{ featureName: '
|
|
51
|
+
{ featureName: 'TangoAdmin', name: 'TicketConfiguration', permissions: [ 'isEdit' ] } ] } ),
|
|
52
52
|
validate( userConfigurationValid ), userConfiguration );
|
|
53
53
|
|
|
54
|
-
clientRouter.put( '/documents/:id', isAllowedSessionHandler,
|
|
54
|
+
clientRouter.put( '/documents/:id', isAllowedSessionHandler, accessVerification(
|
|
55
55
|
{ userType: [ 'tango', 'client' ], access: [
|
|
56
|
-
{ featureName: '
|
|
56
|
+
{ featureName: 'Global', name: 'Configuration', permissions: [ 'isEdit' ] } ] } ),
|
|
57
57
|
validate( documentsValid ), updateDocuments );
|
|
58
58
|
|
|
59
|
-
clientRouter.get( '/audit-configuration/:id', isAllowedSessionHandler,
|
|
59
|
+
clientRouter.get( '/audit-configuration/:id', isAllowedSessionHandler, accessVerification(
|
|
60
60
|
{ userType: [ 'tango' ], access: [
|
|
61
|
-
{ featureName: '
|
|
61
|
+
{ featureName: 'TangoAdmin', name: 'TicketConfiguration', permissions: [] } ] } ),
|
|
62
62
|
validate( getAuditConfigValid ), getAuditConfiguration );
|
|
63
63
|
|
|
64
|
-
clientRouter.post( '/audit-configuration/:id', isAllowedSessionHandler,
|
|
64
|
+
clientRouter.post( '/audit-configuration/:id', isAllowedSessionHandler, accessVerification(
|
|
65
65
|
{ userType: [ 'tango' ], access: [
|
|
66
|
-
{ featureName: '
|
|
66
|
+
{ featureName: 'TangoAdmin', name: 'TicketConfiguration', permissions: [ 'isEdit' ] } ] } ),
|
|
67
67
|
validate( auditConfigValid ), auditConfiguration );
|
|
68
68
|
|
|
69
|
-
clientRouter.get( '/get-csm-users', isAllowedSessionHandler,
|
|
70
|
-
{ userType: [ 'tango' ]
|
|
71
|
-
{ featureName: 'settings', name: 'configuration', permissions: [ 'isView' ] } ] } ),
|
|
69
|
+
clientRouter.get( '/get-csm-users', isAllowedSessionHandler, accessVerification(
|
|
70
|
+
{ userType: [ 'tango' ] } ),
|
|
72
71
|
getCsmUsers );
|
|
73
72
|
|
|
74
|
-
clientRouter.get( '/get-ops-users', isAllowedSessionHandler,
|
|
75
|
-
{ userType: [ 'tango' ]
|
|
76
|
-
{ featureName: 'settings', name: 'configuration', permissions: [ 'isView' ] } ] } ),
|
|
73
|
+
clientRouter.get( '/get-ops-users', isAllowedSessionHandler, accessVerification(
|
|
74
|
+
{ userType: [ 'tango' ] } ),
|
|
77
75
|
getOpsUsers );
|
|
78
76
|
|
|
79
77
|
clientRouter.get( '/detailed-all-client-count', isAllowedSessionHandler,
|
|
80
|
-
|
|
78
|
+
accessVerification( { userType: [ 'tango' ] } ),
|
|
81
79
|
detailedAllClientCount );
|
|
82
80
|
|
|
83
81
|
clientRouter.post( '/client-list', isAllowedSessionHandler,
|
|
84
|
-
|
|
82
|
+
accessVerification( { userType: [ 'tango' ] } ),
|
|
85
83
|
validate( clientListValid ), clientList );
|
|
86
84
|
clientRouter.post( '/client-list_v1', isAllowedSessionHandler,
|
|
87
|
-
|
|
85
|
+
accessVerification( { userType: [ 'tango' ] } ),
|
|
88
86
|
validate( clientListValid ), clientListV1 );
|
|
89
87
|
clientRouter.get( '/detailed-client-count', isAllowedSessionHandler,
|
|
90
|
-
|
|
88
|
+
accessVerification( { userType: [ 'tango', 'client' ] } ),
|
|
91
89
|
validate( detailedClientCountValid ), isclientIdExists, detailedClientCount );
|
|
92
90
|
|
|
93
|
-
clientRouter.post( '/activity-log', isAllowedSessionHandler,
|
|
94
|
-
{ userType: [ 'tango', 'client' ]
|
|
95
|
-
{ featureName: 'settings', name: 'activityLog', permissions: [ 'isView' ] } ] } ),
|
|
91
|
+
clientRouter.post( '/activity-log', isAllowedSessionHandler, accessVerification(
|
|
92
|
+
{ userType: [ 'tango', 'client' ] } ),
|
|
96
93
|
validate( activityLogValid ), getActivityLogs );
|
|
97
94
|
|
|
98
95
|
clientRouter.get( '/show-csm-assign-confirmation', isAllowedSessionHandler,
|
|
@@ -134,7 +134,7 @@ export function featureConfigurationUpdate( {
|
|
|
134
134
|
conversionValue, infraAlertCondition, infraAlertValue, isFootfallDirectory,
|
|
135
135
|
isNormalized, isPasserByData, missedOpportunityCalculation, open, isExcludedArea,
|
|
136
136
|
isCameraDisabled, isbillingDisabled, isNewDashboard, isFootfallAuditStores, isNewTraffic,
|
|
137
|
-
isNewZone, isNewReports, isNOB, isNewZoneV2,
|
|
137
|
+
isNewZone, isNewReports, isNOB, isNewZoneV2, isTrax,
|
|
138
138
|
} ) {
|
|
139
139
|
return clientModel.updateOne( { clientId: clientId },
|
|
140
140
|
{
|
|
@@ -164,6 +164,7 @@ export function featureConfigurationUpdate( {
|
|
|
164
164
|
'featureConfigs.isNewReports': isNewReports,
|
|
165
165
|
'featureConfigs.isNOB': isNOB,
|
|
166
166
|
'featureConfigs.isNewZoneV2': isNewZoneV2,
|
|
167
|
+
'featureConfigs.isTrax': isTrax,
|
|
167
168
|
},
|
|
168
169
|
} );
|
|
169
170
|
}
|
|
@@ -33,3 +33,17 @@ export async function isclientIdExists( req, res, next ) {
|
|
|
33
33
|
return res.sendError( 'Internal Server Error', 500 );
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
|
+
|
|
37
|
+
export async function roleVerification( req, res, next ) {
|
|
38
|
+
try {
|
|
39
|
+
if ( [ 'admin', 'superadmin' ].includes( req?.user?.role ) ) {
|
|
40
|
+
return next();
|
|
41
|
+
} else {
|
|
42
|
+
return res.sendError( 'access forbidden', 403 );
|
|
43
|
+
}
|
|
44
|
+
} catch ( error ) {
|
|
45
|
+
logger.error( { error: error, message: req.body, function: 'roleVerification' } );
|
|
46
|
+
return res.sendError( error, 500 );
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|