tango-app-api-client 3.4.0-beta.4 → 3.4.0-beta.6

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.4.0-beta.4",
3
+ "version": "3.4.0-beta.6",
4
4
  "description": "client",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -14,6 +14,7 @@
14
14
  "license": "ISC",
15
15
  "dependencies": {
16
16
  "aws-sdk": "^2.1560.0",
17
+ "cors": "^2.8.5",
17
18
  "dotenv": "^16.4.4",
18
19
  "express": "^4.18.2",
19
20
  "express-fileupload": "^1.4.3",
@@ -26,7 +27,7 @@
26
27
  "npm": "^10.9.1",
27
28
  "swagger-ui-express": "^5.0.0",
28
29
  "tango-api-schema": "^2.2.59",
29
- "tango-app-api-middleware": "^3.1.60",
30
+ "tango-app-api-middleware": "^3.1.67",
30
31
  "winston": "^3.11.0",
31
32
  "winston-daily-rotate-file": "^5.0.0"
32
33
  },
@@ -1187,22 +1187,22 @@ export async function updateFeatureConfiguration( req, res ) {
1187
1187
  InfraAlertValue: postData?.featureConfigs?.infraAlert?.value,
1188
1188
  InfraAlertCondition: postData?.featureConfigs?.infraAlert?.condition,
1189
1189
  ConversionCalculations: postData?.featureConfigs?.conversionCalculation,
1190
- ExcludedArea: postData?.featureConfigs?.isExcludedArea ==true ? 'Enable': 'Disable',
1191
- PasserBydata: postData?.featureConfigs?.isPasserByData ==true ? 'Enable': 'Disable',
1192
- NormalizedDataDuringDowntime: postData?.featureConfigs?.isNormalized ==true ? 'Enable': 'Disable',
1193
- Billing: postData?.featureConfigs?.isbillingDisabled ==true ? 'Enable': 'Disable',
1194
- CameraBlurring: postData?.featureConfigs?.isCameraDisabled ==true ? 'Enable': 'Disable',
1195
- FootfallDirectory: postData?.featureConfigs?.isFootfallDirectory ==true ? 'Enable': 'Disable',
1196
- NOBStatus: postData?.featureConfigs?.isNOB ==true ? 'Enable': 'Disable',
1197
- EnableAnalyze: postData?.featureConfigs?.isNewDashboard ==true ? 'Enable': 'Disable',
1198
- Traffic: postData?.featureConfigs?.isNewTraffic==true ? 'Enable': 'Disable',
1199
- Zone: postData?.featureConfigs?.isNewZone ==true ? 'Enable': 'Disable',
1200
- Zonev2: postData?.featureConfigs?.isNewZoneV2 ==true ? 'Enable': 'Disable',
1201
- Reports: postData?.featureConfigs?.isNewReports ==true ? 'Enable': 'Disable',
1202
- Trax: postData?.featureConfigs?.isTrax ==true ? 'Enable': 'Disable',
1190
+ ExcludedArea: postData?.featureConfigs?.isExcludedArea ==true ? 'Enabled': 'Disabled',
1191
+ PasserBydata: postData?.featureConfigs?.isPasserByData ==true ? 'Enabled': 'Disabled',
1192
+ NormalizedDataDuringDowntime: postData?.featureConfigs?.isNormalized ==true ? 'Enabled': 'Disabled',
1193
+ Billing: postData?.featureConfigs?.isbillingDisabled ==true ? 'Enabled': 'Disabled',
1194
+ CameraBlurring: postData?.featureConfigs?.isCameraDisabled ==true ? 'Enabled': 'Disabled',
1195
+ FootfallDirectory: postData?.featureConfigs?.isFootfallDirectory ==true ? 'Enabled': 'Disabled',
1196
+ NOBStatus: postData?.featureConfigs?.isNOB ==true ? 'Enabled': 'Disabled',
1197
+ EnableAnalyze: postData?.featureConfigs?.isNewDashboard ==true ? 'Enabled': 'Disabled',
1198
+ Traffic: postData?.featureConfigs?.isNewTraffic==true ? 'Enabled': 'Disabled',
1199
+ Zone: postData?.featureConfigs?.isNewZone ==true ? 'Enabled': 'Disabled',
1200
+ Zonev2: postData?.featureConfigs?.isNewZoneV2 ==true ? 'Enabled': 'Disabled',
1201
+ Reports: postData?.featureConfigs?.isNewReports ==true ? 'Enabled': 'Disabled',
1202
+ Trax: postData?.featureConfigs?.isTrax ==true ? 'Enabled': 'Disabled',
1203
1203
  StreamType: postData?.featureConfigs?.streamBy =='Edge' ? 'Edge App': 'RTSP',
1204
- FootfallDirectoryOnlyAudit: postData?.featureConfigs?.isFootfallDirectoryAudit ==true ? 'Enable': 'Disable',
1205
- FootfallDirectoryOnlyFew: postData?.featureConfigs?.isFootfallDirectoryLimit ==true ? 'Enable': 'Disable',
1204
+ FootfallDirectoryOnlyAudit: postData?.featureConfigs?.isFootfallDirectoryAudit ==true ? 'Enabled': 'Disabled',
1205
+ FootfallDirectoryOnlyFew: postData?.featureConfigs?.isFootfallDirectoryLimit ==true ? 'Enabled': 'Disabled',
1206
1206
 
1207
1207
  };
