import type { FC } from 'react' import React from 'react' import type { PluginTriggerNodeType } from './types' import type { NodeProps } from '@/app/components/workflow/types' import useConfig from './use-config' const formatConfigValue = (rawValue: any): string => { if (rawValue === null || rawValue === undefined) return '' if (typeof rawValue === 'string' || typeof rawValue === 'number' || typeof rawValue === 'boolean') return String(rawValue) if (Array.isArray(rawValue)) return rawValue.join('.') if (typeof rawValue === 'object') { const { value } = rawValue as { value?: any } if (value === null || value === undefined) return '' if (typeof value === 'string' || typeof value === 'number' || typeof value === 'boolean') return String(value) if (Array.isArray(value)) return value.join('.') try { return JSON.stringify(value) } catch { return '' } } return '' } const Node: FC> = ({ id, data, }) => { const { isAuthenticated } = useConfig(id, data) const { config = {} } = data const configKeys = Object.keys(config) // Only show config when authenticated and has config values if (!isAuthenticated || configKeys.length === 0) return null return (
{configKeys.map((key, index) => (
{key}
{(() => { const displayValue = formatConfigValue(config[key]) if (displayValue.includes('secret')) return '********' return displayValue })()}
))}
) } export default React.memo(Node)