mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
refactor(core): Remove NodeExecutionOutput. Add execution hints directly to the context (#13111)
This commit is contained in:
committed by
GitHub
parent
5dddf772cf
commit
dbb9475b7b
@@ -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];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 () => {
|
||||
|
||||
Reference in New Issue
Block a user