Commit 25c00cde by Theresa Committed by GitHub

Mcp db fix (#5096)

* fix: correct input schema property name in getTools method

* fix: refactor schema definitions for AppSchema and AppVersionSchema
parent 62605583
...@@ -22,102 +22,107 @@ export const chatConfigType = { ...@@ -22,102 +22,107 @@ export const chatConfigType = {
}; };
// schema // schema
const AppSchema = new Schema({ const AppSchema = new Schema(
parentId: { {
type: Schema.Types.ObjectId, parentId: {
ref: AppCollectionName, type: Schema.Types.ObjectId,
default: null ref: AppCollectionName,
}, default: null
teamId: { },
type: Schema.Types.ObjectId, teamId: {
ref: TeamCollectionName, type: Schema.Types.ObjectId,
required: true ref: TeamCollectionName,
}, required: true
tmbId: { },
type: Schema.Types.ObjectId, tmbId: {
ref: TeamMemberCollectionName, type: Schema.Types.ObjectId,
required: true ref: TeamMemberCollectionName,
}, required: true
name: { },
type: String, name: {
required: true type: String,
}, required: true
type: { },
type: String, type: {
default: AppTypeEnum.workflow, type: String,
enum: Object.values(AppTypeEnum) default: AppTypeEnum.workflow,
}, enum: Object.values(AppTypeEnum)
version: { },
type: String, version: {
enum: ['v1', 'v2'] type: String,
}, enum: ['v1', 'v2']
avatar: { },
type: String, avatar: {
default: '/icon/logo.svg' type: String,
}, default: '/icon/logo.svg'
intro: { },
type: String, intro: {
default: '' type: String,
}, default: ''
},
updateTime: { updateTime: {
type: Date, type: Date,
default: () => new Date() default: () => new Date()
}, },
// role and auth // role and auth
teamTags: { teamTags: {
type: [String] type: [String]
}, },
// save app(Not publish) // save app(Not publish)
modules: { modules: {
type: Array, type: Array,
default: [] default: []
}, },
edges: { edges: {
type: Array, type: Array,
default: [] default: []
}, },
chatConfig: { chatConfig: {
type: chatConfigType type: chatConfigType
}, },
// plugin config // plugin config
pluginData: { pluginData: {
type: { type: {
nodeVersion: String, nodeVersion: String,
pluginUniId: String, pluginUniId: String,
apiSchemaStr: String, // http plugin apiSchemaStr: String, // http plugin
customHeaders: String // http plugin customHeaders: String // http plugin
} }
}, },
scheduledTriggerConfig: { scheduledTriggerConfig: {
cronString: { cronString: {
type: String type: String
},
timezone: {
type: String
},
defaultPrompt: {
type: String
}
}, },
timezone: { scheduledTriggerNextTime: {
type: String type: Date
}, },
defaultPrompt: {
type: String
}
},
scheduledTriggerNextTime: {
type: Date
},
inited: { inited: {
type: Boolean type: Boolean
}, },
inheritPermission: { inheritPermission: {
type: Boolean, type: Boolean,
default: true default: true
}, },
// abandoned // abandoned
defaultPermission: Number defaultPermission: Number
}); },
{
minimize: false
}
);
AppSchema.index({ type: 1 }); AppSchema.index({ type: 1 });
AppSchema.index({ teamId: 1, updateTime: -1 }); AppSchema.index({ teamId: 1, updateTime: -1 });
......
...@@ -6,35 +6,40 @@ import { TeamMemberCollectionName } from '@fastgpt/global/support/user/team/cons ...@@ -6,35 +6,40 @@ import { TeamMemberCollectionName } from '@fastgpt/global/support/user/team/cons
export const AppVersionCollectionName = 'app_versions'; export const AppVersionCollectionName = 'app_versions';
const AppVersionSchema = new Schema({ const AppVersionSchema = new Schema(
tmbId: { {
type: String, tmbId: {
ref: TeamMemberCollectionName, type: String,
required: true ref: TeamMemberCollectionName,
required: true
},
appId: {
type: Schema.Types.ObjectId,
ref: AppVersionCollectionName,
required: true
},
time: {
type: Date,
default: () => new Date()
},
nodes: {
type: Array,
default: []
},
edges: {
type: Array,
default: []
},
chatConfig: {
type: chatConfigType
},
isPublish: Boolean,
versionName: String
}, },
appId: { {
type: Schema.Types.ObjectId, minimize: false
ref: AppVersionCollectionName, }
required: true );
},
time: {
type: Date,
default: () => new Date()
},
nodes: {
type: Array,
default: []
},
edges: {
type: Array,
default: []
},
chatConfig: {
type: chatConfigType
},
isPublish: Boolean,
versionName: String
});
try { try {
AppVersionSchema.index({ appId: 1, time: -1 }); AppVersionSchema.index({ appId: 1, time: -1 });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment