feat(data-schemas): add new Mongoose models for conversationTag, key, pluginAuth, preset, project, prompt, promptGroup, sharedLink, toolCall, and transaction

- Introduced new model files for conversationTag, key, pluginAuth, preset, project, prompt, promptGroup, sharedLink, toolCall, and transaction.
- Each model includes a function to create or return the respective Mongoose model using the provided instance and schema.
- Updated the centralized models index to include these new models for better organization and accessibility.
This commit is contained in:
Danny Avila 2025-05-30 13:42:49 -04:00
parent 20ad7d52f3
commit 90ac2b51cd
No known key found for this signature in database
GPG key ID: BF31EEB2C5CA0956
11 changed files with 108 additions and 0 deletions

View file

@ -0,0 +1,11 @@
import conversationTagSchema, { IConversationTag } from '~/schema/conversationTag';
/**
* Creates or returns the ConversationTag model using the provided mongoose instance and schema
*/
export function createConversationTagModel(mongoose: typeof import('mongoose')) {
return (
mongoose.models.ConversationTag ||
mongoose.model<IConversationTag>('ConversationTag', conversationTagSchema)
);
}

View file

@ -10,6 +10,16 @@ import { createActionModel } from './action';
import { createAssistantModel } from './assistant'; import { createAssistantModel } from './assistant';
import { createFileModel } from './file'; import { createFileModel } from './file';
import { createBannerModel } from './banner'; import { createBannerModel } from './banner';
import { createProjectModel } from './project';
import { createKeyModel } from './key';
import { createPluginAuthModel } from './pluginAuth';
import { createTransactionModel } from './transaction';
import { createPresetModel } from './preset';
import { createPromptModel } from './prompt';
import { createPromptGroupModel } from './promptGroup';
import { createConversationTagModel } from './conversationTag';
import { createSharedLinkModel } from './sharedLink';
import { createToolCallModel } from './toolCall';
/** /**
* Creates all database models for all collections * Creates all database models for all collections
@ -28,5 +38,15 @@ export function createModels(mongoose: typeof import('mongoose')) {
Assistant: createAssistantModel(mongoose), Assistant: createAssistantModel(mongoose),
File: createFileModel(mongoose), File: createFileModel(mongoose),
Banner: createBannerModel(mongoose), Banner: createBannerModel(mongoose),
Project: createProjectModel(mongoose),
Key: createKeyModel(mongoose),
PluginAuth: createPluginAuthModel(mongoose),
Transaction: createTransactionModel(mongoose),
Preset: createPresetModel(mongoose),
Prompt: createPromptModel(mongoose),
PromptGroup: createPromptGroupModel(mongoose),
ConversationTag: createConversationTagModel(mongoose),
SharedLink: createSharedLinkModel(mongoose),
ToolCall: createToolCallModel(mongoose),
}; };
} }

View file

@ -0,0 +1,8 @@
import keySchema, { IKey } from '~/schema/key';
/**
* Creates or returns the Key model using the provided mongoose instance and schema
*/
export function createKeyModel(mongoose: typeof import('mongoose')) {
return mongoose.models.Key || mongoose.model<IKey>('Key', keySchema);
}

View file

@ -0,0 +1,8 @@
import pluginAuthSchema, { IPluginAuth } from '~/schema/pluginAuth';
/**
* Creates or returns the PluginAuth model using the provided mongoose instance and schema
*/
export function createPluginAuthModel(mongoose: typeof import('mongoose')) {
return mongoose.models.PluginAuth || mongoose.model<IPluginAuth>('PluginAuth', pluginAuthSchema);
}

View file

@ -0,0 +1,8 @@
import presetSchema, { IPreset } from '~/schema/preset';
/**
* Creates or returns the Preset model using the provided mongoose instance and schema
*/
export function createPresetModel(mongoose: typeof import('mongoose')) {
return mongoose.models.Preset || mongoose.model<IPreset>('Preset', presetSchema);
}

View file

@ -0,0 +1,8 @@
import projectSchema, { IMongoProject } from '~/schema/project';
/**
* Creates or returns the Project model using the provided mongoose instance and schema
*/
export function createProjectModel(mongoose: typeof import('mongoose')) {
return mongoose.models.Project || mongoose.model<IMongoProject>('Project', projectSchema);
}

View file

@ -0,0 +1,8 @@
import promptSchema, { IPrompt } from '~/schema/prompt';
/**
* Creates or returns the Prompt model using the provided mongoose instance and schema
*/
export function createPromptModel(mongoose: typeof import('mongoose')) {
return mongoose.models.Prompt || mongoose.model<IPrompt>('Prompt', promptSchema);
}

View file

@ -0,0 +1,11 @@
import promptGroupSchema, { IPromptGroupDocument } from '~/schema/promptGroup';
/**
* Creates or returns the PromptGroup model using the provided mongoose instance and schema
*/
export function createPromptGroupModel(mongoose: typeof import('mongoose')) {
return (
mongoose.models.PromptGroup ||
mongoose.model<IPromptGroupDocument>('PromptGroup', promptGroupSchema)
);
}

View file

@ -0,0 +1,8 @@
import shareSchema, { ISharedLink } from '~/schema/share';
/**
* Creates or returns the SharedLink model using the provided mongoose instance and schema
*/
export function createSharedLinkModel(mongoose: typeof import('mongoose')) {
return mongoose.models.SharedLink || mongoose.model<ISharedLink>('SharedLink', shareSchema);
}

View file

@ -0,0 +1,8 @@
import toolCallSchema, { IToolCallData } from '~/schema/toolCall';
/**
* Creates or returns the ToolCall model using the provided mongoose instance and schema
*/
export function createToolCallModel(mongoose: typeof import('mongoose')) {
return mongoose.models.ToolCall || mongoose.model<IToolCallData>('ToolCall', toolCallSchema);
}

View file

@ -0,0 +1,10 @@
import transactionSchema, { ITransaction } from '~/schema/transaction';
/**
* Creates or returns the Transaction model using the provided mongoose instance and schema
*/
export function createTransactionModel(mongoose: typeof import('mongoose')) {
return (
mongoose.models.Transaction || mongoose.model<ITransaction>('Transaction', transactionSchema)
);
}