This commit is contained in:
Ria 2025-01-18 18:41:01 +01:00
parent 6b7e109afc
commit 1d7883ec6e

View file

@ -18,6 +18,7 @@ import {
fieldValueGetter, fieldValueGetter,
splitData, splitData,
} from './utils'; } from './utils';
import { fields } from '../../Contentful/AssetDescription';
// import { generatePairedItemData } from '../../../utils/utilities'; // import { generatePairedItemData } from '../../../utils/utilities';
// [ria] not needed // [ria] not needed
export class Summarize implements INodeType { export class Summarize implements INodeType {
@ -329,24 +330,29 @@ export class Summarize implements INodeType {
getValue, getValue,
); );
const fieldsNotFound: NodeExecutionHint[] = [];
try { try {
checkIfFieldExists.call(this, newItems, fieldsToSummarize, getValue); checkIfFieldExists.call(this, newItems, fieldsToSummarize, getValue);
} catch (error) { } catch (error) {
if (nodeVersion > 1 || options.continueIfFieldNotFound) { if (nodeVersion > 1 || options.continueIfFieldNotFound) {
// const itemData = generatePairedItemData(items.length); // deleted from return array
const fieldNotFoundHint: NodeExecutionHint = { const fieldNotFoundHint: NodeExecutionHint = {
message: error instanceof Error ? error.message : String(error), message: error instanceof Error ? error.message : String(error),
location: 'outputPane', location: 'outputPane',
}; };
const { pairedItems, ...json } = aggregationResult; fieldsNotFound.push(fieldNotFoundHint);
const executionData: INodeExecutionData = { // const executionOutput = Object.keys(aggregationResult).reduce(
json, // (acc, key) => {
pairedItem: ((pairedItems as number[]) || []).map((index: number) => ({ // const { pairedItem, ...json } = aggregationResult;
item: index, // acc[key] = json;
})), // return acc;
}; // },
return new NodeExecutionOutput([[executionData]], [fieldNotFoundHint]); // {} as { [key: string]: any },
// return new NodeExecutionOutput([[{ json: aggregationResult }]], [fieldNotFoundHint]); // );
// return new NodeExecutionOutput(
// [[{ json: executionOutput }, { json: executionOutput }], [{ json: executionOutput }]],
// [fieldNotFoundHint],
// aggregationResult.fieldnotfoundhint = fieldNotFoundHint;
// );
} else { } else {
throw error; throw error;
} }
@ -381,7 +387,8 @@ export class Summarize implements INodeType {
})), })),
}; };
}); });
return [executionData]; return new NodeExecutionOutput([executionData], fieldsNotFound);
} }
} }
} }
// testing: if node version >1 return output needs to have fieldsnotFound