类型

以下类型可与API方法一起使用。

传统上,流程配置被表示为一个扁平的节点对象数组。

从Node-RED 0.13版本开始,新增了一个API接口,允许单独维护各个流程(也称为标签页)。这些API使用了更丰富的流程配置格式。我们计划在未来将主流程配置也升级为使用这种更丰富的格式,但目前这两种格式需要共存。

节点

节点(Node)代表流程中单个节点的配置。

{
  "id": "123",
  "type": "inject",
  "x": 0,
  "y": 0,
  "z": "456",
  "wires": [ ... ]
}
字段 描述
id The unique id of the node
type The type of the node
x,y The x/y coordinates of the node when the flow is drawn
z The flow, or subflow, the node is a member of
wires The wires the node’s outputs are connected to
* Other fields as defined by the particular type

如果该节点是配置节点,则不能包含 xywires 属性。

子流程

子流程节点代表子流程的配置。

{
  "id": "6115be82.9eea4",
  "type": "subflow",
  "name": "Subflow 1",
  "info": "",
  "in": [{
    "x": 60,
    "y": 40,
    "wires": [{
      "id": "1830cc4e.e7cf34"
    }]
  }],
  "out": [{
    "x": 320,
    "y": 40,
    "wires": [{
      "id": "1830cc4e.e7cf34",
      "port": 0
    }]
  }],
  "configs": [ ... ],
  "nodes": [ ... ]
}

完整流程配置

完整流程配置代表运行时中所有活跃的流程集合。它以扁平化的节点对象数组形式呈现。这是/flows API使用的主要流程格式,也是编辑器导入/导出的标准格式。

[
  {
    "id": "1234",
    "type": "inject"
  },
  {
    "id": "5678",
    "type": "debug"
  }
]

自 0.15.0 版本起,如果设置了 Node-RED-API-Version 请求头为 v2,则 /flows API 接口支持一种新格式。该格式提供了上述节点数组,并包含流程的可选修订标识符:

{
    "rev": "abc-123",
    "flows": [
      {
        "id": "1234",
        "type": "inject"
      },
      {
        "id": "5678",
        "type": "debug"
      }
    ]
}

单流程配置

单个流程配置代表在编辑器中以标签页形式呈现的内容。

{
  "id": "1234",
  "label": "Sheet1",
  "nodes": [ ... ],
  "configs": [ ... ],
  "subflows": [ ... ]
}
字段 描述
id The unique id of the flow
label A label for the flow
nodes An array of the Nodes in the flow
configs An array of the Configs in the flow
subflows An array of the Subflows in the flow - only used when representing the global flow configuration

节点模块

Node模块代表由npm包提供的节点集集合。

{
  "name": "node-module-name",
  "version": "0.0.6",
  "nodes": [ ... ]
}
字段 描述
name The name of the module - as defined in its package.json
version The version of the module - as defined in its package.json
nodes An array of the Node Set objects provided by this module

节点集

节点集代表Node模块中单个文件提供的类型集合。它们对应模块package.jsonnode-red.nodes属性的条目

{
  "id": "node-module-name/node-set-name",
  "name": "node-set-name",
  "types": [ ... ],
  "enabled": true,
  "module": "node-module-name",
  "version": "0.0.6"
}
字段 描述
id The ID of the set - module/name
name The name of the set - as defined in the module’s package.json
types A string array of the node types provided by this set
enabled Whether this set is currently enabled
module The name of the module providing the set. A value of node-red indicates the node was loaded from copied in files, rather than an npm module.