1208
1208
 
@@ -1246,11 +1246,11 @@ export async function domainDetailsConfiguration( req, res ) {
1246
1246
  const getPreData = await findOneClient(
1247
1247
  { clientId: req.params?.id }, // filter by clientId
1248
1248
  {
1249
- domainName: '$domainConfig.ssoLogin.domainName',
1250
- isEnable: '$domainConfig.ssoLogin.isEnable',
1251
- ipWhitelist: '$domainConfig.ipWhitelisting.enableWhitelisting',
1252
- WhitelistedIps: '$domainConfig.ipWhitelisting.allowedIps',
1253
- TwoFactorAuthentication: '$domainConfig.enableOtp',
1249
+ 'domainConfig.ssoLogin.domainName': 1,
1250
+ 'domainConfig.ssoLogin.isEnable': 1,
1251
+ 'domainConfig.ipWhitelisting.enableWhitelisting': 1,
1252
+ 'domainConfig.ipWhitelisting.allowedIps': 1,
1253
+ 'domainConfig.enableOtp': 1,
1254
1254
  },
1255
1255
  );
1256
1256
  const updateAck = await domainDetailsConfigurationUpdate( {
@@ -1271,35 +1271,35 @@ export async function domainDetailsConfiguration( req, res ) {
1271
1271
  const getPostData = await findOneClient(
1272
1272
  { clientId: req.params?.id }, // Filter by clientId
1273
1273
  {
1274
- domainName: '$domainConfig.ssoLogin.domainName',
1275
- isEnable: '$domainConfig.ssoLogin.isEnable',
1276
- ipWhitelist: '$domainConfig.ipWhitelisting.enableWhitelisting',
1277
- WhitelistedIps: '$domainConfig.ipWhitelisting.allowedIps',
1278
- TwoFactorAuthentication: '$domainConfig.enableOtp',
1274
+ 'domainConfig.ssoLogin.domainName': 1,
1275
+ 'domainConfig.ssoLogin.isEnable': 1,
1276
+ 'domainConfig.ipWhitelisting.enableWhitelisting': 1,
1277
+ 'domainConfig.ipWhitelisting.allowedIps': 1,
1278
+ 'domainConfig.enableOtp': 1,
1279
1279
  },
1280
1280
  );
1281
1281
 
1282
1282
 
1283
1283
  // Map and rename keys from previous client info for UI display and logging
1284
1284
  const oldData = {
1285
- DomainName: getPreData?.domainConfig?.ssoLogin?.domainName,
1285
+ DomainName: getPreData?.domainConfig?.ssoLogin?.domainName?.join( ', ' ),
1286
1286
  IsEnable: getPreData?.domainConfig?.ssoLogin?.isEnable ==true ? 'Enable': 'Disable',
1287
1287
  IPWhitelist: getPreData?.domainConfig?.ipWhitelisting?.enableWhitelisting ==true ? 'Enable': 'Disable',
1288
- WhitelistedIps: ( getPreData?.domainConfig?.ipWhitelisting?.allowedIps ).join( ', ' ),
1288
+ WhitelistedIps: getPreData?.domainConfig?.ipWhitelisting?.allowedIps?.join( ', ' ),
1289
1289
  TwoFactorAuthentication: getPreData?.domainConfig?.enableOtp ==true ? 'Enable': 'Disable',
1290
1290
 
1291
1291
  };
1292
1292
 
1293
1293
  // Map and rename keys from current client info for UI display and logging
1294
1294
  const newData ={
1295
- DomainName: getPostData?.domainConfig?.ssoLogin?.domainName,
1295
+ DomainName: getPostData?.domainConfig?.ssoLogin?.domainName?.join( ', ' ),
1296
1296
  IsEnable: getPostData?.domainConfig?.ssoLogin?.isEnable ==true ? 'Enable': 'Disable',
1297
1297
  IPWhitelist: getPostData?.domainConfig?.ipWhitelisting?.enableWhitelisting ==true ? 'Enable': 'Disable',
1298
- WhitelistedIps: ( getPostData?.domainConfig?.ipWhitelisting?.allowedIps ).join( ', ' ),
1298
+ WhitelistedIps: getPostData?.domainConfig?.ipWhitelisting?.allowedIps?.join( ', ' ),
1299
1299
  TwoFactorAuthentication: getPostData?.domainConfig?.enableOtp ==true ? 'Enable': 'Disable',
1300
1300
  };
1301
1301
 
1302
-
1302
+ logger.info( { getPreData: getPreData, getPostData: getPostData, newData: newData, oldData: oldData } );
1303
1303
  // Prepare activity log object with all relevant details for OpenSearch logging
1304
1304
  const logObj = {
1305
1305
  clientId: req.params?.id, // ID of the client whose data was updated
@@ -2285,8 +2285,7 @@ export async function getActivityLogs1( req, res ) {
2285
2285
  $match: {
2286
2286
  $and: [
2287
2287
  {
2288
- clientId: { $in: inputData },
2289
- },
2288
+ clientId: { $in: [ inputData?.clientId ] } },
2290
2289
  ],
2291
2290
  },
2292
2291
  },
@@ -2310,31 +2309,17 @@ export async function getActivityLogs1( req, res ) {
2310
2309
  const query = {
2311
2310
  '_source': [
2312
2311
  'userId', 'userName', 'email', 'date', 'logType', 'logSubType',
2313
- 'changes', 'eventType', 'previous', 'current',
2312
+ 'changes', 'eventType', 'previous', 'current', 'oldData', 'newData',
2314
2313
  ],
2315
2314
  'query': {
2316
2315
  'bool': {
2317
- // 'must': [
2318
- // {
2319
- // 'terms': {
2320
- // 'clientId.keyword': [ req.body.clientId ],
2321
- // },
2322
- // },
2323
- // ],
2324
-
2325
- 'should': [
2326
- {
2327
- 'terms': {
2328
- 'clientId.keyword': [ inputData.clientId ],
2329
- },
2330
- },
2316
+ 'must': [
2331
2317
  {
2332
2318
  'terms': {
2333
- 'clientName.keyword': [ getClientName[0].clientName ], // Add clientName condition
2319
+ 'clientId.keyword': [ req.body.clientId ],
2334
2320
  },
2335
2321
  },
2336
2322
  ],
2337
- 'minimum_should_match': 1, // Ensures at least one condition must match
2338
2323
  },
2339
2324
  },
2340
2325
  'from': ( req.body.offset - 1 ) * req.body.limit,
@@ -2388,12 +2373,16 @@ export async function getActivityLogs1( req, res ) {
2388
2373
  let respo ={};
2389
2374
  hit._source.logSubType = hit._source.logSubType === 'documentUpload'? 'documentsUpload': hit._source.logSubType === 'domainDetails'? 'securityFeatures': hit?._source?.logSubType;
2390
2375
  if ( ( ( hit?._source?.eventType ).match( /update/ ) || ( hit?._source?.eventType ).match( /edit/ ) )&& hit?._source?.previous ) {
2391
- const previous = hit?._source?.previous;
2392
- const current=hit?._source?.current;
2376
+ const previous = hit?._source?.logType == 'cameras'?hit?._source?.oldData: hit?._source?.previous;
2377
+ const current=hit?._source?.logType == 'cameras'? hit?._source?.newData:hit?._source?.current;
2393
2378
  const logType =hit?._source?.logType;
2394
-
2395
2379
  const logSubType =hit?._source?.logSubType;
2396
- respo = findDifferences1( previous, current, logType, logSubType );
2380
+ if ( previous && current && hit?._source?.logType == 'cameras' ) {
2381
+ respo = findDifferences( previous, current );
2382
+ } else {
2383
+ respo = findDifferences1( previous, current, logType, logSubType );
2384
+ }
2385
+
2397
2386
  hit._source.updatedValue = respo;
2398
2387
  temp.push( hit?._source );
2399
2388
  hit._source.changes =logSubType === 'ticketConfig'? Object.keys( respo ).map( ( item ) => item ) : hit._source.changes;
@@ -2699,7 +2688,8 @@ function findDifferences( oldData, newData ) {
2699
2688
 
2700
2689
  function splitCamelCase( text ) {
2701
2690
  return text.replace( /([a-z])([A-Z])/g, '$1 $2' ) // Add space between camelCase words
2702
- .replace( /(\d+)/g, ' $1 ' ) // Add space between numbers
2691
+ .replace( /([a-zA-Z])(\d+)/g, '$1 $2' ) // Add space between letters and numbers
2692
+ .replace( /(\d+)([a-zA-Z])/g, '$1 $2' )
2703
2693
  .trim();
2704
2694
  }
2705
2695
 
@@ -52,8 +52,8 @@ export const signatoryDetailsSchemaBody = joi.object( {
52
52
  name: joi.string().optional(),
53
53
  email: joi.string().email().message( 'Enter a valid email' ).optional(),
54
54
  number: joi.string()
55
- .pattern( /^\d{4,12}$/ )
56
- .message( 'Enter a valid mobile number' )
55
+ .pattern( /^\d{7,15}$/ )
56
+ .message( 'Mobile Number Must be Valid' )
57
57
  .optional(),
58
58
  designation: joi.string().optional(),
59
59
  } );