tango-app-api-client 3.6.5-vms.11 → 3.6.5-vms.12
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 +85 -3
- package/src/dtos/client.dtos.js +4 -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.12",
|
|
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';
|
|
@@ -3007,7 +3086,10 @@ export async function updateTaggingType( req, res ) {
|
|
|
3007
3086
|
{
|
|
3008
3087
|
$addToSet: {
|
|
3009
3088
|
'footfallDirectoryConfigs.taggingLimitation': {
|
|
3010
|
-
$
|
|
3089
|
+
$addToSet: {
|
|
3090
|
+
effectiveFrom: new Date().toISOString().split( 'T' )[0],
|
|
3091
|
+
values: uniqueData,
|
|
3092
|
+
},
|
|
3011
3093
|
},
|
|
3012
3094
|
},
|
|
3013
3095
|
},
|
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 = {
|