tango-app-api-client 3.6.5-vms.0 → 3.6.5-vms.1
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
|
@@ -18,6 +18,7 @@ import { countDocumentsClusters, createclusterModel } from '../service/cluster.s
|
|
|
18
18
|
import { countDocumentsTeams } from '../service/teams.service.js';
|
|
19
19
|
import { createauditConfig, updateauditConfig, aggregateAuditconfig } from '../service/auditConfig.service.js';
|
|
20
20
|
import { findOnerevopConfig, createrevopConfig, updaterevopConfig } from '../service/revopConfig.service.js';
|
|
21
|
+
import clientModel from 'tango-api-schema/schema/client.model.js';
|
|
21
22
|
|
|
22
23
|
export async function create( req, res ) {
|
|
23
24
|
try {
|
|
@@ -2977,3 +2978,58 @@ export async function getFDConfig( req, res ) {
|
|
|
2977
2978
|
}
|
|
2978
2979
|
}
|
|
2979
2980
|
|
|
2981
|
+
|
|
2982
|
+
export async function updateTaggingType( req, res ) {
|
|
2983
|
+
try {
|
|
2984
|
+
const inputData = req.body;
|
|
2985
|
+
|
|
2986
|
+
const inputQuery = req.query; // up
|
|
2987
|
+
const types = inputData?.taggingLimitation?.map( ( x ) => x.type );
|
|
2988
|
+
// Step 1: remove existing items with same "type"
|
|
2989
|
+
await clientModel.updateOne(
|
|
2990
|
+
{ clientId: inputQuery.clientId },
|
|
2991
|
+
{
|
|
2992
|
+
$pull: {
|
|
2993
|
+
'footfallDirectoryConfigs.taggingLimitation': {
|
|
2994
|
+
type: { $in: types },
|
|
2995
|
+
},
|
|
2996
|
+
},
|
|
2997
|
+
},
|
|
2998
|
+
);
|
|
2999
|
+
|
|
3000
|
+
// Remove duplicate entries by type
|
|
3001
|
+
const uniqueData = uniqueByType( inputData.taggingLimitation );
|
|
3002
|
+
|
|
3003
|
+
// Step 2: insert fresh new items
|
|
3004
|
+
let result =await clientModel.updateOne(
|
|
3005
|
+
{ clientId: inputQuery.clientId },
|
|
3006
|
+
{
|
|
3007
|
+
$addToSet: {
|
|
3008
|
+
'footfallDirectoryConfigs.taggingLimitation': {
|
|
3009
|
+
$each: uniqueData,
|
|
3010
|
+
},
|
|
3011
|
+
},
|
|
3012
|
+
},
|
|
3013
|
+
);
|
|
3014
|
+
|
|
3015
|
+
if ( result?.acknowledged === true ) {
|
|
3016
|
+
return res.sendSuccess( result );
|
|
3017
|
+
} else {
|
|
3018
|
+
return res.sendError( 'no data', 204 );
|
|
3019
|
+
}
|
|
3020
|
+
} catch ( error ) {
|
|
3021
|
+
const err = error.message || 'Internal Server Error';
|
|
3022
|
+
logger.error( { error: error, message: req.query, function: 'updateTaggingType' } );
|
|
3023
|
+
return res.sendError( err, 500 );
|
|
3024
|
+
}
|
|
3025
|
+
}
|
|
3026
|
+
|
|
3027
|
+
function uniqueByType( arr ) {
|
|
3028
|
+
const seen = new Set();
|
|
3029
|
+
return arr.filter( ( item ) => {
|
|
3030
|
+
if ( seen.has( item.type ) ) return false;
|
|
3031
|
+
seen.add( item.type );
|
|
3032
|
+
return true;
|
|
3033
|
+
} );
|
|
3034
|
+
}
|
|
3035
|
+
|
package/src/dtos/client.dtos.js
CHANGED
|
@@ -384,3 +384,23 @@ export const updateFDConfigValid = {
|
|
|
384
384
|
export const getFDConfigValid = {
|
|
385
385
|
query: getFDConfigSchema,
|
|
386
386
|
};
|
|
387
|
+
|
|
388
|
+
export const updateTaggingTypeSchema = joi.object( {
|
|
389
|
+
clientId: joi.string().required(),
|
|
390
|
+
taggingLimitation: joi.array().items( joi.object( {
|
|
391
|
+
type: joi.string().required(),
|
|
392
|
+
value: joi.number().required(),
|
|
393
|
+
unit: joi.string().required(),
|
|
394
|
+
} ) ).required(),
|
|
395
|
+
|
|
396
|
+
} );
|
|
397
|
+
|
|
398
|
+
export const updateTaggingTypeQuerySchema = joi.object( {
|
|
399
|
+
clientId: joi.string().required(),
|
|
400
|
+
} );
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
export const updateTaggingTypeValid = {
|
|
404
|
+
body: updateTaggingTypeSchema,
|
|
405
|
+
query: updateTaggingTypeQuerySchema,
|
|
406
|
+
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
|
|
2
2
|
import express from 'express';
|
|
3
|
-
import { activityLogValid, auditConfigValid, billingDetailsValid, brandInfoValid, clientCreationValid, clientDetailsValid, documentsValid, domainDetailsValid, featureConfigurationValid, getAssignedClientValid, getAuditConfigValid, getFDConfigValid, postClientCamApprovalValid, signatoryDetailsValid, ticketConfigurationValid, updateFDConfigValid, userConfigurationValid } from '../dtos/client.dtos.js';
|
|
4
|
-
import { auditConfiguration, changeStatus, clientCsmAssignAction, clientDetails, create, csmAssignConfirmation, domainDetailsConfiguration, getActivityLogs, getAuditConfiguration, getClients, getCsmUsers, getFDConfig, getOpsUsers, updateBillingDetails, updateBrandInfo, updateDocuments, updateFDConfig, updateFeatureConfiguration, updateSignatoryDetails, updateTicketConfiguration, userConfiguration } from '../controllers/client.controllers.js';
|
|
3
|
+
import { activityLogValid, auditConfigValid, billingDetailsValid, brandInfoValid, clientCreationValid, clientDetailsValid, documentsValid, domainDetailsValid, featureConfigurationValid, getAssignedClientValid, getAuditConfigValid, getFDConfigValid, postClientCamApprovalValid, signatoryDetailsValid, ticketConfigurationValid, updateFDConfigValid, updateTaggingTypeValid, userConfigurationValid } from '../dtos/client.dtos.js';
|
|
4
|
+
import { auditConfiguration, changeStatus, clientCsmAssignAction, clientDetails, create, csmAssignConfirmation, domainDetailsConfiguration, getActivityLogs, getAuditConfiguration, getClients, getCsmUsers, getFDConfig, getOpsUsers, updateBillingDetails, updateBrandInfo, updateDocuments, updateFDConfig, updateFeatureConfiguration, updateSignatoryDetails, updateTaggingType, updateTicketConfiguration, userConfiguration } from '../controllers/client.controllers.js';
|
|
5
5
|
import { accessVerification, isAllowedSessionHandler, validate } from 'tango-app-api-middleware';
|
|
6
6
|
import { clientListValid, detailedClientCountValid, createAuditConfigValid, AuditConfiglistValid, revopconfigValid, revopconfiggetValid } from '../dtos/client.dtos.js';
|
|
7
7
|
import { isclientIdExists, isclientNameExists, roleVerification } from '../validations/client.validations.js';
|
|
@@ -115,4 +115,5 @@ clientRouter.get( '/revopconfig', isAllowedSessionHandler,
|
|
|
115
115
|
// footfall directory configurations
|
|
116
116
|
clientRouter.put( '/update-footfall-directory-config', isAllowedSessionHandler, validate( updateFDConfigValid ), updateFDConfig );
|
|
117
117
|
clientRouter.get( '/get-footfall-directory-config', isAllowedSessionHandler, validate( getFDConfigValid ), getFDConfig );
|
|
118
|
+
clientRouter.put( '/update-tagging-type/', isAllowedSessionHandler, validate( updateTaggingTypeValid ), updateTaggingType );
|
|
118
119
|
|