tango-app-api-client 3.0.29-dev → 3.0.31-dev
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.0.
|
|
3
|
+
"version": "3.0.31-dev",
|
|
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.85",
|
|
29
29
|
"tango-app-api-middleware": "^1.0.54-dev",
|
|
30
30
|
"winston": "^3.11.0",
|
|
31
31
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { billingDetailsUpdate, brandInfoUpdate, domainDetailsConfigurationUpdate, featureConfigurationUpdate, getClientData, signatoryDetailsUpdate, ticketConfigurationUpdate, documentsUpdate, getUserData, auditConfigurationUpdate, auditConfigurationGet, CsmUsersGet, OpsUsersGet, userConfigurationUpdate, findClient, aggregateClient, createAuditQueue, findOne,
|
|
1
|
+
import { billingDetailsUpdate, brandInfoUpdate, domainDetailsConfigurationUpdate, featureConfigurationUpdate, getClientData, signatoryDetailsUpdate, ticketConfigurationUpdate, documentsUpdate, getUserData, auditConfigurationUpdate, auditConfigurationGet, CsmUsersGet, OpsUsersGet, userConfigurationUpdate, findClient, aggregateClient, createAuditQueue, findOne, insert, update, findOneClient } from '../service/client.service.js';
|
|
2
2
|
import { checkFileExist, fileUpload, signedUrl, chunkArray, download, logger, getOpenSearchData, insertOpenSearchData, appConfig, sendEmailWithSES } from 'tango-app-api-middleware';
|
|
3
|
-
import { countDocumentsUser, findOneAndUpdateUser, findOneUser, getUserNameEmailById } from '../service/user.service.js';
|
|
4
|
-
import { aggregateStore, countDocumentsStore } from '../service/store.service.js';
|
|
5
|
-
import { aggregateCamera, countDocumentsCamera } from '../service/camera.service.js';
|
|
3
|
+
import { countDocumentsUser, findOneAndUpdateUser, findOneUser, getUserNameEmailById, updateManyUser } from '../service/user.service.js';
|
|
4
|
+
import { aggregateStore, countDocumentsStore, updateManyStore } from '../service/store.service.js';
|
|
5
|
+
import { aggregateCamera, countDocumentsCamera, updateManyCamera } from '../service/camera.service.js';
|
|
6
6
|
import _ from 'lodash';
|
|
7
7
|
import { findOneStandaredRole } from '../service/standaredRole.service.js';
|
|
8
8
|
import { aggregateUserAssignedStore } from '../service/userAssignedStore.service.js';
|
|
@@ -11,13 +11,25 @@ import { join } from 'path';
|
|
|
11
11
|
import { readFileSync } from 'fs';
|
|
12
12
|
import handlebars from 'handlebars';
|
|
13
13
|
import { countDocumentsGroup } from '../service/group.service.js';
|
|
14
|
+
import { deleteOneAuthentication } from '../service/authentication.service.js';
|
|
15
|
+
|
|
14
16
|
|
|
15
17
|
export async function create( req, res ) {
|
|
16
18
|
try {
|
|
17
19
|
const inputData = req.body;
|
|
20
|
+
const countQuery = [
|
|
21
|
+
{
|
|
22
|
+
$sort: { createdAt: -1 },
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
$limit: 1,
|
|
26
|
+
},
|
|
27
|
+
];
|
|
28
|
+
const ID = await aggregateClient( countQuery );
|
|
29
|
+
const count = ID?.tangoId || 0;
|
|
18
30
|
const query = { clientName: inputData.clientName };
|
|
19
31
|
const leadRecord = await findOne( query );
|
|
20
|
-
const tangoId =
|
|
32
|
+
const tangoId = count + 1;
|
|
21
33
|
const generatedName = inputData.clientName.replace( /[^A-Z0-9]+/ig, '' );
|
|
22
34
|
const product = leadRecord?.planDetails?.product.map( ( value ) => ( { productName: value } ) );
|
|
23
35
|
const getPermission = await findOneStandaredRole( { roleName: 'superadmin', userType: 'client' }, { permission: 1 } );
|
|
@@ -44,7 +56,7 @@ export async function create( req, res ) {
|
|
|
44
56
|
'planDetails.totalCamera': leadRecord?.planDetails?.totalCamera,
|
|
45
57
|
'planDetails.subscriptionPeriod': leadRecord?.planDetails?.subscriptionPeriod,
|
|
46
58
|
'planDetails.subscriptionType': leadRecord?.planDetails?.subscriptionType,
|
|
47
|
-
'planDetails.paymentStatus': leadRecord?.planDetails?.
|
|
59
|
+
'planDetails.paymentStatus': leadRecord?.planDetails?.subscriptionType === 'free' ? 'free' : 'trial',
|
|
48
60
|
'planDetails.product': product,
|
|
49
61
|
'reportConfigs.reportName': generatedName,
|
|
50
62
|
'auditConfigs.queueName': generatedName,
|
|
@@ -52,13 +64,16 @@ export async function create( req, res ) {
|
|
|
52
64
|
};
|
|
53
65
|
|
|
54
66
|
const insertClient = await insert( record );
|
|
67
|
+
|
|
55
68
|
if ( insertClient ) {
|
|
56
69
|
const userRecord = {
|
|
57
70
|
role: 'superadmin',
|
|
58
71
|
userType: 'client',
|
|
72
|
+
refreshToken: null,
|
|
59
73
|
permission: getPermission?.permission,
|
|
60
74
|
clientId: String( tangoId ),
|
|
61
75
|
};
|
|
76
|
+
await deleteOneAuthentication( { user: user?._id, type: 'retail' } );
|
|
62
77
|
await findOneAndUpdateUser( userQuery, userRecord );
|
|
63
78
|
await createAuditQueue( generatedName );
|
|
64
79
|
return res.sendSuccess( { result: { clientId: String( tangoId ) } } );
|
|
@@ -255,7 +270,7 @@ export async function detailedAllClientCount( req, res ) {
|
|
|
255
270
|
trialClient: { $cond: [ { $eq: [ '$planDetails.paymentStatus', 'trial' ] }, 1, 0 ] },
|
|
256
271
|
freeClient: { $cond: [ { $eq: [ '$planDetails.paymentStatus', 'free' ] }, 1, 0 ] },
|
|
257
272
|
holdClient: { $cond: [ { $eq: [ '$status', 'hold' ] }, 1, 0 ] },
|
|
258
|
-
suspendClient: { $cond: [ { $eq: [ '$status', '
|
|
273
|
+
suspendClient: { $cond: [ { $eq: [ '$status', 'suspended' ] }, 1, 0 ] },
|
|
259
274
|
deactiveClient: { $cond: [ { $eq: [ '$status', 'deactive' ] }, 1, 0 ] },
|
|
260
275
|
},
|
|
261
276
|
},
|
|
@@ -335,6 +350,27 @@ export async function updateBrandInfo( req, res ) {
|
|
|
335
350
|
clientType: req.body?.clientType, registeredAddress: req.body?.registeredAddress, headQuarters: req.body?.headQuarters,
|
|
336
351
|
website: req.body?.website, status: req.body?.status, logo: req.files?.logo ? `brandLogo.${req.files.logo.name.split( '.' )[1]}` : undefined,
|
|
337
352
|
} );
|
|
353
|
+
|
|
354
|
+
if ( req.body?.status === 'active' ) {
|
|
355
|
+
await updateManyStore( { clientId: req.params?.id }, { status: 'active' } );
|
|
356
|
+
await updateManyUser( { clientId: req.params?.id }, { isActive: true } );
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
if ( req.body?.status === 'suspended' ) {
|
|
360
|
+
await updateManyStore( { clientId: req.params?.id }, { status: 'suspend' } );
|
|
361
|
+
await updateManyUser( { clientId: req.params?.id }, { isActive: false } );
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
if ( req.body?.status === 'hold' ) {
|
|
365
|
+
await updateManyUser( { clientId: req.params?.id }, { isActive: false } );
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
if ( req.body?.status === 'deactive' ) {
|
|
369
|
+
await updateManyStore( { clientId: req.params?.id }, { status: 'deactive' } );
|
|
370
|
+
await updateManyCamera( { clientId: req.params?.id }, { isUp: false, isActivated: false } );
|
|
371
|
+
await updateManyUser( { clientId: req.params?.id }, { isActive: false } );
|
|
372
|
+
}
|
|
373
|
+
|
|
338
374
|
if ( updateAck ) {
|
|
339
375
|
res.sendSuccess( { result: 'Updated Successfully' } );
|
|
340
376
|
}
|
|
@@ -19,3 +19,7 @@ export async function findOneAndUpdateUser( query, record ) {
|
|
|
19
19
|
export function getUserNameEmailById( objectId ) {
|
|
20
20
|
return userModel.findOne( { _id: objectId }, { userName: 1, email: 1, _id: 0 } );
|
|
21
21
|
}
|
|
22
|
+
|
|
23
|
+
export function updateManyUser( query, record ) {
|
|
24
|
+
return userModel.updateMany( query, { $set: record } );
|
|
25
|
+
}
|