tango-app-api-client 3.3.2-beta.2 → 3.3.2-beta.4

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.2",
3
+ "version": "3.3.2-beta.4",
4
4
  "description": "client",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -15,8 +15,7 @@ import { countDocumentsGroup, createGroupModel, findOneGroup } from '../service/
15
15
  import { createBilling } from '../service/billing.service.js';
16
16
  import { createPaymentAccount } from '../service/paymentAccount.service.js';
17
17
  import { countDocumentsClusters } from '../service/cluster.service.js';
18
-
19
-
18
+ import { countDocumentsTeams } from '../service/teams.service.js';
20
19
 
21
20
  export async function create( req, res ) {
22
21
  try {
@@ -80,9 +79,26 @@ export async function create( req, res ) {
80
79
  'auditConfigs.traxQueueName.uniformDetection': `${generatedName}-uniformDetection`,
81
80
  'auditConfigs.traxQueueName.mobileDetection': `${generatedName}-mobileDetection`,
82
81
  'auditConfigs.traxQueueName.cameraAngleChange': `${generatedName}-cameraAngleChange`,
82
+ };
83
83
 
84
+ record.featureConfigs = {};
85
+ if ( product && product.length > 0 ) {
86
+ for ( let data of product ) {
87
+ record.featureConfigs.isNewDashboard = true;
88
+
89
+ if ( data.productName === 'tangoTraffic' ) {
90
+ record.featureConfigs.isNewTraffic = true;
91
+ record.featureConfigs.isNewReports = true;
92
+ }
93
+ if ( data.productName === 'tangoZone' ) {
94
+ record.featureConfigs.isNewZone = true;
95
+ }
96
+ if ( data.productName === 'tangoTrax' ) {
97
+ record.featureConfigs. isTrax= true;
98
+ }
99
+ }
100
+ }
84
101
 
85
- };
86
102
 
87
103
  const insertClient = await insert( record );
88
104
 
@@ -90,8 +106,10 @@ export async function create( req, res ) {
90
106
 
91
107
  const customer = await createCustomer( { name: user.userName, email: user.email, clientId: insertedClientRecord.clientId } );
92
108
 
93
- const virtualAccount = await createVirtualAccount( { receiverTypes: [ 'bank_account' ], description: `Virtual Account for ${insertedClientRecord.clientId}`,
94
- customerId: customer.id, notes: { createdAt: new Date(), createdBy: req.user?.email } } );
109
+ const virtualAccount = await createVirtualAccount( {
110
+ receiverTypes: [ 'bank_account' ], description: `Virtual Account for ${insertedClientRecord.clientId}`,
111
+ customerId: customer.id, notes: { createdAt: new Date(), createdBy: req.user?.email },
112
+ } );
95
113
 
96
114
  const paymentAccount = {
97
115
  clientId: insertedClientRecord.clientId,
@@ -547,7 +565,7 @@ export async function detailedAllClientCount( req, res ) {
547
565
  ];
548
566
  const clientList = await aggregateUserAssignedStore( clientQuery );
549
567
  if ( clientList[0]?.clientId?.length != 0 ) {
550
- Assinedclient= clientList[0]?.clientId;
568
+ Assinedclient = clientList[0]?.clientId;
551
569
  }
552
570
  }
553
571
  const query = [
@@ -621,7 +639,8 @@ export async function detailedAllClientCount( req, res ) {
621
639
  const result = await aggregateClient( query );
622
640
  const activeStores = await findStore( {
623
641
  'clientId': { $in: Assinedclient },
624
- 'status': 'active' }, { storeId: 1 } );
642
+ 'status': 'active',
643
+ }, { storeId: 1 } );
625
644
  let yettoInstallCount = await aggregateTickets( [
626
645
  {
627
646
  $match: {
@@ -642,7 +661,7 @@ export async function detailedAllClientCount( req, res ) {
642
661
  if ( result.length == 0 ) {
643
662
  return res.sendError( 'No Data Found', 204 );
644
663
  }
645
- result[0].activeStoresCount = activeStores.length-yettoInstallCount.length;
664
+ result[0].activeStoresCount = activeStores.length - yettoInstallCount.length;
646
665
  result[0].activeCameraCount = activeCameras;
647
666
  return res.sendSuccess( { result: result } );
648
667
  } catch ( error ) {
@@ -1155,7 +1174,7 @@ export async function updateDocuments( req, res ) {
1155
1174
 
1156
1175
  export async function getAuditConfiguration( req, res ) {
1157
1176
  try {
1158
- const query ={
1177
+ const query = {
1159
1178
  clientId: req.params?.id,
1160
1179
  };
1161
1180
  const fields = {
@@ -1182,14 +1201,14 @@ export async function auditConfiguration( req, res ) {
1182
1201
  try {
1183
1202
  const inputData = req.body;
1184
1203
  const openSearch = JSON.parse( process.env.OPENSEARCH );
1185
- const query ={
1204
+ const query = {
1186
1205
  clientId: req.params?.id,
1187
1206
  };
1188
- const fields ={
1207
+ const fields = {
1189
1208
  auditConfigs: 1, _id: 0,
1190
1209
  };
1191
1210
  const previousClient = await findOneClient( query, fields );
1192
- const record ={
1211
+ const record = {
1193
1212
  'auditConfigs.count': inputData.count,
1194
1213
  'auditConfigs.audit': inputData.audit,
1195
1214
  'auditConfigs.ratio': Number( normalizeNumber( inputData.ratio, 0, 100 ) ),
@@ -1803,10 +1822,12 @@ export async function clientListV1( req, res ) {
1803
1822
  clientId: { $toInt: '$clientId' },
1804
1823
  onboardedStores: 1,
1805
1824
  installedStore: 1,
1806
- activeStores: { $max: [
1807
- { $subtract: [ '$activeStores', '$installedPending' ] },
1808
- 0,
1809
- ] },
1825
+ activeStores: {
1826
+ $max: [
1827
+ { $subtract: [ '$activeStores', '$installedPending' ] },
1828
+ 0,
1829
+ ],
1830
+ },
1810
1831
  InactiveStores: 1,
1811
1832
  ProcessingStatus: 1,
1812
1833
  clientName: 1,
@@ -1848,8 +1869,8 @@ export async function clientListV1( req, res ) {
1848
1869
  return res.sendError( 'No Data Found', 204 );
1849
1870
  }
1850
1871
 
1851
- if ( inputData.sortColumName&&inputData.sortColumName!=''&& req.body.sortBy&&req.body.sortBy!='' ) {
1852
- if ( inputData.sortColumName==='clientName' ) {
1872
+ if ( inputData.sortColumName && inputData.sortColumName != '' && req.body.sortBy && req.body.sortBy != '' ) {
1873
+ if ( inputData.sortColumName === 'clientName' ) {
1853
1874
  clientQuery.push(
1854
1875
  {
1855
1876
  $project: {
@@ -1901,15 +1922,15 @@ export async function clientListV1( req, res ) {
1901
1922
  exportResult.push( {
1902
1923
  'Brand Name': client.clientName,
1903
1924
  'Brand ID': client.clientId,
1904
- 'Onboarded Stores': client.onboardedStores||0,
1925
+ 'Onboarded Stores': client.onboardedStores || 0,
1905
1926
  'Installed Stores': client.installedStore || 0,
1906
- 'Progress Status': client.ProgressBar||0,
1927
+ 'Progress Status': client.ProgressBar || 0,
1907
1928
  'Active Stores': client.activeStores || 0,
1908
1929
  'In-Active Stores': client.InactiveStores || 0,
1909
1930
  'Pending Configuration': client.installedPending || 0,
1910
- 'Payment Plan': client.PaymentPlan == 'free'?'Lifetime Free':client.PaymentPlan,
1931
+ 'Payment Plan': client.PaymentPlan == 'free' ? 'Lifetime Free' : client.PaymentPlan,
1911
1932
  'Subscription Plan': client.subscriptionPlan,
1912
- 'Processing Status': client.ProcessingStatus=='active'?'Activated':client.ProcessingStatus=='deactive'?'Deactivated':client.ProcessingStatus,
1933
+ 'Processing Status': client.ProcessingStatus == 'active' ? 'Activated' : client.ProcessingStatus == 'deactive' ? 'Deactivated' : client.ProcessingStatus,
1913
1934
  } );
1914
1935
  }
1915
1936
  await download( exportResult, res );
@@ -1947,6 +1968,7 @@ export async function detailedClientCount( req, res ) {
1947
1968
  result['totalStoreCount'] = await countDocumentsStore( { clientId: inputData.clientId } );
1948
1969
  result['totalGroupCount'] = await countDocumentsGroup( { clientId: inputData.clientId, isActive: true } );
1949
1970
  result['totalclusterCount'] = await countDocumentsClusters( { clientId: inputData.clientId } );
1971
+ result['totalTeamsCount'] = await countDocumentsTeams( { clientId: inputData.clientId } );
1950
1972
  result['totalCameraCount'] = await countDocumentsCamera( { clientId: inputData.clientId } );
1951
1973
  result['totalUserCount'] = await countDocumentsUser( { clientId: inputData.clientId, userType: 'client' } );
1952
1974
 
@@ -1973,7 +1995,7 @@ export async function detailedClientCount( req, res ) {
1973
1995
  },
1974
1996
  ] );
1975
1997
 
1976
- if ( findCsm&&findCsm.length>0 ) {
1998
+ if ( findCsm && findCsm.length > 0 ) {
1977
1999
  let finduser = await findOneUser( { email: findCsm[0].userEmail }, { userName: 1, email: 1, countryCode: 1, mobileNumber: 1 } );
1978
2000
  result['csm'] = finduser;
1979
2001
  }
@@ -23,5 +23,5 @@ export async function createclusterModel( data ) {
23
23
  return await clusterModel.create( data );
24
24
  };
25
25
  export function countDocumentsClusters( query ) {
26
- return clusterModel.countDocuments( query );
27
- }
26
+ return clusterModel.countDocuments( query );
27
+ }
@@ -0,0 +1,30 @@
1
+ import teamsModel from 'tango-api-schema/schema/teams.model.js';
2
+
3
+
4
+ export async function createTeamsModel( data ) {
5
+ return await teamsModel.create( data );
6
+ };
7
+ export async function updateOneTeams( query, record ) {
8
+ return await teamsModel.updateOne( query, { $set: record }, { upsert: true } );
9
+ };
10
+
11
+ export async function aggregateTeams( query ) {
12
+ return await teamsModel.aggregate( query );
13
+ };
14
+ export async function deleteTeams( query ={} ) {
15
+ return await teamsModel.deleteOne( query );
16
+ };
17
+
18
+ export async function findOneTeams( query ={}, field={} ) {
19
+ return await teamsModel.findOne( query, field );
20
+ };
21
+ export async function findteams( query ={}, field={} ) {
22
+ return await teamsModel.find( query, field );
23
+ };
24
+
25
+ export async function updateOneTeamModel( query, record ) {
26
+ return await teamsModel.updateOne( query, record );
27
+ }
28
+ export function countDocumentsTeams( query ) {
29
+ return teamsModel.countDocuments( query );
30
+ }