tango-app-api-client 3.6.5-vms.12 → 3.6.5-vms.14

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/index.js CHANGED
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { clientRouter } from './src/routes/client.routes.js';
4
4
  import { clientDocs } from './src/docs/client.docs.js';
5
+ import { vmsauditRouter } from './src/routes/vmsAudit.routes.js';
5
6
 
6
- export { clientRouter, clientDocs };
7
+ export { clientRouter, clientDocs, vmsauditRouter };
7
8
 
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "tango-app-api-client",
3
- "version": "3.6.5-vms.12",
3
+ "version": "3.6.5-vms.14",
4
4
  "description": "client",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
7
  "scripts": {
8
- "start": "nodemon --exec \"eslint --fix . && node app.js\"",
8
+ "start": "nodemon --exec \"eslint --fix . && node index.js\"",
9
9
  "build:patch": "node build.js patch && npm publish",
10
10
  "build:minor": "node build.js minor && npm publish",
11
11
  "build:major": "node build.js major && npm publish"
@@ -3062,41 +3062,38 @@ export async function getFDConfig( req, res ) {
3062
3062
  export async function updateTaggingType( req, res ) {
3063
3063
  try {
3064
3064
  const inputData = req.body;
3065
-
3066
- const inputQuery = req.query; // up
3067
- const types = inputData?.taggingLimitation?.map( ( x ) => x.type );
3068
- // Step 1: remove existing items with same "type"
3069
- await clientModel.updateOne(
3070
- { clientId: inputQuery.clientId },
3065
+ const newValues = inputData.taggingLimitation;
3066
+ const today = new Date().toISOString().split( 'T' )[0];
3067
+ logger.info( { today, newValues } );
3068
+ const result = await clientModel.updateOne(
3071
3069
  {
3072
- $pull: {
3073
- 'footfallDirectoryConfigs.taggingLimitation': {
3074
- type: { $in: types },
3075
- },
3070
+ 'clientId': inputData?.clientId,
3071
+ 'footfallDirectoryConfigs.taggingLimitation.effectiveFrom': today,
3072
+ },
3073
+ {
3074
+ $set: {
3075
+ 'footfallDirectoryConfigs.taggingLimitation.$.values': newValues,
3076
3076
  },
3077
3077
  },
3078
3078
  );
3079
-
3080
- // Remove duplicate entries by type
3081
- const uniqueData = uniqueByType( inputData.taggingLimitation );
3082
-
3083
- // Step 2: insert fresh new items
3084
- let result =await clientModel.updateOne(
3085
- { clientId: inputQuery.clientId },
3086
- {
3087
- $addToSet: {
3088
- 'footfallDirectoryConfigs.taggingLimitation': {
3089
- $addToSet: {
3090
- effectiveFrom: new Date().toISOString().split( 'T' )[0],
3091
- values: uniqueData,
3079
+ logger.info( { result } );
3080
+ if ( result?.matchedCount === 0 ) {
3081
+ await clientModel.updateOne(
3082
+ { clientId: inputData.clientId },
3083
+ {
3084
+ $push: {
3085
+ 'footfallDirectoryConfigs.taggingLimitation': {
3086
+ effectiveFrom: today,
3087
+ values: newValues,
3092
3088
  },
3093
3089
  },
3094
3090
  },
3095
- },
3096
- );
3091
+ );
3092
+ }
3093
+
3097
3094
 
3098
3095
  if ( result?.acknowledged === true ) {
3099
- return res.sendSuccess( result );
3096
+ return res.sendSuccess( 'Tagging limitation has been updated' );
3100
3097
  } else {
3101
3098
  return res.sendError( 'no data', 204 );
3102
3099
  }
@@ -3107,14 +3104,14 @@ export async function updateTaggingType( req, res ) {
3107
3104
  }
3108
3105
  }
3109
3106
 
3110
- function uniqueByType( arr ) {
3111
- const seen = new Set();
3112
- return arr.filter( ( item ) => {
3113
- if ( seen.has( item.type ) ) return false;
3114
- seen.add( item.type );
3115
- return true;
3116
- } );
3117
- }
3107
+ // function uniqueByType( arr ) {
3108
+ // const seen = new Set();
3109
+ // return arr.filter( ( item ) => {
3110
+ // if ( seen.has( item.type ) ) return false;
3111
+ // seen.add( item.type );
3112
+ // return true;
3113
+ // } );
3114
+ // }
3118
3115
 
3119
3116
  export async function createStoreRequest( req, res ) {
3120
3117
  try {
@@ -399,6 +399,9 @@ export const updateTaggingTypeSchema = joi.object( {
399
399
  type: joi.string().required(),
400
400
  value: joi.number().required(),
401
401
  unit: joi.string().required(),
402
+ name: joi.string().required(),
403
+ iconName: joi.string().required(),
404
+ key: joi.string().required(),
402
405
  } ) ).required(),
403
406
 
404
407
  } );