mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-23 21:13:50 +00:00

* feat: plugin run (#1950) * feat: plugin run * fix * ui * fix * change user input type * fix * fix * temp * split out plugin chat * perf: chatbox * perf: chatbox * fix: plugin runtime (#2032) * fix: plugin runtime * fix * fix build * fix build * perf: chat send prompt * perf: chat log ux * perf: chatbox context and share page plugin runtime * perf: plugin run time config * fix: ts * feat: doc * perf: isPc check * perf: variable input render * feat: app search * fix: response box height * fix: phone ui * perf: lock * perf: plugin route * fix: chat (#2049) --------- Co-authored-by: heheer <71265218+newfish-cmyk@users.noreply.github.com>
121 lines
2.4 KiB
TypeScript
121 lines
2.4 KiB
TypeScript
import { AppTypeEnum } from '@fastgpt/global/core/app/constants';
|
|
import { Schema, getMongoModel } from '../../common/mongo';
|
|
import type { AppSchema as AppType } from '@fastgpt/global/core/app/type.d';
|
|
import {
|
|
TeamCollectionName,
|
|
TeamMemberCollectionName
|
|
} from '@fastgpt/global/support/user/team/constant';
|
|
import { AppDefaultPermissionVal } from '@fastgpt/global/support/permission/app/constant';
|
|
import { getPermissionSchema } from '@fastgpt/global/support/permission/utils';
|
|
|
|
export const AppCollectionName = 'apps';
|
|
|
|
export const chatConfigType = {
|
|
welcomeText: String,
|
|
variables: Array,
|
|
questionGuide: Boolean,
|
|
ttsConfig: Object,
|
|
whisperConfig: Object,
|
|
scheduledTriggerConfig: Object,
|
|
chatInputGuide: Object
|
|
};
|
|
|
|
// schema
|
|
const AppSchema = new Schema({
|
|
parentId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: AppCollectionName,
|
|
default: null
|
|
},
|
|
teamId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: TeamCollectionName,
|
|
required: true
|
|
},
|
|
tmbId: {
|
|
type: Schema.Types.ObjectId,
|
|
ref: TeamMemberCollectionName,
|
|
required: true
|
|
},
|
|
name: {
|
|
type: String,
|
|
required: true
|
|
},
|
|
type: {
|
|
type: String,
|
|
default: AppTypeEnum.workflow,
|
|
enum: Object.values(AppTypeEnum)
|
|
},
|
|
version: {
|
|
type: String,
|
|
enum: ['v1', 'v2']
|
|
},
|
|
avatar: {
|
|
type: String,
|
|
default: '/icon/logo.svg'
|
|
},
|
|
intro: {
|
|
type: String,
|
|
default: ''
|
|
},
|
|
|
|
updateTime: {
|
|
type: Date,
|
|
default: () => new Date()
|
|
},
|
|
|
|
// role and auth
|
|
teamTags: {
|
|
type: [String]
|
|
},
|
|
|
|
// save app(Not publish)
|
|
modules: {
|
|
type: Array,
|
|
default: []
|
|
},
|
|
edges: {
|
|
type: Array,
|
|
default: []
|
|
},
|
|
chatConfig: {
|
|
type: chatConfigType
|
|
},
|
|
// plugin config
|
|
pluginData: {
|
|
type: {
|
|
nodeVersion: String,
|
|
pluginUniId: String,
|
|
apiSchemaStr: String, // http plugin
|
|
customHeaders: String // http plugin
|
|
}
|
|
},
|
|
|
|
scheduledTriggerConfig: {
|
|
cronString: {
|
|
type: String
|
|
},
|
|
timezone: {
|
|
type: String
|
|
},
|
|
defaultPrompt: {
|
|
type: String
|
|
}
|
|
},
|
|
scheduledTriggerNextTime: {
|
|
type: Date
|
|
},
|
|
|
|
inited: {
|
|
type: Boolean
|
|
},
|
|
|
|
...getPermissionSchema(AppDefaultPermissionVal)
|
|
});
|
|
|
|
AppSchema.index({ teamId: 1, updateTime: -1 });
|
|
AppSchema.index({ teamId: 1, type: 1 });
|
|
AppSchema.index({ scheduledTriggerConfig: 1, intervalNextTime: -1 });
|
|
|
|
export const MongoApp = getMongoModel<AppType>(AppCollectionName, AppSchema);
|