tango-app-api-audit 3.3.0-alpha.0 → 3.3.0-alpha.10
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 +3 -3
- package/src/controllers/audit.controllers.js +309 -36
- package/src/docs/audit.docs.js +43 -2
- package/src/dtos/audit.dtos.js +25 -3
- package/src/routes/audit.routes.js +5 -7
- package/src/service/auditStoreData.service.js +1 -1
- package/src/validation/audit.validation.js +9 -8
- package/src/controllers/auditMetrics.controllers.js +0 -71
- package/src/controllers/zoneAudit.controller.js +0 -1827
- package/src/docs/auditMetrics.docs.js +0 -70
- package/src/docs/zoneAudit.docs.js +0 -268
- package/src/dtos/auditMetrics.dtos.js +0 -39
- package/src/dtos/zoneAudit.dtos.js +0 -171
- package/src/routes/auditMetrics.routes.js +0 -14
- package/src/routes/zone.routes.js +0 -24
- package/src/validation/zoneAudit.validation.js +0 -167
package/src/dtos/audit.dtos.js
CHANGED
|
@@ -227,7 +227,7 @@ export const userMetricsValid = {
|
|
|
227
227
|
body: userMetricsSchema,
|
|
228
228
|
};
|
|
229
229
|
|
|
230
|
-
export const
|
|
230
|
+
export const pendingSummaryTableSchema = joi.object(
|
|
231
231
|
{
|
|
232
232
|
fromDate: joi.string().required(),
|
|
233
233
|
toDate: joi.string().required(),
|
|
@@ -244,8 +244,29 @@ export const overViewTableSchema = joi.object(
|
|
|
244
244
|
},
|
|
245
245
|
);
|
|
246
246
|
|
|
247
|
-
export const
|
|
248
|
-
body:
|
|
247
|
+
export const pendingSummaryTableValid = {
|
|
248
|
+
body: pendingSummaryTableSchema,
|
|
249
|
+
};
|
|
250
|
+
|
|
251
|
+
export const overviewTableSchema = joi.object(
|
|
252
|
+
{
|
|
253
|
+
fromDate: joi.string().required(),
|
|
254
|
+
toDate: joi.string().required(),
|
|
255
|
+
clientId: joi.array().optional(),
|
|
256
|
+
limit: joi.number().optional(),
|
|
257
|
+
offset: joi.number().optional(),
|
|
258
|
+
searchValue: joi.string().optional().allow( '' ),
|
|
259
|
+
filterByStatus: joi.array().optional(),
|
|
260
|
+
filterByModuleType: joi.array().optional(),
|
|
261
|
+
filterByAuditType: joi.array().optional(),
|
|
262
|
+
sortColumnName: joi.string().optional(),
|
|
263
|
+
sortBy: joi.number().optional(),
|
|
264
|
+
isExport: joi.boolean().optional(),
|
|
265
|
+
},
|
|
266
|
+
);
|
|
267
|
+
|
|
268
|
+
export const overviewTableValid= {
|
|
269
|
+
body: overviewTableSchema,
|
|
249
270
|
};
|
|
250
271
|
|
|
251
272
|
export const overAllAuditSummarySchema = joi.object(
|
|
@@ -296,6 +317,7 @@ export const summarySplitSchema = joi.object(
|
|
|
296
317
|
fromDate: joi.string().required(),
|
|
297
318
|
toDate: joi.string().required(),
|
|
298
319
|
clientId: joi.array().optional(),
|
|
320
|
+
moduleType: joi.array().optional(),
|
|
299
321
|
},
|
|
300
322
|
);
|
|
301
323
|
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
2
|
import { isAuditDocumentExist, isAuditInputFolderExist, isExistsQueue, validateUserAudit } from '../validation/audit.validation.js';
|
|
3
3
|
import { isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
|
|
4
|
-
import { auditStoreList, auditUserList, clientMetrics, clients, getAuditFile, getDraftedData, overAllAuditSummary, overViewCard,
|
|
5
|
-
import { auditStoreValid, clientMetricsValid, clientValid, getDraftedDataValid, getFileValid, overAllAuditSummaryValid, overViewCardValid,
|
|
6
|
-
import { auditImages } from '../controllers/auditMetrics.controllers.js';
|
|
4
|
+
import { auditImages, auditStoreList, auditUserList, clientMetrics, clients, getAuditFile, getDraftedData, overAllAuditSummary, overViewCard, overviewTable, pendingSummaryTable, reTrigger, save, saveDraft, storeMetrics, summarySplit, userAuditHistory, userMetrics, workSpace } from '../controllers/audit.controllers.js';
|
|
5
|
+
import { auditStoreValid, clientMetricsValid, clientValid, getDraftedDataValid, getFileValid, overAllAuditSummaryValid, overViewCardValid, pendingSummaryTableValid, reTriggerValid, saveDraftValid, saveValid, storeMetricsValid, summarySplitValid, userAuditHistoryValid, userMetricsValid, workSpaceValid, auditImageValid, overviewTableValid } from '../dtos/audit.dtos.js';
|
|
7
6
|
|
|
8
7
|
export const auditRouter = express.Router();
|
|
9
8
|
|
|
@@ -25,14 +24,13 @@ auditRouter.post( '/metrics/user-audit-history', isAllowedSessionHandler, valida
|
|
|
25
24
|
auditRouter.post( '/metrics/client-metrics', isAllowedSessionHandler, validate( clientMetricsValid ), clientMetrics );
|
|
26
25
|
auditRouter.post( '/metrics/store-metrics', isAllowedSessionHandler, validate( storeMetricsValid ), storeMetrics );
|
|
27
26
|
auditRouter.post( '/metrics/user-metrics', isAllowedSessionHandler, validate( userMetricsValid ), userMetrics );
|
|
28
|
-
auditRouter.post( '/metrics/
|
|
27
|
+
auditRouter.post( '/metrics/pending-summary-table', isAllowedSessionHandler, validate( pendingSummaryTableValid ), pendingSummaryTable );
|
|
29
28
|
auditRouter.post( '/metrics/overall-audit-summary', isAllowedSessionHandler, validate( overAllAuditSummaryValid ), overAllAuditSummary );
|
|
30
29
|
auditRouter.post( '/metrics/re-trigger', isAllowedSessionHandler, validate( reTriggerValid ), isAuditDocumentExist, isAuditInputFolderExist, reTrigger );
|
|
31
30
|
auditRouter.get( '/audit-images', isAllowedSessionHandler, validate( auditImageValid ), isAuditInputFolderExist, auditImages );
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
// hold
|
|
31
|
+
// summary
|
|
35
32
|
auditRouter.post( '/metrics/overview-card', isAllowedSessionHandler, validate( overViewCardValid ), overViewCard );
|
|
36
33
|
auditRouter.post( '/metrics/summary-split-up', isAllowedSessionHandler, validate( summarySplitValid ), summarySplit );
|
|
34
|
+
auditRouter.post( '/metrics/overview-table', isAllowedSessionHandler, validate( overviewTableValid ), overviewTable );
|
|
37
35
|
|
|
38
36
|
export default auditRouter;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import auditStoreDataModel from 'tango-api-schema/schema/auditStoreData.model.js';
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
export function
|
|
4
|
+
export function aggregateAuditStoreData( query ) {
|
|
5
5
|
return auditStoreDataModel.aggregate( query, { collation: { locale: 'en', strength: 2 } } );
|
|
6
6
|
}
|
|
7
7
|
|
|
@@ -215,6 +215,7 @@ export async function getAuditImageData( data ) {
|
|
|
215
215
|
Bucket: `${bucket.auditInput}`,
|
|
216
216
|
filePath: `${fileDate}/${storeId}/${data.zoneName}/`,
|
|
217
217
|
};
|
|
218
|
+
|
|
218
219
|
const folderPath = await listFileWithoutLimit( fetchData );
|
|
219
220
|
if ( folderPath.statusCode == 404 ) {
|
|
220
221
|
return folderPath;
|
|
@@ -233,11 +234,10 @@ export async function getAuditImageData( data ) {
|
|
|
233
234
|
};
|
|
234
235
|
const data = await signedUrl( params );
|
|
235
236
|
files.push( {
|
|
236
|
-
|
|
237
|
-
imgName: indexes[1],
|
|
238
|
-
imgId: image[0],
|
|
237
|
+
img_path: data,
|
|
239
238
|
img_name: indexes[1],
|
|
240
|
-
|
|
239
|
+
img_id: image[0],
|
|
240
|
+
imgFile: auditImages[i],
|
|
241
241
|
} );
|
|
242
242
|
}
|
|
243
243
|
return files;
|
|
@@ -254,9 +254,8 @@ export async function getAuditImageData( data ) {
|
|
|
254
254
|
};
|
|
255
255
|
const data = await signedUrl( params );
|
|
256
256
|
files.push( {
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
imgId: image[0],
|
|
257
|
+
img_path: data,
|
|
258
|
+
img_id: image[0],
|
|
260
259
|
imgFile: auditImages[i],
|
|
261
260
|
img_name: indexes[1],
|
|
262
261
|
} );
|
|
@@ -272,6 +271,7 @@ export async function getAuditImageData( data ) {
|
|
|
272
271
|
|
|
273
272
|
export async function zipDownloadImage( data ) {
|
|
274
273
|
try {
|
|
274
|
+
logger.info( { zipDownloadImage: data } );
|
|
275
275
|
const bucket = JSON.parse( process.env.BUCKET );
|
|
276
276
|
const zip = new AdmZip();
|
|
277
277
|
const split = await chunkArray( data, 10 );
|
|
@@ -281,6 +281,7 @@ export async function zipDownloadImage( data ) {
|
|
|
281
281
|
Bucket: `${bucket.auditInput}`,
|
|
282
282
|
Key: chunk[i].imgFile.Key,
|
|
283
283
|
};
|
|
284
|
+
logger.info( { params: params } );
|
|
284
285
|
const fileBuffer = await getObject( params );
|
|
285
286
|
zip.addFile( chunk[i].imgFile.Key, fileBuffer.Body );
|
|
286
287
|
}
|
|
@@ -302,7 +303,7 @@ export async function getAuditFilterData( data ) {
|
|
|
302
303
|
const storeId = data.storeId;
|
|
303
304
|
const fileDate = data.fileDate;
|
|
304
305
|
const params = {
|
|
305
|
-
Bucket: `${bucket.
|
|
306
|
+
Bucket: `${bucket.auditUploadBucket}`,
|
|
306
307
|
Key: `${storeId}/${data.zoneName}/${fileDate}/${bucket.masterJsonFile}`,
|
|
307
308
|
};
|
|
308
309
|
const mappingFile = await getJsonFileData( params );
|
|
@@ -1,71 +0,0 @@
|
|
|
1
|
-
import { logger } from 'tango-app-api-middleware';
|
|
2
|
-
import { getAuditFilterData, getAuditImageData, zipDownloadImage } from '../validation/audit.validation.js';
|
|
3
|
-
import { getReauditImg } from './audit.controllers.js';
|
|
4
|
-
// import { listQueue } from 'tango-app-api-middleware/src/utils/aws/sqs.js';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
export async function auditImages( req, res ) {
|
|
8
|
-
try {
|
|
9
|
-
const inputData = req.query;
|
|
10
|
-
let auditImageDownload = '';
|
|
11
|
-
switch ( inputData.imageType ) {
|
|
12
|
-
case 'BC':
|
|
13
|
-
const auditImageBC = await getAuditImageData( inputData );
|
|
14
|
-
if ( auditImageBC?.errorCode ) {
|
|
15
|
-
const error = auditImageBC?.errorMsg;
|
|
16
|
-
const code = auditImageBC?.errorCode;
|
|
17
|
-
return res.sendError( { error: error }, code );
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if ( inputData.export==true ) {
|
|
21
|
-
auditImageDownload= await zipDownloadImage( auditImageBC );
|
|
22
|
-
// Set response headers for the zip file
|
|
23
|
-
res.set( 'Content-Type', 'application/zip' );
|
|
24
|
-
res.set( 'Content-Disposition', `attachment; filename=${inputData.storeId}_${inputData.fileDate}_${inputData.imageType}.zip` );
|
|
25
|
-
|
|
26
|
-
// Send the zip file as the API response
|
|
27
|
-
return res.send( auditImageDownload );
|
|
28
|
-
}
|
|
29
|
-
res.sendSuccess( { result: auditImageBC } );
|
|
30
|
-
|
|
31
|
-
break;
|
|
32
|
-
|
|
33
|
-
case 'AC':
|
|
34
|
-
|
|
35
|
-
const [ filterData, auditImageAC ] = await Promise.all( [ getAuditFilterData( inputData ), getAuditImageData( inputData ) ] );
|
|
36
|
-
|
|
37
|
-
if ( filterData?.errorCode || auditImageAC?.errorCode ) {
|
|
38
|
-
const error = filterData?.errorMsg || auditImageAC.errorMsg;
|
|
39
|
-
const code = filterData?.errorCode || auditImageAC.errorCode;
|
|
40
|
-
return res.sendError( { error: error }, code );
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const reauditImg = await getReauditImg( filterData, auditImageAC );
|
|
44
|
-
|
|
45
|
-
logger.info( { filterData: filterData } );
|
|
46
|
-
logger.info( { auditImageAC: auditImageAC } );
|
|
47
|
-
logger.info( { reauditImg: reauditImg } );
|
|
48
|
-
if ( inputData.export==true ) {
|
|
49
|
-
auditImageDownload= await zipDownloadImage( reauditImg );
|
|
50
|
-
// Set response headers for the zip file
|
|
51
|
-
res.set( 'Content-Type', 'application/zip' );
|
|
52
|
-
res.set( 'Content-Disposition', `attachment; filename=${inputData.storeId}_${inputData.fileDate}_${inputData.imageType}.zip` );
|
|
53
|
-
|
|
54
|
-
// Send the zip file as the API response
|
|
55
|
-
return res.send( auditImageDownload );
|
|
56
|
-
}
|
|
57
|
-
res.sendSuccess( { result: reauditImg } );
|
|
58
|
-
break;
|
|
59
|
-
default:
|
|
60
|
-
res.sendError( 'No Data Found', 204 );
|
|
61
|
-
break;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
// return res.sendSuccess( { result: inputData } );
|
|
66
|
-
} catch ( error ) {
|
|
67
|
-
const err = error.message || 'Internal Server Error';
|
|
68
|
-
logger.info( { error: error, message: req.body, function: 'beforeCountImages' } );
|
|
69
|
-
return res.sendError( err, 500 );
|
|
70
|
-
}
|
|
71
|
-
}
|