Fix type-check error (#27051)

This commit is contained in:
GuanMu 2025-10-18 12:03:40 +08:00 committed by GitHub
parent 830f891a74
commit 1a37989769
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
8 changed files with 27 additions and 18 deletions

View File

@ -16,7 +16,7 @@ import {
useReactFlow, useReactFlow,
useStoreApi, useStoreApi,
} from 'reactflow' } 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 type { Edge, Node, OnNodeAdd } from '../types'
import { BlockEnum } from '../types' import { BlockEnum } from '../types'
import { useWorkflowStore } from '../store' import { useWorkflowStore } from '../store'
@ -1286,7 +1286,7 @@ export const useNodesInteractions = () => {
currentNodeId: string, currentNodeId: string,
nodeType: BlockEnum, nodeType: BlockEnum,
sourceHandle: string, sourceHandle: string,
toolDefaultValue?: ToolDefaultValue, toolDefaultValue?: ToolDefaultValue | DataSourceDefaultValue,
) => { ) => {
if (getNodesReadOnly()) return if (getNodesReadOnly()) return

View File

@ -28,7 +28,6 @@ const getIcon = (type: InputVarType) => {
[InputVarType.jsonObject]: RiBracesLine, [InputVarType.jsonObject]: RiBracesLine,
[InputVarType.singleFile]: RiFileList2Line, [InputVarType.singleFile]: RiFileList2Line,
[InputVarType.multiFiles]: RiFileCopy2Line, [InputVarType.multiFiles]: RiFileCopy2Line,
[InputVarType.checkbox]: RiCheckboxLine,
} as any)[type] || RiTextSnippet } as any)[type] || RiTextSnippet
} }

View File

