mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 18:12:04 +00:00
feat: More hints to nodes (#10565)
Co-authored-by: Giulio Andreini <g.andreini@gmail.com> Co-authored-by: Shireen Missi <94372015+ShireenMissi@users.noreply.github.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import get from 'lodash/get';
|
||||
import isEmpty from 'lodash/isEmpty';
|
||||
import set from 'lodash/set';
|
||||
|
||||
import {
|
||||
NodeOperationError,
|
||||
type IDataObject,
|
||||
@@ -10,6 +11,8 @@ import {
|
||||
type INodeTypeDescription,
|
||||
type IPairedItemData,
|
||||
NodeConnectionType,
|
||||
type NodeExecutionHint,
|
||||
NodeExecutionOutput,
|
||||
} from 'n8n-workflow';
|
||||
import { prepareFieldsArray } from '../utils/utils';
|
||||
import { addBinariesToItem } from './utils';
|
||||
@@ -239,6 +242,7 @@ export class Aggregate implements INodeType {
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
let returnData: INodeExecutionData = { json: {}, pairedItem: [] };
|
||||
const items = this.getInputData();
|
||||
const notFoundedFields: { [key: string]: boolean[] } = {};
|
||||
|
||||
const aggregate = this.getNodeParameter('aggregate', 0, '') as string;
|
||||
|
||||
@@ -299,8 +303,13 @@ export class Aggregate implements INodeType {
|
||||
if (fieldToAggregate !== '') {
|
||||
values[_outputFieldName] = [];
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
if (notFoundedFields[fieldToAggregate] === undefined) {
|
||||
notFoundedFields[fieldToAggregate] = [];
|
||||
}
|
||||
|
||||
if (!disableDotNotation) {
|
||||
let value = get(items[i].json, fieldToAggregate);
|
||||
notFoundedFields[fieldToAggregate].push(value === undefined ? false : true);
|
||||
|
||||
if (!keepMissing) {
|
||||
if (Array.isArray(value)) {
|
||||
@@ -317,6 +326,7 @@ export class Aggregate implements INodeType {
|
||||
}
|
||||
} else {
|
||||
let value = items[i].json[fieldToAggregate];
|
||||
notFoundedFields[fieldToAggregate].push(value === undefined ? false : true);
|
||||
|
||||
if (!keepMissing) {
|
||||
if (Array.isArray(value)) {
|
||||
@@ -410,6 +420,21 @@ export class Aggregate implements INodeType {
|
||||
addBinariesToItem(returnData, aggregatedItems, keepOnlyUnique);
|
||||
}
|
||||
|
||||
if (Object.keys(notFoundedFields).length) {
|
||||
const hints: NodeExecutionHint[] = [];
|
||||
|
||||
for (const [field, values] of Object.entries(notFoundedFields)) {
|
||||
if (values.every((value) => !value)) {
|
||||
hints.push({
|
||||
message: `The field '${field}' wasn't found in any input item`,
|
||||
location: 'outputPane',
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (hints.length) return new NodeExecutionOutput([[returnData]], hints);
|
||||
}
|
||||
|
||||
return [[returnData]];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user