tango-app-api-client 3.3.3-beta.14 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-client",
3
- "version": "3.3.3-beta.14",
3
+ "version": "3.3.3-beta.15",
4
4
  "description": "client",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -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
- let findClient = await findOneClient( { clientId: req.params?.id } );
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', TwoFactorAuthentication: '$domainConfig.ssoLogin.isEnable', ipWhitelist: '$domainConfig.ipWhitelisting.enableWhitelisting', WhitelistesIps: '$domainConfig.ipWhitelisting.allowedIps', enableOtp: '$domainConfig.enableOtp' } );
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', TwoFactorAuthentication: '$domainConfig.enableOtp', ipWhitelist: '$domainConfig.ipWhitelisting.enableWhitelisting', WhitelistesIps: '$domainConfig.ipWhitelisting.allowedIps', isEnable: '$domainConfig.ssoLogin.isEnable' } );
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: normalizeNumber( inputData.ratio, 0, 100 ),
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
  }
@@ -2133,6 +2136,7 @@ function findDifferences( previous, current, logType, logSubType, path = '' ) {
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 ) {
@@ -2141,9 +2145,21 @@ function findDifferences( previous, current, logType, logSubType, path = '' ) {
2141
2145
  const prevValue = previous[key];
2142
2146
  const currValue = current[key];
2143
2147
 
2144
- 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 ) ) {
2145
2149
  const nestedDiffs = findDifferences( prevValue, currValue, logType, logSubType, `${path}${key}.` );
2146
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;
2147
2163
  } else if ( prevValue !== currValue ) {
2148
2164
  if (
2149
2165
  ( prevValue === '' && currValue === '' ) ||
@@ -2158,9 +2174,8 @@ function findDifferences( previous, current, logType, logSubType, path = '' ) {
2158
2174
  // **Transform & Filter Differences**
2159
2175
  let updatedDifferences = {};
2160
2176
  Object.keys( differences ).forEach( ( key ) => {
2161
- let newKey = key.replace( /spocDetails\.\d+\./, 'spocDetails.' ).replace( /WhitelistesIps\.\d+/, 'Whitelisted Ips' );
2177
+ let newKey = key.replace( /spocDetails\.\d+\./, 'spocDetails.' ).replace( /WhitelistedIps\.\d+/, 'Whitelisted Ips' );
2162
2178
  let diff = differences[key];
2163
-
2164
2179
  if ( newKey.toLowerCase().includes( 'isactive' ) ) {
2165
2180
  diff = {
2166
2181
  previous: diff.previous ? 'Active' : 'Deactive',
@@ -2172,22 +2187,16 @@ function findDifferences( previous, current, logType, logSubType, path = '' ) {
2172
2187
  if ( userFriendlyKey ) {
2173
2188
  newKey = userFriendlyKey;
2174
2189
  }
2175
-
2176
- if ( newKey === 'Infra Email Alert' || newKey === 'Ip Whitelist' || newKey === 'Excluded Area'|| newKey === 'Passer By Data'|| newKey === 'Normalized'|| newKey === 'Billing'|| newKey === 'Camera'|| newKey === 'Footfall Directory'|| newKey === 'NOB'|| newKey === 'New Traffic'|| newKey === 'Trax'|| newKey === 'New Zone'|| newKey === 'New Reports'|| newKey === 'New Dashboard'|| newKey === 'Stream Type' ) {
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 ) ) {
2177
2192
  diff.previous = ( diff.previous == true || diff.previous == 'Enabled' ) ? 'Enabled' : 'Disabled';
2178
2193
  diff.current = ( diff.current == true || diff.current == 'Enabled' ) ? 'Enabled' : 'Disabled';
2179
2194
  }
2180
- if ( newKey === 'Mat Enabled' ) {
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
- if ( newKey === 'Two Factor Authentication' ) {
2186
- diff.previous = ( diff.previous == true || diff.previous == 'Enabled' ) ? 'Enabled' : 'Disabled';
2187
- diff.current = ( diff.current == true || diff.current == 'Enabled' ) ? 'Enabled' : 'Disabled';
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';
2188
2198
  }
2189
2199
 
2190
-
2191
2200
  // **Transform Roles Permission Keys**
2192
2201
  const rolesPermissionMatch = newKey.match( /rolespermission\.(\d+)\.modules\.(\d+)\.(isAdd|isEdit)/ );
2193
2202
  if ( rolesPermissionMatch ) {
@@ -2306,3 +2315,34 @@ export async function clientCsmAssignAction( req, res ) {
2306
2315
  return res.sendError( 'Internal Server Error', 500 );
2307
2316
  }
2308
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
+ }