diff --git a/packages/data-schemas/src/models/conversationTag.ts b/packages/data-schemas/src/models/conversationTag.ts new file mode 100644 index 0000000000..902915a6cc --- /dev/null +++ b/packages/data-schemas/src/models/conversationTag.ts @@ -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('ConversationTag', conversationTagSchema) + ); +} diff --git a/packages/data-schemas/src/models/index.ts b/packages/data-schemas/src/models/index.ts index dd4f1bd8e1..5be6a67d0e 100644 --- a/packages/data-schemas/src/models/index.ts +++ b/packages/data-schemas/src/models/index.ts @@ -10,6 +10,16 @@ import { createActionModel } from './action'; import { createAssistantModel } from './assistant'; import { createFileModel } from './file'; 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 @@ -28,5 +38,15 @@ export function createModels(mongoose: typeof import('mongoose')) { Assistant: createAssistantModel(mongoose), File: createFileModel(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), }; } diff --git a/packages/data-schemas/src/models/key.ts b/packages/data-schemas/src/models/key.ts new file mode 100644 index 0000000000..6e2ff70c92 --- /dev/null +++ b/packages/data-schemas/src/models/key.ts @@ -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('Key', keySchema); +} diff --git a/packages/data-schemas/src/models/pluginAuth.ts b/packages/data-schemas/src/models/pluginAuth.ts new file mode 100644 index 0000000000..cf466a145f --- /dev/null +++ b/packages/data-schemas/src/models/pluginAuth.ts @@ -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('PluginAuth', pluginAuthSchema); +} diff --git a/packages/data-schemas/src/models/preset.ts b/packages/data-schemas/src/models/preset.ts new file mode 100644 index 0000000000..c5b156e555 --- /dev/null +++ b/packages/data-schemas/src/models/preset.ts @@ -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('Preset', presetSchema); +} diff --git a/packages/data-schemas/src/models/project.ts b/packages/data-schemas/src/models/project.ts new file mode 100644 index 0000000000..c68f532bc3 --- /dev/null +++ b/packages/data-schemas/src/models/project.ts @@ -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('Project', projectSchema); +} diff --git a/packages/data-schemas/src/models/prompt.ts b/packages/data-schemas/src/models/prompt.ts new file mode 100644 index 0000000000..74cc4ea2da --- /dev/null +++ b/packages/data-schemas/src/models/prompt.ts @@ -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('Prompt', promptSchema); +} diff --git a/packages/data-schemas/src/models/promptGroup.ts b/packages/data-schemas/src/models/promptGroup.ts new file mode 100644 index 0000000000..41e3d2e347 --- /dev/null +++ b/packages/data-schemas/src/models/promptGroup.ts @@ -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('PromptGroup', promptGroupSchema) + ); +} diff --git a/packages/data-schemas/src/models/sharedLink.ts b/packages/data-schemas/src/models/sharedLink.ts new file mode 100644 index 0000000000..662f9aafc4 --- /dev/null +++ b/packages/data-schemas/src/models/sharedLink.ts @@ -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('SharedLink', shareSchema); +} diff --git a/packages/data-schemas/src/models/toolCall.ts b/packages/data-schemas/src/models/toolCall.ts new file mode 100644 index 0000000000..18292fd8e8 --- /dev/null +++ b/packages/data-schemas/src/models/toolCall.ts @@ -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('ToolCall', toolCallSchema); +} diff --git a/packages/data-schemas/src/models/transaction.ts b/packages/data-schemas/src/models/transaction.ts new file mode 100644 index 0000000000..52a33b86a7 --- /dev/null +++ b/packages/data-schemas/src/models/transaction.ts @@ -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('Transaction', transactionSchema) + ); +}