@xuda.io/ai_module 1.1.3930 → 1.1.3932

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.
Files changed (2) hide show
  1. package/index.mjs +15 -4
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -2447,13 +2447,23 @@ export const get_ai_agents = async function (req, job_id, headers) {
2447
2447
 
2448
2448
  const app_id = await account_module.get_account_default_project_id(uid);
2449
2449
 
2450
- let user_agents = { docs: [] };
2450
+ let user_agents = { docs: [], total_docs: 0 };
2451
2451
  if (filter_type !== 'pending') {
2452
- user_agents = await db_module.find_app_couch_query(app_id, opt);
2452
+ if (!limit || ai_agent_id) {
2453
+ user_agents = await db_module.find_app_couch_query(app_id, opt);
2454
+ }
2455
+ } else {
2456
+ delete opt.sort;
2457
+ delete opt.skip;
2458
+ opt.limit = 9999;
2459
+ opt.fields = ['_id'];
2460
+
2461
+ const counter = await db_module.find_app_couch_query(app_id, opt);
2462
+ user_agents.total_docs = counter.docs.length;
2453
2463
  }
2454
2464
 
2455
2465
  ////// FROM - IN
2456
- let requests_from = { docs: [] };
2466
+ let requests_from = { docs: [], total_docs: 0 };
2457
2467
  if (filter_type === 'pending') {
2458
2468
  const from_opt = { selector: { docType: 'team_request', access_type: 'ai_agent', team_req_stat: 2, team_req_to_uid: uid }, fields: ['_id', 'team_req_date', 'sender_account_info.email', 'team_req_from_uid', 'share_item_id'] };
2459
2469
  const requests_from_res = await db_module.find_couch_query('xuda_team', from_opt);
@@ -2474,6 +2484,7 @@ export const get_ai_agents = async function (req, job_id, headers) {
2474
2484
 
2475
2485
  requests_from.docs.push(doc);
2476
2486
  }
2487
+ requests_from.total_docs = requests_from.docs.length;
2477
2488
  }
2478
2489
 
2479
2490
  //////////////////////
@@ -2501,7 +2512,7 @@ export const get_ai_agents = async function (req, job_id, headers) {
2501
2512
  docs.push(info_doc);
2502
2513
  }
2503
2514
 
2504
- return { code: 8, data: { docs: [...requests_from.docs, ...docs] } };
2515
+ return { code: 8, data: { docs: [...requests_from.docs, ...docs], total_docs: user_agents.total_docs + requests_from.total_docs.total_docs } };
2505
2516
  } catch (err) {
2506
2517
  return { code: -8, data: err.message };
2507
2518
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.3930",
3
+ "version": "1.1.3932",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",