@xuda.io/ai_module 1.1.5030 → 1.1.5032

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 +11 -11
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -1289,17 +1289,19 @@ export const get_ai_chats = async function (req, job_id, headers) {
1289
1289
  // 1. Determine Sort Pattern and Key Prefix
1290
1290
  const sortType = reference_id ? 'ref' : 'ts';
1291
1291
 
1292
- // 2. Build Base Key Arrays as raw objects
1292
+ // 2. Build Base Key Arrays
1293
1293
  // Key Structure: [profileId, type, convType, sortType, sortVal1, sortVal2]
1294
+ // We use null for start and {} for end to capture ALL conversation types if conversation_type is missing
1294
1295
  let startkey = [profileId, filter_type || 'all', conversation_type || null, sortType];
1295
- let endkey = [profileId, filter_type || 'all', conversation_type || null, sortType];
1296
+ let endkey = [profileId, filter_type || 'all', conversation_type || {}, sortType];
1296
1297
 
1297
1298
  if (reference_id) {
1298
- // Exact match for reference_id, sorted by date_created_ts ASC
1299
+ // Exact match for reference_id
1299
1300
  startkey.push(reference_id);
1300
- endkey.push(reference_id, {}); // {} is the high-value sentinel
1301
+ // {} ensures we get all date_created_ts values for this reference_id
1302
+ endkey.push(reference_id, {});
1301
1303
  } else {
1302
- // For 'ts' descending, startkey must be the "highest" value
1304
+ // For 'ts' descending, we reverse the start/end logic
1303
1305
  startkey.push({});
1304
1306
  endkey.push(0);
1305
1307
  }
@@ -1307,9 +1309,8 @@ export const get_ai_chats = async function (req, job_id, headers) {
1307
1309
  // 3. Construct Query Object
1308
1310
  const query = {
1309
1311
  include_docs: true,
1310
- startkey: startkey, // Pass as Array; Nano handles the stringification
1312
+ startkey: startkey, // Pass as Array for Nano
1311
1313
  endkey: endkey,
1312
- // Cast to Number to prevent CouchDB "Invalid value" errors
1313
1314
  limit: parseInt(limit) || 9999,
1314
1315
  skip: parseInt(skip) || 0,
1315
1316
  descending: !reference_id,
@@ -1320,12 +1321,11 @@ export const get_ai_chats = async function (req, job_id, headers) {
1320
1321
  }
1321
1322
 
1322
1323
  // 4. Call the List Function
1323
- // Adjusted to match your signature without the redundant 'chats' arg
1324
+ // Ensure the order matches your Nano documentation: (ddoc, view, list, query)
1324
1325
  const response = await db_module.call_app_list_function(
1325
1326
  account_profile_info.app_id,
1326
-
1327
- 'by_profile', // View Name ,
1328
- 'filter_chats', // List Name
1327
+ 'by_profile', // viewname
1328
+ 'filter_chats', // listname
1329
1329
  query,
1330
1330
  );
1331
1331
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.5030",
3
+ "version": "1.1.5032",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",