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