From 8106df1d7d01374ea20cc5f860f52fc7ba35d33b Mon Sep 17 00:00:00 2001 From: zxhlyh Date: Mon, 29 Sep 2025 20:53:23 +0800 Subject: [PATCH] fix: types --- .../workflow-app/components/workflow-children.tsx | 3 +-- .../components/workflow-onboarding-modal/index.tsx | 6 +++--- .../start-node-selection-panel.tsx | 6 +++--- .../workflow-app/hooks/use-auto-onboarding.ts | 8 ++++---- .../workflow/block-selector/all-tools.tsx | 10 +++++----- .../components/workflow/block-selector/blocks.tsx | 3 +-- .../workflow/block-selector/data-sources.tsx | 4 ++-- .../block-selector/market-place-plugin/list.tsx | 5 +++-- .../block-selector/rag-tool-suggestions.tsx | 5 +++-- .../workflow/block-selector/start-blocks.tsx | 4 ++-- .../workflow/block-selector/tool/action-item.tsx | 2 +- .../tool/tool-list-flat-view/list.tsx | 2 +- .../tool/tool-list-tree-view/item.tsx | 2 +- .../tool/tool-list-tree-view/list.tsx | 2 +- .../workflow/block-selector/tool/tool.tsx | 3 ++- .../components/workflow/block-selector/tools.tsx | 2 +- web/app/components/workflow/block-selector/types.ts | 12 +++++++----- web/app/components/workflow/custom-edge.tsx | 4 ++-- .../workflow/hooks/use-nodes-interactions.ts | 10 +++++----- .../nodes/_base/components/next-step/add.tsx | 4 ++-- .../nodes/_base/components/next-step/operator.tsx | 4 ++-- .../workflow/nodes/_base/components/node-handle.tsx | 10 +++++----- .../components/panel-operator/change-block.tsx | 4 ++-- .../workflow/nodes/data-source-empty/hooks.ts | 4 ++-- .../workflow/nodes/iteration/add-block.tsx | 4 ++-- .../components/workflow/nodes/loop/add-block.tsx | 4 ++-- .../components/workflow/nodes/loop/insert-block.tsx | 4 ++-- .../extract-parameter/import-from-tool.tsx | 6 ++++-- web/app/components/workflow/operator/add-block.tsx | 4 ++-- web/app/components/workflow/types.ts | 13 ++++--------- 30 files changed, 77 insertions(+), 77 deletions(-) diff --git a/web/app/components/workflow-app/components/workflow-children.tsx b/web/app/components/workflow-app/components/workflow-children.tsx index c58698702c..a7415e2f35 100644 --- a/web/app/components/workflow-app/components/workflow-children.tsx +++ b/web/app/components/workflow-app/components/workflow-children.tsx @@ -22,7 +22,6 @@ import dynamic from 'next/dynamic' import { BlockEnum } from '@/app/components/workflow/types' import type { PluginDefaultValue, - ToolDefaultValue, TriggerDefaultValue, } from '@/app/components/workflow/block-selector/types' import { useAutoOnboarding } from '../hooks/use-auto-onboarding' @@ -96,7 +95,7 @@ const WorkflowChildren = () => { handleOnboardingClose() }, [handleOnboardingClose]) - const handleSelectStartNode = useCallback((nodeType: BlockEnum, toolConfig?: ToolDefaultValue | TriggerDefaultValue | PluginDefaultValue) => { + const handleSelectStartNode = useCallback((nodeType: BlockEnum, toolConfig?: PluginDefaultValue) => { const nodeDefault = availableNodesMetaData.nodesMap?.[nodeType] if (!nodeDefault?.defaultValue) return diff --git a/web/app/components/workflow-app/components/workflow-onboarding-modal/index.tsx b/web/app/components/workflow-app/components/workflow-onboarding-modal/index.tsx index 3a1c352b4e..7e8c76d67a 100644 --- a/web/app/components/workflow-app/components/workflow-onboarding-modal/index.tsx +++ b/web/app/components/workflow-app/components/workflow-onboarding-modal/index.tsx @@ -6,7 +6,7 @@ import { } from 'react' import { useTranslation } from 'react-i18next' import { BlockEnum } from '@/app/components/workflow/types' -import type { ToolDefaultValue } from '@/app/components/workflow/block-selector/types' +import type { PluginDefaultValue } from '@/app/components/workflow/block-selector/types' import Modal from '@/app/components/base/modal' import StartNodeSelectionPanel from './start-node-selection-panel' import { useDocLink } from '@/context/i18n' @@ -14,7 +14,7 @@ import { useDocLink } from '@/context/i18n' type WorkflowOnboardingModalProps = { isShow: boolean onClose: () => void - onSelectStartNode: (nodeType: BlockEnum, toolConfig?: ToolDefaultValue) => void + onSelectStartNode: (nodeType: BlockEnum, toolConfig?: PluginDefaultValue) => void } const WorkflowOnboardingModal: FC = ({ @@ -30,7 +30,7 @@ const WorkflowOnboardingModal: FC = ({ onClose() // Close modal after selection }, [onSelectStartNode, onClose]) - const handleTriggerSelect = useCallback((nodeType: BlockEnum, toolConfig?: ToolDefaultValue) => { + const handleTriggerSelect = useCallback((nodeType: BlockEnum, toolConfig?: PluginDefaultValue) => { onSelectStartNode(nodeType, toolConfig) onClose() // Close modal after selection }, [onSelectStartNode, onClose]) diff --git a/web/app/components/workflow-app/components/workflow-onboarding-modal/start-node-selection-panel.tsx b/web/app/components/workflow-app/components/workflow-onboarding-modal/start-node-selection-panel.tsx index d39e888a85..de934a13b2 100644 --- a/web/app/components/workflow-app/components/workflow-onboarding-modal/start-node-selection-panel.tsx +++ b/web/app/components/workflow-app/components/workflow-onboarding-modal/start-node-selection-panel.tsx @@ -7,12 +7,12 @@ import NodeSelector from '@/app/components/workflow/block-selector' import { Home } from '@/app/components/base/icons/src/vender/workflow' import { TriggerAll } from '@/app/components/base/icons/src/vender/workflow' import { BlockEnum } from '@/app/components/workflow/types' -import type { ToolDefaultValue } from '@/app/components/workflow/block-selector/types' +import type { PluginDefaultValue } from '@/app/components/workflow/block-selector/types' import { TabsEnum } from '@/app/components/workflow/block-selector/types' type StartNodeSelectionPanelProps = { onSelectUserInput: () => void - onSelectTrigger: (nodeType: BlockEnum, toolConfig?: ToolDefaultValue) => void + onSelectTrigger: (nodeType: BlockEnum, toolConfig?: PluginDefaultValue) => void } const StartNodeSelectionPanel: FC = ({ @@ -26,7 +26,7 @@ const StartNodeSelectionPanel: FC = ({ setShowTriggerSelector(true) }, []) - const handleTriggerSelect = useCallback((nodeType: BlockEnum, toolConfig?: ToolDefaultValue) => { + const handleTriggerSelect = useCallback((nodeType: BlockEnum, toolConfig?: PluginDefaultValue) => { setShowTriggerSelector(false) onSelectTrigger(nodeType, toolConfig) }, [onSelectTrigger]) diff --git a/web/app/components/workflow-app/hooks/use-auto-onboarding.ts b/web/app/components/workflow-app/hooks/use-auto-onboarding.ts index 5a8a8ed571..bce2a5117b 100644 --- a/web/app/components/workflow-app/hooks/use-auto-onboarding.ts +++ b/web/app/components/workflow-app/hooks/use-auto-onboarding.ts @@ -28,15 +28,15 @@ export const useAutoOnboarding = () => { // Show onboarding only if canvas is completely empty and we haven't shown it before in this session if (isCompletelyEmpty && !hasShownOnboarding) { - setShowOnboarding(true) - setHasShownOnboarding(true) + setShowOnboarding?.(true) + setHasShownOnboarding?.(true) } }, [store, workflowStore]) const handleOnboardingClose = useCallback(() => { const { setShowOnboarding, setHasShownOnboarding } = workflowStore.getState() - setShowOnboarding(false) - setHasShownOnboarding(true) + setShowOnboarding?.(false) + setHasShownOnboarding?.(true) }, [workflowStore]) // Check on mount and when nodes change diff --git a/web/app/components/workflow/block-selector/all-tools.tsx b/web/app/components/workflow/block-selector/all-tools.tsx index 6a2e07a411..75b2f11c04 100644 --- a/web/app/components/workflow/block-selector/all-tools.tsx +++ b/web/app/components/workflow/block-selector/all-tools.tsx @@ -1,5 +1,6 @@ import type { Dispatch, + RefObject, SetStateAction, } from 'react' import { @@ -10,7 +11,6 @@ import { } from 'react' import type { BlockEnum, - OnSelectBlock, ToolWithProvider, } from '../types' import type { ToolDefaultValue, ToolValue } from './types' @@ -36,12 +36,12 @@ type AllToolsProps = { customTools: ToolWithProvider[] workflowTools: ToolWithProvider[] mcpTools: ToolWithProvider[] - onSelect: OnSelectBlock + onSelect: (type: BlockEnum, tool: ToolDefaultValue) => void canNotSelectMultiple?: boolean onSelectMultiple?: (type: BlockEnum, tools: ToolDefaultValue[]) => void selectedTools?: ToolValue[] canChooseMCPTool?: boolean - onTagsChange: Dispatch> + onTagsChange?: Dispatch> isInRAGPipeline?: boolean } @@ -147,7 +147,7 @@ const AllTools = ({ className='max-h-[464px] overflow-y-auto' onScroll={pluginRef.current?.handleScroll} > - {isShowRAGRecommendations && ( + {isShowRAGRecommendations && onTagsChange && ( } list={notInstalledPlugins} searchText={searchText} toolContentClassName={toolContentClassName} diff --git a/web/app/components/workflow/block-selector/blocks.tsx b/web/app/components/workflow/block-selector/blocks.tsx index c44c9f66ea..e7a3bb6937 100644 --- a/web/app/components/workflow/block-selector/blocks.tsx +++ b/web/app/components/workflow/block-selector/blocks.tsx @@ -11,13 +11,12 @@ import { BlockEnum } from '../types' import type { NodeDefault } from '../types' import { BLOCK_CLASSIFICATIONS } from './constants' import { useBlocks } from './hooks' -import type { ToolDefaultValue } from './types' import Tooltip from '@/app/components/base/tooltip' import Badge from '@/app/components/base/badge' type BlocksProps = { searchText: string - onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void + onSelect: (type: BlockEnum) => void availableBlocksTypes?: BlockEnum[] blocks?: NodeDefault[] } diff --git a/web/app/components/workflow/block-selector/data-sources.tsx b/web/app/components/workflow/block-selector/data-sources.tsx index 294c7c1c79..d07ac5dd3b 100644 --- a/web/app/components/workflow/block-selector/data-sources.tsx +++ b/web/app/components/workflow/block-selector/data-sources.tsx @@ -37,7 +37,7 @@ const DataSources = ({ const { t } = useTranslation() const pluginRef = useRef(null) const wrapElemRef = useRef(null) - const handleSelect = useCallback((_: any, toolDefaultValue: ToolDefaultValue) => { + const handleSelect = useCallback((_: BlockEnum, toolDefaultValue: ToolDefaultValue) => { let defaultValue: DataSourceDefaultValue = { plugin_id: toolDefaultValue?.provider_id, provider_type: toolDefaultValue?.provider_type, @@ -67,7 +67,7 @@ const DataSources = ({ , }) const stickyClassName = useMemo(() => { switch (scrollPosition) { diff --git a/web/app/components/workflow/block-selector/rag-tool-suggestions.tsx b/web/app/components/workflow/block-selector/rag-tool-suggestions.tsx index 075d2c4e3b..7d0772e539 100644 --- a/web/app/components/workflow/block-selector/rag-tool-suggestions.tsx +++ b/web/app/components/workflow/block-selector/rag-tool-suggestions.tsx @@ -1,9 +1,10 @@ import type { Dispatch, SetStateAction } from 'react' import React, { useCallback, useMemo } from 'react' import { Trans, useTranslation } from 'react-i18next' -import type { OnSelectBlock } from '../types' +import type { BlockEnum } from '../types' import Tools from './tools' import { ToolTypeEnum } from './types' +import type { ToolDefaultValue } from './types' import type { ViewType } from './view-type-select' import { RiMoreLine } from '@remixicon/react' import Loading from '@/app/components/base/loading' @@ -13,7 +14,7 @@ import { useRAGRecommendedPlugins } from '@/service/use-tools' type RAGToolSuggestionsProps = { viewType: ViewType - onSelect: OnSelectBlock + onSelect: (type: BlockEnum, tool: ToolDefaultValue) => void onTagsChange: Dispatch> } diff --git a/web/app/components/workflow/block-selector/start-blocks.tsx b/web/app/components/workflow/block-selector/start-blocks.tsx index 8d56f24a40..c9be37bc36 100644 --- a/web/app/components/workflow/block-selector/start-blocks.tsx +++ b/web/app/components/workflow/block-selector/start-blocks.tsx @@ -11,13 +11,13 @@ import type { BlockEnum, CommonNodeType } from '../types' import { BlockEnum as BlockEnumValues } from '../types' // import { useNodeMetaData } from '../hooks' import { START_BLOCKS } from './constants' -import type { ToolDefaultValue } from './types' +import type { TriggerDefaultValue } from './types' import Tooltip from '@/app/components/base/tooltip' import { useAvailableNodesMetaData } from '../../workflow-app/hooks' type StartBlocksProps = { searchText: string - onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void + onSelect: (type: BlockEnum, triggerDefaultValue?: TriggerDefaultValue) => void availableBlocksTypes?: BlockEnum[] onContentStateChange?: (hasContent: boolean) => void } diff --git a/web/app/components/workflow/block-selector/tool/action-item.tsx b/web/app/components/workflow/block-selector/tool/action-item.tsx index 1005758d43..e5aa46b807 100644 --- a/web/app/components/workflow/block-selector/tool/action-item.tsx +++ b/web/app/components/workflow/block-selector/tool/action-item.tsx @@ -16,7 +16,7 @@ type Props = { payload: Tool disabled?: boolean isAdded?: boolean - onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void + onSelect: (type: BlockEnum, tool: ToolDefaultValue) => void } const ToolItem: FC = ({ diff --git a/web/app/components/workflow/block-selector/tool/tool-list-flat-view/list.tsx b/web/app/components/workflow/block-selector/tool/tool-list-flat-view/list.tsx index ca462c082e..510d6f2f4b 100644 --- a/web/app/components/workflow/block-selector/tool/tool-list-flat-view/list.tsx +++ b/web/app/components/workflow/block-selector/tool/tool-list-flat-view/list.tsx @@ -13,7 +13,7 @@ type Props = { isShowLetterIndex: boolean indexBar: React.ReactNode hasSearchText: boolean - onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void + onSelect: (type: BlockEnum, tool: ToolDefaultValue) => void canNotSelectMultiple?: boolean onSelectMultiple?: (type: BlockEnum, tools: ToolDefaultValue[]) => void letters: string[] diff --git a/web/app/components/workflow/block-selector/tool/tool-list-tree-view/item.tsx b/web/app/components/workflow/block-selector/tool/tool-list-tree-view/item.tsx index b3f7aab4df..cb053fe1db 100644 --- a/web/app/components/workflow/block-selector/tool/tool-list-tree-view/item.tsx +++ b/web/app/components/workflow/block-selector/tool/tool-list-tree-view/item.tsx @@ -11,7 +11,7 @@ type Props = { groupName: string toolList: ToolWithProvider[] hasSearchText: boolean - onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void + onSelect: (type: BlockEnum, tool: ToolDefaultValue) => void canNotSelectMultiple?: boolean onSelectMultiple?: (type: BlockEnum, tools: ToolDefaultValue[]) => void selectedTools?: ToolValue[] diff --git a/web/app/components/workflow/block-selector/tool/tool-list-tree-view/list.tsx b/web/app/components/workflow/block-selector/tool/tool-list-tree-view/list.tsx index d85d1ea682..162b816069 100644 --- a/web/app/components/workflow/block-selector/tool/tool-list-tree-view/list.tsx +++ b/web/app/components/workflow/block-selector/tool/tool-list-tree-view/list.tsx @@ -11,7 +11,7 @@ import { AGENT_GROUP_NAME, CUSTOM_GROUP_NAME, WORKFLOW_GROUP_NAME } from '../../ type Props = { payload: Record hasSearchText: boolean - onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void + onSelect: (type: BlockEnum, tool: ToolDefaultValue) => void canNotSelectMultiple?: boolean onSelectMultiple?: (type: BlockEnum, tools: ToolDefaultValue[]) => void selectedTools?: ToolValue[] diff --git a/web/app/components/workflow/block-selector/tool/tool.tsx b/web/app/components/workflow/block-selector/tool/tool.tsx index 6004bb119a..d75ab0c383 100644 --- a/web/app/components/workflow/block-selector/tool/tool.tsx +++ b/web/app/components/workflow/block-selector/tool/tool.tsx @@ -22,11 +22,12 @@ type Props = { payload: ToolWithProvider viewType: ViewType hasSearchText: boolean - onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void + onSelect: (type: BlockEnum, tool: ToolDefaultValue) => void canNotSelectMultiple?: boolean onSelectMultiple?: (type: BlockEnum, tools: ToolDefaultValue[]) => void selectedTools?: ToolValue[] canChooseMCPTool?: boolean + isShowLetterIndex?: boolean } const Tool: FC = ({ diff --git a/web/app/components/workflow/block-selector/tools.tsx b/web/app/components/workflow/block-selector/tools.tsx index feb34d2651..cf652788aa 100644 --- a/web/app/components/workflow/block-selector/tools.tsx +++ b/web/app/components/workflow/block-selector/tools.tsx @@ -16,7 +16,7 @@ import ToolListFlatView from './tool/tool-list-flat-view/list' import classNames from '@/utils/classnames' type ToolsProps = { - onSelect: (type: BlockEnum, tool?: ToolDefaultValue) => void + onSelect: (type: BlockEnum, tool: ToolDefaultValue) => void canNotSelectMultiple?: boolean onSelectMultiple?: (type: BlockEnum, tools: ToolDefaultValue[]) => void tools: ToolWithProvider[] diff --git a/web/app/components/workflow/block-selector/types.ts b/web/app/components/workflow/block-selector/types.ts index 1aa48e8f6d..6c9fcfc6de 100644 --- a/web/app/components/workflow/block-selector/types.ts +++ b/web/app/components/workflow/block-selector/types.ts @@ -25,13 +25,13 @@ export enum BlockClassificationEnum { Utilities = 'utilities', } -export type PluginDefaultValue = { +type PluginCommonDefaultValue = { provider_id: string provider_type: string provider_name: string } -export type TriggerDefaultValue = PluginDefaultValue & { +export type TriggerDefaultValue = PluginCommonDefaultValue & { trigger_name: string trigger_label: string trigger_description: string @@ -45,7 +45,7 @@ export type TriggerDefaultValue = PluginDefaultValue & { meta?: PluginMeta } -export type ToolDefaultValue = PluginDefaultValue & { +export type ToolDefaultValue = PluginCommonDefaultValue & { tool_name: string tool_label: string tool_description: string @@ -53,12 +53,12 @@ export type ToolDefaultValue = PluginDefaultValue & { is_team_authorization: boolean params: Record paramSchemas: Record[] - output_schema: Record + output_schema?: Record credential_id?: string meta?: PluginMeta } -export type DataSourceDefaultValue = { +export type DataSourceDefaultValue = Omit & { plugin_id: string provider_type: string provider_name: string @@ -68,6 +68,8 @@ export type DataSourceDefaultValue = { fileExtensions?: string[] } +export type PluginDefaultValue = ToolDefaultValue | DataSourceDefaultValue | TriggerDefaultValue + export type ToolValue = { provider_name: string provider_show_name?: string diff --git a/web/app/components/workflow/custom-edge.tsx b/web/app/components/workflow/custom-edge.tsx index c38b0ef47d..d4cbc9199d 100644 --- a/web/app/components/workflow/custom-edge.tsx +++ b/web/app/components/workflow/custom-edge.tsx @@ -83,11 +83,11 @@ const CustomEdge = ({ setOpen(v) }, []) - const handleInsert = useCallback((nodeType, toolDefaultValue) => { + const handleInsert = useCallback((nodeType, pluginDefaultValue) => { handleNodeAdd( { nodeType, - toolDefaultValue, + pluginDefaultValue, }, { prevNodeId: source, diff --git a/web/app/components/workflow/hooks/use-nodes-interactions.ts b/web/app/components/workflow/hooks/use-nodes-interactions.ts index 9352edbb2e..162e6d0b5c 100644 --- a/web/app/components/workflow/hooks/use-nodes-interactions.ts +++ b/web/app/components/workflow/hooks/use-nodes-interactions.ts @@ -16,7 +16,7 @@ import { useReactFlow, useStoreApi, } from 'reactflow' -import type { ToolDefaultValue } from '../block-selector/types' +import type { PluginDefaultValue } from '../block-selector/types' import type { Edge, Node, OnNodeAdd } from '../types' import { BlockEnum } from '../types' import { useWorkflowStore } from '../store' @@ -737,7 +737,7 @@ export const useNodesInteractions = () => { nodeType, sourceHandle = 'source', targetHandle = 'target', - toolDefaultValue, + pluginDefaultValue, }, { prevNodeId, prevNodeSourceHandle, nextNodeId, nextNodeTargetHandle }, ) => { @@ -758,7 +758,7 @@ export const useNodesInteractions = () => { nodesWithSameType.length > 0 ? `${defaultValue.title} ${nodesWithSameType.length + 1}` : defaultValue.title, - ...toolDefaultValue, + ...pluginDefaultValue, selected: true, _showAddVariablePopup: (nodeType === BlockEnum.VariableAssigner @@ -1288,7 +1288,7 @@ export const useNodesInteractions = () => { currentNodeId: string, nodeType: BlockEnum, sourceHandle: string, - toolDefaultValue?: ToolDefaultValue, + pluginDefaultValue?: PluginDefaultValue, ) => { if (getNodesReadOnly()) return @@ -1312,7 +1312,7 @@ export const useNodesInteractions = () => { nodesWithSameType.length > 0 ? `${defaultValue.title} ${nodesWithSameType.length + 1}` : defaultValue.title, - ...toolDefaultValue, + ...pluginDefaultValue, _connectedSourceHandleIds: [], _connectedTargetHandleIds: [], selected: currentNode.data.selected, diff --git a/web/app/components/workflow/nodes/_base/components/next-step/add.tsx b/web/app/components/workflow/nodes/_base/components/next-step/add.tsx index 601bc8ea75..3001274c31 100644 --- a/web/app/components/workflow/nodes/_base/components/next-step/add.tsx +++ b/web/app/components/workflow/nodes/_base/components/next-step/add.tsx @@ -39,11 +39,11 @@ const Add = ({ const { nodesReadOnly } = useNodesReadOnly() const { availableNextBlocks } = useAvailableBlocks(nodeData.type, nodeData.isInIteration || nodeData.isInLoop) - const handleSelect = useCallback((type, toolDefaultValue) => { + const handleSelect = useCallback((type, pluginDefaultValue) => { handleNodeAdd( { nodeType: type, - toolDefaultValue, + pluginDefaultValue, }, { prevNodeId: nodeId, diff --git a/web/app/components/workflow/nodes/_base/components/next-step/operator.tsx b/web/app/components/workflow/nodes/_base/components/next-step/operator.tsx index c54a63d8ad..7143e6fe43 100644 --- a/web/app/components/workflow/nodes/_base/components/next-step/operator.tsx +++ b/web/app/components/workflow/nodes/_base/components/next-step/operator.tsx @@ -38,8 +38,8 @@ const ChangeItem = ({ availableNextBlocks, } = useAvailableBlocks(data.type, data.isInIteration || data.isInLoop) - const handleSelect = useCallback((type, toolDefaultValue) => { - handleNodeChange(nodeId, type, sourceHandle, toolDefaultValue) + const handleSelect = useCallback((type, pluginDefaultValue) => { + handleNodeChange(nodeId, type, sourceHandle, pluginDefaultValue) }, [nodeId, sourceHandle, handleNodeChange]) const renderTrigger = useCallback(() => { diff --git a/web/app/components/workflow/nodes/_base/components/node-handle.tsx b/web/app/components/workflow/nodes/_base/components/node-handle.tsx index 01b6f83f2a..b727ad9775 100644 --- a/web/app/components/workflow/nodes/_base/components/node-handle.tsx +++ b/web/app/components/workflow/nodes/_base/components/node-handle.tsx @@ -16,7 +16,7 @@ import { } from '../../../types' import type { Node } from '../../../types' import BlockSelector from '../../../block-selector' -import type { ToolDefaultValue } from '../../../block-selector/types' +import type { PluginDefaultValue } from '../../../block-selector/types' import { useAvailableBlocks, useIsChatMode, @@ -57,11 +57,11 @@ export const NodeTargetHandle = memo(({ if (!connected) setOpen(v => !v) }, [connected]) - const handleSelect = useCallback((type: BlockEnum, toolDefaultValue?: ToolDefaultValue) => { + const handleSelect = useCallback((type: BlockEnum, pluginDefaultValue?: PluginDefaultValue) => { handleNodeAdd( { nodeType: type, - toolDefaultValue, + pluginDefaultValue, }, { nextNodeId: id, @@ -143,11 +143,11 @@ export const NodeSourceHandle = memo(({ e.stopPropagation() setOpen(v => !v) }, []) - const handleSelect = useCallback((type: BlockEnum, toolDefaultValue?: ToolDefaultValue) => { + const handleSelect = useCallback((type: BlockEnum, pluginDefaultValue?: PluginDefaultValue) => { handleNodeAdd( { nodeType: type, - toolDefaultValue, + pluginDefaultValue, }, { prevNodeId: id, diff --git a/web/app/components/workflow/nodes/_base/components/panel-operator/change-block.tsx b/web/app/components/workflow/nodes/_base/components/panel-operator/change-block.tsx index d2c90d47ab..cbbf10b63a 100644 --- a/web/app/components/workflow/nodes/_base/components/panel-operator/change-block.tsx +++ b/web/app/components/workflow/nodes/_base/components/panel-operator/change-block.tsx @@ -43,8 +43,8 @@ const ChangeBlock = ({ return availableNextBlocks }, [availablePrevBlocks, availableNextBlocks]) - const handleSelect = useCallback((type, toolDefaultValue) => { - handleNodeChange(nodeId, type, sourceHandle, toolDefaultValue) + const handleSelect = useCallback((type, pluginDefaultValue) => { + handleNodeChange(nodeId, type, sourceHandle, pluginDefaultValue) }, [handleNodeChange, nodeId, sourceHandle]) const renderTrigger = useCallback(() => { diff --git a/web/app/components/workflow/nodes/data-source-empty/hooks.ts b/web/app/components/workflow/nodes/data-source-empty/hooks.ts index e22e87485c..a17f0b2acb 100644 --- a/web/app/components/workflow/nodes/data-source-empty/hooks.ts +++ b/web/app/components/workflow/nodes/data-source-empty/hooks.ts @@ -11,7 +11,7 @@ export const useReplaceDataSourceNode = (id: string) => { const handleReplaceNode = useCallback(( type, - toolDefaultValue, + pluginDefaultValue, ) => { const { getNodes, @@ -28,7 +28,7 @@ export const useReplaceDataSourceNode = (id: string) => { const { newNode } = generateNewNode({ data: { ...(defaultValue as any), - ...toolDefaultValue, + ...pluginDefaultValue, }, position: { x: emptyNode.position.x, diff --git a/web/app/components/workflow/nodes/iteration/add-block.tsx b/web/app/components/workflow/nodes/iteration/add-block.tsx index 10aa8bb3e2..05d69caef4 100644 --- a/web/app/components/workflow/nodes/iteration/add-block.tsx +++ b/web/app/components/workflow/nodes/iteration/add-block.tsx @@ -33,11 +33,11 @@ const AddBlock = ({ const { handleNodeAdd } = useNodesInteractions() const { availableNextBlocks } = useAvailableBlocks(BlockEnum.Start, true) - const handleSelect = useCallback((type, toolDefaultValue) => { + const handleSelect = useCallback((type, pluginDefaultValue) => { handleNodeAdd( { nodeType: type, - toolDefaultValue, + pluginDefaultValue, }, { prevNodeId: iterationNodeData.start_node_id, diff --git a/web/app/components/workflow/nodes/loop/add-block.tsx b/web/app/components/workflow/nodes/loop/add-block.tsx index a9c1429269..9e2fa5b555 100644 --- a/web/app/components/workflow/nodes/loop/add-block.tsx +++ b/web/app/components/workflow/nodes/loop/add-block.tsx @@ -34,11 +34,11 @@ const AddBlock = ({ const { handleNodeAdd } = useNodesInteractions() const { availableNextBlocks } = useAvailableBlocks(BlockEnum.Start, true) - const handleSelect = useCallback((type, toolDefaultValue) => { + const handleSelect = useCallback((type, pluginDefaultValue) => { handleNodeAdd( { nodeType: type, - toolDefaultValue, + pluginDefaultValue, }, { prevNodeId: loopNodeData.start_node_id, diff --git a/web/app/components/workflow/nodes/loop/insert-block.tsx b/web/app/components/workflow/nodes/loop/insert-block.tsx index c4f4348d8e..66d51956ba 100644 --- a/web/app/components/workflow/nodes/loop/insert-block.tsx +++ b/web/app/components/workflow/nodes/loop/insert-block.tsx @@ -25,11 +25,11 @@ const InsertBlock = ({ const handleOpenChange = useCallback((v: boolean) => { setOpen(v) }, []) - const handleInsert = useCallback((nodeType, toolDefaultValue) => { + const handleInsert = useCallback((nodeType, pluginDefaultValue) => { handleNodeAdd( { nodeType, - toolDefaultValue, + pluginDefaultValue, }, { nextNodeId: startNodeId, diff --git a/web/app/components/workflow/nodes/parameter-extractor/components/extract-parameter/import-from-tool.tsx b/web/app/components/workflow/nodes/parameter-extractor/components/extract-parameter/import-from-tool.tsx index 952a831655..8cb5a4b877 100644 --- a/web/app/components/workflow/nodes/parameter-extractor/components/extract-parameter/import-from-tool.tsx +++ b/web/app/components/workflow/nodes/parameter-extractor/components/extract-parameter/import-from-tool.tsx @@ -9,7 +9,7 @@ import BlockSelector from '../../../../block-selector' import type { Param, ParamType } from '../../types' import cn from '@/utils/classnames' import { useStore } from '@/app/components/workflow/store' -import type { ToolDefaultValue } from '@/app/components/workflow/block-selector/types' +import type { PluginDefaultValue } from '@/app/components/workflow/block-selector/types' import type { ToolParameter } from '@/app/components/tools/types' import { CollectionType } from '@/app/components/tools/types' import type { BlockEnum } from '@/app/components/workflow/types' @@ -43,7 +43,9 @@ const ImportFromTool: FC = ({ const customTools = useStore(s => s.customTools) const workflowTools = useStore(s => s.workflowTools) - const handleSelectTool = useCallback((_type: BlockEnum, toolInfo?: ToolDefaultValue) => { + const handleSelectTool = useCallback((_type: BlockEnum, toolInfo?: PluginDefaultValue) => { + if (!toolInfo || !('tool_name' in toolInfo)) + return const { provider_id, provider_type, tool_name: tool_name } = toolInfo! const currentTools = (() => { switch (provider_type) { diff --git a/web/app/components/workflow/operator/add-block.tsx b/web/app/components/workflow/operator/add-block.tsx index f66e2b49b0..ce1326a78a 100644 --- a/web/app/components/workflow/operator/add-block.tsx +++ b/web/app/components/workflow/operator/add-block.tsx @@ -53,7 +53,7 @@ const AddBlock = ({ handlePaneContextmenuCancel() }, [handlePaneContextmenuCancel]) - const handleSelect = useCallback((type, toolDefaultValue) => { + const handleSelect = useCallback((type, pluginDefaultValue) => { const { getNodes, } = store.getState() @@ -67,7 +67,7 @@ const AddBlock = ({ data: { ...(defaultValue as any), title: nodesWithSameType.length > 0 ? `${defaultValue.title} ${nodesWithSameType.length + 1}` : defaultValue.title, - ...toolDefaultValue, + ...pluginDefaultValue, _isCandidate: true, }, position: { diff --git a/web/app/components/workflow/types.ts b/web/app/components/workflow/types.ts index f611e78344..1be4fcbac3 100644 --- a/web/app/components/workflow/types.ts +++ b/web/app/components/workflow/types.ts @@ -5,11 +5,7 @@ import type { XYPosition, } from 'reactflow' import type { Resolution, TransferMethod } from '@/types/app' -import type { - DataSourceDefaultValue, - PluginDefaultValue, - ToolDefaultValue, -} from '@/app/components/workflow/block-selector/types' +import type { PluginDefaultValue } from '@/app/components/workflow/block-selector/types' import type { VarType as VarKindType } from '@/app/components/workflow/nodes/tool/types' import type { FileResponse, NodeTracing, PanelProps } from '@/types/workflow' import type { Collection, Tool } from '@/app/components/tools/types' @@ -109,8 +105,7 @@ export type CommonNodeType = { credential_id?: string subscription_id?: string _dimmed?: boolean -} & T & Partial> - & Partial> +} & T & Partial export type CommonEdgeType = { _hovering?: boolean @@ -346,7 +341,7 @@ export type NodeDefault = { }) => Var[] } -export type OnSelectBlock = (type: BlockEnum, toolDefaultValue?: ToolDefaultValue | PluginDefaultValue | DataSourceDefaultValue) => void +export type OnSelectBlock = (type: BlockEnum, pluginDefaultValue?: PluginDefaultValue) => void export enum WorkflowRunningStatus { Listening = 'listening', @@ -378,7 +373,7 @@ export type OnNodeAdd = ( nodeType: BlockEnum sourceHandle?: string targetHandle?: string - toolDefaultValue?: ToolDefaultValue | DataSourceDefaultValue + pluginDefaultValue?: PluginDefaultValue }, oldNodesPayload: { prevNodeId?: string