import { NodeConnectionTypes, type INodeType } from '../Interface' export type HttpData = { outputs: Array<{ name: 'body' | 'status_code' | 'headers' describe: string type: 'string' | 'number' | 'object' }> output_can_alter: boolean variables: any[] method: 'post' ssl_verify: boolean isInIteration: boolean default_value: any[] body: { type: 'json' data: Array<{ key: string type: 'text' value: string }> } params: any[] title: string type: 'http-request' error_strategy: 'none' | string retry_config: { max_retries: number retry_enabled: boolean retry_interval: number } url: string authorization: { type: string config: { api_key: string header: string type: string } } timeout_config: { max_write_timeout: number max_read_timeout: number max_connect_timeout: number } heads: Array<{ name: string value: string }> selected: boolean desc: string isInLoop: boolean } export const httpNode: INodeType = { version: ['1'], displayName: 'HTTP 请求', name: 'http-request', description: '通过HTTP请求获取数据', group: '数据处理', icon: 'lucide:link', iconColor: '#9373ee', inputs: [NodeConnectionTypes.main], outputs: (data: HttpData) => { // todo: 判断异常处理,如果是分支,添加异常出口 return data?.error_strategy === 'exception' ? [NodeConnectionTypes.main, NodeConnectionTypes.main] : [NodeConnectionTypes.main] }, validate: (data: HttpData) => { return !!data?.url.trim() ? false : '请填写URL' }, // 业务数据 schema: { appAgentId: '', parentId: '', position: { x: 20, y: 30 }, width: 96, height: 96, selected: false, nodeType: 'http-request', zIndex: 1, data: { outputs: [ { name: 'body', describe: '响应内容', type: 'string' }, { name: 'status_code', describe: '响应状态码', type: 'number' }, { name: 'headers', describe: '响应头列表 JSON', type: 'object' } ], output_can_alter: false, variables: [], method: 'post', ssl_verify: false, isInIteration: false, default_value: [], body: { type: 'json', data: [ { key: '', type: 'text', value: '{"id":"b3a4aabb-a6b8-47f3-8a32-f45930f7d7b8"}' } ] }, params: [], title: 'HTTP 请求', type: 'http-request', error_strategy: 'none', retry_config: { max_retries: 3, retry_enabled: false, retry_interval: 100 }, url: '#{env.api_address}/api/agent/getAgentInfo', authorization: { type: 'none', config: { api_key: '', header: '', type: '' } }, timeout_config: { max_write_timeout: 0, max_read_timeout: 0, max_connect_timeout: 0 }, heads: [ { name: 'Authorization', value: '' } ], selected: true, desc: '', isInLoop: false } } }