@ -16,7 +16,7 @@ import {
} from '../../../types' } from '../../../types'
import type { Node } from '../../../types' import type { Node } from '../../../types'
import BlockSelector from '../../../block-selector' import BlockSelector from '../../../block-selector'
import type { ToolDefaultValue } from '../../../block-selector/types' import type { DataSourceDefaultValue, ToolDefaultValue } from '../../../block-selector/types'
import { import {
useAvailableBlocks, useAvailableBlocks,
useIsChatMode, useIsChatMode,
@ -57,7 +57,7 @@ export const NodeTargetHandle = memo(({
if (!connected) if (!connected)
setOpen(v => !v) setOpen(v => !v)
}, [connected]) }, [connected])
const handleSelect = useCallback((type: BlockEnum, toolDefaultValue?: ToolDefaultValue) => { const handleSelect = useCallback((type: BlockEnum, toolDefaultValue?: ToolDefaultValue | DataSourceDefaultValue) => {
handleNodeAdd( handleNodeAdd(
{ {
nodeType: type, nodeType: type,
@ -140,7 +140,7 @@ export const NodeSourceHandle = memo(({
e.stopPropagation() e.stopPropagation()
setOpen(v => !v) setOpen(v => !v)
}, []) }, [])
const handleSelect = useCallback((type: BlockEnum, toolDefaultValue?: ToolDefaultValue) => { const handleSelect = useCallback((type: BlockEnum, toolDefaultValue?: ToolDefaultValue | DataSourceDefaultValue) => {
handleNodeAdd( handleNodeAdd(
{ {
nodeType: type, nodeType: type,

View File

@ -42,17 +42,17 @@ export const useVarColor = (variables: string[], isExceptionVariable?: boolean,
return 'text-util-colors-teal-teal-700' return 'text-util-colors-teal-teal-700'
return 'text-text-accent' return 'text-text-accent'
}, [variables, isExceptionVariable]) }, [variables, isExceptionVariable, variableCategory])
} }
export const useVarName = (variables: string[], notShowFullPath?: boolean) => { export const useVarName = (variables: string[], notShowFullPath?: boolean) => {
let variableFullPathName = variables.slice(1).join('.')
if (isRagVariableVar(variables))
variableFullPathName = variables.slice(2).join('.')
const variablesLength = variables.length
const varName = useMemo(() => { const varName = useMemo(() => {
let variableFullPathName = variables.slice(1).join('.')
if (isRagVariableVar(variables))
variableFullPathName = variables.slice(2).join('.')
const variablesLength = variables.length
const isSystem = isSystemVar(variables) const isSystem = isSystemVar(variables)
const varName = notShowFullPath ? variables[variablesLength - 1] : variableFullPathName const varName = notShowFullPath ? variables[variablesLength - 1] : variableFullPathName
return `${isSystem ? 'sys.' : ''}${varName}` return `${isSystem ? 'sys.' : ''}${varName}`

View File

@ -48,8 +48,13 @@ import Tooltip from '@/app/components/base/tooltip'
import useInspectVarsCrud from '../../hooks/use-inspect-vars-crud' import useInspectVarsCrud from '../../hooks/use-inspect-vars-crud'
import { ToolTypeEnum } from '../../block-selector/types' import { ToolTypeEnum } from '../../block-selector/types'
type NodeChildProps = {
id: string
data: NodeProps['data']
}
type BaseNodeProps = { type BaseNodeProps = {
children: ReactElement children: ReactElement<Partial<NodeChildProps>>
id: NodeProps['id'] id: NodeProps['id']
data: NodeProps['data'] data: NodeProps['data']
} }

View File

@ -11,6 +11,11 @@ export type OutputVar = Record<string, {
children: null // support nest in the future, children: null // support nest in the future,
}> }>
export type CodeDependency = {
name: string
version?: string
}
export type CodeNodeType = CommonNodeType & { export type CodeNodeType = CommonNodeType & {
variables: Variable[] variables: Variable[]
code_language: CodeLanguage code_language: CodeLanguage

View File

@ -16,7 +16,7 @@ import {
const useConfig = (id: string, payload: HttpNodeType) => { const useConfig = (id: string, payload: HttpNodeType) => {
const { nodesReadOnly: readOnly } = useNodesReadOnly() 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) const { inputs, setInputs } = useNodeCrud<HttpNodeType>(id, payload)

View File

@ -209,7 +209,7 @@ const ConditionItem = ({
onRemoveCondition?.(caseId, condition.id) onRemoveCondition?.(caseId, condition.id)
}, [caseId, condition, conditionId, isSubVariableKey, onRemoveCondition, onRemoveSubVariableCondition]) }, [caseId, condition, conditionId, isSubVariableKey, onRemoveCondition, onRemoveSubVariableCondition])
const { getMatchedSchemaType } = useMatchSchemaType() const { schemaTypeDefinitions } = useMatchSchemaType()
const handleVarChange = useCallback((valueSelector: ValueSelector, _varItem: Var) => { const handleVarChange = useCallback((valueSelector: ValueSelector, _varItem: Var) => {
const { const {
conversationVariables, conversationVariables,
@ -226,7 +226,7 @@ const ConditionItem = ({
workflowTools, workflowTools,
dataSourceList: dataSourceList ?? [], dataSourceList: dataSourceList ?? [],
}, },
getMatchedSchemaType, schemaTypeDefinitions,
}) })
const newCondition = produce(condition, (draft) => { const newCondition = produce(condition, (draft) => {
@ -241,7 +241,7 @@ const ConditionItem = ({
}) })
doUpdateCondition(newCondition) doUpdateCondition(newCondition)
setOpen(false) setOpen(false)
}, [condition, doUpdateCondition, availableNodes, isChatMode, setControlPromptEditorRerenderKey]) }, [condition, doUpdateCondition, availableNodes, isChatMode, setControlPromptEditorRerenderKey, schemaTypeDefinitions])
const showBooleanInput = useMemo(() => { const showBooleanInput = useMemo(() => {
if(condition.varType === VarType.boolean) if(condition.varType === VarType.boolean)