tango-app-api-store-zone 3.3.1-beta.27 → 3.3.1-beta.29
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
|
@@ -1174,7 +1174,6 @@ export const getCameraTagging = async ( req, res ) => {
|
|
|
1174
1174
|
// query = { clientId: req.query.clientId, cameraId: camDetails._id, streamName: camDetails.streamName, storeId: req.query.storeId };
|
|
1175
1175
|
// }
|
|
1176
1176
|
let taggingDetails = await taggingService.find( query );
|
|
1177
|
-
console.log( '🚀 ~ getCameraTagging ~ taggingDetails:', taggingDetails );
|
|
1178
1177
|
if ( taggingDetails.length ) {
|
|
1179
1178
|
let coordinates = [];
|
|
1180
1179
|
details = {
|
|
@@ -1326,15 +1325,14 @@ export const updateOldData = async ( req, res ) => {
|
|
|
1326
1325
|
if ( !upload.Key ) {
|
|
1327
1326
|
logger.error( { message: `JSON Upload Error`, store: item.storeId } );
|
|
1328
1327
|
}
|
|
1329
|
-
console.log( '🚀 ~ updateOldData ~ index:', index );
|
|
1330
|
-
if ( index == tagDetails.entries().length ) {
|
|
1331
|
-
res.sendSuccess( 'Zone Updated Successfully' );
|
|
1332
|
-
}
|
|
1333
1328
|
} else {
|
|
1334
1329
|
logger.error( { message: 'no data', store: item.storeId } );
|
|
1335
1330
|
return res.sendError( 'something went wrong', 500 );
|
|
1336
1331
|
}
|
|
1337
1332
|
}
|
|
1333
|
+
if ( index == tagDetails.length-1 ) {
|
|
1334
|
+
res.sendSuccess( 'Zone Updated Successfully' );
|
|
1335
|
+
}
|
|
1338
1336
|
}
|
|
1339
1337
|
} else {
|
|
1340
1338
|
res.sendSuccess( 'Zone Updated Successfully' );
|
|
@@ -1497,7 +1495,7 @@ export const getZoneTaggingDetails = async ( req, res ) => {
|
|
|
1497
1495
|
searchValue,
|
|
1498
1496
|
sortColumName,
|
|
1499
1497
|
sortBy,
|
|
1500
|
-
limit
|
|
1498
|
+
limit,
|
|
1501
1499
|
offset = 1,
|
|
1502
1500
|
export: isExport,
|
|
1503
1501
|
} = req.body;
|
|
@@ -1573,10 +1571,10 @@ export const getZoneTaggingDetails = async ( req, res ) => {
|
|
|
1573
1571
|
[] ),
|
|
1574
1572
|
...( isExport ?
|
|
1575
1573
|
[] :
|
|
1576
|
-
[
|
|
1574
|
+
limit ? [
|
|
1577
1575
|
{ $skip: ( offset - 1 ) * limit },
|
|
1578
1576
|
{ $limit: Number( limit ) },
|
|
1579
|
-
] ),
|
|
1577
|
+
] : [] ),
|
|
1580
1578
|
],
|
|
1581
1579
|
},
|
|
1582
1580
|
},
|
|
@@ -1719,9 +1717,12 @@ export const addZoneCustomTag = async ( req, res ) => {
|
|
|
1719
1717
|
return res.sendError( 'clientId and zoneName are required', 400 );
|
|
1720
1718
|
}
|
|
1721
1719
|
|
|
1720
|
+
// Escape regex special characters in tagName to avoid invalid regex patterns
|
|
1721
|
+
const escapedTagName = tagName.replace( /[.*+?^${}()|[\]\\]/g, '\\$&' );
|
|
1722
|
+
|
|
1722
1723
|
// Case-insensitive check for existing tag
|
|
1723
1724
|
const existingTag = await customZoneTagService.findOne(
|
|
1724
|
-
{ clientId, tagName: { $regex: `^${
|
|
1725
|
+
{ clientId, tagName: { $regex: `^${escapedTagName}$`, $options: 'i' }, _id: { $ne: _id } },
|
|
1725
1726
|
);
|
|
1726
1727
|
|
|
1727
1728
|
if ( existingTag ) {
|
|
@@ -1730,8 +1731,10 @@ export const addZoneCustomTag = async ( req, res ) => {
|
|
|
1730
1731
|
|
|
1731
1732
|
let groupDoc = null;
|
|
1732
1733
|
if ( groupName ) {
|
|
1734
|
+
// Escape regex special characters in groupName to avoid invalid regex patterns
|
|
1735
|
+
const escapedGroupName = groupName.replace( /[.*+?^${}()|[\]\\]/g, '\\$&' );
|
|
1733
1736
|
// Case-insensitive check for existing group
|
|
1734
|
-
groupDoc = await customzonegrouping.findOne( { clientId, groupName: { $regex: `^${
|
|
1737
|
+
groupDoc = await customzonegrouping.findOne( { clientId, groupName: { $regex: `^${escapedGroupName}$`, $options: 'i' } } );
|
|
1735
1738
|
}
|
|
1736
1739
|
|
|
1737
1740
|
if ( !isExistingGroup && groupDoc ) {
|
|
@@ -1815,10 +1818,13 @@ export const uploadBulkZoneTag = async ( req, res ) => {
|
|
|
1815
1818
|
const uniqueGroupNames = [ ...new Set( zonesArray.map( ( zone ) => zone.groupName ).filter( ( name ) => name && name !== '' && name !== null ) ) ];
|
|
1816
1819
|
|
|
1817
1820
|
for ( const userGroupName of uniqueGroupNames ) {
|
|
1821
|
+
// Escape regex special characters in group name to avoid invalid regex patterns
|
|
1822
|
+
const escapedUserGroupName = userGroupName.replace( /[.*+?^${}()|[\]\\]/g, '\\$&' );
|
|
1823
|
+
|
|
1818
1824
|
// Case-insensitive check for existing group
|
|
1819
1825
|
const existingGroupDoc = await customzonegrouping.findOne( {
|
|
1820
1826
|
clientId,
|
|
1821
|
-
groupName: { $regex: `^${
|
|
1827
|
+
groupName: { $regex: `^${escapedUserGroupName}$`, $options: 'i' },
|
|
1822
1828
|
} );
|
|
1823
1829
|
|
|
1824
1830
|
if ( existingGroupDoc ) {
|
|
@@ -1890,9 +1896,10 @@ export const uploadBulkZoneTag = async ( req, res ) => {
|
|
|
1890
1896
|
if ( zoneGroupDataList.length > 0 ) {
|
|
1891
1897
|
for ( const groupData of zoneGroupDataList ) {
|
|
1892
1898
|
// Case-insensitive check for existing group (same as addZoneCustomTag)
|
|
1899
|
+
const escapedGroupName = groupData.groupName.replace( /[.*+?^${}()|[\]\\]/g, '\\$&' );
|
|
1893
1900
|
const groupDoc = await customzonegrouping.findOne( {
|
|
1894
1901
|
clientId,
|
|
1895
|
-
groupName: { $regex: `^${
|
|
1902
|
+
groupName: { $regex: `^${escapedGroupName}$`, $options: 'i' },
|
|
1896
1903
|
} );
|
|
1897
1904
|
|
|
1898
1905
|
if ( !groupDoc ) {
|
|
@@ -1944,6 +1951,7 @@ export const uploadBulkZoneTag = async ( req, res ) => {
|
|
|
1944
1951
|
count: createdTagNames.length,
|
|
1945
1952
|
} );
|
|
1946
1953
|
} catch ( e ) {
|
|
1954
|
+
console.log( 'uploadBulkZoneTags error :', e );
|
|
1947
1955
|
logger.error( { error: e, function: 'addBulkZoneCustomTag' } );
|
|
1948
1956
|
return res.sendError( 'Failed to upload zone-config file', 500 );
|
|
1949
1957
|
}
|
|
@@ -1958,15 +1966,19 @@ export const updateZoneCustomTag = async ( req, res ) => {
|
|
|
1958
1966
|
}
|
|
1959
1967
|
|
|
1960
1968
|
let findQuery = {};
|
|
1969
|
+
|
|
1970
|
+
// Escape regex special characters in tag names to avoid invalid regex patterns
|
|
1971
|
+
const escapedTagName = tagName.replace( /[.*+?^${}()|[\]\\]/g, '\\$&' );
|
|
1972
|
+
const escapedOldTag = oldTag ? oldTag.replace( /[.*+?^${}()|[\]\\]/g, '\\$&' ) : null;
|
|
1961
1973
|
if ( oldTag !== undefined && oldTag !== null && tagName !== oldTag ) {
|
|
1962
1974
|
findQuery = {
|
|
1963
1975
|
clientId,
|
|
1964
|
-
tagName: { $regex: `^${
|
|
1976
|
+
tagName: { $regex: `^${escapedOldTag}$`, $options: 'i' },
|
|
1965
1977
|
};
|
|
1966
1978
|
} else {
|
|
1967
1979
|
findQuery = {
|
|
1968
1980
|
clientId,
|
|
1969
|
-
tagName: { $regex: `^${
|
|
1981
|
+
tagName: { $regex: `^${escapedTagName}$`, $options: 'i' },
|
|
1970
1982
|
};
|
|
1971
1983
|
}
|
|
1972
1984
|
await externalService.updateMany( { zoneName: oldTag, clientId: req.body.clientId }, { zoneName: req.body.tagName } );
|
|
@@ -1989,7 +2001,7 @@ export const updateZoneCustomTag = async ( req, res ) => {
|
|
|
1989
2001
|
if ( isTagNameChanging ) {
|
|
1990
2002
|
const existingTagWithNewName = await customZoneTagService.findOne( {
|
|
1991
2003
|
clientId,
|
|
1992
|
-
tagName: { $regex: `^${
|
|
2004
|
+
tagName: { $regex: `^${escapedTagName}$`, $options: 'i' },
|
|
1993
2005
|
} );
|
|
1994
2006
|
|
|
1995
2007
|
// If a tag with the new name exists and it's not the same record we're updating, return error
|
|
@@ -2026,8 +2038,10 @@ export const updateZoneCustomTag = async ( req, res ) => {
|
|
|
2026
2038
|
if ( oldGroupNameStr !== newGroupNameStr ) {
|
|
2027
2039
|
// Remove tag from old group if oldGroupName exists
|
|
2028
2040
|
if ( actualOldGroupName ) {
|
|
2041
|
+
// Escape regex special characters in actualOldGroupName
|
|
2042
|
+
const escapedActualOldGroupName = actualOldGroupName.replace( /[.*+?^${}()|[\]\\]/g, '\\$&' );
|
|
2029
2043
|
const oldGroupDoc = await customzonegrouping.findOne(
|
|
2030
|
-
{ clientId, groupName: { $regex: `^${
|
|
2044
|
+
{ clientId, groupName: { $regex: `^${escapedActualOldGroupName}$`, $options: 'i' } },
|
|
2031
2045
|
);
|
|
2032
2046
|
if ( oldGroupDoc ) {
|
|
2033
2047
|
await customzonegrouping.updateOne(
|
|
@@ -2040,8 +2054,10 @@ export const updateZoneCustomTag = async ( req, res ) => {
|
|
|
2040
2054
|
|
|
2041
2055
|
// Add tag to new group if groupName exists
|
|
2042
2056
|
if ( groupName ) {
|
|
2057
|
+
// Escape regex special characters in groupName
|
|
2058
|
+
const escapedGroupName = groupName.replace( /[.*+?^${}()|[\]\\]/g, '\\$&' );
|
|
2043
2059
|
let newGroupDoc = await customzonegrouping.findOne(
|
|
2044
|
-
{ clientId, groupName: { $regex: `^${
|
|
2060
|
+
{ clientId, groupName: { $regex: `^${escapedGroupName}$`, $options: 'i' } },
|
|
2045
2061
|
);
|
|
2046
2062
|
|
|
2047
2063
|
if ( !newGroupDoc && !isExistingGroup ) {
|
|
@@ -2064,7 +2080,9 @@ export const updateZoneCustomTag = async ( req, res ) => {
|
|
|
2064
2080
|
} else if ( groupName && oldGroupNameStr === newGroupNameStr && oldTag && tagName !== oldTag ) {
|
|
2065
2081
|
// If groupName is same (and not null) but tagName changed, update the tagName in the group's zonesTagged
|
|
2066
2082
|
console.log( 'Group name same but tagName changed, updating group zonesTagged' );
|
|
2067
|
-
|
|
2083
|
+
// Escape regex special characters in groupName
|
|
2084
|
+
const escapedGroupName = groupName.replace( /[.*+?^${}()|[\]\\]/g, '\\$&' );
|
|
2085
|
+
const groupDoc = await customzonegrouping.findOne( { clientId, groupName: { $regex: `^${escapedGroupName}$`, $options: 'i' } } );
|
|
2068
2086
|
if ( groupDoc ) {
|
|
2069
2087
|
await customzonegrouping.updateOne(
|
|
2070
2088
|
{ _id: groupDoc._id },
|
|
@@ -2188,7 +2206,7 @@ export const getZoneGroupDetails = async ( req, res ) => {
|
|
|
2188
2206
|
searchValue,
|
|
2189
2207
|
sortColumName,
|
|
2190
2208
|
sortBy,
|
|
2191
|
-
limit
|
|
2209
|
+
limit,
|
|
2192
2210
|
offset = 1,
|
|
2193
2211
|
export: isExport,
|
|
2194
2212
|
} = req.body;
|
|
@@ -2276,10 +2294,10 @@ export const getZoneGroupDetails = async ( req, res ) => {
|
|
|
2276
2294
|
|
|
2277
2295
|
...( isExport ?
|
|
2278
2296
|
[] :
|
|
2279
|
-
[
|
|
2297
|
+
limit ? [
|
|
2280
2298
|
{ $skip: ( offset - 1 ) * limit },
|
|
2281
2299
|
{ $limit: Number( limit ) },
|
|
2282
|
-
] ),
|
|
2300
|
+
] : [] ),
|
|
2283
2301
|
],
|
|
2284
2302
|
},
|
|
2285
2303
|
},
|
|
@@ -2297,6 +2315,7 @@ export const getZoneGroupDetails = async ( req, res ) => {
|
|
|
2297
2315
|
const totalZoneCount = await customZoneTagService.count( { clientId } );
|
|
2298
2316
|
|
|
2299
2317
|
if ( isExport && zoneGroupList.length ) {
|
|
2318
|
+
console.log( 'Exporting Zone Group Data:', JSON.stringify( zoneGroupList ) );
|
|
2300
2319
|
const exportdata = zoneGroupList.map( ( element ) => ( {
|
|
2301
2320
|
'Zone Group Name': element.groupName || '--',
|
|
2302
2321
|
'Zones tagged': Array.isArray( element.zonesTagged ) ?
|
|
@@ -2456,10 +2475,13 @@ export const addZoneGroup = async ( req, res ) => {
|
|
|
2456
2475
|
return res.sendError( 'clientId and groupName are required', 400 );
|
|
2457
2476
|
}
|
|
2458
2477
|
|
|
2478
|
+
// Escape regex special characters in groupName to avoid invalid regex patterns
|
|
2479
|
+
const escapedGroupName = groupName.replace( /[.*+?^${}()|[\]\\]/g, '\\$&' );
|
|
2480
|
+
|
|
2459
2481
|
// Case-insensitive check for existing group
|
|
2460
2482
|
const existingGroup = await customzonegrouping.findOne( {
|
|
2461
2483
|
clientId,
|
|
2462
|
-
groupName: { $regex: `^${
|
|
2484
|
+
groupName: { $regex: `^${escapedGroupName}$`, $options: 'i' },
|
|
2463
2485
|
} );
|
|
2464
2486
|
|
|
2465
2487
|
if ( existingGroup ) {
|
|
@@ -2530,10 +2552,14 @@ export const updateZoneGroup = async ( req, res ) => {
|
|
|
2530
2552
|
}
|
|
2531
2553
|
|
|
2532
2554
|
let findGroup = await customzonegrouping.findOne( { _id: _id } );
|
|
2555
|
+
|
|
2556
|
+
// Escape regex special characters in groupName to avoid invalid regex patterns
|
|
2557
|
+
const escapedGroupName = groupName.replace( /[.*+?^${}()|[\]\\]/g, '\\$&' );
|
|
2558
|
+
|
|
2533
2559
|
// Case-insensitive check for existing group (excluding current group)
|
|
2534
2560
|
const existingGroup = await customzonegrouping.findOne( {
|
|
2535
2561
|
clientId: clientId,
|
|
2536
|
-
groupName: { $regex: `^${
|
|
2562
|
+
groupName: { $regex: `^${escapedGroupName}$`, $options: 'i' },
|
|
2537
2563
|
_id: { $ne: _id },
|
|
2538
2564
|
} );
|
|
2539
2565
|
if ( existingGroup && existingGroup.groupName ) {
|
|
@@ -2702,7 +2728,7 @@ export const deleteZoneGroup = async ( req, res ) => {
|
|
|
2702
2728
|
};
|
|
2703
2729
|
|
|
2704
2730
|
export async function oldTagsMigration() {
|
|
2705
|
-
let uniqueTags = await taggingService.find( { productName: 'tangoZone' } );
|
|
2731
|
+
let uniqueTags = await taggingService.find( { productName: 'tangoZone', clientId: '440' } );
|
|
2706
2732
|
const result = _.uniqBy( uniqueTags, 'tagName' );
|
|
2707
2733
|
|
|
2708
2734
|
|