tango-app-api-store-builder 1.0.0-beta-59 → 1.0.0-beta-61

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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-store-builder",
3
- "version": "1.0.0-beta-59",
3
+ "version": "1.0.0-beta-61",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -17,6 +17,9 @@ import mongoose from 'mongoose';
17
17
 
18
18
  export async function getStoreNames( req, res ) {
19
19
  try {
20
+ if ( req?.headers?.authorization?.split( ' ' )[1] !== 'hwjXfCD6TgMvc82cuSGZ9bNv9MuXsaiQ6uvx' ) {
21
+ return res.sendError( 'Unauthorized', 401 );
22
+ }
20
23
  if ( !req.files.file ) {
21
24
  return res.sendError( 'Excel file is required', 400 );
22
25
  }
@@ -40,6 +43,9 @@ export async function getStoreNames( req, res ) {
40
43
 
41
44
  export async function createFixtureConfig( req, res ) {
42
45
  try {
46
+ if ( req?.headers?.authorization?.split( ' ' )[1] !== 'hwjXfCD6TgMvc82cuSGZ9bNv9MuXsaiQ6uvx' ) {
47
+ return res.sendError( 'Unauthorized', 401 );
48
+ }
43
49
  if ( !req.files.file ) {
44
50
  return res.sendError( 'Invalid or missing Excel file', 400 );
45
51
  }
@@ -105,6 +111,9 @@ export async function createFixtureConfig( req, res ) {
105
111
 
106
112
  export async function createPlano( req, res ) {
107
113
  try {
114
+ if ( req?.headers?.authorization?.split( ' ' )[1] !== 'hwjXfCD6TgMvc82cuSGZ9bNv9MuXsaiQ6uvx' ) {
115
+ return res.sendError( 'Unauthorized', 401 );
116
+ }
108
117
  if ( !req.files.file ) {
109
118
  return res.sendError( 'Invalid or missing Excel file', 400 );
110
119
  }
@@ -156,6 +165,9 @@ export async function createPlano( req, res ) {
156
165
 
157
166
  export async function createFloors( req, res ) {
158
167
  try {
168
+ if ( req?.headers?.authorization?.split( ' ' )[1] !== 'hwjXfCD6TgMvc82cuSGZ9bNv9MuXsaiQ6uvx' ) {
169
+ return res.sendError( 'Unauthorized', 401 );
170
+ }
159
171
  if ( !req.files.file ) {
160
172
  return res.sendError( 'Invalid or missing Excel file', 400 );
161
173
  }
@@ -350,6 +362,9 @@ export async function createFloors( req, res ) {
350
362
 
351
363
  export async function createFixturesShelves( req, res ) {
352
364
  try {
365
+ if ( req?.headers?.authorization?.split( ' ' )[1] !== 'hwjXfCD6TgMvc82cuSGZ9bNv9MuXsaiQ6uvx' ) {
366
+ return res.sendError( 'Unauthorized', 401 );
367
+ }
353
368
  if ( !req.files.file ) {
354
369
  return res.sendError( 'Invalid or missing Excel file', 400 );
355
370
  }
@@ -573,8 +588,6 @@ export async function createFixturesShelves( req, res ) {
573
588
 
574
589
  await fixtureShelfService.create( shelfData );
575
590
 
576
- console.log( 'Shelf Data:', createdShelf );
577
-
578
591
  shelfIndex++;
579
592
  }
580
593
  }
@@ -582,7 +595,7 @@ export async function createFixturesShelves( req, res ) {
582
595
  }
583
596
 
584
597
  for ( let index = 0; index < backFixtures.length; index++ ) {
585
- const fixture = rightFixtures[index];
598
+ const fixture = backFixtures[index];
586
599
 
587
600
  const fixtureData = {
588
601
  'clientId': layoutDoc.clientId,
@@ -682,9 +695,7 @@ export async function createFixturesShelves( req, res ) {
682
695
  'sectionZone': section.sectionId,
683
696
  };
684
697
 
685
- const createdShelf = await fixtureShelfService.create( shelfData );
686
-
687
- console.log( 'Shelf Data:', createdShelf );
698
+ await fixtureShelfService.create( shelfData );
688
699
 
689
700
  shelfIndex++;
690
701
  }
@@ -794,9 +805,6 @@ export async function createFixturesShelves( req, res ) {
794
805
  };
795
806
 
796
807
  await fixtureShelfService.create( shelfData );
797
-
798
- console.log( 'Shelf Data:', createdShelf );
799
-
800
808
  shelfIndex++;
801
809
  }
802
810
  }
@@ -921,8 +929,6 @@ export async function createFixturesShelves( req, res ) {
921
929
 
922
930
  await fixtureShelfService.create( shelfData );
923
931
 
924
- console.log( 'Shelf Data:', createdShelf );
925
-
926
932
  shelfIndex++;
927
933
  }
928
934
  }
@@ -940,6 +946,9 @@ export async function createFixturesShelves( req, res ) {
940
946
 
941
947
  export async function updateFixturesShelves( req, res ) {
942
948
  try {
949
+ if ( req?.headers?.authorization?.split( ' ' )[1] !== 'hwjXfCD6TgMvc82cuSGZ9bNv9MuXsaiQ6uvx' ) {
950
+ return res.sendError( 'Unauthorized', 401 );
951
+ }
943
952
  if ( !req.files.file ) {
944
953
  return res.sendError( 'Invalid or missing Excel file', 400 );
945
954
  }
@@ -1531,6 +1540,9 @@ export async function updateFixturesShelves( req, res ) {
1531
1540
 
1532
1541
  export async function createVmData( req, res ) {
1533
1542
  try {
1543
+ if ( req?.headers?.authorization?.split( ' ' )[1] !== 'hwjXfCD6TgMvc82cuSGZ9bNv9MuXsaiQ6uvx' ) {
1544
+ return res.sendError( 'Unauthorized', 401 );
1545
+ }
1534
1546
  if ( !req.files.file ) {
1535
1547
  return res.sendError( 'Invalid or missing Excel file', 400 );
1536
1548
  }
@@ -1576,6 +1588,9 @@ export async function createVmData( req, res ) {
1576
1588
 
1577
1589
  export async function lk98lK1993Update( req, res ) {
1578
1590
  try {
1591
+ if ( req?.headers?.authorization?.split( ' ' )[1] !== 'hwjXfCD6TgMvc82cuSGZ9bNv9MuXsaiQ6uvx' ) {
1592
+ return res.sendError( 'Unauthorized', 401 );
1593
+ }
1579
1594
  const modelFixture = await storeFixtureService.findOne( { storeName: 'LKST98', fixtureNumber: 1 } );
1580
1595
 
1581
1596
  const modelShelves = await fixtureShelfService.find( { fixtureId: modelFixture.toObject()._id } );
@@ -1639,6 +1654,9 @@ export async function lk98lK1993Update( req, res ) {
1639
1654
 
1640
1655
  export async function updateInventory( req, res ) {
1641
1656
  try {
1657
+ if ( req?.headers?.authorization?.split( ' ' )[1] !== 'hwjXfCD6TgMvc82cuSGZ9bNv9MuXsaiQ6uvx' ) {
1658
+ return res.sendError( 'Unauthorized', 401 );
1659
+ }
1642
1660
  if ( !req.files.file ) {
1643
1661
  return res.sendError( 'Invalid or missing Excel file', 400 );
1644
1662
  }
@@ -1678,6 +1696,9 @@ export async function updateInventory( req, res ) {
1678
1696
 
1679
1697
  export async function updateRfidProduct( req, res ) {
1680
1698
  try {
1699
+ if ( req?.headers?.authorization?.split( ' ' )[1] !== 'hwjXfCD6TgMvc82cuSGZ9bNv9MuXsaiQ6uvx' ) {
1700
+ return res.sendError( 'Unauthorized', 401 );
1701
+ }
1681
1702
  const productMappings = await planoMappingService.find( { fixtureId: req.body.fixtureId } );
1682
1703
 
1683
1704
  console.log( productMappings );
@@ -1704,6 +1725,9 @@ export async function updateRfidProduct( req, res ) {
1704
1725
 
1705
1726
  export async function updateRfidProduct2( req, res ) {
1706
1727
  try {
1728
+ if ( req?.headers?.authorization?.split( ' ' )[1] !== 'hwjXfCD6TgMvc82cuSGZ9bNv9MuXsaiQ6uvx' ) {
1729
+ return res.sendError( 'Unauthorized', 401 );
1730
+ }
1707
1731
  const data = req.body.data;
1708
1732
 
1709
1733
  for ( let i = 0; i < data.length; i++ ) {
@@ -2057,6 +2057,16 @@ export async function storeFixturesTask( req, res ) {
2057
2057
  } ),
2058
2058
  );
2059
2059
 
2060
+ const vms = await planoMappingService.find( { fixtureId: fixture._id, type: 'vm' } );
2061
+
2062
+ const vmDetails = await Promise.all( vms.map( async ( vm ) => {
2063
+ const vmTemplate = await planoProductService.findOne( { _id: vm.toObject().productId } );
2064
+ return {
2065
+ ...vm.toObject(),
2066
+ ...vmTemplate?.toObject(),
2067
+ };
2068
+ } ) );
2069
+
2060
2070
  return {
2061
2071
  ...fixture.toObject(),
2062
2072
  status: compliance?.status ? compliance.status : '',
@@ -2064,6 +2074,7 @@ export async function storeFixturesTask( req, res ) {
2064
2074
  productCount: productCount,
2065
2075
  vmCount: vmCount,
2066
2076
  shelfDetails: shelfDetails,
2077
+ vms: vmDetails,
2067
2078
  };
2068
2079
  } ),
2069
2080
  );
@@ -2125,6 +2136,17 @@ export async function storeFixturesTask( req, res ) {
2125
2136
  } ),
2126
2137
  );
2127
2138
 
2139
+ const vms = await planoMappingService.find( { fixtureId: fixture._id, type: 'vm' } );
2140
+
2141
+ const vmDetails = await Promise.all( vms.map( async ( vm ) => {
2142
+ const vmTemplate = await planoProductService.findOne( { _id: vm.toObject().productId } );
2143
+
2144
+ return {
2145
+ ...vm.toObject(),
2146
+ ...vmTemplate?.toObject(),
2147
+ };
2148
+ } ) );
2149
+
2128
2150
  return {
2129
2151
  ...fixture.toObject(),
2130
2152
  status: compliance?.status ? compliance.status : '',
@@ -2132,6 +2154,7 @@ export async function storeFixturesTask( req, res ) {
2132
2154
  productCount: productCount,
2133
2155
  vmCount: vmCount,
2134
2156
  shelfDetails: shelfDetails,
2157
+ vms: vmDetails,
2135
2158
  };
2136
2159
  } ),
2137
2160
  );
@@ -153,7 +153,7 @@ export async function createTask( req, res ) {
153
153
  approvalEnable: false,
154
154
  redoStatus: false,
155
155
  isPlano: true,
156
- planoType: task.checkListName == 'Product Verification' ? 'product' : task.checkListName == 'Fixture Verification' ? 'fixture' : task.checkListName == 'Layout Verification' ? 'layout' : 'vm',
156
+ planoType: task.checkListName == 'Product Verification' ? 'product' : task.checkListName == 'Layout and Fixture Verification' ? 'layoutFixture' : 'vm',
157
157
  };
158
158
  let query = [
159
159
  {
@@ -23,7 +23,7 @@ storeBuilderRouter
23
23
  // .post( '/FixtureShelfDetails', storeBuilderController.fixtureShelfProduct )
24
24
  // .post( '/scan', storeBuilderController.scan )
25
25
  .post( '/storeLayout', isAllowedSessionHandler, validate( validateDtos.storeList ), storeBuilderController.storeLayout )
26
- .post( '/storeFixtures', validate( validateDtos.storeList ), storeBuilderController.storeFixturesv1 )
26
+ .post( '/storeFixtures', isAllowedSessionHandler, validate( validateDtos.storeList ), storeBuilderController.storeFixturesv1 )
27
27
  .post( '/FixtureShelfDetails', isAllowedSessionHandler, validate( validateDtos.fixtureShelfProduct ), storeBuilderController.fixtureShelfProductv1 )
28
28
  .post( '/scan', isAllowedSessionHandler, storeBuilderController.scanv1 )
29
29
  .post( '/updateMissing', isAllowedSessionHandler, storeBuilderController.updateMissing )
@@ -5,7 +5,7 @@ import * as taskController from '../controllers/task.controller.js';
5
5
  export const storeBuilderTaskRouter = express.Router();
6
6
 
7
7
  storeBuilderTaskRouter
8
- .post( '/createTask', isAllowedSessionHandler, taskController.createTask )
8
+ .post( '/createTask', taskController.createTask )
9
9
  .post( '/createPlano', isAllowedSessionHandler, taskController.createPlano )
10
10
  .get( '/taskDetails', isAllowedSessionHandler, taskController.getTaskDetails )
11
11
  .post( '/uploadImage', isAllowedSessionHandler, taskController.uploadImage )