n8n
Version:
n8n Workflow Automation Tool
53 lines • 2.9 kB
JavaScript
;
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.ExecuteWorkflowEachModeRule = void 0;
const decorators_1 = require("@n8n/decorators");
const EXECUTE_WORKFLOW_NODE_TYPE = 'n8n-nodes-base.executeWorkflow';
let ExecuteWorkflowEachModeRule = class ExecuteWorkflowEachModeRule {
constructor() {
this.id = 'execute-workflow-each-mode-v3';
}
getMetadata() {
return {
version: 'v3',
title: 'Execute Sub-workflow "Run once for each item" mode removed',
description: 'The "Run once for each item" mode of the Execute Sub-workflow node is being removed. Use a Loop Over Items node before the node in "Run once with all items" mode instead.',
category: "workflow",
severity: 'medium',
};
}
async getRecommendations(_workflowResults) {
return [
{
action: 'Replace with a Loop Over Items node',
description: 'Add a Loop Over Items node before the flagged Execute Sub-workflow node and set its mode to "Run once with all items" to keep running the sub-workflow once per item.',
},
];
}
async detectWorkflow(_workflow, nodesGroupedByType) {
const affectedNodes = (nodesGroupedByType.get(EXECUTE_WORKFLOW_NODE_TYPE) ?? []).filter((node) => node.parameters.mode === 'each');
if (affectedNodes.length === 0)
return { isAffected: false, issues: [] };
return {
isAffected: true,
issues: affectedNodes.map((node) => ({
title: `Node '${node.name}' uses the removed "Run once for each item" mode`,
description: 'The "Run once for each item" mode is being removed. Add a Loop Over Items node before this node and switch it to "Run once with all items" to keep running the sub-workflow once per item.',
level: 'error',
nodeId: node.id,
nodeName: node.name,
})),
};
}
};
exports.ExecuteWorkflowEachModeRule = ExecuteWorkflowEachModeRule;
exports.ExecuteWorkflowEachModeRule = ExecuteWorkflowEachModeRule = __decorate([
(0, decorators_1.BreakingChangeRule)({ version: 'v3' })
], ExecuteWorkflowEachModeRule);
//# sourceMappingURL=execute-workflow-each-mode.rule.js.map