@xuda.io/ai_module 1.1.4999 → 1.1.5001

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 +89 -73
  2. package/package.json +1 -1
package/index.mjs CHANGED
@@ -1168,79 +1168,6 @@ export const get_ai_chats = async function (req, job_id, headers) {
1168
1168
  return data;
1169
1169
  }
1170
1170
 
1171
- let opt = {
1172
- selector: {
1173
- docType: 'chat_conversation',
1174
- stat: 3,
1175
- reference_id: '',
1176
- },
1177
- limit: limit || 9999,
1178
- skip: skip || 0,
1179
- // sort: [{ ts: reference_id ? 'asc' : 'desc' }],
1180
- };
1181
-
1182
- if (reference_id) {
1183
- opt.sort = [{ date_created_ts: 'asc' }];
1184
- } else {
1185
- opt.sort = [{ ts: 'desc' }];
1186
- }
1187
-
1188
- if (!account_profile_info.is_main) {
1189
- opt.selector.account_profiles = { $in: [account_profile_info.account_profile_id] };
1190
- }
1191
-
1192
- switch (filter_type) {
1193
- case 'archived': {
1194
- opt.selector.stat = 5;
1195
- break;
1196
- }
1197
- case 'shared': {
1198
- opt.selector.shared_from_uid = { $gt: null };
1199
- // opt.selector.team_req_stat = { $eq: 3 };
1200
- break;
1201
- }
1202
-
1203
- case 'mine': {
1204
- opt.selector.uid = uid;
1205
-
1206
- break;
1207
- }
1208
-
1209
- default:
1210
- // opt.selector.team_req_stat = { $eq: 3 };
1211
- break;
1212
- }
1213
-
1214
- if (conversation_type) {
1215
- opt.selector.conversation_type = conversation_type;
1216
- }
1217
-
1218
- if (reference_id) {
1219
- opt.selector.reference_id = reference_id;
1220
- }
1221
-
1222
- if (conversation_id) {
1223
- opt.selector._id = conversation_id;
1224
- }
1225
-
1226
- if (search) {
1227
- opt.selector = {
1228
- ...opt.selector,
1229
- $or: [
1230
- {
1231
- title: {
1232
- $regex: `(?i)${search}`,
1233
- },
1234
- },
1235
- {
1236
- _id: {
1237
- $regex: `(?i)${search}`,
1238
- },
1239
- },
1240
- ],
1241
- };
1242
- }
1243
-
1244
1171
  const chat_conversation_count = async function (contact_id, conversation_id) {
1245
1172
  const counts_ret = await db_module.get_app_couch_view(account_profile_info.app_id, 'chat_conversation_item_counts', {
1246
1173
  reduce: true,
@@ -1267,6 +1194,95 @@ export const get_ai_chats = async function (req, job_id, headers) {
1267
1194
  return counts_ret?.rows?.[0]?.value || 0;
1268
1195
  };
1269
1196
 
1197
+ const get_data_find = async function () {
1198
+ let opt = {
1199
+ selector: {
1200
+ docType: 'chat_conversation',
1201
+ stat: 3,
1202
+ reference_id: '',
1203
+ },
1204
+ limit: limit || 9999,
1205
+ skip: skip || 0,
1206
+ // sort: [{ ts: reference_id ? 'asc' : 'desc' }],
1207
+ };
1208
+
1209
+ if (reference_id) {
1210
+ opt.sort = [{ date_created_ts: 'asc' }];
1211
+ } else {
1212
+ opt.sort = [{ ts: 'desc' }];
1213
+ }
1214
+
1215
+ if (!account_profile_info.is_main) {
1216
+ opt.selector.account_profiles = { $in: [account_profile_info.account_profile_id] };
1217
+ }
1218
+
1219
+ switch (filter_type) {
1220
+ case 'archived': {
1221
+ opt.selector.stat = 5;
1222
+ break;
1223
+ }
1224
+ case 'shared': {
1225
+ opt.selector.shared_from_uid = { $gt: null };
1226
+ // opt.selector.team_req_stat = { $eq: 3 };
1227
+ break;
1228
+ }
1229
+
1230
+ case 'mine': {
1231
+ opt.selector.uid = uid;
1232
+
1233
+ break;
1234
+ }
1235
+
1236
+ default:
1237
+ // opt.selector.team_req_stat = { $eq: 3 };
1238
+ break;
1239
+ }
1240
+
1241
+ if (conversation_type) {
1242
+ opt.selector.conversation_type = conversation_type;
1243
+ }
1244
+
1245
+ if (reference_id) {
1246
+ opt.selector.reference_id = reference_id;
1247
+ }
1248
+
1249
+ if (conversation_id) {
1250
+ opt.selector._id = conversation_id;
1251
+ }
1252
+
1253
+ if (search) {
1254
+ opt.selector = {
1255
+ ...opt.selector,
1256
+ $or: [
1257
+ {
1258
+ title: {
1259
+ $regex: `(?i)${search}`,
1260
+ },
1261
+ },
1262
+ {
1263
+ _id: {
1264
+ $regex: `(?i)${search}`,
1265
+ },
1266
+ },
1267
+ ],
1268
+ };
1269
+ }
1270
+
1271
+ let ai_chats = await db_module.find_app_couch_query(account_profile_info.app_id, opt);
1272
+ if (!limit || conversation_id) {
1273
+ ai_chats.total_docs = ai_chats.docs.length;
1274
+ } else {
1275
+ delete opt.sort;
1276
+ delete opt.skip;
1277
+ opt.limit = 9999;
1278
+ opt.fields = ['_id'];
1279
+
1280
+ const counter = await db_module.find_app_couch_query(account_profile_info.app_id, opt);
1281
+ ai_chats.total_docs = counter.docs.length;
1282
+ }
1283
+ return ai_chats;
1284
+ };
1285
+
1270
1286
  ////// FROM - IN
1271
1287
  let requests_from = { docs: [], total_docs: 0 };
1272
1288
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xuda.io/ai_module",
3
- "version": "1.1.4999",
3
+ "version": "1.1.5001",
4
4
  "description": "Xuda AI Module",
5
5
  "main": "index.mjs",
6
6
  "type": "module",