diff --git a/packages/global/core/app/type.d.ts b/packages/global/core/app/type.d.ts index 9a2a92ca4..40876e55a 100644 --- a/packages/global/core/app/type.d.ts +++ b/packages/global/core/app/type.d.ts @@ -29,6 +29,7 @@ export type AppSchema = { name: string; avatar: string; intro: string; + templateId?: string; // Create by template updateTime: Date; @@ -46,16 +47,18 @@ export type AppSchema = { scheduledTriggerConfig?: AppScheduledTriggerConfigType | null; scheduledTriggerNextTime?: Date; - inited?: boolean; - teamTags: string[]; inheritPermission?: boolean; // if access the app by favourite or quick favourite?: boolean; quick?: boolean; - // abandon + /** @deprecated */ defaultPermission?: number; + /** @deprecated */ + inited?: boolean; + /** @deprecated */ + teamTags: string[]; }; export type AppListItemType = { diff --git a/packages/global/support/wallet/usage/type.d.ts b/packages/global/support/wallet/usage/type.d.ts index 5a9cd0199..08f820620 100644 --- a/packages/global/support/wallet/usage/type.d.ts +++ b/packages/global/support/wallet/usage/type.d.ts @@ -8,11 +8,12 @@ export type UsageSchemaType = { teamId: string; tmbId: string; appName: string; - appId?: string; - pluginId?: string; totalPoints: number; source: `${UsageSourceEnum}`; + appId?: string; + datasetId?: string; + // @deprecated list?: UsageItemType[]; }; diff --git a/packages/service/core/app/schema.ts b/packages/service/core/app/schema.ts index 2e805ff93..42659811f 100644 --- a/packages/service/core/app/schema.ts +++ b/packages/service/core/app/schema.ts @@ -60,18 +60,14 @@ const AppSchema = new Schema( type: String, default: '' }, + templateId: String, updateTime: { type: Date, default: () => new Date() }, - // role and auth - teamTags: { - type: [String] - }, - - // save app(Not publish) + // Workflow data modules: { type: Array, default: [] @@ -83,7 +79,8 @@ const AppSchema = new Schema( chatConfig: { type: chatConfigType }, - // plugin config + + // Tool config pluginData: { type: { nodeVersion: String, @@ -108,19 +105,21 @@ const AppSchema = new Schema( type: Date }, - inited: { - type: Boolean - }, inheritPermission: { type: Boolean, default: true }, + // Chat setting favourite: Boolean, quick: Boolean, - // abandoned - defaultPermission: Number + /** @deprecated */ + defaultPermission: Number, + inited: Boolean, + teamTags: { + type: [String] + } }, { minimize: false diff --git a/packages/service/support/wallet/usage/schema.ts b/packages/service/support/wallet/usage/schema.ts index 9cb8c727b..278a7b674 100644 --- a/packages/service/support/wallet/usage/schema.ts +++ b/packages/service/support/wallet/usage/schema.ts @@ -7,6 +7,8 @@ import { TeamMemberCollectionName } from '@fastgpt/global/support/user/team/constant'; import { UsageCollectionName, UsageItemCollectionName } from './constants'; +import { AppCollectionName } from '../../../core/app/schema'; +import { DatasetCollectionName } from '../../../core/dataset/schema'; const UsageSchema = new Schema( { @@ -25,31 +27,30 @@ const UsageSchema = new Schema( enum: Object.values(UsageSourceEnum), required: true }, + // usage name appName: { - // usage name type: String, default: '' }, + // total points totalPoints: { - // total points type: Number, required: true }, - appId: { - type: Schema.Types.ObjectId, - ref: 'apps', - required: false - }, - pluginId: { - type: Schema.Types.ObjectId, - ref: 'plugins', - required: false - }, time: { type: Date, default: () => new Date() }, + appId: { + type: Schema.Types.ObjectId, + ref: AppCollectionName + }, + datasetId: { + type: Schema.Types.ObjectId, + ref: DatasetCollectionName + }, + // @description It will not be used again in the future. list: { type: Array diff --git a/projects/app/src/pageComponents/app/detail/SimpleApp/components/ToolSelectModal.tsx b/projects/app/src/pageComponents/app/detail/SimpleApp/components/ToolSelectModal.tsx index 4d123f531..2fe3ebba5 100644 --- a/projects/app/src/pageComponents/app/detail/SimpleApp/components/ToolSelectModal.tsx +++ b/projects/app/src/pageComponents/app/detail/SimpleApp/components/ToolSelectModal.tsx @@ -484,7 +484,7 @@ const RenderList = React.memo(function RenderList({ _hover={{ color: 'primary.600' }} - onClick={() => router.push('/toolkit/tools')} + onClick={() => router.push('/plugin/tool')} gap={1} bottom={0} right={[3, 6]} diff --git a/projects/app/src/pages/api/core/app/create.ts b/projects/app/src/pages/api/core/app/create.ts index 8690b0844..b7e6de213 100644 --- a/projects/app/src/pages/api/core/app/create.ts +++ b/projects/app/src/pages/api/core/app/create.ts @@ -39,11 +39,14 @@ export type CreateAppBody = { modules: AppSchema['modules']; edges?: AppSchema['edges']; chatConfig?: AppSchema['chatConfig']; + + templateId?: string; utmParams?: ShortUrlParams; }; async function handler(req: ApiRequestProps) { - const { parentId, name, avatar, intro, type, modules, edges, chatConfig, utmParams } = req.body; + const { parentId, name, avatar, intro, type, modules, edges, chatConfig, templateId, utmParams } = + req.body; if (!name || !type || !Array.isArray(modules)) { return Promise.reject(CommonErrEnum.inheritPermissionError); @@ -122,6 +125,7 @@ export const onCreateApp = async ({ pluginData, username, userAvatar, + templateId, session }: { parentId?: ParentIdType; @@ -137,6 +141,7 @@ export const onCreateApp = async ({ pluginData?: AppSchema['pluginData']; username?: string; userAvatar?: string; + templateId?: string; session?: ClientSession; }) => { const create = async (session: ClientSession) => { @@ -154,7 +159,8 @@ export const onCreateApp = async ({ chatConfig, type, version: 'v2', - pluginData + pluginData, + templateId } ], { session, ordered: true } diff --git a/projects/app/src/pages/dashboard/templateMarket/index.tsx b/projects/app/src/pages/dashboard/templateMarket/index.tsx index bfac0e18e..d3098cfa0 100644 --- a/projects/app/src/pages/dashboard/templateMarket/index.tsx +++ b/projects/app/src/pages/dashboard/templateMarket/index.tsx @@ -74,7 +74,8 @@ const TemplateMarket = ({ type: template.type as AppTypeEnum, modules: templateDetail.workflow.nodes || [], edges: templateDetail.workflow.edges || [], - chatConfig: templateDetail.workflow.chatConfig + chatConfig: templateDetail.workflow.chatConfig, + templateId: templateDetail.templateId }).then((res) => { webPushTrack.useAppTemplate({ id: res,