adds processed output with hint

This commit is contained in:
Ria 2025-01-15 12:01:14 +01:00
parent 1f4639f834
commit 401a0d2501

View file

@ -18,7 +18,7 @@ import {
fieldValueGetter,
splitData,
} from './utils';
import { generatePairedItemData } from '../../../utils/utilities';
export class Summarize implements INodeType {
description: INodeTypeDescription = {
displayName: 'Summarize',
@ -320,21 +320,6 @@ export class Summarize implements INodeType {
const nodeVersion = this.getNode().typeVersion;
try {
checkIfFieldExists.call(this, newItems, fieldsToSummarize, getValue);
} catch (error) {
if (nodeVersion > 1 || options.continueIfFieldNotFound) {
const itemData = generatePairedItemData(items.length);
const fieldNotFoundHint: NodeExecutionHint = {
message: error.message,
location: 'outputPane',
};
return new NodeExecutionOutput([[{ json: {}, pairedItem: itemData }]], [fieldNotFoundHint]);
} else {
throw error;
}
}
const aggregationResult = splitData(
fieldsToSplitBy,
newItems,
@ -343,6 +328,29 @@ export class Summarize implements INodeType {
getValue,
);
try {
checkIfFieldExists.call(this, newItems, fieldsToSummarize, getValue);
} catch (error) {
if (nodeVersion > 1 || options.continueIfFieldNotFound) {
// const itemData = generatePairedItemData(items.length); // deleted from return array
const fieldNotFoundHint: NodeExecutionHint = {
message: error.message,
location: 'outputPane',
};
const { pairedItems, ...json } = aggregationResult;
const executionData: INodeExecutionData = {
json,
pairedItem: ((pairedItems as number[]) || []).map((index: number) => ({
item: index,
})),
};
return new NodeExecutionOutput([[executionData]], [fieldNotFoundHint]);
// return new NodeExecutionOutput([[{ json: aggregationResult }]], [fieldNotFoundHint]);
} else {
throw error;
}
}
if (options.outputFormat === 'singleItem') {
const executionData: INodeExecutionData = {
json: aggregationResult,