Skip to content

armgit / dify

Public Imported from GitHub
0

Build Agentic workflows, RAG pipelines, with rich AI model and tool support on one collaborative workspace. Deploy on cloud, VPC, or self-hosted, so teams move from prototype to production without rebuilding the stack.

Fix type-check error (#27051)

GuanMu1a379897697b
diff --git a/web/app/components/workflow/hooks/use-nodes-interactions.ts b/web/app/components/workflow/hooks/use-nodes-interactions.ts
index c721442d862..afd13a73fb1 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 { DataSourceDefaultValue, ToolDefaultValue } from '../block-selector/types'
import type { Edge, Node, OnNodeAdd } from '../types'
import { BlockEnum } from '../types'
import { useWorkflowStore } from '../store'
@@ -1286,7 +1286,7 @@ export const useNodesInteractions = () => {
currentNodeId: string,
nodeType: BlockEnum,
sourceHandle: string,
- toolDefaultValue?: ToolDefaultValue,
+ toolDefaultValue?: ToolDefaultValue | DataSourceDefaultValue,
) => {
if (getNodesReadOnly()) return
diff --git a/web/app/components/workflow/nodes/_base/components/input-var-type-icon.tsx b/web/app/components/workflow/nodes/_base/components/input-var-type-icon.tsx
index 566528b5c25..70fd1051b90 100644
--- a/web/app/components/workflow/nodes/_base/components/input-var-type-icon.tsx
+++ b/web/app/components/workflow/nodes/_base/components/input-var-type-icon.tsx
@@ -28,7 +28,6 @@ const getIcon = (type: InputVarType) => {
[InputVarType.jsonObject]: RiBracesLine,
[InputVarType.singleFile]: RiFileList2Line,
[InputVarType.multiFiles]: RiFileCopy2Line,
- [InputVarType.checkbox]: RiCheckboxLine,
} as any)[type] || RiTextSnippet
}
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 d1d79a0faa0..90968a45808 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 { DataSourceDefaultValue, ToolDefaultValue } from '../../../block-selector/types'
import {
useAvailableBlocks,
useIsChatMode,
@@ -57,7 +57,7 @@ export const NodeTargetHandle = memo(({
if (!connected)
setOpen(v => !v)
}, [connected])
- const handleSelect = useCallback((type: BlockEnum, toolDefaultValue?: ToolDefaultValue) => {
+ const handleSelect = useCallback((type: BlockEnum, toolDefaultValue?: ToolDefaultValue | DataSourceDefaultValue) => {
handleNodeAdd(
{
nodeType: type,
@@ -140,7 +140,7 @@ export const NodeSourceHandle = memo(({
e.stopPropagation()
setOpen(v => !v)
}, [])
- const handleSelect = useCallback((type: BlockEnum, toolDefaultValue?: ToolDefaultValue) => {
+ const handleSelect = useCallback((type: BlockEnum, toolDefaultValue?: ToolDefaultValue | DataSourceDefaultValue) => {
handleNodeAdd(
{
nodeType: type,
diff --git a/web/app/components/workflow/nodes/_base/components/variable/variable-label/hooks.ts b/web/app/components/workflow/nodes/_base/components/variable/variable-label/hooks.ts
index 19690edcbae..fef6d8c396d 100644
--- a/web/app/components/workflow/nodes/_base/components/variable/variable-label/hooks.ts
+++ b/web/app/components/workflow/nodes/_base/components/variable/variable-label/hooks.ts
@@ -42,17 +42,17 @@ export const useVarColor = (variables: string[], isExceptionVariable?: boolean,
return 'text-util-colors-teal-teal-700'
return 'text-text-accent'
- }, [variables, isExceptionVariable])
+ }, [variables, isExceptionVariable, variableCategory])
}
export const useVarName = (variables: string[], notShowFullPath?: boolean) => {
- let variableFullPathName = variables.slice(1).join('.')
+ const varName = useMemo(() => {
+ let variableFullPathName = variables.slice(1).join('.')
- if (isRagVariableVar(variables))
- variableFullPathName = variables.slice(2).join('.')
+ if (isRagVariableVar(variables))
+ variableFullPathName = variables.slice(2).join('.')
- const variablesLength = variables.length
- const varName = useMemo(() => {
+ const variablesLength = variables.length
const isSystem = isSystemVar(variables)
const varName = notShowFullPath ? variables[variablesLength - 1] : variableFullPathName
return `${isSystem ? 'sys.' : ''}${varName}`
diff --git a/web/app/components/workflow/nodes/_base/node.tsx b/web/app/components/workflow/nodes/_base/node.tsx
index 9fd9c3ce723..4725f86ad52 100644
--- a/web/app/components/workflow/nodes/_base/node.tsx
+++ b/web/app/components/workflow/nodes/_base/node.tsx
@@ -48,8 +48,13 @@ import Tooltip from '@/app/components/base/tooltip'
import useInspectVarsCrud from '../../hooks/use-inspect-vars-crud'
import { ToolTypeEnum } from '../../block-selector/types'
+type NodeChildProps = {
+ id: string
+ data: NodeProps['data']
+}
+
type BaseNodeProps = {
- children: ReactElement
+ children: ReactElement<Partial<NodeChildProps>>
id: NodeProps['id']
data: NodeProps['data']
}
diff --git a/web/app/components/workflow/nodes/code/types.ts b/web/app/components/workflow/nodes/code/types.ts
index 9c055f39699..265fd9d25d3 100644
--- a/web/app/components/workflow/nodes/code/types.ts
+++ b/web/app/components/workflow/nodes/code/types.ts
@@ -11,6 +11,11 @@ export type OutputVar = Record<string, {
children: null // support nest in the future,
}>
+export type CodeDependency = {
+ name: string
+ version?: string
+}
+
export type CodeNodeType = CommonNodeType & {
variables: Variable[]
code_language: CodeLanguage
diff --git a/web/app/components/workflow/nodes/http/use-config.ts b/web/app/components/workflow/nodes/http/use-config.ts
index 63d14794b25..761ce99b269 100644
--- a/web/app/components/workflow/nodes/http/use-config.ts
+++ b/web/app/components/workflow/nodes/http/use-config.ts
@@ -16,7 +16,7 @@ import {
const useConfig = (id: string, payload: HttpNodeType) => {
const { nodesReadOnly: readOnly } = useNodesReadOnly()
- const defaultConfig = useStore(s => s.nodesDefaultConfigs)[payload.type]
+ const defaultConfig = useStore(s => s.nodesDefaultConfigs?.[payload.type])
const { inputs, setInputs } = useNodeCrud<HttpNodeType>(id, payload)
diff --git a/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx b/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx
index 252c9a7d777..45973122e82 100644
--- a/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx
+++ b/web/app/components/workflow/nodes/if-else/components/condition-list/condition-item.tsx
@@ -209,7 +209,7 @@ const ConditionItem = ({
onRemoveCondition?.(caseId, condition.id)
}, [caseId, condition, conditionId, isSubVariableKey, onRemoveCondition, onRemoveSubVariableCondition])
- const { getMatchedSchemaType } = useMatchSchemaType()
+ const { schemaTypeDefinitions } = useMatchSchemaType()
const handleVarChange = useCallback((valueSelector: ValueSelector, _varItem: Var) => {
const {
conversationVariables,
@@ -226,7 +226,7 @@ const ConditionItem = ({
workflowTools,
dataSourceList: dataSourceList ?? [],
},
- getMatchedSchemaType,
+ schemaTypeDefinitions,
})
const newCondition = produce(condition, (draft) => {
@@ -241,7 +241,7 @@ const ConditionItem = ({
})
doUpdateCondition(newCondition)
setOpen(false)
- }, [condition, doUpdateCondition, availableNodes, isChatMode, setControlPromptEditorRerenderKey])
+ }, [condition, doUpdateCondition, availableNodes, isChatMode, setControlPromptEditorRerenderKey, schemaTypeDefinitions])
const showBooleanInput = useMemo(() => {
if(condition.varType === VarType.boolean)