mirror of
https://github.com/labring/FastGPT.git
synced 2025-12-25 20:02:47 +00:00
Some checks failed
Document deploy / sync-images (push) Has been cancelled
Build FastGPT images in Personal warehouse / get-vars (push) Has been cancelled
Document deploy / generate-timestamp (push) Has been cancelled
Document deploy / build-images (map[domain:https://fastgpt.cn suffix:cn]) (push) Has been cancelled
Document deploy / build-images (map[domain:https://fastgpt.io suffix:io]) (push) Has been cancelled
Document deploy / update-images (map[deployment:fastgpt-docs domain:https://fastgpt.cn kube_config:KUBE_CONFIG_CN suffix:cn]) (push) Has been cancelled
Document deploy / update-images (map[deployment:fastgpt-docs domain:https://fastgpt.io kube_config:KUBE_CONFIG_IO suffix:io]) (push) Has been cancelled
Build FastGPT images in Personal warehouse / build-fastgpt-images (map[arch:amd64 runs-on:ubuntu-24.04]) (push) Has been cancelled
Build FastGPT images in Personal warehouse / build-fastgpt-images (map[arch:arm64 runs-on:ubuntu-24.04-arm]) (push) Has been cancelled
Build FastGPT images in Personal warehouse / release-fastgpt-images (push) Has been cancelled
* app delete queue * test * perf: del app queue * perf: log * perf: query * perf: retry del s3 * fix: ts * perf: add job * redis retry * perf: mq check * update log * perf: mq concurrency * perf: error check * perf: mq * perf: init model --------- Co-authored-by: archer <545436317@qq.com>
150 lines
2.9 KiB
TypeScript
150 lines
2.9 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';
|
||
|
||
export const AppCollectionName = 'apps';
|
||
|
||
export const chatConfigType = {
|
||
welcomeText: String,
|
||
variables: Array,
|
||
questionGuide: Object,
|
||
ttsConfig: Object,
|
||
whisperConfig: Object,
|
||
scheduledTriggerConfig: Object,
|
||
chatInputGuide: Object,
|
||
fileSelectConfig: Object,
|
||
instruction: String,
|
||
autoExecute: 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: ''
|
||
},
|
||
templateId: String,
|
||
|
||
updateTime: {
|
||
type: Date,
|
||
default: () => new Date()
|
||
},
|
||
|
||
// Workflow data
|
||
modules: {
|
||
type: Array,
|
||
default: []
|
||
},
|
||
edges: {
|
||
type: Array,
|
||
default: []
|
||
},
|
||
chatConfig: {
|
||
type: chatConfigType
|
||
},
|
||
|
||
// Tool 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
|
||
},
|
||
|
||
inheritPermission: {
|
||
type: Boolean,
|
||
default: true
|
||
},
|
||
|
||
// Chat setting
|
||
favourite: Boolean,
|
||
quick: Boolean,
|
||
|
||
/** @deprecated */
|
||
defaultPermission: Number,
|
||
inited: Boolean,
|
||
teamTags: {
|
||
type: [String]
|
||
},
|
||
|
||
// 软删除标记字段
|
||
deleteTime: {
|
||
type: Date,
|
||
default: null // null表示未删除,有值表示删除时间
|
||
}
|
||
},
|
||
{
|
||
minimize: false
|
||
}
|
||
);
|
||
|
||
AppSchema.index({ teamId: 1, updateTime: -1 });
|
||
AppSchema.index({ teamId: 1, type: 1 });
|
||
AppSchema.index(
|
||
{ scheduledTriggerConfig: 1, scheduledTriggerNextTime: -1 },
|
||
{
|
||
partialFilterExpression: {
|
||
scheduledTriggerConfig: { $exists: true }
|
||
}
|
||
}
|
||
);
|
||
// Admin count
|
||
AppSchema.index({ type: 1 });
|
||
AppSchema.index({ deleteTime: 1 });
|
||
|
||
export const MongoApp = getMongoModel<AppType>(AppCollectionName, AppSchema);
|