节点版本控制#
¥Node versioning
n8n 支持节点版本控制。你可以通过引入新版本来更改现有节点,而不会破坏现有行为。
¥n8n supports node versioning. You can make changes to existing nodes without breaking the existing behavior by introducing a new version.
请注意 n8n 如何决定加载哪个节点版本:
¥Be aware of how n8n decides which node version to load:
- 如果用户使用版本 1 构建并保存了工作流,即使你创建并发布了节点的版本 2,n8n 仍会在该工作流中继续使用版本 1。
¥If a user builds and saves a workflow using version 1, n8n continues to use version 1 in that workflow, even if you create and publish a version 2 of the node.
- 当用户创建新工作流并浏览节点时,n8n 始终加载节点的最新版本。
¥When a user creates a new workflow and browses for nodes, n8n always loads the latest version of the node.
Versioning type restricted by node style
如果你使用声明式风格构建节点,则无法使用完整版本控制。
¥If you build a node using the declarative style, you can't use full versioning.
轻量级版本控制#
¥Light versioning
此功能适用于所有节点类型。
¥This is available for all node types.
一个节点可以包含多个版本,从而允许小版本增量,而无需代码重复。使用此功能:
¥One node can contain more than one version, allowing small version increments without code duplication. To use this feature:
- 将主
version参数更改为数组,并添加你的版本号,包括你当前的版本。
¥Change the main version parameter to an array, and add your version numbers, including your existing version.
2. 然后,你可以在 displayOptions 的任何对象中使用 @version 访问版本参数(以控制 n8n 显示对象的版本)。你还可以使用 const nodeVersion = this.getNode().typeVersion; 从函数查询版本。
¥You can then access the version parameter with @version in your displayOptions in any object (to control which versions n8n displays the object with). You can also query the version from a function using const nodeVersion = this.getNode().typeVersion;.
例如,假设你想从 声明式节点教程 为 NasaPics 节点添加版本控制,然后配置一个资源,以便 n8n 仅显示该节点的版本 2。在你的 NasaPics.node.ts 基本文件中:
¥As an example, say you want to add versioning to the NasaPics node from the Declarative node tutorial, then configure a resource so that n8n only displays it in version 2 of the node. In your base NasaPics.node.ts file:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | |
完整版本控制#
¥Full versioning
声明式节点不支持此功能。
¥This isn't available for declarative-style nodes.
例如,参考 Mattermost 节点。
¥As an example, refer to the Mattermost node.
完整版本控制摘要:
¥Full versioning summary:
- 基本节点文件应扩展名为
NodeVersionedType而不是INodeType。
¥The base node file should extend NodeVersionedType instead of INodeType.
- 基本节点文件应包含描述信息,包括
defaultVersion(通常为最新版本)、其他基本节点元数据(例如名称)以及版本列表。它不应该包含任何节点功能。
¥The base node file should contain a description including the defaultVersion (usually the latest), other basic node metadata such as name, and a list of versions. It shouldn't contain any node functionality.
- n8n 建议使用
v1、v2等作为版本文件夹名称。
¥n8n recommends using v1, v2, and so on, for version folder names.