tango-app-api-client 3.0.8 → 3.0.10-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.10-dev",
|
|
4
4
|
"description": "client",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"lodash": "^4.17.21",
|
|
24
24
|
"mongodb": "^6.3.0",
|
|
25
25
|
"nodemon": "^3.0.3",
|
|
26
|
-
"tango-api-schema": "^2.0.
|
|
27
|
-
"tango-app-api-middleware": "^1.0.
|
|
26
|
+
"tango-api-schema": "^2.0.53",
|
|
27
|
+
"tango-app-api-middleware": "^1.0.39-dev",
|
|
28
28
|
"winston": "^3.11.0",
|
|
29
29
|
"winston-daily-rotate-file": "^5.0.0"
|
|
30
30
|
},
|
|
@@ -15,16 +15,14 @@ export async function create( req, res ) {
|
|
|
15
15
|
const generatedName = inputData.clientName.replace( /[^A-Z0-9]+/ig, '' );
|
|
16
16
|
const product = leadRecord?.planDetails?.product.map( ( value ) => ( { productName: value } ) );
|
|
17
17
|
const getPermission = await findOneStandaredRole( { roleName: 'superadmin', userType: 'client' }, { permission: 1 } );
|
|
18
|
-
const userRecord = {
|
|
19
|
-
role: 'superadmin',
|
|
20
|
-
userType: 'client',
|
|
21
|
-
permission: getPermission?.permission,
|
|
22
|
-
};
|
|
23
18
|
const userQuery={
|
|
24
|
-
email:
|
|
19
|
+
email: leadRecord?.corporateEmail,
|
|
25
20
|
};
|
|
26
|
-
const user = await
|
|
27
|
-
|
|
21
|
+
const user = await findOneUser( userQuery );
|
|
22
|
+
if ( !user ) {
|
|
23
|
+
return res.sendError( { error: 'User doesnot exist' }, 500 );
|
|
24
|
+
}
|
|
25
|
+
logger.info( { message: user, function: 'findOneUser' } );
|
|
28
26
|
const record = {
|
|
29
27
|
'clientName': leadRecord.clientName,
|
|
30
28
|
'clientId': String( tangoId ),
|
|
@@ -44,6 +42,14 @@ export async function create( req, res ) {
|
|
|
44
42
|
|
|
45
43
|
const insertClient = await insert( record );
|
|
46
44
|
if ( insertClient ) {
|
|
45
|
+
const userRecord = {
|
|
46
|
+
role: 'superadmin',
|
|
47
|
+
userType: 'client',
|
|
48
|
+
permission: getPermission?.permission,
|
|
49
|
+
clientId: String( tangoId ),
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
await findOneAndUpdateUser( userQuery, userRecord );
|
|
47
53
|
await createAuditQueue( generatedName );
|
|
48
54
|
return res.sendSuccess( { result: { clientId: String( tangoId ) } } );
|
|
49
55
|
}
|
|
@@ -749,8 +755,8 @@ export async function clientList( req, res ) {
|
|
|
749
755
|
}
|
|
750
756
|
return list;
|
|
751
757
|
} );
|
|
752
|
-
const
|
|
753
|
-
clientList.flat();
|
|
758
|
+
const clientListResult = await Promise.all( promises );
|
|
759
|
+
const clientList= clientListResult.flat();
|
|
754
760
|
const storeQuery = [
|
|
755
761
|
{
|
|
756
762
|
$match: {
|
|
@@ -806,19 +812,19 @@ export async function clientList( req, res ) {
|
|
|
806
812
|
const list = [];
|
|
807
813
|
for ( let i = 0; i < chunk.length; i++ ) {
|
|
808
814
|
list.push( {
|
|
809
|
-
'client Name': chunk[i]
|
|
810
|
-
'client Id': chunk[i]
|
|
811
|
-
'Active Store': chunk[i]
|
|
812
|
-
'Active Camera': chunk[i]
|
|
813
|
-
'Payment Status': chunk[i]
|
|
814
|
-
'Subs Plan': chunk[i]
|
|
815
|
-
'Status': chunk[i]
|
|
815
|
+
'client Name': chunk[i]?.clientName,
|
|
816
|
+
'client Id': chunk[i]?.clientId,
|
|
817
|
+
'Active Store': chunk[i]?.activeStoreCount || 0,
|
|
818
|
+
'Active Camera': chunk[i]?.activeCameraCount && chunk[i]?.activeCameraCount!=undefined? chunk[i]?.activeCameraCount: 0,
|
|
819
|
+
'Payment Status': chunk[i]?.paymentStatus,
|
|
820
|
+
'Subs Plan': chunk[i]?.subscriptionType,
|
|
821
|
+
'Status': chunk[i]?.status,
|
|
816
822
|
} );
|
|
817
823
|
}
|
|
818
824
|
return list;
|
|
819
825
|
} );
|
|
820
|
-
const
|
|
821
|
-
exportResult.flat();
|
|
826
|
+
const temp = await Promise.all( promises );
|
|
827
|
+
const exportResult = temp.flat();
|
|
822
828
|
await download( exportResult, res );
|
|
823
829
|
return;
|
|
824
830
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import userModel from 'tango-api-schema/schema/user.model.js';
|
|
2
2
|
|
|
3
|
-
export function findOneUser( query ) {
|
|
4
|
-
return userModel.findOne( query );
|
|
3
|
+
export function findOneUser( query, field ) {
|
|
4
|
+
return userModel.findOne( query, field );
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export function countDocumentsUser( query ) {
|