@xuda.io/ai_module 1.1.3570 → 1.1.3572

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 +52 -2
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -1834,7 +1834,7 @@ export const get_ai_chats = async function (req, job_id, headers) {
1834
1834
  // const ai_chats = await db_module.get_app_couch_view(app_id, 'ai_chat_list', {
1835
1835
  // key: reference_id || '',
1836
1836
  // });
1837
- debugger;
1837
+
1838
1838
  let ai_chats = [];
1839
1839
  if (filter_type !== 'pending') {
1840
1840
  ai_chats = await db_module.find_app_couch_query(app_id, opt);
@@ -2293,7 +2293,7 @@ export const get_ai_agent_info = async function (uid, job_id, headers, doc, from
2293
2293
  };
2294
2294
 
2295
2295
  export const get_ai_agents = async function (req, job_id, headers) {
2296
- let { uid, _id } = req;
2296
+ let { uid, _id, search, filter_type = 'all', limit, skip } = req;
2297
2297
 
2298
2298
  try {
2299
2299
  if (_id) {
@@ -2303,6 +2303,56 @@ export const get_ai_agents = async function (req, job_id, headers) {
2303
2303
  return doc;
2304
2304
  }
2305
2305
 
2306
+ ///////////////
2307
+ let opt = {
2308
+ selector: {
2309
+ docType: 'studio',
2310
+ stat: 3,
2311
+ 'studio_meta.miniApp': true,
2312
+ },
2313
+ limit: limit || 9999,
2314
+ skip: skip || 0,
2315
+ sort: ['ts'],
2316
+ };
2317
+
2318
+ switch (filter_type) {
2319
+ case 'archived': {
2320
+ opt.selector.stat = 0;
2321
+ break;
2322
+ }
2323
+ case 'shared': {
2324
+ opt.selector['studio_meta.shared_from_uid'] = { $gt: null };
2325
+ break;
2326
+ }
2327
+
2328
+ default:
2329
+ break;
2330
+ }
2331
+
2332
+ if (search) {
2333
+ opt.selector = {
2334
+ ...opt.selector,
2335
+ $or: [
2336
+ {
2337
+ 'properties.menuName': {
2338
+ $regex: `(?i)${search}`,
2339
+ },
2340
+ },
2341
+ {
2342
+ 'properties.description': {
2343
+ $regex: `(?i)${search}`,
2344
+ },
2345
+ },
2346
+ {
2347
+ _id: {
2348
+ $regex: `(?i)${search}`,
2349
+ },
2350
+ },
2351
+ ],
2352
+ };
2353
+ }
2354
+ //////////////
2355
+
2306
2356
  const app_id = await account_module.get_account_default_project_id(uid);
2307
2357
  const user_agents = await db_module.get_app_couch_view(app_id, 'studio_docs_by_type', {
2308
2358
  key: 'ai_agent',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.3570",
3
+ "version": "1.1.3572",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",