From 5a3122f2796f51b9d59724b75f9d424de0d0558a Mon Sep 17 00:00:00 2001 From: Michael Kret <88898367+michael-radency@users.noreply.github.com> Date: Thu, 16 May 2024 12:35:36 +0300 Subject: [PATCH] fix: PairedItems various fixes (no-changelog) (#9357) --- .../nodes/FileMaker/FileMaker.node.ts | 31 ++++++++++++------- .../v2/actions/sheet/append.operation.ts | 5 ++- .../actions/sheet/appendOrUpdate.operation.ts | 5 ++- .../v2/actions/sheet/update.operation.ts | 5 ++- .../nodes-base/nodes/Merge/v2/MergeV2.node.ts | 12 +++---- 5 files changed, 37 insertions(+), 21 deletions(-) diff --git a/packages/nodes-base/nodes/FileMaker/FileMaker.node.ts b/packages/nodes-base/nodes/FileMaker/FileMaker.node.ts index 29352a9425..245dba6b8b 100644 --- a/packages/nodes-base/nodes/FileMaker/FileMaker.node.ts +++ b/packages/nodes-base/nodes/FileMaker/FileMaker.node.ts @@ -692,8 +692,8 @@ export class FileMaker implements INodeType { const action = this.getNodeParameter('action', 0) as string; - try { - for (let i = 0; i < items.length; i++) { + for (let i = 0; i < items.length; i++) { + try { // Reset all values requestOptions = { uri: '', @@ -807,17 +807,24 @@ export class FileMaker implements INodeType { { itemIndex: i }, ); } - returnData.push({ json: response }); - } - } catch (error) { - if (error.node) { - throw error; - } + returnData.push({ json: response, pairedItem: { item: i } }); + } catch (error) { + if (this.continueOnFail()) { + returnData.push({ + json: { error: error.message }, + pairedItem: { item: i }, + }); + } else { + if (error.node) { + throw error; + } - throw new NodeOperationError( - this.getNode(), - `The action "${error.message}" is not implemented yet!`, - ); + throw new NodeOperationError( + this.getNode(), + `The action "${error.message}" is not implemented yet!`, + ); + } + } } await logout.call(this, token as string); diff --git a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/append.operation.ts b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/append.operation.ts index 5e1d0a810d..e5084f6ec0 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/append.operation.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/append.operation.ts @@ -260,7 +260,10 @@ export async function execute( } if (nodeVersion < 4 || dataMode === 'autoMapInputData') { - return items; + return items.map((item, index) => { + item.pairedItem = { item: index }; + return item; + }); } else { const returnData: INodeExecutionData[] = []; for (const [index, entry] of setData.entries()) { diff --git a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/appendOrUpdate.operation.ts b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/appendOrUpdate.operation.ts index ea68b5b954..b39dc758a8 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/appendOrUpdate.operation.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/appendOrUpdate.operation.ts @@ -430,7 +430,10 @@ export async function execute( } if (nodeVersion < 4 || dataMode === 'autoMapInputData') { - return items; + return items.map((item, index) => { + item.pairedItem = { item: index }; + return item; + }); } else { const returnData: INodeExecutionData[] = []; for (const [index, entry] of mappedValues.entries()) { diff --git a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/update.operation.ts b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/update.operation.ts index 658d8ffcdd..9799bd0c4f 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/update.operation.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/update.operation.ts @@ -404,7 +404,10 @@ export async function execute( } if (nodeVersion < 4 || dataMode === 'autoMapInputData') { - return items; + return items.map((item, index) => { + item.pairedItem = { item: index }; + return item; + }); } else { if (!updateData.length) { return []; diff --git a/packages/nodes-base/nodes/Merge/v2/MergeV2.node.ts b/packages/nodes-base/nodes/Merge/v2/MergeV2.node.ts index ffdfcfe545..1527691082 100644 --- a/packages/nodes-base/nodes/Merge/v2/MergeV2.node.ts +++ b/packages/nodes-base/nodes/Merge/v2/MergeV2.node.ts @@ -368,7 +368,7 @@ export class MergeV2 implements INodeType { let input1 = this.getInputData(0); let input2 = this.getInputData(1); - if (input1.length === 0 || input2.length === 0) { + if (input1?.length === 0 || input2?.length === 0) { // If data of any input is missing, return the data of // the input that contains data return [[...input1, ...input2]]; @@ -474,19 +474,19 @@ export class MergeV2 implements INodeType { if (!input1) return [returnData]; } - if (input1.length === 0 || input2.length === 0) { - if (!input1.length && joinMode === 'keepNonMatches' && outputDataFrom === 'input1') + if (input1?.length === 0 || input2?.length === 0) { + if (!input1?.length && joinMode === 'keepNonMatches' && outputDataFrom === 'input1') return [returnData]; - if (!input2.length && joinMode === 'keepNonMatches' && outputDataFrom === 'input2') + if (!input2?.length && joinMode === 'keepNonMatches' && outputDataFrom === 'input2') return [returnData]; if (joinMode === 'keepMatches') { // Stop the execution return [[]]; - } else if (joinMode === 'enrichInput1' && input1.length === 0) { + } else if (joinMode === 'enrichInput1' && input1?.length === 0) { // No data to enrich so stop return [[]]; - } else if (joinMode === 'enrichInput2' && input2.length === 0) { + } else if (joinMode === 'enrichInput2' && input2?.length === 0) { // No data to enrich so stop return [[]]; } else {