mirror of
https://github.com/Abdulazizzn/n8n-enterprise-unlocked.git
synced 2025-12-19 11:01:15 +00:00
feat(core): Add support for pairedItem (beta) (#3012)
* ✨ Add pairedItem support * 👕 Fix lint issue * 🐛 Fix resolution in frontend * 🐛 Fix resolution issue * 🐛 Fix resolution in frontend * 🐛 Fix another resolution issue in frontend * ⚡ Try to automatically add pairedItem data if possible * ⚡ Cleanup * ⚡ Display expression errors in editor UI * 🐛 Fix issue that it did not display errors in production * 🐛 Fix auto-fix of missing pairedItem data * 🐛 Fix frontend resolution for not executed nodes * ⚡ Fail execution on pairedItem resolve issue and display information about itemIndex and runIndex * ⚡ Allow that pairedItem is only set to number if runIndex is 0 * ✨ Improve Expression Errors * ⚡ Remove no longer needed code * ⚡ Make errors more helpful * ⚡ Add additional errors * 👕 Fix lint issue * ⚡ Add pairedItem support to core nodes * ⚡ Improve support in Merge-Node * ⚡ Fix issue with not correctly converted incoming pairedItem data * 🐛 Fix frontend resolve issue * 🐛 Fix frontend parameter name display issue * ⚡ Improve errors * 👕 Fix lint issue * ⚡ Improve errors * ⚡ Make it possible to display parameter name in error messages * ⚡ Improve error messages * ⚡ Fix error message * ⚡ Improve error messages * ⚡ Add another error message * ⚡ Simplify
This commit is contained in:
@@ -7,7 +7,7 @@
|
||||
// eslint-disable-next-line max-classes-per-file
|
||||
import { parseString } from 'xml2js';
|
||||
// eslint-disable-next-line import/no-cycle
|
||||
import { INode, IStatusCodeMessages, JsonObject } from '.';
|
||||
import { IDataObject, INode, IStatusCodeMessages, JsonObject } from '.';
|
||||
|
||||
/**
|
||||
* Top-level properties where an error message can be found in an API response.
|
||||
@@ -56,29 +56,42 @@ const ERROR_STATUS_PROPERTIES = [
|
||||
*/
|
||||
const ERROR_NESTING_PROPERTIES = ['error', 'err', 'response', 'body', 'data'];
|
||||
|
||||
/**
|
||||
* Base class for specific NodeError-types, with functionality for finding
|
||||
* a value recursively inside an error object.
|
||||
*/
|
||||
abstract class NodeError extends Error {
|
||||
export abstract class ExecutionBaseError extends Error {
|
||||
description: string | null | undefined;
|
||||
|
||||
cause: Error | JsonObject;
|
||||
|
||||
node: INode;
|
||||
|
||||
timestamp: number;
|
||||
|
||||
constructor(node: INode, error: Error | JsonObject) {
|
||||
context: IDataObject = {};
|
||||
|
||||
constructor(error: Error | ExecutionBaseError | JsonObject) {
|
||||
super();
|
||||
this.name = this.constructor.name;
|
||||
this.cause = error;
|
||||
this.node = node;
|
||||
this.timestamp = Date.now();
|
||||
|
||||
if (error.message) {
|
||||
this.message = error.message as string;
|
||||
}
|
||||
|
||||
if (Object.prototype.hasOwnProperty.call(error, 'context')) {
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
this.context = (error as any).context;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Base class for specific NodeError-types, with functionality for finding
|
||||
* a value recursively inside an error object.
|
||||
*/
|
||||
abstract class NodeError extends ExecutionBaseError {
|
||||
node: INode;
|
||||
|
||||
constructor(node: INode, error: Error | JsonObject) {
|
||||
super(error);
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -203,7 +216,11 @@ abstract class NodeError extends Error {
|
||||
* Class for instantiating an operational error, e.g. an invalid credentials error.
|
||||
*/
|
||||
export class NodeOperationError extends NodeError {
|
||||
constructor(node: INode, error: Error | string, options?: { description: string }) {
|
||||
constructor(
|
||||
node: INode,
|
||||
error: Error | string,
|
||||
options?: { description?: string; runIndex?: number; itemIndex?: number },
|
||||
) {
|
||||
if (typeof error === 'string') {
|
||||
error = new Error(error);
|
||||
}
|
||||
@@ -212,6 +229,14 @@ export class NodeOperationError extends NodeError {
|
||||
if (options?.description) {
|
||||
this.description = options.description;
|
||||
}
|
||||
|
||||
if (options?.runIndex !== undefined) {
|
||||
this.context.runIndex = options.runIndex;
|
||||
}
|
||||
|
||||
if (options?.itemIndex !== undefined) {
|
||||
this.context.itemIndex = options.itemIndex;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,7 +274,16 @@ export class NodeApiError extends NodeError {
|
||||
description,
|
||||
httpCode,
|
||||
parseXml,
|
||||
}: { message?: string; description?: string; httpCode?: string; parseXml?: boolean } = {},
|
||||
runIndex,
|
||||
itemIndex,
|
||||
}: {
|
||||
message?: string;
|
||||
description?: string;
|
||||
httpCode?: string;
|
||||
parseXml?: boolean;
|
||||
runIndex?: number;
|
||||
itemIndex?: number;
|
||||
} = {},
|
||||
) {
|
||||
super(node, error);
|
||||
if (error.error) {
|
||||
@@ -272,6 +306,9 @@ export class NodeApiError extends NodeError {
|
||||
}
|
||||
|
||||
this.description = this.findProperty(error, ERROR_MESSAGE_PROPERTIES, ERROR_NESTING_PROPERTIES);
|
||||
|
||||
if (runIndex !== undefined) this.context.runIndex = runIndex;
|
||||
if (itemIndex !== undefined) this.context.itemIndex = itemIndex;
|
||||
}
|
||||
|
||||
private setDescriptionFromXml(xml: string) {
|
||||
|
||||
Reference in New Issue
Block a user