LibreChat/api/models/index.js
lia-by-librechat[bot] 42219ec8e9
🚜 feat: Support Native PostgreSQL Tool Favorites (#18032)
* 🚜 feat: Support Native PostgreSQL Tool Favorites

* fix: Guard PostgreSQL Reconciliation and Connection Leases

* fix: Scope Favorites Erasure Fences to Deletion Attempts

* fix: Preserve Account Erasure Ownership Until Cancellation Completes

* fix: Reject Unsupported PostgreSQL Command Flags Before Connecting

* fix: Keep Command Validation Compatible With the TypeScript Target

* fix: Keep Migration Previews Read-Only and Preserve Erasure Recovery Identity

* fix: Fence Erasure Recovery Across Tenant and Ownership Changes

* fix: Isolate Migration Dependencies and Keep Mongo Scans Outside Transactions

* fix: Inject PostgreSQL Backend Factories at Composition Roots

* ci: Shard Complete Mutation Work Without Relaxing the Aggregate Gate

---------

Co-authored-by: Lia <lia@librechat.ai>
2026-11-11 12:07:07 -05:00

51 lines
1.4 KiB
JavaScript

const mongoose = require('mongoose');
const {
createMethods,
createToolFavoriteMethods,
createPostgresFavoriteBackend,
} = require('@librechat/data-schemas');
const {
matchModelName,
findMatchingPattern,
isDeploymentSkillId,
createMessageBudgetReader,
createFavoriteRuntime,
getPersistenceConfig,
createChannelStorageConfigReader,
} = require('@librechat/api');
const getLogStores = require('~/cache/getLogStores');
const messageBudget = createMessageBudgetReader();
const channelStorageConfig = createChannelStorageConfigReader();
const favorites = createFavoriteRuntime(
createToolFavoriteMethods(mongoose),
process.env,
createPostgresFavoriteBackend,
);
const methods = createMethods(mongoose, {
toolFavorites: favorites.methods,
matchModelName,
findMatchingPattern,
isExternalSkillId: isDeploymentSkillId,
getCache: getLogStores,
getChannelStorageConfig: channelStorageConfig.getConfig,
getMCPAppMessageBudget: messageBudget.getBudget,
});
const seedDatabase = async () => {
await methods.initializeRoles();
await methods.seedDefaultRoles();
await methods.ensureDefaultCategories();
await methods.seedSystemGrants();
};
module.exports = {
...methods,
initializeFavorites: (config) => favorites.initialize(getPersistenceConfig(config)),
closeFavorites: favorites.close,
initializeMessageBudget: messageBudget.initialize,
initializeChannelStorageConfig: channelStorageConfig.initialize,
seedDatabase,
};