tango-app-api-audit 3.4.68-beta.2 → 3.4.68-beta.4
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/README.md
CHANGED
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
# README #
|
|
2
|
-
|
|
3
|
-
This README would normally document whatever steps are necessary to get your application up and running.
|
|
4
|
-
|
|
5
|
-
### What is this repository for? ###
|
|
6
|
-
|
|
7
|
-
* Quick summary
|
|
8
|
-
* Version
|
|
9
|
-
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
|
|
10
|
-
|
|
11
|
-
### How do I get set up? ###
|
|
12
|
-
|
|
13
|
-
* Summary of set up
|
|
14
|
-
* Configuration
|
|
15
|
-
* Dependencies
|
|
16
|
-
* Database configuration
|
|
17
|
-
* How to run tests
|
|
18
|
-
* Deployment instructions
|
|
19
|
-
|
|
20
|
-
### Contribution guidelines ###
|
|
21
|
-
|
|
22
|
-
* Writing tests
|
|
23
|
-
* Code review
|
|
24
|
-
* Other guidelines
|
|
25
|
-
|
|
26
|
-
### Who do I talk to? ###
|
|
27
|
-
|
|
28
|
-
* Repo owner or admin
|
|
1
|
+
# README #
|
|
2
|
+
|
|
3
|
+
This README would normally document whatever steps are necessary to get your application up and running.
|
|
4
|
+
|
|
5
|
+
### What is this repository for? ###
|
|
6
|
+
|
|
7
|
+
* Quick summary
|
|
8
|
+
* Version
|
|
9
|
+
* [Learn Markdown](https://bitbucket.org/tutorials/markdowndemo)
|
|
10
|
+
|
|
11
|
+
### How do I get set up? ###
|
|
12
|
+
|
|
13
|
+
* Summary of set up
|
|
14
|
+
* Configuration
|
|
15
|
+
* Dependencies
|
|
16
|
+
* Database configuration
|
|
17
|
+
* How to run tests
|
|
18
|
+
* Deployment instructions
|
|
19
|
+
|
|
20
|
+
### Contribution guidelines ###
|
|
21
|
+
|
|
22
|
+
* Writing tests
|
|
23
|
+
* Code review
|
|
24
|
+
* Other guidelines
|
|
25
|
+
|
|
26
|
+
### Who do I talk to? ###
|
|
27
|
+
|
|
28
|
+
* Repo owner or admin
|
|
29
29
|
* Other community or team contact
|
package/package.json
CHANGED
|
@@ -16,7 +16,8 @@ export async function getList( req, res ) {
|
|
|
16
16
|
const limit = inputData.limit || 10;
|
|
17
17
|
const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
|
|
18
18
|
|
|
19
|
-
|
|
19
|
+
const sortBy = `${inputData?.sortBy}.keyword`;
|
|
20
|
+
const order = inputData?.sortOrder || -1;
|
|
20
21
|
let filter= [
|
|
21
22
|
{
|
|
22
23
|
'range': {
|
|
@@ -125,9 +126,7 @@ export async function getList( req, res ) {
|
|
|
125
126
|
{ date: { order: 'desc' } },
|
|
126
127
|
],
|
|
127
128
|
};
|
|
128
|
-
if (
|
|
129
|
-
const sortBy = inputData.sortBy;
|
|
130
|
-
const order = inputData.sortOrder || -1;
|
|
129
|
+
if ( sortBy && sortBy !== '' ) {
|
|
131
130
|
searchQuery={
|
|
132
131
|
'from': offset,
|
|
133
132
|
'size': limit,
|
|
@@ -591,6 +590,94 @@ export async function save( req, res ) {
|
|
|
591
590
|
}
|
|
592
591
|
}
|
|
593
592
|
|
|
593
|
+
export async function cancel( req, res ) {
|
|
594
|
+
try {
|
|
595
|
+
const inputData = req.body;
|
|
596
|
+
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
597
|
+
|
|
598
|
+
let searchFilter =[
|
|
599
|
+
{
|
|
600
|
+
'term': {
|
|
601
|
+
'queueId.keyword': inputData?.fileId,
|
|
602
|
+
},
|
|
603
|
+
|
|
604
|
+
},
|
|
605
|
+
{
|
|
606
|
+
'term': {
|
|
607
|
+
'type.keyword': inputData?.type,
|
|
608
|
+
},
|
|
609
|
+
|
|
610
|
+
},
|
|
611
|
+
|
|
612
|
+
{
|
|
613
|
+
'term': {
|
|
614
|
+
'auditStatus.keyword': 'In-Progress',
|
|
615
|
+
},
|
|
616
|
+
},
|
|
617
|
+
];
|
|
618
|
+
if ( inputData?.type == 'remote' ) {
|
|
619
|
+
searchFilter =[
|
|
620
|
+
{
|
|
621
|
+
'term': {
|
|
622
|
+
'engagementId.keyword': inputData?.fileId,
|
|
623
|
+
},
|
|
624
|
+
|
|
625
|
+
},
|
|
626
|
+
{
|
|
627
|
+
'term': {
|
|
628
|
+
'type.keyword': inputData?.type,
|
|
629
|
+
},
|
|
630
|
+
|
|
631
|
+
},
|
|
632
|
+
{
|
|
633
|
+
'term': {
|
|
634
|
+
'userId.keyword': req?.user?._id,
|
|
635
|
+
},
|
|
636
|
+
},
|
|
637
|
+
{
|
|
638
|
+
'term': {
|
|
639
|
+
'auditStatus.keyword': 'In-Progress',
|
|
640
|
+
},
|
|
641
|
+
},
|
|
642
|
+
];
|
|
643
|
+
}
|
|
644
|
+
|
|
645
|
+
let searchQuery={
|
|
646
|
+
'size': 1,
|
|
647
|
+
'query': {
|
|
648
|
+
'bool': {
|
|
649
|
+
'must': searchFilter,
|
|
650
|
+
},
|
|
651
|
+
},
|
|
652
|
+
};
|
|
653
|
+
const getOutput = await getOpenSearchData( openSearch.EyeTestOutput, searchQuery );
|
|
654
|
+
logger.info( { getOutput: getOutput } );
|
|
655
|
+
const output = getOutput?.body?.hits?.hits?.length > 0 ? getOutput?.body?.hits?.hits[0] : null;
|
|
656
|
+
if ( !output ) {
|
|
657
|
+
return res.sendError( 'No saved records found', 400 );
|
|
658
|
+
}
|
|
659
|
+
const record1 ={
|
|
660
|
+
|
|
661
|
+
auditStatus: 'Skipped',
|
|
662
|
+
endTime: dayjs().tz( 'Asia/Kolkata' ),
|
|
663
|
+
|
|
664
|
+
};
|
|
665
|
+
const record2 ={
|
|
666
|
+
|
|
667
|
+
auditStatus: 'Yet-to-Audit',
|
|
668
|
+
endTime: dayjs().tz( 'Asia/Kolkata' ),
|
|
669
|
+
|
|
670
|
+
};
|
|
671
|
+
await updateOpenSearchData( openSearch.EyeTestOutput, output?._id, { doc: record1 } );
|
|
672
|
+
await updateOpenSearchData( openSearch.EyeTestInput, inputData.id, { doc: record2 } );
|
|
673
|
+
return res.sendSuccess( 'The file has canceled ' );
|
|
674
|
+
} catch ( error ) {
|
|
675
|
+
const err = error.message || 'Internal Server Error';
|
|
676
|
+
logger.error( { message: error, data: req.params, function: 'eyetestAudit-controller-cancel' } );
|
|
677
|
+
return res.sendError( err, 500 );
|
|
678
|
+
}
|
|
679
|
+
}
|
|
680
|
+
|
|
594
681
|
export async function getFileHistory( req, res ) {
|
|
595
682
|
try {
|
|
596
683
|
const parsedOpenSearch = JSON.parse( process.env.OPENSEARCH );
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import j2s from 'joi-to-swagger';
|
|
2
|
-
import { getListSchema, getFileSchema, getFileHistorySchema, userAuditedDataSchema, viewFileSchema, saveSchema } from '../dtos/eyeTestAudit.dtos.js';
|
|
2
|
+
import { getListSchema, getFileSchema, getFileHistorySchema, userAuditedDataSchema, viewFileSchema, saveSchema, cancelSchema } from '../dtos/eyeTestAudit.dtos.js';
|
|
3
3
|
|
|
4
4
|
export const eyeTestAuditDocs = {
|
|
5
5
|
|
|
@@ -93,6 +93,28 @@ export const eyeTestAuditDocs = {
|
|
|
93
93
|
},
|
|
94
94
|
},
|
|
95
95
|
|
|
96
|
+
'/v3/eye-test-audit/cancel': {
|
|
97
|
+
post: {
|
|
98
|
+
tags: [ 'Eye Test Audit' ],
|
|
99
|
+
description: 'cancel eytest audit',
|
|
100
|
+
operationId: 'cancel',
|
|
101
|
+
requestBody: {
|
|
102
|
+
content: {
|
|
103
|
+
'application/json': {
|
|
104
|
+
schema: j2s( cancelSchema ).swagger,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
responses: {
|
|
109
|
+
200: { description: 'Successful' },
|
|
110
|
+
401: { description: 'Unauthorized User' },
|
|
111
|
+
422: { description: 'Field Error' },
|
|
112
|
+
500: { description: 'Server Error' },
|
|
113
|
+
204: { description: 'Not Found' },
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
},
|
|
117
|
+
|
|
96
118
|
'/v3/eye-test-audit/get-file-history/{id}': {
|
|
97
119
|
get: {
|
|
98
120
|
tags: [ 'Eye Test Audit' ],
|
|
@@ -53,6 +53,17 @@ export const saveValid = {
|
|
|
53
53
|
};
|
|
54
54
|
|
|
55
55
|
|
|
56
|
+
export const cancelSchema = joi.object( {
|
|
57
|
+
type: joi.string().required(),
|
|
58
|
+
fileId: joi.string().required(),
|
|
59
|
+
id: joi.string().required(),
|
|
60
|
+
} );
|
|
61
|
+
|
|
62
|
+
export const cancelValid = {
|
|
63
|
+
body: cancelSchema,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
|
|
56
67
|
export const getFileHistorySchema = joi.object( {
|
|
57
68
|
id: joi.string().required(),
|
|
58
69
|
type: joi.string().required(),
|
|
@@ -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 { getFileHistoryValid, getFileValid, getListValid, saveValid, userAuditedDataValid, viewFileValid } from '../dtos/eyeTestAudit.dtos.js';
|
|
5
|
-
import { getFile, getFileHistory, getList, save, userAuditedData, viewFile } from '../controllers/eyeTestAudit.controllers.js';
|
|
4
|
+
import { cancelValid, getFileHistoryValid, getFileValid, getListValid, saveValid, userAuditedDataValid, viewFileValid } from '../dtos/eyeTestAudit.dtos.js';
|
|
5
|
+
import { cancel, getFile, getFileHistory, getList, save, userAuditedData, viewFile } from '../controllers/eyeTestAudit.controllers.js';
|
|
6
6
|
|
|
7
7
|
export const eyeTestAuditRouter = Router();
|
|
8
8
|
|
|
@@ -10,6 +10,7 @@ eyeTestAuditRouter.post( '/get-list', isAllowedSessionHandler, accessVerificatio
|
|
|
10
10
|
eyeTestAuditRouter.get( '/view-file/:id', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( viewFileValid ), viewFile );
|
|
11
11
|
eyeTestAuditRouter.get( '/get-file/:id', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( getFileValid ), getFile );
|
|
12
12
|
eyeTestAuditRouter.post( '/save', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( saveValid ), save );
|
|
13
|
+
eyeTestAuditRouter.post( '/cancel', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( cancelValid ), cancel );
|
|
13
14
|
eyeTestAuditRouter.get( '/get-file-history/:id/:type', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( getFileHistoryValid ), getFileHistory );
|
|
14
15
|
eyeTestAuditRouter.get( '/user-audited-data/:id', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( userAuditedDataValid ), userAuditedData );
|
|
15
16
|
|