tango-app-api-audit 3.4.68-beta.2 → 3.4.68-beta.20

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/.eslintrc.cjs CHANGED
@@ -36,7 +36,7 @@ module.exports = {
36
36
  'no-unused-vars': 'error',
37
37
  'new-cap': [ 'error', { 'newIsCap': true, 'capIsNew': false } ],
38
38
  'prefer-const': 'off',
39
- 'no-console': 'error',
39
+ // 'no-console': 'error',
40
40
  },
41
41
  };
42
42
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-audit",
3
- "version": "3.4.68-beta.2",
3
+ "version": "3.4.68-beta.20",
4
4
  "description": "audit & audit metrics apis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -26,8 +26,8 @@
26
26
  "mongodb": "^6.7.0",
27
27
  "nodemon": "^3.1.3",
28
28
  "swagger-ui-express": "^5.0.1",
29
- "tango-api-schema": "^2.2.95",
30
- "tango-app-api-middleware": "^3.1.71",
29
+ "tango-api-schema": "^2.2.98",
30
+ "tango-app-api-middleware": "^3.1.73",
31
31
  "winston": "^3.13.0",
32
32
  "winston-daily-rotate-file": "^5.0.0"
33
33
  },
@@ -12,11 +12,15 @@ dayjs.extend( timezone );
12
12
  export async function getList( req, res ) {
13
13
  try {
14
14
  const inputData = req.body;
15
+ if ( inputData.clientId !== '11' ) {
16
+ return res.sendError( 'No data found', 204 );
17
+ }
15
18
  const openSearch = JSON.parse( process.env.OPENSEARCH );
16
19
  const limit = inputData.limit || 10;
17
20
  const offset = inputData.offset ? ( inputData.offset - 1 ) * limit : 0;
18
21
 
19
-
22
+ const sortBy = inputData?.sortBy ? inputData.sortBy === 'coveredStepsAI'||inputData.sortBy==='updatedAt' ? inputData.sortBy :`${inputData.sortBy}.keyword` : 'storeName.keyword';
23
+ const order = inputData?.sortOrder || -1;
20
24
  let filter= [
21
25
  {
22
26
  'range': {
@@ -30,13 +34,13 @@ export async function getList( req, res ) {
30
34
  ];
31
35
 
32
36
 
33
- // if ( inputData.demographics && inputData.demographics.length > 0 ) {
34
- // filter.push( {
35
- // 'terms': {
36
- // 'visitorsType.keyword': inputData.demographics,
37
- // },
38
- // } );
39
- // }
37
+ if ( inputData.demographics && inputData.demographics.length > 0 ) {
38
+ filter.push( {
39
+ 'terms': {
40
+ 'visitorsType.keyword': inputData.demographics,
41
+ },
42
+ } );
43
+ }
40
44
  if ( inputData.type && inputData.type!='' ) {
41
45
  filter.push( {
42
46
  'term': {
@@ -59,61 +63,100 @@ export async function getList( req, res ) {
59
63
  };
60
64
 
61
65
  if ( inputData.searchValue && inputData.searchValue !== '' ) {
62
- search ={
63
- 'must': filter,
64
- 'should': [
65
- {
66
- 'wildcard': {
67
- 'storeName.keyword': {
68
- 'value': `*${inputData.searchValue}*`,
66
+ if ( inputData.type&&inputData.type==='remote' ) {
67
+ search ={
68
+ 'must': filter,
69
+ 'should': [
70
+ {
71
+ 'wildcard': {
72
+ 'storeName.keyword': {
73
+ 'value': `*${inputData.searchValue}*`,
74
+ },
69
75
  },
70
76
  },
71
- },
72
- {
73
- 'wildcard': {
74
- 'storeId.keyword': {
75
- 'value': `*${inputData.searchValue}*`,
77
+ {
78
+ 'wildcard': {
79
+ 'storeId.keyword': {
80
+ 'value': `*${inputData.searchValue}*`,
81
+ },
76
82
  },
77
83
  },
78
- },
79
- {
80
- 'wildcard': {
81
- 'engagementId.keyword': {
82
- 'value': `*${inputData.searchValue}*`,
84
+ {
85
+ 'wildcard': {
86
+ 'engagementId.keyword': {
87
+ 'value': `*${inputData.searchValue}*`,
88
+ },
83
89
  },
84
90
  },
85
- },
86
- {
87
- 'wildcard': {
88
- 'queueId.keyword': {
89
- 'value': `*${inputData.searchValue}*`,
91
+
92
+ {
93
+ 'wildcard': {
94
+ 'auditStatus.keyword': {
95
+ 'value': `*${inputData.searchValue}*`,
96
+ },
90
97
  },
91
98
  },
92
- },
93
- {
94
- 'wildcard': {
95
- 'optumId.keyword': {
96
- 'value': `*${inputData.engagementId}*`,
99
+ ],
100
+ 'minimum_should_match': 1,
101
+ };
102
+ } else {
103
+ search ={
104
+ 'must': filter,
105
+ 'should': [
106
+ {
107
+ 'wildcard': {
108
+ 'storeName.keyword': {
109
+ 'value': `*${inputData.searchValue}*`,
110
+ },
97
111
  },
98
112
  },
99
- },
100
- {
101
- 'wildcard': {
102
- 'visitorsType.keyword': {
103
- 'value': `*${inputData.searchValue}*`,
113
+ {
114
+ 'wildcard': {
115
+ 'storeId.keyword': {
116
+ 'value': `*${inputData.searchValue}*`,
117
+ },
104
118
  },
105
119
  },
106
- },
107
- {
108
- 'wildcard': {
109
- 'auditStatus.keyword': {
110
- 'value': `*${inputData.searchValue}*`,
120
+ {
121
+ 'wildcard': {
122
+ 'engagementId.keyword': {
123
+ 'value': `*${inputData.searchValue}*`,
124
+ },
111
125
  },
112
126
  },
113
- },
114
- ],
115
- 'minimum_should_match': 1,
116
- };
127
+ {
128
+ 'wildcard': {
129
+ 'queueId.keyword': {
130
+ 'value': `*${inputData.searchValue}*`,
131
+ },
132
+ },
133
+ },
134
+ {
135
+ 'wildcard': {
136
+ 'optumId.keyword': {
137
+ 'value': `*${inputData.searchValue}*`,
138
+ },
139
+ },
140
+ },
141
+ {
142
+ 'wildcard': {
143
+ 'visitorsType.keyword': {
144
+ 'value': `*${inputData.searchValue}*`,
145
+ },
146
+ },
147
+ },
148
+
149
+ {
150
+ 'wildcard': {
151
+ 'auditStatus.keyword': {
152
+ 'value': `*${inputData.searchValue}*`,
153
+ },
154
+ },
155
+ },
156
+ ],
157
+ 'minimum_should_match': 1,
158
+ };
159
+ }
117
160
  }
118
161
  let searchQuery={
119
162
  'from': offset,
@@ -125,9 +168,7 @@ export async function getList( req, res ) {
125
168
  { date: { order: 'desc' } },
126
169
  ],
127
170
  };
128
- if ( inputData.sortBy && inputData.sortBy !== '' ) {
129
- const sortBy = inputData.sortBy;
130
- const order = inputData.sortOrder || -1;
171
+ if ( sortBy && sortBy !== '' ) {
131
172
  searchQuery={
132
173
  'from': offset,
133
174
  'size': limit,
@@ -148,7 +189,7 @@ export async function getList( req, res ) {
148
189
  'bool': search,
149
190
  },
150
191
  'sort': [
151
- { createdAt: { order: 'desc' } },
192
+ { 'storeName.keyword': { order: 'desc' } },
152
193
  ],
153
194
  };
154
195
  }
@@ -165,7 +206,7 @@ export async function getList( req, res ) {
165
206
  const chunkedMappingData = await chunkArray( searchValue, 10 );
166
207
  const promises = chunkedMappingData.map( async ( chunk ) => {
167
208
  const exportData = [];
168
- chunk.forEach( async ( element ) => {
209
+ for ( const element of chunk ) {
169
210
  const testDuration = element?._source?.testDuration;
170
211
  const minutes = Math.floor( testDuration / 60 );
171
212
  const seconds = testDuration % 60;
@@ -175,13 +216,13 @@ export async function getList( req, res ) {
175
216
  const userName = await findOneUser( { _id: element?._source?.userId }, { _id: 0, userName: 1 } );
176
217
  if ( element?._source?.type == 'physical' ) {
177
218
  exportData.push( {
178
- 'Date': dayjs( element?._source?.date ).format( 'YYYY,MMM D' ),
219
+ 'Date': dayjs( element?._source?.date ).format( 'D MMM, YYYY' ),
179
220
  'Store Name': element?._source?.storeName,
180
221
  'Store ID': element?._source?.storeId || 'Un Assigned',
181
222
  'Store Name': element?._source?.storeName ||'Un Assigned',
182
223
  'Optum ID': element?._source?.optumId,
183
224
  'Queue ID': element?._source?.queueId,
184
- 'Compliance Score': element?._source?.complianceScore || 0,
225
+ 'Compliance Score': element?._source?.totalSteps>0 ? Math.round( ( element?._source?.coveredStepsAI/ element?._source?.totalSteps )*100 ): 0,
185
226
  'Steps Covered By AI': element?._source?.coveredStepsAI || 0,
186
227
  'Visitor Type': element?._source?.visitorsType,
187
228
  'Test Duration': duration || '',
@@ -191,21 +232,20 @@ export async function getList( req, res ) {
191
232
  } );
192
233
  } else {
193
234
  exportData.push( {
194
- 'Date': dayjs( element?._source?.date ).format( 'YYYY,MMM D' ),
235
+ 'Date': dayjs( element?._source?.date ).format( 'D MMM, YYYY' ),
195
236
  'Store Name': element?._source?.storeName,
196
237
  'Store ID': element?._source?.storeId || 'Un Assigned',
197
238
  'Store Name': element?._source?.storeName ||'Un Assigned',
198
239
  'Engagement ID': element?._source?.engagementId,
199
240
  'Compliance Score': element?._source?.complianceScore || 0,
200
241
  'Steps Covered By AI': element?._source?.coveredStepsAI || 0,
201
- 'Visitor Type': element?._source?.visitorsType,
202
242
  'Test Duration': duration || '',
203
243
  'Audit Status': element?._source?.auditStatus || '',
204
- 'Audited By': userName.userName || '',
244
+ 'Audited By': userName?.userName || '',
205
245
 
206
246
  } );
207
247
  }
208
- } );
248
+ }
209
249
  return exportData;
210
250
  } );
211
251
  const mappedArrays = await Promise.all( promises );
@@ -218,10 +258,11 @@ export async function getList( req, res ) {
218
258
  const testDuration = searchValue[i]?._source?.testDuration;
219
259
  const minutes = Math.floor( testDuration / 60 );
220
260
  const seconds = testDuration % 60;
221
-
261
+ searchValue[i]._source.complianceScore = searchValue[i]?._source?.totalSteps>0 ? Math.round( ( searchValue[i]?._source?.coveredStepsAI/ searchValue[i]?._source?.totalSteps )*100 ): 0;
222
262
  searchValue[i]._source.min = minutes;
223
263
  searchValue[i]._source.sec = seconds;
224
264
  searchValue[i]._source.auditedBy = userName?.userName || '';
265
+ searchValue[i]._source.date = dayjs( searchValue[i]?._source?.date ).format( 'D MMM, YYYY' );
225
266
  }
226
267
  }
227
268
 
@@ -258,7 +299,11 @@ export async function viewFile( req, res ) {
258
299
  'term': {
259
300
  'type.keyword': getData?.type,
260
301
  },
261
-
302
+ },
303
+ {
304
+ 'terms': {
305
+ 'auditStatus.keyword': [ 'Audited', 'Re-Audited' ],
306
+ },
262
307
  },
263
308
  ];
264
309
  if ( getData?.type == 'remote' ) {
@@ -273,7 +318,11 @@ export async function viewFile( req, res ) {
273
318
  'term': {
274
319
  'type.keyword': getData?.type,
275
320
  },
276
-
321
+ },
322
+ {
323
+ 'terms': {
324
+ 'auditStatus.keyword': [ 'Audited', 'Re-Audited' ],
325
+ },
277
326
  },
278
327
  ];
279
328
  }
@@ -291,6 +340,7 @@ export async function viewFile( req, res ) {
291
340
  };
292
341
 
293
342
  const searchRes= await getOpenSearchData( openSearch.EyeTestOutput, searchQuery );
343
+
294
344
  const temp = searchRes?.body?.hits?.hits?.length > 0? searchRes?.body?.hits?.hits[0] : [];
295
345
 
296
346
  const getUserName = await findOneUser( { _id: new mongoose.Types.ObjectId( temp?._source?.userId ) }, { userName: 1 } );
@@ -298,7 +348,7 @@ export async function viewFile( req, res ) {
298
348
  const searchData = temp?
299
349
  getData['lastAuditedDetails']= {
300
350
  'auditedBy': getUserName?.userName || '',
301
- 'completionTime': temp?._source?.startTime? new Date( temp?._source?.startTime ).toLocaleTimeString( 'en-IN', { hour12: false } ): '',
351
+ 'completionTime': temp?._source?.startTime? dayjs.utc( temp?._source?.startTime ).tz( 'Asia/Kolkata' ).format( 'HH:mm:ss' ): '',
302
352
  'timeZone': temp?.timeZone || '',
303
353
  } : null;
304
354
  getData['complianceScore'] = getData.complianceScore || getData?.totalSteps>0 ? Math.round( ( getData?.coveredStepsAI/ getData?.totalSteps )*100 ): 0;
@@ -322,7 +372,9 @@ export async function viewFile( req, res ) {
322
372
  break;
323
373
  case 'Audited':
324
374
  response['steps']= temp._source?.steps;
375
+ isEnable=true;
325
376
  case 'Re-Audited':
377
+ response['steps']= temp._source?.steps;
326
378
  isEnable=true;
327
379
  }
328
380
 
@@ -433,7 +485,7 @@ export async function getFile( req, res ) {
433
485
  if ( !searchData ) {
434
486
  const data1 = await insertOpenSearchData( openSearch.EyeTestOutput, record );
435
487
  logger.info( { data1: data1 } );
436
- await updateOpenSearchData( openSearch.EyeTestInput, inputData.id, { doc: { auditStatus: 'In-Progress', auditType: 'Audit', userId: req?.user?._id } } );
488
+ await updateOpenSearchData( openSearch.EyeTestInput, inputData.id, { doc: { 'auditStatus': 'In-Progress', 'auditType': 'Audit', 'userId': req?.user?._id, 'updatedAt': dayjs().tz( 'Asia/Kolkata' ) } } );
437
489
  }
438
490
 
439
491
  break;
@@ -481,7 +533,7 @@ export async function getFile( req, res ) {
481
533
 
482
534
  };
483
535
  await insertOpenSearchData( openSearch.EyeTestOutput, newRecord );
484
- await updateOpenSearchData( openSearch.EyeTestInput, inputData.id, { doc: { auditStatus: 'In-Progress', auditType: 'Re-Audit' } } );
536
+ await updateOpenSearchData( openSearch.EyeTestInput, inputData.id, { doc: { auditStatus: 'In-Progress', auditType: 'Re-Audit', userId: req?.user?._id } } );
485
537
 
486
538
  break;
487
539
  default:
@@ -513,7 +565,11 @@ export async function save( req, res ) {
513
565
  },
514
566
 
515
567
  },
516
-
568
+ {
569
+ 'term': {
570
+ 'userId.keyword': req?.user?._id,
571
+ },
572
+ },
517
573
  {
518
574
  'term': {
519
575
  'auditStatus.keyword': 'In-Progress',
@@ -559,26 +615,27 @@ export async function save( req, res ) {
559
615
  logger.info( { getOutput: getOutput } );
560
616
  const output = getOutput?.body?.hits?.hits?.length > 0 ? getOutput?.body?.hits?.hits[0] : null;
561
617
  if ( !output ) {
562
- return res.sendError( 'No saved records found', 400 );
618
+ return res.sendError( 'This file is currently being audited by another user. Any actions you perform will not be saved.', 400 );
563
619
  }
564
620
  const record ={
565
- steps: inputData?.steps,
566
- auditStatus: inputData?.auditStatus,
567
- auditedSteps: inputData?.auditedSteps,
568
- overRides: inputData?.overRides,
569
- trustScore: Math.round( 100-( ( inputData?.overRides / inputData?.steps?.length ) * 100 ) ),
570
- spokenLanguage: inputData?.spokenLanguage,
571
- endTime: dayjs().tz( 'Asia/Kolkata' ),
572
-
621
+ 'steps': inputData?.steps,
622
+ 'auditStatus': inputData?.auditStatus,
623
+ 'auditedSteps': inputData?.auditedSteps,
624
+ 'overRides': inputData?.overRides,
625
+ 'trustScore': Math.round( 100-( ( inputData?.overRides / inputData?.steps?.length ) * 100 ) ),
626
+ 'spokenLanguage': inputData?.spokenLanguage,
627
+ 'endTime': dayjs().tz( 'Asia/Kolkata' ),
628
+ 'updatedAt': dayjs().tz( 'Asia/Kolkata' ),
573
629
  };
574
630
  const inputrecord ={
575
631
 
576
- auditStatus: inputData?.auditStatus,
577
- auditedSteps: inputData?.auditedSteps,
578
- overRides: inputData?.overRides,
579
- trustScore: Math.round( 100-( ( inputData?.overRides / inputData?.steps?.length ) * 100 ) ),
580
- spokenLanguage: inputData?.spokenLanguage,
581
- endTime: dayjs().tz( 'Asia/Kolkata' ),
632
+ 'auditStatus': inputData?.auditStatus,
633
+ 'auditedSteps': inputData?.auditedSteps,
634
+ 'overRides': inputData?.overRides,
635
+ 'trustScore': Math.round( 100-( ( inputData?.overRides / inputData?.steps?.length ) * 100 ) ),
636
+ 'spokenLanguage': inputData?.spokenLanguage,
637
+ 'endTime': dayjs().tz( 'Asia/Kolkata' ),
638
+ 'updatedAt': dayjs().tz( 'Asia/Kolkata' ),
582
639
 
583
640
  };
584
641
  await updateOpenSearchData( openSearch.EyeTestOutput, output?._id, { doc: record } );
@@ -591,6 +648,138 @@ export async function save( req, res ) {
591
648
  }
592
649
  }
593
650
 
651
+ export async function cancel( req, res ) {
652
+ try {
653
+ const inputData = req.body;
654
+ const openSearch = JSON.parse( process.env.OPENSEARCH );
655
+ let searchFilterhistory=[
656
+ {
657
+ 'term': {
658
+ 'queueId.keyword': inputData?.fileId,
659
+ },
660
+
661
+ },
662
+ {
663
+ 'term': {
664
+ 'type.keyword': inputData?.type,
665
+ },
666
+
667
+ },
668
+ ];
669
+ let searchFilter =[
670
+ {
671
+ 'term': {
672
+ 'queueId.keyword': inputData?.fileId,
673
+ },
674
+
675
+ },
676
+ {
677
+ 'term': {
678
+ 'type.keyword': inputData?.type,
679
+ },
680
+
681
+ },
682
+ {
683
+ 'term': {
684
+ 'userId.keyword': req?.user?._id,
685
+ },
686
+ },
687
+ {
688
+ 'term': {
689
+ 'auditStatus.keyword': 'In-Progress',
690
+ },
691
+ },
692
+ ];
693
+ if ( inputData?.type == 'remote' ) {
694
+ searchFilter =[
695
+ {
696
+ 'term': {
697
+ 'engagementId.keyword': inputData?.fileId,
698
+ },
699
+
700
+ },
701
+ {
702
+ 'term': {
703
+ 'type.keyword': inputData?.type,
704
+ },
705
+
706
+ },
707
+ {
708
+ 'term': {
709
+ 'userId.keyword': req?.user?._id,
710
+ },
711
+ },
712
+ {
713
+ 'term': {
714
+ 'auditStatus.keyword': 'In-Progress',
715
+ },
716
+ },
717
+ ];
718
+ searchFilterhistory=[
719
+ {
720
+ 'term': {
721
+ 'engagementId.keyword': inputData?.fileId,
722
+ },
723
+
724
+ },
725
+ {
726
+ 'term': {
727
+ 'type.keyword': inputData?.type,
728
+ },
729
+
730
+ },
731
+ ];
732
+ }
733
+
734
+ let searchQuery={
735
+ 'size': 1,
736
+ 'query': {
737
+ 'bool': {
738
+ 'must': searchFilter,
739
+ },
740
+ },
741
+ };
742
+ let searchQueryHistory={
743
+ 'size': 100,
744
+ 'query': {
745
+ 'bool': {
746
+ 'must': searchFilterhistory,
747
+ },
748
+ },
749
+ };
750
+ const getOutput = await getOpenSearchData( openSearch.EyeTestOutput, searchQuery );
751
+ const getOutputHistory = await getOpenSearchData( openSearch.EyeTestOutput, searchQueryHistory );
752
+ logger.info( { getOutput: getOutput } );
753
+ const output = getOutput?.body?.hits?.hits?.length > 0 ? getOutput?.body?.hits?.hits[0] : null;
754
+ let checkReaudited = getOutput?.body?.hits?.hits?.length > 0 ? getOutputHistory?.body?.hits?.hits.filter( ( data ) => data._source.auditType==='Re-Audit'&&data._source.auditStatus==='Re-Audited' ).length:0;
755
+ let checkaudited = getOutput?.body?.hits?.hits?.length > 0 ? getOutputHistory?.body?.hits?.hits.filter( ( data ) => data._source.auditType==='Audit'&&data._source.auditStatus==='Audited' ).length:0;
756
+
757
+ if ( !output ) {
758
+ return res.sendError( 'No saved records found', 400 );
759
+ }
760
+ const record1 ={
761
+
762
+ auditStatus: 'Skipped',
763
+ auditType: checkReaudited>0?'Re-Audit':'Audit',
764
+ endTime: dayjs().tz( 'Asia/Kolkata' ),
765
+
766
+ };
767
+ const record2 ={
768
+ auditStatus: checkReaudited>0?'Re-Audited':checkaudited>0?'Audited':'Yet-to-Audit',
769
+ auditType: checkReaudited>0?'Re-Audit':'Audit',
770
+ endTime: dayjs().tz( 'Asia/Kolkata' ),
771
+
772
+ };
773
+ await updateOpenSearchData( openSearch.EyeTestOutput, output?._id, { doc: record1 } );
774
+ await updateOpenSearchData( openSearch.EyeTestInput, inputData.id, { doc: record2 } );
775
+ return res.sendSuccess( 'The file has canceled ' );
776
+ } catch ( error ) {
777
+ const err = error.message || 'Internal Server Error';
778
+ logger.error( { message: error, data: req.params, function: 'eyetestAudit-controller-cancel' } );
779
+ return res.sendError( err, 500 );
780
+ }
781
+ }
782
+
594
783
  export async function getFileHistory( req, res ) {
595
784
  try {
596
785
  const parsedOpenSearch = JSON.parse( process.env.OPENSEARCH );
@@ -607,10 +796,17 @@ export async function getFileHistory( req, res ) {
607
796
  'queueId.keyword': inputData.id,
608
797
  },
609
798
  },
610
-
799
+ {
800
+ 'terms': {
801
+ 'auditStatus.keyword': [ 'Audited', 'Re-Audited' ],
802
+ },
803
+ },
611
804
  ],
612
805
  },
613
806
  },
807
+ 'sort': [
808
+ { updatedAt: { order: 'desc' } },
809
+ ],
614
810
  };
615
811
  } else {
616
812
  Query = {
@@ -623,10 +819,17 @@ export async function getFileHistory( req, res ) {
623
819
  'engagementId.keyword': inputData.id,
624
820
  },
625
821
  },
626
-
822
+ {
823
+ 'terms': {
824
+ 'auditStatus.keyword': [ 'Audited', 'Re-Audited' ],
825
+ },
826
+ },
627
827
  ],
628
828
  },
629
829
  },
830
+ 'sort': [
831
+ { updatedAt: { order: 'desc' } },
832
+ ],
630
833
  };
631
834
  };
632
835
 
@@ -641,7 +844,7 @@ export async function getFileHistory( req, res ) {
641
844
  userId: data._source.userId,
642
845
  userName: findUser.userName,
643
846
  Date: dayjs( data._source.endTime ).format( 'DD/MM/YYYY' ),
644
- Time: dayjs( data._source.endTime ).format( 'HH:MM:ss' ),
847
+ Time: dayjs.utc( data._source.endTime ).tz( 'Asia/Kolkata' ).format( 'HH:mm:ss' ),
645
848
  } );
646
849
  }
647
850
 
@@ -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' ],
@@ -2,10 +2,23 @@ import joi from 'joi';
2
2
 
3
3
  export const getListSchema = joi.object(
4
4
  {
5
- fromDate: joi.string().required(),
6
- toDate: joi.string().required(),
7
- type: joi.string().required(),
5
+ fromDate: joi.string().required().messages( {
6
+ 'any.required': 'From Date is required',
7
+ 'string.empty': 'From Date cannot be empty',
8
+ } ),
9
+ toDate: joi.string().required().messages( {
10
+ 'any.required': 'To Date is required',
11
+ 'string.empty': 'To Date cannot be empty',
12
+ } ),
13
+ type: joi.string().required().messages( {
14
+ 'any.required': 'Type is required',
15
+ 'string.empty': 'Type cannot be empty',
16
+ } ),
8
17
  demographics: joi.array().optional(),
18
+ clientId: joi.string().required().messages( {
19
+ 'any.required': 'Client ID is required',
20
+ 'string.empty': 'Client ID cannot be empty',
21
+ } ),
9
22
  storeId: joi.array().optional(),
10
23
  limit: joi.number().optional(),
11
24
  offset: joi.number().optional(),
@@ -53,6 +66,17 @@ export const saveValid = {
53
66
  };
54
67
 
55
68
 
69
+ export const cancelSchema = joi.object( {
70
+ type: joi.string().required(),
71
+ fileId: joi.string().required(),
72
+ id: joi.string().required(),
73
+ } );
74
+
75
+ export const cancelValid = {
76
+ body: cancelSchema,
77
+ };
78
+
79
+
56
80
  export const getFileHistorySchema = joi.object( {
57
81
  id: joi.string().required(),
58
82
  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