tango-app-api-report 3.3.6 → 3.3.7

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-report",
3
- "version": "3.3.6",
3
+ "version": "3.3.7",
4
4
  "description": "report",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -91,7 +91,7 @@ export async function updateReport( req, res ) {
91
91
  date: new Date(),
92
92
  logType: 'configuration',
93
93
  logSubType: 'reportConfig',
94
- changes: [ `Report id ${req.params?.id}` ],
94
+ changes: [ `The Report ${previousReport.fileName}.${previousReport.fileType}` ],
95
95
  eventType: 'update',
96
96
  showTo: [ 'tango' ],
97
97
  current: req.body,
@@ -112,7 +112,27 @@ export async function updateReport( req, res ) {
112
112
  export async function deleteReport( req, res ) {
113
113
  try {
114
114
  const inputData = req.params;
115
+ const previousReport = await reportGetSingle( {
116
+ _id: inputData?.id,
117
+ } );
115
118
  await deleteOneReport( { _id: inputData.id } );
119
+ const logObj = {
120
+ clientId: req.body?.clientId,
121
+ userName: user?.userName,
122
+ email: user?.email,
123
+ date: new Date(),
124
+ logType: 'configuration',
125
+ logSubType: 'reportConfig',
126
+ changes: [ `The Report ${previousReport.fileName}.${previousReport.fileType} has been deleted` ],
127
+ eventType: 'delete',
128
+ showTo: [ 'tango' ],
129
+ current: req.body,
130
+ previous: previousReport,
131
+
132
+ };
133
+
134
+
135
+ await insertOpenSearchData( openSearch.activityLog, logObj );
116
136
  return res.sendSuccess( { result: 'Report has been deleted successfully' } );
117
137
  } catch ( error ) {
118
138
  return res.sendError( error, 500 );
@@ -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' ],
@@ -26,7 +26,7 @@ export function reportGet( { clientId } ) {
26
26
  export function reportGetSingle( { _id } ) {
27
27
  return reportModel.findOne( {
28
28
  _id: new mongoose.Types.ObjectId( _id ),
29
- },
29
+ }, { _id: 0 },
30
30
  );
31
31
  }
32
32