mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-17 10:02:05 +00:00
feat(core): Node hints improvements (no-changelog) (#9387)
Co-authored-by: Giulio Andreini <andreini@netseven.it>
This commit is contained in:
@@ -1,14 +1,14 @@
|
||||
import get from 'lodash/get';
|
||||
import unset from 'lodash/unset';
|
||||
import {
|
||||
type IBinaryData,
|
||||
NodeOperationError,
|
||||
deepCopy,
|
||||
type IDataObject,
|
||||
type IExecuteFunctions,
|
||||
type INodeExecutionData,
|
||||
type INodeType,
|
||||
type INodeTypeDescription,
|
||||
import { NodeOperationError, deepCopy, NodeExecutionOutput } from 'n8n-workflow';
|
||||
import type {
|
||||
IBinaryData,
|
||||
IDataObject,
|
||||
IExecuteFunctions,
|
||||
INodeExecutionData,
|
||||
INodeType,
|
||||
INodeTypeDescription,
|
||||
NodeExecutionHint,
|
||||
} from 'n8n-workflow';
|
||||
import { prepareFieldsArray } from '../utils/utils';
|
||||
|
||||
@@ -111,6 +111,7 @@ export class SplitOut implements INodeType {
|
||||
async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
|
||||
const returnData: INodeExecutionData[] = [];
|
||||
const items = this.getInputData();
|
||||
const notFoundedFields: { [key: string]: boolean[] } = {};
|
||||
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const fieldsToSplitOut = (this.getNodeParameter('fieldToSplitOut', i) as string)
|
||||
@@ -160,6 +161,14 @@ export class SplitOut implements INodeType {
|
||||
|
||||
if (entityToSplit === undefined) {
|
||||
entityToSplit = [];
|
||||
if (!notFoundedFields[fieldToSplitOut]) {
|
||||
notFoundedFields[fieldToSplitOut] = [];
|
||||
}
|
||||
notFoundedFields[fieldToSplitOut].push(false);
|
||||
} else {
|
||||
if (notFoundedFields[fieldToSplitOut]) {
|
||||
notFoundedFields[fieldToSplitOut].push(true);
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof entityToSplit !== 'object' || entityToSplit === null) {
|
||||
@@ -254,6 +263,21 @@ export class SplitOut implements INodeType {
|
||||
}
|
||||
}
|
||||
|
||||
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