@librechat/data-schemas 0.0.22 → 0.0.23

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.
package/dist/index.es.js CHANGED
@@ -536,6 +536,7 @@ const convoSchema = new Schema({
536
536
  user: {
537
537
  type: String,
538
538
  index: true,
539
+ meiliIndex: true,
539
540
  },
540
541
  messages: [{ type: Schema.Types.ObjectId, ref: 'Message' }],
541
542
  agentOptions: {
@@ -676,6 +677,7 @@ const messageSchema = new Schema({
676
677
  index: true,
677
678
  required: true,
678
679
  default: null,
680
+ meiliIndex: true,
679
681
  },
680
682
  model: {
681
683
  type: String,
@@ -2419,6 +2421,16 @@ function mongoMeili(schema, options) {
2419
2421
  logger.error(`[mongoMeili] Error checking index ${indexName}:`, error);
2420
2422
  }
2421
2423
  }
2424
+ // Configure index settings to make 'user' field filterable
2425
+ try {
2426
+ await index.updateSettings({
2427
+ filterableAttributes: ['user'],
2428
+ });
2429
+ logger.debug(`[mongoMeili] Updated index ${indexName} settings to make 'user' filterable`);
2430
+ }
2431
+ catch (settingsError) {
2432
+ logger.error(`[mongoMeili] Error updating index settings for ${indexName}:`, settingsError);
2433
+ }
2422
2434
  })();
2423
2435
  // Collect attributes from the schema that should be indexed
2424
2436
  const attributesToIndex = [
@@ -2427,6 +2439,12 @@ function mongoMeili(schema, options) {
2427
2439
  return schemaValue.meiliIndex ? [...results, key] : results;
2428
2440
  }, []),
2429
2441
  ];
2442
+ // CRITICAL: Always include 'user' field for proper filtering
2443
+ // This ensures existing deployments can filter by user after migration
2444
+ if (schema.obj.user && !attributesToIndex.includes('user')) {
2445
+ attributesToIndex.push('user');
2446
+ logger.debug(`[mongoMeili] Added 'user' field to ${indexName} index attributes`);
2447
+ }
2430
2448
  schema.loadClass(createMeiliMongooseModel({ index, attributesToIndex, syncOptions }));
2431
2449
  // Register Mongoose hooks
2432
2450
  schema.post('save', function (doc, next) {
@@ -3084,7 +3102,7 @@ function createTokenMethods(mongoose) {
3084
3102
  /**
3085
3103
  * Finds a Token document that matches the provided query.
3086
3104
  */
3087
- async function findToken(query) {
3105
+ async function findToken(query, options) {
3088
3106
  try {
3089
3107
  const Token = mongoose.models.Token;
3090
3108
  const conditions = [];
@@ -3100,9 +3118,7 @@ function createTokenMethods(mongoose) {
3100
3118
  if (query.identifier) {
3101
3119
  conditions.push({ identifier: query.identifier });
3102
3120
  }
3103
- const token = await Token.findOne({
3104
- $and: conditions,
3105
- }).lean();
3121
+ const token = await Token.findOne({ $and: conditions }, null, options).lean();
3106
3122
  return token;
3107
3123
  }
3108
3124
  catch (error) {
@@ -4805,7 +4821,9 @@ function createShareMethods(mongoose) {
4805
4821
  }
4806
4822
  if (search && search.trim()) {
4807
4823
  try {
4808
- const searchResults = await Conversation.meiliSearch(search);
4824
+ const searchResults = await Conversation.meiliSearch(search, {
4825
+ filter: `user = "${user}"`,
4826
+ });
4809
4827
  if (!((_a = searchResults === null || searchResults === void 0 ? void 0 : searchResults.hits) === null || _a === void 0 ? void 0 : _a.length)) {
4810
4828
  return {
4811
4829
  links: [],