tango-app-api-client 3.3.3-beta.10 → 3.3.3-beta.11
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
|
@@ -700,33 +700,40 @@ export async function updateBrandInfo( req, res ) {
|
|
|
700
700
|
updateKeys.push( camelCaseToWords( element ) );
|
|
701
701
|
} );
|
|
702
702
|
}
|
|
703
|
+
const getPreCientInfo = await findOneClient( { clientId: req.params.id }, { _id: 0, registeredCompanyName: '$profileDetails.registeredCompanyName', industry: '$profileDetails.industry', clientType: '$profileDetails.clientType',
|
|
704
|
+
registeredAddress: '$profileDetails.registeredAddress', headQuarters: '$profileDetails.headQuarters', website: '$profileDetails.website', status: 1, averageTransactionValue: 1 } );
|
|
703
705
|
|
|
704
|
-
const user = await getUserNameEmailById( req.userId );
|
|
705
706
|
|
|
707
|
+
const updateAck = await brandInfoUpdate( {
|
|
708
|
+
clientId: req.params?.id, registeredCompanyName: req.body?.registeredCompanyName, industry: req.body?.industry,
|
|
709
|
+
clientType: req.body?.clientType, registeredAddress: req.body?.registeredAddress, headQuarters: req.body?.headQuarters,
|
|
710
|
+
website: req.body?.website, status: req.body?.status, logo: req.files?.logo ? `brandLogo.${req.files.logo.name.split( '.' )[1]}` : undefined, averageTransactionValue: req.body?.averageTransactionValue,
|
|
711
|
+
} );
|
|
712
|
+
const getPosCientInfo = await findOneClient( { clientId: req.params.id }, { _id: 0, registeredCompanyName: '$profileDetails.registeredCompanyName', industry: '$profileDetails.industry', clientType: '$profileDetails.clientType',
|
|
713
|
+
registeredAddress: '$profileDetails.registeredAddress', headQuarters: '$profileDetails.headQuarters', website: '$profileDetails.website', status: 1, averageTransactionValue: 1 } );
|
|
706
714
|
|
|
707
715
|
const logObj = {
|
|
708
716
|
clientId: req.params?.id,
|
|
709
|
-
userName: user?.userName,
|
|
710
|
-
email: user?.email,
|
|
717
|
+
userName: req?.user?.userName,
|
|
718
|
+
email: req?.user?.email,
|
|
711
719
|
date: new Date(),
|
|
712
720
|
logType: 'brandDetails',
|
|
713
721
|
logSubType: 'brandInfo',
|
|
714
722
|
changes: updateKeys,
|
|
715
723
|
eventType: 'update',
|
|
716
724
|
showTo: [ 'client', 'tango' ],
|
|
725
|
+
previous: getPreCientInfo,
|
|
726
|
+
current: getPosCientInfo,
|
|
717
727
|
};
|
|
718
|
-
|
|
728
|
+
logger.info( { previous: getPreCientInfo,
|
|
729
|
+
current: getPosCientInfo, logObj: logObj } );
|
|
719
730
|
if ( updateKeys.length ) {
|
|
720
|
-
|
|
731
|
+
logger.info( { updateKeys: updateKeys } );
|
|
732
|
+
const a =await insertOpenSearchData( openSearch.activityLog, logObj );
|
|
733
|
+
logger.info( { a: a } );
|
|
721
734
|
}
|
|
722
735
|
|
|
723
736
|
|
|
724
|
-
const updateAck = await brandInfoUpdate( {
|
|
725
|
-
clientId: req.params?.id, registeredCompanyName: req.body?.registeredCompanyName, industry: req.body?.industry,
|
|
726
|
-
clientType: req.body?.clientType, registeredAddress: req.body?.registeredAddress, headQuarters: req.body?.headQuarters,
|
|
727
|
-
website: req.body?.website, status: req.body?.status, logo: req.files?.logo ? `brandLogo.${req.files.logo.name.split( '.' )[1]}` : undefined, averageTransactionValue: req.body?.averageTransactionValue,
|
|
728
|
-
} );
|
|
729
|
-
|
|
730
737
|
if ( req.body?.status === 'active' ) {
|
|
731
738
|
await updateManyStore( { clientId: req.params?.id }, { status: 'active' } );
|
|
732
739
|
await updateManyUser( { clientId: req.params?.id }, { isActive: true } );
|
|
@@ -878,7 +885,7 @@ export async function updateSignatoryDetails( req, res ) {
|
|
|
878
885
|
export async function updateTicketConfiguration( req, res ) {
|
|
879
886
|
try {
|
|
880
887
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
881
|
-
let
|
|
888
|
+
let findClient = await findOneClient( { clientId: req.params?.id } );
|
|
882
889
|
const updateAck = await ticketConfigurationUpdate( {
|
|
883
890
|
clientId: req.params?.id, MinFilesCount: req.body?.MinFilesCount, accuracyPercentage: req.body?.accuracyPercentage, downTimeType: req.body?.downTimeType,
|
|
884
891
|
infraDownTime: req.body?.infraDownTime, installationReAssign: req.body?.installationReAssign, isRcaTicketAssign: req.body?.isRcaTicketAssign,
|
|
@@ -894,7 +901,7 @@ export async function updateTicketConfiguration( req, res ) {
|
|
|
894
901
|
}
|
|
895
902
|
|
|
896
903
|
const user = await getUserNameEmailById( req.userId );
|
|
897
|
-
let
|
|
904
|
+
let updatedClient = await findOneClient( { clientId: req.params?.id } );
|
|
898
905
|
|
|
899
906
|
const logObj = {
|
|
900
907
|
clientId: req.params?.id,
|
|
@@ -906,8 +913,8 @@ export async function updateTicketConfiguration( req, res ) {
|
|
|
906
913
|
changes: updateKeys,
|
|
907
914
|
eventType: 'update',
|
|
908
915
|
showTo: [ 'tango' ],
|
|
909
|
-
current:updatedClient.ticketConfigs,
|
|
910
|
-
previous:findClient.ticketConfigs
|
|
916
|
+
current: updatedClient.ticketConfigs,
|
|
917
|
+
previous: findClient.ticketConfigs,
|
|
911
918
|
};
|
|
912
919
|
|
|
913
920
|
if ( updateKeys.length ) {
|
|
@@ -1020,6 +1027,7 @@ export async function updateFeatureConfiguration( req, res ) {
|
|
|
1020
1027
|
export async function domainDetailsConfiguration( req, res ) {
|
|
1021
1028
|
try {
|
|
1022
1029
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
1030
|
+
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' } );
|
|
1023
1031
|
const updateAck = await domainDetailsConfigurationUpdate( {
|
|
1024
1032
|
clientId: req.params?.id, domainName: req.body?.domainName, isEnable: req.body?.isEnable,
|
|
1025
1033
|
enableWhitelisting: req.body?.enableWhitelisting, allowedIps: req.body?.allowedIps, enableOtp: req.body?.enableOtp,
|
|
@@ -1034,19 +1042,20 @@ export async function domainDetailsConfiguration( req, res ) {
|
|
|
1034
1042
|
} );
|
|
1035
1043
|
}
|
|
1036
1044
|
|
|
1037
|
-
const
|
|
1038
|
-
|
|
1045
|
+
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' } );
|
|
1039
1046
|
|
|
1040
1047
|
const logObj = {
|
|
1041
1048
|
clientId: req.params?.id,
|
|
1042
|
-
userName: user?.userName,
|
|
1043
|
-
email: user?.email,
|
|
1049
|
+
userName: req?.user?.userName,
|
|
1050
|
+
email: req?.user?.email,
|
|
1044
1051
|
date: new Date(),
|
|
1045
1052
|
logType: 'configuration',
|
|
1046
1053
|
logSubType: 'domainDetails',
|
|
1047
1054
|
changes: updateKeys,
|
|
1048
1055
|
eventType: 'update',
|
|
1049
1056
|
showTo: [ 'client', 'tango' ],
|
|
1057
|
+
previous: getPreData,
|
|
1058
|
+
current: getPostData,
|
|
1050
1059
|
};
|
|
1051
1060
|
|
|
1052
1061
|
if ( updateKeys.length ) {
|
|
@@ -2085,7 +2094,8 @@ export async function getActivityLogs( req, res ) {
|
|
|
2085
2094
|
const previous = hit?._source?.previous;
|
|
2086
2095
|
const current=hit?._source?.current;
|
|
2087
2096
|
const logType =hit?._source?.logType;
|
|
2088
|
-
|
|
2097
|
+
const logSubType =hit?._source?.logSubType;
|
|
2098
|
+
respo = findDifferences( previous, current, logType, logSubType );
|
|
2089
2099
|
hit._source.updatedValue = respo;
|
|
2090
2100
|
temp.push( hit?._source );
|
|
2091
2101
|
} else {
|
|
@@ -2104,15 +2114,15 @@ export async function getActivityLogs( req, res ) {
|
|
|
2104
2114
|
}
|
|
2105
2115
|
|
|
2106
2116
|
|
|
2107
|
-
function findDifferences( previous, current, logType, path = '' ) {
|
|
2117
|
+
function findDifferences( previous, current, logType, logSubType, path = '' ) {
|
|
2108
2118
|
const dbKeys = JSON.parse( process.env.DB_KEYS );
|
|
2109
2119
|
const ignoredKeys = new Set( [
|
|
2110
2120
|
'_id', 'updatedAt', 'createdAt', 'password', 'clientId',
|
|
2111
2121
|
'storeId', 'refreshToken', 'employeeId', 'fcmToken', 'permission',
|
|
2112
2122
|
] );
|
|
2113
|
-
|
|
2123
|
+
const documents = dbKeys.DOCUMENTS;
|
|
2114
2124
|
// Get correct key mapping based on logType
|
|
2115
|
-
const keyMapping =
|
|
2125
|
+
const keyMapping = logType == 'stores' ?documents.stores: logType == 'users' ?documents.users :logSubType=='reportConfig'?documents.reports: logType=='brandInfo'?documents.client:documents.client;
|
|
2116
2126
|
|
|
2117
2127
|
let differences = {};
|
|
2118
2128
|
|
|
@@ -2123,7 +2133,7 @@ function findDifferences( previous, current, logType, path = '' ) {
|
|
|
2123
2133
|
const currValue = current[key];
|
|
2124
2134
|
|
|
2125
2135
|
if ( typeof prevValue === 'object' && typeof currValue === 'object' && prevValue !== null && currValue !== null ) {
|
|
2126
|
-
const nestedDiffs = findDifferences( prevValue, currValue, logType, `${path}${key}.` );
|
|
2136
|
+
const nestedDiffs = findDifferences( prevValue, currValue, logType, logSubType, `${path}${key}.` );
|
|
2127
2137
|
Object.assign( differences, nestedDiffs );
|
|
2128
2138
|
} else if ( prevValue !== currValue ) {
|
|
2129
2139
|
if (
|
|
@@ -2139,7 +2149,7 @@ function findDifferences( previous, current, logType, path = '' ) {
|
|
|
2139
2149
|
// **Transform & Filter Differences**
|
|
2140
2150
|
let updatedDifferences = {};
|
|
2141
2151
|
Object.keys( differences ).forEach( ( key ) => {
|
|
2142
|
-
let newKey = key.replace( /spocDetails\.\d+\./, 'spocDetails.' );
|
|
2152
|
+
let newKey = key.replace( /spocDetails\.\d+\./, 'spocDetails.' ).replace( /WhitelistesIps\.\d+/, 'Whitelisted Ips' );
|
|
2143
2153
|
let diff = differences[key];
|
|
2144
2154
|
|
|
2145
2155
|
if ( newKey.toLowerCase().includes( 'isactive' ) ) {
|
|
@@ -2154,11 +2164,21 @@ function findDifferences( previous, current, logType, path = '' ) {
|
|
|
2154
2164
|
newKey = userFriendlyKey;
|
|
2155
2165
|
}
|
|
2156
2166
|
|
|
2157
|
-
if ( newKey === 'Infra Email Alert' ) {
|
|
2158
|
-
diff.previous = diff.previous ? 'Enabled' : 'Disabled';
|
|
2159
|
-
diff.current = diff.current ? 'Enabled' : 'Disabled';
|
|
2167
|
+
if ( newKey === 'Infra Email Alert' || newKey === 'Ip Whitelist' ) {
|
|
2168
|
+
diff.previous = ( diff.previous == true || diff.previous == 'Enabled' ) ? 'Enabled' : 'Disabled';
|
|
2169
|
+
diff.current = ( diff.current == true || diff.current == 'Enabled' ) ? 'Enabled' : 'Disabled';
|
|
2170
|
+
}
|
|
2171
|
+
if ( newKey === 'Mat Enabled' ) {
|
|
2172
|
+
diff.previous = ( diff.previous == true || diff.previous == 'Enabled' )?'Enabled' : 'Disabled';
|
|
2173
|
+
diff.current = ( diff.current == true || diff.current == 'Enabled' ) ? 'Enabled' : 'Disabled';
|
|
2174
|
+
}
|
|
2175
|
+
|
|
2176
|
+
if ( newKey === 'Two Factor Authentication' ) {
|
|
2177
|
+
diff.previous = ( diff.previous == true || diff.previous == 'Enabled' ) ? 'Enabled' : 'Disabled';
|
|
2178
|
+
diff.current = ( diff.current == true || diff.current == 'Enabled' ) ? 'Enabled' : 'Disabled';
|
|
2160
2179
|
}
|
|
2161
2180
|
|
|
2181
|
+
|
|
2162
2182
|
// **Transform Roles Permission Keys**
|
|
2163
2183
|
const rolesPermissionMatch = newKey.match( /rolespermission\.(\d+)\.modules\.(\d+)\.(isAdd|isEdit)/ );
|
|
2164
2184
|
if ( rolesPermissionMatch ) {
|