diff --git a/packages/global/core/workflow/type/index.d.ts b/packages/global/core/workflow/type/index.d.ts index 4fb7611e0..aff900e44 100644 --- a/packages/global/core/workflow/type/index.d.ts +++ b/packages/global/core/workflow/type/index.d.ts @@ -77,8 +77,6 @@ export type SystemPluginTemplateItemType = WorkflowTemplateType & { description: string; value?: any; }[]; - - workflow: WorkflowTemplateBasicType; }; export type THelperLine = { diff --git a/packages/service/core/workflow/dispatch/index.ts b/packages/service/core/workflow/dispatch/index.ts index a8eea6c52..57aceb5f8 100644 --- a/packages/service/core/workflow/dispatch/index.ts +++ b/packages/service/core/workflow/dispatch/index.ts @@ -314,7 +314,7 @@ export async function dispatchWorkFlow(data: Props): Promise; }[]; // If there are no running nodes, the workflow is complete - if (!flat.some((item) => item.runStatus === 'run')) return; + if (flat.length === 0) return; // Update the node output at the end of the run and get the next nodes const nextNodes = flat.map((item) => nodeOutput(item.node, item.result)).flat(); diff --git a/packages/service/support/permission/app/auth.ts b/packages/service/support/permission/app/auth.ts index d4426ced7..5ba1a8518 100644 --- a/packages/service/support/permission/app/auth.ts +++ b/packages/service/support/permission/app/auth.ts @@ -52,6 +52,11 @@ export const authAppByTmbId = async ({ if (!app) { return Promise.reject(AppErrEnum.unExist); } + + if (String(app.teamId) !== teamId) { + return Promise.reject(AppErrEnum.unAuthApp); + } + const isOwner = tmbPer.isOwner || String(app.tmbId) === String(tmbId); const { Per, defaultPermission } = await (async () => { diff --git a/packages/service/support/permission/auth/openapi.ts b/packages/service/support/permission/auth/openapi.ts index c24d2e964..f5121f358 100644 --- a/packages/service/support/permission/auth/openapi.ts +++ b/packages/service/support/permission/auth/openapi.ts @@ -28,6 +28,10 @@ export async function authOpenApiKeyCrud({ return Promise.reject(OpenApiErrEnum.unExist); } + if (String(openapi.teamId) !== teamId) { + return Promise.reject(OpenApiErrEnum.unAuth); + } + if (!!openapi.appId) { // if is not global openapi, then auth app const { app } = await authAppByTmbId({ appId: openapi.appId!, tmbId, per }); diff --git a/packages/service/support/permission/dataset/auth.ts b/packages/service/support/permission/dataset/auth.ts index 7549a8db9..77b532c4f 100644 --- a/packages/service/support/permission/dataset/auth.ts +++ b/packages/service/support/permission/dataset/auth.ts @@ -43,6 +43,11 @@ export const authDatasetByTmbId = async ({ if (!dataset) { return Promise.reject(DatasetErrEnum.unExist); } + + if (String(dataset.teamId) !== teamId) { + return Promise.reject(DatasetErrEnum.unAuthDataset); + } + const isOwner = tmbPer.isOwner || String(dataset.tmbId) === String(tmbId); // get dataset permission or inherit permission from parent folder. diff --git a/packages/service/support/permission/publish/authLink.ts b/packages/service/support/permission/publish/authLink.ts index 0d306a31c..551437135 100644 --- a/packages/service/support/permission/publish/authLink.ts +++ b/packages/service/support/permission/publish/authLink.ts @@ -29,10 +29,14 @@ export async function authOutLinkCrud({ return Promise.reject(OutLinkErrEnum.unExist); } + if (String(outLink.teamId) !== teamId) { + return Promise.reject(OutLinkErrEnum.unAuthLink); + } + const { app } = await authAppByTmbId({ tmbId, appId: outLink.appId, - per: per + per }); return { diff --git a/projects/app/src/components/support/user/team/TeamManageModal/context.tsx b/projects/app/src/components/support/user/team/TeamManageModal/context.tsx index 31362fcf4..b179b7cb2 100644 --- a/projects/app/src/components/support/user/team/TeamManageModal/context.tsx +++ b/projects/app/src/components/support/user/team/TeamManageModal/context.tsx @@ -71,7 +71,7 @@ export const TeamModalContextProvider = ({ children }: { children: ReactNode }) } = useRequest2( () => { if (!userInfo?.team?.teamId) return Promise.resolve([]); - return loadAndGetTeamMembers(); + return loadAndGetTeamMembers(true); }, { manual: false, diff --git a/projects/app/src/pages/api/v1/chat/completions.ts b/projects/app/src/pages/api/v1/chat/completions.ts index 434b75a6f..a5b2df4ba 100644 --- a/projects/app/src/pages/api/v1/chat/completions.ts +++ b/projects/app/src/pages/api/v1/chat/completions.ts @@ -244,9 +244,10 @@ async function handler(req: NextApiRequest, res: NextApiResponse) { // Get runtimeNodes let runtimeNodes = storeNodes2RuntimeNodes(nodes, getWorkflowEntryNodeIds(nodes, newHistories)); if (isPlugin) { - // Rewrite plugin run params variables - variables = removePluginInputVariables(variables, runtimeNodes); + // Assign values to runtimeNodes using variables runtimeNodes = updatePluginInputByVariables(runtimeNodes, variables); + // Remove pluginInput fields from variables (they are not global variables) + variables = removePluginInputVariables(variables, runtimeNodes); } runtimeNodes = rewriteNodeOutputByHistories(newHistories, runtimeNodes); diff --git a/projects/app/src/pages/app/list/components/List.tsx b/projects/app/src/pages/app/list/components/List.tsx index 61e14cec0..9f80e305b 100644 --- a/projects/app/src/pages/app/list/components/List.tsx +++ b/projects/app/src/pages/app/list/components/List.tsx @@ -247,7 +247,7 @@ const ListItem = () => { {formatTimeToChatTime(app.updateTime)} )} - {app.permission.hasManagePer && ( + {app.permission.hasWritePer && ( { } ] : []), - { - children: [ - { - icon: 'edit', - label: t('common:dataset.Edit Info'), - onClick: () => { - if (app.type === AppTypeEnum.httpPlugin) { - setEditHttpPlugin({ - id: app._id, - name: app.name, - avatar: app.avatar, - intro: app.intro, - pluginData: app.pluginData - }); - } else { - setEditedApp({ - id: app._id, - avatar: app.avatar, - name: app.name, - intro: app.intro - }); - } - } - }, - ...(folderDetail?.type === AppTypeEnum.httpPlugin - ? [] - : [ + ...(app.permission.hasManagePer + ? [ + { + children: [ { - icon: 'common/file/move', - label: t('common:common.folder.Move to'), - onClick: () => setMoveAppId(app._id) - } - ]), - ...(app.permission.hasManagePer - ? [ - { - icon: 'support/team/key', - label: t('common:permission.Permission'), - onClick: () => setEditPerAppIndex(index) - } + icon: 'edit', + label: t('common:dataset.Edit Info'), + onClick: () => { + if (app.type === AppTypeEnum.httpPlugin) { + setEditHttpPlugin({ + id: app._id, + name: app.name, + avatar: app.avatar, + intro: app.intro, + pluginData: app.pluginData + }); + } else { + setEditedApp({ + id: app._id, + avatar: app.avatar, + name: app.name, + intro: app.intro + }); + } + } + }, + ...(folderDetail?.type === AppTypeEnum.httpPlugin + ? [] + : [ + { + icon: 'common/file/move', + label: t('common:common.folder.Move to'), + onClick: () => setMoveAppId(app._id) + } + ]), + ...(app.permission.hasManagePer + ? [ + { + icon: 'support/team/key', + label: t('common:permission.Permission'), + onClick: () => setEditPerAppIndex(index) + } + ] + : []) ] - : []) - ] - }, + } + ] + : []), ...(AppFolderTypeList.includes(app.type) ? [] : [ @@ -347,7 +351,6 @@ const ListItem = () => { ] } ]), - ...(app.permission.isOwner ? [ { diff --git a/projects/app/src/pages/dataset/detail/components/Info.tsx b/projects/app/src/pages/dataset/detail/components/Info.tsx index 7cd49a79a..f786cb1d5 100644 --- a/projects/app/src/pages/dataset/detail/components/Info.tsx +++ b/projects/app/src/pages/dataset/detail/components/Info.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React, { useEffect, useState } from 'react'; import { useRouter } from 'next/router'; import { Box, Flex, Input } from '@chakra-ui/react'; import { delDatasetById } from '@/web/core/dataset/api'; @@ -50,7 +50,7 @@ const Info = ({ datasetId }: { datasetId: string }) => { DatasetPageContext, (v) => v.refetchDatasetTraining ); - const { setValue, register, handleSubmit, watch } = useForm({ + const { setValue, register, handleSubmit, watch, reset } = useForm({ defaultValues: datasetDetail }); @@ -147,6 +147,10 @@ const Info = ({ datasetId }: { datasetId: string }) => { errorToast: t('common:common.Update Failed') }); + useEffect(() => { + reset(datasetDetail); + }, [datasetDetail._id]); + return ( diff --git a/projects/app/src/web/common/hooks/useCopyData.tsx b/projects/app/src/web/common/hooks/useCopyData.tsx index 3dbcde2d9..de112a519 100644 --- a/projects/app/src/web/common/hooks/useCopyData.tsx +++ b/projects/app/src/web/common/hooks/useCopyData.tsx @@ -18,7 +18,7 @@ export const useCopyData = () => { duration = 1000 ) => { try { - if (hasHttps() && !isProduction && navigator.clipboard) { + if ((hasHttps() || !isProduction) && navigator.clipboard) { await navigator.clipboard.writeText(data); } else { throw new Error('');