tango-app-api-client 3.6.5-vms.11 → 3.6.5-vms.13
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 +1 -2
- package/package.json +4 -4
- package/src/controllers/client.controllers.js +113 -34
- package/src/dtos/client.dtos.js +7 -0
package/index.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
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';
|
|
6
5
|
|
|
7
|
-
export { clientRouter, clientDocs
|
|
6
|
+
export { clientRouter, clientDocs };
|
|
8
7
|
|
package/package.json
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-client",
|
|
3
|
-
"version": "3.6.5-vms.
|
|
3
|
+
"version": "3.6.5-vms.13",
|
|
4
4
|
"description": "client",
|
|
5
5
|
"main": "index.js",
|
|
6
|
-
"type": "module",
|
|
6
|
+
"type": "module",
|
|
7
7
|
"scripts": {
|
|
8
|
-
"start": "nodemon --exec \"eslint --fix . && node
|
|
8
|
+
"start": "nodemon --exec \"eslint --fix . && node app.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"
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"npm": "^10.9.1",
|
|
32
32
|
"sharp": "^0.34.3",
|
|
33
33
|
"swagger-ui-express": "^5.0.0",
|
|
34
|
-
"tango-api-schema": "^2.
|
|
34
|
+
"tango-api-schema": "^2.5.2",
|
|
35
35
|
"tango-app-api-middleware": "^3.6.0",
|
|
36
36
|
"winston": "^3.11.0",
|
|
37
37
|
"winston-daily-rotate-file": "^5.0.0"
|
|
@@ -2967,10 +2967,89 @@ export async function updateFDConfig( req, res ) {
|
|
|
2967
2967
|
export async function getFDConfig( req, res ) {
|
|
2968
2968
|
try {
|
|
2969
2969
|
const inputData = req.query;
|
|
2970
|
-
let result = await findOneClient( { clientId: inputData.clientId }, { footfallDirectoryConfigs: 1 } );
|
|
2971
|
-
|
|
2970
|
+
// let result = await findOneClient( { clientId: inputData.clientId }, { footfallDirectoryConfigs: 1 } );
|
|
2971
|
+
const configQuery = [
|
|
2972
|
+
{
|
|
2973
|
+
$match: {
|
|
2974
|
+
clientId: inputData?.clientId,
|
|
2975
|
+
},
|
|
2976
|
+
},
|
|
2977
|
+
|
|
2978
|
+
// Convert all effectiveFrom to proper Date
|
|
2979
|
+
{
|
|
2980
|
+
$addFields: {
|
|
2981
|
+
taggingLimitationWithDate: {
|
|
2982
|
+
$map: {
|
|
2983
|
+
input: '$footfallDirectoryConfigs.taggingLimitation',
|
|
2984
|
+
as: 'item',
|
|
2985
|
+
in: {
|
|
2986
|
+
effectiveFrom: { $toDate: '$$item.effectiveFrom' },
|
|
2987
|
+
values: '$$item.values',
|
|
2988
|
+
},
|
|
2989
|
+
},
|
|
2990
|
+
},
|
|
2991
|
+
},
|
|
2992
|
+
},
|
|
2993
|
+
|
|
2994
|
+
// Filter items <= input date
|
|
2995
|
+
{
|
|
2996
|
+
$addFields: {
|
|
2997
|
+
matchedLimitation: {
|
|
2998
|
+
$filter: {
|
|
2999
|
+
input: '$taggingLimitationWithDate',
|
|
3000
|
+
as: 'item',
|
|
3001
|
+
cond: {
|
|
3002
|
+
$lte: [
|
|
3003
|
+
'$$item.effectiveFrom',
|
|
3004
|
+
{ $toDate: inputData.dateString },
|
|
3005
|
+
],
|
|
3006
|
+
},
|
|
3007
|
+
},
|
|
3008
|
+
},
|
|
3009
|
+
},
|
|
3010
|
+
},
|
|
3011
|
+
|
|
3012
|
+
// Sort DESC and pick ONLY top 1 -> latest effective record
|
|
3013
|
+
{
|
|
3014
|
+
$addFields: {
|
|
3015
|
+
effectiveLimitation: {
|
|
3016
|
+
$arrayElemAt: [
|
|
3017
|
+
{
|
|
3018
|
+
$slice: [
|
|
3019
|
+
{
|
|
3020
|
+
$sortArray: {
|
|
3021
|
+
input: '$matchedLimitation',
|
|
3022
|
+
sortBy: { effectiveFrom: -1 },
|
|
3023
|
+
},
|
|
3024
|
+
},
|
|
3025
|
+
1,
|
|
3026
|
+
],
|
|
3027
|
+
},
|
|
3028
|
+
0,
|
|
3029
|
+
],
|
|
3030
|
+
},
|
|
3031
|
+
},
|
|
3032
|
+
},
|
|
3033
|
+
|
|
3034
|
+
{
|
|
3035
|
+
$project: {
|
|
3036
|
+
'config': 1,
|
|
3037
|
+
'effectiveLimitation': 1,
|
|
3038
|
+
'footfallDirectoryConfigs': 1,
|
|
3039
|
+
|
|
3040
|
+
},
|
|
3041
|
+
},
|
|
3042
|
+
];
|
|
3043
|
+
|
|
3044
|
+
|
|
3045
|
+
const getData = await aggregateClient( configQuery );
|
|
3046
|
+
let result = getData[0];
|
|
3047
|
+
if ( !result || result===null ) {
|
|
2972
3048
|
return res.sendError( 'no data found', 204 );
|
|
2973
3049
|
}
|
|
3050
|
+
result.footfallDirectoryConfigs.taggingLimitation = result?.effectiveLimitation?.values;
|
|
3051
|
+
delete result.effectiveLimitation;
|
|
3052
|
+
|
|
2974
3053
|
return res.sendSuccess( result );
|
|
2975
3054
|
} catch ( error ) {
|
|
2976
3055
|
const err = error.message || 'Internal Server Error';
|
|
@@ -2983,38 +3062,38 @@ export async function getFDConfig( req, res ) {
|
|
|
2983
3062
|
export async function updateTaggingType( req, res ) {
|
|
2984
3063
|
try {
|
|
2985
3064
|
const inputData = req.body;
|
|
2986
|
-
|
|
2987
|
-
const
|
|
2988
|
-
|
|
2989
|
-
|
|
2990
|
-
await clientModel.updateOne(
|
|
2991
|
-
{ 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(
|
|
2992
3069
|
{
|
|
2993
|
-
|
|
2994
|
-
|
|
2995
|
-
type: { $in: types },
|
|
2996
|
-
},
|
|
2997
|
-
},
|
|
3070
|
+
'clientId': inputData?.clientId,
|
|
3071
|
+
'footfallDirectoryConfigs.taggingLimitation.effectiveFrom': today,
|
|
2998
3072
|
},
|
|
2999
|
-
);
|
|
3000
|
-
|
|
3001
|
-
// Remove duplicate entries by type
|
|
3002
|
-
const uniqueData = uniqueByType( inputData.taggingLimitation );
|
|
3003
|
-
|
|
3004
|
-
// Step 2: insert fresh new items
|
|
3005
|
-
let result =await clientModel.updateOne(
|
|
3006
|
-
{ clientId: inputQuery.clientId },
|
|
3007
3073
|
{
|
|
3008
|
-
$
|
|
3009
|
-
'footfallDirectoryConfigs.taggingLimitation':
|
|
3010
|
-
$each: uniqueData,
|
|
3011
|
-
},
|
|
3074
|
+
$set: {
|
|
3075
|
+
'footfallDirectoryConfigs.taggingLimitation.$.values': newValues,
|
|
3012
3076
|
},
|
|
3013
3077
|
},
|
|
3014
3078
|
);
|
|
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,
|
|
3088
|
+
},
|
|
3089
|
+
},
|
|
3090
|
+
},
|
|
3091
|
+
);
|
|
3092
|
+
}
|
|
3093
|
+
|
|
3015
3094
|
|
|
3016
3095
|
if ( result?.acknowledged === true ) {
|
|
3017
|
-
return res.sendSuccess(
|
|
3096
|
+
return res.sendSuccess( 'Tagging limitation has been updated' );
|
|
3018
3097
|
} else {
|
|
3019
3098
|
return res.sendError( 'no data', 204 );
|
|
3020
3099
|
}
|
|
@@ -3025,14 +3104,14 @@ export async function updateTaggingType( req, res ) {
|
|
|
3025
3104
|
}
|
|
3026
3105
|
}
|
|
3027
3106
|
|
|
3028
|
-
function uniqueByType( arr ) {
|
|
3029
|
-
|
|
3030
|
-
|
|
3031
|
-
|
|
3032
|
-
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
}
|
|
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
|
+
// }
|
|
3036
3115
|
|
|
3037
3116
|
export async function createStoreRequest( req, res ) {
|
|
3038
3117
|
try {
|
package/src/dtos/client.dtos.js
CHANGED
|
@@ -377,8 +377,12 @@ export const updateFDConfigQuerySchema = joi.object( {
|
|
|
377
377
|
clientId: joi.string().required(),
|
|
378
378
|
} );
|
|
379
379
|
|
|
380
|
+
|
|
381
|
+
const todayDate = () => new Date().toISOString().split( 'T' )[0];
|
|
382
|
+
|
|
380
383
|
export const getFDConfigSchema = joi.object( {
|
|
381
384
|
clientId: joi.string().required(),
|
|
385
|
+
dateString: joi.string().optional().default( () => todayDate() ),
|
|
382
386
|
} );
|
|
383
387
|
|
|
384
388
|
export const updateFDConfigValid = {
|
|
@@ -395,6 +399,9 @@ export const updateTaggingTypeSchema = joi.object( {
|
|
|
395
399
|
type: joi.string().required(),
|
|
396
400
|
value: joi.number().required(),
|
|
397
401
|
unit: joi.string().required(),
|
|
402
|
+
name: joi.string().required(),
|
|
403
|
+
iconName: joi.string().required(),
|
|
404
|
+
key: joi.string().required(),
|
|
398
405
|
} ) ).required(),
|
|
399
406
|
|
|
400
407
|
} );
|