refactor(core): Remove NodeExecutionOutput. Add execution hints directly to the context (#13111)

This commit is contained in:
कारतोफ्फेलस्क्रिप्ट™
2025-02-10 16:51:01 +01:00
committed by GitHub
parent 5dddf772cf
commit dbb9475b7b
17 changed files with 103 additions and 171 deletions

View File

@@ -11,7 +11,6 @@ import {
type IPairedItemData,
NodeConnectionType,
type NodeExecutionHint,
NodeExecutionOutput,
} from 'n8n-workflow';
import { addBinariesToItem } from './utils';
@@ -432,7 +431,9 @@ export class Aggregate implements INodeType {
}
}
if (hints.length) return new NodeExecutionOutput([[returnData]], hints);
if (hints.length) {
this.addExecutionHints(...hints);
}
}
return [[returnData]];

View File

@@ -1,9 +1,4 @@
import {
NodeConnectionType,
NodeExecutionOutput,
NodeOperationError,
tryToParseDateTime,
} from 'n8n-workflow';
import { NodeConnectionType, NodeOperationError, tryToParseDateTime } from 'n8n-workflow';
import type {
INodeTypeBaseDescription,
IExecuteFunctions,
@@ -126,13 +121,12 @@ export class RemoveDuplicatesV2 implements INodeType {
);
if (maxEntriesNum > 0 && processedDataCount / maxEntriesNum > 0.5) {
return new NodeExecutionOutput(returnData, [
{
message: `Some duplicates may be not be removed since you're approaching the maximum history size (${maxEntriesNum} items). You can raise this limit using the history size option.`,
location: 'outputPane',
},
]);
} else return returnData;
this.addExecutionHints({
message: `Some duplicates may be not be removed since you're approaching the maximum history size (${maxEntriesNum} items). You can raise this limit using the history size option.`,
location: 'outputPane',
});
}
return returnData;
} else if (logic === 'removeItemsUpToStoredIncrementalKey') {
if (!['node', 'workflow'].includes(scope)) {
throw new NodeOperationError(

View File

@@ -1,11 +1,6 @@
import get from 'lodash/get';
import unset from 'lodash/unset';
import {
NodeOperationError,
deepCopy,
NodeExecutionOutput,
NodeConnectionType,
} from 'n8n-workflow';
import { NodeOperationError, deepCopy, NodeConnectionType } from 'n8n-workflow';
import type {
IBinaryData,
IDataObject,
@@ -281,7 +276,9 @@ export class SplitOut implements INodeType {
}
}
if (hints.length) return new NodeExecutionOutput([returnData], hints);
if (hints.length) {
this.addExecutionHints(...hints);
}
}
return [returnData];

View File

@@ -5,7 +5,6 @@ import {
type INodeExecutionData,
type INodeType,
type INodeTypeDescription,
NodeExecutionOutput,
type NodeExecutionHint,
type IDataObject,
} from 'n8n-workflow';
@@ -345,6 +344,10 @@ export class Summarize implements INodeType {
}
}
if (fieldsNotFound.length) {
this.addExecutionHints(...fieldsNotFound);
}
if (options.outputFormat === 'singleItem') {
const executionData: INodeExecutionData = {
json: aggregationResult,
@@ -352,7 +355,7 @@ export class Summarize implements INodeType {
item: index,
})),
};
return new NodeExecutionOutput([[executionData]], fieldsNotFound);
return [[executionData]];
} else {
if (!fieldsToSplitBy.length) {
const { pairedItems, ...json } = aggregationResult;
@@ -362,7 +365,7 @@ export class Summarize implements INodeType {
item: index,
})),
};
return new NodeExecutionOutput([[executionData]], fieldsNotFound);
return [[executionData]];
}
let returnData: IDataObject[] = [];
if (nodeVersion > 1) {
@@ -379,7 +382,7 @@ export class Summarize implements INodeType {
})),
};
});
return new NodeExecutionOutput([executionData], fieldsNotFound);
return [executionData];
}
}
}

View File

@@ -1,7 +1,7 @@
import type { MockProxy } from 'jest-mock-extended';
import { mock } from 'jest-mock-extended';
import type { IExecuteFunctions } from 'n8n-workflow';
import { NodeExecutionOutput, NodeOperationError } from 'n8n-workflow';
import { NodeOperationError } from 'n8n-workflow';
import { Summarize } from '../../Summarize.node';
import type { Aggregations } from '../../utils';
@@ -43,14 +43,11 @@ describe('Test Summarize Node, execute', () => {
const result = await summarizeNode.execute.call(mockExecuteFunctions);
expect(result).toBeInstanceOf(NodeExecutionOutput);
expect(result).toEqual([[{ json: { sum_nonexistentField: 0 }, pairedItem: [{ item: 0 }] }]]);
expect((result as NodeExecutionOutput).getHints()).toEqual([
{
location: 'outputPane',
message: "The field 'nonexistentField' does not exist in any items",
},
]);
expect(mockExecuteFunctions.addExecutionHints).toHaveBeenCalledWith({
location: 'outputPane',
message: "The field 'nonexistentField' does not exist in any items",
});
});
it('should throw error if node version is < 1.1 and fields not found', async () => {