Skip to content

结构节点基础文件#

¥Structure of the node base file

节点基础文件遵循以下基本结构:

¥The node base file follows this basic structure:

  1. 添加导入语句

¥Add import statements. 2. 创建节点类

¥Create a class for the node. 3. 在节点类中,创建一个 description 对象来定义节点。

¥Within the node class, create a description object, which defines the node.

程序化风格节点还具有 execute() 方法,该方法读取传入的数据和参数,然后构建请求。声明式风格使用 descriptions 对象中的 properties 对象中的 routing 键来处理此请求。

¥A programmatic-style node also has an execute() method, which reads incoming data and parameters, then builds a request. The declarative style handles this using the routing key in the properties object, within descriptions.

声明式节点的结构概要#

¥Outline structure for a declarative-style node

此代码片段概述了节点结构。

¥This code snippet gives an outline of the node structure.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
import { INodeType, INodeTypeDescription } from 'n8n-workflow';

export class ExampleNode implements INodeType {
	description: INodeTypeDescription = {
		// Basic node details here
		properties: [
			// Resources and operations here
		]
	};
}

请参阅 标准参数 以了解所有节点类型可用的参数。有关声明式节点可用的参数,请参阅 声明式参数

¥Refer to Standard parameters for information on parameters available to all node types. Refer to Declarative-style parameters for the parameters available for declarative-style nodes.

程序式节点的结构概要#

¥Outline structure for a programmatic-style node

此代码片段概述了节点结构。

¥This code snippet gives an outline of the node structure.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
import { IExecuteFunctions } from 'n8n-core';
import { INodeExecutionData, INodeType, INodeTypeDescription } from 'n8n-workflow';

export class ExampleNode implements INodeType {
	description: INodeTypeDescription = {
    // Basic node details here
    properties: [
      // Resources and operations here
    ]
  };

  async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
    // Process data and return
  }
};

请参阅 标准参数 以了解所有节点类型可用的参数。有关使用程序化节点的更多信息,请参阅 程序化参数Programmatic-style execute method

¥Refer to Standard parameters for information on parameters available to all node types. Refer to Programmatic-style parameters and Programmatic-style execute method for more information on working with programmatic-style nodes.