tango-app-api-audit 3.5.20 → 3.5.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
|
@@ -7,6 +7,7 @@ import timezone from 'dayjs/plugin/timezone.js';
|
|
|
7
7
|
import 'dayjs/locale/en.js';
|
|
8
8
|
import { findOneEyeTestConfig, updateOneEyeTestConfig } from '../service/eyeTestConfiguration.service.js';
|
|
9
9
|
import { ObjectId } from 'mongodb';
|
|
10
|
+
import { aggregateClusters } from '../service/clusters.service.js';
|
|
10
11
|
|
|
11
12
|
dayjs.extend( utc );
|
|
12
13
|
dayjs.extend( timezone );
|
|
@@ -1598,9 +1599,12 @@ export async function getUserConfig( req, res ) {
|
|
|
1598
1599
|
configureType: 'user',
|
|
1599
1600
|
|
|
1600
1601
|
};
|
|
1601
|
-
const getOne = await findOneEyeTestConfig( query, { userList: 1 } );
|
|
1602
|
+
const getOne = await findOneEyeTestConfig( query, { userList: 1, _id: 1 } );
|
|
1603
|
+
if ( !getOne ) {
|
|
1604
|
+
return res.sendError( ' No data found', 204 );
|
|
1605
|
+
}
|
|
1602
1606
|
logger.info( { getOne: getOne, message: 'getUserConfig' } );
|
|
1603
|
-
return res.sendSuccess( { result: getOne
|
|
1607
|
+
return res.sendSuccess( { result: getOne || [] } );
|
|
1604
1608
|
} catch ( error ) {
|
|
1605
1609
|
const err = error.message || 'Internal Server Error';
|
|
1606
1610
|
logger.error( { message: error, data: req.body, function: 'eyetestAudit-controller-getUserConfig' } );
|
|
@@ -1666,6 +1670,50 @@ export async function updateUserConfig( req, res ) {
|
|
|
1666
1670
|
}
|
|
1667
1671
|
}
|
|
1668
1672
|
|
|
1673
|
+
export async function clusterList( req, res ) {
|
|
1674
|
+
try {
|
|
1675
|
+
const inputData = req.body;
|
|
1676
|
+
inputData.clientId = req?.user?.userType == 'tango' ? inputData.clientId : req?.user?.clientId;
|
|
1677
|
+
const query = [
|
|
1678
|
+
|
|
1679
|
+
{
|
|
1680
|
+
$match: {
|
|
1681
|
+
$and: [
|
|
1682
|
+
{
|
|
1683
|
+
clientId: { $eq: inputData?.clientId },
|
|
1684
|
+
},
|
|
1685
|
+
{
|
|
1686
|
+
'Teamlead.email': { $in: inputData?.rmList },
|
|
1687
|
+
},
|
|
1688
|
+
|
|
1689
|
+
],
|
|
1690
|
+
},
|
|
1691
|
+
},
|
|
1692
|
+
{
|
|
1693
|
+
$group: {
|
|
1694
|
+
_id: null,
|
|
1695
|
+
clientId: { $first: '$clientId' },
|
|
1696
|
+
clusterList: { $addToSet: '$clusterName' },
|
|
1697
|
+
},
|
|
1698
|
+
},
|
|
1699
|
+
{
|
|
1700
|
+
$project: {
|
|
1701
|
+
_id: 0,
|
|
1702
|
+
clientId: 1,
|
|
1703
|
+
clusterList: 1,
|
|
1704
|
+
},
|
|
1705
|
+
},
|
|
1706
|
+
];
|
|
1707
|
+
const getClusterList = await aggregateClusters( query );
|
|
1708
|
+
logger.info( { getClusterList: getClusterList, query: query } );
|
|
1709
|
+
return res.sendSuccess( { result: getClusterList || [] } );
|
|
1710
|
+
} catch ( error ) {
|
|
1711
|
+
const err = error.message || 'Internal Server Error';
|
|
1712
|
+
logger.error( { message: error, data: req.body, function: 'eyetestAudit-controller-clusterList' } );
|
|
1713
|
+
return res.sendError( err, 500 );
|
|
1714
|
+
}
|
|
1715
|
+
}
|
|
1716
|
+
|
|
1669
1717
|
export async function rmList( req, res ) {
|
|
1670
1718
|
try {
|
|
1671
1719
|
const inputData = req.query;
|
|
@@ -1674,7 +1722,6 @@ export async function rmList( req, res ) {
|
|
|
1674
1722
|
configureType: 'user',
|
|
1675
1723
|
};
|
|
1676
1724
|
const getRMList = await findOneEyeTestConfig( query, { userList: 1 } );
|
|
1677
|
-
logger.info( { getRMList: getRMList } );
|
|
1678
1725
|
return res.sendSuccess( { result: getRMList?.userList || [] } );
|
|
1679
1726
|
} catch ( error ) {
|
|
1680
1727
|
const err = error.message || 'Internal Server Error';
|
|
@@ -1692,12 +1739,15 @@ export async function getEmailConfig( req, res ) {
|
|
|
1692
1739
|
clientId: clientId,
|
|
1693
1740
|
configureType: 'email',
|
|
1694
1741
|
};
|
|
1695
|
-
const getOne = await findOneEyeTestConfig( query, { complianceThreshold: 1 } );
|
|
1742
|
+
const getOne = await findOneEyeTestConfig( query, { complianceThreshold: 1, _id: 1 } );
|
|
1696
1743
|
logger.info( { getOne: getOne, message: 'getEmailConfig' } );
|
|
1697
1744
|
// if ( !getOne?.complianceThreshold ) {
|
|
1698
1745
|
// return res.sendError( 'No data found', 204 );
|
|
1699
1746
|
// }
|
|
1700
|
-
|
|
1747
|
+
if ( !getOne ) {
|
|
1748
|
+
return res.sendError( ' No data found', 204 );
|
|
1749
|
+
}
|
|
1750
|
+
return res.sendSuccess( { result: getOne } );
|
|
1701
1751
|
} catch ( error ) {
|
|
1702
1752
|
const err = error.message || 'Internal Server Error';
|
|
1703
1753
|
logger.error( { message: error, data: req.body, function: 'eyetestAudit-controller-getEmailConfig' } );
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import j2s from 'joi-to-swagger';
|
|
2
|
-
import { getListSchema, getFileSchema, getFileHistorySchema, userAuditedDataSchema, viewFileSchema, saveSchema, cancelSchema, summaryCardSchema, getUserConfigSchema, rmListSchema, updateUserConfigParamsSchema, updateUserConfigSchema, updateEmailConfigParamaSchema, updateEmailConfigSchema, getEmailConfigSchema, summaryListSchema, emailAlertLogSchema } from '../dtos/eyeTestAudit.dtos.js';
|
|
2
|
+
import { getListSchema, getFileSchema, getFileHistorySchema, userAuditedDataSchema, viewFileSchema, saveSchema, cancelSchema, summaryCardSchema, getUserConfigSchema, rmListSchema, updateUserConfigParamsSchema, updateUserConfigSchema, updateEmailConfigParamaSchema, updateEmailConfigSchema, getEmailConfigSchema, summaryListSchema, emailAlertLogSchema, clusterSchema } from '../dtos/eyeTestAudit.dtos.js';
|
|
3
3
|
|
|
4
4
|
export const eyeTestAuditDocs = {
|
|
5
5
|
|
|
@@ -270,6 +270,28 @@ export const eyeTestAuditDocs = {
|
|
|
270
270
|
},
|
|
271
271
|
},
|
|
272
272
|
|
|
273
|
+
'/v3/eye-test-audit/cluster-list': {
|
|
274
|
+
post: {
|
|
275
|
+
tags: [ 'Eye Test Audit' ],
|
|
276
|
+
description: 'get cluster likt filter by client an RM',
|
|
277
|
+
operationId: 'cluster-list',
|
|
278
|
+
requestBody: {
|
|
279
|
+
content: {
|
|
280
|
+
'application/json': {
|
|
281
|
+
schema: j2s( clusterSchema ).swagger,
|
|
282
|
+
},
|
|
283
|
+
},
|
|
284
|
+
},
|
|
285
|
+
responses: {
|
|
286
|
+
200: { description: 'Successful' },
|
|
287
|
+
401: { description: 'Unauthorized User' },
|
|
288
|
+
422: { description: 'Field Error' },
|
|
289
|
+
500: { description: 'Server Error' },
|
|
290
|
+
204: { description: 'Not Found' },
|
|
291
|
+
},
|
|
292
|
+
},
|
|
293
|
+
},
|
|
294
|
+
|
|
273
295
|
'/v3/eye-test-audit/update-user-config': {
|
|
274
296
|
put: {
|
|
275
297
|
tags: [ 'Eye Test Audit' ],
|
|
@@ -319,6 +319,22 @@ export const rmListValid = {
|
|
|
319
319
|
query: rmListSchema,
|
|
320
320
|
};
|
|
321
321
|
|
|
322
|
+
export const clusterSchema = joi.object( {
|
|
323
|
+
clientId: joi.string().when( '$userType', {
|
|
324
|
+
is: 'tango',
|
|
325
|
+
then: joi.required().messages( {
|
|
326
|
+
'any.required': 'clientId is required',
|
|
327
|
+
'string.base': 'clientId must be a string',
|
|
328
|
+
} ),
|
|
329
|
+
otherwise: joi.optional(),
|
|
330
|
+
} ),
|
|
331
|
+
rmList: joi.array().items( joi.string().optional() ).optional(),
|
|
332
|
+
} );
|
|
333
|
+
|
|
334
|
+
export const clusterListValid = {
|
|
335
|
+
body: clusterSchema,
|
|
336
|
+
};
|
|
337
|
+
|
|
322
338
|
export const updateUserConfigSchema = joi.object( {
|
|
323
339
|
clientId: joi.string().when( '$userType', {
|
|
324
340
|
is: 'tango',
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Router } from 'express';
|
|
2
2
|
import { isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
|
|
3
3
|
import { accessVerification } from 'tango-app-api-middleware';
|
|
4
|
-
import { cancelValid, emailAlertLogValid, getEmailConfigValid, getFileHistoryValid, getFileValid, getListValid, getUserConfigValid, rmListValid, saveValid, summaryCardValid, summaryListValid, updateEmailConfigValid, updateUserConfigValid, userAuditedDataValid, viewFileValid } from '../dtos/eyeTestAudit.dtos.js';
|
|
5
|
-
import { addUserConfig, cancel, emailAlertLog, getEmailConfig, getFile, getFileHistory, getList, getUserConfig, rmList, save, summaryCard, summaryList, updateEmailConfig, updateEmailConfig1, updateUserConfig, userAuditedData, viewFile } from '../controllers/eyeTestAudit.controllers.js';
|
|
4
|
+
import { cancelValid, clusterListValid, emailAlertLogValid, getEmailConfigValid, getFileHistoryValid, getFileValid, getListValid, getUserConfigValid, rmListValid, saveValid, summaryCardValid, summaryListValid, updateEmailConfigValid, updateUserConfigValid, userAuditedDataValid, viewFileValid } from '../dtos/eyeTestAudit.dtos.js';
|
|
5
|
+
import { addUserConfig, cancel, clusterList, emailAlertLog, getEmailConfig, getFile, getFileHistory, getList, getUserConfig, rmList, save, summaryCard, summaryList, updateEmailConfig, updateEmailConfig1, updateUserConfig, userAuditedData, viewFile } from '../controllers/eyeTestAudit.controllers.js';
|
|
6
6
|
import { isSuperAdmin, roleValidation } from '../validation/eyeTest.validation.js';
|
|
7
7
|
|
|
8
8
|
export const eyeTestAuditRouter = Router();
|
|
@@ -21,11 +21,14 @@ eyeTestAuditRouter.post( '/summary-list', isAllowedSessionHandler, accessVerific
|
|
|
21
21
|
eyeTestAuditRouter.post( '/summary-card', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( summaryCardValid ), summaryCard );
|
|
22
22
|
eyeTestAuditRouter.post( '/email-alert-log', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), isSuperAdmin, validate( emailAlertLogValid ), emailAlertLog );
|
|
23
23
|
|
|
24
|
+
eyeTestAuditRouter.post( '/cluster-list', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), isSuperAdmin, validate( clusterListValid ), clusterList );
|
|
25
|
+
eyeTestAuditRouter.get( '/rm-list', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), isSuperAdmin, validate( rmListValid ), rmList );
|
|
26
|
+
|
|
27
|
+
|
|
24
28
|
// setting
|
|
25
29
|
eyeTestAuditRouter.get( '/get-user-config', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( getUserConfigValid ), getUserConfig );
|
|
26
30
|
eyeTestAuditRouter.put( '/update-user-config', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), isSuperAdmin, validate( updateUserConfigValid ), addUserConfig, updateUserConfig );
|
|
27
31
|
|
|
28
|
-
eyeTestAuditRouter.get( '/rm-list', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), isSuperAdmin, validate( rmListValid ), rmList );
|
|
29
32
|
eyeTestAuditRouter.get( '/get-email-config', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), isSuperAdmin, validate( getEmailConfigValid ), getEmailConfig );
|
|
30
33
|
eyeTestAuditRouter.put( '/update-email-config', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( updateEmailConfigValid ), updateEmailConfig );
|
|
31
34
|
|
|
@@ -1,6 +1,10 @@
|
|
|
1
|
-
import clusterModel from 'tango-api-schema/schema/cluster.model';
|
|
1
|
+
import clusterModel from 'tango-api-schema/schema/cluster.model.js';
|
|
2
2
|
|
|
3
3
|
|
|
4
4
|
export function aggregateClusters( query ) {
|
|
5
5
|
return clusterModel.aggregate( query, { collation: { locale: 'en', strength: 2 } } );
|
|
6
6
|
}
|
|
7
|
+
|
|
8
|
+
export function findClusters( query ) {
|
|
9
|
+
return clusterModel.find( query, field );
|
|
10
|
+
}
|