tango-app-api-client 3.0.3 → 3.0.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 +2 -2
- package/src/controllers/client.controllers.js +25 -2
- package/src/service/camera.service.js +3 -3
- package/src/service/standaredRole.service.js +5 -0
- package/src/service/store.service.js +3 -3
- package/src/service/user.service.js +7 -3
- package/src/service/userPermission.service.js +5 -0
- package/src/services/client.services.js +0 -263
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.4",
|
|
4
4
|
"description": "client",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"mongodb": "^6.3.0",
|
|
25
25
|
"nodemon": "^3.0.3",
|
|
26
26
|
"tango-api-schema": "^2.0.33",
|
|
27
|
-
"tango-app-api-middleware": "^1.0.
|
|
27
|
+
"tango-app-api-middleware": "^1.0.26",
|
|
28
28
|
"winston": "^3.11.0",
|
|
29
29
|
"winston-daily-rotate-file": "^5.0.0"
|
|
30
30
|
},
|
|
@@ -1,9 +1,11 @@
|
|
|
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 } from 'tango-app-api-middleware';
|
|
3
|
-
import { countDocumentsUser, findOneUser } from '../service/user.service.js';
|
|
2
|
+
import { checkFileExist, fileUpload, signedUrl, chunkArray, download, logger, encrypt } from 'tango-app-api-middleware';
|
|
3
|
+
import { countDocumentsUser, createUser, findOneUser } 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';
|
|
7
|
+
import { findOneStandaredRole } from '../service/standaredRole.service.js';
|
|
8
|
+
import { createUserPermission } from '../service/userPermission.service.js';
|
|
7
9
|
|
|
8
10
|
export async function create( req, res ) {
|
|
9
11
|
try {
|
|
@@ -13,10 +15,30 @@ export async function create( req, res ) {
|
|
|
13
15
|
const tangoId = await getClientCount() +1;
|
|
14
16
|
const generatedName =inputData.clientName.replace( /[^A-Z0-9]+/ig, '' );
|
|
15
17
|
const product = leadRecord?.planDetails?.product.map( ( value ) => ( { productName: value } ) );
|
|
18
|
+
const password = await encrypt( leadRecord?.mobileNumber.toString() );
|
|
19
|
+
const userRecord ={
|
|
20
|
+
userName: leadRecord?.lastName?`${inputData.firstName}${inputData.lastName}`: inputData?.firstName,
|
|
21
|
+
email: leadRecord?.corporateEmail,
|
|
22
|
+
password: password,
|
|
23
|
+
mobileNumber: leadRecord?.mobileNumber,
|
|
24
|
+
role: 'superadmin',
|
|
25
|
+
userType: 'client',
|
|
26
|
+
};
|
|
27
|
+
const user = await createUser( userRecord );
|
|
28
|
+
const getPermission = await findOneStandaredRole( { roleName: 'superadmin', clientType: 'client' }, { permission: 1 } );
|
|
29
|
+
const permissionRecord ={
|
|
30
|
+
userName: user?.userName,
|
|
31
|
+
email: user?.email,
|
|
32
|
+
role: user?.role,
|
|
33
|
+
userType: user?.userType,
|
|
34
|
+
permission: getPermission?.permission,
|
|
35
|
+
};
|
|
36
|
+
await createUserPermission( permissionRecord );
|
|
16
37
|
const record = {
|
|
17
38
|
'clientName': leadRecord.clientName,
|
|
18
39
|
'clientId': String( tangoId ),
|
|
19
40
|
'tangoId': tangoId,
|
|
41
|
+
'userId': user?._id,
|
|
20
42
|
'planDetails.totalStores': leadRecord?.planDetails?.totalStores,
|
|
21
43
|
'planDetails.storeSize': leadRecord?.planDetails?.storeSize,
|
|
22
44
|
'planDetails.totalCamera': leadRecord?.planDetails?.totalCamera,
|
|
@@ -28,6 +50,7 @@ export async function create( req, res ) {
|
|
|
28
50
|
'auditConfigs.queueName': generatedName,
|
|
29
51
|
|
|
30
52
|
};
|
|
53
|
+
|
|
31
54
|
const insertClient = await insert( record );
|
|
32
55
|
if ( insertClient ) {
|
|
33
56
|
await createAuditQueue( generatedName );
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import cameraModel from 'tango-api-schema/schema/camera.model.js';
|
|
2
2
|
|
|
3
3
|
export function countDocumentsCamera( query ) {
|
|
4
|
-
return
|
|
4
|
+
return cameraModel.countDocuments( query );
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export function aggregateCamera( query ) {
|
|
8
|
-
return
|
|
8
|
+
return cameraModel.aggregate( query );
|
|
9
9
|
}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import
|
|
1
|
+
import storeModel from 'tango-api-schema/schema/store.model.js';
|
|
2
2
|
|
|
3
3
|
export function countDocumentsStore( query ) {
|
|
4
|
-
return
|
|
4
|
+
return storeModel.countDocuments( query );
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export function aggregateStore( query ) {
|
|
8
|
-
return
|
|
8
|
+
return storeModel.aggregate( query );
|
|
9
9
|
}
|
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import
|
|
1
|
+
import userModel from 'tango-api-schema/schema/user.model.js';
|
|
2
2
|
|
|
3
3
|
export function findOneUser( query ) {
|
|
4
|
-
return
|
|
4
|
+
return userModel.findOne( query );
|
|
5
5
|
}
|
|
6
6
|
|
|
7
7
|
export function countDocumentsUser( query ) {
|
|
8
|
-
return
|
|
8
|
+
return userModel.countDocuments( query );
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export async function createUser( record ) {
|
|
12
|
+
return userModel.create( record );
|
|
9
13
|
}
|
|
@@ -1,263 +0,0 @@
|
|
|
1
|
-
import clientModel from 'tango-api-schema/schema/client.model.js';
|
|
2
|
-
import leadModel from 'tango-api-schema/schema/lead.model.js';
|
|
3
|
-
import storeModel from 'tango-api-schema/schema/store.model.js';
|
|
4
|
-
import userModel from 'tango-api-schema/schema/user.model.js';
|
|
5
|
-
// import { createQueue, getQueueUrl } from 'tango-app-api-middleware';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
export function update( query, record ) {
|
|
9
|
-
return leadModel.updateMany( query, { $set: record } );
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export function findOne( query, field ) {
|
|
13
|
-
return leadModel.findOne( query, field );
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export function getClientCount( query ) {
|
|
17
|
-
return clientModel.countDocuments( query );
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function insert( record ) {
|
|
21
|
-
return clientModel.insertMany( record );
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export function find( query, field ) {
|
|
25
|
-
return clientModel.find( query, field );
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
export async function createAuditQueue( queueName ) {
|
|
29
|
-
try {
|
|
30
|
-
// const isExist = await getQueueUrl( `${queueName}${config.aws.sqs.queueType}` );
|
|
31
|
-
// if ( isExist.statusCode ) {
|
|
32
|
-
// const addQueue = await createQueue( `${queueName}${config.aws.sqs.queueType}` );
|
|
33
|
-
// if ( addQueue.QueueUrl ) {
|
|
34
|
-
// logger.info(
|
|
35
|
-
// 'Queueue Created'
|
|
36
|
-
// , { queueName: addQueue.QueueUrl, addQueue },
|
|
37
|
-
// );
|
|
38
|
-
// } else {
|
|
39
|
-
// logger.error( { error: 'Queue creation failed', function: 'createAuditQueue' } );
|
|
40
|
-
// }
|
|
41
|
-
// } else {
|
|
42
|
-
// logger.error( { error: 'Queue already exisit', message: queueName, function: 'createAuditQueue' } );
|
|
43
|
-
// }
|
|
44
|
-
return true;
|
|
45
|
-
} catch ( error ) {
|
|
46
|
-
return false;
|
|
47
|
-
logger.error( { error: error, message: queueName, function: 'createAuditQueue' } );
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
export function getClientData( { id } ) {
|
|
53
|
-
return clientModel.findOne( { clientId: id } );
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
export function getUserData( { id } ) {
|
|
57
|
-
return userModel.findOne( { _id: id }, { email: 1, countryCode: 1, mobileNumber: 1 } );
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
export function brandInfoUpdate( { clientId, registeredCompanyName, industry, clientType, registeredAddress, headQuarters, website, status, logo } ) {
|
|
61
|
-
return clientModel.updateOne( { clientId: clientId },
|
|
62
|
-
{
|
|
63
|
-
$set: {
|
|
64
|
-
'profileDetails.registeredCompanyName': registeredCompanyName,
|
|
65
|
-
'profileDetails.industry': industry,
|
|
66
|
-
'profileDetails.clientType': clientType,
|
|
67
|
-
'profileDetails.registeredAddress': registeredAddress,
|
|
68
|
-
'profileDetails.headQuarters': headQuarters,
|
|
69
|
-
'profileDetails.website': website,
|
|
70
|
-
'profileDetails.logo': logo,
|
|
71
|
-
'status': status,
|
|
72
|
-
},
|
|
73
|
-
} );
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export function billingDetailsUpdate( { clientId, tradeName, gstNumber, authorityName, authorityEmail, billingAddress, gstCertificate } ) {
|
|
77
|
-
return clientModel.updateOne( { clientId: clientId },
|
|
78
|
-
{
|
|
79
|
-
$set: {
|
|
80
|
-
'billingDetails.tradeName': tradeName,
|
|
81
|
-
'billingDetails.gstNumber': gstNumber,
|
|
82
|
-
'billingDetails.authorityName': authorityName,
|
|
83
|
-
'billingDetails.authorityEmail': authorityEmail,
|
|
84
|
-
'billingDetails.billingAddress': billingAddress,
|
|
85
|
-
'document.gst.number': gstNumber,
|
|
86
|
-
'document.gst.path': gstCertificate,
|
|
87
|
-
},
|
|
88
|
-
} );
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
export function signatoryDetailsUpdate( { clientId, name, email, number, designation } ) {
|
|
92
|
-
return clientModel.updateOne( { clientId: clientId },
|
|
93
|
-
{
|
|
94
|
-
$set: {
|
|
95
|
-
'signatoryDetail.name': name,
|
|
96
|
-
'signatoryDetail.email': email,
|
|
97
|
-
'signatoryDetail.number': number,
|
|
98
|
-
'signatoryDetail.designation': designation,
|
|
99
|
-
},
|
|
100
|
-
} );
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
export function ticketConfigurationUpdate( {
|
|
104
|
-
clientId, MinFilesCount, accuracyPercentage, downTimeType, infraDownTime, installationReAssign, isRcaTicketAssign,
|
|
105
|
-
isRefreshAlert, isStatusCheckAlert, rcaTicketAssign, reTrain, refreshAlert, sendToAdmin, sendToUser, statusCheckAlert,
|
|
106
|
-
} ) {
|
|
107
|
-
return clientModel.updateOne( { clientId: clientId },
|
|
108
|
-
{
|
|
109
|
-
$set: {
|
|
110
|
-
'ticketConfigs.installationReAssign': installationReAssign,
|
|
111
|
-
'ticketConfigs.alertSentTo.admin': sendToAdmin,
|
|
112
|
-
'ticketConfigs.alertSentTo.user': sendToUser,
|
|
113
|
-
'ticketConfigs.downTimeType': downTimeType,
|
|
114
|
-
'ticketConfigs.infraDownTime': infraDownTime,
|
|
115
|
-
'ticketConfigs.MinFilesCount': MinFilesCount,
|
|
116
|
-
'ticketConfigs.isRcaTicketAssign': isRcaTicketAssign,
|
|
117
|
-
'ticketConfigs.rcaTicketAssign': rcaTicketAssign,
|
|
118
|
-
'ticketConfigs.isRefreshAlert': isRefreshAlert,
|
|
119
|
-
'ticketConfigs.refreshAlert': refreshAlert,
|
|
120
|
-
'ticketConfigs.isStatusCheckAlert': isStatusCheckAlert,
|
|
121
|
-
'ticketConfigs.statusCheckAlert': statusCheckAlert,
|
|
122
|
-
'ticketConfigs.reTrain': reTrain,
|
|
123
|
-
'ticketConfigs.accuracyPercentage': accuracyPercentage,
|
|
124
|
-
},
|
|
125
|
-
} );
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
export function featureConfigurationUpdate( {
|
|
129
|
-
clientId, billableCalculation, bouncedLimitCondition, bouncedLimitValue,
|
|
130
|
-
close, conversionCalculation, conversionCondition,
|
|
131
|
-
conversionValue, infraAlertCondition, infraAlertValue, isFootfallDirectory,
|
|
132
|
-
isNormalized, isPasserByData, missedOpportunityCalculation, open,
|
|
133
|
-
} ) {
|
|
134
|
-
return clientModel.updateOne( { clientId: clientId },
|
|
135
|
-
{
|
|
136
|
-
$set: {
|
|
137
|
-
'featureConfigs.open': open,
|
|
138
|
-
'featureConfigs.close': close,
|
|
139
|
-
'featureConfigs.infraAlert.condition': infraAlertCondition,
|
|
140
|
-
'featureConfigs.infraAlert.value': infraAlertValue,
|
|
141
|
-
'featureConfigs.bouncedLimit.condition': bouncedLimitCondition,
|
|
142
|
-
'featureConfigs.bouncedLimit.value': bouncedLimitValue,
|
|
143
|
-
'featureConfigs.conversion.condition': conversionCondition,
|
|
144
|
-
'featureConfigs.conversion.value': conversionValue,
|
|
145
|
-
'featureConfigs.billableCalculation': billableCalculation,
|
|
146
|
-
'featureConfigs.missedOpportunityCalculation': missedOpportunityCalculation,
|
|
147
|
-
'featureConfigs.conversionCalculation': conversionCalculation,
|
|
148
|
-
'featureConfigs.isNormalized': isNormalized,
|
|
149
|
-
'featureConfigs.isPasserByData': isPasserByData,
|
|
150
|
-
'featureConfigs.isFootfallDirectory': isFootfallDirectory,
|
|
151
|
-
},
|
|
152
|
-
} );
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
export function domainDetailsConfigurationUpdate( { clientId, domainName, isEnable } ) {
|
|
156
|
-
return clientModel.updateOne( { clientId: clientId },
|
|
157
|
-
{
|
|
158
|
-
$set: {
|
|
159
|
-
'ssoLogin.domainName': domainName,
|
|
160
|
-
'ssoLogin.isEnable': isEnable,
|
|
161
|
-
},
|
|
162
|
-
} );
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
export function userConfigurationUpdate( { clientId, csm, ops } ) {
|
|
166
|
-
return clientModel.updateOne( { clientId: clientId },
|
|
167
|
-
{
|
|
168
|
-
$set: {
|
|
169
|
-
'assignedUsers.csm': csm,
|
|
170
|
-
'assignedUsers.ops': ops,
|
|
171
|
-
},
|
|
172
|
-
} );
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
export function documentsUpdate( { clientId, gstNumber, panNumber, cinNumber, addressDoc, gstDoc, panDoc, cinDoc } ) {
|
|
176
|
-
return clientModel.updateOne( { clientId: clientId },
|
|
177
|
-
{
|
|
178
|
-
$set: {
|
|
179
|
-
'document.addressProof.path': addressDoc,
|
|
180
|
-
'document.gst.number': gstNumber,
|
|
181
|
-
'document.gst.path': gstDoc,
|
|
182
|
-
'document.pan.number': panNumber,
|
|
183
|
-
'document.pan.path': panDoc,
|
|
184
|
-
'document.pan.number': panNumber,
|
|
185
|
-
'document.pan.path': panDoc,
|
|
186
|
-
'document.cin.number': cinNumber,
|
|
187
|
-
'document.cin.path': cinDoc,
|
|
188
|
-
},
|
|
189
|
-
} );
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
export function auditConfigurationGet( { storeId } ) {
|
|
193
|
-
return storeModel.findOne( { storeId: storeId },
|
|
194
|
-
{
|
|
195
|
-
'auditConfigs.count': 1,
|
|
196
|
-
'auditConfigs.iteration': 1,
|
|
197
|
-
'auditConfigs.ratio': 1,
|
|
198
|
-
'storeId': 1,
|
|
199
|
-
'_id': 0,
|
|
200
|
-
} );
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
export function auditConfigurationUpdate( { storeId, count, iteration, ratio } ) {
|
|
204
|
-
return storeModel.updateOne( { storeId: storeId },
|
|
205
|
-
{
|
|
206
|
-
$set: {
|
|
207
|
-
'auditConfigs.count': count,
|
|
208
|
-
'auditConfigs.iteration': iteration,
|
|
209
|
-
'auditConfigs.ratio': ratio,
|
|
210
|
-
},
|
|
211
|
-
} );
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
export function CsmUsersGet( ) {
|
|
215
|
-
return userModel.aggregate( [
|
|
216
|
-
{
|
|
217
|
-
$match: {
|
|
218
|
-
$and: [
|
|
219
|
-
{
|
|
220
|
-
$or: [
|
|
221
|
-
{
|
|
222
|
-
role: 'user',
|
|
223
|
-
},
|
|
224
|
-
{
|
|
225
|
-
role: 'admin',
|
|
226
|
-
},
|
|
227
|
-
],
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
userType: 'tango',
|
|
231
|
-
},
|
|
232
|
-
],
|
|
233
|
-
},
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
$project: {
|
|
237
|
-
userName: 1,
|
|
238
|
-
},
|
|
239
|
-
},
|
|
240
|
-
] );
|
|
241
|
-
}
|
|
242
|
-
|
|
243
|
-
export function OpsUsersGet( ) {
|
|
244
|
-
return userModel.aggregate( [
|
|
245
|
-
{
|
|
246
|
-
$match: {
|
|
247
|
-
$and: [
|
|
248
|
-
{
|
|
249
|
-
role: 'user',
|
|
250
|
-
},
|
|
251
|
-
{
|
|
252
|
-
userType: 'tango',
|
|
253
|
-
},
|
|
254
|
-
],
|
|
255
|
-
},
|
|
256
|
-
},
|
|
257
|
-
{
|
|
258
|
-
$project: {
|
|
259
|
-
userName: 1,
|
|
260
|
-
},
|
|
261
|
-
},
|
|
262
|
-
] );
|
|
263
|
-
}
|