mirror of
https://github.com/danny-avila/LibreChat.git
synced 2026-02-23 02:44:08 +01:00
fix(data-schemas): resolve circular dependencies and add missing model registrations
- Break circular dependency by importing schemas directly from individual files - Add missing actionSchema and pluginAuthSchema imports - Add registerActionModel and registerPluginAuthModel functions - Fix typo in Transaction model registration (Trasaction → Transaction) - Include Action and PluginAuth models in registerModels return object
This commit is contained in:
parent
0cb5ed4063
commit
7caffda81a
1 changed files with 39 additions and 27 deletions
|
|
@ -1,27 +1,27 @@
|
||||||
import type { Mongoose } from 'mongoose';
|
import type { Mongoose } from 'mongoose';
|
||||||
import {
|
import { default as actionSchema } from '../schema/action';
|
||||||
agentSchema,
|
import { default as agentSchema } from '../schema/agent';
|
||||||
assistantSchema,
|
import { default as assistantSchema } from '../schema/assistant';
|
||||||
balanceSchema,
|
import { default as balanceSchema } from '../schema/balance';
|
||||||
categoriesSchema,
|
import { default as bannerSchema } from '../schema/banner';
|
||||||
messageSchema,
|
import { default as categoriesSchema } from '../schema/categories';
|
||||||
sessionSchema,
|
import { default as conversationTagSchema } from '../schema/conversationTag';
|
||||||
tokenSchema,
|
import { default as convoSchema } from '../schema/convo';
|
||||||
userSchema,
|
import { default as fileSchema } from '../schema/file';
|
||||||
conversationTagSchema,
|
import { default as keySchema } from '../schema/key';
|
||||||
convoSchema,
|
import { default as messageSchema } from '../schema/message';
|
||||||
fileSchema,
|
import { default as pluginAuthSchema } from '../schema/pluginAuth';
|
||||||
keySchema,
|
import { default as presetSchema } from '../schema/preset';
|
||||||
presetSchema,
|
import { default as projectSchema } from '../schema/project';
|
||||||
projectSchema,
|
import { default as promptSchema } from '../schema/prompt';
|
||||||
promptSchema,
|
import { default as promptGroupSchema } from '../schema/promptGroup';
|
||||||
roleSchema,
|
import { default as roleSchema } from '../schema/role';
|
||||||
shareSchema,
|
import { default as sessionSchema } from '../schema/session';
|
||||||
toolCallSchema,
|
import { default as shareSchema } from '../schema/share';
|
||||||
transactionSchema,
|
import { default as tokenSchema } from '../schema/token';
|
||||||
bannerSchema,
|
import { default as toolCallSchema } from '../schema/toolCall';
|
||||||
promptGroupSchema,
|
import { default as transactionSchema } from '../schema/transaction';
|
||||||
} from '..';
|
import { default as userSchema } from '../schema/user';
|
||||||
import mongoMeili from './plugins/mongoMeili';
|
import mongoMeili from './plugins/mongoMeili';
|
||||||
|
|
||||||
export const registerModels = (mongoose: Mongoose) => {
|
export const registerModels = (mongoose: Mongoose) => {
|
||||||
|
|
@ -29,6 +29,7 @@ export const registerModels = (mongoose: Mongoose) => {
|
||||||
const Session = registerSessionModel(mongoose);
|
const Session = registerSessionModel(mongoose);
|
||||||
const Token = registerTokenModel(mongoose);
|
const Token = registerTokenModel(mongoose);
|
||||||
const Message = registerMessageModel(mongoose);
|
const Message = registerMessageModel(mongoose);
|
||||||
|
const Action = registerActionModel(mongoose);
|
||||||
const Agent = registerAgentModel(mongoose);
|
const Agent = registerAgentModel(mongoose);
|
||||||
const Assistant = registerAssistantModel(mongoose);
|
const Assistant = registerAssistantModel(mongoose);
|
||||||
const Balance = registerBalanceModel(mongoose);
|
const Balance = registerBalanceModel(mongoose);
|
||||||
|
|
@ -37,6 +38,7 @@ export const registerModels = (mongoose: Mongoose) => {
|
||||||
const ConversationTag = registerConversationTagModel(mongoose);
|
const ConversationTag = registerConversationTagModel(mongoose);
|
||||||
const File = registerFileModel(mongoose);
|
const File = registerFileModel(mongoose);
|
||||||
const Key = registerKeyModel(mongoose);
|
const Key = registerKeyModel(mongoose);
|
||||||
|
const PluginAuth = registerPluginAuthModel(mongoose);
|
||||||
const Preset = registerPresetModel(mongoose);
|
const Preset = registerPresetModel(mongoose);
|
||||||
const Project = registerProjectModel(mongoose);
|
const Project = registerProjectModel(mongoose);
|
||||||
const Prompt = registerPromptModel(mongoose);
|
const Prompt = registerPromptModel(mongoose);
|
||||||
|
|
@ -52,6 +54,7 @@ export const registerModels = (mongoose: Mongoose) => {
|
||||||
Session,
|
Session,
|
||||||
Token,
|
Token,
|
||||||
Message,
|
Message,
|
||||||
|
Action,
|
||||||
Agent,
|
Agent,
|
||||||
Assistant,
|
Assistant,
|
||||||
Balance,
|
Balance,
|
||||||
|
|
@ -60,10 +63,11 @@ export const registerModels = (mongoose: Mongoose) => {
|
||||||
ConversationTag,
|
ConversationTag,
|
||||||
File,
|
File,
|
||||||
Key,
|
Key,
|
||||||
|
PluginAuth,
|
||||||
Preset,
|
Preset,
|
||||||
Project,
|
Project,
|
||||||
Prompt,
|
Prompt,
|
||||||
PromptGroup
|
PromptGroup,
|
||||||
Role,
|
Role,
|
||||||
SharedLink,
|
SharedLink,
|
||||||
ToolCall,
|
ToolCall,
|
||||||
|
|
@ -84,8 +88,11 @@ const registerTokenModel = (mongoose: Mongoose) => {
|
||||||
return mongoose.models.Token || mongoose.model('Token', tokenSchema);
|
return mongoose.models.Token || mongoose.model('Token', tokenSchema);
|
||||||
};
|
};
|
||||||
|
|
||||||
const registerMessageModel = (mongoose: Mongoose) => {
|
const registerActionModel = (mongoose: Mongoose) => {
|
||||||
|
return mongoose.models.Action || mongoose.model('Action', actionSchema);
|
||||||
|
};
|
||||||
|
|
||||||
|
const registerMessageModel = (mongoose: Mongoose) => {
|
||||||
if (process.env.MEILI_HOST && process.env.MEILI_MASTER_KEY) {
|
if (process.env.MEILI_HOST && process.env.MEILI_MASTER_KEY) {
|
||||||
messageSchema.plugin(mongoMeili, {
|
messageSchema.plugin(mongoMeili, {
|
||||||
host: process.env.MEILI_HOST,
|
host: process.env.MEILI_HOST,
|
||||||
|
|
@ -130,6 +137,11 @@ const registerFileModel = (mongoose: Mongoose) => {
|
||||||
const registerKeyModel = (mongoose: Mongoose) => {
|
const registerKeyModel = (mongoose: Mongoose) => {
|
||||||
return mongoose.models.Key || mongoose.model('Key', keySchema);
|
return mongoose.models.Key || mongoose.model('Key', keySchema);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const registerPluginAuthModel = (mongoose: Mongoose) => {
|
||||||
|
return mongoose.models.PluginAuth || mongoose.model('PluginAuth', pluginAuthSchema);
|
||||||
|
};
|
||||||
|
|
||||||
const registerPresetModel = (mongoose: Mongoose) => {
|
const registerPresetModel = (mongoose: Mongoose) => {
|
||||||
return mongoose.models.Preset || mongoose.model('Preset', presetSchema);
|
return mongoose.models.Preset || mongoose.model('Preset', presetSchema);
|
||||||
};
|
};
|
||||||
|
|
@ -156,7 +168,7 @@ const registerToolCallModel = (mongoose: Mongoose) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const registerTransactionModel = (mongoose: Mongoose) => {
|
const registerTransactionModel = (mongoose: Mongoose) => {
|
||||||
return mongoose.models.Transaction || mongoose.model('Trasaction', transactionSchema);
|
return mongoose.models.Transaction || mongoose.model('Transaction', transactionSchema);
|
||||||
};
|
};
|
||||||
const registerConversationModel = (mongoose: Mongoose) => {
|
const registerConversationModel = (mongoose: Mongoose) => {
|
||||||
if (process.env.MEILI_HOST && process.env.MEILI_MASTER_KEY) {
|
if (process.env.MEILI_HOST && process.env.MEILI_MASTER_KEY) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue