@librechat/data-schemas 0.0.38 → 0.0.40

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
@@ -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
  /**
@@ -2629,6 +2629,15 @@ const userSchema = new Schema({
2629
2629
  type: [BackupCodeSchema],
2630
2630
  select: false,
2631
2631
  },
2632
+ pendingTotpSecret: {
2633
+ type: String,
2634
+ select: false,
2635
+ },
2636
+ pendingBackupCodes: {
2637
+ type: [BackupCodeSchema],
2638
+ select: false,
2639
+ default: undefined,
2640
+ },
2632
2641
  refreshToken: {
2633
2642
  type: [SessionSchema],
2634
2643
  },
@@ -3254,7 +3263,6 @@ function mongoMeili(schema, options) {
3254
3263
  const client = new MeiliSearch({ host, apiKey });
3255
3264
  /** Create index only if it doesn't exist */
3256
3265
  const index = client.index(indexName);
3257
- // Check if index exists and create if needed
3258
3266
  (async () => {
3259
3267
  try {
3260
3268
  await index.getRawInfo();
@@ -3265,19 +3273,38 @@ function mongoMeili(schema, options) {
3265
3273
  if (errorCode === 'index_not_found') {
3266
3274
  try {
3267
3275
  logger.info(`[mongoMeili] Creating new index: ${indexName}`);
3268
- await client.createIndex(indexName, { primaryKey });
3269
- logger.info(`[mongoMeili] Successfully created index: ${indexName}`);
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
+ }
3270
3294
  }
3271
3295
  catch (createError) {
3272
- // Index might have been created by another instance
3273
- logger.debug(`[mongoMeili] Index ${indexName} may already exist:`, createError);
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
+ }
3274
3302
  }
3275
3303
  }
3276
3304
  else {
3277
3305
  logger.error(`[mongoMeili] Error checking index ${indexName}:`, error);
3278
3306
  }
3279
3307
  }
3280
- // Configure index settings to make 'user' field filterable
3281
3308
  try {
3282
3309
  await index.updateSettings({
3283
3310
  filterableAttributes: ['user'],