|
|
|
@ -16,6 +16,8 @@ import {
|
|
|
|
} from '@/service/use-workflow'
|
|
|
|
} from '@/service/use-workflow'
|
|
|
|
import { useCallback, useEffect, useState } from 'react'
|
|
|
|
import { useCallback, useEffect, useState } from 'react'
|
|
|
|
import { isConversationVar, isENV, isSystemVar } from '../nodes/_base/components/variable/utils'
|
|
|
|
import { isConversationVar, isENV, isSystemVar } from '../nodes/_base/components/variable/utils'
|
|
|
|
|
|
|
|
import produce from 'immer'
|
|
|
|
|
|
|
|
import type { Node } from '@/app/components/workflow/types'
|
|
|
|
|
|
|
|
|
|
|
|
const useInspectVarsCrud = () => {
|
|
|
|
const useInspectVarsCrud = () => {
|
|
|
|
const workflowStore = useWorkflowStore()
|
|
|
|
const workflowStore = useWorkflowStore()
|
|
|
|
@ -28,6 +30,7 @@ const useInspectVarsCrud = () => {
|
|
|
|
deleteAllInspectVars: deleteAllInspectVarsInStore,
|
|
|
|
deleteAllInspectVars: deleteAllInspectVarsInStore,
|
|
|
|
deleteNodeInspectVars: deleteNodeInspectVarsInStore,
|
|
|
|
deleteNodeInspectVars: deleteNodeInspectVarsInStore,
|
|
|
|
deleteInspectVar: deleteInspectVarInStore,
|
|
|
|
deleteInspectVar: deleteInspectVarInStore,
|
|
|
|
|
|
|
|
setNodesWithInspectVars,
|
|
|
|
} = workflowStore.getState()
|
|
|
|
} = workflowStore.getState()
|
|
|
|
|
|
|
|
|
|
|
|
const { data: conversationVars } = useConversationVarValues(appId)
|
|
|
|
const { data: conversationVars } = useConversationVarValues(appId)
|
|
|
|
@ -100,6 +103,28 @@ const useInspectVarsCrud = () => {
|
|
|
|
setNodeInspectVars(nodeId, vars)
|
|
|
|
setNodeInspectVars(nodeId, vars)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// after last run would call this
|
|
|
|
|
|
|
|
const appendNodeInspectVars = (nodeId: string, payload: VarInInspect[], allNodes: Node[]) => {
|
|
|
|
|
|
|
|
const nodes = produce(nodesWithInspectVars, (draft) => {
|
|
|
|
|
|
|
|
const nodeInfo = allNodes.find(node => node.id === nodeId)
|
|
|
|
|
|
|
|
if (nodeInfo) {
|
|
|
|
|
|
|
|
const index = draft.findIndex(node => node.nodeId === nodeId)
|
|
|
|
|
|
|
|
if (index === -1) {
|
|
|
|
|
|
|
|
draft.push({
|
|
|
|
|
|
|
|
nodeId,
|
|
|
|
|
|
|
|
nodeType: nodeInfo.data.type,
|
|
|
|
|
|
|
|
title: nodeInfo.data.title,
|
|
|
|
|
|
|
|
vars: payload,
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else {
|
|
|
|
|
|
|
|
draft[index].vars = payload
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
setNodesWithInspectVars(nodes)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const deleteInspectVar = async (nodeId: string, varId: string) => {
|
|
|
|
const deleteInspectVar = async (nodeId: string, varId: string) => {
|
|
|
|
await doDeleteInspectVar(varId)
|
|
|
|
await doDeleteInspectVar(varId)
|
|
|
|
deleteInspectVarInStore(nodeId, varId)
|
|
|
|
deleteInspectVarInStore(nodeId, varId)
|
|
|
|
@ -184,6 +209,7 @@ const useInspectVarsCrud = () => {
|
|
|
|
fetchInspectVarValue,
|
|
|
|
fetchInspectVarValue,
|
|
|
|
editInspectVarValue,
|
|
|
|
editInspectVarValue,
|
|
|
|
renameInspectVarName,
|
|
|
|
renameInspectVarName,
|
|
|
|
|
|
|
|
appendNodeInspectVars,
|
|
|
|
deleteInspectVar,
|
|
|
|
deleteInspectVar,
|
|
|
|
deleteNodeInspectorVars,
|
|
|
|
deleteNodeInspectorVars,
|
|
|
|
deleteAllInspectorVars,
|
|
|
|
deleteAllInspectorVars,
|
|
|
|
|