tango-app-api-store-builder 1.0.0-beta-95 → 1.0.0-beta-96

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-95",
3
+ "version": "1.0.0-beta-96",
4
4
  "description": "storeBuilder",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1,6 +1,6 @@
1
1
  // import { writeFileSync } from 'fs';
2
2
  import xlsx from 'xlsx';
3
- import { logger } from 'tango-app-api-middleware';
3
+ import { logger, fileUpload } from 'tango-app-api-middleware';
4
4
  import * as storeBuilderService from '../service/storeBuilder.service.js';
5
5
  import * as storeService from '../service/store.service.js';
6
6
  import * as planoService from '../service/planogram.service.js';
@@ -2318,9 +2318,9 @@ export async function updateVmData( req, res ) {
2318
2318
 
2319
2319
 
2320
2320
  async function scrapeCrest() {
2321
- const storeIds = [];
2321
+ const storeIds = [ 'LKST682' ];
2322
2322
  const apiUrl = 'https://api.getcrest.ai/api/ms_shelfsensei/layout/';
2323
- const bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzQzNjY5ODIyLCJpYXQiOjE3NDM2NjYyMjIsImp0aSI6IjA5ZDRjYTVhZGRiNzQxMDVhYjhjOWVjMmU3MjZiM2NiIiwidXNlcl9pZCI6MTA4NSwiaWQiOjEwODUsImN1c3RvbWVyX2dyb3VwIjozOTgsImxpY2VuY2Vfc2NvcGVzIjpbeyJyZXNvdXJjZV9zZXQiOiJwcF9zZXQiLCJzY29wZV9yb2xlIjoiY29udHJpYnV0b3IifSx7InJlc291cmNlX3NldCI6ImRwX3NldCIsInNjb3BlX3JvbGUiOiJjb250cmlidXRvciJ9LHsicmVzb3VyY2Vfc2V0IjoiZGZfc2V0Iiwic2NvcGVfcm9sZSI6ImNvbnRyaWJ1dG9yIn0seyJyZXNvdXJjZV9zZXQiOiJkZWZhdWx0X3NldCIsInNjb3BlX3JvbGUiOiJjb250cmlidXRvciJ9XX0.C3wLXzbv0bTDGiZqs8jSA3up0cq0wqA5PIMw45_T4Wg';
2323
+ const bearerToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzQ4ODQ3NTcxLCJpYXQiOjE3NDg4NDM5NzEsImp0aSI6ImZiZWEwODRlZjY5ZjRmYWM4MTYwNDBjODMwOTMyZDA0IiwidXNlcl9pZCI6MTA4NSwiaWQiOjEwODUsImlzX21lZXNlZWtfYWNjb3VudCI6ZmFsc2UsImN1c3RvbWVyX2dyb3VwIjozOTgsImxpY2VuY2Vfc2NvcGVzIjpbeyJyZXNvdXJjZV9zZXQiOiJwcF9zZXQiLCJzY29wZV9yb2xlIjoiY29udHJpYnV0b3IifSx7InJlc291cmNlX3NldCI6ImRwX3NldCIsInNjb3BlX3JvbGUiOiJjb250cmlidXRvciJ9LHsicmVzb3VyY2Vfc2V0IjoiZGZfc2V0Iiwic2NvcGVfcm9sZSI6ImNvbnRyaWJ1dG9yIn0seyJyZXNvdXJjZV9zZXQiOiJkZWZhdWx0X3NldCIsInNjb3BlX3JvbGUiOiJjb250cmlidXRvciJ9XX0.A81bI3_-YupAf4H1ctIMijGEOPHuCvXFG0yiXN30QbQ';
2324
2324
  const filePath = 'response.json';
2325
2325
  let allResults = [];
2326
2326
 
@@ -2385,6 +2385,8 @@ async function scrapeCrest() {
2385
2385
  }
2386
2386
  }
2387
2387
 
2388
+ // scrapeCrest()
2389
+
2388
2390
  export async function createCrestPlanogram( req, res ) {
2389
2391
  try {
2390
2392
  if ( req?.headers?.authorization?.split( ' ' )[1] !== 'hwjXfCD6TgMvc82cuSGZ9bNv9MuXsaiQ6uvx' ) {
@@ -4343,6 +4345,8 @@ export async function updateCrestPlanogram( req, res ) {
4343
4345
 
4344
4346
  const layoutApiUrl = 'https://api.getcrest.ai/api/ms_shelfsensei/layout/';
4345
4347
  let staticToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzQ1NTE3MjQxLCJpYXQiOjE3NDU1MTM2NDEsImp0aSI6Ijg3MWVlNTA3ODY2OTQ5OTVhMTQ0YTk4NzQyNzY0MzEzIiwidXNlcl9pZCI6MTA4NSwiaWQiOjEwODUsImlzX21lZXNlZWtfYWNjb3VudCI6ZmFsc2UsImN1c3RvbWVyX2dyb3VwIjozOTgsImxpY2VuY2Vfc2NvcGVzIjpbeyJyZXNvdXJjZV9zZXQiOiJwcF9zZXQiLCJzY29wZV9yb2xlIjoiY29udHJpYnV0b3IifSx7InJlc291cmNlX3NldCI6ImRwX3NldCIsInNjb3BlX3JvbGUiOiJjb250cmlidXRvciJ9LHsicmVzb3VyY2Vfc2V0IjoiZGZfc2V0Iiwic2NvcGVfcm9sZSI6ImNvbnRyaWJ1dG9yIn0seyJyZXNvdXJjZV9zZXQiOiJkZWZhdWx0X3NldCIsInNjb3BlX3JvbGUiOiJjb250cmlidXRvciJ9XX0.eGzTMGwwstr13M0Hu1Ls5-gkE_oSPMJJBL2wgygT6Ac';
4348
+ const fetchWithCookies = fetchCookie( fetch );
4349
+
4346
4350
 
4347
4351
  async function fetchStoreData( store, bearerToken, res ) {
4348
4352
  const payload = JSON.stringify( { store_id: store.toObject().storeName?.toUpperCase() } );
@@ -4392,8 +4396,6 @@ export async function updateCrestPlanogram( req, res ) {
4392
4396
 
4393
4397
 
4394
4398
  const fetchNewToken = async () => {
4395
- const fetchWithCookies = fetchCookie( fetch );
4396
-
4397
4399
  const email = 'tango.lenskart@getcrest.ai';
4398
4400
  const password = 'Tangolenskart@123';
4399
4401
 
@@ -4434,6 +4436,62 @@ export async function updateCrestPlanogram( req, res ) {
4434
4436
  }
4435
4437
  };
4436
4438
 
4439
+ const fetchVmImage = async ( attachmentId ) => {
4440
+ try {
4441
+ const response = await fetchWithCookies( `https://api.getcrest.ai/api/ms_data_preparation/master_data/attachment/?preview=0&attachment_id=${attachmentId}`, {
4442
+ method: 'GET',
4443
+ headers: {
4444
+ 'Authorization': `Bearer ${staticToken}`,
4445
+ 'Cookie': 'prod_session_key=w144dqljxlh096487nc33rm09vwtossh',
4446
+ },
4447
+ } );
4448
+
4449
+ if ( !response.ok ) {
4450
+ throw new Error( `Failed to fetch image: ${response.status}` );
4451
+ }
4452
+
4453
+ // const dest = fs.createWriteStream( `${attachmentId}.png` );
4454
+ // response.body.pipe( dest );
4455
+
4456
+ // return await response.buffer();
4457
+
4458
+ const arrayBuffer = await response.arrayBuffer();
4459
+ return Buffer.from( arrayBuffer );
4460
+ } catch ( error ) {
4461
+ console.error( 'Error fetching image buffer:', error.message );
4462
+ throw error;
4463
+ }
4464
+ };
4465
+
4466
+ const getImageMetadata = async ( imageBuffer ) => {
4467
+ try {
4468
+ const metadata = await sharp( imageBuffer ).metadata();
4469
+ const { width, height, format } = metadata;
4470
+
4471
+ if ( !width || !height || !format ) throw new Error( 'Invalid image metadata' );
4472
+
4473
+ const ratio = width / height;
4474
+ const normalizedRatio = ratio > 1 ? ratio : 1 / ratio;
4475
+ const squareThreshold = 1.2;
4476
+ const imageShape = normalizedRatio <= squareThreshold ? 'square' : 'rectangle';
4477
+
4478
+ const fileExtension = format === 'jpeg' ? 'jpg' : format;
4479
+ const contentType = `image/${format}`;
4480
+
4481
+ return {
4482
+ imageShape,
4483
+ width,
4484
+ height,
4485
+ fileExtension,
4486
+ contentType,
4487
+ };
4488
+ } catch ( error ) {
4489
+ console.error( 'Error processing image buffer:', error.message );
4490
+ throw error;
4491
+ }
4492
+ };
4493
+
4494
+
4437
4495
  if ( !req?.body?.storeName ) {
4438
4496
  return res.sendError( 'No store supplied', 200 );
4439
4497
  }
@@ -4442,7 +4500,7 @@ export async function updateCrestPlanogram( req, res ) {
4442
4500
  clientId: '11',
4443
4501
  $and: [
4444
4502
  { storeName: req.body.storeName },
4445
- { storeName: { $nin: [ 'LKST98', 'LKST1193' ] } },
4503
+ // { storeName: { $nin: [ 'LKST98', 'LKST1193' ] } },
4446
4504
  ],
4447
4505
  };
4448
4506
 
@@ -4470,11 +4528,11 @@ export async function updateCrestPlanogram( req, res ) {
4470
4528
  const existingPlanogram = await planoService.findOne( { storeName: storeData.storeName } );
4471
4529
 
4472
4530
  if ( existingPlanogram ) {
4473
- const checkTaskSubmitted = await planoTaskService.findOne( { planoId: existingPlanogram.toObject()._id } );
4531
+ // const checkTaskSubmitted = await planoTaskService.findOne( { planoId: existingPlanogram.toObject()._id } );
4474
4532
 
4475
4533
  const checkTaskCreated = await processedTaskService.findOne( { storeName: storeData.storeName, date_string: dayjs().format( 'YYYY-MM-DD' ), isPlano: true } );
4476
4534
 
4477
- if ( checkTaskSubmitted || checkTaskCreated ) {
4535
+ if ( checkTaskCreated ) {
4478
4536
  continue;
4479
4537
  }
4480
4538
  }
@@ -4789,6 +4847,37 @@ export async function updateCrestPlanogram( req, res ) {
4789
4847
 
4790
4848
  if ( !configData ) return;
4791
4849
 
4850
+ let attachmentId = '';
4851
+ let imgPath = '';
4852
+ let imageMeta = null;
4853
+
4854
+
4855
+ if ( zone.preview_image_url ) {
4856
+ const parsedUrl = new URL( zone.preview_image_url );
4857
+ attachmentId = parsedUrl.searchParams.get( 'attachment_id' );
4858
+
4859
+ const isVmImageExist = await planoProductService.findOne( { crestImageId: attachmentId } );
4860
+
4861
+
4862
+ if ( !isVmImageExist ) {
4863
+ const vmImageData = await fetchVmImage( attachmentId );
4864
+
4865
+ imageMeta = await getImageMetadata( vmImageData );
4866
+
4867
+ const params = {
4868
+ Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
4869
+ Key: `crestVms/`,
4870
+ fileName: `${attachmentId}.${imageMeta.fileExtension}`,
4871
+ ContentType: imageMeta.contentType,
4872
+ body: vmImageData,
4873
+ };
4874
+
4875
+ const imgUpload = await fileUpload( params );
4876
+
4877
+ imgPath = imgUpload.Key;
4878
+ }
4879
+ }
4880
+
4792
4881
  const insertData = {
4793
4882
  'clientId': '11',
4794
4883
  'productId': 'VMCR',
@@ -4808,6 +4897,30 @@ export async function updateCrestPlanogram( req, res ) {
4808
4897
  'fixtureConfigId': fixtureConfig._id,
4809
4898
  };
4810
4899
 
4900
+ if ( attachmentId && imgPath ) {
4901
+ insertData.crestImageId = attachmentId;
4902
+ insertData.productImageUrl = imgPath;
4903
+
4904
+ const shelfData = fixtureConfigDoc.shelfConfig
4905
+ .filter( ( shelf ) => shelf.shelfZone === configData.position )
4906
+ .sort( ( a, b ) => a.shelfNumber - b.shelfNumber );
4907
+
4908
+ if ( imageMeta.imageShape === 'square' ) {
4909
+ insertData.productHeight.value = 100;
4910
+ insertData.productWidth.value = 230;
4911
+
4912
+ if ( shelfData.length ) {
4913
+ insertData.startYPosition = shelfData[0].shelfNumber;
4914
+ insertData.endYPosition = shelfData[shelfData.length - 1].shelfNumber;
4915
+ }
4916
+ }
4917
+
4918
+ // if ( imageMeta.imageShape === 'rectangle' ) {
4919
+ // insertData.productHeight.value = 100;
4920
+ // insertData.productWidth.value = 905;
4921
+ // }
4922
+ }
4923
+
4811
4924
  const vmTemplate = await planoProductService.upsertOne(
4812
4925
  {
4813
4926
  'productName': vm.productName,
@@ -4966,6 +5079,37 @@ export async function updateCrestPlanogram( req, res ) {
4966
5079
 
4967
5080
  if ( !configData ) return;
4968
5081
 
5082
+ let attachmentId = '';
5083
+ let imgPath = '';
5084
+ let imageMeta = null;
5085
+
5086
+
5087
+ if ( zone.preview_image_url ) {
5088
+ const parsedUrl = new URL( zone.preview_image_url );
5089
+ attachmentId = parsedUrl.searchParams.get( 'attachment_id' );
5090
+
5091
+ const isVmImageExist = await planoProductService.findOne( { crestImageId: attachmentId } );
5092
+
5093
+
5094
+ if ( !isVmImageExist ) {
5095
+ const vmImageData = await fetchVmImage( attachmentId );
5096
+
5097
+ imageMeta = await getImageMetadata( vmImageData );
5098
+
5099
+ const params = {
5100
+ Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
5101
+ Key: `crestVms/`,
5102
+ fileName: `${attachmentId}.${imageMeta.fileExtension}`,
5103
+ ContentType: imageMeta.contentType,
5104
+ body: vmImageData,
5105
+ };
5106
+
5107
+ const imgUpload = await fileUpload( params );
5108
+
5109
+ imgPath = imgUpload.Key;
5110
+ }
5111
+ }
5112
+
4969
5113
  const insertData = {
4970
5114
  'clientId': '11',
4971
5115
  'productId': 'VMCR',
@@ -4985,6 +5129,30 @@ export async function updateCrestPlanogram( req, res ) {
4985
5129
  'fixtureConfigId': fixtureConfig._id,
4986
5130
  };
4987
5131
 
5132
+ if ( attachmentId && imgPath ) {
5133
+ insertData.crestImageId = attachmentId;
5134
+ insertData.productImageUrl = imgPath;
5135
+
5136
+ const shelfData = fixtureConfigDoc.shelfConfig
5137
+ .filter( ( shelf ) => shelf.shelfZone === configData.position )
5138
+ .sort( ( a, b ) => a.shelfNumber - b.shelfNumber );
5139
+
5140
+ if ( imageMeta.imageShape === 'square' ) {
5141
+ insertData.productHeight.value = 100;
5142
+ insertData.productWidth.value = 230;
5143
+
5144
+ if ( shelfData.length ) {
5145
+ insertData.startYPosition = shelfData[0].shelfNumber;
5146
+ insertData.endYPosition = shelfData[shelfData.length - 1].shelfNumber;
5147
+ }
5148
+ }
5149
+
5150
+ // if ( imageMeta.imageShape === 'rectangle' ) {
5151
+ // insertData.productHeight.value = 100;
5152
+ // insertData.productWidth.value = 905;
5153
+ // }
5154
+ }
5155
+
4988
5156
  const vmTemplate = await planoProductService.upsertOne(
4989
5157
  {
4990
5158
  'productName': vm.productName,
@@ -5142,6 +5310,38 @@ export async function updateCrestPlanogram( req, res ) {
5142
5310
 
5143
5311
  if ( !configData ) return;
5144
5312
 
5313
+ let attachmentId = '';
5314
+ let imgPath = '';
5315
+ let imageMeta = null;
5316
+
5317
+
5318
+ if ( zone.preview_image_url ) {
5319
+ const parsedUrl = new URL( zone.preview_image_url );
5320
+ attachmentId = parsedUrl.searchParams.get( 'attachment_id' );
5321
+
5322
+ const isVmImageExist = await planoProductService.findOne( { crestImageId: attachmentId } );
5323
+
5324
+
5325
+ if ( !isVmImageExist ) {
5326
+ const vmImageData = await fetchVmImage( attachmentId );
5327
+
5328
+ imageMeta = await getImageMetadata( vmImageData );
5329
+
5330
+ const params = {
5331
+ Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
5332
+ Key: `crestVms/`,
5333
+ fileName: `${attachmentId}.${imageMeta.fileExtension}`,
5334
+ ContentType: imageMeta.contentType,
5335
+ body: vmImageData,
5336
+ };
5337
+
5338
+ const imgUpload = await fileUpload( params );
5339
+
5340
+ imgPath = imgUpload.Key;
5341
+ }
5342
+ }
5343
+
5344
+
5145
5345
  const insertData = {
5146
5346
  'clientId': '11',
5147
5347
  'productId': 'VMCR',
@@ -5161,6 +5361,30 @@ export async function updateCrestPlanogram( req, res ) {
5161
5361
  'fixtureConfigId': fixtureConfig._id,
5162
5362
  };
5163
5363
 
5364
+ if ( attachmentId && imgPath ) {
5365
+ insertData.crestImageId = attachmentId;
5366
+ insertData.productImageUrl = imgPath;
5367
+
5368
+ const shelfData = fixtureConfigDoc.shelfConfig
5369
+ .filter( ( shelf ) => shelf.shelfZone === configData.position )
5370
+ .sort( ( a, b ) => a.shelfNumber - b.shelfNumber );
5371
+
5372
+ if ( imageMeta.imageShape === 'square' ) {
5373
+ insertData.productHeight.value = 100;
5374
+ insertData.productWidth.value = 230;
5375
+
5376
+ if ( shelfData.length ) {
5377
+ insertData.startYPosition = shelfData[0].shelfNumber;
5378
+ insertData.endYPosition = shelfData[shelfData.length - 1].shelfNumber;
5379
+ }
5380
+ }
5381
+
5382
+ // if ( imageMeta.imageShape === 'rectangle' ) {
5383
+ // insertData.productHeight.value = 100;
5384
+ // insertData.productWidth.value = 905;
5385
+ // }
5386
+ }
5387
+
5164
5388
  const vmTemplate = await planoProductService.upsertOne(
5165
5389
  {
5166
5390
  'productName': vm.productName,
@@ -6797,8 +7021,8 @@ async function downloadImage() {
6797
7021
  try {
6798
7022
  const response = await fetch( url, {
6799
7023
  headers: {
6800
- Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzQ3MDMyNDcyLCJpYXQiOjE3NDcwMjg4NzIsImp0aSI6IjZmN2Y0Yzk4OGY5ZjRiYjg5NmNhOTYwNzMyMTVlOTUwIiwidXNlcl9pZCI6MTA4NCwiaWQiOjEwODQsImlzX21lZXNlZWtfYWNjb3VudCI6ZmFsc2UsImN1c3RvbWVyX2dyb3VwIjozOTgsImxpY2VuY2Vfc2NvcGVzIjpbeyJyZXNvdXJjZV9zZXQiOiJwcF9zZXQiLCJzY29wZV9yb2xlIjoiYWRtaW4ifSx7InJlc291cmNlX3NldCI6ImRwX3NldCIsInNjb3BlX3JvbGUiOiJhZG1pbiJ9LHsicmVzb3VyY2Vfc2V0IjoiZGZfc2V0Iiwic2NvcGVfcm9sZSI6ImFkbWluIn0seyJyZXNvdXJjZV9zZXQiOiJkZWZhdWx0X3NldCIsInNjb3BlX3JvbGUiOiJhZG1pbiJ9XX0.Lt3zT1Rw4KnDWRQ8LWYRVMFPS3PHRRTgHXn6kLG8Uk0',
6801
- Cookie: 'prod_session_key=w144dqljxlh096487nc33rm09vwtossh; prod_session_key=xn1fry9sekk94hs2hfo78erxcmc8a3am',
7024
+ Authorization: 'Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNzQ3MjE0MjcxLCJpYXQiOjE3NDcyMTA2NzEsImp0aSI6ImM4ZjQ4ZDY2YWJkYzRmNDU4MWI4OGE4MTMwODVjOTUwIiwidXNlcl9pZCI6MTA4NSwiaWQiOjEwODUsImlzX21lZXNlZWtfYWNjb3VudCI6ZmFsc2UsImN1c3RvbWVyX2dyb3VwIjozOTgsImxpY2VuY2Vfc2NvcGVzIjpbeyJyZXNvdXJjZV9zZXQiOiJwcF9zZXQiLCJzY29wZV9yb2xlIjoiY29udHJpYnV0b3IifSx7InJlc291cmNlX3NldCI6ImRwX3NldCIsInNjb3BlX3JvbGUiOiJjb250cmlidXRvciJ9LHsicmVzb3VyY2Vfc2V0IjoiZGZfc2V0Iiwic2NvcGVfcm9sZSI6ImNvbnRyaWJ1dG9yIn0seyJyZXNvdXJjZV9zZXQiOiJkZWZhdWx0X3NldCIsInNjb3BlX3JvbGUiOiJjb250cmlidXRvciJ9XX0.IOw_0yNA6CMBCIn7cxjPR0FqHI949WplCKzlkr8aK7g',
7025
+ Cookie: 'prod_session_key=w144dqljxlh096487nc33rm09vwtossh; prod_session_key=7mljy9k7niwpw4btbbyvuhkz7otbdh6v',
6802
7026
  },
6803
7027
  } );
6804
7028
 
@@ -6857,3 +7081,77 @@ export async function recorrectTaskData( req, res ) {
6857
7081
  return res.sendError( e, 500 );
6858
7082
  }
6859
7083
  }
7084
+
7085
+
7086
+ function fillFeedbackFromJson( excelPath, jsonData, outputPath ) {
7087
+ const workbook = xlsx.readFile( excelPath );
7088
+ const sheetName = workbook.SheetNames[0];
7089
+ const sheet = workbook.Sheets[sheetName];
7090
+
7091
+ const data = xlsx.utils.sheet_to_json( sheet, { defval: 'Transformed by Data.Page' } );
7092
+
7093
+ const feedbackMap = {};
7094
+ jsonData.forEach( ( entry ) => {
7095
+ feedbackMap[entry.store] = entry.videoUrl;
7096
+ } );
7097
+
7098
+ const updatedData = data.map( ( row ) => {
7099
+ const store = row.storeName;
7100
+ if ( feedbackMap[store] ) {
7101
+ row.FeedBack = feedbackMap[store];
7102
+ }
7103
+ return row;
7104
+ } );
7105
+
7106
+ const newSheet = xlsx.utils.json_to_sheet( updatedData );
7107
+
7108
+ workbook.Sheets[sheetName] = newSheet;
7109
+
7110
+ xlsx.writeFile( workbook, outputPath );
7111
+ }
7112
+
7113
+ // fillFeedbackFromJson('input.xlsx', feedbackJson, 'output.xlsx');
7114
+
7115
+
7116
+ function exportFixtureJsonToExcel( fixtures, filePath ) {
7117
+ const fixtureInfoArr = [];
7118
+ const shelfConfigArr = [];
7119
+ const vmConfigArr = [];
7120
+
7121
+ for ( const fixture of fixtures ) {
7122
+ fixtureInfoArr.push( {
7123
+ clientId: fixture.clientId,
7124
+ fixtureCode: fixture.fixtureCode,
7125
+ fixtureCategory: fixture.fixtureCategory,
7126
+ fixtureConfigType: fixture.fixtureConfigType,
7127
+ fixtureLength: `${fixture.fixtureLength?.value} ${fixture.fixtureLength?.unit}`,
7128
+ fixtureCapacity: fixture.fixtureCapacity,
7129
+ } );
7130
+
7131
+ ( fixture.shelfConfig || [] ).forEach( ( shelf ) => {
7132
+ shelfConfigArr.push( {
7133
+ fixtureCode: fixture.fixtureCode,
7134
+ ...shelf,
7135
+ } );
7136
+ } );
7137
+
7138
+ ( fixture.vmConfig || [] ).forEach( ( vm ) => {
7139
+ vmConfigArr.push( {
7140
+ fixtureCode: fixture.fixtureCode,
7141
+ ...vm,
7142
+ } );
7143
+ } );
7144
+ }
7145
+
7146
+ const workbook = xlsx.utils.book_new();
7147
+ xlsx.utils.book_append_sheet( workbook, xlsx.utils.json_to_sheet( fixtureInfoArr ), 'Fixture Info' );
7148
+ xlsx.utils.book_append_sheet( workbook, xlsx.utils.json_to_sheet( shelfConfigArr ), 'Shelf Config' );
7149
+ xlsx.utils.book_append_sheet( workbook, xlsx.utils.json_to_sheet( vmConfigArr ), 'VM Config' );
7150
+
7151
+ xlsx.writeFile( workbook, filePath );
7152
+ }
7153
+
7154
+ // const fixtures = JSON.parse( fs.readFileSync( './input.json', 'utf-8' ) );
7155
+ // exportFixtureJsonToExcel( fixtures, 'output.xlsx' );
7156
+
7157
+
@@ -639,9 +639,15 @@ export async function storeFixturesv1( req, res ) {
639
639
 
640
640
  const vmDetails = await Promise.all( vms.map( async ( vm ) => {
641
641
  const vmTemplate = await planoProductService.findOne( { _id: vm.toObject().productId } );
642
+ const params = {
643
+ Bucket: JSON.parse( process.env.BUCKET ).storeBuilder,
644
+ file_path: vmTemplate?.productImageUrl,
645
+ };
646
+ const vmImage = await signedUrl( params );
642
647
  return {
643
648
  ...vm.toObject(),
644
649
  ...vmTemplate?.toObject(),
650
+ ...( typeof vmImage === 'string' && { productImageUrl: vmImage } ),
645
651
  };
646
652
  } ) );
647
653