跳到主要内容

节点基础文件结构#

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

  1. 添加导入语句
  2. 创建节点类
  3. 在节点类中创建定义节点的description对象

编程式节点还包含一个execute()方法,该方法负责读取输入数据和参数,然后构建请求。而声明式风格则通过在descriptions内的properties对象中使用routing键来处理这一过程。

声明式节点的概要结构#

以下代码片段展示了节点的概要结构。

import { INodeType, INodeTypeDescription } from 'n8n-workflow';

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

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

编程式节点的框架结构#

以下代码片段展示了节点的框架结构:

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

有关所有节点类型通用参数的详细信息,请参阅标准参数。若需了解编程式节点的使用方法,请参阅编程式参数编程式执行方法获取更多信息。