@librechat/data-schemas 0.0.37 → 0.0.39
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 +38 -8
- package/dist/index.cjs.map +1 -1
- package/dist/index.es.js +39 -9
- package/dist/index.es.js.map +1 -1
- package/dist/types/types/user.d.ts +6 -0
- package/package.json +1 -1
package/dist/index.es.js
CHANGED
|
@@ -8,7 +8,7 @@ import jwt from 'jsonwebtoken';
|
|
|
8
8
|
import crypto from 'node:crypto';
|
|
9
9
|
import mongoose, { Schema, Types } from 'mongoose';
|
|
10
10
|
import _ from 'lodash';
|
|
11
|
-
import { MeiliSearch } from 'meilisearch';
|
|
11
|
+
import { MeiliSearch, MeiliSearchTimeOutError } from 'meilisearch';
|
|
12
12
|
import { nanoid } from 'nanoid';
|
|
13
13
|
|
|
14
14
|
/**
|
|
@@ -92,6 +92,7 @@ async function loadDefaultInterface({ config, configDefaults, }) {
|
|
|
92
92
|
fileCitations: interfaceConfig === null || interfaceConfig === void 0 ? void 0 : interfaceConfig.fileCitations,
|
|
93
93
|
peoplePicker: interfaceConfig === null || interfaceConfig === void 0 ? void 0 : interfaceConfig.peoplePicker,
|
|
94
94
|
marketplace: interfaceConfig === null || interfaceConfig === void 0 ? void 0 : interfaceConfig.marketplace,
|
|
95
|
+
remoteAgents: interfaceConfig === null || interfaceConfig === void 0 ? void 0 : interfaceConfig.remoteAgents,
|
|
95
96
|
});
|
|
96
97
|
return loadedInterface;
|
|
97
98
|
}
|
|
@@ -2628,6 +2629,15 @@ const userSchema = new Schema({
|
|
|
2628
2629
|
type: [BackupCodeSchema],
|
|
2629
2630
|
select: false,
|
|
2630
2631
|
},
|
|
2632
|
+
pendingTotpSecret: {
|
|
2633
|
+
type: String,
|
|
2634
|
+
select: false,
|
|
2635
|
+
},
|
|
2636
|
+
pendingBackupCodes: {
|
|
2637
|
+
type: [BackupCodeSchema],
|
|
2638
|
+
select: false,
|
|
2639
|
+
default: undefined,
|
|
2640
|
+
},
|
|
2631
2641
|
refreshToken: {
|
|
2632
2642
|
type: [SessionSchema],
|
|
2633
2643
|
},
|
|
@@ -3002,9 +3012,11 @@ const createMeiliMongooseModel = ({ index, attributesToIndex, syncOptions, }) =>
|
|
|
3002
3012
|
try {
|
|
3003
3013
|
// Add documents to MeiliSearch
|
|
3004
3014
|
await index.addDocumentsInBatches(formattedDocs);
|
|
3005
|
-
// Update MongoDB to mark documents as indexed
|
|
3015
|
+
// Update MongoDB to mark documents as indexed.
|
|
3016
|
+
// { timestamps: false } prevents Mongoose from touching updatedAt, preserving
|
|
3017
|
+
// original conversation/message timestamps (fixes sidebar chronological sort).
|
|
3006
3018
|
const docsIds = documents.map((doc) => doc._id);
|
|
3007
|
-
await this.updateMany({ _id: { $in: docsIds } }, { $set: { _meiliIndex: true } });
|
|
3019
|
+
await this.updateMany({ _id: { $in: docsIds } }, { $set: { _meiliIndex: true } }, { timestamps: false });
|
|
3008
3020
|
}
|
|
3009
3021
|
catch (error) {
|
|
3010
3022
|
logger.error('[processSyncBatch] Error processing batch:', error);
|
|
@@ -3251,7 +3263,6 @@ function mongoMeili(schema, options) {
|
|
|
3251
3263
|
const client = new MeiliSearch({ host, apiKey });
|
|
3252
3264
|
/** Create index only if it doesn't exist */
|
|
3253
3265
|
const index = client.index(indexName);
|
|
3254
|
-
// Check if index exists and create if needed
|
|
3255
3266
|
(async () => {
|
|
3256
3267
|
try {
|
|
3257
3268
|
await index.getRawInfo();
|
|
@@ -3262,19 +3273,38 @@ function mongoMeili(schema, options) {
|
|
|
3262
3273
|
if (errorCode === 'index_not_found') {
|
|
3263
3274
|
try {
|
|
3264
3275
|
logger.info(`[mongoMeili] Creating new index: ${indexName}`);
|
|
3265
|
-
await client.createIndex(indexName, { primaryKey });
|
|
3266
|
-
|
|
3276
|
+
const enqueued = await client.createIndex(indexName, { primaryKey });
|
|
3277
|
+
const task = await client.waitForTask(enqueued.taskUid, {
|
|
3278
|
+
timeOutMs: 10000,
|
|
3279
|
+
intervalMs: 100,
|
|
3280
|
+
});
|
|
3281
|
+
logger.debug(`[mongoMeili] Index ${indexName} creation task:`, task);
|
|
3282
|
+
if (task.status !== 'succeeded') {
|
|
3283
|
+
const taskError = task.error;
|
|
3284
|
+
if ((taskError === null || taskError === void 0 ? void 0 : taskError.code) === 'index_already_exists') {
|
|
3285
|
+
logger.debug(`[mongoMeili] Index ${indexName} was created by another instance`);
|
|
3286
|
+
}
|
|
3287
|
+
else {
|
|
3288
|
+
logger.warn(`[mongoMeili] Index ${indexName} creation failed:`, taskError);
|
|
3289
|
+
}
|
|
3290
|
+
}
|
|
3291
|
+
else {
|
|
3292
|
+
logger.info(`[mongoMeili] Successfully created index: ${indexName}`);
|
|
3293
|
+
}
|
|
3267
3294
|
}
|
|
3268
3295
|
catch (createError) {
|
|
3269
|
-
|
|
3270
|
-
|
|
3296
|
+
if (createError instanceof MeiliSearchTimeOutError) {
|
|
3297
|
+
logger.warn(`[mongoMeili] Timed out waiting for index ${indexName} creation`);
|
|
3298
|
+
}
|
|
3299
|
+
else {
|
|
3300
|
+
logger.warn(`[mongoMeili] Error creating index ${indexName}:`, createError);
|
|
3301
|
+
}
|
|
3271
3302
|
}
|
|
3272
3303
|
}
|
|
3273
3304
|
else {
|
|
3274
3305
|
logger.error(`[mongoMeili] Error checking index ${indexName}:`, error);
|
|
3275
3306
|
}
|
|
3276
3307
|
}
|
|
3277
|
-
// Configure index settings to make 'user' field filterable
|
|
3278
3308
|
try {
|
|
3279
3309
|
await index.updateSettings({
|
|
3280
3310
|
filterableAttributes: ['user'],
|