Concat plugin to app (#1799)

This commit is contained in:
Archer
2024-06-19 14:38:21 +08:00
committed by GitHub
parent b17d14bb7d
commit 565bfc8486
220 changed files with 5018 additions and 4667 deletions

View File

@@ -1,6 +1,5 @@
import { getTeamPlanStatus, getTeamStandPlan } from '../../support/wallet/sub/utils';
import { MongoApp } from '../../core/app/schema';
import { MongoPlugin } from '../../core/plugin/schema';
import { MongoDataset } from '../../core/dataset/schema';
import { DatasetTypeEnum } from '@fastgpt/global/core/dataset/constants';
import { TeamErrEnum } from '@fastgpt/global/common/error/code/team';
@@ -64,26 +63,19 @@ export const checkTeamDatasetLimit = async (teamId: string) => {
return Promise.reject(SystemErrEnum.communityVersionNumLimit);
}
};
export const checkTeamAppLimit = async (teamId: string) => {
export const checkTeamAppLimit = async (teamId: string, amount = 1) => {
const [{ standardConstants }, appCount] = await Promise.all([
getTeamStandPlan({ teamId }),
MongoApp.count({ teamId, type: { $in: [AppTypeEnum.advanced, AppTypeEnum.simple] } })
MongoApp.count({
teamId,
type: { $in: [AppTypeEnum.simple, AppTypeEnum.workflow, AppTypeEnum.plugin] }
})
]);
if (standardConstants && appCount >= standardConstants.maxAppAmount) {
if (standardConstants && appCount + amount >= standardConstants.maxAppAmount) {
return Promise.reject(TeamErrEnum.appAmountNotEnough);
}
};
export const checkTeamPluginLimit = async (teamId: string) => {
const [{ standardConstants }, pluginCount] = await Promise.all([
getTeamStandPlan({ teamId }),
MongoPlugin.count({ teamId })
]);
if (standardConstants && pluginCount >= standardConstants.maxAppAmount) {
return Promise.reject(TeamErrEnum.pluginAmountNotEnough);
}
};
export const checkTeamReRankPermission = async (teamId: string) => {
const { standardConstants } = await getTeamStandPlan({