@xuda.io/ai_module 1.1.3560 → 1.1.3561

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 +53 -1
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -2528,10 +2528,62 @@ export const install_ai_agent = async function (req) {
2528
2528
  };
2529
2529
 
2530
2530
  export const get_apps = async function (req, job_id, headers) {
2531
- let { uid, _id } = req;
2531
+ let { uid, _id, search, filter_type = 'all' } = req;
2532
2532
 
2533
2533
  try {
2534
2534
  if (_id) return await get_ai_doc({ _id, uid });
2535
+ ///////////////
2536
+ let opt = {
2537
+ selector: {
2538
+ docType: 'chat_conversation',
2539
+ stat: 3,
2540
+ reference_id: '',
2541
+ },
2542
+ limit: limit || 9999,
2543
+ skip: skip || 0,
2544
+ sort: ['ts'],
2545
+ };
2546
+
2547
+ switch (filter_type) {
2548
+ case 'archived': {
2549
+ opt.selector.stat = 0;
2550
+ break;
2551
+ }
2552
+ case 'shared': {
2553
+ opt.selector.shared_from_uid = { $gt: null };
2554
+ break;
2555
+ }
2556
+
2557
+ default:
2558
+ break;
2559
+ }
2560
+
2561
+ if (conversation_type) {
2562
+ opt.selector.conversation_type = conversation_type;
2563
+ }
2564
+
2565
+ if (reference_id) {
2566
+ opt.selector.reference_id = reference_id;
2567
+ }
2568
+
2569
+ if (search) {
2570
+ opt.selector = {
2571
+ ...opt.selector,
2572
+ $or: [
2573
+ {
2574
+ title: {
2575
+ $regex: `(?i)${search}`,
2576
+ },
2577
+ },
2578
+ {
2579
+ _id: {
2580
+ $regex: `(?i)${search}`,
2581
+ },
2582
+ },
2583
+ ],
2584
+ };
2585
+ }
2586
+ //////////////
2535
2587
 
2536
2588
  const app_id = await account_module.get_account_default_project_id(uid);
2537
2589
  const user_apps = await db_module.get_app_couch_view(app_id, 'studio_mini_apps', {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.3560",
3
+ "version": "1.1.3561",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",