tango-app-api-infra 3.9.5-vms.6 → 3.9.5-vms.61
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.
|
@@ -3,9 +3,25 @@ import dayjs from 'dayjs';
|
|
|
3
3
|
|
|
4
4
|
export const createTicketSchema = Joi.object().keys( {
|
|
5
5
|
|
|
6
|
-
dateString: Joi.string().required(),
|
|
6
|
+
dateString: Joi.string().required().custom( ( value, helpers ) => {
|
|
7
|
+
const inputDate = dayjs( value, 'YYYY-MM-DD', true );
|
|
8
|
+
const today = dayjs();
|
|
9
|
+
|
|
10
|
+
if ( !inputDate.isValid() ) {
|
|
11
|
+
return helpers.error( 'any.invalid' );
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const diff = today.diff( inputDate, 'day' );
|
|
15
|
+
|
|
16
|
+
if ( diff > 3 ) {
|
|
17
|
+
return helpers.message( 'Ticket Creation is not allowed for a period exceeding 3 days' );
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return value;
|
|
21
|
+
} ),
|
|
7
22
|
storeId: Joi.string().required(),
|
|
8
23
|
ticketName: Joi.string().required(),
|
|
24
|
+
comments: Joi.string().optional(),
|
|
9
25
|
type: Joi.string()
|
|
10
26
|
.required()
|
|
11
27
|
.valid( 'create', 'review', 'approve', 'tangRreview' )
|
|
@@ -23,6 +39,40 @@ export const createTicketValid = {
|
|
|
23
39
|
body: createTicketSchema,
|
|
24
40
|
};
|
|
25
41
|
|
|
42
|
+
export const tangoReviewTicketSchema = Joi.object().keys( {
|
|
43
|
+
|
|
44
|
+
dateString: Joi.string().required().custom( ( value, helpers ) => {
|
|
45
|
+
const inputDate = dayjs( value, 'YYYY-MM-DD', true );
|
|
46
|
+
|
|
47
|
+
if ( !inputDate.isValid() ) {
|
|
48
|
+
return helpers.error( 'any.invalid' );
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return value;
|
|
52
|
+
} ),
|
|
53
|
+
storeId: Joi.string().required(),
|
|
54
|
+
comments: Joi.string().optional(),
|
|
55
|
+
ticketType: Joi.string().optional(),
|
|
56
|
+
mappingInfo: Joi.object().keys( {
|
|
57
|
+
type: Joi.string().required(),
|
|
58
|
+
mode: Joi.string().required(),
|
|
59
|
+
revicedFootfall: Joi.number().required(),
|
|
60
|
+
revicedPerc: Joi.string().required(),
|
|
61
|
+
count: Joi.array().required(),
|
|
62
|
+
revisedDetail: Joi.array().required(),
|
|
63
|
+
createdByEmail: Joi.string().optional(),
|
|
64
|
+
createdByUserName: Joi.string().optional(),
|
|
65
|
+
createdByRole: Joi.string().optional(),
|
|
66
|
+
status: Joi.string().optional(),
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
} ).required(),
|
|
70
|
+
} );
|
|
71
|
+
|
|
72
|
+
export const tangoReviewTicketValid = {
|
|
73
|
+
body: tangoReviewTicketSchema,
|
|
74
|
+
};
|
|
75
|
+
|
|
26
76
|
export const ticketSummarySchema = Joi.object().keys( {
|
|
27
77
|
clientId: Joi.string().required(),
|
|
28
78
|
|
|
@@ -93,8 +143,16 @@ export const ticketListSchema = Joi.object().keys( {
|
|
|
93
143
|
offset: Joi.number().optional(),
|
|
94
144
|
isExport: Joi.boolean().optional(),
|
|
95
145
|
sortBy: Joi.string().optional().allow( '' ),
|
|
146
|
+
status: Joi.array().items( Joi.string().required() ).optional(),
|
|
96
147
|
sortOrder: Joi.number().valid( -1, 1 ).optional(),
|
|
97
148
|
tangoType: Joi.string().valid( 'store', 'internal', '' ).optional(),
|
|
149
|
+
permissionType: Joi.string().valid( 'review', 'approve' ).optional(),
|
|
150
|
+
filterByStatus: Joi.array().items( Joi.string().required() ).optional(),
|
|
151
|
+
filterByReviewer: Joi.string().optional(),
|
|
152
|
+
filterByApprover: Joi.string().optional(),
|
|
153
|
+
filterByTango: Joi.string().optional(),
|
|
154
|
+
filterByReviewedBy: Joi.array().items( Joi.string().required() ).optional(),
|
|
155
|
+
fileterByApprovedBy: Joi.array().items( Joi.string().required() ).optional(),
|
|
98
156
|
fromDate: Joi.string()
|
|
99
157
|
.pattern( /^\d{4}-\d{2}-\d{2}$/, 'YYYY-MM-DD format' )
|
|
100
158
|
.required()
|
|
@@ -154,73 +212,75 @@ export const ticketListValid = {
|
|
|
154
212
|
};
|
|
155
213
|
|
|
156
214
|
export const getTicketsSchema = Joi.object().keys( {
|
|
157
|
-
storeId: Joi.string().required().allow( '' ),
|
|
158
|
-
dateString: Joi.string().
|
|
159
|
-
fromDate: Joi.string()
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
toDate: Joi.string()
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
215
|
+
// storeId: Joi.string().required().allow( '' ),
|
|
216
|
+
// dateString: Joi.string().required(),
|
|
217
|
+
// fromDate: Joi.string()
|
|
218
|
+
// .pattern( /^\d{4}-\d{2}-\d{2}$/, 'YYYY-MM-DD format' )
|
|
219
|
+
// .required()
|
|
220
|
+
// .messages( {
|
|
221
|
+
// 'string.pattern.name': `'fromDate' must be in the format YYYY-MM-DD (e.g., 2025-07-19).`,
|
|
222
|
+
// 'string.empty': `'fromDate' is required.`,
|
|
223
|
+
// } )
|
|
224
|
+
// .custom( ( value, helpers ) => {
|
|
225
|
+
// const from = dayjs( value );
|
|
226
|
+
// if ( !from.isValid() ) {
|
|
227
|
+
// return helpers.error( 'any.invalid', { message: 'Invalid fromDate' } );
|
|
228
|
+
// }
|
|
229
|
+
// return value;
|
|
230
|
+
// } ),
|
|
231
|
+
|
|
232
|
+
// toDate: Joi.string()
|
|
233
|
+
// .pattern( /^\d{4}-\d{2}-\d{2}$/, 'YYYY-MM-DD format' )
|
|
234
|
+
// .required()
|
|
235
|
+
// .messages( {
|
|
236
|
+
// 'string.pattern.name': `'toDate' must be in the format YYYY-MM-DD (e.g., 2025-07-19).`,
|
|
237
|
+
// 'string.empty': `'toDate' is required.`,
|
|
238
|
+
// } )
|
|
239
|
+
// .custom( ( value, helpers ) => {
|
|
240
|
+
// const to = dayjs( value );
|
|
241
|
+
// const today = dayjs();
|
|
242
|
+
|
|
243
|
+
// if ( !to.isValid() ) {
|
|
244
|
+
// return helpers.error( 'any.invalid', { message: 'Invalid toDate' } );
|
|
245
|
+
// }
|
|
246
|
+
// if ( to.isAfter( today, 'day' ) ) {
|
|
247
|
+
// return helpers.error( 'any.invalid', { message: 'toDate cannot be in the future' } );
|
|
248
|
+
// }
|
|
249
|
+
|
|
250
|
+
// return value;
|
|
251
|
+
// } ),
|
|
252
|
+
ticketId: Joi.string().required(),
|
|
253
|
+
// status: Joi.string().optional(),
|
|
195
254
|
action: Joi.string().optional(),
|
|
196
|
-
revopsType: Joi.string().optional(),
|
|
197
|
-
limit: Joi.number().required(),
|
|
198
|
-
offset: Joi.number().optional(),
|
|
255
|
+
// revopsType: Joi.string().optional(),
|
|
256
|
+
// limit: Joi.number().required(),
|
|
257
|
+
// offset: Joi.number().optional(),
|
|
199
258
|
|
|
200
|
-
} )
|
|
201
|
-
|
|
202
|
-
|
|
259
|
+
} );
|
|
260
|
+
// .custom( ( value, helpers ) => {
|
|
261
|
+
// const from = dayjs( value.fromDate );
|
|
262
|
+
// const to = dayjs( value.toDate );
|
|
203
263
|
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
264
|
+
// if ( !from.isValid() || !to.isValid() ) {
|
|
265
|
+
// return helpers.error( 'any.invalid', { message: 'Invalid dates' } );
|
|
266
|
+
// }
|
|
207
267
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
268
|
+
// if ( from.isAfter( to ) ) {
|
|
269
|
+
// return helpers.error( 'any.invalid', { message: 'fromDate cannot be after toDate' } );
|
|
270
|
+
// }
|
|
211
271
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
272
|
+
// if ( to.diff( from, 'day' ) > 90 ) {
|
|
273
|
+
// return helpers.error( 'any.invalid', { message: 'Date range cannot exceed 90 days' } );
|
|
274
|
+
// }
|
|
215
275
|
|
|
216
|
-
|
|
217
|
-
} );
|
|
276
|
+
// return value;
|
|
277
|
+
// } );
|
|
218
278
|
|
|
219
279
|
export const getTicketsValid = {
|
|
220
280
|
query: getTicketsSchema,
|
|
221
281
|
};
|
|
222
282
|
|
|
223
|
-
export const updateStatusSchemea =Joi.object().keys( {
|
|
283
|
+
export const updateStatusSchemea = Joi.object().keys( {
|
|
224
284
|
data: Joi.array().items(
|
|
225
285
|
Joi.object( {
|
|
226
286
|
_id: Joi.string().required(),
|
|
@@ -442,6 +502,7 @@ export const downloadTicketsValid = {
|
|
|
442
502
|
|
|
443
503
|
export const reviewerListSchema = Joi.object().keys( {
|
|
444
504
|
clientId: Joi.string().required(),
|
|
505
|
+
type: Joi.string().required().allow( 'approve', 'review' ),
|
|
445
506
|
} );
|
|
446
507
|
|
|
447
508
|
export const reviewerListValid = {
|
|
@@ -454,6 +515,8 @@ export const openTicketListSchema = Joi.object().keys( {
|
|
|
454
515
|
clientId: Joi.array().items(
|
|
455
516
|
Joi.string().required(),
|
|
456
517
|
).required(),
|
|
518
|
+
type: Joi.string().required().allow( 'review', 'approve' ),
|
|
519
|
+
sortOrder: Joi.number().allow( 1, -1 ).optional(),
|
|
457
520
|
|
|
458
521
|
|
|
459
522
|
} );
|
|
@@ -463,16 +526,55 @@ export const openTicketListValid = {
|
|
|
463
526
|
};
|
|
464
527
|
|
|
465
528
|
|
|
466
|
-
export const
|
|
529
|
+
export const assignTicketSchema = Joi.object().keys( {
|
|
467
530
|
email: Joi.string().required(),
|
|
468
531
|
userName: Joi.string().optional(),
|
|
469
532
|
role: Joi.string().optional(),
|
|
470
533
|
actionType: Joi.string().required(),
|
|
471
|
-
|
|
534
|
+
storeId: Joi.string().required(),
|
|
535
|
+
dateString: Joi.string().required(),
|
|
536
|
+
|
|
537
|
+
|
|
538
|
+
} );
|
|
539
|
+
|
|
540
|
+
export const assignTicketValid = {
|
|
541
|
+
body: assignTicketSchema,
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
export const updateTempStatusSchema = Joi.object().keys( {
|
|
545
|
+
id: Joi.array().items( Joi.string().required() ).required(),
|
|
546
|
+
status: Joi.string().required(),
|
|
547
|
+
type: Joi.string().required().allow( 'review', 'approve' ),
|
|
548
|
+
comments: Joi.string().optional().allow( '' ),
|
|
549
|
+
|
|
550
|
+
|
|
551
|
+
} );
|
|
552
|
+
|
|
553
|
+
export const updateTempStatusValid = {
|
|
554
|
+
body: updateTempStatusSchema,
|
|
555
|
+
};
|
|
556
|
+
|
|
557
|
+
export const updateTicketStatusSchema = Joi.object().keys( {
|
|
558
|
+
storeId: Joi.string().required(),
|
|
559
|
+
dateString: Joi.string().required(),
|
|
560
|
+
mode: Joi.string().required(),
|
|
561
|
+
|
|
562
|
+
} );
|
|
563
|
+
|
|
564
|
+
export const updateTicketStatusValid = {
|
|
565
|
+
body: updateTicketStatusSchema,
|
|
566
|
+
};
|
|
567
|
+
|
|
568
|
+
export const multiCloseTicketSchema = Joi.object().keys( {
|
|
472
569
|
|
|
570
|
+
ticketList: Joi.array().items( Joi.object().keys( {
|
|
571
|
+
storeId: Joi.string().required(),
|
|
572
|
+
dateString: Joi.string().required(),
|
|
573
|
+
} ) ),
|
|
574
|
+
mode: Joi.string().required(),
|
|
473
575
|
|
|
474
576
|
} );
|
|
475
577
|
|
|
476
|
-
export const
|
|
477
|
-
body:
|
|
578
|
+
export const multiCloseTicketValid = {
|
|
579
|
+
body: multiCloseTicketSchema,
|
|
478
580
|
};
|
|
@@ -1,12 +1,17 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
|
-
import { getClusters, getConfig, isGrantedUsers, isTicketExists, ticketCreation } from '../validations/footfallDirectory.validation.js';
|
|
3
|
-
import { createTicket, downloadTickets, getTaggedStores, getTickets, openTicketList, reviewerList, ticketList, ticketSummary,
|
|
4
|
-
import { createTicketValid, downloadTicketsValid, getTaggedStoresValid, getTicketsValid, openTicketListValid, reviewerListValid, ticketListValid, ticketSummaryValid, updateStatusValid,
|
|
2
|
+
import { getClusters, getConfig, isGrantedUsers, isTicketExists, ticketApprove, ticketCreation, ticketReview } from '../validations/footfallDirectory.validation.js';
|
|
3
|
+
import { assignTicket, createTicket, downloadTickets, getTaggedStores, getTickets, multiCloseTicket, openTicketList, reviewerList, tangoReviewTicket, ticketList, ticketSummary, updateStatus, updateTempStatus, updateUserTicketStatus, createinternalTicket, checkTicketExists } from '../controllers/footfallDirectory.controllers.js';
|
|
4
|
+
import { createTicketValid, downloadTicketsValid, getTaggedStoresValid, getTicketsValid, openTicketListValid, reviewerListValid, ticketListValid, ticketSummaryValid, updateStatusValid, assignTicketValid, updateTempStatusValid, updateTicketStatusValid, tangoReviewTicketValid, multiCloseTicketValid } from '../dtos/footfallDirectory.dtos.js';
|
|
5
5
|
import { bulkValidate, getAssinedStore, isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
|
|
6
6
|
|
|
7
7
|
export const footfallDirectoryRouter = express.Router();
|
|
8
8
|
|
|
9
|
-
footfallDirectoryRouter.post( '/create-ticket', isAllowedSessionHandler, validate( createTicketValid ), isGrantedUsers, getConfig, ticketCreation, createTicket );
|
|
9
|
+
footfallDirectoryRouter.post( '/create-ticket', isAllowedSessionHandler, validate( createTicketValid ), isGrantedUsers, getConfig, ticketCreation, ticketReview, ticketApprove, createTicket );
|
|
10
|
+
footfallDirectoryRouter.post( '/create-internalticket', isAllowedSessionHandler, createinternalTicket );
|
|
11
|
+
footfallDirectoryRouter.post( '/checkTicketExists', isAllowedSessionHandler, checkTicketExists );
|
|
12
|
+
|
|
13
|
+
footfallDirectoryRouter.post( '/tango-review-ticket', isAllowedSessionHandler, validate( tangoReviewTicketValid ), tangoReviewTicket );
|
|
14
|
+
|
|
10
15
|
footfallDirectoryRouter.get( '/ticket-summary', isAllowedSessionHandler, bulkValidate( ticketSummaryValid ), ticketSummary );
|
|
11
16
|
|
|
12
17
|
footfallDirectoryRouter.get( '/ticket-list', isAllowedSessionHandler, bulkValidate( ticketListValid ), ticketList );
|
|
@@ -17,6 +22,9 @@ footfallDirectoryRouter.put( '/update-status', isAllowedSessionHandler, bulkVali
|
|
|
17
22
|
footfallDirectoryRouter.get( '/download-tickets', isAllowedSessionHandler, bulkValidate( downloadTicketsValid ), isTicketExists, downloadTickets );
|
|
18
23
|
footfallDirectoryRouter.get( '/reviewer-list', isAllowedSessionHandler, bulkValidate( reviewerListValid ), reviewerList );
|
|
19
24
|
footfallDirectoryRouter.post( '/open-ticket-list', isAllowedSessionHandler, bulkValidate( openTicketListValid ), openTicketList );
|
|
20
|
-
footfallDirectoryRouter.post( '/
|
|
25
|
+
footfallDirectoryRouter.post( '/assign-ticket', isAllowedSessionHandler, bulkValidate( assignTicketValid ), assignTicket );
|
|
26
|
+
footfallDirectoryRouter.post( '/update-temp-status', isAllowedSessionHandler, bulkValidate( updateTempStatusValid ), updateTempStatus );
|
|
27
|
+
footfallDirectoryRouter.post( '/update-ticket-status', isAllowedSessionHandler, bulkValidate( updateTicketStatusValid ), updateUserTicketStatus );
|
|
28
|
+
footfallDirectoryRouter.post( '/multi-close-tickets', isAllowedSessionHandler, bulkValidate( multiCloseTicketValid ), multiCloseTicket );
|
|
21
29
|
|
|
22
30
|
|