tango-app-api-client 3.3.3-beta.14 → 3.3.3-beta.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
|
@@ -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,
|
|
@@ -1034,7 +1034,7 @@ export async function updateFeatureConfiguration( req, res ) {
|
|
|
1034
1034
|
export async function domainDetailsConfiguration( req, res ) {
|
|
1035
1035
|
try {
|
|
1036
1036
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
1037
|
-
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' } );
|
|
1038
1038
|
const updateAck = await domainDetailsConfigurationUpdate( {
|
|
1039
1039
|
clientId: req.params?.id, domainName: req.body?.domainName, isEnable: req.body?.isEnable,
|
|
1040
1040
|
enableWhitelisting: req.body?.enableWhitelisting, allowedIps: req.body?.allowedIps, enableOtp: req.body?.enableOtp,
|
|
@@ -1049,7 +1049,7 @@ export async function domainDetailsConfiguration( req, res ) {
|
|
|
1049
1049
|
} );
|
|
1050
1050
|
}
|
|
1051
1051
|
|
|
1052
|
-
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' } );
|
|
1053
1053
|
|
|
1054
1054
|
const logObj = {
|
|
1055
1055
|
clientId: req.params?.id,
|
|
@@ -1230,6 +1230,7 @@ export async function auditConfiguration( req, res ) {
|
|
|
1230
1230
|
auditConfigs: 1, _id: 0,
|
|
1231
1231
|
};
|
|
1232
1232
|
const previousClient = await findOneClient( query, fields );
|
|
1233
|
+
previousClient.auditConfigs.ratio = previousClient?.auditConfigs?.ratio? ( previousClient.auditConfigs.ratio )*100 : null;
|
|
1233
1234
|
const record = {
|
|
1234
1235
|
'auditConfigs.count': inputData.count,
|
|
1235
1236
|
'auditConfigs.audit': inputData.audit,
|
|
@@ -1253,7 +1254,7 @@ export async function auditConfiguration( req, res ) {
|
|
|
1253
1254
|
clientId: req.params?.id,
|
|
1254
1255
|
count: inputData.count,
|
|
1255
1256
|
audit: inputData.audit,
|
|
1256
|
-
ratio:
|
|
1257
|
+
ratio: inputData.ratio,
|
|
1257
1258
|
},
|
|
1258
1259
|
};
|
|
1259
1260
|
|
|
@@ -2097,7 +2098,7 @@ export async function getActivityLogs( req, res ) {
|
|
|
2097
2098
|
if ( totalDocuments ) {
|
|
2098
2099
|
hits.map( ( hit, i ) => {
|
|
2099
2100
|
let respo ={};
|
|
2100
|
-
hit._source.logSubType = hit._source.logSubType === 'documentUpload'? 'documentsUpload': hit?._source?.logSubType;
|
|
2101
|
+
hit._source.logSubType = hit._source.logSubType === 'documentUpload'? 'documentsUpload': hit._source.logSubType === 'domainDetails'? 'securityFeatures': hit?._source?.logSubType;
|
|
2101
2102
|
if ( ( ( hit?._source?.eventType ).match( /update/ ) || ( hit?._source?.eventType ).match( /edit/ ) )&& hit?._source?.previous ) {
|
|
2102
2103
|
const previous = hit?._source?.previous;
|
|
2103
2104
|
const current=hit?._source?.current;
|
|
@@ -2106,7 +2107,9 @@ export async function getActivityLogs( req, res ) {
|
|
|
2106
2107
|
const logSubType =hit?._source?.logSubType;
|
|
2107
2108
|
respo = findDifferences( previous, current, logType, logSubType );
|
|
2108
2109
|
hit._source.updatedValue = respo;
|
|
2110
|
+
// Object.keys( respo ).length === 0?null:
|
|
2109
2111
|
temp.push( hit?._source );
|
|
2112
|
+
hit._source.changes =logSubType === 'ticketConfig'? Object.keys( respo ).map( ( item ) => item ) : hit._source.changes;
|
|
2110
2113
|
} else {
|
|
2111
2114
|
temp.push( hit?._source );
|
|
2112
2115
|
}
|
|
@@ -2127,12 +2130,13 @@ function findDifferences( previous, current, logType, logSubType, path = '' ) {
|
|
|
2127
2130
|
const dbKeys = JSON.parse( process.env.DB_KEYS );
|
|
2128
2131
|
const ignoredKeys = new Set( [
|
|
2129
2132
|
'_id', 'updatedAt', 'createdAt', 'password', 'clientId',
|
|
2130
|
-
'storeId', 'refreshToken', 'employeeId', 'fcmToken', 'permission',
|
|
2133
|
+
'storeId', 'refreshToken', 'employeeId', 'fcmToken', 'permission', 'updateFeatureConfig',
|
|
2131
2134
|
] );
|
|
2132
2135
|
const documents = dbKeys.DOCUMENTS;
|
|
2133
2136
|
// Get correct key mapping based on logType
|
|
2134
2137
|
const keyMapping = logType == 'stores' ?documents.stores: logType == 'users' ?documents.users :logSubType=='reportConfig'?documents.reports: logType=='brandInfo'?documents.client:documents.client;
|
|
2135
2138
|
|
|
2139
|
+
|
|
2136
2140
|
let differences = {};
|
|
2137
2141
|
|
|
2138
2142
|
for ( const key in current ) {
|
|
@@ -2142,8 +2146,24 @@ function findDifferences( previous, current, logType, logSubType, path = '' ) {
|
|
|
2142
2146
|
const currValue = current[key];
|
|
2143
2147
|
|
|
2144
2148
|
if ( typeof prevValue === 'object' && typeof currValue === 'object' && prevValue !== null && currValue !== null ) {
|
|
2145
|
-
|
|
2146
|
-
|
|
2149
|
+
if ( logSubType!== 'userUpdated' ) {
|
|
2150
|
+
if ( key == 'spocDetails' ) {
|
|
2151
|
+
if ( _.isEqual( prevValue, currValue ) ) {
|
|
2152
|
+
continue;
|
|
2153
|
+
} else {
|
|
2154
|
+
let result = compareArrayObjects( prevValue, currValue );
|
|
2155
|
+
differences = { ...differences, ...result };
|
|
2156
|
+
}
|
|
2157
|
+
} else if ( Array.isArray( prevValue ) && prevValue.every( ( item ) => typeof item === 'string' ) ||Array.isArray( currValue ) && currValue.every( ( item ) => typeof item === 'string' ) ) {
|
|
2158
|
+
JSON.stringify( prevValue ) !== JSON.stringify( currValue )?
|
|
2159
|
+
differences[`${path}${key}`] = { previous: prevValue.length> 0 ? prevValue.join( ',' ): null, current: currValue.length > 0? currValue.join( ',' ): null } : null;
|
|
2160
|
+
|
|
2161
|
+
// differences[`${path}${key}`] = { previous: removed.length> 0 ? prevValue.join( ',' ): prevValue.join( ', ' ) :, current: added.length > 0? addedUsers.join( ', ' ) : currValue.join( ',' ) } : null;
|
|
2162
|
+
}
|
|
2163
|
+
} else {
|
|
2164
|
+
const nestedDiffs = findDifferences( prevValue, currValue, logType, logSubType, `${path}${key}.` );
|
|
2165
|
+
Object.assign( differences, nestedDiffs );
|
|
2166
|
+
}
|
|
2147
2167
|
} else if ( prevValue !== currValue ) {
|
|
2148
2168
|
if (
|
|
2149
2169
|
( prevValue === '' && currValue === '' ) ||
|
|
@@ -2158,9 +2178,8 @@ function findDifferences( previous, current, logType, logSubType, path = '' ) {
|
|
|
2158
2178
|
// **Transform & Filter Differences**
|
|
2159
2179
|
let updatedDifferences = {};
|
|
2160
2180
|
Object.keys( differences ).forEach( ( key ) => {
|
|
2161
|
-
let newKey = key.replace( /spocDetails\.\d+\./, 'spocDetails.' ).replace( /
|
|
2181
|
+
let newKey = key.replace( /spocDetails\.\d+\./, 'spocDetails.' ).replace( /WhitelistedIps\.\d+/, 'Whitelisted Ips' );
|
|
2162
2182
|
let diff = differences[key];
|
|
2163
|
-
|
|
2164
2183
|
if ( newKey.toLowerCase().includes( 'isactive' ) ) {
|
|
2165
2184
|
diff = {
|
|
2166
2185
|
previous: diff.previous ? 'Active' : 'Deactive',
|
|
@@ -2172,22 +2191,21 @@ function findDifferences( previous, current, logType, logSubType, path = '' ) {
|
|
|
2172
2191
|
if ( userFriendlyKey ) {
|
|
2173
2192
|
newKey = userFriendlyKey;
|
|
2174
2193
|
}
|
|
2175
|
-
|
|
2176
|
-
if (
|
|
2194
|
+
const binaryKeys = [ 'Two Factor Authentication', 'Mat Enabled', 'Audit', 'Infra Email Alert', 'Ip Whitelist', 'Excluded Area', 'Passer-by data', 'Normalized data during downtime', 'Billing', 'Camera Blurring', 'Footfall Directory', 'Footfall Directory Audit', 'Footfall Directory Limit', 'NOB Status', 'Traffic', 'Trax', 'Zone V1', 'Zone V2', 'Reports', 'Analyze' ];
|
|
2195
|
+
if ( binaryKeys.includes( newKey ) ) {
|
|
2177
2196
|
diff.previous = ( diff.previous == true || diff.previous == 'Enabled' ) ? 'Enabled' : 'Disabled';
|
|
2178
2197
|
diff.current = ( diff.current == true || diff.current == 'Enabled' ) ? 'Enabled' : 'Disabled';
|
|
2179
2198
|
}
|
|
2180
|
-
if ( newKey === '
|
|
2181
|
-
diff.previous = ( diff.previous == true || diff.previous == '
|
|
2182
|
-
diff.current = ( diff.current == true || diff.current == '
|
|
2199
|
+
if ( newKey === 'Server Type' ) {
|
|
2200
|
+
diff.previous = ( diff.previous == true || diff.previous == 'Server' ) ? 'Server' : 'Serverless';
|
|
2201
|
+
diff.current = ( diff.current == true || diff.current == 'Server' ) ? 'Server' : 'Serverless';
|
|
2183
2202
|
}
|
|
2184
2203
|
|
|
2185
|
-
if ( newKey === '
|
|
2186
|
-
diff.previous = ( diff.previous ==
|
|
2187
|
-
diff.current = ( diff.current ==
|
|
2204
|
+
if ( newKey === 'Stream Type' ) {
|
|
2205
|
+
diff.previous = ( diff.previous == 'Edge' || diff.previous == 'Edge App' ) ? 'Edge App' : 'RTSP';
|
|
2206
|
+
diff.current = ( diff.current == 'Edge' || diff.current == 'Edge App' ) ? 'Edge App' : 'RTSP';
|
|
2188
2207
|
}
|
|
2189
2208
|
|
|
2190
|
-
|
|
2191
2209
|
// **Transform Roles Permission Keys**
|
|
2192
2210
|
const rolesPermissionMatch = newKey.match( /rolespermission\.(\d+)\.modules\.(\d+)\.(isAdd|isEdit)/ );
|
|
2193
2211
|
if ( rolesPermissionMatch ) {
|
|
@@ -2306,3 +2324,34 @@ export async function clientCsmAssignAction( req, res ) {
|
|
|
2306
2324
|
return res.sendError( 'Internal Server Error', 500 );
|
|
2307
2325
|
}
|
|
2308
2326
|
}
|
|
2327
|
+
|
|
2328
|
+
function compareArrayObjects( prevArray, currArray ) {
|
|
2329
|
+
let changes = {};
|
|
2330
|
+
logger.info( { prevArray: prevArray, currArray: currArray } );
|
|
2331
|
+
// Find the longest array length to avoid index mismatch
|
|
2332
|
+
let maxLength = Math.max( prevArray.length, currArray.length );
|
|
2333
|
+
|
|
2334
|
+
for ( let i = 0; i < maxLength; i++ ) {
|
|
2335
|
+
let prevObj = prevArray[i] || {}; // Default to empty object if missing
|
|
2336
|
+
let currObj = currArray[i] || {};
|
|
2337
|
+
let diff = {};
|
|
2338
|
+
|
|
2339
|
+
Object.keys( { ...prevObj, ...currObj } ).forEach( ( key ) => {
|
|
2340
|
+
if ( prevObj[key] !== currObj[key] && key !== '_id' ) {
|
|
2341
|
+
const key1 = key == 'contact'? 'Contact Number': key == 'email'? 'Email ID':key == 'name'?'Name': key == 'designation'?'Designation':key;
|
|
2342
|
+
const name = i ==0? 'Primary Spoc': `Alternate Spoc ${i+1}`;
|
|
2343
|
+
diff[`${name} ${key1}`] = {
|
|
2344
|
+
previous: prevObj[key] || 'null',
|
|
2345
|
+
current: currObj[key] || 'null',
|
|
2346
|
+
};
|
|
2347
|
+
}
|
|
2348
|
+
} );
|
|
2349
|
+
|
|
2350
|
+
if ( Object.keys( diff ).length > 0 ) {
|
|
2351
|
+
// changes.push( { index: i, changes: diff } );
|
|
2352
|
+
changes = { ...changes, ...diff };
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2356
|
+
return changes;
|
|
2357
|
+
}
|