tango-app-api-task 3.2.1-beta-15 → 3.2.1-beta-16

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-task",
3
- "version": "3.2.1-beta-15",
3
+ "version": "3.2.1-beta-16",
4
4
  "description": "Task",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -1,4 +1,4 @@
1
- import { logger, fileUpload, signedUrl } from 'tango-app-api-middleware';
1
+ import { logger, fileUpload, signedUrl, getObject } from 'tango-app-api-middleware';
2
2
  import * as taskService from '../service/task.service.js';
3
3
  import * as checklistLogs from '../service/checklistLog.service.js';
4
4
  import * as taskQuestionService from '../service/taskQuestion.service.js';
@@ -2367,21 +2367,22 @@ export async function createAiTaskNew( req, res ) {
2367
2367
  if ( !storeDetails ) {
2368
2368
  return res.sendError( 'Store Not Found', 500 );
2369
2369
  }
2370
- console.log( storeDetails );
2370
+
2371
2371
  let url = JSON.parse( process.env.LAMBDAURL );
2372
2372
  let checklistId = url.dailystoreChecklistId;
2373
2373
  let finduser = await checklistassignconfigModel.findOne( { checkListId: new mongoose.Types.ObjectId( checklistId ), store_id: storeDetails.storeId } );
2374
- console.log( finduser );
2374
+
2375
2375
  if ( !finduser ) {
2376
2376
  return res.sendError( 'No user Found For this store', 500 );
2377
2377
  }
2378
+ console.log( finduser );
2378
2379
  userId = finduser.userId;
2379
2380
  inputBody.userName = finduser.userName;
2380
2381
  inputBody.userEmail = finduser.userEmail;
2381
2382
 
2382
2383
 
2383
2384
  let teamList = await findteams( { users: { $elemMatch: { email: finduser.userEmail } } } );
2384
- console.log( teamList );
2385
+
2385
2386
  inputBody.approver = '';
2386
2387
  for ( let team of teamList ) {
2387
2388
  for ( let user of team.Teamlead ) {
@@ -2389,8 +2390,6 @@ export async function createAiTaskNew( req, res ) {
2389
2390
  }
2390
2391
  }
2391
2392
  inputBody.approver = inputBody.approver.replace( /,$/, '' );
2392
- console.log( inputBody?.approver );
2393
- // return;
2394
2393
 
2395
2394
 
2396
2395
  // let title = `New Task Alert ${inputBody.taskName}-${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}`;
@@ -2408,10 +2407,10 @@ export async function createAiTaskNew( req, res ) {
2408
2407
  }
2409
2408
 
2410
2409
  let approverList = inputBody?.approver.split( ',' );
2411
- console.log( approverList );
2410
+
2412
2411
 
2413
2412
  let userAdmin = await userService.find( { clientId: inputBody.clientId, email: { $in: approverList }, userType: 'client', isActive: true }, { name: '$userName', email: 1 } );
2414
- console.log( userAdmin );
2413
+
2415
2414
  if ( userAdmin && userAdmin.length === 0 ) {
2416
2415
  userAdmin = await userService.find( { clientId: inputBody.clientId, email: 'rohit.chawla@lenskart.com', userType: 'client', isActive: true }, { name: '$userName', email: 1 } );
2417
2416
  }
@@ -2420,10 +2419,13 @@ export async function createAiTaskNew( req, res ) {
2420
2419
  if ( creator && creator.length === 0 ) {
2421
2420
  return res.sendError( 'Invalid Creator Details', 500 );
2422
2421
  }
2423
- if ( req.files && req.files.referenceImage && req.files.referenceImage.length > 3 ) {
2422
+
2423
+ console.log( req.body.referenceImage );
2424
+ req.body.referenceImage = req.body.referenceImage.split( ',' );
2425
+ console.log( req.body.referenceImage );
2426
+ if ( req.body && req.body.referenceImage && req.body.referenceImage.length > 3 ) {
2424
2427
  return res.sendError( 'Maximum 3 referenceImage only allowed', 500 );
2425
2428
  }
2426
-
2427
2429
  let data = {
2428
2430
  checkListName: `${inputBody.taskName}-${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}`,
2429
2431
  checkListDescription: inputBody.taskDescription,
@@ -2445,14 +2447,13 @@ export async function createAiTaskNew( req, res ) {
2445
2447
 
2446
2448
 
2447
2449
  data['approver'] = userAdmin;
2448
- console.log( data );
2450
+
2449
2451
 
2450
2452
  let answer = await findAnswer( inputBody?.answerType );
2451
2453
  if ( answer.length == 0 ) {
2452
2454
  return res.sendError( 'please enter Valid AnswerType', 500 );
2453
2455
  }
2454
2456
  if ( inputBody?.answerType === 'multiplechoicesingle' || inputBody?.answerType === 'multiplechoicemultiple' ) {
2455
- console.log( inputBody?.options );
2456
2457
  if ( inputBody?.options && inputBody?.options.length > 0 ) {
2457
2458
  let optionsResult = [];
2458
2459
  let optionList = inputBody?.options.split( ',' );
@@ -2484,7 +2485,6 @@ export async function createAiTaskNew( req, res ) {
2484
2485
  if ( response?.approver.length ) {
2485
2486
  let inputData = [];
2486
2487
  response?.approver.forEach( ( ele ) => {
2487
- console.log( data );
2488
2488
  inputData.push( {
2489
2489
  userEmail: ele.email,
2490
2490
  checkListId: response._id,
@@ -2493,7 +2493,7 @@ export async function createAiTaskNew( req, res ) {
2493
2493
  checkListName: data?.checkListName || '',
2494
2494
  } );
2495
2495
  } );
2496
- console.log( inputData );
2496
+
2497
2497
  await traxApprover.insertMany( inputData );
2498
2498
  }
2499
2499
 
@@ -2514,22 +2514,36 @@ export async function createAiTaskNew( req, res ) {
2514
2514
  ];
2515
2515
 
2516
2516
 
2517
- if ( req.files && req.files.referenceImage && req.files.referenceImage.length ) {
2518
- let images = [];
2519
- console.log( req.files.referenceImage.length );
2517
+ let images = [];
2520
2518
 
2519
+ for ( let imgpath of req.body.referenceImage ) {
2520
+ let configURL = JSON.parse( process.env.BUCKET );
2521
+ let inputData = {
2522
+ Bucket: configURL.aiTraxoutput,
2523
+ Key: imgpath,
2524
+ };
2521
2525
 
2522
- for ( let image of req.files.referenceImage ) {
2523
- let uplaodedImage = await uploadmultiImage( image );
2524
- let imgUrl = decodeURIComponent( uplaodedImage.imgUrl.split( '?' )[0] );
2525
- let url = imgUrl.split( '/' );
2526
- if ( url.includes( 'https:' ) || url.includes( 'http:' ) ) {
2527
- url.splice( 0, 3 );
2528
- }
2529
- images.push( url.join( '/' ) );
2526
+ console.log( inputData );
2527
+ let output = await getObject( inputData );
2528
+ console.log( output );
2529
+
2530
+
2531
+ let image = {
2532
+ data: output.Body,
2533
+ name: imgpath,
2534
+ mimetype: output.ContentType,
2535
+ };
2536
+ let uplaodedImage = await uploadmultiImage( image );
2537
+ console.log( uplaodedImage );
2538
+ let imgUrl = decodeURIComponent( uplaodedImage.imgUrl.split( '?' )[0] );
2539
+ let url = imgUrl.split( '/' );
2540
+ if ( url.includes( 'https:' ) || url.includes( 'http:' ) ) {
2541
+ url.splice( 0, 3 );
2530
2542
  }
2531
- question[0].questionReferenceImage = images;
2543
+ images.push( url.join( '/' ) );
2532
2544
  }
2545
+ question[0].questionReferenceImage = images;
2546
+
2533
2547
  if ( inputBody?.answerType === 'image' || inputBody?.answerType === 'descriptiveImage' || inputBody?.answerType === 'multipleImage' ) {
2534
2548
  answer[0].referenceImage = question[0].questionReferenceImage;
2535
2549
  }
@@ -2556,7 +2570,6 @@ export async function createAiTaskNew( req, res ) {
2556
2570
  client_id: inputBody.clientId,
2557
2571
  userId: userId,
2558
2572
  };
2559
- console.log( userDetails );
2560
2573
  await taskAssignService.create( userDetails );
2561
2574
  await insertSingleProcessData( response?._id );
2562
2575
  return res.sendSuccess( 'Task created successfully' );
@@ -3040,14 +3053,25 @@ export async function uploadmultiImage( images ) {
3040
3053
 
3041
3054
  export async function customertrial( params ) {
3042
3055
  try {
3056
+ // let inputData = {
3057
+ // Bucket: 'tango-trax-audit',
3058
+ // file_path: 'trail/59-147/b1c5b15c0133dec0c45640d923fda221_10_09_59_000_24_01_2025_false.mp4',
3059
+ // };
3060
+ // let url = await signedUrl( inputData );
3061
+ // console.log( url );
3062
+
3063
+
3043
3064
  let inputData = {
3044
3065
  Bucket: 'tango-trax-audit',
3045
- file_path: 'trail/59-147/b1c5b15c0133dec0c45640d923fda221_10_09_59_000_24_01_2025_false.mp4',
3066
+ Key: 'hygiene/16-01-2025/11-2212/11-2212_13d76f2dd3ea3123aa476a885893c9fd_labelled.jpeg',
3046
3067
  };
3047
- let url = await signedUrl( inputData );
3068
+
3069
+ console.log( inputData );
3070
+ let url = await getObject( inputData );
3048
3071
  console.log( url );
3049
3072
  } catch ( e ) {
3050
3073
  logger.error( 'uploadImage =>', e );
3051
3074
  return e;
3052
3075
  }
3053
3076
  };
3077
+
@@ -20,7 +20,7 @@ export const aitaskvalidationSchemanew = Joi.object().keys( {
20
20
  options: Joi.string().optional(),
21
21
  scheduleDate: Joi.string().optional(),
22
22
  scheduleEndTime: Joi.string().optional(),
23
- referenceImage: Joi.string().optional(),
23
+ referenceImage: Joi.string().required(),
24
24
  } );
25
25
 
26
26
  export const aitaskvalidation = {