tango-app-api-report 3.0.12-dev → 3.0.14-dev
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,4 +1,4 @@
|
|
|
1
|
-
import { findOneReport, findReport, reportCreate, reportGet, reportGetSingle, reportUpdate } from '../service/report.service.js';
|
|
1
|
+
import { deleteOneReport, findOneReport, findReport, reportCreate, reportGet, reportGetSingle, reportUpdate } from '../service/report.service.js';
|
|
2
2
|
import { appConfig, fileUpload, getObject, getOpenSearchData, insertOpenSearchData, listFileByPath, logger, sendMessageToQueue } from 'tango-app-api-middleware';
|
|
3
3
|
import { findOneUser, getUserNameEmailById } from '../service/user.service.js';
|
|
4
4
|
import { updateOneBasePriceModel } from '../service/basePrice.service.js';
|
|
@@ -107,6 +107,16 @@ export async function updateReport( req, res ) {
|
|
|
107
107
|
}
|
|
108
108
|
}
|
|
109
109
|
|
|
110
|
+
export async function deleteReport( req, res ) {
|
|
111
|
+
try {
|
|
112
|
+
const inputData = req.params;
|
|
113
|
+
await deleteOneReport( { _id: inputData.id } );
|
|
114
|
+
return res.sendSuccess( { result: 'Report has been deleted successfully' } );
|
|
115
|
+
} catch ( error ) {
|
|
116
|
+
return res.sendError( error, 500 );
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
110
120
|
export async function clientReportList( req, res ) {
|
|
111
121
|
try {
|
|
112
122
|
const inputData = req.body;
|
|
@@ -118,6 +128,7 @@ export async function clientReportList( req, res ) {
|
|
|
118
128
|
$match: {
|
|
119
129
|
$and: [
|
|
120
130
|
{ 'reportConfigs.report': { $eq: true } },
|
|
131
|
+
{ status: { $eq: 'active' } },
|
|
121
132
|
{ clientId: { $in: inputData.clientId } },
|
|
122
133
|
],
|
|
123
134
|
|
|
@@ -214,7 +225,7 @@ export async function generateReport( req, res ) {
|
|
|
214
225
|
QueueUrl: `${appConfig.cloud.aws.sqs.url}${appConfig.cloud.aws.sqs.generateReport}`,
|
|
215
226
|
MessageBody: JSON.stringify( {
|
|
216
227
|
file_date: inputData.fileDate,
|
|
217
|
-
client_name:
|
|
228
|
+
client_name: req.report?.reportConfigs?.reportName,
|
|
218
229
|
client_id: Number( inputData.clientId ),
|
|
219
230
|
message: 'good to trigger',
|
|
220
231
|
} ),
|
|
@@ -228,9 +239,9 @@ export async function generateReport( req, res ) {
|
|
|
228
239
|
logType: 'report',
|
|
229
240
|
logSubType: 'generateReport',
|
|
230
241
|
logData: {
|
|
231
|
-
clientName:
|
|
242
|
+
clientName: req.report?.clientName,
|
|
232
243
|
fileDate: inputData.fileDate,
|
|
233
|
-
reportName:
|
|
244
|
+
reportName: req.report?.reportConfigs?.reportName,
|
|
234
245
|
clientId: inputData.ClientId,
|
|
235
246
|
sqsMessageId: sqsQueue.MessageId,
|
|
236
247
|
},
|
|
@@ -271,7 +282,7 @@ export async function uploadManualReport( req, res ) {
|
|
|
271
282
|
logger.info( { files: req.files } );
|
|
272
283
|
const uploadDataParams = {
|
|
273
284
|
Bucket: appConfig.cloud.aws.bucket.reportBucket,
|
|
274
|
-
Key: `reports/${inputData.fileDate}/${
|
|
285
|
+
Key: `reports/${inputData.fileDate}/${req.report?.reportConfigs?.reportName}/`,
|
|
275
286
|
fileName: inputData.fileName,
|
|
276
287
|
body: req.files.files.data,
|
|
277
288
|
};
|
|
@@ -292,7 +303,7 @@ export async function uploadManualReport( req, res ) {
|
|
|
292
303
|
logSubType: 'uploadReport',
|
|
293
304
|
logData: {
|
|
294
305
|
fileDate: inputData.fileDate,
|
|
295
|
-
reportName:
|
|
306
|
+
reportName: req.report?.reportConfigs?.reportName,
|
|
296
307
|
clientId: data.clientId,
|
|
297
308
|
},
|
|
298
309
|
};
|
|
@@ -374,7 +385,7 @@ export async function sendReport( req, res ) {
|
|
|
374
385
|
for ( const data of getReportList ) {
|
|
375
386
|
const fetchData = {
|
|
376
387
|
Bucket: appConfig.cloud.aws.bucket.reportBucket,
|
|
377
|
-
Key: `reports/${inputData.fileDate}/${
|
|
388
|
+
Key: `reports/${inputData.fileDate}/${req.report?.reportConfigs?.reportName}/${inputData.fileDate}_${data.fileName}.${data.fileType}`,
|
|
378
389
|
};
|
|
379
390
|
reportName.push( `${inputData.fileDate}_${data.fileName}` );
|
|
380
391
|
name.push( `${data.fileName}` );
|
|
@@ -423,7 +434,7 @@ export async function sendReport( req, res ) {
|
|
|
423
434
|
QueueUrl: `${appConfig.cloud.aws.sqs.url}${appConfig.cloud.aws.sqs.sendReport}`,
|
|
424
435
|
MessageBody: JSON.stringify( {
|
|
425
436
|
file_date: inputData.fileDate,
|
|
426
|
-
client_name:
|
|
437
|
+
client_name: req.report?.reportConfigs?.reportName,
|
|
427
438
|
client_id: Number( inputData.clientId ),
|
|
428
439
|
file_name: regionalKey,
|
|
429
440
|
report_name: name,
|
|
@@ -440,7 +451,7 @@ export async function sendReport( req, res ) {
|
|
|
440
451
|
logSubType: 'sendReport',
|
|
441
452
|
logData: {
|
|
442
453
|
fileDate: inputData.fileDate,
|
|
443
|
-
reportName:
|
|
454
|
+
reportName: req.report?.reportConfigs?.reportName,
|
|
444
455
|
clientId: getReportList[0].clientId,
|
|
445
456
|
},
|
|
446
457
|
};
|
package/src/docs/report.docs.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import j2s from 'joi-to-swagger';
|
|
2
2
|
|
|
3
|
-
import { clientListTableSchema, downloadReportSchema, generateReportSchema, getReportListSchema, getReportLogSchema, sendReportSchema, uploadManualReportSchema, uploadManualReportSchema2 } from '../dtos/report.dtos.js';
|
|
3
|
+
import { clientListTableSchema, deleteReportSchemaParam, downloadReportSchema, generateReportSchema, getReportListSchema, getReportLogSchema, sendReportSchema, uploadManualReportSchema, uploadManualReportSchema2 } from '../dtos/report.dtos.js';
|
|
4
4
|
|
|
5
5
|
export const reportDocs = {
|
|
6
6
|
|
|
@@ -175,5 +175,29 @@ export const reportDocs = {
|
|
|
175
175
|
},
|
|
176
176
|
},
|
|
177
177
|
|
|
178
|
+
'/v3/report/delete-report/{id}': {
|
|
179
|
+
get: {
|
|
180
|
+
tags: [ 'Report' ],
|
|
181
|
+
description: 'delete report by _id',
|
|
182
|
+
operationId: 'delete-report/{id}',
|
|
183
|
+
parameters: [
|
|
184
|
+
{
|
|
185
|
+
in: 'path',
|
|
186
|
+
name: 'id',
|
|
187
|
+
required: true,
|
|
188
|
+
description: 'The _id of the report.',
|
|
189
|
+
scema: j2s( deleteReportSchemaParam ).swagger,
|
|
190
|
+
},
|
|
191
|
+
],
|
|
192
|
+
responses: {
|
|
193
|
+
200: { description: 'Success' },
|
|
194
|
+
401: { description: 'Unauthorized User' },
|
|
195
|
+
422: { description: 'Field Error' },
|
|
196
|
+
500: { description: 'Server Error' },
|
|
197
|
+
204: { description: 'Not Found' },
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
},
|
|
201
|
+
|
|
178
202
|
};
|
|
179
203
|
|
package/src/dtos/report.dtos.js
CHANGED
|
@@ -56,6 +56,15 @@ export const updateReportValid = {
|
|
|
56
56
|
|
|
57
57
|
};
|
|
58
58
|
|
|
59
|
+
export const deleteReportSchemaParam = joi.object( {
|
|
60
|
+
id: joi.string().required(),
|
|
61
|
+
} );
|
|
62
|
+
|
|
63
|
+
export const deleteReportValid = {
|
|
64
|
+
params: deleteReportSchemaParam,
|
|
65
|
+
|
|
66
|
+
};
|
|
67
|
+
|
|
59
68
|
|
|
60
69
|
export const clientListTableSchema = joi.object( {
|
|
61
70
|
fromDate: joi.string().required(),
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
|
|
2
2
|
import express from 'express';
|
|
3
3
|
import { authorize, isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
|
|
4
|
-
import { addReportValid, clientListTableValid, downloadReportValid, generateReportValid, getReportListValid, getReportLogValid, getReportValid, getSingleReportValid, sendReportValid, updateReportValid } from '../dtos/report.dtos.js';
|
|
5
|
-
import { clientReportList, createReport, dowloadReport, generateReport, getReport, getReportList, getReportLog, getSingleReport, sendReport, updateBasePrice, updateReport, uploadManualReport } from '../controllers/report.controllers.js';
|
|
4
|
+
import { addReportValid, clientListTableValid, deleteReportValid, downloadReportValid, generateReportValid, getReportListValid, getReportLogValid, getReportValid, getSingleReportValid, sendReportValid, updateReportValid } from '../dtos/report.dtos.js';
|
|
5
|
+
import { clientReportList, createReport, deleteReport, dowloadReport, generateReport, getReport, getReportList, getReportLog, getSingleReport, sendReport, updateBasePrice, updateReport, uploadManualReport } from '../controllers/report.controllers.js';
|
|
6
6
|
import { isFileExist, isFolderExist, isReportEnable } from '../validations/report.validations.js';
|
|
7
7
|
|
|
8
8
|
export const reportRouter = express.Router();
|
|
@@ -21,6 +21,10 @@ reportRouter.put( '/update-report/:id', isAllowedSessionHandler, authorize( { us
|
|
|
21
21
|
{ featureName: 'settings', name: 'configuration', permissions: [ 'isEdit' ] },
|
|
22
22
|
] } ), validate( updateReportValid ), updateReport );
|
|
23
23
|
|
|
24
|
+
reportRouter.get( '/delete-report/:id', isAllowedSessionHandler, authorize( { userType: [ 'tango' ], access: [
|
|
25
|
+
{ featureName: 'settings', name: 'configuration', permissions: [ 'isEdit' ] },
|
|
26
|
+
] } ), validate( deleteReportValid ), deleteReport );
|
|
27
|
+
|
|
24
28
|
|
|
25
29
|
// admin report's overview
|
|
26
30
|
reportRouter.post( '/client-list-table', isAllowedSessionHandler,
|
|
@@ -5,7 +5,7 @@ import { findOneClient } from '../service/client.service.js';
|
|
|
5
5
|
export async function isReportEnable( req, res, next ) {
|
|
6
6
|
try {
|
|
7
7
|
const inputData = req.method !== 'GET'? req.body: req.query;
|
|
8
|
-
const getReportName = await findOneClient( { 'clientId': inputData.clientId, 'reportConfigs.report': true }, { '_id': 0, 'reportConfigs.reportName': 1, 'clientName': 1 } );
|
|
8
|
+
const getReportName = await findOneClient( { 'clientId': inputData.clientId, 'status': 'active', 'reportConfigs.report': true }, { '_id': 0, 'reportConfigs.reportName': 1, 'clientName': 1 } );
|
|
9
9
|
if ( !getReportName ) {
|
|
10
10
|
return res.sendError( 'reportName is not there in the client', 204 );
|
|
11
11
|
}
|