tango-app-api-report 3.3.5 → 3.3.7-beta.0
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
|
@@ -81,6 +81,9 @@ export async function updateReport( req, res ) {
|
|
|
81
81
|
const updateAck = await reportUpdate( {
|
|
82
82
|
_id: req.params?.id, fileType: req.body?.fileType, email: req.body?.email, clientId: req.body?.clientId,
|
|
83
83
|
} );
|
|
84
|
+
const postReport = await reportGetSingle( {
|
|
85
|
+
_id: req.params?.id,
|
|
86
|
+
} );
|
|
84
87
|
|
|
85
88
|
const user = await getUserNameEmailById( req.userId );
|
|
86
89
|
|
|
@@ -91,10 +94,10 @@ export async function updateReport( req, res ) {
|
|
|
91
94
|
date: new Date(),
|
|
92
95
|
logType: 'configuration',
|
|
93
96
|
logSubType: 'reportConfig',
|
|
94
|
-
changes: [ `Report
|
|
97
|
+
changes: [ `The Report ${previousReport.fileName}.${previousReport.fileType}` ],
|
|
95
98
|
eventType: 'update',
|
|
96
99
|
showTo: [ 'tango' ],
|
|
97
|
-
current:
|
|
100
|
+
current: postReport,
|
|
98
101
|
previous: previousReport,
|
|
99
102
|
|
|
100
103
|
};
|
|
@@ -112,10 +115,37 @@ export async function updateReport( req, res ) {
|
|
|
112
115
|
export async function deleteReport( req, res ) {
|
|
113
116
|
try {
|
|
114
117
|
const inputData = req.params;
|
|
118
|
+
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
119
|
+
const previousReport = await reportGetSingle( {
|
|
120
|
+
_id: inputData?.id,
|
|
121
|
+
} );
|
|
122
|
+
|
|
115
123
|
await deleteOneReport( { _id: inputData.id } );
|
|
124
|
+
const postReport = await reportGetSingle( {
|
|
125
|
+
_id: req.params?.id,
|
|
126
|
+
} );
|
|
127
|
+
const logObj = {
|
|
128
|
+
clientId: req?.body?.clientId,
|
|
129
|
+
userName: req?.user?.userName,
|
|
130
|
+
email: req?.user?.email,
|
|
131
|
+
date: new Date(),
|
|
132
|
+
logType: 'configuration',
|
|
133
|
+
logSubType: 'reportConfig',
|
|
134
|
+
changes: [ `The Report ${previousReport.fileName}.${previousReport.fileType} has been deleted` ],
|
|
135
|
+
eventType: 'delete',
|
|
136
|
+
showTo: [ 'tango' ],
|
|
137
|
+
current: postReport,
|
|
138
|
+
previous: previousReport,
|
|
139
|
+
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
|
|
143
|
+
await insertOpenSearchData( openSearch.activityLog, logObj );
|
|
116
144
|
return res.sendSuccess( { result: 'Report has been deleted successfully' } );
|
|
117
145
|
} catch ( error ) {
|
|
118
|
-
|
|
146
|
+
const err = error.message || 'Internal Server Error';
|
|
147
|
+
logger.error( { message: error, data: req.params, function: 'deleteReport' } );
|
|
148
|
+
return res.sendError( err, 500 );
|
|
119
149
|
}
|
|
120
150
|
}
|
|
121
151
|
|
package/src/docs/report.docs.js
CHANGED
|
@@ -1,9 +1,40 @@
|
|
|
1
1
|
import j2s from 'joi-to-swagger';
|
|
2
2
|
|
|
3
|
-
import { clientListTableSchema, deleteReportSchemaParam, downloadReportSchema, generateReportSchema, getReportListSchema, getReportLogSchema, getReportSchemaParam, sendReportSchema, uploadManualReportSchema, uploadManualReportSchema2 } from '../dtos/report.dtos.js';
|
|
3
|
+
import { addReportSchemaBody, addReportSchemaParam, clientListTableSchema, deleteReportSchemaParam, downloadReportSchema, generateReportSchema, getReportListSchema, getReportLogSchema, getReportSchemaParam, sendReportSchema, updateReportSchemaBody, updateReportSchemaParam, uploadManualReportSchema, uploadManualReportSchema2 } from '../dtos/report.dtos.js';
|
|
4
4
|
|
|
5
5
|
export const reportDocs = {
|
|
6
6
|
|
|
7
|
+
'/v3/report/create-report/{id}': {
|
|
8
|
+
post: {
|
|
9
|
+
tags: [ 'Report' ],
|
|
10
|
+
description: `Create a report`,
|
|
11
|
+
operationId: 'create-repor',
|
|
12
|
+
parameters: [
|
|
13
|
+
{
|
|
14
|
+
in: 'path',
|
|
15
|
+
name: 'id',
|
|
16
|
+
required: true,
|
|
17
|
+
description: 'The ID of the report',
|
|
18
|
+
scema: j2s( addReportSchemaParam ).swagger,
|
|
19
|
+
},
|
|
20
|
+
],
|
|
21
|
+
requestBody: {
|
|
22
|
+
content: {
|
|
23
|
+
'application/json': {
|
|
24
|
+
schema: j2s( addReportSchemaBody ).swagger,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
responses: {
|
|
29
|
+
200: { description: 'Report has been Created Successfully' },
|
|
30
|
+
401: { description: 'Unauthorized User' },
|
|
31
|
+
422: { description: 'Field Error' },
|
|
32
|
+
500: { description: 'Server Error' },
|
|
33
|
+
204: { description: 'Not Found' },
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
},
|
|
37
|
+
|
|
7
38
|
'/v3/report/client-list-table': {
|
|
8
39
|
post: {
|
|
9
40
|
tags: [ 'Report' ],
|
|
@@ -27,7 +58,6 @@ export const reportDocs = {
|
|
|
27
58
|
},
|
|
28
59
|
},
|
|
29
60
|
|
|
30
|
-
|
|
31
61
|
'/v3/report/generate-report': {
|
|
32
62
|
post: {
|
|
33
63
|
tags: [ 'Report' ],
|
|
@@ -106,6 +136,37 @@ export const reportDocs = {
|
|
|
106
136
|
},
|
|
107
137
|
},
|
|
108
138
|
|
|
139
|
+
'/v3/report/update-report/{id}': {
|
|
140
|
+
put: {
|
|
141
|
+
tags: [ 'Report' ],
|
|
142
|
+
description: `Update a report`,
|
|
143
|
+
operationId: 'update-report',
|
|
144
|
+
parameters: [
|
|
145
|
+
{
|
|
146
|
+
in: 'path',
|
|
147
|
+
name: 'id',
|
|
148
|
+
required: true,
|
|
149
|
+
description: 'The ID of the report',
|
|
150
|
+
scema: j2s( updateReportSchemaParam ).swagger,
|
|
151
|
+
},
|
|
152
|
+
],
|
|
153
|
+
requestBody: {
|
|
154
|
+
content: {
|
|
155
|
+
'application/json': {
|
|
156
|
+
schema: j2s( updateReportSchemaBody ).swagger,
|
|
157
|
+
},
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
responses: {
|
|
161
|
+
200: { description: 'Report has been Updated Successfully' },
|
|
162
|
+
401: { description: 'Unauthorized User' },
|
|
163
|
+
422: { description: 'Field Error' },
|
|
164
|
+
500: { description: 'Server Error' },
|
|
165
|
+
204: { description: 'Not Found' },
|
|
166
|
+
},
|
|
167
|
+
},
|
|
168
|
+
},
|
|
169
|
+
|
|
109
170
|
'/v3/report/download-report': {
|
|
110
171
|
get: {
|
|
111
172
|
tags: [ 'Report' ],
|
|
@@ -43,9 +43,7 @@ reportRouter.get( '/get-report-list', isAllowedSessionHandler,
|
|
|
43
43
|
validate( getReportListValid ), isFolderExist, getReportList );
|
|
44
44
|
|
|
45
45
|
reportRouter.get( '/download-report', isAllowedSessionHandler,
|
|
46
|
-
accessVerification( { userType: [ 'tango' ]
|
|
47
|
-
{ featureName: 'TangoAdmin', name: 'Reports', permissions: [ 'isEdit' ] },
|
|
48
|
-
] } ),
|
|
46
|
+
accessVerification( { userType: [ 'tango' ] } ),
|
|
49
47
|
validate( downloadReportValid ), isFileExist, dowloadReport );
|
|
50
48
|
|
|
51
49
|
reportRouter.post( '/send-report', isAllowedSessionHandler,
|