tango-app-api-task 3.2.1-beta-14 → 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-14",
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';
@@ -8,6 +8,7 @@ import * as storeService from '../service/store.service.js';
8
8
  import * as traxApprover from '../service/approver.service.js';
9
9
  import * as processedChecklist from '../service/processedChecklist.service.js';
10
10
  import * as checklistassignconfigModel from '../service/checklistAssign.service.js';
11
+ import * as clusterModel from '../service/cluster.service.js';
11
12
  // import * as domainService from '../service/domain.service.js';
12
13
  import mongoose from 'mongoose';
13
14
  const ObjectId = mongoose.Types.ObjectId;
@@ -19,7 +20,7 @@ dayjs.extend( customParseFormat );
19
20
  import * as taskProcessedConfigService from '../service/processedTaskConfig.service.js';
20
21
  import * as taskProcessedService from '../service/processedTaskList.service.js';
21
22
  import * as ApproverModel from '../service/approver.service.js';
22
- import { createTeamsModel, findOneTeams, updateOneTeamModel } from '../service/teams.service.js';
23
+ import { createTeamsModel, findOneTeams, updateOneTeamModel, findteams } from '../service/teams.service.js';
23
24
  import { sendPushNotification } from 'tango-app-api-middleware';
24
25
  async function LamdaServiceCall( url, data ) {
25
26
  try {
@@ -2089,8 +2090,6 @@ export const duplicateChecklist = async ( req, res ) => {
2089
2090
  export async function teamMigrations( req, res ) {
2090
2091
  try {
2091
2092
  let input = [];
2092
-
2093
-
2094
2093
  for ( let user of input ) {
2095
2094
  let userexits = await userService.findOne( { email: user.userEmail } );
2096
2095
  if ( userexits ) {
@@ -2156,7 +2155,55 @@ export async function teamMigrations( req, res ) {
2156
2155
  return res.sendError( error, 500 );
2157
2156
  }
2158
2157
  }
2159
-
2158
+ export async function clusterMigrations( req, res ) {
2159
+ try {
2160
+ let input = [
2161
+ ];
2162
+ for ( let user of input ) {
2163
+ let userexits = await userService.findOne( { email: user.AOMsmailID } );
2164
+ if ( userexits ) {
2165
+ let findStore = await storeService.findOne( { storeName: user.FacilityCode } );
2166
+ if ( findStore ) {
2167
+ let clusterExists = await clusterModel.findOneCluster( { clusterName: user.AomName } );
2168
+ if ( clusterExists ) {
2169
+ let data = {
2170
+ storeId: findStore.storeId,
2171
+ store: findStore._id,
2172
+ };
2173
+ let updatecluster = await clusterModel.updateCluster( { clusterName: user.AomName }, { $push: { stores: data } } );
2174
+ console.log( updatecluster );
2175
+ } else {
2176
+ let payload = {
2177
+ 'clusterName': user.AomName,
2178
+ 'clientId': '11',
2179
+ 'description': user.AomName,
2180
+ 'stores': [
2181
+ {
2182
+ storeId: findStore.storeId,
2183
+ store: findStore._id,
2184
+ },
2185
+ ],
2186
+ 'status': 'active',
2187
+ 'Teamlead': [
2188
+ {
2189
+ email: userexits.email,
2190
+ userId: userexits._id,
2191
+ },
2192
+ ],
2193
+ 'users': [],
2194
+ };
2195
+ let createcluster = await clusterModel.createclusterModel( payload );
2196
+ console.log( createcluster );
2197
+ }
2198
+ }
2199
+ }
2200
+ }
2201
+ res.sendSuccess( 'completed' );
2202
+ } catch ( error ) {
2203
+ logger.error( 'duplicateTask =>', error );
2204
+ return res.sendError( error, 500 );
2205
+ }
2206
+ }
2160
2207
  export async function createAiChecklist( req, res ) {
2161
2208
  try {
2162
2209
  let inputBody = req.body;
@@ -2309,10 +2356,233 @@ export async function createAiChecklist( req, res ) {
2309
2356
  return res.sendError( e, 500 );
2310
2357
  }
2311
2358
  }
2359
+ export async function createAiTaskNew( req, res ) {
2360
+ try {
2361
+ let inputBody = req.body;
2362
+ console.log( inputBody );
2363
+ inputBody.clientId = 11;
2364
+ inputBody.taskDescription = '';
2365
+ let userId;
2366
+ let storeDetails = await storeService.findOne( { storeName: inputBody.storeName, clientId: inputBody.clientId, status: 'active' }, { storeId: 1, storeName: 1, storeProfile: 1 } );
2367
+ if ( !storeDetails ) {
2368
+ return res.sendError( 'Store Not Found', 500 );
2369
+ }
2370
+
2371
+ let url = JSON.parse( process.env.LAMBDAURL );
2372
+ let checklistId = url.dailystoreChecklistId;
2373
+ let finduser = await checklistassignconfigModel.findOne( { checkListId: new mongoose.Types.ObjectId( checklistId ), store_id: storeDetails.storeId } );
2374
+
2375
+ if ( !finduser ) {
2376
+ return res.sendError( 'No user Found For this store', 500 );
2377
+ }
2378
+ console.log( finduser );
2379
+ userId = finduser.userId;
2380
+ inputBody.userName = finduser.userName;
2381
+ inputBody.userEmail = finduser.userEmail;
2382
+
2383
+
2384
+ let teamList = await findteams( { users: { $elemMatch: { email: finduser.userEmail } } } );
2385
+
2386
+ inputBody.approver = '';
2387
+ for ( let team of teamList ) {
2388
+ for ( let user of team.Teamlead ) {
2389
+ inputBody.approver = user.email + ',' + inputBody.approver;
2390
+ }
2391
+ }
2392
+ inputBody.approver = inputBody.approver.replace( /,$/, '' );
2393
+
2394
+
2395
+ // let title = `New Task Alert ${inputBody.taskName}-${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}`;
2396
+ let time = inputBody?.scheduleEndTime || '11:59 PM';
2397
+ let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
2398
+ // let description = `A new task has been assigned to ${storeDetails.storeName}. Please complete it before the due date of ${date}.`;
2399
+ // if ( userDetails&&userDetails.fcmToken ) {
2400
+ // const fcmToken = userDetails.fcmToken;
2401
+ // await sendPushNotification( title, description, fcmToken );
2402
+ // }
2403
+ const inputDateTime = dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' );
2404
+ const currentTime = dayjs.utc();
2405
+ if ( inputDateTime.isBefore( currentTime ) ) {
2406
+ return res.sendError( 'The input date-time is before the current time.', 500 );
2407
+ }
2408
+
2409
+ let approverList = inputBody?.approver.split( ',' );
2410
+
2411
+
2412
+ let userAdmin = await userService.find( { clientId: inputBody.clientId, email: { $in: approverList }, userType: 'client', isActive: true }, { name: '$userName', email: 1 } );
2413
+
2414
+ if ( userAdmin && userAdmin.length === 0 ) {
2415
+ userAdmin = await userService.find( { clientId: inputBody.clientId, email: 'rohit.chawla@lenskart.com', userType: 'client', isActive: true }, { name: '$userName', email: 1 } );
2416
+ }
2417
+
2418
+ let creator = await userService.find( { clientId: inputBody.clientId, email: 'rohit.chawla@lenskart.com', userType: 'client', isActive: true } );
2419
+ if ( creator && creator.length === 0 ) {
2420
+ return res.sendError( 'Invalid Creator Details', 500 );
2421
+ }
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 ) {
2427
+ return res.sendError( 'Maximum 3 referenceImage only allowed', 500 );
2428
+ }
2429
+ let data = {
2430
+ checkListName: `${inputBody.taskName}-${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}`,
2431
+ checkListDescription: inputBody.taskDescription,
2432
+ createdBy: creator[0]._id,
2433
+ createdByName: creator[0].userName,
2434
+ publish: true,
2435
+ questionCount: 1,
2436
+ storeCount: 1,
2437
+ scheduleDate: date,
2438
+ scheduleEndTime: time,
2439
+ scheduleEndTimeISO: dayjs.utc( `${date} ${time}`, 'YYYY-MM-DD hh:mm A' ).format(),
2440
+ priorityType: 'high',
2441
+ client_id: inputBody.clientId,
2442
+ checkListType: 'task',
2443
+ publishDate: new Date(),
2444
+ locationCount: 1,
2445
+ ...( inputBody?.checkListId ) ? { referenceCheckListId: inputBody?.checkListId } : {},
2446
+ };
2447
+
2448
+
2449
+ data['approver'] = userAdmin;
2450
+
2451
+
2452
+ let answer = await findAnswer( inputBody?.answerType );
2453
+ if ( answer.length == 0 ) {
2454
+ return res.sendError( 'please enter Valid AnswerType', 500 );
2455
+ }
2456
+ if ( inputBody?.answerType === 'multiplechoicesingle' || inputBody?.answerType === 'multiplechoicemultiple' ) {
2457
+ if ( inputBody?.options && inputBody?.options.length > 0 ) {
2458
+ let optionsResult = [];
2459
+ let optionList = inputBody?.options.split( ',' );
2460
+ for ( let option of optionList ) {
2461
+ let optiondata = {
2462
+ 'answer': '',
2463
+ 'sopFlag': false,
2464
+ 'validation': false,
2465
+ 'validationType': '',
2466
+ 'referenceImage': [],
2467
+ 'runAI': false,
2468
+ 'allowUploadfromGallery': false,
2469
+ 'descriptivetype': '',
2470
+ 'showLinked': false,
2471
+ 'linkedQuestion': 0,
2472
+ 'nestedQuestion': [],
2473
+ };
2474
+ optiondata.answer = option;
2475
+ optionsResult.push( optiondata );
2476
+ }
2477
+ answer = optionsResult;
2478
+ } else {
2479
+ return res.sendError( 'please enter Valid Options', 500 );
2480
+ }
2481
+ }
2482
+
2483
+
2484
+ let response = await taskService.create( data );
2485
+ if ( response?.approver.length ) {
2486
+ let inputData = [];
2487
+ response?.approver.forEach( ( ele ) => {
2488
+ inputData.push( {
2489
+ userEmail: ele.email,
2490
+ checkListId: response._id,
2491
+ type: 'task',
2492
+ client_id: inputBody.clientId,
2493
+ checkListName: data?.checkListName || '',
2494
+ } );
2495
+ } );
2496
+
2497
+ await traxApprover.insertMany( inputData );
2498
+ }
2499
+
2500
+ if ( response?._id ) {
2501
+ let question = [
2502
+ {
2503
+ 'qno': 1,
2504
+ 'qname': inputBody.question,
2505
+ 'answerType': inputBody?.answerType || 'yes/no',
2506
+ 'runAI': false,
2507
+ 'runAIDescription': '',
2508
+ 'allowUploadfromGallery': false,
2509
+ 'linkType': false,
2510
+ 'questionReferenceImage': [],
2511
+ 'answers': answer,
2512
+ 'descriptivetype': 'text',
2513
+ },
2514
+ ];
2515
+
2516
+
2517
+ let images = [];
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
+ };
2525
+
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 );
2542
+ }
2543
+ images.push( url.join( '/' ) );
2544
+ }
2545
+ question[0].questionReferenceImage = images;
2546
+
2547
+ if ( inputBody?.answerType === 'image' || inputBody?.answerType === 'descriptiveImage' || inputBody?.answerType === 'multipleImage' ) {
2548
+ answer[0].referenceImage = question[0].questionReferenceImage;
2549
+ }
2550
+
2551
+
2552
+ question = {
2553
+ checkListId: response?._id,
2554
+ question: question,
2555
+ section: 'Section 1',
2556
+ checkList: data.checkListName,
2557
+ client_id: inputBody.clientId,
2558
+ };
2559
+ await taskQuestionService.create( question );
2560
+
2561
+ let userDetails = {
2562
+ userName: inputBody.userName,
2563
+ userEmail: inputBody.userEmail,
2564
+ store_id: storeDetails.storeId,
2565
+ storeName: storeDetails.storeName,
2566
+ city: storeDetails?.storeProfile?.city,
2567
+ checkFlag: true,
2568
+ checkListId: response?._id,
2569
+ checkListName: data.checkListName,
2570
+ client_id: inputBody.clientId,
2571
+ userId: userId,
2572
+ };
2573
+ await taskAssignService.create( userDetails );
2574
+ await insertSingleProcessData( response?._id );
2575
+ return res.sendSuccess( 'Task created successfully' );
2576
+ }
2577
+ } catch ( e ) {
2578
+ logger.error( { function: 'createAiTaskNew', error: e } );
2579
+ return res.sendError( e, 500 );
2580
+ }
2581
+ }
2312
2582
  export async function createAiTask( req, res ) {
2313
2583
  try {
2314
2584
  let inputBody = req.body;
2315
- inputBody.clientId= 11;
2585
+ inputBody.clientId = 11;
2316
2586
  inputBody.taskDescription = '';
2317
2587
  let userId;
2318
2588
  let storeDetails = await storeService.findOne( { storeName: inputBody.storeName, clientId: inputBody.clientId, status: 'active' }, { storeId: 1, storeName: 1, storeProfile: 1 } );
@@ -2320,7 +2590,9 @@ export async function createAiTask( req, res ) {
2320
2590
  return res.sendError( 'Store Not Found', 500 );
2321
2591
  }
2322
2592
  console.log( storeDetails );
2323
- let finduser= await checklistassignconfigModel.findOne( { checkListId: new mongoose.Types.ObjectId( '6789e3c7a5683c58215ec089' ), store_id: storeDetails.storeId } );
2593
+ let url = JSON.parse( process.env.LAMBDAURL );
2594
+ let checklistId = url.dailystoreChecklistId;
2595
+ let finduser = await checklistassignconfigModel.findOne( { checkListId: new mongoose.Types.ObjectId( checklistId ), store_id: storeDetails.storeId } );
2324
2596
  console.log( finduser );
2325
2597
  if ( !finduser ) {
2326
2598
  return res.sendError( 'No user Found For this store', 500 );
@@ -2329,6 +2601,7 @@ export async function createAiTask( req, res ) {
2329
2601
  inputBody.userName = finduser.userName;
2330
2602
  inputBody.userEmail = finduser.userEmail;
2331
2603
 
2604
+
2332
2605
  // let title = `New Task Alert ${inputBody.taskName}-${storeDetails.storeName}-${dayjs().format( 'YYYY-MM-DD' )}`;
2333
2606
  let time = inputBody?.scheduleEndTime || '11:59 PM';
2334
2607
  let date = inputBody?.scheduleDate || dayjs().format( 'YYYY-MM-DD' );
@@ -2348,15 +2621,15 @@ export async function createAiTask( req, res ) {
2348
2621
 
2349
2622
  let userAdmin = await userService.find( { clientId: inputBody.clientId, email: { $in: approverList }, userType: 'client', isActive: true }, { name: '$userName', email: 1 } );
2350
2623
  console.log( userAdmin );
2351
- if ( userAdmin&&userAdmin.length===0 ) {
2624
+ if ( userAdmin && userAdmin.length === 0 ) {
2352
2625
  return res.sendError( 'Invalid Approver Details', 500 );
2353
2626
  }
2354
2627
 
2355
2628
  let creator = await userService.find( { clientId: inputBody.clientId, email: { $in: inputBody.creator }, userType: 'client', isActive: true } );
2356
- if ( creator&&creator.length===0 ) {
2629
+ if ( creator && creator.length === 0 ) {
2357
2630
  return res.sendError( 'Invalid Creator Details', 500 );
2358
2631
  }
2359
- if ( req.files&&req.files.referenceImage&& req.files.referenceImage.length>3 ) {
2632
+ if ( req.files && req.files.referenceImage && req.files.referenceImage.length > 3 ) {
2360
2633
  return res.sendError( 'Maximum 3 referenceImage only allowed', 500 );
2361
2634
  }
2362
2635
 
@@ -2384,12 +2657,12 @@ export async function createAiTask( req, res ) {
2384
2657
  console.log( data );
2385
2658
 
2386
2659
  let answer = await findAnswer( inputBody?.answerType );
2387
- if ( answer.length==0 ) {
2660
+ if ( answer.length == 0 ) {
2388
2661
  return res.sendError( 'please enter Valid AnswerType', 500 );
2389
2662
  }
2390
- if ( inputBody?.answerType === 'multiplechoicesingle'||inputBody?.answerType === 'multiplechoicemultiple' ) {
2663
+ if ( inputBody?.answerType === 'multiplechoicesingle' || inputBody?.answerType === 'multiplechoicemultiple' ) {
2391
2664
  console.log( inputBody?.options );
2392
- if ( inputBody?.options&& inputBody?.options.length>0 ) {
2665
+ if ( inputBody?.options && inputBody?.options.length > 0 ) {
2393
2666
  let optionsResult = [];
2394
2667
  let optionList = inputBody?.options.split( ',' );
2395
2668
  for ( let option of optionList ) {
@@ -2409,7 +2682,7 @@ export async function createAiTask( req, res ) {
2409
2682
  optiondata.answer = option;
2410
2683
  optionsResult.push( optiondata );
2411
2684
  }
2412
- answer =optionsResult;
2685
+ answer = optionsResult;
2413
2686
  } else {
2414
2687
  return res.sendError( 'please enter Valid Options', 500 );
2415
2688
  }
@@ -2450,13 +2723,13 @@ export async function createAiTask( req, res ) {
2450
2723
  ];
2451
2724
 
2452
2725
 
2453
- if ( req.files&& req.files.referenceImage&&req.files.referenceImage.length ) {
2726
+ if ( req.files && req.files.referenceImage && req.files.referenceImage.length ) {
2454
2727
  let images = [];
2455
2728
  console.log( req.files.referenceImage.length );
2456
2729
 
2457
2730
 
2458
2731
  for ( let image of req.files.referenceImage ) {
2459
- let uplaodedImage =await uploadmultiImage( image );
2732
+ let uplaodedImage = await uploadmultiImage( image );
2460
2733
  let imgUrl = decodeURIComponent( uplaodedImage.imgUrl.split( '?' )[0] );
2461
2734
  let url = imgUrl.split( '/' );
2462
2735
  if ( url.includes( 'https:' ) || url.includes( 'http:' ) ) {
@@ -2466,7 +2739,7 @@ export async function createAiTask( req, res ) {
2466
2739
  }
2467
2740
  question[0].questionReferenceImage = images;
2468
2741
  }
2469
- if ( inputBody?.answerType === 'image'||inputBody?.answerType === 'descriptiveImage'||inputBody?.answerType === 'multipleImage' ) {
2742
+ if ( inputBody?.answerType === 'image' || inputBody?.answerType === 'descriptiveImage' || inputBody?.answerType === 'multipleImage' ) {
2470
2743
  answer[0].referenceImage = question[0].questionReferenceImage;
2471
2744
  }
2472
2745
 
@@ -2498,12 +2771,11 @@ export async function createAiTask( req, res ) {
2498
2771
  return res.sendSuccess( 'Task created successfully' );
2499
2772
  }
2500
2773
  } catch ( e ) {
2501
- logger.error( { function: createAiChecklist, error: e } );
2774
+ logger.error( { function: 'createAiChecklist', error: e } );
2502
2775
  return res.sendError( e, 500 );
2503
2776
  }
2504
2777
  }
2505
2778
 
2506
-
2507
2779
  async function findAnswer( type ) {
2508
2780
  let answer = [];
2509
2781
 
@@ -2781,14 +3053,25 @@ export async function uploadmultiImage( images ) {
2781
3053
 
2782
3054
  export async function customertrial( params ) {
2783
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
+
2784
3064
  let inputData = {
2785
3065
  Bucket: 'tango-trax-audit',
2786
- 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',
2787
3067
  };
2788
- let url = await signedUrl( inputData );
3068
+
3069
+ console.log( inputData );
3070
+ let url = await getObject( inputData );
2789
3071
  console.log( url );
2790
3072
  } catch ( e ) {
2791
3073
  logger.error( 'uploadImage =>', e );
2792
3074
  return e;
2793
3075
  }
2794
3076
  };
3077
+
@@ -11,9 +11,21 @@ export const aitaskvalidationSchema = Joi.object().keys( {
11
11
  options: Joi.string().optional(),
12
12
  scheduleDate: Joi.string().optional(),
13
13
  scheduleEndTime: Joi.string().optional(),
14
-
14
+ } );
15
+ export const aitaskvalidationSchemanew = Joi.object().keys( {
16
+ storeName: Joi.string().required(),
17
+ taskName: Joi.string().required(),
18
+ question: Joi.string().required(),
19
+ answerType: Joi.string().required(),
20
+ options: Joi.string().optional(),
21
+ scheduleDate: Joi.string().optional(),
22
+ scheduleEndTime: Joi.string().optional(),
23
+ referenceImage: Joi.string().required(),
15
24
  } );
16
25
 
17
26
  export const aitaskvalidation = {
18
27
  body: aitaskvalidationSchema,
19
28
  };
29
+ export const aitaskvalidationNew = {
30
+ body: aitaskvalidationSchemanew,
31
+ };
@@ -2,7 +2,7 @@
2
2
  import * as taskController from '../controllers/task.controller.js';
3
3
  import { isAllowedSessionHandler, validate, accessVerification, isAllowedClient, isAllowedInternalAPIHandler } from 'tango-app-api-middleware';
4
4
  import express from 'express';
5
- import { aitaskvalidation } from '../dtos/task.dto.js';
5
+ import { aitaskvalidation, aitaskvalidationNew } from '../dtos/task.dto.js';
6
6
  export const taskRouter = express.Router();
7
7
 
8
8
  taskRouter
@@ -26,8 +26,10 @@ taskRouter
26
26
  .put( '/publish', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.updatePublish )
27
27
  .get( '/duplicateTask/:checklistId', isAllowedSessionHandler, isAllowedClient, accessVerification( { userType: [ 'tango', 'client' ], access: [ { featureName: 'TangoTrax', name: 'Task', permissions: [ 'isEdit' ] } ] } ), taskController.duplicateChecklist )
28
28
  .get( '/teamMigrations', taskController.teamMigrations )
29
+ .get( '/clusterMigrations', taskController.clusterMigrations )
29
30
  .post( '/createaiChecklist', isAllowedInternalAPIHandler, taskController.createAiChecklist )
30
31
  .post( '/createaiTask', isAllowedInternalAPIHandler, validate( aitaskvalidation ), taskController.createAiTask )
32
+ .post( '/createAiTaskNew', isAllowedInternalAPIHandler, validate( aitaskvalidationNew ), taskController.createAiTaskNew )
31
33
  .get( '/getcoustemer', taskController.customertrial );
32
34
 
33
35
 
@@ -0,0 +1,31 @@
1
+ import clusterModel from 'tango-api-schema/schema/cluster.model.js';
2
+
3
+ export async function updateOneCluster( query, record ) {
4
+ return await clusterModel.updateOne( query, { $set: record } );
5
+ };
6
+
7
+ export async function updateCluster( query, record ) {
8
+ return await clusterModel.updateMany( query, record );
9
+ };
10
+
11
+ export async function aggregateCluster( query ) {
12
+ return await clusterModel.aggregate( query );
13
+ };
14
+
15
+ export async function findOneCluster( query ={}, field={} ) {
16
+ return await clusterModel.findOne( query, field );
17
+ };
18
+ export async function deleteCluster( query ={} ) {
19
+ return await clusterModel.deleteOne( query );
20
+ };
21
+
22
+ export async function createclusterModel( data ) {
23
+ return await clusterModel.create( data );
24
+ };
25
+
26
+ export async function findcluster( query, project ) {
27
+ return await clusterModel.find( query, project );
28
+ };
29
+ export function countDocumentsClusters( query ) {
30
+ return clusterModel.countDocuments( query );
31
+ }
@@ -19,6 +19,8 @@ export async function findOneTeams( query ={}, field={} ) {
19
19
  return await teamsModel.findOne( query, field );
20
20
  };
21
21
  export async function findteams( query ={}, field={} ) {
22
+ console.log( query );
23
+
22
24
  return await teamsModel.find( query, field );
23
25
  };
24
26