tango-app-api-audit 3.5.20 → 3.5.21
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 );
|
|
@@ -1666,6 +1667,50 @@ export async function updateUserConfig( req, res ) {
|
|
|
1666
1667
|
}
|
|
1667
1668
|
}
|
|
1668
1669
|
|
|
1670
|
+
export async function clusterList( req, res ) {
|
|
1671
|
+
try {
|
|
1672
|
+
const inputData = req.body;
|
|
1673
|
+
inputData.clientId = req?.user?.userType == 'tango' ? inputData.clientId : req?.user?.clientId;
|
|
1674
|
+
const query = [
|
|
1675
|
+
|
|
1676
|
+
{
|
|
1677
|
+
$match: {
|
|
1678
|
+
$and: [
|
|
1679
|
+
{
|
|
1680
|
+
clientId: { $eq: inputData?.clientId },
|
|
1681
|
+
},
|
|
1682
|
+
{
|
|
1683
|
+
'Teamlead.email': { $in: inputData?.rmList },
|
|
1684
|
+
},
|
|
1685
|
+
|
|
1686
|
+
],
|
|
1687
|
+
},
|
|
1688
|
+
},
|
|
1689
|
+
{
|
|
1690
|
+
$group: {
|
|
1691
|
+
_id: null,
|
|
1692
|
+
clientId: { $first: '$clientId' },
|
|
1693
|
+
clusterList: { $addToSet: '$clusterName' },
|
|
1694
|
+
},
|
|
1695
|
+
},
|
|
1696
|
+
{
|
|
1697
|
+
$project: {
|
|
1698
|
+
_id: 0,
|
|
1699
|
+
clientId: 1,
|
|
1700
|
+
clusterList: 1,
|
|
1701
|
+
},
|
|
1702
|
+
},
|
|
1703
|
+
];
|
|
1704
|
+
const getClusterList = await aggregateClusters( query );
|
|
1705
|
+
logger.info( { getClusterList: getClusterList, query: query } );
|
|
1706
|
+
return res.sendSuccess( { result: getClusterList || [] } );
|
|
1707
|
+
} catch ( error ) {
|
|
1708
|
+
const err = error.message || 'Internal Server Error';
|
|
1709
|
+
logger.error( { message: error, data: req.body, function: 'eyetestAudit-controller-clusterList' } );
|
|
1710
|
+
return res.sendError( err, 500 );
|
|
1711
|
+
}
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1669
1714
|
export async function rmList( req, res ) {
|
|
1670
1715
|
try {
|
|
1671
1716
|
const inputData = req.query;
|
|
@@ -1674,7 +1719,6 @@ export async function rmList( req, res ) {
|
|
|
1674
1719
|
configureType: 'user',
|
|
1675
1720
|
};
|
|
1676
1721
|
const getRMList = await findOneEyeTestConfig( query, { userList: 1 } );
|
|
1677
|
-
logger.info( { getRMList: getRMList } );
|
|
1678
1722
|
return res.sendSuccess( { result: getRMList?.userList || [] } );
|
|
1679
1723
|
} catch ( error ) {
|
|
1680
1724
|
const err = error.message || 'Internal Server Error';
|
|
@@ -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
|
+
}
|