mirror of
https://github.com/labring/FastGPT.git
synced 2025-07-24 13:53:50 +00:00
perf: load plugin groups code;perf: system plugin schema;fix: special variables replace;perf: retry cron app job (#3347)
* perf: load plugin groups code * perf: system plugin schema * feat: retry cron app job * fix: special variables replace
This commit is contained in:
@@ -4,3 +4,15 @@ export const delay = (ms: number) =>
|
||||
resolve('');
|
||||
}, ms);
|
||||
});
|
||||
|
||||
export const retryFn = async <T>(fn: () => Promise<T>, retryTimes = 3): Promise<T> => {
|
||||
try {
|
||||
return fn();
|
||||
} catch (error) {
|
||||
if (retryTimes > 0) {
|
||||
await delay(500);
|
||||
return retryFn(fn, retryTimes - 1);
|
||||
}
|
||||
return Promise.reject(error);
|
||||
}
|
||||
};
|
||||
|
3
packages/global/core/dataset/type.d.ts
vendored
3
packages/global/core/dataset/type.d.ts
vendored
@@ -34,6 +34,9 @@ export type DatasetSchemaType = {
|
||||
inheritPermission: boolean;
|
||||
apiServer?: APIFileServer;
|
||||
|
||||
syncSchedule?: { cronString: string; timezone: string };
|
||||
syncNextTime?: Date;
|
||||
|
||||
// abandon
|
||||
externalReadUrl?: string;
|
||||
defaultPermission?: number;
|
||||
|
@@ -321,7 +321,7 @@ export function replaceEditorVariable({
|
||||
})();
|
||||
|
||||
const regex = new RegExp(`\\{\\{\\$(${nodeId}\\.${id})\\$\\}\\}`, 'g');
|
||||
text = text.replace(regex, formatVal);
|
||||
text = text.replace(regex, () => formatVal);
|
||||
});
|
||||
|
||||
return text || '';
|
||||
|
@@ -10,8 +10,7 @@ const SystemPluginSchema = new Schema({
|
||||
required: true
|
||||
},
|
||||
isActive: {
|
||||
type: Boolean,
|
||||
required: true
|
||||
type: Boolean
|
||||
},
|
||||
inputConfig: {
|
||||
type: Array,
|
||||
|
2
packages/service/core/app/plugin/type.d.ts
vendored
2
packages/service/core/app/plugin/type.d.ts
vendored
@@ -13,7 +13,7 @@ export type SystemPluginConfigSchemaType = {
|
||||
hasTokenFee: boolean;
|
||||
isActive: boolean;
|
||||
pluginOrder: number;
|
||||
inputConfig: SystemPluginTemplateItemType['inputConfig'];
|
||||
inputConfig?: SystemPluginTemplateItemType['inputConfig'];
|
||||
|
||||
customConfig?: {
|
||||
name: string;
|
||||
|
@@ -121,6 +121,6 @@ const AppSchema = new Schema({
|
||||
|
||||
AppSchema.index({ teamId: 1, updateTime: -1 });
|
||||
AppSchema.index({ teamId: 1, type: 1 });
|
||||
AppSchema.index({ scheduledTriggerConfig: 1, intervalNextTime: -1 });
|
||||
AppSchema.index({ scheduledTriggerConfig: 1, scheduledTriggerNextTime: -1 });
|
||||
|
||||
export const MongoApp = getMongoModel<AppType>(AppCollectionName, AppSchema);
|
||||
|
@@ -91,6 +91,18 @@ const DatasetSchema = new Schema({
|
||||
type: Object
|
||||
},
|
||||
|
||||
syncSchedule: {
|
||||
cronString: {
|
||||
type: String
|
||||
},
|
||||
timezone: {
|
||||
type: String
|
||||
}
|
||||
},
|
||||
syncNextTime: {
|
||||
type: Date
|
||||
},
|
||||
|
||||
// abandoned
|
||||
externalReadUrl: {
|
||||
type: String
|
||||
@@ -100,6 +112,7 @@ const DatasetSchema = new Schema({
|
||||
|
||||
try {
|
||||
DatasetSchema.index({ teamId: 1 });
|
||||
DatasetSchema.index({ syncSchedule: 1, syncNextTime: -1 });
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
import { FlowNodeTemplateTypeEnum } from '@fastgpt/global/core/workflow/constants';
|
||||
import { i18nT } from '../../i18n/utils';
|
||||
import type { PluginGroupSchemaType, TGroupType } from '../../../service/core/app/plugin/type';
|
||||
|
||||
export const workflowNodeTemplateList = [
|
||||
{
|
||||
@@ -49,10 +50,7 @@ export const workflowNodeTemplateList = [
|
||||
}
|
||||
];
|
||||
|
||||
export const systemPluginTemplateList: {
|
||||
typeId: string;
|
||||
typeName: string;
|
||||
}[] = [
|
||||
export const systemPluginTemplateList: TGroupType[] = [
|
||||
{
|
||||
typeId: FlowNodeTemplateTypeEnum.tools,
|
||||
typeName: i18nT('common:navbar.Tools')
|
||||
@@ -74,7 +72,7 @@ export const systemPluginTemplateList: {
|
||||
typeName: i18nT('common:common.Other')
|
||||
}
|
||||
];
|
||||
export const defaultGroup = {
|
||||
export const defaultGroup: PluginGroupSchemaType = {
|
||||
groupId: 'systemPlugin',
|
||||
groupAvatar: 'common/navbar/pluginLight',
|
||||
groupName: i18nT('common:core.module.template.System Plugin'),
|
||||
|
Reference in New Issue
Block a user