tango-app-api-client 3.1.19 → 3.1.20-alpha.1
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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-client",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.20-alpha.1",
|
|
4
4
|
"description": "client",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"mongodb": "^6.3.0",
|
|
26
26
|
"nodemon": "^3.0.3",
|
|
27
27
|
"swagger-ui-express": "^5.0.0",
|
|
28
|
-
"tango-api-schema": "^2.0.
|
|
28
|
+
"tango-api-schema": "^2.0.161",
|
|
29
29
|
"tango-app-api-middleware": "^3.1.30",
|
|
30
30
|
"winston": "^3.11.0",
|
|
31
31
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { billingDetailsUpdate, brandInfoUpdate, domainDetailsConfigurationUpdate, featureConfigurationUpdate, getClientData, signatoryDetailsUpdate, ticketConfigurationUpdate, documentsUpdate, getUserData,
|
|
1
|
+
import { billingDetailsUpdate, brandInfoUpdate, domainDetailsConfigurationUpdate, featureConfigurationUpdate, getClientData, signatoryDetailsUpdate, ticketConfigurationUpdate, documentsUpdate, getUserData, CsmUsersGet, OpsUsersGet, userConfigurationUpdate, findClient, aggregateClient, createAuditQueue, findOne, insert, update, findOneClient, updateOneClient } from '../service/client.service.js';
|
|
2
2
|
import { checkFileExist, fileUpload, signedUrl, chunkArray, download, logger, getOpenSearchData, insertOpenSearchData, sendEmailWithSES, createCustomer, createVirtualAccount } from 'tango-app-api-middleware';
|
|
3
3
|
import { countDocumentsUser, findOneAndUpdateUser, findOneUser, getUserNameEmailById, updateManyUser } from '../service/user.service.js';
|
|
4
|
-
import { aggregateStore, countDocumentsStore, findStore,
|
|
4
|
+
import { aggregateStore, countDocumentsStore, findStore, updateManyStore } from '../service/store.service.js';
|
|
5
5
|
import { aggregateCamera, countDocumentsCamera } from '../service/camera.service.js';
|
|
6
6
|
import _ from 'lodash';
|
|
7
7
|
import { findOneStandaredRole } from '../service/standaredRole.service.js';
|
|
8
|
-
import { aggregateUserAssignedStore,
|
|
8
|
+
import { aggregateUserAssignedStore, updateOneUserAssignedStore } from '../service/userAssignedStore.service.js';
|
|
9
9
|
import { aggregateTickets } from '../service/tangoticket.service.js';
|
|
10
10
|
import { join } from 'path';
|
|
11
11
|
import { readFileSync } from 'fs';
|
|
@@ -356,18 +356,18 @@ export async function getClients( req, res ) {
|
|
|
356
356
|
$match: {
|
|
357
357
|
userEmail: req?.user?.email,
|
|
358
358
|
assignedType: { $eq: 'client' },
|
|
359
|
-
$expr: {
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
},
|
|
359
|
+
// $expr: {
|
|
360
|
+
// $cond: {
|
|
361
|
+
// if: {
|
|
362
|
+
// $and: [
|
|
363
|
+
// { $eq: [ '$userType', 'tango' ] },
|
|
364
|
+
// { $eq: [ '$tangoUserType', 'csm' ] },
|
|
365
|
+
// ],
|
|
366
|
+
// },
|
|
367
|
+
// then: { $eq: [ '$isClientApproved', true ] },
|
|
368
|
+
// else: true,
|
|
369
|
+
// },
|
|
370
|
+
// },
|
|
371
371
|
},
|
|
372
372
|
},
|
|
373
373
|
{
|
|
@@ -1093,67 +1093,75 @@ export async function updateDocuments( req, res ) {
|
|
|
1093
1093
|
|
|
1094
1094
|
export async function getAuditConfiguration( req, res ) {
|
|
1095
1095
|
try {
|
|
1096
|
-
const
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
res.sendError( '
|
|
1096
|
+
const query ={
|
|
1097
|
+
clientId: req.params?.id,
|
|
1098
|
+
};
|
|
1099
|
+
const fields = {
|
|
1100
|
+
'auditConfigs.count': 1,
|
|
1101
|
+
'auditConfigs.audit': 1,
|
|
1102
|
+
'auditConfigs.ratio': 1,
|
|
1103
|
+
'clientId': 1,
|
|
1104
|
+
'_id': 0,
|
|
1105
|
+
};
|
|
1106
|
+
const auditConfig = await findOneClient( query, fields );
|
|
1107
|
+
if ( !auditConfig ) {
|
|
1108
|
+
return res.sendError( 'Client not Found', 204 );
|
|
1109
1109
|
}
|
|
1110
|
+
return res.sendSuccess( auditConfig );
|
|
1110
1111
|
} catch ( error ) {
|
|
1112
|
+
const err = error.message || 'Internal Server Error';
|
|
1111
1113
|
logger.error( { error: error, message: req.params, function: 'getAuditConfiguration' } );
|
|
1112
|
-
return res.sendError(
|
|
1114
|
+
return res.sendError( err, 500 );
|
|
1113
1115
|
}
|
|
1114
1116
|
}
|
|
1115
1117
|
|
|
1116
1118
|
|
|
1117
1119
|
export async function auditConfiguration( req, res ) {
|
|
1118
1120
|
try {
|
|
1121
|
+
const inputData = req.body;
|
|
1119
1122
|
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1123
|
+
const query ={
|
|
1124
|
+
clientId: req.params?.id,
|
|
1125
|
+
};
|
|
1126
|
+
const fields ={
|
|
1127
|
+
auditConfigs: 1, _id: 0,
|
|
1128
|
+
};
|
|
1129
|
+
const previousClient = await findOneClient( query, fields );
|
|
1130
|
+
const record ={
|
|
1131
|
+
'auditConfigs.count': inputData.count,
|
|
1132
|
+
'auditConfigs.audit': inputData.audit,
|
|
1133
|
+
'auditConfigs.ratio': Number( normalizeNumber( inputData.ratio, 0, 100 ) ),
|
|
1134
|
+
};
|
|
1135
|
+
logger.info( { record: record, query: query } );
|
|
1136
|
+
const a = await updateOneClient( query, record );
|
|
1137
|
+
logger.info( { a: a } );
|
|
1138
|
+
const logObj = {
|
|
1139
|
+
clientId: req.params?.id,
|
|
1140
|
+
userName: req.user?.userName,
|
|
1141
|
+
email: req.user?.email,
|
|
1142
|
+
date: new Date(),
|
|
1143
|
+
logType: 'configuration',
|
|
1144
|
+
logSubType: 'auditConfig',
|
|
1145
|
+
eventType: 'update',
|
|
1146
|
+
showTo: [ 'tango' ],
|
|
1147
|
+
changes: [ `Audit config for client id ${req.params?.id}` ],
|
|
1148
|
+
previous: previousClient,
|
|
1149
|
+
current: {
|
|
1130
1150
|
clientId: req.params?.id,
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
eventType: 'update',
|
|
1137
|
-
showTo: [ 'tango' ],
|
|
1138
|
-
changes: [ `Audit config for store id ${req.body[i].storeId}` ],
|
|
1139
|
-
storeId: req.body[i].storeId,
|
|
1140
|
-
previous: previousStore,
|
|
1141
|
-
current: {
|
|
1142
|
-
storeId: req.body[i].storeId,
|
|
1143
|
-
count: req.body[i].count,
|
|
1144
|
-
iteration: req.body[i].iteration,
|
|
1145
|
-
ratio: normalizeNumber( req.body[i].ratio, 0, 100 ),
|
|
1146
|
-
},
|
|
1147
|
-
};
|
|
1151
|
+
count: inputData.count,
|
|
1152
|
+
audit: inputData.audit,
|
|
1153
|
+
ratio: normalizeNumber( inputData.ratio, 0, 100 ),
|
|
1154
|
+
},
|
|
1155
|
+
};
|
|
1148
1156
|
|
|
1149
|
-
|
|
1150
|
-
}
|
|
1157
|
+
await insertOpenSearchData( openSearch.activityLog, logObj );
|
|
1151
1158
|
|
|
1152
1159
|
|
|
1153
|
-
res.sendSuccess( { result: 'Updated Successfully' } );
|
|
1160
|
+
return res.sendSuccess( { result: 'Updated Successfully' } );
|
|
1154
1161
|
} catch ( error ) {
|
|
1162
|
+
const err = message.error || 'Internal Server Error';
|
|
1155
1163
|
logger.error( { error: error, message: req.params, function: 'auditConfiguration' } );
|
|
1156
|
-
return res.sendError(
|
|
1164
|
+
return res.sendError( err, 500 );
|
|
1157
1165
|
}
|
|
1158
1166
|
}
|
|
1159
1167
|
|
|
@@ -1186,17 +1194,17 @@ export async function clientList( req, res ) {
|
|
|
1186
1194
|
$match: {
|
|
1187
1195
|
userEmail: { $eq: req?.user?.email },
|
|
1188
1196
|
userType: 'tango',
|
|
1189
|
-
$expr: {
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
},
|
|
1197
|
+
// $expr: {
|
|
1198
|
+
// $cond: {
|
|
1199
|
+
// if: {
|
|
1200
|
+
// $and: [
|
|
1201
|
+
// { $eq: [ '$tangoUserType', 'csm' ] },
|
|
1202
|
+
// ],
|
|
1203
|
+
// },
|
|
1204
|
+
// then: { $eq: [ '$isClientApproved', true ] },
|
|
1205
|
+
// else: true,
|
|
1206
|
+
// },
|
|
1207
|
+
// },
|
|
1200
1208
|
|
|
1201
1209
|
},
|
|
1202
1210
|
}, {
|
|
@@ -1512,17 +1520,17 @@ export async function clientListV1( req, res ) {
|
|
|
1512
1520
|
$match: {
|
|
1513
1521
|
userEmail: { $eq: req?.user?.email },
|
|
1514
1522
|
userType: 'tango',
|
|
1515
|
-
$expr: {
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
},
|
|
1523
|
+
// $expr: {
|
|
1524
|
+
// $cond: {
|
|
1525
|
+
// if: {
|
|
1526
|
+
// $and: [
|
|
1527
|
+
// { $eq: [ '$tangoUserType', 'csm' ] },
|
|
1528
|
+
// ],
|
|
1529
|
+
// },
|
|
1530
|
+
// then: { $eq: [ '$isClientApproved', true ] },
|
|
1531
|
+
// else: true,
|
|
1532
|
+
// },
|
|
1533
|
+
// },
|
|
1526
1534
|
|
|
1527
1535
|
},
|
|
1528
1536
|
},
|
|
@@ -2048,7 +2056,7 @@ export async function clientCsmAssignAction( req, res ) {
|
|
|
2048
2056
|
}
|
|
2049
2057
|
|
|
2050
2058
|
if ( req.body.action === 'decline' ) {
|
|
2051
|
-
await deleteOneAssignedStore( { clientId: req.query.clientId, tangoUserType: 'csm', assignedType: 'client' } );
|
|
2059
|
+
// await deleteOneAssignedStore( { clientId: req.query.clientId, tangoUserType: 'csm', assignedType: 'client' } );
|
|
2052
2060
|
}
|
|
2053
2061
|
|
|
2054
2062
|
res.sendSuccess( 'Updated Succesfully' );
|
package/src/docs/client.docs.js
CHANGED
|
@@ -319,14 +319,14 @@ export const clientDocs = {
|
|
|
319
319
|
'/v3/client/audit-configuration/{id}': {
|
|
320
320
|
get: {
|
|
321
321
|
tags: [ 'Client' ],
|
|
322
|
-
description: 'Get audit configuration by
|
|
322
|
+
description: 'Get audit configuration by client id',
|
|
323
323
|
operationId: 'get-audit-configuration',
|
|
324
324
|
parameters: [
|
|
325
325
|
{
|
|
326
326
|
in: 'path',
|
|
327
327
|
name: 'id',
|
|
328
328
|
required: true,
|
|
329
|
-
description: 'The ID of the
|
|
329
|
+
description: 'The ID of the client.',
|
|
330
330
|
schema: {
|
|
331
331
|
type: 'string',
|
|
332
332
|
},
|
|
@@ -340,9 +340,6 @@ export const clientDocs = {
|
|
|
340
340
|
204: { description: 'Not Found' },
|
|
341
341
|
},
|
|
342
342
|
},
|
|
343
|
-
},
|
|
344
|
-
|
|
345
|
-
'/v3/client/audit-configuration/{id}': {
|
|
346
343
|
post: {
|
|
347
344
|
tags: [ 'Client' ],
|
|
348
345
|
description: 'Audit configuration settings',
|
|
@@ -351,7 +348,7 @@ export const clientDocs = {
|
|
|
351
348
|
in: 'path',
|
|
352
349
|
name: 'id',
|
|
353
350
|
required: true,
|
|
354
|
-
description: 'The ID of the
|
|
351
|
+
description: 'The ID of the client.',
|
|
355
352
|
schema: {
|
|
356
353
|
type: 'string',
|
|
357
354
|
},
|
package/src/dtos/client.dtos.js
CHANGED
|
@@ -206,16 +206,11 @@ export const getAuditConfigValid = {
|
|
|
206
206
|
};
|
|
207
207
|
|
|
208
208
|
|
|
209
|
-
export const auditConfigSchemaBody = joi.
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
iteration: joi.number().required(),
|
|
215
|
-
storeId: joi.string().required(),
|
|
216
|
-
},
|
|
217
|
-
).required(),
|
|
218
|
-
).required();
|
|
209
|
+
export const auditConfigSchemaBody = joi.object( {
|
|
210
|
+
ratio: joi.number().required(),
|
|
211
|
+
count: joi.number().required(),
|
|
212
|
+
audit: joi.boolean().required(),
|
|
213
|
+
} );
|
|
219
214
|
|
|
220
215
|
export const auditConfigSchemaParam = joi.object( {
|
|
221
216
|
id: joi.string().required(),
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import clientModel from 'tango-api-schema/schema/client.model.js';
|
|
2
2
|
import leadModel from 'tango-api-schema/schema/lead.model.js';
|
|
3
|
-
import storeModel from 'tango-api-schema/schema/store.model.js';
|
|
4
3
|
import userModel from 'tango-api-schema/schema/user.model.js';
|
|
5
4
|
import { createQueue, getQueueUrl, logger } from 'tango-app-api-middleware';
|
|
6
5
|
|
|
@@ -197,27 +196,6 @@ export function documentsUpdate( { clientId, gstNumber, panNumber, cinNumber, ad
|
|
|
197
196
|
} );
|
|
198
197
|
}
|
|
199
198
|
|
|
200
|
-
export function auditConfigurationGet( { storeId } ) {
|
|
201
|
-
return storeModel.findOne( { storeId: storeId },
|
|
202
|
-
{
|
|
203
|
-
'auditConfigs.count': 1,
|
|
204
|
-
'auditConfigs.iteration': 1,
|
|
205
|
-
'auditConfigs.ratio': 1,
|
|
206
|
-
'storeId': 1,
|
|
207
|
-
'_id': 0,
|
|
208
|
-
} );
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
export function auditConfigurationUpdate( { storeId, count, iteration, ratio } ) {
|
|
212
|
-
return storeModel.updateOne( { storeId: storeId },
|
|
213
|
-
{
|
|
214
|
-
$set: {
|
|
215
|
-
'auditConfigs.count': count,
|
|
216
|
-
'auditConfigs.iteration': iteration,
|
|
217
|
-
'auditConfigs.ratio': ratio,
|
|
218
|
-
},
|
|
219
|
-
} );
|
|
220
|
-
}
|
|
221
199
|
|
|
222
200
|
export function CsmUsersGet( ) {
|
|
223
201
|
return userModel.aggregate(
|