123456789101112131415161718192021222324252627282930313233343536 |
- import { BlockEnum } from '../../types'
- import type { NodeDefault } from '../../types'
- import type { AnswerNodeType } from './types'
- import { ALL_CHAT_AVAILABLE_BLOCKS, ALL_COMPLETION_AVAILABLE_BLOCKS } from '@/app/components/workflow/constants'
- const nodeDefault: NodeDefault<AnswerNodeType> = {
- defaultValue: {
- variables: [],
- answer: '',
- },
- getAvailablePrevNodes(isChatMode: boolean) {
- const nodes = isChatMode
- ? ALL_CHAT_AVAILABLE_BLOCKS
- : ALL_COMPLETION_AVAILABLE_BLOCKS.filter(type => type !== BlockEnum.End)
- return nodes
- },
- getAvailableNextNodes(isChatMode: boolean) {
- const nodes = isChatMode
- ? ALL_CHAT_AVAILABLE_BLOCKS
- : ALL_COMPLETION_AVAILABLE_BLOCKS
- return nodes
- },
- checkValid(payload: AnswerNodeType, t: any) {
- let errorMessages = ''
- const { answer } = payload
- if (!answer)
- errorMessages = t('workflow.errorMsg.fieldRequired', { field: t('workflow.nodes.answer.answer') })
- return {
- isValid: !errorMessages,
- errorMessage: errorMessages,
- }
- },
- }
- export default nodeDefault
|