2025-04-22 16:46:33 +08:00
|
|
|
import type { NodeDefault } from '../../types'
|
|
|
|
import type { DataSourceNodeType } from './types'
|
2025-04-25 11:32:17 +08:00
|
|
|
import { genNodeMetaData } from '@/app/components/workflow/utils'
|
|
|
|
import { BlockEnum } from '@/app/components/workflow/types'
|
2025-05-23 18:19:01 +08:00
|
|
|
import { OUTPUT_VARIABLES_MAP } from './constants'
|
2025-04-22 16:46:33 +08:00
|
|
|
|
2025-04-29 16:11:54 +08:00
|
|
|
const metaData = genNodeMetaData({
|
|
|
|
sort: -1,
|
|
|
|
type: BlockEnum.DataSource,
|
|
|
|
})
|
2025-04-22 16:46:33 +08:00
|
|
|
const nodeDefault: NodeDefault<DataSourceNodeType> = {
|
2025-04-29 16:11:54 +08:00
|
|
|
metaData,
|
2025-05-23 18:19:01 +08:00
|
|
|
defaultValue: {
|
2025-06-03 14:41:45 +08:00
|
|
|
fileExtensions: [
|
|
|
|
'txt',
|
|
|
|
'markdown',
|
|
|
|
'mdx',
|
|
|
|
'pdf',
|
|
|
|
'html',
|
|
|
|
'xlsx',
|
|
|
|
'xls',
|
|
|
|
'vtt',
|
|
|
|
'properties',
|
|
|
|
'doc',
|
|
|
|
'docx',
|
|
|
|
'csv',
|
|
|
|
'eml',
|
|
|
|
'msg',
|
|
|
|
'pptx',
|
|
|
|
'xml',
|
|
|
|
'epub',
|
|
|
|
'ppt',
|
|
|
|
'md',
|
|
|
|
'html',
|
|
|
|
],
|
2025-05-23 18:19:01 +08:00
|
|
|
datasource_parameters: {},
|
|
|
|
datasource_configurations: {},
|
|
|
|
},
|
2025-04-22 16:46:33 +08:00
|
|
|
checkValid() {
|
|
|
|
return {
|
|
|
|
isValid: true,
|
|
|
|
errorMessage: '',
|
|
|
|
}
|
|
|
|
},
|
2025-05-23 18:19:01 +08:00
|
|
|
getOutputVars(payload) {
|
2025-05-27 18:44:04 +08:00
|
|
|
const {
|
|
|
|
provider_type,
|
|
|
|
} = payload
|
2025-05-26 17:47:03 +08:00
|
|
|
const isLocalFile = provider_type === 'local_file'
|
2025-05-23 18:19:01 +08:00
|
|
|
return [
|
|
|
|
{
|
|
|
|
variable: OUTPUT_VARIABLES_MAP.datasource_type.name,
|
|
|
|
type: OUTPUT_VARIABLES_MAP.datasource_type.type,
|
|
|
|
},
|
|
|
|
...(
|
|
|
|
isLocalFile
|
|
|
|
? [
|
|
|
|
{
|
|
|
|
variable: OUTPUT_VARIABLES_MAP.file.name,
|
|
|
|
type: OUTPUT_VARIABLES_MAP.file.type,
|
|
|
|
},
|
|
|
|
]
|
|
|
|
: []
|
|
|
|
),
|
|
|
|
]
|
|
|
|
},
|
2025-04-22 16:46:33 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
export default nodeDefault
|