tango-app-api-audit 3.4.3-alpha.15 → 3.4.3-alpha.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-audit",
3
- "version": "3.4.3-alpha.15",
3
+ "version": "3.4.3-alpha.16",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1218,6 +1218,7 @@ export async function getDraftedData( req, res ) {
1218
1218
  userId: userId,
1219
1219
  moduleType: inputData.moduleType,
1220
1220
  zoneName: inputData.zoneName,
1221
+ auditId: inputData.auditId,
1221
1222
  };
1222
1223
  const result = await findOneAuditLog( query, {}, { createdAt: -1 }, 1 );
1223
1224
 
@@ -4429,24 +4430,25 @@ export async function auditViewLogs( req, res ) {
4429
4430
  try {
4430
4431
  const inputData = req.query;
4431
4432
  const parsedOpenSearch = JSON.parse( process.env.OPENSEARCH );
4432
- let downTimeQuery = {
4433
+ const logData =[];
4434
+ let logsQuery = {
4433
4435
  'size': 100,
4434
4436
  'query': {
4435
4437
  'bool': {
4436
4438
  'must': [
4437
4439
  {
4438
4440
  'term': {
4439
- 'doc.logData.fileDate.keyword': dayjs( inputData.fileDate ).format( 'DD-MM-YYYY' ),
4441
+ 'logData.fileDate.keyword': inputData.fileDate,
4440
4442
  },
4441
4443
  },
4442
4444
  {
4443
4445
  'term': {
4444
- 'doc.logData.storeId.keyword': inputData.storeId,
4446
+ 'logData.storeId.keyword': inputData.storeId,
4445
4447
  },
4446
4448
  },
4447
4449
  {
4448
4450
  'term': {
4449
- 'doc.logData.moduleType.keyword': inputData.moduleType,
4451
+ 'logData.moduleType.keyword': inputData.moduleType,
4450
4452
  },
4451
4453
  },
4452
4454
  ],
@@ -4454,10 +4456,17 @@ export async function auditViewLogs( req, res ) {
4454
4456
  },
4455
4457
  },
4456
4458
  };
4457
- const downtime = await getOpenSearchData( parsedOpenSearch.auditLog, downTimeQuery );
4458
- return res.sendSuccess( downtime );
4459
- } catch ( err ) {
4460
-
4459
+ const logs = await getOpenSearchData( parsedOpenSearch.auditLog, logsQuery );
4460
+ if ( logs.body.hits.hits.length > 0 ) {
4461
+ logData.push( logs.body.hits.hits[0]._source );
4462
+ return res.sendSuccess( logData );
4463
+ } else {
4464
+ return res.sendError( 'No Record Inserted', 500 );
4465
+ }
4466
+ } catch ( error ) {
4467
+ const err = error.message || 'Internal Server Error';
4468
+ logger.info( { error: error, message: req.body, function: 'auditViewLogs' } );
4469
+ return res.sendError( err, 500 );
4461
4470
  }
4462
4471
  }
4463
4472
 
@@ -4212,6 +4212,7 @@ export async function getDraftedData( req, res ) {
4212
4212
  storeId: inputData.storeId,
4213
4213
  userId: userId,
4214
4214
  moduleType: inputData.moduleType,
4215
+ auditId: inputData.auditId,
4215
4216
  };
4216
4217
  const result = await findOneAuditLog( query, {}, { createdAt: -1 }, 1 );
4217
4218
 
@@ -184,6 +184,12 @@ export const auditDocs = {
184
184
  scema: j2s( getDraftedDataSchema ).swagger,
185
185
  require: true,
186
186
  },
187
+ {
188
+ in: 'query',
189
+ name: 'auditId',
190
+ scema: j2s( getDraftedDataSchema ).swagger,
191
+ require: true,
192
+ },
187
193
  {
188
194
  in: 'query',
189
195
  name: 'userId',
@@ -387,6 +387,12 @@ export const traxAuditDocs = {
387
387
  scema: j2s( getDraftedDataSchema ).swagger,
388
388
  require: true,
389
389
  },
390
+ {
391
+ in: 'query',
392
+ name: 'auditId',
393
+ scema: j2s( getDraftedDataSchema ).swagger,
394
+ require: true,
395
+ },
390
396
  {
391
397
  in: 'query',
392
398
  name: 'userId',
@@ -76,6 +76,7 @@ export const getDraftedDataSchema = joi.object( {
76
76
  userId: joi.string().optional(),
77
77
  moduleType: joi.string().required(),
78
78
  zoneName: joi.string().required(),
79
+ auditId: joi.string().required(),
79
80
  } );
80
81
 
81
82
  export const getDraftedDataValid = {
@@ -68,6 +68,7 @@ export const getDraftedDataSchema = joi.object(
68
68
  fileDate: joi.string().required(),
69
69
  userId: joi.string().optional(),
70
70
  moduleType: joi.string().required(),
71
+ auditId: joi.string().required(),
71
72
  },
72
73
  );
73
74