tango-app-api-client 3.3.3-beta.13 → 3.3.3-beta.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
CHANGED
|
@@ -885,14 +885,14 @@ export async function updateSignatoryDetails( req, res ) {
|
|
|
885
885
|
export async function updateTicketConfiguration( req, res ) {
|
|
886
886
|
try {
|
|
887
887
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
888
|
-
|
|
888
|
+
const fields ={ 'ticketConfigs.downTimeType': 1, 'ticketConfigs.installationReAssign': 1, 'ticketConfigs.downTimeType': 1, 'ticketConfigs.infraDownTime': 1, 'ticketConfigs.MinFilesCount': 1, 'ticketConfigs.rcaTicketAssign': 1, 'ticketConfigs.refreshAlert': 1, 'ticketConfigs.statusCheckAlert': 1, 'ticketConfigs.accuracyPercentage': 1, 'ticketConfigs.reTrain': 1 };
|
|
889
|
+
let findClient = await findOneClient( { clientId: req.params?.id }, fields );
|
|
889
890
|
const updateAck = await ticketConfigurationUpdate( {
|
|
890
891
|
clientId: req.params?.id, MinFilesCount: req.body?.MinFilesCount, accuracyPercentage: req.body?.accuracyPercentage, downTimeType: req.body?.downTimeType,
|
|
891
892
|
infraDownTime: req.body?.infraDownTime, installationReAssign: req.body?.installationReAssign, isRcaTicketAssign: req.body?.isRcaTicketAssign,
|
|
892
893
|
isRefreshAlert: req.body?.isRefreshAlert, isStatusCheckAlert: req.body?.isStatusCheckAlert, rcaTicketAssign: req.body?.rcaTicketAssign, reTrain: req.body?.reTrain,
|
|
893
894
|
refreshAlert: req.body?.refreshAlert, sendToAdmin: req.body?.sendToAdmin, sendToUser: req.body?.sendToUser, statusCheckAlert: req.body?.statusCheckAlert,
|
|
894
895
|
} );
|
|
895
|
-
|
|
896
896
|
let updateKeys = [];
|
|
897
897
|
if ( Object.keys( req.body ).length > 0 ) {
|
|
898
898
|
Object.keys( req.body ).forEach( ( element ) => {
|
|
@@ -901,7 +901,7 @@ export async function updateTicketConfiguration( req, res ) {
|
|
|
901
901
|
}
|
|
902
902
|
|
|
903
903
|
const user = await getUserNameEmailById( req.userId );
|
|
904
|
-
let updatedClient = await findOneClient( { clientId: req.params?.id } );
|
|
904
|
+
let updatedClient = await findOneClient( { clientId: req.params?.id }, fields );
|
|
905
905
|
|
|
906
906
|
const logObj = {
|
|
907
907
|
clientId: req.params?.id,
|
|
@@ -999,20 +999,23 @@ export async function updateFeatureConfiguration( req, res ) {
|
|
|
999
999
|
}
|
|
1000
1000
|
|
|
1001
1001
|
await postApi( `${url.oldapidomain}/oldBrandUpdate/${data?._id}`, { brandConfigs: data.brandConfigs } );
|
|
1002
|
-
|
|
1003
|
-
|
|
1002
|
+
const keysArray = [
|
|
1003
|
+
'isExcludedArea', 'isPasserByData', 'isNormalized', 'isbillingDisabled',
|
|
1004
|
+
'isCameraDisabled', 'isFootfallDirectory', 'isNOB', 'isNewTraffic',
|
|
1005
|
+
'isTrax', 'isNewZone', 'isNewReports', 'isNewDashboard', 'streamBy',
|
|
1006
|
+
];
|
|
1004
1007
|
const logObj = {
|
|
1005
1008
|
clientId: req.params?.id,
|
|
1006
1009
|
userName: user?.userName,
|
|
1007
1010
|
email: user?.email,
|
|
1008
1011
|
date: new Date(),
|
|
1009
1012
|
logType: 'configuration',
|
|
1010
|
-
logSubType:
|
|
1013
|
+
logSubType: Object.keys( inputData ).some( ( key ) => keysArray.includes( key ) ) ? 'dashboardConfig' : 'featureConfig',
|
|
1011
1014
|
changes: updateKeys,
|
|
1012
1015
|
eventType: 'update',
|
|
1013
1016
|
showTo: [ 'client', 'tango' ],
|
|
1014
|
-
|
|
1015
|
-
current: postData,
|
|
1017
|
+
previous: previousData.featureConfigs,
|
|
1018
|
+
current: postData.featureConfigs,
|
|
1016
1019
|
};
|
|
1017
1020
|
if ( updateKeys.length ) {
|
|
1018
1021
|
await insertOpenSearchData( openSearch.activityLog, logObj );
|
|
@@ -1031,7 +1034,7 @@ export async function updateFeatureConfiguration( req, res ) {
|
|
|
1031
1034
|
export async function domainDetailsConfiguration( req, res ) {
|
|
1032
1035
|
try {
|
|
1033
1036
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
1034
|
-
const getPreData = await findOneClient( { clientId: req.params?.id }, { domainName: '$domainConfig.ssoLogin.domainName',
|
|
1037
|
+
const getPreData = await findOneClient( { clientId: req.params?.id }, { domainName: '$domainConfig.ssoLogin.domainName', isEnable: '$domainConfig.ssoLogin.isEnable', ipWhitelist: '$domainConfig.ipWhitelisting.enableWhitelisting', WhitelistedIps: '$domainConfig.ipWhitelisting.allowedIps', TwoFactorAuthentication: '$domainConfig.enableOtp' } );
|
|
1035
1038
|
const updateAck = await domainDetailsConfigurationUpdate( {
|
|
1036
1039
|
clientId: req.params?.id, domainName: req.body?.domainName, isEnable: req.body?.isEnable,
|
|
1037
1040
|
enableWhitelisting: req.body?.enableWhitelisting, allowedIps: req.body?.allowedIps, enableOtp: req.body?.enableOtp,
|
|
@@ -1046,7 +1049,7 @@ export async function domainDetailsConfiguration( req, res ) {
|
|
|
1046
1049
|
} );
|
|
1047
1050
|
}
|
|
1048
1051
|
|
|
1049
|
-
const getPostData = await findOneClient( { clientId: req.params?.id }, { domainName: '$domainConfig.ssoLogin.domainName',
|
|
1052
|
+
const getPostData = await findOneClient( { clientId: req.params?.id }, { domainName: '$domainConfig.ssoLogin.domainName', isEnable: '$domainConfig.ssoLogin.isEnable', ipWhitelist: '$domainConfig.ipWhitelisting.enableWhitelisting', WhitelistedIps: '$domainConfig.ipWhitelisting.allowedIps', TwoFactorAuthentication: '$domainConfig.enableOtp' } );
|
|
1050
1053
|
|
|
1051
1054
|
const logObj = {
|
|
1052
1055
|
clientId: req.params?.id,
|
|
@@ -1227,6 +1230,7 @@ export async function auditConfiguration( req, res ) {
|
|
|
1227
1230
|
auditConfigs: 1, _id: 0,
|
|
1228
1231
|
};
|
|
1229
1232
|
const previousClient = await findOneClient( query, fields );
|
|
1233
|
+
previousClient.auditConfigs.ratio = previousClient?.auditConfigs?.ratio? ( previousClient.auditConfigs.ratio )*100 : null;
|
|
1230
1234
|
const record = {
|
|
1231
1235
|
'auditConfigs.count': inputData.count,
|
|
1232
1236
|
'auditConfigs.audit': inputData.audit,
|
|
@@ -1250,7 +1254,7 @@ export async function auditConfiguration( req, res ) {
|
|
|
1250
1254
|
clientId: req.params?.id,
|
|
1251
1255
|
count: inputData.count,
|
|
1252
1256
|
audit: inputData.audit,
|
|
1253
|
-
ratio:
|
|
1257
|
+
ratio: inputData.ratio,
|
|
1254
1258
|
},
|
|
1255
1259
|
};
|
|
1256
1260
|
|
|
@@ -2089,19 +2093,23 @@ export async function getActivityLogs( req, res ) {
|
|
|
2089
2093
|
|
|
2090
2094
|
const hits = logs?.body?.hits?.hits;
|
|
2091
2095
|
const totalDocuments = logs?.body?.hits?.total?.value;
|
|
2096
|
+
|
|
2092
2097
|
let temp = [];
|
|
2093
2098
|
if ( totalDocuments ) {
|
|
2094
2099
|
hits.map( ( hit, i ) => {
|
|
2095
2100
|
let respo ={};
|
|
2096
|
-
|
|
2101
|
+
hit._source.logSubType = hit._source.logSubType === 'documentUpload'? 'documentsUpload': hit._source.logSubType === 'domainDetails'? 'securityFeatures': hit?._source?.logSubType;
|
|
2097
2102
|
if ( ( ( hit?._source?.eventType ).match( /update/ ) || ( hit?._source?.eventType ).match( /edit/ ) )&& hit?._source?.previous ) {
|
|
2098
2103
|
const previous = hit?._source?.previous;
|
|
2099
2104
|
const current=hit?._source?.current;
|
|
2100
2105
|
const logType =hit?._source?.logType;
|
|
2101
|
-
|
|
2106
|
+
|
|
2107
|
+
const logSubType =hit?._source?.logSubType;
|
|
2102
2108
|
respo = findDifferences( previous, current, logType, logSubType );
|
|
2103
2109
|
hit._source.updatedValue = respo;
|
|
2110
|
+
// Object.keys( respo ).length === 0?null:
|
|
2104
2111
|
temp.push( hit?._source );
|
|
2112
|
+
hit._source.changes =logSubType === 'ticketConfig'? Object.keys( respo ).map( ( item ) => item ) : hit._source.changes;
|
|
2105
2113
|
} else {
|
|
2106
2114
|
temp.push( hit?._source );
|
|
2107
2115
|
}
|
|
@@ -2128,6 +2136,7 @@ function findDifferences( previous, current, logType, logSubType, path = '' ) {
|
|
|
2128
2136
|
// Get correct key mapping based on logType
|
|
2129
2137
|
const keyMapping = logType == 'stores' ?documents.stores: logType == 'users' ?documents.users :logSubType=='reportConfig'?documents.reports: logType=='brandInfo'?documents.client:documents.client;
|
|
2130
2138
|
|
|
2139
|
+
|
|
2131
2140
|
let differences = {};
|
|
2132
2141
|
|
|
2133
2142
|
for ( const key in current ) {
|
|
@@ -2136,9 +2145,21 @@ function findDifferences( previous, current, logType, logSubType, path = '' ) {
|
|
|
2136
2145
|
const prevValue = previous[key];
|
|
2137
2146
|
const currValue = current[key];
|
|
2138
2147
|
|
|
2139
|
-
if ( typeof prevValue === 'object' && typeof currValue === 'object' && prevValue !== null && currValue !== null ) {
|
|
2148
|
+
if ( typeof prevValue === 'object' && typeof currValue === 'object' && prevValue !== null && currValue !== null && !Array.isArray( prevValue ) && !Array.isArray( currValue ) ) {
|
|
2140
2149
|
const nestedDiffs = findDifferences( prevValue, currValue, logType, logSubType, `${path}${key}.` );
|
|
2141
2150
|
Object.assign( differences, nestedDiffs );
|
|
2151
|
+
} else if ( Array.isArray( prevValue ) && prevValue.every( ( item ) => typeof item === 'object' && item !== null ) || Array.isArray( currValue ) && currValue.every( ( item ) => typeof item === 'object' && item !== null ) ) {
|
|
2152
|
+
if ( _.isEqual( prevValue, currValue ) ) {
|
|
2153
|
+
continue;
|
|
2154
|
+
} else {
|
|
2155
|
+
let result = compareArrayObjects( prevValue, currValue );
|
|
2156
|
+
differences = { ...differences, ...result };
|
|
2157
|
+
}
|
|
2158
|
+
} else if ( Array.isArray( prevValue ) && Array.isArray( currValue ) && prevValue.length !== 0 && currValue.length !== 0 ) {
|
|
2159
|
+
JSON.stringify( prevValue ) !== JSON.stringify( currValue )?
|
|
2160
|
+
differences[`${path}${key}`] = { previous: prevValue.length> 0 ? prevValue.join( ',' ): null, current: currValue.length > 0? currValue.join( ',' ): null } : null;
|
|
2161
|
+
|
|
2162
|
+
// differences[`${path}${key}`] = { previous: removed.length> 0 ? prevValue.join( ',' ): prevValue.join( ', ' ) :, current: added.length > 0? addedUsers.join( ', ' ) : currValue.join( ',' ) } : null;
|
|
2142
2163
|
} else if ( prevValue !== currValue ) {
|
|
2143
2164
|
if (
|
|
2144
2165
|
( prevValue === '' && currValue === '' ) ||
|
|
@@ -2153,9 +2174,8 @@ function findDifferences( previous, current, logType, logSubType, path = '' ) {
|
|
|
2153
2174
|
// **Transform & Filter Differences**
|
|
2154
2175
|
let updatedDifferences = {};
|
|
2155
2176
|
Object.keys( differences ).forEach( ( key ) => {
|
|
2156
|
-
let newKey = key.replace( /spocDetails\.\d+\./, 'spocDetails.' ).replace( /
|
|
2177
|
+
let newKey = key.replace( /spocDetails\.\d+\./, 'spocDetails.' ).replace( /WhitelistedIps\.\d+/, 'Whitelisted Ips' );
|
|
2157
2178
|
let diff = differences[key];
|
|
2158
|
-
|
|
2159
2179
|
if ( newKey.toLowerCase().includes( 'isactive' ) ) {
|
|
2160
2180
|
diff = {
|
|
2161
2181
|
previous: diff.previous ? 'Active' : 'Deactive',
|
|
@@ -2167,22 +2187,16 @@ function findDifferences( previous, current, logType, logSubType, path = '' ) {
|
|
|
2167
2187
|
if ( userFriendlyKey ) {
|
|
2168
2188
|
newKey = userFriendlyKey;
|
|
2169
2189
|
}
|
|
2170
|
-
|
|
2171
|
-
if (
|
|
2190
|
+
const binaryKeys = [ 'Two Factor Authentication', 'Mat Enabled', 'Audit', 'Infra Email Alert', 'Ip Whitelist', 'Excluded Area', 'Passer By Data', 'Normalized', 'Billing', 'Camera', 'Footfall Directory', 'Footfall Directory Audit', 'Footfall Directory Limit', 'NOB', 'New Traffic', 'Trax', 'Zone V1', 'Zone V2', 'Reports', 'New Dashboard' ];
|
|
2191
|
+
if ( binaryKeys.includes( newKey ) ) {
|
|
2172
2192
|
diff.previous = ( diff.previous == true || diff.previous == 'Enabled' ) ? 'Enabled' : 'Disabled';
|
|
2173
2193
|
diff.current = ( diff.current == true || diff.current == 'Enabled' ) ? 'Enabled' : 'Disabled';
|
|
2174
2194
|
}
|
|
2175
|
-
if ( newKey === '
|
|
2176
|
-
diff.previous = ( diff.previous == true || diff.previous == '
|
|
2177
|
-
diff.current = ( diff.current == true || diff.current == '
|
|
2195
|
+
if ( newKey === 'Server Type' ) {
|
|
2196
|
+
diff.previous = ( diff.previous == true || diff.previous == 'Server' ) ? 'Server' : 'Serverless';
|
|
2197
|
+
diff.current = ( diff.current == true || diff.current == 'Server' ) ? 'Server' : 'Serverless';
|
|
2178
2198
|
}
|
|
2179
2199
|
|
|
2180
|
-
if ( newKey === 'Two Factor Authentication' ) {
|
|
2181
|
-
diff.previous = ( diff.previous == true || diff.previous == 'Enabled' ) ? 'Enabled' : 'Disabled';
|
|
2182
|
-
diff.current = ( diff.current == true || diff.current == 'Enabled' ) ? 'Enabled' : 'Disabled';
|
|
2183
|
-
}
|
|
2184
|
-
|
|
2185
|
-
|
|
2186
2200
|
// **Transform Roles Permission Keys**
|
|
2187
2201
|
const rolesPermissionMatch = newKey.match( /rolespermission\.(\d+)\.modules\.(\d+)\.(isAdd|isEdit)/ );
|
|
2188
2202
|
if ( rolesPermissionMatch ) {
|
|
@@ -2301,3 +2315,34 @@ export async function clientCsmAssignAction( req, res ) {
|
|
|
2301
2315
|
return res.sendError( 'Internal Server Error', 500 );
|
|
2302
2316
|
}
|
|
2303
2317
|
}
|
|
2318
|
+
|
|
2319
|
+
function compareArrayObjects( prevArray, currArray ) {
|
|
2320
|
+
let changes = {};
|
|
2321
|
+
logger.info( { prevArray: prevArray, currArray: currArray } );
|
|
2322
|
+
// Find the longest array length to avoid index mismatch
|
|
2323
|
+
let maxLength = Math.max( prevArray.length, currArray.length );
|
|
2324
|
+
|
|
2325
|
+
for ( let i = 0; i < maxLength; i++ ) {
|
|
2326
|
+
let prevObj = prevArray[i] || {}; // Default to empty object if missing
|
|
2327
|
+
let currObj = currArray[i] || {};
|
|
2328
|
+
let diff = {};
|
|
2329
|
+
|
|
2330
|
+
Object.keys( { ...prevObj, ...currObj } ).forEach( ( key ) => {
|
|
2331
|
+
if ( prevObj[key] !== currObj[key] && key !== '_id' ) {
|
|
2332
|
+
const key1 = key == 'contact'? 'Contact Number': key == 'email'? 'Email ID':key == 'name'?'Name': key == 'designation'?'Designation':key;
|
|
2333
|
+
const name = i ==0? 'Primary Spoc': `Alternate Spoc ${i+1}`;
|
|
2334
|
+
diff[`${name} ${key1}`] = {
|
|
2335
|
+
previous: prevObj[key] || 'null',
|
|
2336
|
+
current: currObj[key] || 'null',
|
|
2337
|
+
};
|
|
2338
|
+
}
|
|
2339
|
+
} );
|
|
2340
|
+
|
|
2341
|
+
if ( Object.keys( diff ).length > 0 ) {
|
|
2342
|
+
// changes.push( { index: i, changes: diff } );
|
|
2343
|
+
changes = { ...changes, ...diff };
|
|
2344
|
+
}
|
|
2345
|
+
}
|
|
2346
|
+
|
|
2347
|
+
return changes;
|
|
2348
|
+
}
|