tango-app-api-audit 3.4.68 → 3.4.69-beta.0

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.
@@ -0,0 +1,163 @@
1
+ import j2s from 'joi-to-swagger';
2
+ import { getListSchema, getFileSchema, getFileHistorySchema, userAuditedDataSchema, viewFileSchema, saveSchema, cancelSchema } from '../dtos/eyeTestAudit.dtos.js';
3
+
4
+ export const eyeTestAuditDocs = {
5
+
6
+ '/v3/eye-test-audit/get-list': {
7
+ post: {
8
+ tags: [ 'Eye Test Audit' ],
9
+ description: 'Get list of files',
10
+ operationId: 'get-list',
11
+ requestBody: {
12
+ content: {
13
+ 'application/json': {
14
+ schema: j2s( getListSchema ).swagger,
15
+ },
16
+ },
17
+ },
18
+ responses: {
19
+ 200: { description: 'Successful' },
20
+ 401: { description: 'Unauthorized User' },
21
+ 422: { description: 'Field Error' },
22
+ 500: { description: 'Server Error' },
23
+ 204: { description: 'Not Found' },
24
+ },
25
+ },
26
+ },
27
+
28
+ '/v3/eye-test-audit/view-file/{id}': {
29
+ get: {
30
+ tags: [ 'Eye Test Audit' ],
31
+ description: 'View a file via Open Serach',
32
+ operationId: 'view-file',
33
+ parameters: [
34
+ {
35
+ in: 'path',
36
+ name: 'id',
37
+ scema: j2s( viewFileSchema ).swagger,
38
+ require: true,
39
+ },
40
+ ],
41
+ responses: {
42
+ 200: { description: 'Successful' },
43
+ 401: { description: 'Unauthorized User' },
44
+ 422: { description: 'Field Error' },
45
+ 500: { description: 'Server Error' },
46
+ 204: { description: 'Not Found' },
47
+ },
48
+ },
49
+ },
50
+
51
+ '/v3/eye-test-audit/get-file/{id}': {
52
+ get: {
53
+ tags: [ 'Eye Test Audit' ],
54
+ description: 'Get a file via Open Serach',
55
+ operationId: 'get-file',
56
+ parameters: [
57
+ {
58
+ in: 'path',
59
+ name: 'id',
60
+ scema: j2s( getFileSchema ).swagger,
61
+ require: true,
62
+ },
63
+ ],
64
+ responses: {
65
+ 200: { description: 'Successful' },
66
+ 401: { description: 'Unauthorized User' },
67
+ 422: { description: 'Field Error' },
68
+ 500: { description: 'Server Error' },
69
+ 204: { description: 'Not Found' },
70
+ },
71
+ },
72
+ },
73
+
74
+ '/v3/eye-test-audit/save': {
75
+ post: {
76
+ tags: [ 'Eye Test Audit' ],
77
+ description: 'submit eytest audit',
78
+ operationId: 'save',
79
+ requestBody: {
80
+ content: {
81
+ 'application/json': {
82
+ schema: j2s( saveSchema ).swagger,
83
+ },
84
+ },
85
+ },
86
+ responses: {
87
+ 200: { description: 'Successful' },
88
+ 401: { description: 'Unauthorized User' },
89
+ 422: { description: 'Field Error' },
90
+ 500: { description: 'Server Error' },
91
+ 204: { description: 'Not Found' },
92
+ },
93
+ },
94
+ },
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
+
118
+ '/v3/eye-test-audit/get-file-history/{id}': {
119
+ get: {
120
+ tags: [ 'Eye Test Audit' ],
121
+ description: 'Get a file history via Open Serach',
122
+ operationId: 'get-file-history',
123
+ parameters: [
124
+ {
125
+ in: 'path',
126
+ name: 'id',
127
+ scema: j2s( getFileHistorySchema ).swagger,
128
+ require: true,
129
+ },
130
+ ],
131
+ responses: {
132
+ 200: { description: 'Successful' },
133
+ 401: { description: 'Unauthorized User' },
134
+ 422: { description: 'Field Error' },
135
+ 500: { description: 'Server Error' },
136
+ 204: { description: 'Not Found' },
137
+ },
138
+ },
139
+ },
140
+
141
+ '/v3/eye-test-audit/user-audited-data/{id}': {
142
+ get: {
143
+ tags: [ 'Eye Test Audit' ],
144
+ description: `Get a user's audited file`,
145
+ operationId: 'user-audited-data',
146
+ parameters: [
147
+ {
148
+ in: 'path',
149
+ name: 'id',
150
+ scema: j2s( userAuditedDataSchema ).swagger,
151
+ require: true,
152
+ },
153
+ ],
154
+ responses: {
155
+ 200: { description: 'Successful' },
156
+ 401: { description: 'Unauthorized User' },
157
+ 422: { description: 'Field Error' },
158
+ 500: { description: 'Server Error' },
159
+ 204: { description: 'Not Found' },
160
+ },
161
+ },
162
+ },
163
+ };
@@ -0,0 +1,97 @@
1
+ import joi from 'joi';
2
+
3
+ export const getListSchema = joi.object(
4
+ {
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
+ } ),
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
+ } ),
22
+ storeId: joi.array().optional(),
23
+ limit: joi.number().optional(),
24
+ offset: joi.number().optional(),
25
+ searchValue: joi.string().optional().allow( '' ),
26
+ isExport: joi.boolean().optional(),
27
+ sortBy: joi.string().optional(),
28
+ sortOrder: joi.number().optional(),
29
+ },
30
+ );
31
+
32
+ export const getListValid = {
33
+ body: getListSchema,
34
+ };
35
+
36
+ export const viewFileSchema = joi.object( {
37
+ id: joi.string().required(),
38
+ } );
39
+
40
+ export const viewFileValid = {
41
+ params: viewFileSchema,
42
+ };
43
+
44
+
45
+ export const getFileSchema = joi.object( {
46
+ id: joi.string().required(),
47
+ } );
48
+
49
+ export const getFileValid = {
50
+ params: getFileSchema,
51
+ };
52
+
53
+ export const saveSchema = joi.object( {
54
+ type: joi.string().required(),
55
+ fileId: joi.string().required(),
56
+ id: joi.string().required(),
57
+ steps: joi.array().required(),
58
+ auditedSteps: joi.number().required(),
59
+ auditStatus: joi.string().required(),
60
+ overRides: joi.number().required(),
61
+ spokenLanguage: joi.string().optional(),
62
+ } );
63
+
64
+ export const saveValid = {
65
+ body: saveSchema,
66
+ };
67
+
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
+
80
+ export const getFileHistorySchema = joi.object( {
81
+ id: joi.string().required(),
82
+ type: joi.string().required(),
83
+ } );
84
+
85
+ export const getFileHistoryValid = {
86
+ params: getFileHistorySchema,
87
+ };
88
+
89
+ export const userAuditedDataSchema = joi.object( {
90
+ id: joi.string().required(),
91
+ } );
92
+
93
+ export const userAuditedDataValid = {
94
+ params: userAuditedDataSchema,
95
+ };
96
+
97
+
@@ -0,0 +1,18 @@
1
+ import { Router } from 'express';
2
+ import { isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
3
+ import { accessVerification } from 'tango-app-api-middleware';
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
+
7
+ export const eyeTestAuditRouter = Router();
8
+
9
+ eyeTestAuditRouter.post( '/get-list', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( getListValid ), getList );
10
+ eyeTestAuditRouter.get( '/view-file/:id', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( viewFileValid ), viewFile );
11
+ eyeTestAuditRouter.get( '/get-file/:id', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( getFileValid ), getFile );
12
+ eyeTestAuditRouter.post( '/save', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( saveValid ), save );
13
+ eyeTestAuditRouter.post( '/cancel', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( cancelValid ), cancel );
14
+ eyeTestAuditRouter.get( '/get-file-history/:id/:type', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( getFileHistoryValid ), getFileHistory );
15
+ eyeTestAuditRouter.get( '/user-audited-data/:id', isAllowedSessionHandler, accessVerification( { userType: [ 'tango', 'client' ] } ), validate( userAuditedDataValid ), userAuditedData );
16
+
17
+
18
+ export default eyeTestAuditRouter;