tango-app-api-store-zone 3.0.15-dev → 3.0.17-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-store-zone",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.17-dev",
|
|
4
4
|
"description": "zone",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"nodemon": "^3.1.0",
|
|
23
23
|
"swagger-ui-express": "^5.0.0",
|
|
24
24
|
"tango-api-schema": "^2.0.115",
|
|
25
|
-
"tango-app-api-middleware": "^1.
|
|
25
|
+
"tango-app-api-middleware": "^3.1.19",
|
|
26
26
|
"winston": "^3.13.0",
|
|
27
27
|
"winston-daily-rotate-file": "^5.0.0"
|
|
28
28
|
},
|
|
@@ -3,7 +3,7 @@ import * as cameraService from '../services/camera.service.js';
|
|
|
3
3
|
import * as taggingService from '../services/tagging.service.js';
|
|
4
4
|
import * as storeService from '../services/store.service.js';
|
|
5
5
|
import * as clientService from '../services/client.service.js';
|
|
6
|
-
import {
|
|
6
|
+
import { signedUrl, listFileByPath, fileUpload, insertOpenSearchData } from 'tango-app-api-middleware';
|
|
7
7
|
import axios from 'axios';
|
|
8
8
|
export const addCustomTag = async ( req, res ) => {
|
|
9
9
|
try {
|
|
@@ -31,7 +31,7 @@ export const addCustomTag = async ( req, res ) => {
|
|
|
31
31
|
eventType: '',
|
|
32
32
|
showTo: [ 'client', 'tango' ],
|
|
33
33
|
};
|
|
34
|
-
insertOpenSearchData(
|
|
34
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH )?.activityLog, logObj );
|
|
35
35
|
return res.sendSuccess( 'Tag Created Successfully' );
|
|
36
36
|
} catch ( e ) {
|
|
37
37
|
logger.error( { error: 'e', function: 'addCustomTag' } );
|
|
@@ -43,7 +43,7 @@ export const customTagList = async ( req, res ) => {
|
|
|
43
43
|
try {
|
|
44
44
|
let customTagList = [];
|
|
45
45
|
let storeDetails = await storeService.findOne( { storeId: req.query.storeId }, { product: 1 } );
|
|
46
|
-
let clientDetails = await clientService.findOne( { clientId: req.query.clientId } );
|
|
46
|
+
let clientDetails = await clientService.findOne( { clientId: req.query.clientId }, { featureConfigs: 1 } );
|
|
47
47
|
if ( clientDetails && clientDetails?.featureConfigs?.isExcludedArea ) {
|
|
48
48
|
customTagList.push( 'Excluded Area' );
|
|
49
49
|
}
|
|
@@ -64,7 +64,7 @@ export const customTagList = async ( req, res ) => {
|
|
|
64
64
|
} );
|
|
65
65
|
if ( tagInfo.length ) {
|
|
66
66
|
tagInfo.forEach( ( item ) => {
|
|
67
|
-
if ( !customTagList.includes( item ) ) {
|
|
67
|
+
if ( !customTagList.includes( item ) && ![ 'Excluded Area', 'Passer By', 'Entry/Exit', 'Billing' ].includes( item ) ) {
|
|
68
68
|
customTagList.push( item );
|
|
69
69
|
}
|
|
70
70
|
} );
|
|
@@ -133,10 +133,10 @@ export const tagging = async ( req, res ) => {
|
|
|
133
133
|
eventType: '',
|
|
134
134
|
showTo: [ 'client', 'tango' ],
|
|
135
135
|
};
|
|
136
|
-
insertOpenSearchData(
|
|
136
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH )?.activityLog, logObj );
|
|
137
137
|
let response = await taggingService.create( InputData );
|
|
138
138
|
await taggingService.deleteOne( { clientId: InputData.clientId, storeId: InputData.storeId, cameraId: { $exists: false }, tagName: InputData.tagName } );
|
|
139
|
-
await axios.post( `${
|
|
139
|
+
await axios.post( `${JSON.parse( process.env.URL ).oldapidomain}/tagging/oldTaggingAdd`, [ response ], { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( res ) => logger.info( res?.data ) ).catch( ( error ) => logger.error( { error: error } ) );
|
|
140
140
|
} else {
|
|
141
141
|
const logObj = {
|
|
142
142
|
clientId: InputData.clientId,
|
|
@@ -149,20 +149,21 @@ export const tagging = async ( req, res ) => {
|
|
|
149
149
|
changes: [ `${InputData.tagName} zone Updated tagging` ],
|
|
150
150
|
eventType: '',
|
|
151
151
|
};
|
|
152
|
-
insertOpenSearchData(
|
|
152
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH )?.activityLog, logObj );
|
|
153
153
|
taggingDetails.cameraId = InputData.cameraId;
|
|
154
154
|
taggingDetails.streamName = InputData.streamName;
|
|
155
|
-
if ( req.body?.redoPoint ) {
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}
|
|
155
|
+
// if ( req.body?.redoPoint ) {
|
|
156
|
+
// taggingDetails.coordinates = InputData.coordinates[0];
|
|
157
|
+
// taggingDetails.save();
|
|
158
|
+
// }
|
|
159
|
+
if ( req.body?.redraw || req.body?.redoPoint ) {
|
|
159
160
|
taggingDetails.coordinates = InputData.coordinates;
|
|
160
161
|
taggingDetails.save();
|
|
161
162
|
} else {
|
|
162
163
|
if ( InputData.coordinates[0].coor.length ) {
|
|
163
164
|
taggingDetails.coordinates.push( InputData.coordinates[0] );
|
|
164
165
|
taggingDetails.save();
|
|
165
|
-
await axios.post( `${
|
|
166
|
+
await axios.post( `${JSON.parse( process.env.URL ).oldapidomain}/tagging/oldTaggingUpdate/${taggingDetails._id}`, taggingDetails, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( res ) => {
|
|
166
167
|
logger.info( res?.data );
|
|
167
168
|
} ).catch( ( error ) => {
|
|
168
169
|
logger.error( { error: error } );
|
|
@@ -186,11 +187,11 @@ export const getCameraList = async ( req, res ) => {
|
|
|
186
187
|
return res.sendError( 'no data found', 204 );
|
|
187
188
|
}
|
|
188
189
|
const folderPath = { file_path: `${req.query.storeId}/zone_base_images/`,
|
|
189
|
-
Bucket:
|
|
190
|
+
Bucket: JSON.parse( process.env.BUCKET ).zoneBaseImage, MaxKeys: 1000,
|
|
190
191
|
};
|
|
191
192
|
let fileList = await listFileByPath( folderPath );
|
|
192
193
|
const TaggedfolderPath = { file_path: `${req.query.storeId}/zone_tagged_image/`,
|
|
193
|
-
Bucket:
|
|
194
|
+
Bucket: JSON.parse( process.env.BUCKET ).zoneTaggingImage, MaxKeys: 1000,
|
|
194
195
|
};
|
|
195
196
|
let tagFileList = await listFileByPath( TaggedfolderPath );
|
|
196
197
|
for ( let [ index, camera ] of cameraDetails.entries() ) {
|
|
@@ -234,14 +235,14 @@ export const getCameraList = async ( req, res ) => {
|
|
|
234
235
|
}
|
|
235
236
|
if ( tagPath ) {
|
|
236
237
|
const params = { file_path: tagPath,
|
|
237
|
-
Bucket:
|
|
238
|
+
Bucket: JSON.parse( process.env.BUCKET ).zoneTaggingImage,
|
|
238
239
|
};
|
|
239
240
|
const cameraTagImage = await signedUrl( params );
|
|
240
241
|
camera.tagImg = cameraTagImage;
|
|
241
242
|
}
|
|
242
243
|
if ( imgPath ) {
|
|
243
244
|
const baseParams = { file_path: imgPath,
|
|
244
|
-
Bucket:
|
|
245
|
+
Bucket: JSON.parse( process.env.BUCKET ).zoneBaseImage,
|
|
245
246
|
};
|
|
246
247
|
const cameraBaseImage = await signedUrl( baseParams );
|
|
247
248
|
camera.baseImg = cameraBaseImage;
|
|
@@ -278,7 +279,7 @@ export const updateTag = async ( req, res ) => {
|
|
|
278
279
|
} );
|
|
279
280
|
}
|
|
280
281
|
taggingCoordinates.forEach( async ( item ) => {
|
|
281
|
-
await axios.post( `${
|
|
282
|
+
await axios.post( `${JSON.parse( process.env.URL ).oldapidomain}/tagging/oldTaggingUpdate/${item._id}`, item, { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( res ) => {
|
|
282
283
|
logger.info( res?.data );
|
|
283
284
|
} ).catch( ( error ) => {
|
|
284
285
|
logger.error( { error: error } );
|
|
@@ -296,7 +297,7 @@ export const updateTag = async ( req, res ) => {
|
|
|
296
297
|
eventType: '',
|
|
297
298
|
showTo: [ 'client', 'tango' ],
|
|
298
299
|
};
|
|
299
|
-
insertOpenSearchData(
|
|
300
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH )?.activityLog, logObj );
|
|
300
301
|
if ( tagUpdate.modifiedCount || tagUpdate.matchedCount ) {
|
|
301
302
|
logger.info( 'Custom Tag Updated Successfully' );
|
|
302
303
|
return res.sendSuccess( 'Custom Tag Updated Successfully' );
|
|
@@ -342,7 +343,7 @@ export const deleteTag = async ( req, res ) => {
|
|
|
342
343
|
}
|
|
343
344
|
}
|
|
344
345
|
taggingDetails.forEach( async ( item ) => {
|
|
345
|
-
await axios.post( `${
|
|
346
|
+
await axios.post( `${JSON.parse( process.env.URL ).oldapidomain}/tagging/oldTaggingDelete/${item._id}`, '', { headers: { Authorization: 'Bearer d47433f8-9a33-47c7-ba43-1a0fbac28f66' } } ).then( ( res ) => {
|
|
346
347
|
logger.info( res?.data );
|
|
347
348
|
} ).catch( ( error ) => {
|
|
348
349
|
logger.error( { error: error } );
|
|
@@ -360,7 +361,7 @@ export const deleteTag = async ( req, res ) => {
|
|
|
360
361
|
eventType: '',
|
|
361
362
|
showTo: [ 'client', 'tango' ],
|
|
362
363
|
};
|
|
363
|
-
insertOpenSearchData(
|
|
364
|
+
insertOpenSearchData( JSON.parse( process.env.OPENSEARCH )?.activityLog, logObj );
|
|
364
365
|
await updatezoneTagging( req, res );
|
|
365
366
|
// return res.sendSuccess( 'Tag Deleted Successfully' );
|
|
366
367
|
} catch ( e ) {
|
|
@@ -466,7 +467,7 @@ async function getCamTaggingDetails( req, res ) {
|
|
|
466
467
|
zones: zoneList,
|
|
467
468
|
// totalZone: zoneList.length,
|
|
468
469
|
storeId: req.body.storeId,
|
|
469
|
-
bucketName:
|
|
470
|
+
bucketName: JSON.parse( process.env.BUCKET ).zoneTaggingImage,
|
|
470
471
|
} );
|
|
471
472
|
}
|
|
472
473
|
|
|
@@ -480,15 +481,15 @@ async function getCamTaggingDetails( req, res ) {
|
|
|
480
481
|
export const updatezoneTagging = async ( req, res ) => {
|
|
481
482
|
try {
|
|
482
483
|
let camDetails = await getCamTaggingDetails( req, res );
|
|
483
|
-
if ( !camDetails ) {
|
|
484
|
+
if ( !camDetails.length ) {
|
|
484
485
|
return res.sendError( 'Something Went Wrong', 500 );
|
|
485
486
|
}
|
|
486
|
-
const response = await axios.post(
|
|
487
|
+
const response = await axios.post( JSON.parse( process.env.URL ).zoneTaggingLamdaUrl, camDetails );
|
|
487
488
|
if ( response?.data?.status && response?.data?.status == 'success' ) {
|
|
488
489
|
let fileData = {
|
|
489
490
|
Key: `${req.body.storeId}/zonetagging/`,
|
|
490
491
|
fileName: `${req.body.storeId}_zonetagging.json`,
|
|
491
|
-
Bucket:
|
|
492
|
+
Bucket: JSON.parse( process.env.BUCKET ).zoneTaggingImage,
|
|
492
493
|
body: JSON.stringify( camDetails ),
|
|
493
494
|
ContentType: 'application/json',
|
|
494
495
|
};
|
|
@@ -517,12 +518,12 @@ export const updateOldData = async ( req, res ) => {
|
|
|
517
518
|
if ( !camDetails ) {
|
|
518
519
|
logger.error( { message: 'no data', store: item.storeId } );
|
|
519
520
|
}
|
|
520
|
-
const response = await axios.post(
|
|
521
|
+
const response = await axios.post( JSON.parse( process.env.URL ).zoneTaggingLamdaUrl, camDetails );
|
|
521
522
|
if ( response?.data?.status && response?.data?.status == 'success' ) {
|
|
522
523
|
let fileData = {
|
|
523
524
|
Key: `${req.body.storeId}/zonetagging/`,
|
|
524
525
|
fileName: `${req.body.storeId}_zonetagging.json`,
|
|
525
|
-
Bucket:
|
|
526
|
+
Bucket: JSON.parse( process.env.BUCKET ).zoneTaggingImage,
|
|
526
527
|
body: JSON.stringify( camDetails ),
|
|
527
528
|
ContentType: 'application/json',
|
|
528
529
|
};
|