tango-app-api-audit 3.6.20 → 3.6.22
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.6.
|
|
3
|
+
"version": "3.6.22",
|
|
4
4
|
"description": "audit & audit metrics apis",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -13,6 +13,7 @@
|
|
|
13
13
|
"author": "praveenraj",
|
|
14
14
|
"license": "ISC",
|
|
15
15
|
"dependencies": {
|
|
16
|
+
"@aws-sdk/client-ses": "^3.918.0",
|
|
16
17
|
"adm-zip": "^0.5.15",
|
|
17
18
|
"aws-sdk": "^2.1643.0",
|
|
18
19
|
"axios": "^1.7.9",
|
|
@@ -24,6 +25,7 @@
|
|
|
24
25
|
"joi-to-swagger": "^6.2.0",
|
|
25
26
|
"lodash": "^4.17.21",
|
|
26
27
|
"mongodb": "^6.7.0",
|
|
28
|
+
"nodemailer": "^7.0.10",
|
|
27
29
|
"nodemon": "^3.1.3",
|
|
28
30
|
"swagger-ui-express": "^5.0.1",
|
|
29
31
|
"tango-api-schema": "^2.3.28",
|
|
@@ -637,6 +637,9 @@ export async function getAuditFile( req, res ) {
|
|
|
637
637
|
'minimum_should_match': 1,
|
|
638
638
|
},
|
|
639
639
|
},
|
|
640
|
+
sort: [
|
|
641
|
+
{ timestamp: { order: 'desc' } },
|
|
642
|
+
],
|
|
640
643
|
|
|
641
644
|
}:
|
|
642
645
|
{
|
|
@@ -664,6 +667,9 @@ export async function getAuditFile( req, res ) {
|
|
|
664
667
|
],
|
|
665
668
|
},
|
|
666
669
|
},
|
|
670
|
+
sort: [
|
|
671
|
+
{ timestamp: { order: 'desc' } },
|
|
672
|
+
],
|
|
667
673
|
|
|
668
674
|
};
|
|
669
675
|
logger.info( { fetchData: fetchData, msg: msg, inputData: inputData, type: 'debug-bucketNameIssue' } );
|
|
@@ -847,6 +853,7 @@ export async function getAuditFile( req, res ) {
|
|
|
847
853
|
storeId: storeId,
|
|
848
854
|
storeName: storeInfo?.storeName,
|
|
849
855
|
address: storeInfo?.address,
|
|
856
|
+
folderPath: folderPath,
|
|
850
857
|
file: {
|
|
851
858
|
queueName: inputData.queueName,
|
|
852
859
|
store_id: storeId,
|
|
@@ -4507,6 +4514,9 @@ export async function auditImages( req, res ) {
|
|
|
4507
4514
|
},
|
|
4508
4515
|
},
|
|
4509
4516
|
|
|
4517
|
+
sort: [
|
|
4518
|
+
{ timestamp: { order: 'desc' } },
|
|
4519
|
+
],
|
|
4510
4520
|
};
|
|
4511
4521
|
const files = [];
|
|
4512
4522
|
const list = await searchOpenSearchData( openSearch.trackerInput, getQuery );
|
|
@@ -4583,6 +4593,9 @@ export async function auditImages( req, res ) {
|
|
|
4583
4593
|
'minimum_should_match': 1,
|
|
4584
4594
|
},
|
|
4585
4595
|
},
|
|
4596
|
+
sort: [
|
|
4597
|
+
{ timestamp: { order: 'desc' } },
|
|
4598
|
+
],
|
|
4586
4599
|
|
|
4587
4600
|
};
|
|
4588
4601
|
const filesAC = [];
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getOpenSearchById, logger } from 'tango-app-api-middleware';
|
|
2
|
+
import { SESClient, SendEmailCommand } from '@aws-sdk/client-ses';
|
|
2
3
|
|
|
3
4
|
export async function roleValidation( req, res, next ) {
|
|
4
5
|
try {
|
|
@@ -62,3 +63,95 @@ export async function sendAlert( req, res, next ) {
|
|
|
62
63
|
}
|
|
63
64
|
}
|
|
64
65
|
|
|
66
|
+
/**
|
|
67
|
+
* Send HTML Email using AWS SES
|
|
68
|
+
* @param {Object} params
|
|
69
|
+
* @param {string} params.toEmail - Recipient email address
|
|
70
|
+
* @param {string} params.userName - Recipient name
|
|
71
|
+
* @param {number} params.compliancePercentage - Compliance score
|
|
72
|
+
*/
|
|
73
|
+
export async function sendComplianceEmail( {
|
|
74
|
+
toEmail,
|
|
75
|
+
fromEmail, // sender email added here
|
|
76
|
+
userName,
|
|
77
|
+
compliancePercentage,
|
|
78
|
+
} ) {
|
|
79
|
+
// Initialize AWS SES client
|
|
80
|
+
const sesClient = new SESClient( {
|
|
81
|
+
region: 'ap-south-1', // Change to your AWS region
|
|
82
|
+
credentials: {
|
|
83
|
+
accessKeyId: process.env.AWS_ACCESS_KEY_ID,
|
|
84
|
+
secretAccessKey: process.env.AWS_SECRET_ACCESS_KEY,
|
|
85
|
+
},
|
|
86
|
+
} );
|
|
87
|
+
const htmlBody = `
|
|
88
|
+
<!DOCTYPE html>
|
|
89
|
+
<html>
|
|
90
|
+
<head>
|
|
91
|
+
<meta charset="UTF-8" />
|
|
92
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
93
|
+
<title>Non Compliance Report</title>
|
|
94
|
+
<style>
|
|
95
|
+
body { font-family: 'Inter', sans-serif; margin: 0; padding: 24px; background: #f9fafb; color: #121a26; }
|
|
96
|
+
.container { max-width: 700px; background: #fff; padding: 24px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,0.1); }
|
|
97
|
+
.title { font-size: 24px; font-weight: 700; color: #121a26; }
|
|
98
|
+
.subtitle { font-size: 16px; color: #384860; line-height: 1.5; margin-top: 8px; }
|
|
99
|
+
.table { width: 100%; border-collapse: collapse; margin-top: 16px; }
|
|
100
|
+
.table th, .table td { text-align: left; padding: 12px 16px; border-bottom: 1px solid #eaeef0; color: #667085; }
|
|
101
|
+
.footer { margin-top: 32px; font-size: 14px; color: #384860; }
|
|
102
|
+
.compliance { font-size: 18px; font-weight: 700; color: #f04438; margin-top: 16px; }
|
|
103
|
+
</style>
|
|
104
|
+
</head>
|
|
105
|
+
<body>
|
|
106
|
+
<div class="container">
|
|
107
|
+
<p class="title">Non Compliance on Eye Test Procedures</p>
|
|
108
|
+
<p class="subtitle">
|
|
109
|
+
Dear ${userName},<br><br>
|
|
110
|
+
Please ensure that all conducted eye tests meet the required compliance standards.<br>
|
|
111
|
+
Your prompt attention to this matter will help us maintain the highest standards and avoid any discrepancies.<br>
|
|
112
|
+
Please take a look at the below findings.
|
|
113
|
+
</p>
|
|
114
|
+
|
|
115
|
+
<table class="table">
|
|
116
|
+
<thead>
|
|
117
|
+
<tr>
|
|
118
|
+
<th>RM Name</th>
|
|
119
|
+
<th>Comments</th>
|
|
120
|
+
</tr>
|
|
121
|
+
</thead>
|
|
122
|
+
<tbody>
|
|
123
|
+
<tr><td>JCC (Jackson Cross Cylinder)</td><td>Lorem ipsum dolor sit amet consectetur.</td></tr>
|
|
124
|
+
<tr><td>DuoChrome Test</td><td>Lorem ipsum dolor sit amet consectetur.</td></tr>
|
|
125
|
+
<tr><td>Prescription Verification</td><td>Lorem ipsum dolor sit amet consectetur.</td></tr>
|
|
126
|
+
<tr><td>Distance-VA-Check</td><td>Lorem ipsum dolor sit amet consectetur.</td></tr>
|
|
127
|
+
</tbody>
|
|
128
|
+
</table>
|
|
129
|
+
|
|
130
|
+
<p class="compliance">Compliance Percentage: ${compliancePercentage}%</p>
|
|
131
|
+
<p class="footer">Regards,<br>Team Tango</p>
|
|
132
|
+
</div>
|
|
133
|
+
</body>
|
|
134
|
+
</html>`;
|
|
135
|
+
|
|
136
|
+
const params = {
|
|
137
|
+
Source: fromEmail, // sender email (must be verified in SES)
|
|
138
|
+
Destination: {
|
|
139
|
+
ToAddresses: [ toEmail ],
|
|
140
|
+
},
|
|
141
|
+
Message: {
|
|
142
|
+
Subject: { Data: 'Non Compliance on Eye Test Procedures' },
|
|
143
|
+
Body: { Html: { Data: htmlBody } },
|
|
144
|
+
},
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
try {
|
|
148
|
+
const response = await sesClient.send( new SendEmailCommand( params ) );
|
|
149
|
+
// console.log( 'Email sent successfully:', response.MessageId );
|
|
150
|
+
return response;
|
|
151
|
+
} catch ( error ) {
|
|
152
|
+
// console.error( 'Error sending email:', error );
|
|
153
|
+
throw error;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
|