http.ts 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. import { NodeConnectionTypes, type INodeType } from '../Interface'
  2. type HttpData = {
  3. outputs: [
  4. {
  5. name: 'body'
  6. describe: '响应内容'
  7. type: 'string'
  8. },
  9. {
  10. name: 'status_code'
  11. describe: '响应状态码'
  12. type: 'number'
  13. },
  14. {
  15. name: 'headers'
  16. describe: '响应头列表 JSON'
  17. type: 'object'
  18. }
  19. ]
  20. output_can_alter: false
  21. variables: []
  22. method: 'post'
  23. ssl_verify: false
  24. isInIteration: false
  25. default_value: []
  26. body: {
  27. type: 'json'
  28. data: [
  29. {
  30. key: ''
  31. type: 'text'
  32. value: '{"id":"b3a4aabb-a6b8-47f3-8a32-f45930f7d7b8"}'
  33. }
  34. ]
  35. }
  36. params: []
  37. title: 'HTTP 请求'
  38. type: 'http-request'
  39. error_strategy: 'none'
  40. retry_config: {
  41. max_retries: 3
  42. retry_enabled: false
  43. retry_interval: 100
  44. }
  45. url: '#{env.api_address}/api/agent/getAgentInfo'
  46. authorization: {
  47. type: 'none'
  48. config: {
  49. api_key: ''
  50. header: ''
  51. type: ''
  52. }
  53. }
  54. timeout_config: {
  55. max_write_timeout: 0
  56. max_read_timeout: 0
  57. max_connect_timeout: 0
  58. }
  59. heads: [
  60. {
  61. name: 'Authorization'
  62. value: ''
  63. }
  64. ]
  65. selected: true
  66. desc: ''
  67. isInLoop: false
  68. }
  69. export const httpNode: INodeType = {
  70. version: ['1'],
  71. displayName: 'HTTP 请求',
  72. name: 'http-request',
  73. description: '通过HTTP请求获取数据',
  74. icon: 'lucide:link',
  75. iconColor: '#9373ee',
  76. inputs: [NodeConnectionTypes.main],
  77. outputs: (data: HttpData) => {
  78. // todo: 判断异常处理,如果是分支,添加异常出口
  79. return [NodeConnectionTypes.main]
  80. },
  81. // 业务数据
  82. schema: {
  83. appAgentId: '',
  84. parentId: '',
  85. position: {
  86. x: 20,
  87. y: 30
  88. },
  89. width: 280,
  90. height: 60,
  91. selected: true,
  92. nodeType: 'http-request',
  93. zIndex: 1,
  94. data: {
  95. outputs: [
  96. {
  97. name: 'body',
  98. describe: '响应内容',
  99. type: 'string'
  100. },
  101. {
  102. name: 'status_code',
  103. describe: '响应状态码',
  104. type: 'number'
  105. },
  106. {
  107. name: 'headers',
  108. describe: '响应头列表 JSON',
  109. type: 'object'
  110. }
  111. ],
  112. output_can_alter: false,
  113. variables: [],
  114. method: 'post',
  115. ssl_verify: false,
  116. isInIteration: false,
  117. default_value: [],
  118. body: {
  119. type: 'json',
  120. data: [
  121. {
  122. key: '',
  123. type: 'text',
  124. value: '{"id":"b3a4aabb-a6b8-47f3-8a32-f45930f7d7b8"}'
  125. }
  126. ]
  127. },
  128. params: [],
  129. title: 'HTTP 请求',
  130. type: 'http-request',
  131. error_strategy: 'none',
  132. retry_config: {
  133. max_retries: 3,
  134. retry_enabled: false,
  135. retry_interval: 100
  136. },
  137. url: '#{env.api_address}/api/agent/getAgentInfo',
  138. authorization: {
  139. type: 'none',
  140. config: {
  141. api_key: '',
  142. header: '',
  143. type: ''
  144. }
  145. },
  146. timeout_config: {
  147. max_write_timeout: 0,
  148. max_read_timeout: 0,
  149. max_connect_timeout: 0
  150. },
  151. heads: [
  152. {
  153. name: 'Authorization',
  154. value: ''
  155. }
  156. ],
  157. selected: true,
  158. desc: '',
  159. isInLoop: false
  160. }
  161. }
  162. }