tango-app-api-client 3.3.2-beta.1 → 3.3.2-beta.3

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.3.2-beta.1",
3
+ "version": "3.3.2-beta.3",
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.1.59",
28
+ "tango-api-schema": "^2.1.64",
29
29
  "tango-app-api-middleware": "^3.1.43-alpha.8",
30
30
  "winston": "^3.11.0",
31
31
  "winston-daily-rotate-file": "^5.0.0"
@@ -14,6 +14,7 @@ import { countDocumentsGroup, createGroupModel, findOneGroup } from '../service/
14
14
  // import { deleteOneAuthentication } from '../service/authentication.service.js';
15
15
  import { createBilling } from '../service/billing.service.js';
16
16
  import { createPaymentAccount } from '../service/paymentAccount.service.js';
17
+ import { countDocumentsClusters } from '../service/cluster.service.js';
17
18
 
18
19
 
19
20
  export async function create( req, res ) {
@@ -42,7 +43,7 @@ export async function create( req, res ) {
42
43
  const tangoId = count + 1;
43
44
  const generatedName = inputData.clientName.replace( /[^A-Z0-9]+/ig, '' );
44
45
  const product = leadRecord?.planDetails?.product.map( ( value ) => ( { productName: value } ) );
45
- const getPermission = await findOneStandaredRole( { roleName: 'superadmin', userType: 'client' }, { permission: 1 } );
46
+ const getPermission = await findOneStandaredRole( { roleName: 'superadmin', userType: 'client' }, { permission: 1, rolespermission: 1 } );
46
47
  const userQuery = {
47
48
  email: leadRecord?.corporateEmail,
48
49
  };
@@ -78,18 +79,36 @@ export async function create( req, res ) {
78
79
  'auditConfigs.traxQueueName.uniformDetection': `${generatedName}-uniformDetection`,
79
80
  'auditConfigs.traxQueueName.mobileDetection': `${generatedName}-mobileDetection`,
80
81
  'auditConfigs.traxQueueName.cameraAngleChange': `${generatedName}-cameraAngleChange`,
81
-
82
-
83
82
  };
84
83
 
84
+
85
+ if ( product && product.length > 0 ) {
86
+ for ( let data of product ) {
87
+ console.log( data.productName );
88
+ record.featureConfigs = {};
89
+ if ( data.productName === 'tangoTraffic' ) {
90
+ record.featureConfigs.isNewDashboard = true;
91
+ record.featureConfigs.isNewTraffic = true;
92
+ record.featureConfigs.isNewReports = true;
93
+ }
94
+ if ( data.productName === 'tangozone' ) {
95
+ record.featureConfigs.isNewZone = true;
96
+ }
97
+ if ( data.productName === 'tangoTrax' ) {
98
+ record.featureConfigs. isTrax= true;
99
+ }
100
+ }
101
+ }
85
102
  const insertClient = await insert( record );
86
103
 
87
104
  const insertedClientRecord = await findOneClient( { clientId: record.clientId }, {} );
88
105
 
89
106
  const customer = await createCustomer( { name: user.userName, email: user.email, clientId: insertedClientRecord.clientId } );
90
107
 
91
- const virtualAccount = await createVirtualAccount( { receiverTypes: [ 'bank_account' ], description: `Virtual Account for ${insertedClientRecord.clientId}`,
92
- customerId: customer.id, notes: { createdAt: new Date(), createdBy: req.user?.email } } );
108
+ const virtualAccount = await createVirtualAccount( {
109
+ receiverTypes: [ 'bank_account' ], description: `Virtual Account for ${insertedClientRecord.clientId}`,
110
+ customerId: customer.id, notes: { createdAt: new Date(), createdBy: req.user?.email },
111
+ } );
93
112
 
94
113
  const paymentAccount = {
95
114
  clientId: insertedClientRecord.clientId,
@@ -293,6 +312,7 @@ export async function create( req, res ) {
293
312
  userType: 'client',
294
313
  refreshToken: null,
295
314
  permission: getPermission?.permission,
315
+ rolespermission: getPermission?.rolespermission,
296
316
  clientId: String( tangoId ),
297
317
  };
298
318
  // await deleteOneAuthentication( { user: user?._id, type: 'retail' } );
@@ -544,7 +564,7 @@ export async function detailedAllClientCount( req, res ) {
544
564
  ];
545
565
  const clientList = await aggregateUserAssignedStore( clientQuery );
546
566
  if ( clientList[0]?.clientId?.length != 0 ) {
547
- Assinedclient= clientList[0]?.clientId;
567
+ Assinedclient = clientList[0]?.clientId;
548
568
  }
549
569
  }
550
570
  const query = [
@@ -618,7 +638,8 @@ export async function detailedAllClientCount( req, res ) {
618
638
  const result = await aggregateClient( query );
619
639
  const activeStores = await findStore( {
620
640
  'clientId': { $in: Assinedclient },
621
- 'status': 'active' }, { storeId: 1 } );
641
+ 'status': 'active',
642
+ }, { storeId: 1 } );
622
643
  let yettoInstallCount = await aggregateTickets( [
623
644
  {
624
645
  $match: {
@@ -639,7 +660,7 @@ export async function detailedAllClientCount( req, res ) {
639
660
  if ( result.length == 0 ) {
640
661
  return res.sendError( 'No Data Found', 204 );
641
662
  }
642
- result[0].activeStoresCount = activeStores.length-yettoInstallCount.length;
663
+ result[0].activeStoresCount = activeStores.length - yettoInstallCount.length;
643
664
  result[0].activeCameraCount = activeCameras;
644
665
  return res.sendSuccess( { result: result } );
645
666
  } catch ( error ) {
@@ -1152,7 +1173,7 @@ export async function updateDocuments( req, res ) {
1152
1173
 
1153
1174
  export async function getAuditConfiguration( req, res ) {
1154
1175
  try {
1155
- const query ={
1176
+ const query = {
1156
1177
  clientId: req.params?.id,
1157
1178
  };
1158
1179
  const fields = {
@@ -1179,14 +1200,14 @@ export async function auditConfiguration( req, res ) {
1179
1200
  try {
1180
1201
  const inputData = req.body;
1181
1202
  const openSearch = JSON.parse( process.env.OPENSEARCH );
1182
- const query ={
1203
+ const query = {
1183
1204
  clientId: req.params?.id,
1184
1205
  };
1185
- const fields ={
1206
+ const fields = {
1186
1207
  auditConfigs: 1, _id: 0,
1187
1208
  };
1188
1209
  const previousClient = await findOneClient( query, fields );
1189
- const record ={
1210
+ const record = {
1190
1211
  'auditConfigs.count': inputData.count,
1191
1212
  'auditConfigs.audit': inputData.audit,
1192
1213
  'auditConfigs.ratio': Number( normalizeNumber( inputData.ratio, 0, 100 ) ),
@@ -1800,10 +1821,12 @@ export async function clientListV1( req, res ) {
1800
1821
  clientId: { $toInt: '$clientId' },
1801
1822
  onboardedStores: 1,
1802
1823
  installedStore: 1,
1803
- activeStores: { $max: [
1804
- { $subtract: [ '$activeStores', '$installedPending' ] },
1805
- 0,
1806
- ] },
1824
+ activeStores: {
1825
+ $max: [
1826
+ { $subtract: [ '$activeStores', '$installedPending' ] },
1827
+ 0,
1828
+ ],
1829
+ },
1807
1830
  InactiveStores: 1,
1808
1831
  ProcessingStatus: 1,
1809
1832
  clientName: 1,
@@ -1845,8 +1868,8 @@ export async function clientListV1( req, res ) {
1845
1868
  return res.sendError( 'No Data Found', 204 );
1846
1869
  }
1847
1870
 
1848
- if ( inputData.sortColumName&&inputData.sortColumName!=''&& req.body.sortBy&&req.body.sortBy!='' ) {
1849
- if ( inputData.sortColumName==='clientName' ) {
1871
+ if ( inputData.sortColumName && inputData.sortColumName != '' && req.body.sortBy && req.body.sortBy != '' ) {
1872
+ if ( inputData.sortColumName === 'clientName' ) {
1850
1873
  clientQuery.push(
1851
1874
  {
1852
1875
  $project: {
@@ -1898,15 +1921,15 @@ export async function clientListV1( req, res ) {
1898
1921
  exportResult.push( {
1899
1922
  'Brand Name': client.clientName,
1900
1923
  'Brand ID': client.clientId,
1901
- 'Onboarded Stores': client.onboardedStores||0,
1924
+ 'Onboarded Stores': client.onboardedStores || 0,
1902
1925
  'Installed Stores': client.installedStore || 0,
1903
- 'Progress Status': client.ProgressBar||0,
1926
+ 'Progress Status': client.ProgressBar || 0,
1904
1927
  'Active Stores': client.activeStores || 0,
1905
1928
  'In-Active Stores': client.InactiveStores || 0,
1906
1929
  'Pending Configuration': client.installedPending || 0,
1907
- 'Payment Plan': client.PaymentPlan == 'free'?'Lifetime Free':client.PaymentPlan,
1930
+ 'Payment Plan': client.PaymentPlan == 'free' ? 'Lifetime Free' : client.PaymentPlan,
1908
1931
  'Subscription Plan': client.subscriptionPlan,
1909
- 'Processing Status': client.ProcessingStatus=='active'?'Activated':client.ProcessingStatus=='deactive'?'Deactivated':client.ProcessingStatus,
1932
+ 'Processing Status': client.ProcessingStatus == 'active' ? 'Activated' : client.ProcessingStatus == 'deactive' ? 'Deactivated' : client.ProcessingStatus,
1910
1933
  } );
1911
1934
  }
1912
1935
  await download( exportResult, res );
@@ -1943,6 +1966,7 @@ export async function detailedClientCount( req, res ) {
1943
1966
  };
1944
1967
  result['totalStoreCount'] = await countDocumentsStore( { clientId: inputData.clientId } );
1945
1968
  result['totalGroupCount'] = await countDocumentsGroup( { clientId: inputData.clientId, isActive: true } );
1969
+ result['totalclusterCount'] = await countDocumentsClusters( { clientId: inputData.clientId } );
1946
1970
  result['totalCameraCount'] = await countDocumentsCamera( { clientId: inputData.clientId } );
1947
1971
  result['totalUserCount'] = await countDocumentsUser( { clientId: inputData.clientId, userType: 'client' } );
1948
1972
 
@@ -1969,7 +1993,7 @@ export async function detailedClientCount( req, res ) {
1969
1993
  },
1970
1994
  ] );
1971
1995
 
1972
- if ( findCsm&&findCsm.length>0 ) {
1996
+ if ( findCsm && findCsm.length > 0 ) {
1973
1997
  let finduser = await findOneUser( { email: findCsm[0].userEmail }, { userName: 1, email: 1, countryCode: 1, mobileNumber: 1 } );
1974
1998
  result['csm'] = finduser;
1975
1999
  }
@@ -0,0 +1,27 @@
1
+ import clusterModel from 'tango-api-schema/schema/cluster.model.js';
2
+
3
+ export async function updateOneCluster( query, record ) {
4
+ return await clusterModel.updateOne( query, { $set: record } );
5
+ };
6
+
7
+ export async function updateCluster( query, record ) {
8
+ return await clusterModel.updateMany( query, record );
9
+ };
10
+
11
+ export async function aggregateCluster( query ) {
12
+ return await clusterModel.aggregate( query );
13
+ };
14
+
15
+ export async function findOneCluster( query ={}, field={} ) {
16
+ return await clusterModel.findOne( query, field );
17
+ };
18
+ export async function deleteCluster( query ={} ) {
19
+ return await clusterModel.deleteOne( query );
20
+ };
21
+
22
+ export async function createclusterModel( data ) {
23
+ return await clusterModel.create( data );
24
+ };
25
+ export function countDocumentsClusters( query ) {
26
+ return clusterModel.countDocuments( query );
27
+ }