tango-app-api-client 3.0.6 → 3.0.7

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.6",
3
+ "version": "3.0.7",
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.44",
27
- "tango-app-api-middleware": "^1.0.29",
26
+ "tango-api-schema": "^2.0.50",
27
+ "tango-app-api-middleware": "^1.0.30",
28
28
  "winston": "^3.11.0",
29
29
  "winston-daily-rotate-file": "^5.0.0"
30
30
  },
@@ -1,6 +1,6 @@
1
1
  import { billingDetailsUpdate, brandInfoUpdate, domainDetailsConfigurationUpdate, featureConfigurationUpdate, getClientData, signatoryDetailsUpdate, ticketConfigurationUpdate, documentsUpdate, getUserData, auditConfigurationUpdate, auditConfigurationGet, CsmUsersGet, OpsUsersGet, userConfigurationUpdate, findClient, aggregateClient, createAuditQueue, findOne, getClientCount, insert, update } from '../service/client.service.js';
2
- import { checkFileExist, fileUpload, signedUrl, chunkArray, download, logger, encrypt, getOpenSearchData, insertOpenSearchData } from 'tango-app-api-middleware';
3
- import { countDocumentsUser, createUser, findOneUser, getUserNameEmailById } from '../service/user.service.js';
2
+ import { checkFileExist, fileUpload, signedUrl, chunkArray, download, logger, getOpenSearchData, insertOpenSearchData } from 'tango-app-api-middleware';
3
+ import { countDocumentsUser, findOneAndUpdateUser, findOneUser, getUserNameEmailById } from '../service/user.service.js';
4
4
  import { aggregateStore, countDocumentsStore } from '../service/store.service.js';
5
5
  import { aggregateCamera, countDocumentsCamera } from '../service/camera.service.js';
6
6
  import _ from 'lodash';
@@ -14,18 +14,17 @@ export async function create( req, res ) {
14
14
  const tangoId = await getClientCount() + 1;
15
15
  const generatedName = inputData.clientName.replace( /[^A-Z0-9]+/ig, '' );
16
16
  const product = leadRecord?.planDetails?.product.map( ( value ) => ( { productName: value } ) );
17
- const password = await encrypt( leadRecord?.mobileNumber.toString() );
18
- const getPermission = await findOneStandaredRole( { roleName: 'superadmin', clientType: 'client' }, { permission: 1 } );
17
+ const getPermission = await findOneStandaredRole( { roleName: 'superadmin', userType: 'client' }, { permission: 1 } );
19
18
  const userRecord = {
20
- userName: leadRecord?.lastName ? `${inputData.firstName}${inputData.lastName}` : inputData?.firstName,
21
- email: leadRecord?.corporateEmail,
22
- password: password,
23
- mobileNumber: leadRecord?.mobileNumber,
24
19
  role: 'superadmin',
25
20
  userType: 'client',
26
21
  permission: getPermission?.permission,
27
22
  };
28
- const user = await createUser( userRecord );
23
+ const userQuery={
24
+ email: inputData?.corporateEmail,
25
+ };
26
+ const user = await findOneAndUpdateUser( userQuery, userRecord );
27
+ logger.info( { message: user } );
29
28
  const record = {
30
29
  'clientName': leadRecord.clientName,
31
30
  'clientId': String( tangoId ),
@@ -12,6 +12,10 @@ export async function createUser( record ) {
12
12
  return userModel.create( record );
13
13
  }
14
14
 
15
+ export async function findOneAndUpdateUser( query, record ) {
16
+ return userModel.findOneAndUpdate( query, record );
17
+ }
18
+
15
19
  export function getUserNameEmailById( objectId ) {
16
20
  return userModel.findOne( { _id: objectId }, { userName: 1, email: 1, _id: 0 } );
17
21
  }