Skip to content

节点基础文件的结构

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

  1. 添加导入语句。
  2. 为节点创建一个类。
  3. 在节点类中,创建一个定义节点的对象。

程序化风格的节点也有一个方法,用于读取传入的数据和参数,然后构建请求。声明式风格使用对象中的键(位于 内)来处理此操作。

声明式节点的概要结构

此代码片段给出了节点结构的概要。

 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.

程序化风格节点的概要结构

此代码片段给出了节点结构的概要。

 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
  }
};

有关所有节点类型可用参数的信息,请参阅标准参数。有关使用程序化样式节点的更多信息,请参阅程序化样式参数程序化样式执行方法