diff --git a/packages/nodes-base/.eslintrc.js b/packages/nodes-base/.eslintrc.js index 98f30a7991..f517dd8c48 100644 --- a/packages/nodes-base/.eslintrc.js +++ b/packages/nodes-base/.eslintrc.js @@ -22,7 +22,7 @@ module.exports = { '@typescript-eslint/naming-convention': ['error', { selector: 'memberLike', format: null }], '@typescript-eslint/no-explicit-any': 'off', //812 warnings, better to fix in separate PR '@typescript-eslint/no-non-null-assertion': 'off', //665 errors, better to fix in separate PR - '@typescript-eslint/no-unsafe-argument': 'off', //1538 errors, better to fix in separate PR + // '@typescript-eslint/no-unsafe-argument': 'off', //1538 errors, better to fix in separate PR '@typescript-eslint/no-unsafe-assignment': 'off', //7084 problems, better to fix in separate PR '@typescript-eslint/no-unsafe-call': 'off', //541 errors, better to fix in separate PR '@typescript-eslint/no-unsafe-member-access': 'off', //4591 errors, better to fix in separate PR diff --git a/packages/nodes-base/nodes/ActionNetwork/ActionNetwork.node.ts b/packages/nodes-base/nodes/ActionNetwork/ActionNetwork.node.ts index 793dde2aa2..e7aa0c69cc 100644 --- a/packages/nodes-base/nodes/ActionNetwork/ActionNetwork.node.ts +++ b/packages/nodes-base/nodes/ActionNetwork/ActionNetwork.node.ts @@ -481,10 +481,12 @@ export class ActionNetwork implements INodeType { response = operation === 'getAll' ? response.map((entry: Response) => simplifyResponse(entry, resource)) - : simplifyResponse(response, resource); + : simplifyResponse(response as Response, resource); } - Array.isArray(response) ? returnData.push(...response) : returnData.push(response); + Array.isArray(response) + ? returnData.push(...(response as IDataObject[])) + : returnData.push(response as IDataObject); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); diff --git a/packages/nodes-base/nodes/ActionNetwork/GenericFunctions.ts b/packages/nodes-base/nodes/ActionNetwork/GenericFunctions.ts index 2aa0538568..1de5b018fb 100644 --- a/packages/nodes-base/nodes/ActionNetwork/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ActionNetwork/GenericFunctions.ts @@ -81,14 +81,16 @@ export async function handleListing( do { responseData = await actionNetworkApiRequest.call(this, method, endpoint, body, qs); const items = responseData._embedded[itemsKey]; - returnData.push(...items); + returnData.push(...(items as IDataObject[])); if (!returnAll && returnData.length >= limit) { return returnData.slice(0, limit); } if (responseData._links?.next?.href) { - const queryString = new URLSearchParams(responseData._links.next.href.split('?')[1]); + const queryString = new URLSearchParams( + responseData._links.next.href.split('?')[1] as string, + ); qs.page = queryString.get('page') as string; } } while (responseData._links?.next); diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts index 2cbadde818..4941acf03b 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaign.node.ts @@ -1182,7 +1182,7 @@ export class ActiveCampaign implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaignTrigger.node.ts b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaignTrigger.node.ts index ce2eaea8f5..1d316e9ab0 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaignTrigger.node.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/ActiveCampaignTrigger.node.ts @@ -169,7 +169,7 @@ export class ActiveCampaignTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const req = this.getRequestObject(); return { - workflowData: [this.helpers.returnJsonArray(req.body)], + workflowData: [this.helpers.returnJsonArray(req.body as IDataObject[])], }; } } diff --git a/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts b/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts index db7ffc0c8f..54c81b3901 100644 --- a/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ActiveCampaign/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import type { IDataObject, ILoadOptionsFunctions, INodeProperties } from 'n8n-workflow'; +import type { IDataObject, ILoadOptionsFunctions, INodeProperties, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import type { OptionsWithUri } from 'request'; @@ -49,7 +49,7 @@ export async function activeCampaignApiRequest( ); if (responseData.success === false) { - throw new NodeApiError(this.getNode(), responseData); + throw new NodeApiError(this.getNode(), responseData as JsonObject); } if (dataKey === undefined) { @@ -58,7 +58,7 @@ export async function activeCampaignApiRequest( return responseData[dataKey] as IDataObject; } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -91,12 +91,12 @@ export async function activeCampaignApiRequestAllItems( responseData = await activeCampaignApiRequest.call(this, method, endpoint, body, query); if (dataKey === undefined) { - returnData.push.apply(returnData, responseData); + returnData.push.apply(returnData, responseData as IDataObject[]); if (returnData !== undefined) { itemsReceived += returnData.length; } } else { - returnData.push.apply(returnData, responseData[dataKey]); + returnData.push.apply(returnData, responseData[dataKey] as IDataObject[]); if (responseData[dataKey] !== undefined) { itemsReceived += responseData[dataKey].length; } diff --git a/packages/nodes-base/nodes/AcuityScheduling/AcuitySchedulingTrigger.node.ts b/packages/nodes-base/nodes/AcuityScheduling/AcuitySchedulingTrigger.node.ts index d9747b2694..85377674d3 100644 --- a/packages/nodes-base/nodes/AcuityScheduling/AcuitySchedulingTrigger.node.ts +++ b/packages/nodes-base/nodes/AcuityScheduling/AcuitySchedulingTrigger.node.ts @@ -168,7 +168,7 @@ export class AcuitySchedulingTrigger implements INodeType { if (!resolveData) { // Return the data as it got received return { - workflowData: [this.helpers.returnJsonArray(req.body)], + workflowData: [this.helpers.returnJsonArray(req.body as IDataObject[])], }; } @@ -179,7 +179,7 @@ export class AcuitySchedulingTrigger implements INodeType { const responseData = await acuitySchedulingApiRequest.call(this, 'GET', endpoint, {}); return { - workflowData: [this.helpers.returnJsonArray(responseData)], + workflowData: [this.helpers.returnJsonArray(responseData as IDataObject)], }; } } diff --git a/packages/nodes-base/nodes/AcuityScheduling/GenericFunctions.ts b/packages/nodes-base/nodes/AcuityScheduling/GenericFunctions.ts index b0ea38712f..2492be7c8f 100644 --- a/packages/nodes-base/nodes/AcuityScheduling/GenericFunctions.ts +++ b/packages/nodes-base/nodes/AcuityScheduling/GenericFunctions.ts @@ -6,7 +6,7 @@ import type { ILoadOptionsFunctions, IWebhookFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function acuitySchedulingApiRequest( @@ -58,6 +58,6 @@ export async function acuitySchedulingApiRequest( ); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Affinity/Affinity.node.ts b/packages/nodes-base/nodes/Affinity/Affinity.node.ts index d475394a06..6d85aad421 100644 --- a/packages/nodes-base/nodes/Affinity/Affinity.node.ts +++ b/packages/nodes-base/nodes/Affinity/Affinity.node.ts @@ -415,7 +415,7 @@ export class Affinity implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Affinity/AffinityTrigger.node.ts b/packages/nodes-base/nodes/Affinity/AffinityTrigger.node.ts index 5dc788effb..05205fa16b 100644 --- a/packages/nodes-base/nodes/Affinity/AffinityTrigger.node.ts +++ b/packages/nodes-base/nodes/Affinity/AffinityTrigger.node.ts @@ -167,7 +167,10 @@ export class AffinityTrigger implements INodeType { const events = this.getNodeParameter('events') as string[]; for (const webhook of responseData) { - if (eventsExist(webhook.subscriptions, events) && webhook.webhook_url === webhookUrl) { + if ( + eventsExist(webhook.subscriptions as string[], events) && + webhook.webhook_url === webhookUrl + ) { // Set webhook-id to be sure that it can be deleted const webhookData = this.getWorkflowStaticData('node'); webhookData.webhookId = webhook.id as string; diff --git a/packages/nodes-base/nodes/Affinity/GenericFunctions.ts b/packages/nodes-base/nodes/Affinity/GenericFunctions.ts index 110a063792..1266077e8d 100644 --- a/packages/nodes-base/nodes/Affinity/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Affinity/GenericFunctions.ts @@ -3,7 +3,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { BINARY_ENCODING } from 'n8n-core'; -import type { IDataObject, IHookFunctions, IWebhookFunctions } from 'n8n-workflow'; +import type { IDataObject, IHookFunctions, IWebhookFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function affinityApiRequest( @@ -32,7 +32,7 @@ export async function affinityApiRequest( uri: uri || `${endpoint}${resource}`, json: true, }; - if (!Object.keys(body).length) { + if (!Object.keys(body as IDataObject).length) { delete options.body; } if (!Object.keys(query).length) { @@ -42,7 +42,7 @@ export async function affinityApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -64,7 +64,7 @@ export async function affinityApiRequestAllItems( responseData = await affinityApiRequest.call(this, method, resource, body, query); // @ts-ignore query.page_token = responseData.page_token; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.page_token !== undefined && responseData.page_token !== null); return returnData; diff --git a/packages/nodes-base/nodes/AgileCrm/AgileCrm.node.ts b/packages/nodes-base/nodes/AgileCrm/AgileCrm.node.ts index 56d3ac169a..ad24cc3bad 100644 --- a/packages/nodes-base/nodes/AgileCrm/AgileCrm.node.ts +++ b/packages/nodes-base/nodes/AgileCrm/AgileCrm.node.ts @@ -191,6 +191,7 @@ export class AgileCrm implements INodeType { } if (simple) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument responseData = simplifyResponse(responseData); } } else if (operation === 'create') { diff --git a/packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts b/packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts index 0d89b9fe88..7269b7f985 100644 --- a/packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts +++ b/packages/nodes-base/nodes/AgileCrm/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import type { IContactUpdate } from './ContactInterface'; @@ -51,7 +51,7 @@ export async function agileCrmApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -79,7 +79,7 @@ export async function agileCrmApiRequestAllItems( sendAsForm, ); if (responseData.length !== 0) { - returnData.push.apply(returnData, responseData); + returnData.push.apply(returnData, responseData as IDataObject[]); if (sendAsForm) { body.cursor = responseData[responseData.length - 1].cursor; } else { @@ -169,9 +169,9 @@ export async function agileCrmApiRequestUpdate( return lastSuccesfulUpdateReturn; } catch (error) { if (successfulUpdates.length === 0) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } else { - throw new NodeApiError(this.getNode(), error, { + throw new NodeApiError(this.getNode(), error as JsonObject, { message: `Not all properties updated. Updated properties: ${successfulUpdates.join(', ')}`, description: error.message, httpCode: error.statusCode, diff --git a/packages/nodes-base/nodes/Airtable/Airtable.node.ts b/packages/nodes-base/nodes/Airtable/Airtable.node.ts index 7dde15bb0d..494b9899b0 100644 --- a/packages/nodes-base/nodes/Airtable/Airtable.node.ts +++ b/packages/nodes-base/nodes/Airtable/Airtable.node.ts @@ -8,6 +8,7 @@ import type { } from 'n8n-workflow'; import { NodeOperationError } from 'n8n-workflow'; +import type { IRecord } from './GenericFunctions'; import { apiRequest, apiRequestAllItems, downloadRecordAttachments } from './GenericFunctions'; export class Airtable implements INodeType { @@ -567,7 +568,7 @@ export class Airtable implements INodeType { responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData.records), + this.helpers.returnJsonArray(responseData.records as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -609,7 +610,7 @@ export class Airtable implements INodeType { responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData.records), + this.helpers.returnJsonArray(responseData.records as IDataObject[]), { itemData: { item: i } }, ); @@ -654,7 +655,7 @@ export class Airtable implements INodeType { responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); } - returnData.push.apply(returnData, responseData.records); + returnData.push.apply(returnData, responseData.records as INodeExecutionData[]); if (downloadAttachments === true) { const downloadFieldNames = ( @@ -662,7 +663,7 @@ export class Airtable implements INodeType { ).split(','); const data = await downloadRecordAttachments.call( this, - responseData.records, + responseData.records as IRecord[], downloadFieldNames, ); return [data]; @@ -704,7 +705,7 @@ export class Airtable implements INodeType { responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -786,7 +787,7 @@ export class Airtable implements INodeType { responseData = await apiRequest.call(this, requestMethod, endpoint, data, qs); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData.records), + this.helpers.returnJsonArray(responseData.records as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Airtable/AirtableTrigger.node.ts b/packages/nodes-base/nodes/Airtable/AirtableTrigger.node.ts index 5ca532fe05..9902557e04 100644 --- a/packages/nodes-base/nodes/Airtable/AirtableTrigger.node.ts +++ b/packages/nodes-base/nodes/Airtable/AirtableTrigger.node.ts @@ -8,6 +8,7 @@ import type { } from 'n8n-workflow'; import { NodeOperationError } from 'n8n-workflow'; +import type { IRecord } from './GenericFunctions'; import { apiRequestAllItems, downloadRecordAttachments } from './GenericFunctions'; import moment from 'moment'; @@ -245,7 +246,11 @@ export class AirtableTrigger implements INodeType { const downloadFieldNames = (this.getNodeParameter('downloadFieldNames', 0) as string).split( ',', ); - const data = await downloadRecordAttachments.call(this, records, downloadFieldNames); + const data = await downloadRecordAttachments.call( + this, + records as IRecord[], + downloadFieldNames, + ); return [data]; } diff --git a/packages/nodes-base/nodes/Airtable/GenericFunctions.ts b/packages/nodes-base/nodes/Airtable/GenericFunctions.ts index 88aed757e9..6b046a1e5a 100644 --- a/packages/nodes-base/nodes/Airtable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Airtable/GenericFunctions.ts @@ -86,7 +86,7 @@ export async function apiRequestAllItems( do { responseData = await apiRequest.call(this, method, endpoint, body, query); - returnData.push.apply(returnData, responseData.records); + returnData.push.apply(returnData, responseData.records as IDataObject[]); query.offset = responseData.offset; } while (responseData.offset !== undefined); @@ -113,7 +113,7 @@ export async function downloadRecordAttachments( encoding: null, }); element.binary![`${fieldName}_${index}`] = await this.helpers.prepareBinaryData( - Buffer.from(file), + Buffer.from(file as string), attachment.filename, attachment.type, ); diff --git a/packages/nodes-base/nodes/Amqp/AmqpTrigger.node.ts b/packages/nodes-base/nodes/Amqp/AmqpTrigger.node.ts index 6661de2962..68dcd10e21 100644 --- a/packages/nodes-base/nodes/Amqp/AmqpTrigger.node.ts +++ b/packages/nodes-base/nodes/Amqp/AmqpTrigger.node.ts @@ -168,23 +168,23 @@ export class AmqpTrigger implements INodeType { if (options.jsonConvertByteArrayToString === true && data.body.content !== undefined) { // The buffer is not ready... Stringify and parse back to load it. const cont = deepCopy(data.body.content); - data.body = String.fromCharCode.apply(null, cont.data); + data.body = String.fromCharCode.apply(null, cont.data as number[]); } if (options.jsonConvertByteArrayToString === true && data.body.content !== undefined) { // The buffer is not ready... Stringify and parse back to load it. const cont = deepCopy(data.body.content); - data.body = String.fromCharCode.apply(null, cont.data); + data.body = String.fromCharCode.apply(null, cont.data as number[]); } if (options.jsonConvertByteArrayToString === true && data.body.content !== undefined) { // The buffer is not ready... Stringify and parse back to load it. const content = deepCopy(data.body.content); - data.body = String.fromCharCode.apply(null, content.data); + data.body = String.fromCharCode.apply(null, content.data as number[]); } if (options.jsonParseBody === true) { - data.body = jsonParse(data.body); + data.body = jsonParse(data.body as string); } if (options.onlyBody === true) { data = data.body; diff --git a/packages/nodes-base/nodes/ApiTemplateIo/ApiTemplateIo.node.ts b/packages/nodes-base/nodes/ApiTemplateIo/ApiTemplateIo.node.ts index 3cf254681a..cbdd192a3e 100644 --- a/packages/nodes-base/nodes/ApiTemplateIo/ApiTemplateIo.node.ts +++ b/packages/nodes-base/nodes/ApiTemplateIo/ApiTemplateIo.node.ts @@ -364,7 +364,7 @@ export class ApiTemplateIo implements INodeType { try { responseData = await apiTemplateIoApiRequest.call(this, 'GET', '/account-information'); - returnData.push(responseData); + returnData.push(responseData as IDataObject); } catch (error) { if (this.continueOnFail()) { returnData.push({ json: { error: error.message } }); @@ -437,11 +437,11 @@ export class ApiTemplateIo implements INodeType { if (download) { const binaryProperty = this.getNodeParameter('binaryProperty', i); - const data = await downloadImage.call(this, responseData.download_url); + const data = await downloadImage.call(this, responseData.download_url as string); const fileName = responseData.download_url.split('/').pop(); const binaryData = await this.helpers.prepareBinaryData( - data, - options.fileName || fileName, + data as Buffer, + (options.fileName as string) || (fileName as string), ); responseData = { json: responseData, @@ -450,7 +450,7 @@ export class ApiTemplateIo implements INodeType { }, }; } - returnData.push(responseData); + returnData.push(responseData as IDataObject); } catch (error) { if (this.continueOnFail()) { returnData.push({ json: { error: error.message } }); @@ -517,15 +517,21 @@ export class ApiTemplateIo implements INodeType { } } - responseData = await apiTemplateIoApiRequest.call(this, 'POST', '/create', qs, data); + responseData = await apiTemplateIoApiRequest.call( + this, + 'POST', + '/create', + qs, + data as IDataObject, + ); if (download) { const binaryProperty = this.getNodeParameter('binaryProperty', i); - const imageData = await downloadImage.call(this, responseData.download_url); + const imageData = await downloadImage.call(this, responseData.download_url as string); const fileName = responseData.download_url.split('/').pop(); const binaryData = await this.helpers.prepareBinaryData( - imageData, - options.fileName || fileName, + imageData as Buffer, + (options.fileName || fileName) as string, ); responseData = { json: responseData, @@ -534,7 +540,7 @@ export class ApiTemplateIo implements INodeType { }, }; } - returnData.push(responseData); + returnData.push(responseData as IDataObject); } catch (error) { if (this.continueOnFail()) { returnData.push({ json: { error: error.message } }); diff --git a/packages/nodes-base/nodes/ApiTemplateIo/GenericFunctions.ts b/packages/nodes-base/nodes/ApiTemplateIo/GenericFunctions.ts index 698255c022..aef669dae2 100644 --- a/packages/nodes-base/nodes/ApiTemplateIo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ApiTemplateIo/GenericFunctions.ts @@ -1,6 +1,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; +import type { JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function apiTemplateIoApiRequest( @@ -39,11 +40,11 @@ export async function apiTemplateIoApiRequest( options, ); if (response.status === 'error') { - throw new NodeApiError(this.getNode(), response.message); + throw new NodeApiError(this.getNode(), response.message as JsonObject); } return response; } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Asana/Asana.node.ts b/packages/nodes-base/nodes/Asana/Asana.node.ts index 9cd61f28a2..3029c56f1a 100644 --- a/packages/nodes-base/nodes/Asana/Asana.node.ts +++ b/packages/nodes-base/nodes/Asana/Asana.node.ts @@ -8,6 +8,7 @@ import type { INodePropertyOptions, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -1691,7 +1692,9 @@ export class Asana implements INodeType { const responseData = await asanaApiRequest.call(this, 'GET', endpoint, {}); if (responseData.data === undefined) { - throw new NodeApiError(this.getNode(), responseData, { message: 'No data got returned' }); + throw new NodeApiError(this.getNode(), responseData as JsonObject, { + message: 'No data got returned', + }); } const returnData: INodePropertyOptions[] = []; @@ -1730,7 +1733,9 @@ export class Asana implements INodeType { const responseData = await asanaApiRequest.call(this, 'GET', endpoint, {}); if (responseData.data === undefined) { - throw new NodeApiError(this.getNode(), responseData, { message: 'No data got returned' }); + throw new NodeApiError(this.getNode(), responseData as JsonObject, { + message: 'No data got returned', + }); } const returnData: INodePropertyOptions[] = []; @@ -1818,7 +1823,7 @@ export class Asana implements INodeType { try { taskData = await asanaApiRequest.call(this, 'GET', `/tasks/${taskId}`, {}); } catch (error) { - throw new NodeApiError(this.getNode(), error, { + throw new NodeApiError(this.getNode(), error as JsonObject, { message: `Could not find task with id "${taskId}" so tags could not be loaded.`, }); } @@ -1827,7 +1832,9 @@ export class Asana implements INodeType { const responseData = await asanaApiRequest.call(this, 'GET', endpoint, {}, { workspace }); if (responseData.data === undefined) { - throw new NodeApiError(this.getNode(), responseData, { message: 'No data got returned' }); + throw new NodeApiError(this.getNode(), responseData as JsonObject, { + message: 'No data got returned', + }); } const returnData: INodePropertyOptions[] = []; @@ -1863,7 +1870,9 @@ export class Asana implements INodeType { const responseData = await asanaApiRequest.call(this, 'GET', endpoint, {}); if (responseData.data === undefined) { - throw new NodeApiError(this.getNode(), responseData, { message: 'No data got returned' }); + throw new NodeApiError(this.getNode(), responseData as JsonObject, { + message: 'No data got returned', + }); } const returnData: INodePropertyOptions[] = []; @@ -2400,9 +2409,12 @@ export class Asana implements INodeType { } returnData.push( - ...this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { - itemData: { item: i }, - }), + ...this.helpers.constructExecutionMetaData( + this.helpers.returnJsonArray(responseData as IDataObject[]), + { + itemData: { item: i }, + }, + ), ); } catch (error) { if (this.continueOnFail()) { diff --git a/packages/nodes-base/nodes/Asana/AsanaTrigger.node.ts b/packages/nodes-base/nodes/Asana/AsanaTrigger.node.ts index dc173916bd..f85f6f7c0a 100644 --- a/packages/nodes-base/nodes/Asana/AsanaTrigger.node.ts +++ b/packages/nodes-base/nodes/Asana/AsanaTrigger.node.ts @@ -240,7 +240,7 @@ export class AsanaTrigger implements INodeType { // } return { - workflowData: [this.helpers.returnJsonArray(req.body.events)], + workflowData: [this.helpers.returnJsonArray(req.body.events as IDataObject[])], }; } } diff --git a/packages/nodes-base/nodes/Asana/GenericFunctions.ts b/packages/nodes-base/nodes/Asana/GenericFunctions.ts index 5b92e21917..519dc6a338 100644 --- a/packages/nodes-base/nodes/Asana/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Asana/GenericFunctions.ts @@ -51,9 +51,16 @@ export async function asanaApiRequestAllItems( query.limit = 100; do { - responseData = await asanaApiRequest.call(this, method, endpoint, body, query, uri); + responseData = await asanaApiRequest.call( + this, + method, + endpoint, + body as IDataObject, + query, + uri, + ); uri = get(responseData, 'next_page.uri'); - returnData.push.apply(returnData, responseData.data); + returnData.push.apply(returnData, responseData.data as IDataObject[]); } while (responseData.next_page !== null); return returnData; diff --git a/packages/nodes-base/nodes/Automizy/Automizy.node.ts b/packages/nodes-base/nodes/Automizy/Automizy.node.ts index 68dff56343..9e77f51419 100644 --- a/packages/nodes-base/nodes/Automizy/Automizy.node.ts +++ b/packages/nodes-base/nodes/Automizy/Automizy.node.ts @@ -164,7 +164,7 @@ export class Automizy implements INodeType { ); responseData = responseData.contacts; responseData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); } @@ -186,7 +186,7 @@ export class Automizy implements INodeType { responseData = await automizyApiRequest.call(this, 'GET', `/contacts/${contactId}`); responseData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); } @@ -228,7 +228,7 @@ export class Automizy implements INodeType { } responseData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); } @@ -258,7 +258,7 @@ export class Automizy implements INodeType { responseData = await automizyApiRequest.call(this, 'PATCH', `/contacts/${email}`, body); responseData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); } @@ -274,7 +274,7 @@ export class Automizy implements INodeType { responseData = await automizyApiRequest.call(this, 'POST', '/smart-lists', body); responseData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); } @@ -296,7 +296,7 @@ export class Automizy implements INodeType { responseData = await automizyApiRequest.call(this, 'GET', `/smart-lists/${listId}`); responseData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); } @@ -332,7 +332,7 @@ export class Automizy implements INodeType { } responseData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); } @@ -354,7 +354,7 @@ export class Automizy implements INodeType { ); responseData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); } diff --git a/packages/nodes-base/nodes/Automizy/GenericFunctions.ts b/packages/nodes-base/nodes/Automizy/GenericFunctions.ts index d4d6e6f751..7fd08548a1 100644 --- a/packages/nodes-base/nodes/Automizy/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Automizy/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function automizyApiRequest( @@ -28,7 +28,7 @@ export async function automizyApiRequest( }; try { - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } if (Object.keys(qs).length === 0) { @@ -40,7 +40,7 @@ export async function automizyApiRequest( //@ts-ignore return await this.helpers.request.call(this, options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -61,7 +61,7 @@ export async function automizyApiRequestAllItems( do { responseData = await automizyApiRequest.call(this, method, endpoint, body, query); query.page++; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.pageCount !== responseData.page); return returnData; diff --git a/packages/nodes-base/nodes/Autopilot/Autopilot.node.ts b/packages/nodes-base/nodes/Autopilot/Autopilot.node.ts index 4250c87bab..3d17b80198 100644 --- a/packages/nodes-base/nodes/Autopilot/Autopilot.node.ts +++ b/packages/nodes-base/nodes/Autopilot/Autopilot.node.ts @@ -300,7 +300,7 @@ export class Autopilot implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Autopilot/AutopilotTrigger.node.ts b/packages/nodes-base/nodes/Autopilot/AutopilotTrigger.node.ts index afeac94955..2bb4a13697 100644 --- a/packages/nodes-base/nodes/Autopilot/AutopilotTrigger.node.ts +++ b/packages/nodes-base/nodes/Autopilot/AutopilotTrigger.node.ts @@ -124,7 +124,7 @@ export class AutopilotTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const req = this.getRequestObject(); return { - workflowData: [this.helpers.returnJsonArray(req.body)], + workflowData: [this.helpers.returnJsonArray(req.body as IDataObject[])], }; } } diff --git a/packages/nodes-base/nodes/Autopilot/GenericFunctions.ts b/packages/nodes-base/nodes/Autopilot/GenericFunctions.ts index 87616ade6e..bd73190879 100644 --- a/packages/nodes-base/nodes/Autopilot/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Autopilot/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject, IHookFunctions, IWebhookFunctions } from 'n8n-workflow'; +import type { IDataObject, IHookFunctions, IWebhookFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function autopilotApiRequest( @@ -32,7 +32,7 @@ export async function autopilotApiRequest( uri: uri || `${endpoint}${resource}`, json: true, }; - if (!Object.keys(body).length) { + if (!Object.keys(body as IDataObject).length) { delete options.body; } if (!Object.keys(query).length) { @@ -42,7 +42,7 @@ export async function autopilotApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -64,7 +64,7 @@ export async function autopilotApiRequestAllItems( do { responseData = await autopilotApiRequest.call(this, method, endpoint, body, query); endpoint = `${base}/${responseData.bookmark}`; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); if (query.limit && returnData.length >= query.limit && !returnAll) { return returnData; } diff --git a/packages/nodes-base/nodes/Aws/AwsLambda.node.ts b/packages/nodes-base/nodes/Aws/AwsLambda.node.ts index d53f5cf149..a7e3160741 100644 --- a/packages/nodes-base/nodes/Aws/AwsLambda.node.ts +++ b/packages/nodes-base/nodes/Aws/AwsLambda.node.ts @@ -193,7 +193,7 @@ export class AwsLambda implements INodeType { _errorMessage += `\n\nStack trace:\n${responseData.stackTrace}`; } - throw new NodeApiError(this.getNode(), responseData); + throw new NodeApiError(this.getNode(), responseData as JsonObject); } else { returnData.push({ result: responseData, diff --git a/packages/nodes-base/nodes/Aws/CertificateManager/AwsCertificateManager.node.ts b/packages/nodes-base/nodes/Aws/CertificateManager/AwsCertificateManager.node.ts index 1b1833a093..39397a999b 100644 --- a/packages/nodes-base/nodes/Aws/CertificateManager/AwsCertificateManager.node.ts +++ b/packages/nodes-base/nodes/Aws/CertificateManager/AwsCertificateManager.node.ts @@ -216,7 +216,7 @@ export class AwsCertificateManager implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Aws/CertificateManager/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/CertificateManager/GenericFunctions.ts index fe6a7de806..ec178291b3 100644 --- a/packages/nodes-base/nodes/Aws/CertificateManager/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/CertificateManager/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { IWebhookFunctions, } from 'n8n-core'; -import type { IDataObject, IHttpRequestOptions } from 'n8n-workflow'; +import type { IDataObject, IHttpRequestOptions, JsonObject } from 'n8n-workflow'; import { jsonParse, NodeApiError } from 'n8n-workflow'; export async function awsApiRequest( @@ -37,7 +37,7 @@ export async function awsApiRequest( try { return await this.helpers.requestWithAuthentication.call(this, 'aws', requestOptions); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -52,7 +52,7 @@ export async function awsApiRequestREST( ): Promise { const response = await awsApiRequest.call(this, service, method, path, body, query, headers); try { - return JSON.parse(response); + return JSON.parse(response as string); } catch (e) { return response; } @@ -80,7 +80,7 @@ export async function awsApiRequestAllItems( }); data.NextToken = responseData.NextToken; } - returnData.push.apply(returnData, get(responseData, propertyName)); + returnData.push.apply(returnData, get(responseData, propertyName) as IDataObject[]); } while (responseData.NextToken !== undefined); return returnData; diff --git a/packages/nodes-base/nodes/Aws/Comprehend/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/Comprehend/GenericFunctions.ts index 76f88c9825..f8742dc522 100644 --- a/packages/nodes-base/nodes/Aws/Comprehend/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/Comprehend/GenericFunctions.ts @@ -43,7 +43,7 @@ export async function awsApiRequestREST( ): Promise { const response = await awsApiRequest.call(this, service, method, path, body, headers); try { - return JSON.parse(response); + return JSON.parse(response as string); } catch (error) { return response; } @@ -60,7 +60,7 @@ export async function awsApiRequestSOAP( const response = await awsApiRequest.call(this, service, method, path, body, headers); try { return await new Promise((resolve, reject) => { - parseString(response, { explicitArray: false }, (err, data) => { + parseString(response as string, { explicitArray: false }, (err, data) => { if (err) { return reject(err); } diff --git a/packages/nodes-base/nodes/Aws/DynamoDB/AwsDynamoDB.node.ts b/packages/nodes-base/nodes/Aws/DynamoDB/AwsDynamoDB.node.ts index 87e8d6d9e6..39158c26ea 100644 --- a/packages/nodes-base/nodes/Aws/DynamoDB/AwsDynamoDB.node.ts +++ b/packages/nodes-base/nodes/Aws/DynamoDB/AwsDynamoDB.node.ts @@ -17,6 +17,7 @@ import { itemFields, itemOperations } from './ItemDescription'; import type { FieldsUiValues, IAttributeNameUi, + IAttributeValue, IAttributeValueUi, IRequestBody, PutItemUi, @@ -229,10 +230,10 @@ export class AwsDynamoDB implements INodeType { responseData = await awsApiRequest.call(this, 'dynamodb', 'POST', '/', body, headers); - if (!Object.keys(responseData).length) { + if (!Object.keys(responseData as IDataObject).length) { responseData = { success: true }; } else if (simple) { - responseData = decodeItem(responseData.Attributes); + responseData = decodeItem(responseData.Attributes as IAttributeValue); } } else if (operation === 'get') { // ---------------------------------- @@ -293,7 +294,7 @@ export class AwsDynamoDB implements INodeType { responseData = responseData.Item; if (simple && responseData) { - responseData = decodeItem(responseData); + responseData = decodeItem(responseData as IAttributeValue); } } else if (operation === 'getAll') { // ---------------------------------- @@ -392,7 +393,7 @@ export class AwsDynamoDB implements INodeType { } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Aws/DynamoDB/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/DynamoDB/GenericFunctions.ts index c0fd7d04d9..b23784527c 100644 --- a/packages/nodes-base/nodes/Aws/DynamoDB/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/DynamoDB/GenericFunctions.ts @@ -33,7 +33,7 @@ export async function awsApiRequest( try { return JSON.parse( - await this.helpers.requestWithAuthentication.call(this, 'aws', requestOptions), + (await this.helpers.requestWithAuthentication.call(this, 'aws', requestOptions)) as string, ); } catch (error) { const errorMessage = @@ -72,7 +72,7 @@ export async function awsApiRequestAllItems( if (responseData.LastEvaluatedKey) { body!.ExclusiveStartKey = responseData.LastEvaluatedKey; } - returnData.push(...responseData.Items); + returnData.push(...(responseData.Items as IDataObject[])); } while (responseData.LastEvaluatedKey !== undefined); return returnData; diff --git a/packages/nodes-base/nodes/Aws/DynamoDB/utils.ts b/packages/nodes-base/nodes/Aws/DynamoDB/utils.ts index 3a85e46c81..a55e9ff46d 100644 --- a/packages/nodes-base/nodes/Aws/DynamoDB/utils.ts +++ b/packages/nodes-base/nodes/Aws/DynamoDB/utils.ts @@ -96,7 +96,7 @@ function decodeAttribute(type: AttributeValueType, attribute: string | IAttribut export function validateJSON(input: any): object { try { - return JSON.parse(input); + return JSON.parse(input as string); } catch (error) { throw new Error('Items must be a valid JSON'); } diff --git a/packages/nodes-base/nodes/Aws/ELB/AwsElb.node.ts b/packages/nodes-base/nodes/Aws/ELB/AwsElb.node.ts index 6382af1e5f..bacedf2714 100644 --- a/packages/nodes-base/nodes/Aws/ELB/AwsElb.node.ts +++ b/packages/nodes-base/nodes/Aws/ELB/AwsElb.node.ts @@ -443,9 +443,12 @@ export class AwsElb implements INodeType { } returnData.push( - ...this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { - itemData: { item: i }, - }), + ...this.helpers.constructExecutionMetaData( + this.helpers.returnJsonArray(responseData as IDataObject), + { + itemData: { item: i }, + }, + ), ); } catch (error) { if (this.continueOnFail()) { diff --git a/packages/nodes-base/nodes/Aws/ELB/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/ELB/GenericFunctions.ts index dd9835b220..e2f5537e51 100644 --- a/packages/nodes-base/nodes/Aws/ELB/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/ELB/GenericFunctions.ts @@ -68,7 +68,7 @@ export async function awsApiRequestREST( region, ); try { - return JSON.parse(response); + return JSON.parse(response as string); } catch (e) { return response; } @@ -98,7 +98,7 @@ export async function awsApiRequestSOAP( ); try { return await new Promise((resolve, reject) => { - parseString(response, { explicitArray: false }, (err, data) => { + parseString(response as string, { explicitArray: false }, (err, data) => { if (err) { return reject(err); } @@ -149,9 +149,9 @@ export async function awsApiRequestSOAPAllItems( } if (get(responseData, propertyName)) { if (Array.isArray(get(responseData, propertyName))) { - returnData.push.apply(returnData, get(responseData, propertyName)); + returnData.push.apply(returnData, get(responseData, propertyName) as IDataObject[]); } else { - returnData.push(get(responseData, propertyName)); + returnData.push(get(responseData, propertyName) as IDataObject); } } } while ( diff --git a/packages/nodes-base/nodes/Aws/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/GenericFunctions.ts index 4ac8db754d..bd5d124ea3 100644 --- a/packages/nodes-base/nodes/Aws/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { IWebhookFunctions, } from 'n8n-core'; -import type { IHttpRequestOptions } from 'n8n-workflow'; +import type { IHttpRequestOptions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function awsApiRequest( @@ -34,7 +34,7 @@ export async function awsApiRequest( try { return await this.helpers.requestWithAuthentication.call(this, 'aws', requestOptions); } catch (error) { - throw new NodeApiError(this.getNode(), error, { parseXml: true }); + throw new NodeApiError(this.getNode(), error as JsonObject, { parseXml: true }); } } @@ -48,7 +48,7 @@ export async function awsApiRequestREST( ): Promise { const response = await awsApiRequest.call(this, service, method, path, body, headers); try { - return JSON.parse(response); + return JSON.parse(response as string); } catch (error) { return response; } @@ -65,7 +65,7 @@ export async function awsApiRequestSOAP( const response = await awsApiRequest.call(this, service, method, path, body, headers); try { return await new Promise((resolve, reject) => { - parseXml(response, { explicitArray: false }, (err, data) => { + parseXml(response as string, { explicitArray: false }, (err, data) => { if (err) { return reject(err); } diff --git a/packages/nodes-base/nodes/Aws/Rekognition/AwsRekognition.node.ts b/packages/nodes-base/nodes/Aws/Rekognition/AwsRekognition.node.ts index 0e63a26fd5..fa028bfcd3 100644 --- a/packages/nodes-base/nodes/Aws/Rekognition/AwsRekognition.node.ts +++ b/packages/nodes-base/nodes/Aws/Rekognition/AwsRekognition.node.ts @@ -472,7 +472,7 @@ export class AwsRekognition implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Aws/Rekognition/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/Rekognition/GenericFunctions.ts index e608da4c67..482dd6b723 100644 --- a/packages/nodes-base/nodes/Aws/Rekognition/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/Rekognition/GenericFunctions.ts @@ -67,7 +67,7 @@ export async function awsApiRequestREST( region, ); try { - return JSON.parse(response); + return JSON.parse(response as string); } catch (error) { return response; } @@ -97,7 +97,7 @@ export async function awsApiRequestSOAP( ); try { return await new Promise((resolve, reject) => { - parseString(response, { explicitArray: false }, (err, data) => { + parseString(response as string, { explicitArray: false }, (err, data) => { if (err) { return reject(err); } @@ -147,9 +147,9 @@ export async function awsApiRequestSOAPAllItems( } if (get(responseData, propertyName)) { if (Array.isArray(get(responseData, propertyName))) { - returnData.push.apply(returnData, get(responseData, propertyName)); + returnData.push.apply(returnData, get(responseData, propertyName) as IDataObject[]); } else { - returnData.push(get(responseData, propertyName)); + returnData.push(get(responseData, propertyName) as IDataObject); } } if (query.limit && query.limit <= returnData.length) { diff --git a/packages/nodes-base/nodes/Aws/S3/AwsS3.node.ts b/packages/nodes-base/nodes/Aws/S3/AwsS3.node.ts index d5c368b1c6..f34b1642ae 100644 --- a/packages/nodes-base/nodes/Aws/S3/AwsS3.node.ts +++ b/packages/nodes-base/nodes/Aws/S3/AwsS3.node.ts @@ -201,7 +201,7 @@ export class AwsS3 implements INodeType { responseData = responseData.slice(0, qs.limit); } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -274,7 +274,7 @@ export class AwsS3 implements INodeType { responseData = responseData.ListBucketResult.Contents; } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -314,7 +314,7 @@ export class AwsS3 implements INodeType { qs, headers, {}, - region, + region as string, ); const executionData = this.helpers.constructExecutionMetaData( this.helpers.returnJsonArray({ success: true }), @@ -343,7 +343,7 @@ export class AwsS3 implements INodeType { { 'list-type': 2, prefix: folderKey }, {}, {}, - region, + region as string, ); // folder empty then just delete it @@ -357,7 +357,7 @@ export class AwsS3 implements INodeType { qs, {}, {}, - region, + region as string, ); responseData = { deleted: [{ Key: folderKey }] }; @@ -395,7 +395,7 @@ export class AwsS3 implements INodeType { { delete: '' }, headers, {}, - region, + region as string, ); responseData = { deleted: responseData.DeleteResult.Deleted }; @@ -439,7 +439,7 @@ export class AwsS3 implements INodeType { qs, {}, {}, - region, + region as string, ); } else { qs.limit = this.getNodeParameter('limit', 0); @@ -453,7 +453,7 @@ export class AwsS3 implements INodeType { qs, {}, {}, - region, + region as string, ); } if (Array.isArray(responseData)) { @@ -574,10 +574,10 @@ export class AwsS3 implements INodeType { qs, headers, {}, - region, + region as string, ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData.CopyObjectResult), + this.helpers.returnJsonArray(responseData.CopyObjectResult as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -612,7 +612,7 @@ export class AwsS3 implements INodeType { qs, {}, { encoding: null, resolveWithFullResponse: true }, - region, + region as string, ); let mimeType: string | undefined; @@ -671,7 +671,7 @@ export class AwsS3 implements INodeType { qs, {}, {}, - region, + region as string, ); const executionData = this.helpers.constructExecutionMetaData( this.helpers.returnJsonArray({ success: true }), @@ -714,7 +714,7 @@ export class AwsS3 implements INodeType { qs, {}, {}, - region, + region as string, ); } else { qs.limit = this.getNodeParameter('limit', 0); @@ -728,7 +728,7 @@ export class AwsS3 implements INodeType { qs, {}, {}, - region, + region as string, ); responseData = responseData.splice(0, qs.limit); } @@ -873,7 +873,7 @@ export class AwsS3 implements INodeType { qs, headers, {}, - region, + region as string, ); } else { const fileContent = this.getNodeParameter('fileContent', i) as string; @@ -893,7 +893,7 @@ export class AwsS3 implements INodeType { qs, headers, {}, - region, + region as string, ); } const executionData = this.helpers.constructExecutionMetaData( diff --git a/packages/nodes-base/nodes/Aws/S3/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/S3/GenericFunctions.ts index 34e39cf8c3..cd5556dfb1 100644 --- a/packages/nodes-base/nodes/Aws/S3/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/S3/GenericFunctions.ts @@ -65,7 +65,7 @@ export async function awsApiRequestREST( region, ); try { - return JSON.parse(response); + return JSON.parse(response as string); } catch (error) { return response; } @@ -95,7 +95,7 @@ export async function awsApiRequestSOAP( ); try { return await new Promise((resolve, reject) => { - parseString(response, { explicitArray: false }, (err, data) => { + parseString(response as string, { explicitArray: false }, (err, data) => { if (err) { return reject(err); } @@ -145,9 +145,9 @@ export async function awsApiRequestSOAPAllItems( } if (get(responseData, propertyName)) { if (Array.isArray(get(responseData, propertyName))) { - returnData.push.apply(returnData, get(responseData, propertyName)); + returnData.push.apply(returnData, get(responseData, propertyName) as IDataObject[]); } else { - returnData.push(get(responseData, propertyName)); + returnData.push(get(responseData, propertyName) as IDataObject); } } if (query.limit && query.limit <= returnData.length) { diff --git a/packages/nodes-base/nodes/Aws/SES/AwsSes.node.ts b/packages/nodes-base/nodes/Aws/SES/AwsSes.node.ts index 6cbe0158f6..aaf33419c4 100644 --- a/packages/nodes-base/nodes/Aws/SES/AwsSes.node.ts +++ b/packages/nodes-base/nodes/Aws/SES/AwsSes.node.ts @@ -1282,7 +1282,7 @@ export class AwsSes implements INodeType { } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Aws/SES/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/SES/GenericFunctions.ts index 62321049dc..82ced08044 100644 --- a/packages/nodes-base/nodes/Aws/SES/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/SES/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { IWebhookFunctions, } from 'n8n-core'; -import type { IDataObject, IHttpRequestOptions } from 'n8n-workflow'; +import type { IDataObject, IHttpRequestOptions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import get from 'lodash.get'; @@ -37,7 +37,7 @@ export async function awsApiRequest( try { return await this.helpers.requestWithAuthentication.call(this, 'aws', requestOptions); } catch (error) { - throw new NodeApiError(this.getNode(), error, { parseXml: true }); + throw new NodeApiError(this.getNode(), error as JsonObject, { parseXml: true }); } } @@ -51,7 +51,7 @@ export async function awsApiRequestREST( ): Promise { const response = await awsApiRequest.call(this, service, method, path, body, headers); try { - return JSON.parse(response); + return JSON.parse(response as string); } catch (error) { return response; } @@ -68,7 +68,7 @@ export async function awsApiRequestSOAP( const response = await awsApiRequest.call(this, service, method, path, body, headers); try { return await new Promise((resolve, reject) => { - parseString(response, { explicitArray: false }, (err, data) => { + parseString(response as string, { explicitArray: false }, (err, data) => { if (err) { return reject(err); } @@ -109,9 +109,9 @@ export async function awsApiRequestSOAPAllItems( } if (get(responseData, propertyName)) { if (Array.isArray(get(responseData, propertyName))) { - returnData.push.apply(returnData, get(responseData, propertyName)); + returnData.push.apply(returnData, get(responseData, propertyName) as IDataObject[]); } else { - returnData.push(get(responseData, propertyName)); + returnData.push(get(responseData, propertyName) as IDataObject); } } } while ( diff --git a/packages/nodes-base/nodes/Aws/SQS/AwsSqs.node.ts b/packages/nodes-base/nodes/Aws/SQS/AwsSqs.node.ts index 2195ba76d0..436615a406 100644 --- a/packages/nodes-base/nodes/Aws/SQS/AwsSqs.node.ts +++ b/packages/nodes-base/nodes/Aws/SQS/AwsSqs.node.ts @@ -8,6 +8,7 @@ import type { INodePropertyOptions, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -255,7 +256,7 @@ export class AwsSqs implements INodeType { // loads first 1000 queues from SQS data = await awsApiRequestSOAP.call(this, 'sqs', 'GET', `?${params.join('&')}`); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } let queues = data.ListQueuesResponse.ListQueuesResult.QueueUrl; @@ -385,7 +386,7 @@ export class AwsSqs implements INodeType { `${queuePath}?${params.join('&')}`, ); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } const result = responseData.SendMessageResponse.SendMessageResult; diff --git a/packages/nodes-base/nodes/Aws/Textract/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/Textract/GenericFunctions.ts index 1adb59bd68..3d49d2d1b0 100644 --- a/packages/nodes-base/nodes/Aws/Textract/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/Textract/GenericFunctions.ts @@ -18,6 +18,7 @@ import type { ICredentialDataDecryptedObject, ICredentialTestFunctions, IHttpRequestOptions, + JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -64,15 +65,15 @@ export async function awsApiRequest( if (error?.response?.data || error?.response?.body) { const errorMessage = error?.response?.data || error?.response?.body; if (errorMessage.includes('AccessDeniedException')) { - const user = JSON.parse(errorMessage).Message.split(' ')[1]; - throw new NodeApiError(this.getNode(), error, { + const user = JSON.parse(errorMessage as string).Message.split(' ')[1]; + throw new NodeApiError(this.getNode(), error as JsonObject, { message: 'Unauthorized — please check your AWS policy configuration', description: `Make sure an identity-based policy allows user ${user} to perform textract:AnalyzeExpense`, }); } } - throw new NodeApiError(this.getNode(), error); // no XML parsing needed + throw new NodeApiError(this.getNode(), error as JsonObject); // no XML parsing needed } } @@ -86,7 +87,7 @@ export async function awsApiRequestREST( ): Promise { const response = await awsApiRequest.call(this, service, method, path, body, headers); try { - return JSON.parse(response); + return JSON.parse(response as string); } catch (error) { return response; } @@ -103,7 +104,7 @@ export async function awsApiRequestSOAP( const response = await awsApiRequest.call(this, service, method, path, body, headers); try { return await new Promise((resolve, reject) => { - parseString(response, { explicitArray: false }, (err, data) => { + parseString(response as string, { explicitArray: false }, (err, data) => { if (err) { return reject(err); } @@ -177,7 +178,7 @@ export async function validateCredentials( const response = await this.helpers.request(options); return new Promise((resolve, reject) => { - parseString(response, { explicitArray: false }, (err, data) => { + parseString(response as string, { explicitArray: false }, (err, data) => { if (err) { return reject(err); } diff --git a/packages/nodes-base/nodes/Aws/Transcribe/GenericFunctions.ts b/packages/nodes-base/nodes/Aws/Transcribe/GenericFunctions.ts index a0fc777f52..3dff43e92f 100644 --- a/packages/nodes-base/nodes/Aws/Transcribe/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Aws/Transcribe/GenericFunctions.ts @@ -12,7 +12,7 @@ import type { IWebhookFunctions, } from 'n8n-core'; -import type { ICredentialDataDecryptedObject, IDataObject } from 'n8n-workflow'; +import type { ICredentialDataDecryptedObject, IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import get from 'lodash.get'; @@ -67,7 +67,7 @@ export async function awsApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); // no XML parsing needed + throw new NodeApiError(this.getNode(), error as JsonObject); // no XML parsing needed } } @@ -81,7 +81,7 @@ export async function awsApiRequestREST( ): Promise { const response = await awsApiRequest.call(this, service, method, path, body, headers); try { - return JSON.parse(response); + return JSON.parse(response as string); } catch (error) { return response; } @@ -116,9 +116,9 @@ export async function awsApiRequestRESTAllItems( } if (get(responseData, propertyName)) { if (Array.isArray(get(responseData, propertyName))) { - returnData.push.apply(returnData, get(responseData, propertyName)); + returnData.push.apply(returnData, get(responseData, propertyName) as IDataObject[]); } else { - returnData.push(get(responseData, propertyName)); + returnData.push(get(responseData, propertyName) as IDataObject); } } } while ( diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/companyReport/get/execute.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/companyReport/get/execute.ts index 32e750949b..653756c1ca 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/companyReport/get/execute.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/companyReport/get/execute.ts @@ -26,7 +26,7 @@ export async function get(this: IExecuteFunctions, index: number) { {}, { resolveWithFullResponse: true }, ); - return this.helpers.returnJsonArray(responseData.body); + return this.helpers.returnJsonArray(responseData.body as IDataObject); } const output: string = this.getNodeParameter('output', index) as string; @@ -40,7 +40,7 @@ export async function get(this: IExecuteFunctions, index: number) { mimeType = mimeType ? mimeType.split(';').find((value) => value.includes('/')) : undefined; const contentDisposition = response.headers['content-disposition']; const fileNameRegex = /(?<=filename=").*\b/; - const match = fileNameRegex.exec(contentDisposition); + const match = fileNameRegex.exec(contentDisposition as string); let fileName = ''; // file name was found diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/get/execute.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/get/execute.ts index f91534e76e..f434a06174 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employee/get/execute.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employee/get/execute.ts @@ -31,5 +31,5 @@ export async function get(this: IExecuteFunctions, index: number): Promise limit) { - return this.helpers.returnJsonArray(responseData.employees.slice(0, limit)); + return this.helpers.returnJsonArray(responseData.employees.slice(0, limit) as IDataObject[]); } //return all result - return this.helpers.returnJsonArray(responseData.employees); + return this.helpers.returnJsonArray(responseData.employees as IDataObject[]); } diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/download/execute.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/download/execute.ts index 49625eb6a3..71cd2a6ceb 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/download/execute.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/download/execute.ts @@ -27,7 +27,7 @@ export async function download(this: IExecuteFunctions, index: number) { mimeType = mimeType ? mimeType.split(';').find((value) => value.includes('/')) : undefined; const contentDisposition = response.headers['content-disposition']; const fileNameRegex = /(?<=filename=").*\b/; - const match = fileNameRegex.exec(contentDisposition); + const match = fileNameRegex.exec(contentDisposition as string); let fileName = ''; // file name was found diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/getAll/execute.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/getAll/execute.ts index ec8a82a060..64fe5fc066 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/getAll/execute.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/employeeDocument/getAll/execute.ts @@ -46,9 +46,9 @@ export async function getAll( //return limited result if (!returnAll && responseData.categories.length > limit) { - return this.helpers.returnJsonArray(responseData.categories.slice(0, limit)); + return this.helpers.returnJsonArray(responseData.categories.slice(0, limit) as IDataObject[]); } //return - return this.helpers.returnJsonArray(responseData.categories); + return this.helpers.returnJsonArray(responseData.categories as IDataObject[]); } diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/file/download/execute.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/file/download/execute.ts index 279034b020..8e9eef4a72 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/file/download/execute.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/file/download/execute.ts @@ -27,7 +27,7 @@ export async function download(this: IExecuteFunctions, index: number) { mimeType = mimeType ? mimeType.split(';').find((value) => value.includes('/')) : undefined; const contentDisposition = response.headers['content-disposition']; const fileNameRegex = /(?<=filename=").*\b/; - const match = fileNameRegex.exec(contentDisposition); + const match = fileNameRegex.exec(contentDisposition as string); let fileName = ''; // file name was found diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/file/getAll/execute.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/file/getAll/execute.ts index 74701ee4c2..944a39f553 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/file/getAll/execute.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/file/getAll/execute.ts @@ -41,9 +41,9 @@ export async function getAll( //return limited result if (!returnAll && responseData.categories.length > limit) { - return this.helpers.returnJsonArray(responseData.categories.slice(0, limit)); + return this.helpers.returnJsonArray(responseData.categories.slice(0, limit) as IDataObject[]); } //return - return this.helpers.returnJsonArray(responseData.categories); + return this.helpers.returnJsonArray(responseData.categories as IDataObject[]); } diff --git a/packages/nodes-base/nodes/BambooHr/v1/actions/router.ts b/packages/nodes-base/nodes/BambooHr/v1/actions/router.ts index af8368b329..55ce4f657b 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/actions/router.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/actions/router.ts @@ -1,3 +1,4 @@ +/* eslint-disable @typescript-eslint/no-unsafe-argument */ import type { IExecuteFunctions } from 'n8n-core'; import type { INodeExecutionData } from 'n8n-workflow'; diff --git a/packages/nodes-base/nodes/BambooHr/v1/transport/index.ts b/packages/nodes-base/nodes/BambooHr/v1/transport/index.ts index 3525037296..920718fb51 100644 --- a/packages/nodes-base/nodes/BambooHr/v1/transport/index.ts +++ b/packages/nodes-base/nodes/BambooHr/v1/transport/index.ts @@ -1,6 +1,6 @@ import type { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import type { OptionsWithUrl } from 'request'; @@ -55,6 +55,6 @@ export async function apiRequest( } catch (error) { const description = error?.response?.headers['x-bamboohr-error-messsage'] || ''; const message = error?.message || ''; - throw new NodeApiError(this.getNode(), error, { message, description }); + throw new NodeApiError(this.getNode(), error as JsonObject, { message, description }); } } diff --git a/packages/nodes-base/nodes/Bannerbear/Bannerbear.node.ts b/packages/nodes-base/nodes/Bannerbear/Bannerbear.node.ts index b57182572f..ebdb752e50 100644 --- a/packages/nodes-base/nodes/Bannerbear/Bannerbear.node.ts +++ b/packages/nodes-base/nodes/Bannerbear/Bannerbear.node.ts @@ -161,7 +161,7 @@ export class Bannerbear implements INodeType { }); }; - responseData = await promise(responseData.uid); + responseData = await promise(responseData.uid as string); } } //https://developers.bannerbear.com/#get-a-specific-image @@ -184,7 +184,7 @@ export class Bannerbear implements INodeType { if (Array.isArray(responseData)) { returnData.push.apply(returnData, responseData as IDataObject[]); } else { - returnData.push(responseData); + returnData.push(responseData as IDataObject); } } return [this.helpers.returnJsonArray(returnData)]; diff --git a/packages/nodes-base/nodes/Bannerbear/GenericFunctions.ts b/packages/nodes-base/nodes/Bannerbear/GenericFunctions.ts index f0e8a53adb..0934bf07a5 100644 --- a/packages/nodes-base/nodes/Bannerbear/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bannerbear/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject, IHookFunctions, IWebhookFunctions } from 'n8n-workflow'; +import type { IDataObject, IHookFunctions, IWebhookFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import { snakeCase } from 'change-case'; @@ -30,7 +30,7 @@ export async function bannerbearApiRequest( uri: uri || `https://api.bannerbear.com/v2${resource}`, json: true, }; - if (!Object.keys(body).length) { + if (!Object.keys(body as IDataObject).length) { delete options.form; } if (!Object.keys(query).length) { @@ -40,7 +40,7 @@ export async function bannerbearApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Baserow/Baserow.node.ts b/packages/nodes-base/nodes/Baserow/Baserow.node.ts index 5b7fa2eb46..0c84aa3f15 100644 --- a/packages/nodes-base/nodes/Baserow/Baserow.node.ts +++ b/packages/nodes-base/nodes/Baserow/Baserow.node.ts @@ -229,9 +229,9 @@ export class Baserow implements INodeType { const endpoint = `/api/database/rows/table/${tableId}/${rowId}/`; const row = await baserowApiRequest.call(this, 'GET', endpoint, jwtToken); - mapper.idsToNames(row); + mapper.idsToNames(row as Row); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(row), + this.helpers.returnJsonArray(row as Row), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -268,9 +268,9 @@ export class Baserow implements INodeType { const endpoint = `/api/database/rows/table/${tableId}/`; const createdRow = await baserowApiRequest.call(this, 'POST', endpoint, jwtToken, body); - mapper.idsToNames(createdRow); + mapper.idsToNames(createdRow as Row); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(createdRow), + this.helpers.returnJsonArray(createdRow as Row), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -309,9 +309,9 @@ export class Baserow implements INodeType { const endpoint = `/api/database/rows/table/${tableId}/${rowId}/`; const updatedRow = await baserowApiRequest.call(this, 'PATCH', endpoint, jwtToken, body); - mapper.idsToNames(updatedRow); + mapper.idsToNames(updatedRow as Row); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(updatedRow), + this.helpers.returnJsonArray(updatedRow as Row), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Baserow/GenericFunctions.ts b/packages/nodes-base/nodes/Baserow/GenericFunctions.ts index 79b1faf208..8b1c5e1f22 100644 --- a/packages/nodes-base/nodes/Baserow/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Baserow/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { IExecuteFunctions } from 'n8n-core'; import type { OptionsWithUri } from 'request'; -import type { IDataObject, ILoadOptionsFunctions } from 'n8n-workflow'; +import type { IDataObject, ILoadOptionsFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import type { Accumulator, BaserowCredentials, LoadedResource } from './types'; @@ -42,7 +42,7 @@ export async function baserowApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -68,7 +68,7 @@ export async function baserowApiRequestAllItems( do { responseData = await baserowApiRequest.call(this, method, endpoint, jwtToken, body, qs); - returnData.push(...responseData.results); + returnData.push(...(responseData.results as IDataObject[])); if (!returnAll && returnData.length > limit) { return returnData.slice(0, limit); @@ -101,7 +101,7 @@ export async function getJwtToken( const { token } = (await this.helpers.request(options)) as { token: string }; return token; } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Beeminder/Beeminder.node.ts b/packages/nodes-base/nodes/Beeminder/Beeminder.node.ts index fa74f9f547..697022c75e 100644 --- a/packages/nodes-base/nodes/Beeminder/Beeminder.node.ts +++ b/packages/nodes-base/nodes/Beeminder/Beeminder.node.ts @@ -318,7 +318,7 @@ export class Beeminder implements INodeType { } results = await createDatapoint.call(this, data); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(results), + this.helpers.returnJsonArray(results as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -336,7 +336,7 @@ export class Beeminder implements INodeType { results = await getAllDatapoints.call(this, data); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(results), + this.helpers.returnJsonArray(results as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -353,7 +353,7 @@ export class Beeminder implements INodeType { } results = await updateDatapoint.call(this, data); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(results), + this.helpers.returnJsonArray(results as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -365,7 +365,7 @@ export class Beeminder implements INodeType { }; results = await deleteDatapoint.call(this, data); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(results), + this.helpers.returnJsonArray(results as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Beeminder/GenericFunctions.ts b/packages/nodes-base/nodes/Beeminder/GenericFunctions.ts index 99e36be756..7cd7b31e56 100644 --- a/packages/nodes-base/nodes/Beeminder/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Beeminder/GenericFunctions.ts @@ -22,7 +22,7 @@ export async function beeminderApiRequest( json: true, }; - if (!Object.keys(body).length) { + if (!Object.keys(body as IDataObject).length) { delete options.body; } @@ -48,7 +48,7 @@ export async function beeminderApiRequestAllItems( do { responseData = await beeminderApiRequest.call(this, method, endpoint, body, query); query.page++; - returnData.push.apply(returnData, responseData); + returnData.push.apply(returnData, responseData as IDataObject[]); } while (responseData.length !== 0); return returnData; diff --git a/packages/nodes-base/nodes/Bitbucket/BitbucketTrigger.node.ts b/packages/nodes-base/nodes/Bitbucket/BitbucketTrigger.node.ts index afa3ed7604..69109f9832 100644 --- a/packages/nodes-base/nodes/Bitbucket/BitbucketTrigger.node.ts +++ b/packages/nodes-base/nodes/Bitbucket/BitbucketTrigger.node.ts @@ -329,7 +329,7 @@ export class BitbucketTrigger implements INodeType { return {}; } return { - workflowData: [this.helpers.returnJsonArray(req.body)], + workflowData: [this.helpers.returnJsonArray(req.body as IDataObject[])], }; } } diff --git a/packages/nodes-base/nodes/Bitbucket/GenericFunctions.ts b/packages/nodes-base/nodes/Bitbucket/GenericFunctions.ts index 62f4b37f1f..0f9ce524fb 100644 --- a/packages/nodes-base/nodes/Bitbucket/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bitbucket/GenericFunctions.ts @@ -5,7 +5,7 @@ import type { IHookFunctions, ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function bitbucketApiRequest( @@ -31,14 +31,14 @@ export async function bitbucketApiRequest( json: true, }; options = Object.assign({}, options, option); - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -64,7 +64,7 @@ export async function bitbucketApiRequestAllItems( do { responseData = await bitbucketApiRequest.call(this, method, resource, body, query, uri); uri = responseData.next; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.next !== undefined); return returnData; diff --git a/packages/nodes-base/nodes/Bitly/Bitly.node.ts b/packages/nodes-base/nodes/Bitly/Bitly.node.ts index 87d7d51887..887e099b6b 100644 --- a/packages/nodes-base/nodes/Bitly/Bitly.node.ts +++ b/packages/nodes-base/nodes/Bitly/Bitly.node.ts @@ -207,7 +207,7 @@ export class Bitly implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Bitly/GenericFunctions.ts b/packages/nodes-base/nodes/Bitly/GenericFunctions.ts index fd5960a62c..067eb40615 100644 --- a/packages/nodes-base/nodes/Bitly/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bitly/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function bitlyApiRequest( @@ -30,7 +30,7 @@ export async function bitlyApiRequest( json: true, }; options = Object.assign({}, options, option); - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } @@ -46,7 +46,7 @@ export async function bitlyApiRequest( }); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -71,7 +71,7 @@ export async function bitlyApiRequestAllItems( do { responseData = await bitlyApiRequest.call(this, method, resource, body, query, uri); - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); if (responseData.pagination?.next) { uri = responseData.pagination.next; } diff --git a/packages/nodes-base/nodes/Bitwarden/Bitwarden.node.ts b/packages/nodes-base/nodes/Bitwarden/Bitwarden.node.ts index c2f2467b63..3988a47bbc 100644 --- a/packages/nodes-base/nodes/Bitwarden/Bitwarden.node.ts +++ b/packages/nodes-base/nodes/Bitwarden/Bitwarden.node.ts @@ -147,7 +147,7 @@ export class Bitwarden implements INodeType { const endpoint = `/public/collections/${id}`; responseData = await bitwardenApiRequest.call(this, 'GET', endpoint, {}, {}); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -160,7 +160,7 @@ export class Bitwarden implements INodeType { const endpoint = '/public/collections'; responseData = await handleGetAll.call(this, i, 'GET', endpoint, {}, {}); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -199,7 +199,7 @@ export class Bitwarden implements INodeType { const endpoint = `/public/collections/${id}`; responseData = await bitwardenApiRequest.call(this, 'PUT', endpoint, {}, body); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -220,7 +220,7 @@ export class Bitwarden implements INodeType { const endpoint = '/public/events'; responseData = await handleGetAll.call(this, i, 'GET', endpoint, qs, {}); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -260,7 +260,7 @@ export class Bitwarden implements INodeType { const endpoint = '/public/groups'; responseData = await bitwardenApiRequest.call(this, 'POST', endpoint, {}, body); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -288,7 +288,7 @@ export class Bitwarden implements INodeType { const endpoint = `/public/groups/${id}`; responseData = await bitwardenApiRequest.call(this, 'GET', endpoint, {}, {}); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -301,7 +301,7 @@ export class Bitwarden implements INodeType { const endpoint = '/public/groups'; responseData = await handleGetAll.call(this, i, 'GET', endpoint, {}, {}); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -316,7 +316,7 @@ export class Bitwarden implements INodeType { responseData = await bitwardenApiRequest.call(this, 'GET', endpoint, {}, {}); responseData = responseData.map((memberId: string) => ({ memberId })); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -378,7 +378,7 @@ export class Bitwarden implements INodeType { const endpoint = `/public/groups/${groupId}`; responseData = await bitwardenApiRequest.call(this, 'PUT', endpoint, {}, body); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -439,7 +439,7 @@ export class Bitwarden implements INodeType { const endpoint = '/public/members/'; responseData = await bitwardenApiRequest.call(this, 'POST', endpoint, {}, body); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -468,7 +468,7 @@ export class Bitwarden implements INodeType { const endpoint = `/public/members/${id}`; responseData = await bitwardenApiRequest.call(this, 'GET', endpoint, {}, {}); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -481,7 +481,7 @@ export class Bitwarden implements INodeType { const endpoint = '/public/members'; responseData = await handleGetAll.call(this, i, 'GET', endpoint, {}, {}); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -496,7 +496,7 @@ export class Bitwarden implements INodeType { responseData = await bitwardenApiRequest.call(this, 'GET', endpoint, {}, {}); responseData = responseData.map((groupId: string) => ({ groupId })); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -542,7 +542,7 @@ export class Bitwarden implements INodeType { const endpoint = `/public/members/${id}`; responseData = await bitwardenApiRequest.call(this, 'PUT', endpoint, {}, body); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts b/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts index 213d0e7316..91169e7464 100644 --- a/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bitwarden/GenericFunctions.ts @@ -1,6 +1,11 @@ import type { IExecuteFunctions } from 'n8n-core'; -import type { IDataObject, ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow'; +import type { + IDataObject, + ILoadOptionsFunctions, + INodePropertyOptions, + JsonObject, +} from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import type { OptionsWithUri } from 'request'; @@ -61,7 +66,7 @@ export async function bitwardenApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -95,7 +100,7 @@ export async function getAccessToken( const { access_token } = await this.helpers.request(options); return access_token; } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -130,7 +135,7 @@ export async function loadResource(this: ILoadOptionsFunctions, resource: string const token = await getAccessToken.call(this); const endpoint = `/public/${resource}`; - const { data } = await bitwardenApiRequest.call(this, 'GET', endpoint, {}, {}, token); + const { data } = await bitwardenApiRequest.call(this, 'GET', endpoint, {}, {}, token as string); data.forEach(({ id, name, externalId }: { id: string; name: string; externalId?: string }) => { returnData.push({ diff --git a/packages/nodes-base/nodes/Box/Box.node.ts b/packages/nodes-base/nodes/Box/Box.node.ts index 498bfad8e9..c24cbb902b 100644 --- a/packages/nodes-base/nodes/Box/Box.node.ts +++ b/packages/nodes-base/nodes/Box/Box.node.ts @@ -149,11 +149,11 @@ export class Box implements INodeType { items[i] = newItem; - const data = Buffer.from(responseData.body); + const data = Buffer.from(responseData.body as string); items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData( data as unknown as Buffer, - fileName, + fileName as string, mimeType, ); } @@ -524,7 +524,7 @@ export class Box implements INodeType { } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Box/GenericFunctions.ts b/packages/nodes-base/nodes/Box/GenericFunctions.ts index 05469a59bd..098b8a6c9e 100644 --- a/packages/nodes-base/nodes/Box/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Box/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject, IOAuth2Options } from 'n8n-workflow'; +import type { IDataObject, IOAuth2Options, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function boxApiRequest( @@ -33,7 +33,7 @@ export async function boxApiRequest( options = Object.assign({}, options, option); try { - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } @@ -44,7 +44,7 @@ export async function boxApiRequest( //@ts-ignore return await this.helpers.requestOAuth2.call(this, 'boxOAuth2Api', options, oAuth2Options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -65,7 +65,7 @@ export async function boxApiRequestAllItems( do { responseData = await boxApiRequest.call(this, method, endpoint, body, query); query.offset = (responseData.offset as number) + query.limit; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData[propertyName].length !== 0); return returnData; diff --git a/packages/nodes-base/nodes/Brandfetch/Brandfetch.node.ts b/packages/nodes-base/nodes/Brandfetch/Brandfetch.node.ts index 37ca58da34..43314f2933 100644 --- a/packages/nodes-base/nodes/Brandfetch/Brandfetch.node.ts +++ b/packages/nodes-base/nodes/Brandfetch/Brandfetch.node.ts @@ -198,7 +198,7 @@ export class Brandfetch implements INodeType { newItem.binary![`${imageType}_${imageFormat}`] = await this.helpers.prepareBinaryData( - data, + data as Buffer, `${imageType}_${domain}.${imageFormat}`, ); @@ -212,7 +212,7 @@ export class Brandfetch implements INodeType { } } else { const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(response.response), + this.helpers.returnJsonArray(response.response as IDataObject), { itemData: { item: i } }, ); responseData.push(...executionData); @@ -227,7 +227,7 @@ export class Brandfetch implements INodeType { const response = await brandfetchApiRequest.call(this, 'POST', '/color', body); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(response), + this.helpers.returnJsonArray(response as IDataObject), { itemData: { item: i } }, ); responseData.push(...executionData); @@ -241,7 +241,7 @@ export class Brandfetch implements INodeType { const response = await brandfetchApiRequest.call(this, 'POST', '/font', body); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(response), + this.helpers.returnJsonArray(response as IDataObject), { itemData: { item: i } }, ); responseData.push(...executionData); @@ -255,7 +255,7 @@ export class Brandfetch implements INodeType { const response = await brandfetchApiRequest.call(this, 'POST', '/company', body); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(response), + this.helpers.returnJsonArray(response as IDataObject), { itemData: { item: i } }, ); responseData.push(...executionData); @@ -270,7 +270,7 @@ export class Brandfetch implements INodeType { const response = await brandfetchApiRequest.call(this, 'POST', '/industry', body); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(response), + this.helpers.returnJsonArray(response as IDataObject), { itemData: { item: i } }, ); responseData.push(...executionData); diff --git a/packages/nodes-base/nodes/Brandfetch/GenericFunctions.ts b/packages/nodes-base/nodes/Brandfetch/GenericFunctions.ts index 5fc03ca367..afbc6a657e 100644 --- a/packages/nodes-base/nodes/Brandfetch/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Brandfetch/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function brandfetchApiRequest( @@ -39,7 +39,7 @@ export async function brandfetchApiRequest( delete options.headers; } - if (!Object.keys(body).length) { + if (!Object.keys(body as IDataObject).length) { delete options.body; } if (!Object.keys(qs).length) { @@ -49,11 +49,11 @@ export async function brandfetchApiRequest( const response = await this.helpers.request(options); if (response.statusCode && response.statusCode !== 200) { - throw new NodeApiError(this.getNode(), response); + throw new NodeApiError(this.getNode(), response as JsonObject); } return response; } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Bubble/Bubble.node.ts b/packages/nodes-base/nodes/Bubble/Bubble.node.ts index 8d0b6887c9..e6f0f3a8cf 100644 --- a/packages/nodes-base/nodes/Bubble/Bubble.node.ts +++ b/packages/nodes-base/nodes/Bubble/Bubble.node.ts @@ -174,7 +174,7 @@ export class Bubble implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Bubble/GenericFunctions.ts b/packages/nodes-base/nodes/Bubble/GenericFunctions.ts index 0775a93e2c..62a6438f03 100644 --- a/packages/nodes-base/nodes/Bubble/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Bubble/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import type { IDataObject, ILoadOptionsFunctions } from 'n8n-workflow'; +import type { IDataObject, ILoadOptionsFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import type { OptionsWithUri } from 'request'; @@ -51,7 +51,7 @@ export async function bubbleApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -73,7 +73,7 @@ export async function bubbleApiRequestAllItems( do { responseData = await bubbleApiRequest.call(this, method, endpoint, body, qs); qs.cursor += qs.limit; - returnData.push.apply(returnData, responseData.response.results); + returnData.push.apply(returnData, responseData.response.results as IDataObject[]); } while (responseData.response.remaining !== 0); return returnData; diff --git a/packages/nodes-base/nodes/Cal/CalTrigger.node.ts b/packages/nodes-base/nodes/Cal/CalTrigger.node.ts index 884f5d0cbc..a4dd358c79 100644 --- a/packages/nodes-base/nodes/Cal/CalTrigger.node.ts +++ b/packages/nodes-base/nodes/Cal/CalTrigger.node.ts @@ -1,6 +1,7 @@ import type { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import type { + IDataObject, ILoadOptionsFunctions, INodePropertyOptions, INodeType, @@ -121,7 +122,6 @@ export class CalTrigger implements INodeType { }, }; - // @ts-ignore (because of request) webhookMethods = { default: { async checkExists(this: IHookFunctions): Promise { @@ -196,9 +196,9 @@ export class CalTrigger implements INodeType { return { workflowData: [ this.helpers.returnJsonArray({ - triggerEvent: req.body.triggerEvent, - createdAt: req.body.createdAt, - ...req.body.payload, + triggerEvent: req.body.triggerEvent as string, + createdAt: req.body.createdAt as string, + ...(req.body.payload as IDataObject), }), ], }; diff --git a/packages/nodes-base/nodes/Cal/GenericFunctions.ts b/packages/nodes-base/nodes/Cal/GenericFunctions.ts index f84174c890..4910c0d5b6 100644 --- a/packages/nodes-base/nodes/Cal/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Cal/GenericFunctions.ts @@ -7,6 +7,7 @@ import type { IHttpRequestOptions, INodePropertyOptions, IWebhookFunctions, + JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -36,7 +37,7 @@ export async function calApiRequest( try { return await this.helpers.httpRequestWithAuthentication.call(this, 'calApi', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Calendly/GenericFunctions.ts b/packages/nodes-base/nodes/Calendly/GenericFunctions.ts index 87f1dce09b..46d473605f 100644 --- a/packages/nodes-base/nodes/Calendly/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Calendly/GenericFunctions.ts @@ -50,7 +50,7 @@ export async function calendlyApiRequest( json: true, }; - if (!Object.keys(body).length) { + if (!Object.keys(body as IDataObject).length) { delete options.form; } if (!Object.keys(query).length) { diff --git a/packages/nodes-base/nodes/Chargebee/Chargebee.node.ts b/packages/nodes-base/nodes/Chargebee/Chargebee.node.ts index c231d1e3eb..2a97d652c1 100644 --- a/packages/nodes-base/nodes/Chargebee/Chargebee.node.ts +++ b/packages/nodes-base/nodes/Chargebee/Chargebee.node.ts @@ -4,6 +4,7 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + JsonObject, NodeParameterValue, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -597,7 +598,7 @@ export class Chargebee implements INodeType { try { responseData = await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } if (resource === 'invoice' && operation === 'list') { @@ -620,7 +621,7 @@ export class Chargebee implements INodeType { returnData.push(...responseData); } else { responseData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...responseData); diff --git a/packages/nodes-base/nodes/Chargebee/ChargebeeTrigger.node.ts b/packages/nodes-base/nodes/Chargebee/ChargebeeTrigger.node.ts index bcefe8cc7f..19298dc8be 100644 --- a/packages/nodes-base/nodes/Chargebee/ChargebeeTrigger.node.ts +++ b/packages/nodes-base/nodes/Chargebee/ChargebeeTrigger.node.ts @@ -1,6 +1,11 @@ import type { IWebhookFunctions } from 'n8n-core'; -import type { INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow'; +import type { + IDataObject, + INodeType, + INodeTypeDescription, + IWebhookResponseData, +} from 'n8n-workflow'; export class ChargebeeTrigger implements INodeType { description: INodeTypeDescription = { @@ -236,7 +241,7 @@ export class ChargebeeTrigger implements INodeType { } return { - workflowData: [this.helpers.returnJsonArray(req.body)], + workflowData: [this.helpers.returnJsonArray(req.body as IDataObject[])], }; } } diff --git a/packages/nodes-base/nodes/CircleCi/CircleCi.node.ts b/packages/nodes-base/nodes/CircleCi/CircleCi.node.ts index b1bd7fd0a9..48f2831739 100644 --- a/packages/nodes-base/nodes/CircleCi/CircleCi.node.ts +++ b/packages/nodes-base/nodes/CircleCi/CircleCi.node.ts @@ -74,7 +74,7 @@ export class CircleCi implements INodeType { responseData = await circleciApiRequest.call(this, 'GET', endpoint, {}, qs); responseData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); } @@ -108,7 +108,7 @@ export class CircleCi implements INodeType { responseData = responseData.splice(0, qs.limit); } responseData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); } @@ -135,13 +135,13 @@ export class CircleCi implements INodeType { responseData = await circleciApiRequest.call(this, 'POST', endpoint, body, qs); responseData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); } } - returnData.push(...responseData); + returnData.push(...(responseData as INodeExecutionData[])); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message, json: {}, itemIndex: i }); diff --git a/packages/nodes-base/nodes/CircleCi/GenericFunctions.ts b/packages/nodes-base/nodes/CircleCi/GenericFunctions.ts index 9c5840974b..41b2a77594 100644 --- a/packages/nodes-base/nodes/CircleCi/GenericFunctions.ts +++ b/packages/nodes-base/nodes/CircleCi/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function circleciApiRequest( @@ -33,13 +33,13 @@ export async function circleciApiRequest( json: true, }; options = Object.assign({}, options, option); - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -62,7 +62,7 @@ export async function circleciApiRequestAllItems( do { responseData = await circleciApiRequest.call(this, method, resource, body, query); - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); query['page-token'] = responseData.next_page_token; } while (responseData.next_page_token !== undefined && responseData.next_page_token !== null); return returnData; diff --git a/packages/nodes-base/nodes/Cisco/Webex/CiscoWebex.node.ts b/packages/nodes-base/nodes/Cisco/Webex/CiscoWebex.node.ts index e21f821b1b..8ce1a5b930 100644 --- a/packages/nodes-base/nodes/Cisco/Webex/CiscoWebex.node.ts +++ b/packages/nodes-base/nodes/Cisco/Webex/CiscoWebex.node.ts @@ -212,7 +212,7 @@ export class CiscoWebex implements INodeType { responseData = await webexApiRequest.call(this, 'POST', '/messages', body); } responseData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); } else if (operation === 'delete') { @@ -240,7 +240,7 @@ export class CiscoWebex implements INodeType { const endpoint = `/messages/${messageId}`; responseData = await webexApiRequest.call(this, 'GET', endpoint); responseData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); } else if (operation === 'getAll') { @@ -274,7 +274,7 @@ export class CiscoWebex implements INodeType { responseData = responseData.items; } responseData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData.items), + this.helpers.returnJsonArray(responseData.items as IDataObject[]), { itemData: { item: i } }, ); } else if (operation === 'update') { @@ -302,7 +302,7 @@ export class CiscoWebex implements INodeType { responseData = await webexApiRequest.call(this, 'PUT', endpoint, body); responseData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); } @@ -342,7 +342,7 @@ export class CiscoWebex implements INodeType { responseData = await webexApiRequest.call(this, 'POST', '/meetings', body); responseData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); } @@ -393,7 +393,7 @@ export class CiscoWebex implements INodeType { { headers }, ); responseData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); } @@ -433,7 +433,7 @@ export class CiscoWebex implements INodeType { responseData = responseData.items; } responseData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); } @@ -491,13 +491,13 @@ export class CiscoWebex implements INodeType { responseData = await webexApiRequest.call(this, 'PUT', `/meetings/${meetingId}`, body); responseData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); } } - returnData.push(...responseData); + returnData.push(...(responseData as INodeExecutionData[])); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.toString(), json: {}, itemIndex: i }); diff --git a/packages/nodes-base/nodes/Cisco/Webex/GenericFunctions.ts b/packages/nodes-base/nodes/Cisco/Webex/GenericFunctions.ts index 389f5eadc3..77e6a0be3c 100644 --- a/packages/nodes-base/nodes/Cisco/Webex/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Cisco/Webex/GenericFunctions.ts @@ -7,6 +7,7 @@ import type { IDataObject, INodeProperties, IWebhookFunctions, + JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -35,7 +36,7 @@ export async function webexApiRequest( if (Object.keys(option).length !== 0) { options = Object.assign({}, options, option); } - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } if (Object.keys(qs).length === 0) { @@ -46,7 +47,7 @@ export async function webexApiRequest( tokenType: 'Bearer', }); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -73,7 +74,7 @@ export async function webexApiRequestAllItems( if (responseData.headers.link) { uri = responseData.headers.link.split(';')[0].replace('<', '').replace('>', ''); } - returnData.push.apply(returnData, responseData.body[propertyName]); + returnData.push.apply(returnData, responseData.body[propertyName] as IDataObject[]); } while (responseData.headers.link?.includes('rel="next"')); return returnData; } diff --git a/packages/nodes-base/nodes/Citrix/ADC/CitrixAdc.node.ts b/packages/nodes-base/nodes/Citrix/ADC/CitrixAdc.node.ts index 57c59fe74f..5822ce0701 100644 --- a/packages/nodes-base/nodes/Citrix/ADC/CitrixAdc.node.ts +++ b/packages/nodes-base/nodes/Citrix/ADC/CitrixAdc.node.ts @@ -130,8 +130,8 @@ export class CitrixAdc implements INodeType { const file = systemfile[0]; const binaryData = await this.helpers.prepareBinaryData( - Buffer.from(file.filecontent, 'base64'), - file.filename, + Buffer.from(file.filecontent as string, 'base64'), + file.filename as string, ); responseData = { diff --git a/packages/nodes-base/nodes/Clearbit/Clearbit.node.ts b/packages/nodes-base/nodes/Clearbit/Clearbit.node.ts index c4794b47e3..d99106f185 100644 --- a/packages/nodes-base/nodes/Clearbit/Clearbit.node.ts +++ b/packages/nodes-base/nodes/Clearbit/Clearbit.node.ts @@ -153,7 +153,7 @@ export class Clearbit implements INodeType { } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Clearbit/GenericFunctions.ts b/packages/nodes-base/nodes/Clearbit/GenericFunctions.ts index 116c882bcc..f443e8f237 100644 --- a/packages/nodes-base/nodes/Clearbit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Clearbit/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function clearbitApiRequest( @@ -31,12 +31,12 @@ export async function clearbitApiRequest( json: true, }; options = Object.assign({}, options, option); - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/ClickUp/ClickUp.node.ts b/packages/nodes-base/nodes/ClickUp/ClickUp.node.ts index 5f4cf43849..37fb535552 100644 --- a/packages/nodes-base/nodes/ClickUp/ClickUp.node.ts +++ b/packages/nodes-base/nodes/ClickUp/ClickUp.node.ts @@ -1625,7 +1625,7 @@ export class ClickUp implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/ClickUp/ClickUpTrigger.node.ts b/packages/nodes-base/nodes/ClickUp/ClickUpTrigger.node.ts index ba4b1d4dba..3f88c19f46 100644 --- a/packages/nodes-base/nodes/ClickUp/ClickUpTrigger.node.ts +++ b/packages/nodes-base/nodes/ClickUp/ClickUpTrigger.node.ts @@ -338,7 +338,7 @@ export class ClickUpTrigger implements INodeType { return {}; } return { - workflowData: [this.helpers.returnJsonArray(req.body)], + workflowData: [this.helpers.returnJsonArray(req.body as IDataObject)], }; } } diff --git a/packages/nodes-base/nodes/ClickUp/GenericFunctions.ts b/packages/nodes-base/nodes/ClickUp/GenericFunctions.ts index f0949081de..40182083ff 100644 --- a/packages/nodes-base/nodes/ClickUp/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ClickUp/GenericFunctions.ts @@ -8,7 +8,7 @@ import type { IWebhookFunctions, } from 'n8n-core'; -import type { IDataObject, IOAuth2Options } from 'n8n-workflow'; +import type { IDataObject, IOAuth2Options, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function clickupApiRequest( @@ -56,7 +56,7 @@ export async function clickupApiRequest( ); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -76,7 +76,7 @@ export async function clickupApiRequestAllItems( do { responseData = await clickupApiRequest.call(this, method, resource, body, query); - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); query.page++; if (query.limit && query.limit <= returnData.length) { return returnData; diff --git a/packages/nodes-base/nodes/Clockify/Clockify.node.ts b/packages/nodes-base/nodes/Clockify/Clockify.node.ts index 8ddf595c9c..1b7357c993 100644 --- a/packages/nodes-base/nodes/Clockify/Clockify.node.ts +++ b/packages/nodes-base/nodes/Clockify/Clockify.node.ts @@ -836,7 +836,7 @@ export class Clockify implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Clockify/GenericFunctions.ts b/packages/nodes-base/nodes/Clockify/GenericFunctions.ts index 149cadb17e..1f898ade8c 100644 --- a/packages/nodes-base/nodes/Clockify/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Clockify/GenericFunctions.ts @@ -49,7 +49,7 @@ export async function clockifyApiRequestAllItems( do { responseData = await clockifyApiRequest.call(this, method, endpoint, body, query); - returnData.push.apply(returnData, responseData); + returnData.push.apply(returnData, responseData as IDataObject[]); if (query.limit && returnData.length >= query.limit) { return returnData; diff --git a/packages/nodes-base/nodes/Cloudflare/Cloudflare.node.ts b/packages/nodes-base/nodes/Cloudflare/Cloudflare.node.ts index e09b30bc0f..24defa030c 100644 --- a/packages/nodes-base/nodes/Cloudflare/Cloudflare.node.ts +++ b/packages/nodes-base/nodes/Cloudflare/Cloudflare.node.ts @@ -160,9 +160,12 @@ export class Cloudflare implements INodeType { } returnData.push( - ...this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { - itemData: { item: i }, - }), + ...this.helpers.constructExecutionMetaData( + this.helpers.returnJsonArray(responseData as IDataObject[]), + { + itemData: { item: i }, + }, + ), ); } catch (error) { if (this.continueOnFail()) { diff --git a/packages/nodes-base/nodes/Cloudflare/GenericFunctions.ts b/packages/nodes-base/nodes/Cloudflare/GenericFunctions.ts index ecf8c22229..ff586129a7 100644 --- a/packages/nodes-base/nodes/Cloudflare/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Cloudflare/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { IPollFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function cloudflareApiRequest( @@ -36,7 +36,7 @@ export async function cloudflareApiRequest( } return await this.helpers.requestWithAuthentication.call(this, 'cloudflareApi', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -56,7 +56,7 @@ export async function cloudflareApiRequestAllItems( do { responseData = await cloudflareApiRequest.call(this, method, endpoint, body, query); query.page++; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.result_info.total_pages !== responseData.result_info.page); return returnData; } diff --git a/packages/nodes-base/nodes/Cockpit/GenericFunctions.ts b/packages/nodes-base/nodes/Cockpit/GenericFunctions.ts index 1e6fe13e6d..0dd1539abd 100644 --- a/packages/nodes-base/nodes/Cockpit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Cockpit/GenericFunctions.ts @@ -1,5 +1,5 @@ import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { jsonParse, NodeApiError } from 'n8n-workflow'; import type { OptionsWithUri } from 'request'; @@ -29,14 +29,14 @@ export async function cockpitApiRequest( options = Object.assign({}, options, option); - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Coda/Coda.node.ts b/packages/nodes-base/nodes/Coda/Coda.node.ts index 5eeb58b40a..76d1361d0a 100644 --- a/packages/nodes-base/nodes/Coda/Coda.node.ts +++ b/packages/nodes-base/nodes/Coda/Coda.node.ts @@ -6,6 +6,7 @@ import type { INodePropertyOptions, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import { codaApiRequest, codaApiRequestAllItems } from './GenericFunctions'; @@ -331,13 +332,16 @@ export class Coda implements INodeType { responseData = await codaApiRequest.call(this, 'GET', endpoint, {}, qs); if (options.rawData === true) { const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); } else { const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray({ id: responseData.id, ...responseData.values }), + this.helpers.returnJsonArray({ + id: responseData.id as string, + ...(responseData.values as IDataObject), + }), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -400,13 +404,14 @@ export class Coda implements INodeType { if (this.continueOnFail()) { return [this.helpers.returnJsonArray({ error: error.message })]; } - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } if (options.rawData === true) { - return [this.helpers.returnJsonArray(responseData)]; + return [this.helpers.returnJsonArray(responseData as IDataObject[])]; } else { for (const item of responseData) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument returnData.push({ id: item.id, ...item.values, @@ -456,7 +461,7 @@ export class Coda implements INodeType { const columnId = this.getNodeParameter('columnId', i) as string; const endpoint = `/docs/${docId}/tables/${tableId}/rows/${rowId}/buttons/${columnId}`; responseData = await codaApiRequest.call(this, 'POST', endpoint, {}); - returnData.push(responseData); + returnData.push(responseData as INodeExecutionData); } catch (error) { if (this.continueOnFail()) { const executionErrorData = this.helpers.constructExecutionMetaData( @@ -481,7 +486,7 @@ export class Coda implements INodeType { const endpoint = `/docs/${docId}/tables/${tableId}/columns/${columnId}`; responseData = await codaApiRequest.call(this, 'GET', endpoint, {}); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -515,7 +520,7 @@ export class Coda implements INodeType { responseData = responseData.items; } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -544,7 +549,7 @@ export class Coda implements INodeType { const endpoint = `/docs/${docId}/formulas/${formulaId}`; responseData = await codaApiRequest.call(this, 'GET', endpoint, {}); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -577,7 +582,7 @@ export class Coda implements INodeType { responseData = responseData.items; } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -606,7 +611,7 @@ export class Coda implements INodeType { const endpoint = `/docs/${docId}/controls/${controlId}`; responseData = await codaApiRequest.call(this, 'GET', endpoint, {}); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -639,7 +644,7 @@ export class Coda implements INodeType { responseData = responseData.items; } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -667,7 +672,7 @@ export class Coda implements INodeType { const endpoint = `/docs/${docId}/tables/${viewId}`; responseData = await codaApiRequest.call(this, 'GET', endpoint, {}); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -689,7 +694,7 @@ export class Coda implements INodeType { responseData = responseData.items; } responseData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...responseData); @@ -746,13 +751,14 @@ export class Coda implements INodeType { if (this.continueOnFail()) { return [this.helpers.returnJsonArray({ error: error.message })]; } - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } if (options.rawData === true) { - return [this.helpers.returnJsonArray(responseData)]; + return [this.helpers.returnJsonArray(responseData as IDataObject[])]; } else { for (const item of responseData) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument returnData.push({ id: item.id, ...item.values, @@ -771,7 +777,7 @@ export class Coda implements INodeType { const endpoint = `/docs/${docId}/tables/${viewId}/rows/${rowId}`; responseData = await codaApiRequest.call(this, 'DELETE', endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -800,7 +806,7 @@ export class Coda implements INodeType { const endpoint = `/docs/${docId}/tables/${viewId}/rows/${rowId}/buttons/${columnId}`; responseData = await codaApiRequest.call(this, 'POST', endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -833,7 +839,7 @@ export class Coda implements INodeType { responseData = responseData.items; } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Coda/GenericFunctions.ts b/packages/nodes-base/nodes/Coda/GenericFunctions.ts index 83260a59cd..13636430ba 100644 --- a/packages/nodes-base/nodes/Coda/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Coda/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function codaApiRequest( @@ -24,14 +24,14 @@ export async function codaApiRequest( json: true, }; options = Object.assign({}, options, option); - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -60,7 +60,7 @@ export async function codaApiRequestAllItems( responseData = await codaApiRequest.call(this, method, resource, body, query, uri); uri = responseData.nextPageLink; // @ts-ignore - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.nextPageLink !== undefined && responseData.nextPageLink !== ''); return returnData; diff --git a/packages/nodes-base/nodes/Code/Sandbox.ts b/packages/nodes-base/nodes/Code/Sandbox.ts index 9f946eb1d5..c8374d3a38 100644 --- a/packages/nodes-base/nodes/Code/Sandbox.ts +++ b/packages/nodes-base/nodes/Code/Sandbox.ts @@ -6,7 +6,13 @@ import { ExecutionError } from './ExecutionError'; import type { CodeNodeMode } from './utils'; import { isObject, REQUIRED_N8N_ITEM_KEYS } from './utils'; -import type { IExecuteFunctions, IWorkflowDataProxyData, WorkflowExecuteMode } from 'n8n-workflow'; +import type { + IDataObject, + IExecuteFunctions, + INodeExecutionData, + IWorkflowDataProxyData, + WorkflowExecuteMode, +} from 'n8n-workflow'; export class Sandbox extends NodeVM { private jsCode = ''; @@ -59,6 +65,7 @@ export class Sandbox extends NodeVM { error.message = (quoted as string) + '. Did you mean `$input.all()`?'; } + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument throw new ExecutionError(error); } @@ -82,7 +89,7 @@ export class Sandbox extends NodeVM { * item keys to be wrapped in `json` when normalizing items below. */ const mustHaveTopLevelN8nKey = executionResult.some((item) => - Object.keys(item).find((key) => REQUIRED_N8N_ITEM_KEYS.has(key)), + Object.keys(item as IDataObject).find((key) => REQUIRED_N8N_ITEM_KEYS.has(key)), ); for (const item of executionResult) { @@ -95,7 +102,7 @@ export class Sandbox extends NodeVM { } if (mustHaveTopLevelN8nKey) { - Object.keys(item).forEach((key) => { + Object.keys(item as IDataObject).forEach((key) => { if (REQUIRED_N8N_ITEM_KEYS.has(key)) return; throw new ValidationError({ message: `Unknown top-level item key: ${key}`, @@ -131,7 +138,7 @@ export class Sandbox extends NodeVM { } } - return normalizeItems(executionResult); + return normalizeItems(executionResult as INodeExecutionData[]); } private async runCodeEachItem() { @@ -170,6 +177,7 @@ export class Sandbox extends NodeVM { error.message = (quoted as string) + '. Did you mean `$input.item.json`?'; } + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument throw new ExecutionError(error, this.itemIndex); } @@ -203,7 +211,7 @@ export class Sandbox extends NodeVM { // and another top-level key is unrecognized, then the user mis-added a property // directly on the item, when they intended to add it on the `json` property - Object.keys(executionResult).forEach((key) => { + Object.keys(executionResult as IDataObject).forEach((key) => { if (REQUIRED_N8N_ITEM_KEYS.has(key)) return; throw new ValidationError({ diff --git a/packages/nodes-base/nodes/CoinGecko/CoinGecko.node.ts b/packages/nodes-base/nodes/CoinGecko/CoinGecko.node.ts index 63f20e14bb..33587e894e 100644 --- a/packages/nodes-base/nodes/CoinGecko/CoinGecko.node.ts +++ b/packages/nodes-base/nodes/CoinGecko/CoinGecko.node.ts @@ -369,7 +369,7 @@ export class CoinGecko implements INodeType { const marketCaps = respData.market_caps[idx][1]; const totalVolume = respData.total_volumes[idx][1]; responseData.push({ - time: moment(time).toISOString(), + time: moment(time as string).toISOString(), price, marketCaps, totalVolume, @@ -397,7 +397,7 @@ export class CoinGecko implements INodeType { for (let idx = 0; idx < responseData.length; idx++) { const [time, open, high, low, close] = responseData[idx]; responseData[idx] = { - time: moment(time).toISOString(), + time: moment(time as string).toISOString(), open, high, low, @@ -473,7 +473,7 @@ export class CoinGecko implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/CoinGecko/GenericFunctions.ts b/packages/nodes-base/nodes/CoinGecko/GenericFunctions.ts index aac10abd58..afbb2f702b 100644 --- a/packages/nodes-base/nodes/CoinGecko/GenericFunctions.ts +++ b/packages/nodes-base/nodes/CoinGecko/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function coinGeckoApiRequest( @@ -30,14 +30,14 @@ export async function coinGeckoApiRequest( options = Object.assign({}, options, option); try { - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } //@ts-ignore return await this.helpers.request.call(this, options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -64,7 +64,7 @@ export async function coinGeckoRequestAllItems( if (propertyName !== '') { respData = responseData[propertyName]; } - returnData.push.apply(returnData, respData); + returnData.push.apply(returnData, respData as IDataObject[]); } while (respData.length !== 0); return returnData; diff --git a/packages/nodes-base/nodes/Contentful/Contentful.node.ts b/packages/nodes-base/nodes/Contentful/Contentful.node.ts index f312fc8a94..e2e775e9f2 100644 --- a/packages/nodes-base/nodes/Contentful/Contentful.node.ts +++ b/packages/nodes-base/nodes/Contentful/Contentful.node.ts @@ -201,7 +201,7 @@ export class Contentful implements INodeType { const assets: IDataObject[] = []; responseData.map((asset: any) => { - assets.push(asset.fields); + assets.push(asset.fields as IDataObject); }); responseData = assets; } @@ -221,7 +221,7 @@ export class Contentful implements INodeType { const assets: IDataObject[] = []; responseData.map((asset: any) => { - assets.push(asset.fields); + assets.push(asset.fields as IDataObject); }); responseData = assets; } @@ -300,7 +300,7 @@ export class Contentful implements INodeType { const assets: IDataObject[] = []; responseData.map((asset: any) => { - assets.push(asset.fields); + assets.push(asset.fields as IDataObject); }); responseData = assets; } @@ -320,7 +320,7 @@ export class Contentful implements INodeType { const assets: IDataObject[] = []; responseData.map((asset: any) => { - assets.push(asset.fields); + assets.push(asset.fields as IDataObject); }); responseData = assets; } @@ -359,7 +359,7 @@ export class Contentful implements INodeType { } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Contentful/GenericFunctions.ts b/packages/nodes-base/nodes/Contentful/GenericFunctions.ts index 905d706d20..c43fcc0b5b 100644 --- a/packages/nodes-base/nodes/Contentful/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Contentful/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions import type { OptionsWithUri } from 'request'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function contentfulApiRequest( @@ -36,7 +36,7 @@ export async function contentfulApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -59,7 +59,7 @@ export async function contenfulApiRequestAllItems( do { responseData = await contentfulApiRequest.call(this, method, resource, body, query); query.skip = (query.skip + 1) * query.limit; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (returnData.length < responseData.total); return returnData; diff --git a/packages/nodes-base/nodes/ConvertKit/ConvertKit.node.ts b/packages/nodes-base/nodes/ConvertKit/ConvertKit.node.ts index 6dcb6e003b..0090cf6185 100644 --- a/packages/nodes-base/nodes/ConvertKit/ConvertKit.node.ts +++ b/packages/nodes-base/nodes/ConvertKit/ConvertKit.node.ts @@ -479,7 +479,7 @@ export class ConvertKit implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts b/packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts index 59677219a0..8204a97e09 100644 --- a/packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ConvertKit/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject, IHookFunctions } from 'n8n-workflow'; +import type { IDataObject, IHookFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function convertKitApiRequest( @@ -30,7 +30,7 @@ export async function convertKitApiRequest( options = Object.assign({}, options, option); - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } @@ -41,13 +41,13 @@ export async function convertKitApiRequest( qs.api_secret = credentials.apiSecret; } - if (Object.keys(options.qs).length === 0) { + if (Object.keys(options.qs as IDataObject).length === 0) { delete options.qs; } try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Copper/Copper.node.ts b/packages/nodes-base/nodes/Copper/Copper.node.ts index ef539b1b86..d7fd7f4645 100644 --- a/packages/nodes-base/nodes/Copper/Copper.node.ts +++ b/packages/nodes-base/nodes/Copper/Copper.node.ts @@ -628,7 +628,7 @@ export class Copper implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Copper/CopperTrigger.node.ts b/packages/nodes-base/nodes/Copper/CopperTrigger.node.ts index 8a924cc12d..fd96e528b4 100644 --- a/packages/nodes-base/nodes/Copper/CopperTrigger.node.ts +++ b/packages/nodes-base/nodes/Copper/CopperTrigger.node.ts @@ -161,7 +161,7 @@ export class CopperTrigger implements INodeType { } return { - workflowData: [this.helpers.returnJsonArray(req.body)], + workflowData: [this.helpers.returnJsonArray(req.body as IDataObject)], }; } } diff --git a/packages/nodes-base/nodes/Copper/GenericFunctions.ts b/packages/nodes-base/nodes/Copper/GenericFunctions.ts index eee2f44d33..9c29a3cdfc 100644 --- a/packages/nodes-base/nodes/Copper/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Copper/GenericFunctions.ts @@ -10,7 +10,7 @@ import type { IWebhookFunctions, } from 'n8n-core'; -import type { ICredentialDataDecryptedObject, IDataObject } from 'n8n-workflow'; +import type { ICredentialDataDecryptedObject, IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import flow from 'lodash.flow'; @@ -62,14 +62,14 @@ export async function copperApiRequest( delete options.qs; } - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -167,7 +167,7 @@ export async function copperApiRequestAllItems( do { responseData = await copperApiRequest.call(this, method, resource, body, qs, uri, option); totalItems = responseData.headers['x-pw-total']; - returnData.push(...responseData.body); + returnData.push(...(responseData.body as IDataObject[])); } while (totalItems > returnData.length); return returnData; diff --git a/packages/nodes-base/nodes/Cortex/Cortex.node.ts b/packages/nodes-base/nodes/Cortex/Cortex.node.ts index 7eba5a1ea1..495b415c9c 100644 --- a/packages/nodes-base/nodes/Cortex/Cortex.node.ts +++ b/packages/nodes-base/nodes/Cortex/Cortex.node.ts @@ -295,7 +295,7 @@ export class Cortex implements INodeType { body = { responderId, - label: getEntityLabel(entityJson), + label: getEntityLabel(entityJson as IDataObject), dataType: `thehive:${entityType}`, data: entityJson, tlp: entityJson.tlp || 2, diff --git a/packages/nodes-base/nodes/Cortex/GenericFunctions.ts b/packages/nodes-base/nodes/Cortex/GenericFunctions.ts index f74730c1df..3298ed4fbf 100644 --- a/packages/nodes-base/nodes/Cortex/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Cortex/GenericFunctions.ts @@ -34,7 +34,7 @@ export async function cortexApiRequest( if (Object.keys(option).length !== 0) { options = Object.assign({}, options, option); } - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } if (Object.keys(query).length === 0) { diff --git a/packages/nodes-base/nodes/CustomerIo/CustomerIoTrigger.node.ts b/packages/nodes-base/nodes/CustomerIo/CustomerIoTrigger.node.ts index 91ed6e791c..dbde86f5e0 100644 --- a/packages/nodes-base/nodes/CustomerIo/CustomerIoTrigger.node.ts +++ b/packages/nodes-base/nodes/CustomerIo/CustomerIoTrigger.node.ts @@ -244,7 +244,10 @@ export class CustomerIoTrigger implements INodeType { } for (const webhook of webhooks) { - if (webhook.endpoint === webhookUrl && eventExists(currentEvents, webhook.events)) { + if ( + webhook.endpoint === webhookUrl && + eventExists(currentEvents, webhook.events as IDataObject) + ) { webhookData.webhookId = webhook.id; return true; } diff --git a/packages/nodes-base/nodes/DeepL/DeepL.node.ts b/packages/nodes-base/nodes/DeepL/DeepL.node.ts index d13aeb4922..f7839ada04 100644 --- a/packages/nodes-base/nodes/DeepL/DeepL.node.ts +++ b/packages/nodes-base/nodes/DeepL/DeepL.node.ts @@ -130,7 +130,7 @@ export class DeepL implements INodeType { const { translations } = await deepLApiRequest.call(this, 'GET', '/translate', body); const [translation] = translations; - const translationJsonArray = this.helpers.returnJsonArray(translation); + const translationJsonArray = this.helpers.returnJsonArray(translation as IDataObject[]); const executionData = this.helpers.constructExecutionMetaData(translationJsonArray, { itemData: { item: i }, }); diff --git a/packages/nodes-base/nodes/Demio/GenericFunctions.ts b/packages/nodes-base/nodes/Demio/GenericFunctions.ts index 06a66078f0..c4a224455b 100644 --- a/packages/nodes-base/nodes/Demio/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Demio/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function demioApiRequest( @@ -38,6 +38,6 @@ export async function demioApiRequest( return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Dhl/Dhl.node.ts b/packages/nodes-base/nodes/Dhl/Dhl.node.ts index dbb311dd43..924d54171c 100644 --- a/packages/nodes-base/nodes/Dhl/Dhl.node.ts +++ b/packages/nodes-base/nodes/Dhl/Dhl.node.ts @@ -142,7 +142,7 @@ export class Dhl implements INodeType { responseData = await dhlApiRequest.call(this, 'GET', '/track/shipments', {}, qs); - returnData.push(...responseData.shipments); + returnData.push(...(responseData.shipments as IDataObject[])); } } } catch (error) { diff --git a/packages/nodes-base/nodes/Dhl/GenericFunctions.ts b/packages/nodes-base/nodes/Dhl/GenericFunctions.ts index 74cb6ab373..4c167c3b17 100644 --- a/packages/nodes-base/nodes/Dhl/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Dhl/GenericFunctions.ts @@ -11,6 +11,7 @@ import type { ICredentialDataDecryptedObject, ICredentialTestFunctions, IDataObject, + JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -37,14 +38,14 @@ export async function dhlApiRequest( json: true, }; options = Object.assign({}, options, option); - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Discourse/Discourse.node.ts b/packages/nodes-base/nodes/Discourse/Discourse.node.ts index 51745c4970..322cee5c95 100644 --- a/packages/nodes-base/nodes/Discourse/Discourse.node.ts +++ b/packages/nodes-base/nodes/Discourse/Discourse.node.ts @@ -421,7 +421,7 @@ export class Discourse implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Discourse/GenericFunctions.ts b/packages/nodes-base/nodes/Discourse/GenericFunctions.ts index d3ec81962d..175f375aed 100644 --- a/packages/nodes-base/nodes/Discourse/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Discourse/GenericFunctions.ts @@ -25,7 +25,7 @@ export async function discourseApiRequest( }; try { - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } return await this.helpers.requestWithAuthentication.call(this, 'discourseApi', options); @@ -48,7 +48,7 @@ export async function discourseApiRequestAllItems( query.page = 1; do { responseData = await discourseApiRequest.call(this, method, endpoint, body, query); - returnData.push.apply(returnData, responseData); + returnData.push.apply(returnData, responseData as IDataObject[]); query.page++; } while (responseData.length !== 0); return returnData; diff --git a/packages/nodes-base/nodes/Disqus/Disqus.node.ts b/packages/nodes-base/nodes/Disqus/Disqus.node.ts index c3db8f7741..a07e083595 100644 --- a/packages/nodes-base/nodes/Disqus/Disqus.node.ts +++ b/packages/nodes-base/nodes/Disqus/Disqus.node.ts @@ -605,7 +605,7 @@ export class Disqus implements INodeType { try { const responseData = await disqusApiRequest.call(this, requestMethod, qs, endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData.response), + this.helpers.returnJsonArray(responseData.response as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Disqus/GenericFunctions.ts b/packages/nodes-base/nodes/Disqus/GenericFunctions.ts index d72793cf86..4ae9521f87 100644 --- a/packages/nodes-base/nodes/Disqus/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Disqus/GenericFunctions.ts @@ -5,7 +5,7 @@ import type { IHookFunctions, ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function disqusApiRequest( @@ -39,13 +39,13 @@ export async function disqusApiRequest( }; options = Object.assign({}, options, option); - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -69,7 +69,7 @@ export async function disqusApiRequestAllItems( do { responseData = await disqusApiRequest.call(this, method, qs, uri, body, option); qs.cursor = responseData.cursor.id; - returnData.push.apply(returnData, responseData.response); + returnData.push.apply(returnData, responseData.response as IDataObject[]); } while (responseData.cursor.more === true && responseData.cursor.hasNext === true); return returnData; } catch (error) { diff --git a/packages/nodes-base/nodes/Drift/GenericFunctions.ts b/packages/nodes-base/nodes/Drift/GenericFunctions.ts index 6fef0d3a2f..6b6df1041f 100644 --- a/packages/nodes-base/nodes/Drift/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Drift/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject, IHookFunctions, IWebhookFunctions } from 'n8n-workflow'; +import type { IDataObject, IHookFunctions, IWebhookFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function driftApiRequest( @@ -24,7 +24,7 @@ export async function driftApiRequest( json: true, }; - if (!Object.keys(body).length) { + if (!Object.keys(body as IDataObject).length) { delete options.form; } if (!Object.keys(query).length) { @@ -45,6 +45,6 @@ export async function driftApiRequest( return await this.helpers.requestOAuth2.call(this, 'driftOAuth2Api', options); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Dropbox/Dropbox.node.ts b/packages/nodes-base/nodes/Dropbox/Dropbox.node.ts index 8a09f9c731..edcce4c51c 100644 --- a/packages/nodes-base/nodes/Dropbox/Dropbox.node.ts +++ b/packages/nodes-base/nodes/Dropbox/Dropbox.node.ts @@ -932,9 +932,9 @@ export class Dropbox implements INodeType { } if (resource === 'file' && operation === 'upload') { - const data = JSON.parse(responseData); + const data = JSON.parse(responseData as string); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(data), + this.helpers.returnJsonArray(data as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -958,7 +958,7 @@ export class Dropbox implements INodeType { const filePathDownload = this.getNodeParameter('path', i) as string; items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData( - Buffer.from(responseData), + Buffer.from(responseData as string), filePathDownload, ); } else if (resource === 'folder' && operation === 'list') { @@ -1000,20 +1000,22 @@ export class Dropbox implements INodeType { } else if (resource === 'search' && operation === 'query') { let data = responseData; if (returnAll) { - data = simple ? simplify(responseData) : responseData; + data = simple ? simplify(responseData as IDataObject[]) : responseData; } else { - data = simple ? simplify(responseData[property]) : responseData[property]; + data = simple + ? simplify(responseData[property] as IDataObject[]) + : responseData[property]; } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(data), + this.helpers.returnJsonArray(data as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); } else { const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Dropbox/GenericFunctions.ts b/packages/nodes-base/nodes/Dropbox/GenericFunctions.ts index 3943862e14..e5832f6a6b 100644 --- a/packages/nodes-base/nodes/Dropbox/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Dropbox/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { IExecuteFunctions, IHookFunctions } from 'n8n-core'; import type { OptionsWithUri } from 'request'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; /** @@ -42,7 +42,7 @@ export async function dropboxApiRequest( return await this.helpers.requestOAuth2.call(this, 'dropboxOAuth2Api', options); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -67,13 +67,20 @@ export async function dropboxpiRequestAllItems( let responseData; do { - responseData = await dropboxApiRequest.call(this, method, endpoint, body, query, headers); + responseData = await dropboxApiRequest.call( + this, + method, + endpoint, + body as IDataObject, + query, + headers, + ); const cursor = responseData.cursor; if (cursor !== undefined) { endpoint = paginationEndpoint[resource] as string; body = { cursor }; } - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.has_more !== false); return returnData; diff --git a/packages/nodes-base/nodes/Dropcontact/Dropcontact.node.ts b/packages/nodes-base/nodes/Dropcontact/Dropcontact.node.ts index 84d6ac5493..35acbbfd57 100644 --- a/packages/nodes-base/nodes/Dropcontact/Dropcontact.node.ts +++ b/packages/nodes-base/nodes/Dropcontact/Dropcontact.node.ts @@ -330,7 +330,7 @@ export class Dropcontact implements INodeType { } } else { const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: mapPairedItemsFrom(entryData), }, @@ -363,7 +363,7 @@ export class Dropcontact implements INodeType { } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData.data), + this.helpers.returnJsonArray(responseData.data as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/ERPNext/ERPNext.node.ts b/packages/nodes-base/nodes/ERPNext/ERPNext.node.ts index 716955c490..f2ef75328f 100644 --- a/packages/nodes-base/nodes/ERPNext/ERPNext.node.ts +++ b/packages/nodes-base/nodes/ERPNext/ERPNext.node.ts @@ -90,6 +90,7 @@ export class ERPNext implements INodeType { docFields.unshift({ name: '*', value: '*' }); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument return processNames(docFields); }, async getDocFields(this: ILoadOptionsFunctions): Promise { @@ -107,6 +108,7 @@ export class ERPNext implements INodeType { }, ); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument return processNames(docFields); }, }, @@ -284,7 +286,7 @@ export class ERPNext implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/ERPNext/GenericFunctions.ts b/packages/nodes-base/nodes/ERPNext/GenericFunctions.ts index fb4492a8e1..3e419c7b35 100644 --- a/packages/nodes-base/nodes/ERPNext/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ERPNext/GenericFunctions.ts @@ -38,11 +38,11 @@ export async function erpNextApiRequest( options = Object.assign({}, options, option); - if (!Object.keys(options.body).length) { + if (!Object.keys(options.body as IDataObject).length) { delete options.body; } - if (!Object.keys(options.qs).length) { + if (!Object.keys(options.qs as IDataObject).length) { delete options.qs; } try { @@ -77,7 +77,7 @@ export async function erpNextApiRequestAllItems( do { responseData = await erpNextApiRequest.call(this, method, resource, body, query); - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); query.limit_start += query.limit_page_length - 1; } while (responseData.data && responseData.data.length > 0); diff --git a/packages/nodes-base/nodes/Egoi/Egoi.node.ts b/packages/nodes-base/nodes/Egoi/Egoi.node.ts index 4d7ad4ff27..daee3b0b06 100644 --- a/packages/nodes-base/nodes/Egoi/Egoi.node.ts +++ b/packages/nodes-base/nodes/Egoi/Egoi.node.ts @@ -632,6 +632,7 @@ export class Egoi implements INodeType { } if (simple) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument const data = (await simplify.call(this, [responseData], listId))[0]; responseData = { @@ -675,6 +676,7 @@ export class Egoi implements INodeType { } if (simple) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument responseData = await simplify.call(this, responseData, listId); } } @@ -749,7 +751,7 @@ export class Egoi implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Egoi/GenericFunctions.ts b/packages/nodes-base/nodes/Egoi/GenericFunctions.ts index 0671c10ca2..5a2c5b0c61 100644 --- a/packages/nodes-base/nodes/Egoi/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Egoi/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; interface IContact { @@ -43,14 +43,14 @@ export async function egoiApiRequest( json: true, }; - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -80,7 +80,7 @@ export async function egoiApiRequestAllItems( do { responseData = await egoiApiRequest.call(this, method, endpoint, body, query); - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); query.offset += query.count; } while (responseData[propertyName] && responseData[propertyName].length !== 0); diff --git a/packages/nodes-base/nodes/Elastic/ElasticSecurity/ElasticSecurity.node.ts b/packages/nodes-base/nodes/Elastic/ElasticSecurity/ElasticSecurity.node.ts index e02571cb58..4aeb4e5d07 100644 --- a/packages/nodes-base/nodes/Elastic/ElasticSecurity/ElasticSecurity.node.ts +++ b/packages/nodes-base/nodes/Elastic/ElasticSecurity/ElasticSecurity.node.ts @@ -574,7 +574,7 @@ export class ElasticSecurity implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Elastic/ElasticSecurity/GenericFunctions.ts b/packages/nodes-base/nodes/Elastic/ElasticSecurity/GenericFunctions.ts index 38b728ba23..7f242de187 100644 --- a/packages/nodes-base/nodes/Elastic/ElasticSecurity/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Elastic/ElasticSecurity/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { IExecuteFunctions } from 'n8n-core'; -import type { IDataObject, ILoadOptionsFunctions } from 'n8n-workflow'; +import type { IDataObject, ILoadOptionsFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; import type { OptionsWithUri } from 'request'; @@ -55,7 +55,7 @@ export async function elasticSecurityApiRequest( error.error.error = `${error.error.error}: ${error.error.message}`; } - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -78,7 +78,7 @@ export async function elasticSecurityApiRequestAllItems( const items = resource === 'case' ? responseData.cases : responseData; - returnData.push(...items); + returnData.push(...(items as IDataObject[])); } while (returnData.length < responseData.total); return returnData; diff --git a/packages/nodes-base/nodes/Elastic/Elasticsearch/Elasticsearch.node.ts b/packages/nodes-base/nodes/Elastic/Elasticsearch/Elasticsearch.node.ts index be5b2f0721..1fe89b8ab4 100644 --- a/packages/nodes-base/nodes/Elastic/Elasticsearch/Elasticsearch.node.ts +++ b/packages/nodes-base/nodes/Elastic/Elasticsearch/Elasticsearch.node.ts @@ -331,7 +331,9 @@ export class Elasticsearch implements INodeType { // https://www.elastic.co/guide/en/elasticsearch/reference/current/indices-aliases.html responseData = await elasticsearchApiRequest.call(this, 'GET', '/_aliases'); - responseData = Object.keys(responseData).map((index) => ({ indexId: index })); + responseData = Object.keys(responseData as IDataObject).map((index) => ({ + indexId: index, + })); const returnAll = this.getNodeParameter('returnAll', i); @@ -342,7 +344,7 @@ export class Elasticsearch implements INodeType { } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Elastic/Elasticsearch/GenericFunctions.ts b/packages/nodes-base/nodes/Elastic/Elasticsearch/GenericFunctions.ts index 09f3cbc885..e4503280c8 100644 --- a/packages/nodes-base/nodes/Elastic/Elasticsearch/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Elastic/Elasticsearch/GenericFunctions.ts @@ -38,7 +38,7 @@ export async function elasticsearchApiRequest( try { return await this.helpers.requestWithAuthentication.call(this, 'elasticsearchApi', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -71,7 +71,7 @@ export async function elasticsearchApiRequestAllItems( responseData = await elasticsearchApiRequest.call(this, 'GET', '/_search', requestBody, qs); if (responseData?.hits?.hits) { - returnData = returnData.concat(responseData.hits.hits); + returnData = returnData.concat(responseData.hits.hits as IDataObject[]); const lastHitIndex = responseData.hits.hits.length - 1; //Sort values for the last returned hit with the tiebreaker value searchAfter = responseData.hits.hits[lastHitIndex].sort; @@ -88,7 +88,7 @@ export async function elasticsearchApiRequestAllItems( responseData = await elasticsearchApiRequest.call(this, 'GET', '/_search', requestBody, qs); if (responseData?.hits?.hits?.length) { - returnData = returnData.concat(responseData.hits.hits); + returnData = returnData.concat(responseData.hits.hits as IDataObject[]); const lastHitIndex = responseData.hits.hits.length - 1; searchAfter = responseData.hits.hits[lastHitIndex].sort; pit = responseData.pit_id; diff --git a/packages/nodes-base/nodes/EmailReadImap/v1/EmailReadImapV1.node.ts b/packages/nodes-base/nodes/EmailReadImap/v1/EmailReadImapV1.node.ts index 13f88a403f..9da9a45059 100644 --- a/packages/nodes-base/nodes/EmailReadImap/v1/EmailReadImapV1.node.ts +++ b/packages/nodes-base/nodes/EmailReadImap/v1/EmailReadImapV1.node.ts @@ -323,8 +323,8 @@ export class EmailReadImapV1 implements INodeType { .then(async (partData) => { // Return it in the format n8n expects return this.helpers.prepareBinaryData( - partData, - attachmentPart.disposition.params.filename, + partData as Buffer, + attachmentPart.disposition.params.filename as string, ); }); @@ -393,7 +393,7 @@ export class EmailReadImapV1 implements INodeType { } const parsedEmail = await parseRawEmail.call( this, - part.body, + part.body as Buffer, dataPropertyAttachmentsPrefixName, ); @@ -437,7 +437,7 @@ export class EmailReadImapV1 implements INodeType { }); messageBody = messageHeader[0].body; - for (propertyName of Object.keys(messageBody)) { + for (propertyName of Object.keys(messageBody as IDataObject)) { if (messageBody[propertyName].length) { if (topLevelProperties.includes(propertyName)) { newEmail.json[propertyName] = messageBody[propertyName][0]; @@ -579,7 +579,7 @@ export class EmailReadImapV1 implements INodeType { return imapConnect(config).then(async (conn) => { conn.on('error', async (error) => { const errorCode = error.code.toUpperCase(); - if (['ECONNRESET', 'EPIPE'].includes(errorCode)) { + if (['ECONNRESET', 'EPIPE'].includes(errorCode as string)) { Logger.verbose(`IMAP connection was reset (${errorCode}) - reconnecting.`, { error }); try { connection = await establishConnection(); @@ -591,7 +591,7 @@ export class EmailReadImapV1 implements INodeType { } } else { Logger.error('Email Read Imap node encountered a connection error', { error }); - this.emitError(error); + this.emitError(error as Error); } }); return conn; diff --git a/packages/nodes-base/nodes/EmailReadImap/v2/EmailReadImapV2.node.ts b/packages/nodes-base/nodes/EmailReadImap/v2/EmailReadImapV2.node.ts index 0d71a8eb13..a2ca0f0bd7 100644 --- a/packages/nodes-base/nodes/EmailReadImap/v2/EmailReadImapV2.node.ts +++ b/packages/nodes-base/nodes/EmailReadImap/v2/EmailReadImapV2.node.ts @@ -331,8 +331,8 @@ export class EmailReadImapV2 implements INodeType { .then(async (partData) => { // Return it in the format n8n expects return this.helpers.prepareBinaryData( - partData, - attachmentPart.disposition.params.filename, + partData as Buffer, + attachmentPart.disposition.params.filename as string, ); }); @@ -401,7 +401,7 @@ export class EmailReadImapV2 implements INodeType { } const parsedEmail = await parseRawEmail.call( this, - part.body, + part.body as Buffer, dataPropertyAttachmentsPrefixName, ); @@ -445,7 +445,7 @@ export class EmailReadImapV2 implements INodeType { }); messageBody = messageHeader[0].body; - for (propertyName of Object.keys(messageBody)) { + for (propertyName of Object.keys(messageBody as IDataObject)) { if (messageBody[propertyName].length) { if (topLevelProperties.includes(propertyName)) { newEmail.json[propertyName] = messageBody[propertyName][0]; @@ -567,7 +567,7 @@ export class EmailReadImapV2 implements INodeType { } }, onupdate: async (seqno: number, info) => { - Logger.verbose(`Email Read Imap:update ${seqno}`, info); + Logger.verbose(`Email Read Imap:update ${seqno}`, info as IDataObject); }, }; @@ -603,7 +603,7 @@ export class EmailReadImapV2 implements INodeType { Logger.verbose(`IMAP connection experienced an error: (${errorCode})`, { error }); // eslint-disable-next-line @typescript-eslint/no-use-before-define await closeFunction(); - this.emitError(error); + this.emitError(error as Error); }); return conn; }); @@ -625,7 +625,7 @@ export class EmailReadImapV2 implements INodeType { connection = await establishConnection(); await connection.openBox(mailbox); } catch (error) { - Logger.error(error); + Logger.error(error as string); } finally { isCurrentlyReconnecting = false; } diff --git a/packages/nodes-base/nodes/Emelia/Emelia.node.ts b/packages/nodes-base/nodes/Emelia/Emelia.node.ts index 36d3045c6b..e54052a82b 100644 --- a/packages/nodes-base/nodes/Emelia/Emelia.node.ts +++ b/packages/nodes-base/nodes/Emelia/Emelia.node.ts @@ -165,7 +165,7 @@ export class Emelia implements INodeType { }); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData.data.createCampaign), + this.helpers.returnJsonArray(responseData.data.createCampaign as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -210,7 +210,7 @@ export class Emelia implements INodeType { }); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData.data.campaign), + this.helpers.returnJsonArray(responseData.data.campaign as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -252,7 +252,7 @@ export class Emelia implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(campaigns), + this.helpers.returnJsonArray(campaigns as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -423,7 +423,7 @@ export class Emelia implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(contactLists), + this.helpers.returnJsonArray(contactLists as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Emelia/EmeliaTrigger.node.ts b/packages/nodes-base/nodes/Emelia/EmeliaTrigger.node.ts index 657294efc8..82214f4a3f 100644 --- a/packages/nodes-base/nodes/Emelia/EmeliaTrigger.node.ts +++ b/packages/nodes-base/nodes/Emelia/EmeliaTrigger.node.ts @@ -1,4 +1,5 @@ import type { + IDataObject, IHookFunctions, ILoadOptionsFunctions, INodePropertyOptions, @@ -174,7 +175,7 @@ export class EmeliaTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const req = this.getRequestObject(); return { - workflowData: [this.helpers.returnJsonArray(req.body)], + workflowData: [this.helpers.returnJsonArray(req.body as IDataObject)], }; } } diff --git a/packages/nodes-base/nodes/Emelia/GenericFunctions.ts b/packages/nodes-base/nodes/Emelia/GenericFunctions.ts index bf04a3dbc8..043000f5b6 100644 --- a/packages/nodes-base/nodes/Emelia/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Emelia/GenericFunctions.ts @@ -50,7 +50,7 @@ export async function emeliaGraphqlRequest( const response = await emeliaApiRequest.call(this, 'POST', '/graphql', body); if (response.errors) { - throw new NodeApiError(this.getNode(), response); + throw new NodeApiError(this.getNode(), response as JsonObject); } return response; diff --git a/packages/nodes-base/nodes/Eventbrite/EventbriteTrigger.node.ts b/packages/nodes-base/nodes/Eventbrite/EventbriteTrigger.node.ts index a385324909..4a4e3ecbb6 100644 --- a/packages/nodes-base/nodes/Eventbrite/EventbriteTrigger.node.ts +++ b/packages/nodes-base/nodes/Eventbrite/EventbriteTrigger.node.ts @@ -7,6 +7,7 @@ import type { INodeType, INodeTypeDescription, IWebhookResponseData, + JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -248,7 +249,7 @@ export class EventbriteTrigger implements INodeType { }; for (const webhook of webhooks) { - if (webhook.endpoint_url === webhookUrl && check(actions, webhook.actions)) { + if (webhook.endpoint_url === webhookUrl && check(actions, webhook.actions as string[])) { webhookData.webhookId = webhook.id; return true; } @@ -297,7 +298,7 @@ export class EventbriteTrigger implements INodeType { const req = this.getRequestObject(); if (req.body.api_url === undefined) { - throw new NodeApiError(this.getNode(), req.body, { + throw new NodeApiError(this.getNode(), req.body as JsonObject, { message: 'The received data does not contain required "api_url" property!', }); } @@ -307,7 +308,7 @@ export class EventbriteTrigger implements INodeType { if (!resolveData) { // Return the data as it got received return { - workflowData: [this.helpers.returnJsonArray(req.body)], + workflowData: [this.helpers.returnJsonArray(req.body as IDataObject)], }; } @@ -328,11 +329,11 @@ export class EventbriteTrigger implements INodeType { '', {}, undefined, - req.body.api_url, + req.body.api_url as string, ); return { - workflowData: [this.helpers.returnJsonArray(responseData)], + workflowData: [this.helpers.returnJsonArray(responseData as IDataObject)], }; } } diff --git a/packages/nodes-base/nodes/Eventbrite/GenericFunctions.ts b/packages/nodes-base/nodes/Eventbrite/GenericFunctions.ts index 8e6d88a7e9..dba22be6ab 100644 --- a/packages/nodes-base/nodes/Eventbrite/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Eventbrite/GenericFunctions.ts @@ -35,7 +35,7 @@ export async function eventbriteApiRequest( json: true, }; options = Object.assign({}, options, option); - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } @@ -75,7 +75,7 @@ export async function eventbriteApiRequestAllItems( do { responseData = await eventbriteApiRequest.call(this, method, resource, body, query); query.continuation = responseData.pagination.continuation; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while ( responseData.pagination?.has_more_items !== undefined && responseData.pagination.has_more_items !== false diff --git a/packages/nodes-base/nodes/Facebook/FacebookGraphApi.node.ts b/packages/nodes-base/nodes/Facebook/FacebookGraphApi.node.ts index 4b10c8e2ff..b53df356e7 100644 --- a/packages/nodes-base/nodes/Facebook/FacebookGraphApi.node.ts +++ b/packages/nodes-base/nodes/Facebook/FacebookGraphApi.node.ts @@ -4,6 +4,7 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -413,7 +414,7 @@ export class FacebookGraphApi implements INodeType { response = await this.helpers.request(requestOptions); } catch (error) { if (!this.continueOnFail()) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } let errorItem; diff --git a/packages/nodes-base/nodes/Facebook/FacebookTrigger.node.ts b/packages/nodes-base/nodes/Facebook/FacebookTrigger.node.ts index 9e14cdb0e7..b0b613b9dd 100644 --- a/packages/nodes-base/nodes/Facebook/FacebookTrigger.node.ts +++ b/packages/nodes-base/nodes/Facebook/FacebookTrigger.node.ts @@ -7,6 +7,7 @@ import type { INodeType, INodeTypeDescription, IWebhookResponseData, + JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -220,7 +221,7 @@ export class FacebookTrigger implements INodeType { if (responseData.success !== true) { // Facebook did not return success, so something went wrong - throw new NodeApiError(this.getNode(), responseData, { + throw new NodeApiError(this.getNode(), responseData as JsonObject, { message: 'Facebook webhook creation response did not contain the expected data.', }); } diff --git a/packages/nodes-base/nodes/Facebook/GenericFunctions.ts b/packages/nodes-base/nodes/Facebook/GenericFunctions.ts index 9a1034f88b..9cc6aa60a7 100644 --- a/packages/nodes-base/nodes/Facebook/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Facebook/GenericFunctions.ts @@ -8,7 +8,7 @@ import type { IWebhookFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import { capitalCase } from 'change-case'; @@ -53,7 +53,7 @@ export async function facebookApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -554,6 +554,7 @@ export function getFields(object: string) { ], } as { [key: string]: any }; + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument return [{ name: '*', value: '*' }].concat(data[object] || []).map((fieldObject: IDataObject) => ({ ...fieldObject, name: fieldObject.value !== '*' ? capitalCase(fieldObject.value as string) : fieldObject.value, diff --git a/packages/nodes-base/nodes/Figma/GenericFunctions.ts b/packages/nodes-base/nodes/Figma/GenericFunctions.ts index 73ff4f4b80..3fb79a1cad 100644 --- a/packages/nodes-base/nodes/Figma/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Figma/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function figmaApiRequest( @@ -30,12 +30,12 @@ export async function figmaApiRequest( json: true, }; options = Object.assign({}, options, option); - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/FileMaker/FileMaker.node.ts b/packages/nodes-base/nodes/FileMaker/FileMaker.node.ts index affa5602cd..329e2f2c4d 100644 --- a/packages/nodes-base/nodes/FileMaker/FileMaker.node.ts +++ b/packages/nodes-base/nodes/FileMaker/FileMaker.node.ts @@ -1,6 +1,7 @@ /* eslint-disable n8n-nodes-base/node-filename-against-convention */ import type { IExecuteFunctions } from 'n8n-core'; import type { + IDataObject, ILoadOptionsFunctions, INodeExecutionData, INodePropertyOptions, @@ -604,7 +605,7 @@ export class FileMaker implements INodeType { try { returnData = await layoutsApiRequest.call(this); } catch (error) { - throw new NodeOperationError(this.getNode(), error); + throw new NodeOperationError(this.getNode(), error as Error); } return returnData; @@ -620,7 +621,7 @@ export class FileMaker implements INodeType { try { layouts = await layoutsApiRequest.call(this); } catch (error) { - throw new NodeOperationError(this.getNode(), error); + throw new NodeOperationError(this.getNode(), error as Error); } for (const layout of layouts) { returnData.push({ @@ -638,7 +639,7 @@ export class FileMaker implements INodeType { try { fields = await getFields.call(this); } catch (error) { - throw new NodeOperationError(this.getNode(), error); + throw new NodeOperationError(this.getNode(), error as Error); } for (const field of fields) { returnData.push({ @@ -656,7 +657,7 @@ export class FileMaker implements INodeType { try { scripts = await getScripts.call(this); } catch (error) { - throw new NodeOperationError(this.getNode(), error); + throw new NodeOperationError(this.getNode(), error as Error); } for (const script of scripts) { if (!script.isFolder) { @@ -676,9 +677,9 @@ export class FileMaker implements INodeType { try { portals = await getPortals.call(this); } catch (error) { - throw new NodeOperationError(this.getNode(), error); + throw new NodeOperationError(this.getNode(), error as Error); } - Object.keys(portals).forEach((portal) => { + Object.keys(portals as IDataObject).forEach((portal) => { returnData.push({ name: portal, value: portal, @@ -830,7 +831,7 @@ export class FileMaker implements INodeType { returnData.push({ json: response }); } } catch (error) { - await logout.call(this, token); + await logout.call(this, token as string); if (error.node) { throw error; diff --git a/packages/nodes-base/nodes/FileMaker/GenericFunctions.ts b/packages/nodes-base/nodes/FileMaker/GenericFunctions.ts index 28ef268132..9607aaaec2 100644 --- a/packages/nodes-base/nodes/FileMaker/GenericFunctions.ts +++ b/packages/nodes-base/nodes/FileMaker/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject, INodePropertyOptions } from 'n8n-workflow'; +import type { IDataObject, INodePropertyOptions, JsonObject } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; import type { OptionsWithUri } from 'request'; @@ -71,7 +71,7 @@ export async function getToken( return response.response.token; } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -115,11 +115,11 @@ export async function layoutsApiRequest( try { const responseData = await this.helpers.request(options); - const items = parseLayouts(responseData.response.layouts); + const items = parseLayouts(responseData.response.layouts as LayoutObject[]); items.sort((a, b) => (a.name > b.name ? 0 : 1)); return items; } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -223,7 +223,7 @@ export async function getScripts(this: ILoadOptionsFunctions): Promise { try { const responseData = await this.helpers.request(options); - const items = parseScriptsList(responseData.response.scripts); + const items = parseScriptsList(responseData.response.scripts as ScriptObject[]); items.sort((a, b) => (a.name > b.name ? 0 : 1)); return items; } catch (error) { diff --git a/packages/nodes-base/nodes/Flow/Flow.node.ts b/packages/nodes-base/nodes/Flow/Flow.node.ts index 3479c50b77..ce38b63cb8 100644 --- a/packages/nodes-base/nodes/Flow/Flow.node.ts +++ b/packages/nodes-base/nodes/Flow/Flow.node.ts @@ -4,6 +4,7 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import { flowApiRequest, FlowApiRequestAllItems } from './GenericFunctions'; @@ -124,7 +125,7 @@ export class Flow implements INodeType { responseData = await flowApiRequest.call(this, 'POST', '/tasks', body); responseData = responseData.task; } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } //https://developer.getflow.com/api/#tasks_update-a-task @@ -192,7 +193,7 @@ export class Flow implements INodeType { responseData = await flowApiRequest.call(this, 'PUT', `/tasks/${taskId}`, body); responseData = responseData.task; } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } //https://developer.getflow.com/api/#tasks_get-task @@ -206,7 +207,7 @@ export class Flow implements INodeType { try { responseData = await flowApiRequest.call(this, 'GET', `/tasks/${taskId}`, {}, qs); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } //https://developer.getflow.com/api/#tasks_get-tasks @@ -257,13 +258,13 @@ export class Flow implements INodeType { responseData = responseData.tasks; } } catch (error) { - throw new NodeApiError(this.getNode(), error, { itemIndex: i }); + throw new NodeApiError(this.getNode(), error as JsonObject, { itemIndex: i }); } } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Flow/FlowTrigger.node.ts b/packages/nodes-base/nodes/Flow/FlowTrigger.node.ts index 62c4e59262..fadc50ce2d 100644 --- a/packages/nodes-base/nodes/Flow/FlowTrigger.node.ts +++ b/packages/nodes-base/nodes/Flow/FlowTrigger.node.ts @@ -193,7 +193,7 @@ export class FlowTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const req = this.getRequestObject(); return { - workflowData: [this.helpers.returnJsonArray(req.body)], + workflowData: [this.helpers.returnJsonArray(req.body as IDataObject[])], }; } } diff --git a/packages/nodes-base/nodes/Flow/GenericFunctions.ts b/packages/nodes-base/nodes/Flow/GenericFunctions.ts index 9b54bdeb9f..70903c4523 100644 --- a/packages/nodes-base/nodes/Flow/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Flow/GenericFunctions.ts @@ -5,7 +5,7 @@ import type { IHookFunctions, ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function flowApiRequest( @@ -29,14 +29,14 @@ export async function flowApiRequest( json: true, }; options = Object.assign({}, options, option); - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -67,7 +67,7 @@ export async function FlowApiRequestAllItems( }); uri = responseData.headers.link; // @ts-ignore - returnData.push.apply(returnData, responseData.body[propertyName]); + returnData.push.apply(returnData, responseData.body[propertyName] as IDataObject[]); } while (responseData.headers.link !== undefined && responseData.headers.link !== ''); return returnData; diff --git a/packages/nodes-base/nodes/FormIo/FormIoTrigger.node.ts b/packages/nodes-base/nodes/FormIo/FormIoTrigger.node.ts index 02d582f896..5217c75924 100644 --- a/packages/nodes-base/nodes/FormIo/FormIoTrigger.node.ts +++ b/packages/nodes-base/nodes/FormIo/FormIoTrigger.node.ts @@ -1,6 +1,7 @@ import type { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import type { + IDataObject, ILoadOptionsFunctions, INodePropertyOptions, INodeType, @@ -139,7 +140,7 @@ export class FormIoTrigger implements INodeType { if ( action.settings.url === webhookUrl && action.method.length === method.length && - action.method.every((value: any) => method.includes(value)) + action.method.every((value: any) => method.includes(value as string)) ) { webhookData.webhookId = action._id; return true; @@ -205,7 +206,7 @@ export class FormIoTrigger implements INodeType { response = response.data; } return { - workflowData: [this.helpers.returnJsonArray(response)], + workflowData: [this.helpers.returnJsonArray(response as IDataObject[])], }; } } diff --git a/packages/nodes-base/nodes/FormIo/GenericFunctions.ts b/packages/nodes-base/nodes/FormIo/GenericFunctions.ts index 35f954796d..0a4c85e5d0 100644 --- a/packages/nodes-base/nodes/FormIo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/FormIo/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IHookFunctions, IWebhookFunctions } from 'n8n-workflow'; +import type { IHookFunctions, IWebhookFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; interface IFormIoCredentials { @@ -75,6 +75,6 @@ export async function formIoApiRequest( try { return await this.helpers.request.call(this, options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Formstack/GenericFunctions.ts b/packages/nodes-base/nodes/Formstack/GenericFunctions.ts index 75f1e65fc5..52ec0bda44 100644 --- a/packages/nodes-base/nodes/Formstack/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Formstack/GenericFunctions.ts @@ -5,7 +5,7 @@ import type { IWebhookFunctions, } from 'n8n-core'; -import type { IDataObject, INodePropertyOptions } from 'n8n-workflow'; +import type { IDataObject, INodePropertyOptions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import type { OptionsWithUri } from 'request'; @@ -80,7 +80,7 @@ export async function apiRequest( return await this.helpers.requestOAuth2.call(this, 'formstackOAuth2Api', options); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -115,7 +115,7 @@ export async function apiRequestAllItems( query.page += 1; responseData = await apiRequest.call(this, method, endpoint, body, query); - returnData.items.push.apply(returnData.items, responseData[dataKey]); + returnData.items.push.apply(returnData.items, responseData[dataKey] as IDataObject[]); } while ( responseData.total !== undefined && Math.ceil(responseData.total / query.per_page) > query.page diff --git a/packages/nodes-base/nodes/Freshdesk/Freshdesk.node.ts b/packages/nodes-base/nodes/Freshdesk/Freshdesk.node.ts index 7ae5848d46..2e43a258a4 100644 --- a/packages/nodes-base/nodes/Freshdesk/Freshdesk.node.ts +++ b/packages/nodes-base/nodes/Freshdesk/Freshdesk.node.ts @@ -1405,7 +1405,7 @@ export class Freshdesk implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Freshdesk/GenericFunctions.ts b/packages/nodes-base/nodes/Freshdesk/GenericFunctions.ts index 385b06b7d4..823b16134c 100644 --- a/packages/nodes-base/nodes/Freshdesk/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Freshdesk/GenericFunctions.ts @@ -3,7 +3,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { BINARY_ENCODING } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function freshdeskApiRequest( @@ -33,7 +33,7 @@ export async function freshdeskApiRequest( uri: uri || `https://${credentials.domain}.${endpoint}${resource}`, json: true, }; - if (!Object.keys(body).length) { + if (!Object.keys(body as IDataObject).length) { delete options.body; } if (!Object.keys(query).length) { @@ -43,7 +43,7 @@ export async function freshdeskApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -67,7 +67,7 @@ export async function freshdeskApiRequestAllItems( if (responseData.headers.link) { uri = responseData.headers.link.split(';')[0].replace('<', '').replace('>', ''); } - returnData.push.apply(returnData, responseData.body); + returnData.push.apply(returnData, responseData.body as IDataObject[]); } while (responseData.headers.link?.includes('rel="next"')); return returnData; } diff --git a/packages/nodes-base/nodes/Freshservice/Freshservice.node.ts b/packages/nodes-base/nodes/Freshservice/Freshservice.node.ts index 66181396e0..2775d7de0c 100644 --- a/packages/nodes-base/nodes/Freshservice/Freshservice.node.ts +++ b/packages/nodes-base/nodes/Freshservice/Freshservice.node.ts @@ -237,6 +237,7 @@ export class Freshservice implements INodeType { fields = fields .concat(...asset_type_fields.map((data) => data.fields)) .map((data) => ({ name: data.label, id: data.name })); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument return toOptions(fields); }, @@ -1384,7 +1385,7 @@ export class Freshservice implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Freshservice/GenericFunctions.ts b/packages/nodes-base/nodes/Freshservice/GenericFunctions.ts index e88886895f..c75db17b6e 100644 --- a/packages/nodes-base/nodes/Freshservice/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Freshservice/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import type { IDataObject, ILoadOptionsFunctions } from 'n8n-workflow'; +import type { IDataObject, ILoadOptionsFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; import type { @@ -54,19 +54,19 @@ export async function freshserviceApiRequest( if (numberOfErrors === 1) { const [validationError] = error.error.errors; - throw new NodeApiError(this.getNode(), error, { + throw new NodeApiError(this.getNode(), error as JsonObject, { message, description: `For ${validationError.field}: ${validationError.message}`, }); } else if (numberOfErrors > 1) { - throw new NodeApiError(this.getNode(), error, { + throw new NodeApiError(this.getNode(), error as JsonObject, { message, description: "For more information, expand 'details' below and look at 'cause' section", }); } } - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -83,10 +83,10 @@ export async function freshserviceApiRequestAllItems( do { const responseData = await freshserviceApiRequest.call(this, method, endpoint, body, qs); - const key = Object.keys(responseData)[0]; + const key = Object.keys(responseData as IDataObject)[0]; items = responseData[key]; if (!items.length) return returnData; - returnData.push(...items); + returnData.push(...(items as IDataObject[])); qs.page++; } while (items.length >= 30); diff --git a/packages/nodes-base/nodes/FreshworksCrm/FreshworksCrm.node.ts b/packages/nodes-base/nodes/FreshworksCrm/FreshworksCrm.node.ts index c346483cfb..86c3058a4e 100644 --- a/packages/nodes-base/nodes/FreshworksCrm/FreshworksCrm.node.ts +++ b/packages/nodes-base/nodes/FreshworksCrm/FreshworksCrm.node.ts @@ -989,7 +989,7 @@ export class FreshworksCrm implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/FreshworksCrm/GenericFunctions.ts b/packages/nodes-base/nodes/FreshworksCrm/GenericFunctions.ts index 376c5c702c..d57a1e643b 100644 --- a/packages/nodes-base/nodes/FreshworksCrm/GenericFunctions.ts +++ b/packages/nodes-base/nodes/FreshworksCrm/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { IExecuteFunctions } from 'n8n-core'; -import type { IDataObject, ILoadOptionsFunctions } from 'n8n-workflow'; +import type { IDataObject, ILoadOptionsFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; import type { OptionsWithUri } from 'request'; @@ -42,7 +42,7 @@ export async function freshworksCrmApiRequest( const credentialsType = 'freshworksCrmApi'; return await this.helpers.requestWithAuthentication.call(this, credentialsType, options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -90,8 +90,8 @@ export async function freshworksCrmApiRequestAllItems( do { response = await freshworksCrmApiRequest.call(this, method, endpoint, body, qs); - const key = Object.keys(response)[0]; - returnData.push(...response[key]); + const key = Object.keys(response as IDataObject)[0]; + returnData.push(...(response[key] as IDataObject[])); qs.page++; } while (response.meta.total_pages && qs.page <= response.meta.total_pages); diff --git a/packages/nodes-base/nodes/Ftp/Ftp.node.ts b/packages/nodes-base/nodes/Ftp/Ftp.node.ts index 71e8d49ed5..18b0ac9f48 100644 --- a/packages/nodes-base/nodes/Ftp/Ftp.node.ts +++ b/packages/nodes-base/nodes/Ftp/Ftp.node.ts @@ -9,6 +9,7 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; import { createWriteStream } from 'fs'; @@ -783,7 +784,7 @@ export class Ftp implements INodeType { await ftp!.mkdir(dirPath, true); await ftp!.put(uploadData, remotePath); } else { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } } else { @@ -797,7 +798,7 @@ export class Ftp implements INodeType { await ftp!.mkdir(dirPath, true); await ftp!.put(buffer, remotePath); } else { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } } diff --git a/packages/nodes-base/nodes/Function/Function.node.ts b/packages/nodes-base/nodes/Function/Function.node.ts index 0511055a1f..a186f2d627 100644 --- a/packages/nodes-base/nodes/Function/Function.node.ts +++ b/packages/nodes-base/nodes/Function/Function.node.ts @@ -227,7 +227,7 @@ return items;`, const lineParts = stackLines.find((line: string) => line.includes('Function')).split(':'); if (lineParts.length > 2) { const lineNumber = lineParts.splice(-2, 1); - if (!isNaN(lineNumber)) { + if (!isNaN(lineNumber as number)) { error.message = `${error.message} [Line ${lineNumber}]`; } } diff --git a/packages/nodes-base/nodes/FunctionItem/FunctionItem.node.ts b/packages/nodes-base/nodes/FunctionItem/FunctionItem.node.ts index 6e39d8f31a..cf58cf0e5b 100644 --- a/packages/nodes-base/nodes/FunctionItem/FunctionItem.node.ts +++ b/packages/nodes-base/nodes/FunctionItem/FunctionItem.node.ts @@ -206,7 +206,7 @@ return item;`, .split(':'); if (lineParts.length > 2) { const lineNumber = lineParts.splice(-2, 1); - if (!isNaN(lineNumber)) { + if (!isNaN(lineNumber as number)) { error.message = `${error.message} [Line ${lineNumber} | Item Index: ${itemIndex}]`; return Promise.reject(error); } diff --git a/packages/nodes-base/nodes/GetResponse/GenericFunctions.ts b/packages/nodes-base/nodes/GetResponse/GenericFunctions.ts index 0aa7c097b2..e7d1367827 100644 --- a/packages/nodes-base/nodes/GetResponse/GenericFunctions.ts +++ b/packages/nodes-base/nodes/GetResponse/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { IWebhookFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function getresponseApiRequest( @@ -34,7 +34,7 @@ export async function getresponseApiRequest( }; try { options = Object.assign({}, options, option); - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } @@ -45,7 +45,7 @@ export async function getresponseApiRequest( return await this.helpers.requestOAuth2.call(this, 'getResponseOAuth2Api', options); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -73,7 +73,7 @@ export async function getResponseApiRequestAllItems( { resolveWithFullResponse: true }, ); query.page++; - returnData.push.apply(returnData, responseData.body); + returnData.push.apply(returnData, responseData.body as IDataObject[]); } while (responseData.headers.TotalPages !== responseData.headers.CurrentPage); return returnData; diff --git a/packages/nodes-base/nodes/GetResponse/GetResponse.node.ts b/packages/nodes-base/nodes/GetResponse/GetResponse.node.ts index 9541504d09..b2f1abfb82 100644 --- a/packages/nodes-base/nodes/GetResponse/GetResponse.node.ts +++ b/packages/nodes-base/nodes/GetResponse/GetResponse.node.ts @@ -293,7 +293,7 @@ export class GetResponse implements INodeType { } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/GetResponse/GetResponseTrigger.node.ts b/packages/nodes-base/nodes/GetResponse/GetResponseTrigger.node.ts index d587d69ce1..e290dc1f8e 100644 --- a/packages/nodes-base/nodes/GetResponse/GetResponseTrigger.node.ts +++ b/packages/nodes-base/nodes/GetResponse/GetResponseTrigger.node.ts @@ -7,6 +7,7 @@ import type { INodeType, INodeTypeDescription, IWebhookResponseData, + JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -166,7 +167,7 @@ export class GetResponseTrigger implements INodeType { if (data.url !== webhookUrl) { if (!deleteCurrentSubscription) { - throw new NodeApiError(this.getNode(), data, { + throw new NodeApiError(this.getNode(), data as JsonObject, { message: `The webhook (${data.url}) is active in the account. Delete it manually or set the parameter "Delete Current Subscription" to true, and the node will delete it for you.`, }); } diff --git a/packages/nodes-base/nodes/Ghost/GenericFunctions.ts b/packages/nodes-base/nodes/Ghost/GenericFunctions.ts index 6db387cfe5..7fe74a3b70 100644 --- a/packages/nodes-base/nodes/Ghost/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Ghost/GenericFunctions.ts @@ -64,7 +64,7 @@ export async function ghostApiRequestAllItems( do { responseData = await ghostApiRequest.call(this, method, endpoint, body, query); query.page = responseData.meta.pagination.next; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (query.page !== null); return returnData; } diff --git a/packages/nodes-base/nodes/Ghost/Ghost.node.ts b/packages/nodes-base/nodes/Ghost/Ghost.node.ts index 88009a4449..2f0e93ba90 100644 --- a/packages/nodes-base/nodes/Ghost/Ghost.node.ts +++ b/packages/nodes-base/nodes/Ghost/Ghost.node.ts @@ -341,7 +341,7 @@ export class Ghost implements INodeType { } } - responseData = this.helpers.returnJsonArray(responseData); + responseData = this.helpers.returnJsonArray(responseData as IDataObject[]); const executionData = this.helpers.constructExecutionMetaData( this.helpers.returnJsonArray(responseData), { itemData: { item: i } }, diff --git a/packages/nodes-base/nodes/Github/GenericFunctions.ts b/packages/nodes-base/nodes/Github/GenericFunctions.ts index d25f4e588b..cb99b5fb3d 100644 --- a/packages/nodes-base/nodes/Github/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Github/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import type { IDataObject, ILoadOptionsFunctions } from 'n8n-workflow'; +import type { IDataObject, ILoadOptionsFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; /** @@ -56,7 +56,7 @@ export async function githubApiRequest( return await this.helpers.requestWithAuthentication.call(this, credentialType, options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -101,11 +101,11 @@ export async function githubApiRequestAllItems( query.page = 1; do { - responseData = await githubApiRequest.call(this, method, endpoint, body, query, { + responseData = await githubApiRequest.call(this, method, endpoint, body as IDataObject, query, { resolveWithFullResponse: true, }); query.page++; - returnData.push.apply(returnData, responseData.body); + returnData.push.apply(returnData, responseData.body as IDataObject[]); } while (responseData.headers.link?.includes('next')); return returnData; } diff --git a/packages/nodes-base/nodes/Github/Github.node.ts b/packages/nodes-base/nodes/Github/Github.node.ts index 5dac88eb7f..c91733ac9e 100644 --- a/packages/nodes-base/nodes/Github/Github.node.ts +++ b/packages/nodes-base/nodes/Github/Github.node.ts @@ -2250,7 +2250,7 @@ export class Github implements INodeType { overwriteDataOperationsArray.includes(fullOperation) ) { const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Github/GithubTrigger.node.ts b/packages/nodes-base/nodes/Github/GithubTrigger.node.ts index 518f2d0d87..63298d219b 100644 --- a/packages/nodes-base/nodes/Github/GithubTrigger.node.ts +++ b/packages/nodes-base/nodes/Github/GithubTrigger.node.ts @@ -5,6 +5,7 @@ import type { INodeType, INodeTypeDescription, IWebhookResponseData, + JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -535,7 +536,7 @@ export class GithubTrigger implements INodeType { if (responseData.id === undefined || responseData.active !== true) { // Required data is missing so was not successful - throw new NodeApiError(this.getNode(), responseData, { + throw new NodeApiError(this.getNode(), responseData as JsonObject, { message: 'Github webhook creation response did not contain the expected data.', }); } diff --git a/packages/nodes-base/nodes/Gitlab/GenericFunctions.ts b/packages/nodes-base/nodes/Gitlab/GenericFunctions.ts index e7c32c463b..7f17384839 100644 --- a/packages/nodes-base/nodes/Gitlab/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Gitlab/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import type { OptionsWithUri } from 'request'; @@ -47,7 +47,7 @@ export async function gitlabApiRequest( return await this.helpers.requestOAuth2.call(this, 'gitlabOAuth2Api', options); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -67,11 +67,11 @@ export async function gitlabApiRequestAllItems( query.page = 1; do { - responseData = await gitlabApiRequest.call(this, method, endpoint, body, query, { + responseData = await gitlabApiRequest.call(this, method, endpoint, body as IDataObject, query, { resolveWithFullResponse: true, }); query.page++; - returnData.push.apply(returnData, responseData.body); + returnData.push.apply(returnData, responseData.body as IDataObject[]); } while (responseData.headers.link?.includes('next')); return returnData; } diff --git a/packages/nodes-base/nodes/Gitlab/Gitlab.node.ts b/packages/nodes-base/nodes/Gitlab/Gitlab.node.ts index a4023ced8a..e2f4837677 100644 --- a/packages/nodes-base/nodes/Gitlab/Gitlab.node.ts +++ b/packages/nodes-base/nodes/Gitlab/Gitlab.node.ts @@ -1302,7 +1302,7 @@ export class Gitlab implements INodeType { if (this.continueOnFail()) { return [this.helpers.returnJsonArray([{ error: error.message }])]; } - throw new NodeOperationError(this.getNode(), error); + throw new NodeOperationError(this.getNode(), error as Error); } // Operations which overwrite the returned data @@ -1720,7 +1720,7 @@ export class Gitlab implements INodeType { overwriteDataOperationsArray.includes(fullOperation) ) { const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Gitlab/GitlabTrigger.node.ts b/packages/nodes-base/nodes/Gitlab/GitlabTrigger.node.ts index f9f4056da3..e0bc0667d2 100644 --- a/packages/nodes-base/nodes/Gitlab/GitlabTrigger.node.ts +++ b/packages/nodes-base/nodes/Gitlab/GitlabTrigger.node.ts @@ -5,6 +5,7 @@ import type { INodeType, INodeTypeDescription, IWebhookResponseData, + JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -250,12 +251,12 @@ export class GitlabTrigger implements INodeType { try { responseData = await gitlabApiRequest.call(this, 'POST', endpoint, body); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } if (responseData.id === undefined) { // Required data is missing so was not successful - throw new NodeApiError(this.getNode(), responseData, { + throw new NodeApiError(this.getNode(), responseData as JsonObject, { message: 'GitLab webhook creation response did not contain the expected data.', }); } diff --git a/packages/nodes-base/nodes/GoToWebinar/GenericFunctions.ts b/packages/nodes-base/nodes/GoToWebinar/GenericFunctions.ts index 3037100c7a..b40544b45d 100644 --- a/packages/nodes-base/nodes/GoToWebinar/GenericFunctions.ts +++ b/packages/nodes-base/nodes/GoToWebinar/GenericFunctions.ts @@ -1,6 +1,11 @@ import type { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import type { IDataObject, ILoadOptionsFunctions, INodePropertyOptions } from 'n8n-workflow'; +import type { + IDataObject, + ILoadOptionsFunctions, + INodePropertyOptions, + JsonObject, +} from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import type { OptionsWithUri } from 'request'; @@ -70,9 +75,9 @@ export async function goToWebinarApiRequest( } // https://stackoverflow.com/questions/62190724/getting-gotowebinar-registrant - return losslessJSON.parse(response, convertLosslessNumber); + return losslessJSON.parse(response as string, convertLosslessNumber); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -100,12 +105,12 @@ export async function goToWebinarApiRequestAllItems( do { responseData = await goToWebinarApiRequest.call(this, method, endpoint, qs, body); - if (responseData.page && parseInt(responseData.page.totalElements, 10) === 0) { + if (responseData.page && parseInt(responseData.page.totalElements as string, 10) === 0) { return []; } else if (responseData._embedded?.[key]) { - returnData.push(...responseData._embedded[key]); + returnData.push(...(responseData._embedded[key] as IDataObject[])); } else { - returnData.push(...responseData); + returnData.push(...(responseData as IDataObject[])); } if (qs.limit && returnData.length >= qs.limit) { @@ -114,7 +119,7 @@ export async function goToWebinarApiRequestAllItems( } } while ( responseData.totalElements && - parseInt(responseData.totalElements, 10) > returnData.length + parseInt(responseData.totalElements as string, 10) > returnData.length ); return returnData; diff --git a/packages/nodes-base/nodes/GoToWebinar/GoToWebinar.node.ts b/packages/nodes-base/nodes/GoToWebinar/GoToWebinar.node.ts index 5cca0919a3..4dcce9f046 100644 --- a/packages/nodes-base/nodes/GoToWebinar/GoToWebinar.node.ts +++ b/packages/nodes-base/nodes/GoToWebinar/GoToWebinar.node.ts @@ -646,7 +646,7 @@ export class GoToWebinar implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Google/Analytics/v1/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Analytics/v1/GenericFunctions.ts index f4902752f8..165e625af4 100644 --- a/packages/nodes-base/nodes/Google/Analytics/v1/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Analytics/v1/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function googleApiRequest( @@ -43,9 +43,13 @@ export async function googleApiRequest( const [message, ...rest] = parsedError.error.message.split('\n'); const description = rest.join('\n'); const httpCode = parsedError.error.code; - throw new NodeApiError(this.getNode(), error, { message, description, httpCode }); + throw new NodeApiError(this.getNode(), error as JsonObject, { + message, + description, + httpCode, + }); } - throw new NodeApiError(this.getNode(), error, { message: error.message }); + throw new NodeApiError(this.getNode(), error as JsonObject, { message: error.message }); } } @@ -69,7 +73,7 @@ export async function googleApiRequestAllItems( } else { body.pageToken = responseData.nextPageToken; } - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while ( (responseData.nextPageToken !== undefined && responseData.nextPageToken !== '') || responseData[propertyName]?.[0].nextPageToken !== undefined @@ -119,7 +123,7 @@ export function merge(responseData: [any]) { for (const { data: { rows }, } of responseData) { - allRows.push(...rows); + allRows.push(...(rows as IDataObject[])); } response.data.rows = allRows as []; return [response]; diff --git a/packages/nodes-base/nodes/Google/Analytics/v1/GoogleAnalyticsV1.node.ts b/packages/nodes-base/nodes/Google/Analytics/v1/GoogleAnalyticsV1.node.ts index a99aac1146..31cf060335 100644 --- a/packages/nodes-base/nodes/Google/Analytics/v1/GoogleAnalyticsV1.node.ts +++ b/packages/nodes-base/nodes/Google/Analytics/v1/GoogleAnalyticsV1.node.ts @@ -245,6 +245,7 @@ export class GoogleAnalyticsV1 implements INodeType { if (simple) { responseData = simplify(responseData); } else if (returnAll && responseData.length > 1) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument responseData = merge(responseData); } } @@ -284,7 +285,7 @@ export class GoogleAnalyticsV1 implements INodeType { } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Google/Analytics/v2/actions/report/get.universal.operation.ts b/packages/nodes-base/nodes/Google/Analytics/v2/actions/report/get.universal.operation.ts index b5adbd6859..ff3cb1f40a 100644 --- a/packages/nodes-base/nodes/Google/Analytics/v2/actions/report/get.universal.operation.ts +++ b/packages/nodes-base/nodes/Google/Analytics/v2/actions/report/get.universal.operation.ts @@ -713,11 +713,12 @@ export async function execute( if (simple) { responseData = simplify(responseData); } else if (returnAll && responseData.length > 1) { + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument responseData = merge(responseData); } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: index } }, ); diff --git a/packages/nodes-base/nodes/Google/Analytics/v2/actions/userActivity/search.operation.ts b/packages/nodes-base/nodes/Google/Analytics/v2/actions/userActivity/search.operation.ts index f0e633cbd1..dfa6f79a1d 100644 --- a/packages/nodes-base/nodes/Google/Analytics/v2/actions/userActivity/search.operation.ts +++ b/packages/nodes-base/nodes/Google/Analytics/v2/actions/userActivity/search.operation.ts @@ -150,7 +150,7 @@ export async function execute( } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: index } }, ); diff --git a/packages/nodes-base/nodes/Google/Analytics/v2/helpers/utils.ts b/packages/nodes-base/nodes/Google/Analytics/v2/helpers/utils.ts index a01f7dc608..71d3722053 100644 --- a/packages/nodes-base/nodes/Google/Analytics/v2/helpers/utils.ts +++ b/packages/nodes-base/nodes/Google/Analytics/v2/helpers/utils.ts @@ -47,7 +47,7 @@ export function merge(responseData: [any]) { for (const { data: { rows }, } of responseData) { - allRows.push(...rows); + allRows.push(...(rows as IDataObject[])); } response.data.rows = allRows as []; return [response]; diff --git a/packages/nodes-base/nodes/Google/Analytics/v2/transport/index.ts b/packages/nodes-base/nodes/Google/Analytics/v2/transport/index.ts index 7370f2be76..ce4a824003 100644 --- a/packages/nodes-base/nodes/Google/Analytics/v2/transport/index.ts +++ b/packages/nodes-base/nodes/Google/Analytics/v2/transport/index.ts @@ -1,6 +1,6 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function googleApiRequest( @@ -48,10 +48,14 @@ export async function googleApiRequest( const [message, ...rest] = parsedError.error.message.split('\n'); const description = rest.join('\n'); const httpCode = parsedError.error.code; - throw new NodeApiError(this.getNode(), error, { message, description, httpCode }); + throw new NodeApiError(this.getNode(), error as JsonObject, { + message, + description, + httpCode, + }); } } - throw new NodeApiError(this.getNode(), error, { message: error.message }); + throw new NodeApiError(this.getNode(), error as JsonObject, { message: error.message }); } } @@ -75,16 +79,16 @@ export async function googleApiRequestAllItems( query.offset = 0; responseData = await googleApiRequest.call(this, method, endpoint, body, query, uri); - rows = rows.concat(responseData.rows); + rows = rows.concat(responseData.rows as IDataObject[]); query.offset = rows.length; while (responseData.rowCount > rows.length) { responseData = await googleApiRequest.call(this, method, endpoint, body, query, uri); - rows = rows.concat(responseData.rows); + rows = rows.concat(responseData.rows as IDataObject[]); query.offset = rows.length; } responseData.rows = rows; - returnData.push(responseData); + returnData.push(responseData as IDataObject); } else { do { responseData = await googleApiRequest.call(this, method, endpoint, body, query, uri); @@ -94,7 +98,7 @@ export async function googleApiRequestAllItems( } else { body.pageToken = responseData.nextPageToken; } - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while ( (responseData.nextPageToken !== undefined && responseData.nextPageToken !== '') || responseData[propertyName]?.[0].nextPageToken !== undefined diff --git a/packages/nodes-base/nodes/Google/BigQuery/GenericFunctions.ts b/packages/nodes-base/nodes/Google/BigQuery/GenericFunctions.ts index a484bfc275..9f62de8ba1 100644 --- a/packages/nodes-base/nodes/Google/BigQuery/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/BigQuery/GenericFunctions.ts @@ -87,7 +87,7 @@ export async function googleApiRequest( if (Object.keys(headers).length !== 0) { options.headers = Object.assign({}, options.headers, headers); } - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } @@ -131,7 +131,7 @@ export async function googleApiRequestAllItems( do { responseData = await googleApiRequest.call(this, method, endpoint, body, query); query.pageToken = responseData.pageToken; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.pageToken !== undefined && responseData.pageToken !== ''); return returnData; diff --git a/packages/nodes-base/nodes/Google/BigQuery/GoogleBigQuery.node.ts b/packages/nodes-base/nodes/Google/BigQuery/GoogleBigQuery.node.ts index 3a7f905190..ce340591ee 100644 --- a/packages/nodes-base/nodes/Google/BigQuery/GoogleBigQuery.node.ts +++ b/packages/nodes-base/nodes/Google/BigQuery/GoogleBigQuery.node.ts @@ -7,6 +7,7 @@ import type { INodePropertyOptions, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -192,7 +193,7 @@ export class GoogleBigQuery implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: 0 } }, ); returnData.push(...executionData); @@ -204,7 +205,7 @@ export class GoogleBigQuery implements INodeType { ); returnData.push(...executionErrorData); } - throw new NodeApiError(this.getNode(), error, { itemIndex: 0 }); + throw new NodeApiError(this.getNode(), error as JsonObject, { itemIndex: 0 }); } } else if (operation === 'getAll') { // ---------------------------------- @@ -262,10 +263,12 @@ export class GoogleBigQuery implements INodeType { if (!returnAll) { responseData = responseData.rows; } - responseData = simple ? simplify(responseData, fields) : responseData; + responseData = simple + ? simplify(responseData as IDataObject[], fields as string[]) + : responseData; const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -278,7 +281,7 @@ export class GoogleBigQuery implements INodeType { returnData.push(...executionErrorData); continue; } - throw new NodeApiError(this.getNode(), error, { itemIndex: i }); + throw new NodeApiError(this.getNode(), error as JsonObject, { itemIndex: i }); } } } diff --git a/packages/nodes-base/nodes/Google/Books/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Books/GenericFunctions.ts index 298ef8fb46..593538153f 100644 --- a/packages/nodes-base/nodes/Google/Books/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Books/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import moment from 'moment-timezone'; @@ -94,7 +94,7 @@ export async function googleApiRequest( if (Object.keys(headers).length !== 0) { options.headers = Object.assign({}, options.headers, headers); } - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } @@ -120,7 +120,7 @@ export async function googleApiRequest( error.statusCode = '401'; } - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -140,7 +140,7 @@ export async function googleApiRequestAllItems( do { responseData = await googleApiRequest.call(this, method, endpoint, body, query); - returnData.push.apply(returnData, responseData[propertyName] || []); + returnData.push.apply(returnData, (responseData[propertyName] as IDataObject[]) || []); } while (returnData.length < responseData.totalItems); return returnData; diff --git a/packages/nodes-base/nodes/Google/Books/GoogleBooks.node.ts b/packages/nodes-base/nodes/Google/Books/GoogleBooks.node.ts index 33e80c46e4..64a1efdedb 100644 --- a/packages/nodes-base/nodes/Google/Books/GoogleBooks.node.ts +++ b/packages/nodes-base/nodes/Google/Books/GoogleBooks.node.ts @@ -507,7 +507,7 @@ export class GoogleBooks implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Google/Calendar/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Calendar/GenericFunctions.ts index e2bb7202ce..2379b78698 100644 --- a/packages/nodes-base/nodes/Google/Calendar/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Calendar/GenericFunctions.ts @@ -7,6 +7,7 @@ import type { INodeListSearchItems, INodeListSearchResult, IPollFunctions, + JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -36,13 +37,13 @@ export async function googleApiRequest( if (Object.keys(headers).length !== 0) { options.headers = Object.assign({}, options.headers, headers); } - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } //@ts-ignore return await this.helpers.requestOAuth2.call(this, 'googleCalendarOAuth2Api', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -63,7 +64,7 @@ export async function googleApiRequestAllItems( do { responseData = await googleApiRequest.call(this, method, endpoint, body, query); query.pageToken = responseData.nextPageToken; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.nextPageToken !== undefined && responseData.nextPageToken !== ''); return returnData; diff --git a/packages/nodes-base/nodes/Google/Calendar/GoogleCalendar.node.ts b/packages/nodes-base/nodes/Google/Calendar/GoogleCalendar.node.ts index 5ff26395be..9079fb1c34 100644 --- a/packages/nodes-base/nodes/Google/Calendar/GoogleCalendar.node.ts +++ b/packages/nodes-base/nodes/Google/Calendar/GoogleCalendar.node.ts @@ -7,6 +7,7 @@ import type { INodePropertyOptions, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -109,7 +110,7 @@ export class GoogleCalendar implements INodeType { async getColors(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const { event } = await googleApiRequest.call(this, 'GET', '/calendar/v3/colors'); - for (const key of Object.keys(event)) { + for (const key of Object.keys(event as IDataObject)) { const colorName = `Background: ${event[key].background} - Foreground: ${event[key].foreground}`; const colorId = key; returnData.push({ @@ -168,9 +169,13 @@ export class GoogleCalendar implements INodeType { ); if (responseData.calendars[calendarId].errors) { - throw new NodeApiError(this.getNode(), responseData.calendars[calendarId], { - itemIndex: i, - }); + throw new NodeApiError( + this.getNode(), + responseData.calendars[calendarId] as JsonObject, + { + itemIndex: i, + }, + ); } if (outputFormat === 'availability') { @@ -579,7 +584,7 @@ export class GoogleCalendar implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Google/Chat/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Chat/GenericFunctions.ts index 9cbcb03882..ec12705ab5 100644 --- a/packages/nodes-base/nodes/Google/Chat/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Chat/GenericFunctions.ts @@ -7,6 +7,7 @@ import type { ICredentialTestFunctions, IDataObject, INodeProperties, + JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -96,7 +97,7 @@ export async function googleApiRequest( json: true, }; - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } @@ -123,7 +124,7 @@ export async function googleApiRequest( error.statusCode = '401'; } - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } if (Object.keys(responseData as IDataObject).length !== 0) { return responseData; @@ -149,7 +150,7 @@ export async function googleApiRequestAllItems( do { responseData = await googleApiRequest.call(this, method, endpoint, body, query); query.pageToken = responseData.nextPageToken; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.nextPageToken !== undefined && responseData.nextPageToken !== ''); return returnData; diff --git a/packages/nodes-base/nodes/Google/Chat/GoogleChat.node.ts b/packages/nodes-base/nodes/Google/Chat/GoogleChat.node.ts index fe7a73fbd0..5c7393802e 100644 --- a/packages/nodes-base/nodes/Google/Chat/GoogleChat.node.ts +++ b/packages/nodes-base/nodes/Google/Chat/GoogleChat.node.ts @@ -246,7 +246,7 @@ export class GoogleChat implements INodeType { const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i); items[i].binary![binaryPropertyName] = await this.helpers.prepareBinaryData( - responseData, + responseData as Buffer, endpoint, ); } @@ -536,7 +536,7 @@ export class GoogleChat implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Google/CloudNaturalLanguage/GenericFunctions.ts b/packages/nodes-base/nodes/Google/CloudNaturalLanguage/GenericFunctions.ts index 3d7a1d5624..0e5da0904a 100644 --- a/packages/nodes-base/nodes/Google/CloudNaturalLanguage/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/CloudNaturalLanguage/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function googleApiRequest( @@ -30,7 +30,7 @@ export async function googleApiRequest( options = Object.assign({}, options, option); try { - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } //@ts-ignore @@ -40,6 +40,6 @@ export async function googleApiRequest( options, ); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Google/Contacts/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Contacts/GenericFunctions.ts index 0b8d0b9c3c..da6cee4c58 100644 --- a/packages/nodes-base/nodes/Google/Contacts/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Contacts/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function googleApiRequest( @@ -29,14 +29,14 @@ export async function googleApiRequest( if (Object.keys(headers).length !== 0) { options.headers = Object.assign({}, options.headers, headers); } - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } //@ts-ignore return await this.helpers.requestOAuth2.call(this, 'googleContactsOAuth2Api', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -57,7 +57,7 @@ export async function googleApiRequestAllItems( do { responseData = await googleApiRequest.call(this, method, endpoint, body, query); query.pageToken = responseData.nextPageToken; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.nextPageToken !== undefined && responseData.nextPageToken !== ''); return returnData; @@ -98,7 +98,7 @@ export function cleanData(responseData: any) { } for (let y = 0; y < responseData.length; y++) { const object: { [key: string]: any } = {}; - for (const key of Object.keys(responseData[y])) { + for (const key of Object.keys(responseData[y] as IDataObject)) { if (key === 'metadata') { continue; } diff --git a/packages/nodes-base/nodes/Google/Contacts/GoogleContacts.node.ts b/packages/nodes-base/nodes/Google/Contacts/GoogleContacts.node.ts index b71bb82530..0cb2e6bce4 100644 --- a/packages/nodes-base/nodes/Google/Contacts/GoogleContacts.node.ts +++ b/packages/nodes-base/nodes/Google/Contacts/GoogleContacts.node.ts @@ -505,7 +505,7 @@ export class GoogleContacts implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Google/Docs/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Docs/GenericFunctions.ts index 17b67f6852..3537c88587 100644 --- a/packages/nodes-base/nodes/Google/Docs/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Docs/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import moment from 'moment-timezone'; @@ -112,7 +112,7 @@ export async function googleApiRequest( return await this.helpers.requestOAuth2.call(this, 'googleDocsOAuth2Api', options); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -135,7 +135,7 @@ export async function googleApiRequestAllItems( do { responseData = await googleApiRequest.call(this, method, endpoint, body, query, uri); query.pageToken = responseData.nextPageToken; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.nextPageToken !== undefined && responseData.nextPageToken !== ''); return returnData; diff --git a/packages/nodes-base/nodes/Google/Docs/GoogleDocs.node.ts b/packages/nodes-base/nodes/Google/Docs/GoogleDocs.node.ts index 2e2d1fa5c9..f9b552cabf 100644 --- a/packages/nodes-base/nodes/Google/Docs/GoogleDocs.node.ts +++ b/packages/nodes-base/nodes/Google/Docs/GoogleDocs.node.ts @@ -6,6 +6,7 @@ import type { INodePropertyOptions, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -144,7 +145,9 @@ export class GoogleDocs implements INodeType { 'https://www.googleapis.com/drive/v3/drives', ); } catch (error) { - throw new NodeApiError(this.getNode(), error, { message: 'Error in loading Drives' }); + throw new NodeApiError(this.getNode(), error as JsonObject, { + message: 'Error in loading Drives', + }); } for (const drive of drives) { @@ -183,7 +186,9 @@ export class GoogleDocs implements INodeType { 'https://www.googleapis.com/drive/v3/files', ); } catch (error) { - throw new NodeApiError(this.getNode(), error, { message: 'Error in loading Folders' }); + throw new NodeApiError(this.getNode(), error as JsonObject, { + message: 'Error in loading Folders', + }); } for (const folder of folders) { @@ -494,8 +499,8 @@ export class GoogleDocs implements INodeType { ); if (simple) { - if (Object.keys(responseData.replies[0]).length !== 0) { - const key = Object.keys(responseData.replies[0])[0]; + if (Object.keys(responseData.replies[0] as IDataObject).length !== 0) { + const key = Object.keys(responseData.replies[0] as IDataObject)[0]; responseData = responseData.replies[0][key]; } else { responseData = {}; @@ -517,7 +522,7 @@ export class GoogleDocs implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Google/Drive/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Drive/GenericFunctions.ts index ded6d7b49b..f526e1e454 100644 --- a/packages/nodes-base/nodes/Google/Drive/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Drive/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject, IPollFunctions } from 'n8n-workflow'; +import type { IDataObject, IPollFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import moment from 'moment-timezone'; @@ -99,7 +99,7 @@ export async function googleApiRequest( options = Object.assign({}, options, option); try { - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } @@ -121,7 +121,7 @@ export async function googleApiRequest( error.statusCode = '401'; } - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -142,7 +142,7 @@ export async function googleApiRequestAllItems( do { responseData = await googleApiRequest.call(this, method, endpoint, body, query); - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.nextPageToken !== undefined && responseData.nextPageToken !== ''); return returnData; diff --git a/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts b/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts index e57b468241..3f7f198c67 100644 --- a/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts +++ b/packages/nodes-base/nodes/Google/Drive/GoogleDrive.node.ts @@ -2069,7 +2069,7 @@ export class GoogleDrive implements INodeType { }); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(response), + this.helpers.returnJsonArray(response as IDataObject[]), { itemData: { item: i } }, ); @@ -2115,7 +2115,7 @@ export class GoogleDrive implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(response), + this.helpers.returnJsonArray(response as IDataObject[]), { itemData: { item: i } }, ); @@ -2176,7 +2176,7 @@ export class GoogleDrive implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(response), + this.helpers.returnJsonArray(response as IDataObject[]), { itemData: { item: i } }, ); @@ -2217,7 +2217,7 @@ export class GoogleDrive implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(response), + this.helpers.returnJsonArray(response as IDataObject[]), { itemData: { item: i } }, ); @@ -2320,8 +2320,8 @@ export class GoogleDrive implements INodeType { items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData( response.body as unknown as Readable, - fileName, - mimeType, + fileName as string, + mimeType as string, ); } else if (operation === 'list') { // ---------------------------------- @@ -2412,7 +2412,7 @@ export class GoogleDrive implements INodeType { const version = this.getNode().typeVersion; const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(files), + this.helpers.returnJsonArray(files as IDataObject[]), { itemData: { item: i } }, ); @@ -2496,7 +2496,7 @@ export class GoogleDrive implements INodeType { json: false, }, ); - uploadId = JSON.parse(response).id; + uploadId = JSON.parse(response as string).id; } else { const resumableUpload = await googleApiRequest.call( this, @@ -2591,7 +2591,7 @@ export class GoogleDrive implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(response), + this.helpers.returnJsonArray(response as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -2636,7 +2636,7 @@ export class GoogleDrive implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -2664,7 +2664,7 @@ export class GoogleDrive implements INodeType { const response = await googleApiRequest.call(this, 'POST', '/drive/v3/files', body, qs); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(response), + this.helpers.returnJsonArray(response as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -2729,7 +2729,7 @@ export class GoogleDrive implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(response), + this.helpers.returnJsonArray(response as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GenericFunctions.ts index 446e880792..bc43ff40a9 100644 --- a/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import moment from 'moment-timezone'; @@ -30,7 +30,7 @@ export async function googleApiRequest( json: true, }; try { - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } @@ -41,7 +41,7 @@ export async function googleApiRequest( options, ); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -63,7 +63,7 @@ export async function googleApiRequestAllItems( do { responseData = await googleApiRequest.call(this, method, endpoint, body, query, uri); query.pageToken = responseData.nextPageToken; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.nextPageToken !== undefined && responseData.nextPageToken !== ''); return returnData; @@ -97,7 +97,7 @@ export function jsonToDocument(value: string | number | IDataObject | IDataObjec const obj = {}; for (const o of Object.keys(value)) { //@ts-ignore - obj[o] = jsonToDocument(value[o]); + obj[o] = jsonToDocument(value[o] as IDataObject); } return { mapValue: { fields: obj } }; } @@ -136,7 +136,7 @@ export function documentToJson(fields: IDataObject): IDataObject { return value as IDataObject; } else if ('mapValue' === key) { //@ts-ignore - return documentToJson(value!.fields || {}); + return documentToJson((value!.fields as IDataObject) || {}); } else if ('arrayValue' === key) { // @ts-ignore const list = value.values as IDataObject[]; diff --git a/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GoogleFirebaseCloudFirestore.node.ts b/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GoogleFirebaseCloudFirestore.node.ts index a32b4fc194..6dce53e0d3 100644 --- a/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GoogleFirebaseCloudFirestore.node.ts +++ b/packages/nodes-base/nodes/Google/Firebase/CloudFirestore/GoogleFirebaseCloudFirestore.node.ts @@ -130,7 +130,7 @@ export class GoogleFirebaseCloudFirestore implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: 0 } }, ); @@ -150,7 +150,7 @@ export class GoogleFirebaseCloudFirestore implements INodeType { // @ts-ignore if (item.json[column]) { // @ts-ignore - document.fields[column] = jsonToDocument(item.json[column]); + document.fields[column] = jsonToDocument(item.json[column] as IDataObject); } else { // @ts-ignore document.fields[column] = jsonToDocument(null); @@ -166,11 +166,11 @@ export class GoogleFirebaseCloudFirestore implements INodeType { responseData.id = (responseData.name as string).split('/').pop(); if (simple) { - responseData = fullDocumentToJson(responseData); + responseData = fullDocumentToJson(responseData as IDataObject); } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -213,7 +213,7 @@ export class GoogleFirebaseCloudFirestore implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: 0 } }, ); @@ -256,7 +256,7 @@ export class GoogleFirebaseCloudFirestore implements INodeType { // @ts-ignore if (item.json.hasOwnProperty(column)) { // @ts-ignore - document[column] = jsonToDocument(item.json[column]); + document[column] = jsonToDocument(item.json[column] as IDataObject); } else { // @ts-ignore document[column] = jsonToDocument(null); @@ -288,7 +288,7 @@ export class GoogleFirebaseCloudFirestore implements INodeType { Object.assign(writeResults[i], items[i].json); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(writeResults[i]), + this.helpers.returnJsonArray(writeResults[i] as IDataObject[]), { itemData: { item: i } }, ); @@ -358,7 +358,7 @@ export class GoogleFirebaseCloudFirestore implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -395,7 +395,7 @@ export class GoogleFirebaseCloudFirestore implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: 0 } }, ); diff --git a/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GenericFunctions.ts index 7ea04f3c05..877c3a29fd 100644 --- a/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GenericFunctions.ts @@ -35,7 +35,7 @@ export async function googleApiRequest( if (Object.keys(headers).length !== 0) { options.headers = Object.assign({}, options.headers, headers); } - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } @@ -77,7 +77,7 @@ export async function googleApiRequestAllItems( uri, ); qs.pageToken = responseData.nextPageToken; - returnData.push.apply(returnData, responseData[resource]); + returnData.push.apply(returnData, responseData[resource] as IDataObject[]); } while (responseData.nextPageToken !== undefined && responseData.nextPageToken !== ''); return returnData; diff --git a/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GoogleFirebaseRealtimeDatabase.node.ts b/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GoogleFirebaseRealtimeDatabase.node.ts index 65ff373938..f69ec937c7 100644 --- a/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GoogleFirebaseRealtimeDatabase.node.ts +++ b/packages/nodes-base/nodes/Google/Firebase/RealtimeDatabase/GoogleFirebaseRealtimeDatabase.node.ts @@ -7,6 +7,7 @@ import type { INodePropertyOptions, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -217,7 +218,7 @@ export class GoogleFirebaseRealtimeDatabase implements INodeType { if (responseData === null) { if (operation === 'get') { - throw new NodeApiError(this.getNode(), responseData, { + throw new NodeApiError(this.getNode(), responseData as JsonObject, { message: 'Requested entity was not found.', }); } else if (method === 'DELETE') { @@ -243,7 +244,7 @@ export class GoogleFirebaseRealtimeDatabase implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Google/GSuiteAdmin/GSuiteAdmin.node.ts b/packages/nodes-base/nodes/Google/GSuiteAdmin/GSuiteAdmin.node.ts index 5604f40363..e4d9b99990 100644 --- a/packages/nodes-base/nodes/Google/GSuiteAdmin/GSuiteAdmin.node.ts +++ b/packages/nodes-base/nodes/Google/GSuiteAdmin/GSuiteAdmin.node.ts @@ -418,7 +418,7 @@ export class GSuiteAdmin implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Google/GSuiteAdmin/GenericFunctions.ts b/packages/nodes-base/nodes/Google/GSuiteAdmin/GenericFunctions.ts index 29c6f2acf8..2e0c631d87 100644 --- a/packages/nodes-base/nodes/Google/GSuiteAdmin/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/GSuiteAdmin/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function googleApiRequest( @@ -29,13 +29,13 @@ export async function googleApiRequest( if (Object.keys(headers).length !== 0) { options.headers = Object.assign({}, options.headers, headers); } - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } //@ts-ignore return await this.helpers.requestOAuth2.call(this, 'gSuiteAdminOAuth2Api', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -56,7 +56,7 @@ export async function googleApiRequestAllItems( do { responseData = await googleApiRequest.call(this, method, endpoint, body, query); query.pageToken = responseData.nextPageToken; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.nextPageToken !== undefined && responseData.nextPageToken !== ''); return returnData; diff --git a/packages/nodes-base/nodes/Google/Gmail/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Gmail/GenericFunctions.ts index 228c11cb3d..b711119658 100644 --- a/packages/nodes-base/nodes/Google/Gmail/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Gmail/GenericFunctions.ts @@ -10,6 +10,7 @@ import type { IDataObject, INodeExecutionData, IPollFunctions, + JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -161,7 +162,7 @@ export async function googleApiRequest( resource.charAt(0).toUpperCase() + resource.slice(1) } IDs should look something like this: 182b676d244938bd`, }; - throw new NodeApiError(this.getNode(), error, errorOptions); + throw new NodeApiError(this.getNode(), error as JsonObject, errorOptions); } } @@ -174,7 +175,7 @@ export async function googleApiRequest( message: `${resource.charAt(0).toUpperCase() + resource.slice(1)} not found`, description: '', }; - throw new NodeApiError(this.getNode(), error, errorOptions); + throw new NodeApiError(this.getNode(), error as JsonObject, errorOptions); } if (error.httpCode === '409') { @@ -184,7 +185,7 @@ export async function googleApiRequest( message: 'Label name exists already', description: '', }; - throw new NodeApiError(this.getNode(), error, errorOptions); + throw new NodeApiError(this.getNode(), error as JsonObject, errorOptions); } } @@ -193,7 +194,7 @@ export async function googleApiRequest( message: error?.body?.error_description || 'Authorization error', description: (error as Error).message, }; - throw new NodeApiError(this.getNode(), error, errorOptions); + throw new NodeApiError(this.getNode(), error as JsonObject, errorOptions); } if ( @@ -204,10 +205,10 @@ export async function googleApiRequest( message: error.description, description: '', }; - throw new NodeApiError(this.getNode(), error, errorOptions); + throw new NodeApiError(this.getNode(), error as JsonObject, errorOptions); } - throw new NodeApiError(this.getNode(), error, { + throw new NodeApiError(this.getNode(), error as JsonObject, { message: error.message, description: error.description, }); @@ -220,7 +221,7 @@ export async function parseRawEmail( messageData: any, dataPropertyNameDownload: string, ): Promise { - const messageEncoded = Buffer.from(messageData.raw, 'base64').toString('utf8'); + const messageEncoded = Buffer.from(messageData.raw as string, 'base64').toString('utf8'); const responseData = await simpleParser(messageEncoded); const headers: IDataObject = {}; @@ -333,9 +334,9 @@ export async function googleApiRequestAllItems( query.maxResults = 100; do { - responseData = await googleApiRequest.call(this, method, endpoint, body, query); + responseData = await googleApiRequest.call(this, method, endpoint, body as IDataObject, query); query.pageToken = responseData.nextPageToken; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.nextPageToken !== undefined && responseData.nextPageToken !== ''); return returnData; @@ -621,7 +622,7 @@ export async function replayToEmail( options.replyToSenderOnly === undefined ? false : (options.replyToSenderOnly as boolean); const prepareEmailString = (email: string) => { - if (email.includes(emailAddress)) return; + if (email.includes(emailAddress as string)) return; if (email.includes('<') && email.includes('>')) { to += `${email}, `; } else { diff --git a/packages/nodes-base/nodes/Google/Gmail/GmailTrigger.node.ts b/packages/nodes-base/nodes/Google/Gmail/GmailTrigger.node.ts index d14363e947..8f7b389773 100644 --- a/packages/nodes-base/nodes/Google/Gmail/GmailTrigger.node.ts +++ b/packages/nodes-base/nodes/Google/Gmail/GmailTrigger.node.ts @@ -294,7 +294,9 @@ export class GmailTrigger implements INodeType { } if (simple) { - responseData = this.helpers.returnJsonArray(await simplifyOutput.call(this, responseData)); + responseData = this.helpers.returnJsonArray( + await simplifyOutput.call(this, responseData as IDataObject[]), + ); } } catch (error) { if (this.getMode() === 'manual' || !webhookData.lastTimeChecked) { diff --git a/packages/nodes-base/nodes/Google/Gmail/v1/GmailV1.node.ts b/packages/nodes-base/nodes/Google/Gmail/v1/GmailV1.node.ts index b6d041df51..f89e3ef264 100644 --- a/packages/nodes-base/nodes/Google/Gmail/v1/GmailV1.node.ts +++ b/packages/nodes-base/nodes/Google/Gmail/v1/GmailV1.node.ts @@ -589,7 +589,7 @@ export class GmailV1 implements INodeType { } if (format !== 'resolved') { - responseData = this.helpers.returnJsonArray(responseData); + responseData = this.helpers.returnJsonArray(responseData as IDataObject[]); } } if (operation === 'delete') { @@ -821,13 +821,13 @@ export class GmailV1 implements INodeType { } if (format !== 'resolved') { - responseData = this.helpers.returnJsonArray(responseData); + responseData = this.helpers.returnJsonArray(responseData as IDataObject[]); } } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Google/Gmail/v2/GmailV2.node.ts b/packages/nodes-base/nodes/Google/Gmail/v2/GmailV2.node.ts index 7e1deb2387..4e9e5c55cc 100644 --- a/packages/nodes-base/nodes/Google/Gmail/v2/GmailV2.node.ts +++ b/packages/nodes-base/nodes/Google/Gmail/v2/GmailV2.node.ts @@ -262,7 +262,7 @@ export class GmailV2 implements INodeType { responseData = await googleApiRequest.call(this, 'GET', '/gmail/v1/users/me/labels'); - responseData = this.helpers.returnJsonArray(responseData.labels); + responseData = this.helpers.returnJsonArray(responseData.labels as IDataObject[]); if (!returnAll) { const limit = this.getNodeParameter('limit', i); @@ -372,7 +372,7 @@ export class GmailV2 implements INodeType { dataPropertyNameDownload, ); } else { - const [json, _] = await simplifyOutput.call(this, [responseData]); + const [json, _] = await simplifyOutput.call(this, [responseData as IDataObject]); nodeExecutionData = { json }; } @@ -442,7 +442,7 @@ export class GmailV2 implements INodeType { if (simple) { responseData = this.helpers.returnJsonArray( - await simplifyOutput.call(this, responseData), + await simplifyOutput.call(this, responseData as IDataObject[]), ); } } @@ -694,10 +694,13 @@ export class GmailV2 implements INodeType { if (onlyMessages) { responseData = this.helpers.returnJsonArray( - await simplifyOutput.call(this, responseData.messages), + await simplifyOutput.call(this, responseData.messages as IDataObject[]), ); } else { - responseData.messages = await simplifyOutput.call(this, responseData.messages); + responseData.messages = await simplifyOutput.call( + this, + responseData.messages as IDataObject[], + ); responseData = [{ json: responseData }]; } } @@ -733,7 +736,7 @@ export class GmailV2 implements INodeType { responseData = []; } - responseData = this.helpers.returnJsonArray(responseData); + responseData = this.helpers.returnJsonArray(responseData as IDataObject[]); } if (operation === 'reply') { const messageIdGmail = this.getNodeParameter('messageId', i) as string; @@ -783,7 +786,7 @@ export class GmailV2 implements INodeType { //------------------------------------------------------------------// const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i }, }, @@ -795,7 +798,7 @@ export class GmailV2 implements INodeType { returnData.push({ json: { error: error.message }, pairedItem: { item: i } }); continue; } - throw new NodeOperationError(this.getNode(), error, { + throw new NodeOperationError(this.getNode(), error as Error, { description: error.description, itemIndex: i, }); diff --git a/packages/nodes-base/nodes/Google/Perspective/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Perspective/GenericFunctions.ts index 3b2993dc5a..66b658d2dc 100644 --- a/packages/nodes-base/nodes/Google/Perspective/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Perspective/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function googleApiRequest( @@ -29,6 +29,6 @@ export async function googleApiRequest( try { return await this.helpers.requestOAuth2.call(this, 'googlePerspectiveOAuth2Api', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Google/Perspective/GooglePerspective.node.ts b/packages/nodes-base/nodes/Google/Perspective/GooglePerspective.node.ts index 350eb29e52..2b35201f90 100644 --- a/packages/nodes-base/nodes/Google/Perspective/GooglePerspective.node.ts +++ b/packages/nodes-base/nodes/Google/Perspective/GooglePerspective.node.ts @@ -6,6 +6,7 @@ import type { INodePropertyOptions, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeOperationError } from 'n8n-workflow'; @@ -275,7 +276,7 @@ export class GooglePerspective implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as JsonObject), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Google/Sheet/GoogleSheetsTrigger.node.ts b/packages/nodes-base/nodes/Google/Sheet/GoogleSheetsTrigger.node.ts index e4bcb37816..514c12d952 100644 --- a/packages/nodes-base/nodes/Google/Sheet/GoogleSheetsTrigger.node.ts +++ b/packages/nodes-base/nodes/Google/Sheet/GoogleSheetsTrigger.node.ts @@ -597,7 +597,7 @@ export class GoogleSheetsTrigger implements INodeType { const previousRevisionSheetData = sheetBinaryToArrayOfArrays( previousRevisionBinaryData, - sheetName, + sheetName as string, rangeDefinition === 'specifyRangeA1' ? range : undefined, ) || []; diff --git a/packages/nodes-base/nodes/Google/Sheet/v1/GenericFunctions.ts b/packages/nodes-base/nodes/Google/Sheet/v1/GenericFunctions.ts index 713d35a3c0..1603395fd1 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v1/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v1/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { ICredentialTestFunctions, IDataObject } from 'n8n-workflow'; +import type { ICredentialTestFunctions, IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import moment from 'moment-timezone'; @@ -102,7 +102,7 @@ export async function googleApiRequest( if (Object.keys(headers).length !== 0) { options.headers = Object.assign({}, options.headers, headers); } - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } @@ -124,7 +124,7 @@ export async function googleApiRequest( error.statusCode = '401'; } - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -145,7 +145,7 @@ export async function googleApiRequestAllItems( do { responseData = await googleApiRequest.call(this, method, endpoint, body, query); query.pageToken = responseData.nextPageToken; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.nextPageToken !== undefined && responseData.nextPageToken !== ''); return returnData; diff --git a/packages/nodes-base/nodes/Google/Sheet/v1/GoogleSheetsV1.node.ts b/packages/nodes-base/nodes/Google/Sheet/v1/GoogleSheetsV1.node.ts index 5c9c3ff5ac..1ca0e728cb 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v1/GoogleSheetsV1.node.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v1/GoogleSheetsV1.node.ts @@ -201,7 +201,7 @@ export class GoogleSheetsV1 implements INodeType { Object.assign(responseData, responseData.replies[0].addSheet.properties); delete responseData.replies; } - returnData.push(responseData); + returnData.push(responseData as IDataObject); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); @@ -366,7 +366,7 @@ export class GoogleSheetsV1 implements INodeType { { requests }, ); delete responseData.replies; - returnData.push(responseData); + returnData.push(responseData as IDataObject); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); @@ -479,7 +479,7 @@ export class GoogleSheetsV1 implements INodeType { responseData = await googleApiRequest.call(this, 'POST', '/v4/spreadsheets', body); - returnData.push(responseData); + returnData.push(responseData as IDataObject); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); diff --git a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/create.operation.ts b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/create.operation.ts index 70946a6e15..5f0493e5a8 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/create.operation.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/create.operation.ts @@ -121,7 +121,7 @@ export async function execute( existingSheetNames.push(sheetTitle); - returnData.push(responseData); + returnData.push(responseData as IDataObject); } return this.helpers.returnJsonArray(returnData); } diff --git a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/remove.operation.ts b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/remove.operation.ts index 442cd2a0da..8e5855d289 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/remove.operation.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v2/actions/sheet/remove.operation.ts @@ -27,7 +27,7 @@ export async function execute( { requests }, ); delete responseData.replies; - returnData.push(responseData); + returnData.push(responseData as IDataObject); } return this.helpers.returnJsonArray(returnData); diff --git a/packages/nodes-base/nodes/Google/Sheet/v2/actions/spreadsheet/create.operation.ts b/packages/nodes-base/nodes/Google/Sheet/v2/actions/spreadsheet/create.operation.ts index 060babac73..7fb605cd01 100644 --- a/packages/nodes-base/nodes/Google/Sheet/v2/actions/spreadsheet/create.operation.ts +++ b/packages/nodes-base/nodes/Google/Sheet/v2/actions/spreadsheet/create.operation.ts @@ -146,7 +146,7 @@ export async function execute(this: IExecuteFunctions): Promise error.message).join(', ') || 'Unexpected error'; - throw new NodeApiError(this.getNode(), response.errors, { message }); + throw new NodeApiError(this.getNode(), response.errors as JsonObject, { message }); } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(response), + this.helpers.returnJsonArray(response as IDataObject), { itemData: { item: itemIndex } }, ); returnItems.push(...executionData); diff --git a/packages/nodes-base/nodes/Grist/GenericFunctions.ts b/packages/nodes-base/nodes/Grist/GenericFunctions.ts index 101def1a1f..3a2d77be8b 100644 --- a/packages/nodes-base/nodes/Grist/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Grist/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; import type { OptionsWithUri } from 'request'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; import type { @@ -52,7 +52,7 @@ export async function gristApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Grist/Grist.node.ts b/packages/nodes-base/nodes/Grist/Grist.node.ts index c529165f17..7b7f9a593d 100644 --- a/packages/nodes-base/nodes/Grist/Grist.node.ts +++ b/packages/nodes-base/nodes/Grist/Grist.node.ts @@ -258,7 +258,7 @@ export class Grist implements INodeType { throw error; } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Gumroad/GenericFunctions.ts b/packages/nodes-base/nodes/Gumroad/GenericFunctions.ts index ec3f6ebb0a..54ef0cca82 100644 --- a/packages/nodes-base/nodes/Gumroad/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Gumroad/GenericFunctions.ts @@ -6,7 +6,7 @@ import type { ILoadOptionsFunctions, IWebhookFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function gumroadApiRequest( @@ -35,13 +35,13 @@ export async function gumroadApiRequest( json: true, }; options = Object.assign({}, options, option); - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Gumroad/GumroadTrigger.node.ts b/packages/nodes-base/nodes/Gumroad/GumroadTrigger.node.ts index 0e7a58c407..bdea564385 100644 --- a/packages/nodes-base/nodes/Gumroad/GumroadTrigger.node.ts +++ b/packages/nodes-base/nodes/Gumroad/GumroadTrigger.node.ts @@ -136,7 +136,7 @@ export class GumroadTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const req = this.getRequestObject(); return { - workflowData: [this.helpers.returnJsonArray(req.body)], + workflowData: [this.helpers.returnJsonArray(req.body as IDataObject)], }; } } diff --git a/packages/nodes-base/nodes/HackerNews/GenericFunctions.ts b/packages/nodes-base/nodes/HackerNews/GenericFunctions.ts index 341f98e720..fce70da36b 100644 --- a/packages/nodes-base/nodes/HackerNews/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HackerNews/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import type { IDataObject, ILoadOptionsFunctions } from 'n8n-workflow'; +import type { IDataObject, ILoadOptionsFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import type { OptionsWithUri } from 'request'; @@ -25,7 +25,7 @@ export async function hackerNewsApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -50,7 +50,7 @@ export async function hackerNewsApiRequestAllItems( do { responseData = await hackerNewsApiRequest.call(this, method, endpoint, qs); - returnData.push.apply(returnData, responseData.hits); + returnData.push.apply(returnData, responseData.hits as IDataObject[]); if (returnData !== undefined) { itemsReceived += returnData.length; diff --git a/packages/nodes-base/nodes/HackerNews/HackerNews.node.ts b/packages/nodes-base/nodes/HackerNews/HackerNews.node.ts index 5452b1eec9..3c23bcea12 100644 --- a/packages/nodes-base/nodes/HackerNews/HackerNews.node.ts +++ b/packages/nodes-base/nodes/HackerNews/HackerNews.node.ts @@ -343,7 +343,7 @@ export class HackerNews implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/HaloPSA/HaloPSA.node.ts b/packages/nodes-base/nodes/HaloPSA/HaloPSA.node.ts index e7358f131e..2a46185a74 100644 --- a/packages/nodes-base/nodes/HaloPSA/HaloPSA.node.ts +++ b/packages/nodes-base/nodes/HaloPSA/HaloPSA.node.ts @@ -278,7 +278,7 @@ export class HaloPSA implements INodeType { tokens.access_token, ); responseData = simplify - ? simplifyHaloPSAGetOutput([response], simplifiedOutput) + ? simplifyHaloPSAGetOutput([response] as IDataObject[], simplifiedOutput) : response; } @@ -314,7 +314,7 @@ export class HaloPSA implements INodeType { response = clients; } responseData = simplify - ? simplifyHaloPSAGetOutput(response, simplifiedOutput) + ? simplifyHaloPSAGetOutput(response as IDataObject[], simplifiedOutput) : response; } @@ -385,7 +385,7 @@ export class HaloPSA implements INodeType { tokens.access_token, ); responseData = simplify - ? simplifyHaloPSAGetOutput([response], simplifiedOutput) + ? simplifyHaloPSAGetOutput([response] as IDataObject[], simplifiedOutput) : response; } @@ -421,7 +421,7 @@ export class HaloPSA implements INodeType { response = sites; } responseData = simplify - ? simplifyHaloPSAGetOutput(response, simplifiedOutput) + ? simplifyHaloPSAGetOutput(response as IDataObject[], simplifiedOutput) : response; } @@ -494,7 +494,7 @@ export class HaloPSA implements INodeType { tokens.access_token, ); responseData = simplify - ? simplifyHaloPSAGetOutput([response], simplifiedOutput) + ? simplifyHaloPSAGetOutput([response] as IDataObject[], simplifiedOutput) : response; } @@ -530,7 +530,7 @@ export class HaloPSA implements INodeType { response = tickets; } responseData = simplify - ? simplifyHaloPSAGetOutput(response, simplifiedOutput) + ? simplifyHaloPSAGetOutput(response as IDataObject[], simplifiedOutput) : response; } @@ -602,7 +602,7 @@ export class HaloPSA implements INodeType { tokens.access_token, ); responseData = simplify - ? simplifyHaloPSAGetOutput([response], simplifiedOutput) + ? simplifyHaloPSAGetOutput([response] as IDataObject[], simplifiedOutput) : response; } @@ -638,7 +638,7 @@ export class HaloPSA implements INodeType { response = users; } responseData = simplify - ? simplifyHaloPSAGetOutput(response, simplifiedOutput) + ? simplifyHaloPSAGetOutput(response as IDataObject[], simplifiedOutput) : response; } @@ -661,7 +661,7 @@ export class HaloPSA implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Harvest/GenericFunctions.ts b/packages/nodes-base/nodes/Harvest/GenericFunctions.ts index 9018d1bb22..312c949dac 100644 --- a/packages/nodes-base/nodes/Harvest/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Harvest/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function harvestApiRequest( @@ -33,7 +33,7 @@ export async function harvestApiRequest( }; options = Object.assign({}, options, option); - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } const authenticationMethod = this.getNodeParameter('authentication', 0); @@ -50,7 +50,7 @@ export async function harvestApiRequest( return await this.helpers.requestOAuth2.call(this, 'harvestOAuth2Api', options); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -74,7 +74,7 @@ export async function harvestApiRequestAllItems( do { responseData = await harvestApiRequest.call(this, method, qs, uri, body, option); qs.page = responseData.next_page; - returnData.push.apply(returnData, responseData[resource]); + returnData.push.apply(returnData, responseData[resource] as IDataObject[]); } while (responseData.next_page); return returnData; diff --git a/packages/nodes-base/nodes/Harvest/Harvest.node.ts b/packages/nodes-base/nodes/Harvest/Harvest.node.ts index 36bf2568f7..b2931ba234 100644 --- a/packages/nodes-base/nodes/Harvest/Harvest.node.ts +++ b/packages/nodes-base/nodes/Harvest/Harvest.node.ts @@ -230,7 +230,7 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -269,7 +269,7 @@ export class Harvest implements INodeType { body, ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -298,7 +298,7 @@ export class Harvest implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -315,7 +315,7 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -332,7 +332,7 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -349,7 +349,7 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -366,7 +366,7 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -392,7 +392,7 @@ export class Harvest implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -418,7 +418,7 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -458,7 +458,7 @@ export class Harvest implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -484,7 +484,7 @@ export class Harvest implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -501,7 +501,7 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -527,7 +527,7 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -571,7 +571,7 @@ export class Harvest implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -597,7 +597,7 @@ export class Harvest implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -614,7 +614,7 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -640,7 +640,7 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -670,7 +670,7 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -699,7 +699,7 @@ export class Harvest implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -725,7 +725,7 @@ export class Harvest implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -742,7 +742,7 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -768,7 +768,7 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -809,7 +809,7 @@ export class Harvest implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -835,7 +835,7 @@ export class Harvest implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -852,7 +852,7 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -876,7 +876,7 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -902,7 +902,7 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -942,7 +942,7 @@ export class Harvest implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -968,7 +968,7 @@ export class Harvest implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -985,7 +985,7 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -1011,7 +1011,7 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -1051,7 +1051,7 @@ export class Harvest implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -1077,7 +1077,7 @@ export class Harvest implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -1094,7 +1094,7 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -1120,7 +1120,7 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -1162,7 +1162,7 @@ export class Harvest implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -1188,7 +1188,7 @@ export class Harvest implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -1205,7 +1205,7 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -1231,7 +1231,7 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -1271,7 +1271,7 @@ export class Harvest implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -1297,7 +1297,7 @@ export class Harvest implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -1314,7 +1314,7 @@ export class Harvest implements INodeType { const responseData = await harvestApiRequest.call(this, requestMethod, qs, endpoint); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/HelpScout/GenericFunctions.ts b/packages/nodes-base/nodes/HelpScout/GenericFunctions.ts index 146b672466..4d21b8f51e 100644 --- a/packages/nodes-base/nodes/HelpScout/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HelpScout/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import get from 'lodash.get'; @@ -36,13 +36,13 @@ export async function helpscoutApiRequest( if (Object.keys(option).length !== 0) { options = Object.assign({}, options, option); } - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } //@ts-ignore return await this.helpers.requestOAuth2.call(this, 'helpScoutOAuth2Api', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -58,12 +58,12 @@ export async function helpscoutApiRequestAllItems( const returnData: IDataObject[] = []; let responseData; - let uri; + let uri: undefined | string = undefined; do { responseData = await helpscoutApiRequest.call(this, method, endpoint, body, query, uri); uri = get(responseData, '_links.next.href'); - returnData.push.apply(returnData, get(responseData, propertyName)); + returnData.push.apply(returnData, get(responseData, propertyName) as IDataObject[]); if (query.limit && query.limit <= returnData.length) { return returnData; } diff --git a/packages/nodes-base/nodes/HelpScout/HelpScout.node.ts b/packages/nodes-base/nodes/HelpScout/HelpScout.node.ts index 1d1e39e6d5..d68f840a5c 100644 --- a/packages/nodes-base/nodes/HelpScout/HelpScout.node.ts +++ b/packages/nodes-base/nodes/HelpScout/HelpScout.node.ts @@ -217,7 +217,7 @@ export class HelpScout implements INodeType { const id = responseData.headers['resource-id']; const uri = responseData.headers.location; if (resolveData) { - responseData = await helpscoutApiRequest.call(this, 'GET', '', {}, {}, uri); + responseData = await helpscoutApiRequest.call(this, 'GET', '', {}, {}, uri as string); } else { responseData = { id, @@ -335,7 +335,7 @@ export class HelpScout implements INodeType { const id = responseData.headers['resource-id']; const uri = responseData.headers.location; if (resolveData) { - responseData = await helpscoutApiRequest.call(this, 'GET', '', {}, {}, uri); + responseData = await helpscoutApiRequest.call(this, 'GET', '', {}, {}, uri as string); } else { responseData = { id, @@ -573,7 +573,7 @@ export class HelpScout implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/HighLevel/GenericFunctions.ts b/packages/nodes-base/nodes/HighLevel/GenericFunctions.ts index 0be43214fa..25af2a5d24 100644 --- a/packages/nodes-base/nodes/HighLevel/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HighLevel/GenericFunctions.ts @@ -184,7 +184,7 @@ export async function taskUpdatePreSendAction( const responseData = await highLevelApiRequest.call(this, 'GET', resource); body.title = body.title || responseData.title; // the api response dueDate has to be formatted or it will error on update - body.dueDate = body.dueDate || dateToIsoSupressMillis(responseData.dueDate); + body.dueDate = body.dueDate || dateToIsoSupressMillis(responseData.dueDate as string); requestOptions.body = body; } return requestOptions; diff --git a/packages/nodes-base/nodes/HomeAssistant/GenericFunctions.ts b/packages/nodes-base/nodes/HomeAssistant/GenericFunctions.ts index 153c07b5d2..89e4dac2a3 100644 --- a/packages/nodes-base/nodes/HomeAssistant/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HomeAssistant/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject, INodePropertyOptions } from 'n8n-workflow'; +import type { IDataObject, INodePropertyOptions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function homeAssistantApiRequest( @@ -32,7 +32,7 @@ export async function homeAssistantApiRequest( }; options = Object.assign({}, options, option); - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } try { @@ -40,7 +40,7 @@ export async function homeAssistantApiRequest( return await this.helpers.request(options); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -72,13 +72,18 @@ export async function getHomeAssistantServices( if (domain === '') { // If no domain specified return domains const domains = services.map(({ domain: service }: IDataObject) => service as string).sort(); - returnData.push(...domains.map((service: string) => ({ name: service, value: service }))); + returnData.push( + ...(domains.map((service: string) => ({ + name: service, + value: service, + })) as INodePropertyOptions[]), + ); return returnData; } else { // If we have a domain, return all relevant services const domainServices = services.filter((service: IDataObject) => service.domain === domain); for (const domainService of domainServices) { - for (const [serviceID, value] of Object.entries(domainService.services)) { + for (const [serviceID, value] of Object.entries(domainService.services as IDataObject)) { const serviceProperties = value as IDataObject; const serviceName = serviceProperties.description || serviceID; returnData.push({ diff --git a/packages/nodes-base/nodes/HomeAssistant/HomeAssistant.node.ts b/packages/nodes-base/nodes/HomeAssistant/HomeAssistant.node.ts index ddc69e1e53..9e04244765 100644 --- a/packages/nodes-base/nodes/HomeAssistant/HomeAssistant.node.ts +++ b/packages/nodes-base/nodes/HomeAssistant/HomeAssistant.node.ts @@ -453,7 +453,7 @@ export class HomeAssistant implements INodeType { throw error; } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Html/Html.node.ts b/packages/nodes-base/nodes/Html/Html.node.ts index 75b8a0b2ed..6c08ece69d 100644 --- a/packages/nodes-base/nodes/Html/Html.node.ts +++ b/packages/nodes-base/nodes/Html/Html.node.ts @@ -256,7 +256,10 @@ export class Html implements INodeType { let html = this.getNodeParameter('html', itemIndex) as string; for (const resolvable of getResolvables(html)) { - html = html.replace(resolvable, this.evaluateExpression(resolvable, itemIndex) as any); + html = html.replace( + resolvable, + this.evaluateExpression(resolvable, itemIndex) as string, + ); } const result = this.helpers.constructExecutionMetaData( diff --git a/packages/nodes-base/nodes/HttpRequest/V1/HttpRequestV1.node.ts b/packages/nodes-base/nodes/HttpRequest/V1/HttpRequestV1.node.ts index 125da63a10..0dbad1a8e5 100644 --- a/packages/nodes-base/nodes/HttpRequest/V1/HttpRequestV1.node.ts +++ b/packages/nodes-base/nodes/HttpRequest/V1/HttpRequestV1.node.ts @@ -7,6 +7,7 @@ import type { INodeType, INodeTypeBaseDescription, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError, sleep } from 'n8n-workflow'; @@ -23,6 +24,8 @@ interface OptionDataParamters { [key: string]: OptionData; } +type OptionsWithUriKeys = keyof OptionsWithUri; + export class HttpRequestV1 implements INodeType { description: INodeTypeDescription; @@ -826,7 +829,9 @@ export class HttpRequestV1 implements INodeType { // If it is not an object && bodyContentType is not 'raw' it must be JSON so parse it try { // @ts-ignore - requestOptions[optionData.name] = JSON.parse(requestOptions[optionData.name]); + requestOptions[optionData.name] = JSON.parse( + requestOptions[optionData.name as OptionsWithUriKeys] as string, + ); } catch (error) { throw new NodeOperationError( this.getNode(), @@ -985,7 +990,7 @@ export class HttpRequestV1 implements INodeType { if (response!.status !== 'fulfilled') { if (!this.continueOnFail()) { // throw error; - throw new NodeApiError(this.getNode(), response); + throw new NodeApiError(this.getNode(), response as JsonObject); } else { // Return the actual reason as error returnItems.push({ @@ -1040,14 +1045,14 @@ export class HttpRequestV1 implements INodeType { newItem.json = returnItem; newItem.binary![dataPropertyName] = await this.helpers.prepareBinaryData( - response!.body, + response!.body as Buffer, fileName, ); } else { newItem.json = items[itemIndex].json; newItem.binary![dataPropertyName] = await this.helpers.prepareBinaryData( - response!, + response! as Buffer, fileName, ); } diff --git a/packages/nodes-base/nodes/HttpRequest/V2/HttpRequestV2.node.ts b/packages/nodes-base/nodes/HttpRequest/V2/HttpRequestV2.node.ts index 5b85cf4fee..89fabccbaf 100644 --- a/packages/nodes-base/nodes/HttpRequest/V2/HttpRequestV2.node.ts +++ b/packages/nodes-base/nodes/HttpRequest/V2/HttpRequestV2.node.ts @@ -5,6 +5,7 @@ import type { INodeType, INodeTypeBaseDescription, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError, sleep } from 'n8n-workflow'; @@ -25,6 +26,7 @@ interface OptionDataParamters { [key: string]: OptionData; } +type OptionsWithUriKeys = keyof OptionsWithUri; export class HttpRequestV2 implements INodeType { description: INodeTypeDescription; @@ -864,7 +866,9 @@ export class HttpRequestV2 implements INodeType { // If it is not an object && bodyContentType is not 'raw' it must be JSON so parse it try { // @ts-ignore - requestOptions[optionData.name] = JSON.parse(requestOptions[optionData.name]); + requestOptions[optionData.name] = JSON.parse( + requestOptions[optionData.name as OptionsWithUriKeys] as string, + ); } catch (error) { throw new NodeOperationError( this.getNode(), @@ -1037,7 +1041,7 @@ export class HttpRequestV2 implements INodeType { if (response!.status !== 'fulfilled') { if (!this.continueOnFail()) { // throw error; - throw new NodeApiError(this.getNode(), response); + throw new NodeApiError(this.getNode(), response as JsonObject); } else { // Return the actual reason as error returnItems.push({ @@ -1092,14 +1096,14 @@ export class HttpRequestV2 implements INodeType { newItem.json = returnItem; newItem.binary![dataPropertyName] = await this.helpers.prepareBinaryData( - response!.body, + response!.body as Buffer, fileName, ); } else { newItem.json = items[itemIndex].json; newItem.binary![dataPropertyName] = await this.helpers.prepareBinaryData( - response!, + response! as Buffer, fileName, ); } diff --git a/packages/nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts b/packages/nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts index af4eada7bd..45570b6df2 100644 --- a/packages/nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts +++ b/packages/nodes-base/nodes/HttpRequest/V3/HttpRequestV3.node.ts @@ -7,6 +7,7 @@ import type { INodeType, INodeTypeBaseDescription, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { jsonParse, NodeApiError, NodeOperationError, sleep } from 'n8n-workflow'; @@ -1307,9 +1308,9 @@ export class HttpRequestV3 implements INodeType { if (response!.status !== 'fulfilled') { if (!this.continueOnFail()) { if (autoDetectResponseFormat && response.reason.error instanceof Buffer) { - response.reason.error = Buffer.from(response.reason.error).toString(); + response.reason.error = Buffer.from(response.reason.error as Buffer).toString(); } - throw new NodeApiError(this.getNode(), response); + throw new NodeApiError(this.getNode(), response as JsonObject); } else { // Return the actual reason as error returnItems.push({ @@ -1349,7 +1350,7 @@ export class HttpRequestV3 implements INodeType { 0, false, ) as boolean; - const data = Buffer.from(response.body).toString(); + const data = Buffer.from(response.body as Buffer).toString(); response.body = jsonParse(data, { ...(neverError ? { fallbackValue: {} } @@ -1359,7 +1360,7 @@ export class HttpRequestV3 implements INodeType { responseFormat = 'file'; } else { responseFormat = 'text'; - const data = Buffer.from(response.body).toString(); + const data = Buffer.from(response.body as Buffer).toString(); response.body = !data ? undefined : data; } } @@ -1408,14 +1409,14 @@ export class HttpRequestV3 implements INodeType { newItem.json = returnItem; newItem.binary![outputPropertyName] = await this.helpers.prepareBinaryData( - response!.body, + response!.body as Buffer, fileName, ); } else { newItem.json = items[itemIndex].json; newItem.binary![outputPropertyName] = await this.helpers.prepareBinaryData( - response!, + response! as Buffer, fileName, ); } diff --git a/packages/nodes-base/nodes/Hubspot/GenericFunctions.ts b/packages/nodes-base/nodes/Hubspot/GenericFunctions.ts index 7d627d9f34..a380a222bd 100644 --- a/packages/nodes-base/nodes/Hubspot/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Hubspot/GenericFunctions.ts @@ -97,7 +97,7 @@ export async function hubspotApiRequestAllItems( if (responseData.paging) { body.after = responseData.paging.next.after; } - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); //ticket:getAll endpoint does not support setting a limit, so return once the limit is reached if (query.limit && query.limit <= returnData.length && endpoint.includes('/tickets/paged')) { return returnData; diff --git a/packages/nodes-base/nodes/Hubspot/Hubspot.node.ts b/packages/nodes-base/nodes/Hubspot/Hubspot.node.ts index 2ac6d125a5..c547ab70bf 100644 --- a/packages/nodes-base/nodes/Hubspot/Hubspot.node.ts +++ b/packages/nodes-base/nodes/Hubspot/Hubspot.node.ts @@ -959,7 +959,7 @@ export class Hubspot implements INodeType { `/contacts/v1/lists/${listId}/add`, body, ); - returnData.push(responseData); + returnData.push(responseData as INodeExecutionData); } //https://legacydocs.hubspot.com/docs/methods/lists/remove_contact_from_list if (operation === 'remove') { @@ -975,7 +975,7 @@ export class Hubspot implements INodeType { `/contacts/v1/lists/${listId}/remove`, body, ); - returnData.push(responseData); + returnData.push(responseData as INodeExecutionData); } } catch (error) { if (this.continueOnFail()) { @@ -2720,7 +2720,7 @@ export class Hubspot implements INodeType { } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Hubspot/HubspotTrigger.node.ts b/packages/nodes-base/nodes/Hubspot/HubspotTrigger.node.ts index da60ba0091..583728492a 100644 --- a/packages/nodes-base/nodes/Hubspot/HubspotTrigger.node.ts +++ b/packages/nodes-base/nodes/Hubspot/HubspotTrigger.node.ts @@ -436,7 +436,7 @@ export class HubspotTrigger implements INodeType { delete bodyData[i].objectId; } return { - workflowData: [this.helpers.returnJsonArray(bodyData)], + workflowData: [this.helpers.returnJsonArray(bodyData as IDataObject[])], }; } } diff --git a/packages/nodes-base/nodes/HumanticAI/GenericFunctions.ts b/packages/nodes-base/nodes/HumanticAI/GenericFunctions.ts index 0df68d93d8..fb952ac931 100644 --- a/packages/nodes-base/nodes/HumanticAI/GenericFunctions.ts +++ b/packages/nodes-base/nodes/HumanticAI/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function humanticAiApiRequest( @@ -35,18 +35,18 @@ export async function humanticAiApiRequest( options = Object.assign({}, options, option); options.qs.apikey = credentials.apiKey; - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } const response = await this.helpers.request(options); if (response.data && response.data.status === 'error') { - throw new NodeApiError(this.getNode(), response.data); + throw new NodeApiError(this.getNode(), response.data as JsonObject); } return response; } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Hunter/GenericFunctions.ts b/packages/nodes-base/nodes/Hunter/GenericFunctions.ts index 3ee85baf23..601830fd06 100644 --- a/packages/nodes-base/nodes/Hunter/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Hunter/GenericFunctions.ts @@ -5,7 +5,7 @@ import type { IHookFunctions, ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function hunterApiRequest( @@ -28,13 +28,13 @@ export async function hunterApiRequest( json: true, }; options = Object.assign({}, options, option); - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -59,7 +59,7 @@ export async function hunterApiRequestAllItems( do { responseData = await hunterApiRequest.call(this, method, resource, body, query); - returnData.push(responseData[propertyName]); + returnData.push(responseData[propertyName] as IDataObject); query.offset += query.limit; } while ( responseData.meta?.results !== undefined && diff --git a/packages/nodes-base/nodes/Hunter/Hunter.node.ts b/packages/nodes-base/nodes/Hunter/Hunter.node.ts index 37e29a0efc..e630a5da88 100644 --- a/packages/nodes-base/nodes/Hunter/Hunter.node.ts +++ b/packages/nodes-base/nodes/Hunter/Hunter.node.ts @@ -319,7 +319,7 @@ export class Hunter implements INodeType { } (tempReturnData.emails as IDataObject[]).push.apply( tempReturnData.emails, - responseData[index].emails, + responseData[index].emails as IDataObject[], ); } @@ -337,7 +337,7 @@ export class Hunter implements INodeType { if (Array.isArray(responseData)) { for (const data of responseData) { - tempReturnData.push.apply(tempReturnData, data.emails); + tempReturnData.push.apply(tempReturnData, data.emails as IDataObject[]); } } else { tempReturnData = responseData.emails; @@ -366,7 +366,7 @@ export class Hunter implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Intercom/GenericFunctions.ts b/packages/nodes-base/nodes/Intercom/GenericFunctions.ts index 97211dc10f..4a3d927bcb 100644 --- a/packages/nodes-base/nodes/Intercom/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Intercom/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function intercomApiRequest( @@ -38,7 +38,7 @@ export async function intercomApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -66,7 +66,7 @@ export async function intercomApiRequestAllItems( do { responseData = await intercomApiRequest.call(this, endpoint, method, body, query, uri); uri = responseData.pages.next; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.pages?.next !== null); return returnData; diff --git a/packages/nodes-base/nodes/Intercom/Intercom.node.ts b/packages/nodes-base/nodes/Intercom/Intercom.node.ts index 3c7b93592e..83faa932d6 100644 --- a/packages/nodes-base/nodes/Intercom/Intercom.node.ts +++ b/packages/nodes-base/nodes/Intercom/Intercom.node.ts @@ -6,6 +6,7 @@ import type { INodePropertyOptions, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; import { leadFields, leadOperations } from './LeadDescription'; @@ -82,7 +83,7 @@ export class Intercom implements INodeType { try { response = await intercomApiRequest.call(this, '/companies', 'GET'); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } const companies = response.companies; for (const company of companies) { @@ -201,7 +202,7 @@ export class Intercom implements INodeType { try { responseData = await intercomApiRequest.call(this, '/contacts', 'POST', body); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } if (operation === 'get') { @@ -224,7 +225,7 @@ export class Intercom implements INodeType { responseData = responseData.contacts; } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } if (operation === 'getAll') { @@ -248,7 +249,7 @@ export class Intercom implements INodeType { responseData = responseData.contacts; } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } if (operation === 'delete') { @@ -262,7 +263,7 @@ export class Intercom implements INodeType { responseData = await intercomApiRequest.call(this, '/contacts', 'DELETE', {}, qs); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } } @@ -377,7 +378,7 @@ export class Intercom implements INodeType { try { responseData = await intercomApiRequest.call(this, '/users', 'POST', body, qs); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } if (operation === 'get') { @@ -399,7 +400,7 @@ export class Intercom implements INodeType { responseData = await intercomApiRequest.call(this, '/users', 'GET', {}, qs); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } if (operation === 'getAll') { @@ -423,7 +424,7 @@ export class Intercom implements INodeType { responseData = responseData.users; } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } if (operation === 'delete') { @@ -614,7 +615,7 @@ export class Intercom implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/InvoiceNinja/GenericFunctions.ts b/packages/nodes-base/nodes/InvoiceNinja/GenericFunctions.ts index ae0dc2e604..f88d099802 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/GenericFunctions.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/GenericFunctions.ts @@ -74,7 +74,7 @@ export async function invoiceNinjaApiRequestAllItems( if (next) { uri = next; } - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.meta?.pagination?.links?.next); return returnData; diff --git a/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinja.node.ts b/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinja.node.ts index 54e668a1af..b02c2754cd 100644 --- a/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinja.node.ts +++ b/packages/nodes-base/nodes/InvoiceNinja/InvoiceNinja.node.ts @@ -1006,7 +1006,7 @@ export class InvoiceNinja implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Iterable/GenericFunctions.ts b/packages/nodes-base/nodes/Iterable/GenericFunctions.ts index 6011e08f87..11735fd71a 100644 --- a/packages/nodes-base/nodes/Iterable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Iterable/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function iterableApiRequest( @@ -32,13 +32,13 @@ export async function iterableApiRequest( if (Object.keys(headers).length !== 0) { options.headers = Object.assign({}, options.headers, headers); } - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } //@ts-ignore return await this.helpers.request.call(this, options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -59,7 +59,7 @@ export async function iterableApiRequestAllItems( do { responseData = await iterableApiRequest.call(this, method, endpoint, body, query); query.pageToken = responseData.nextPageToken; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.nextPageToken !== undefined && responseData.nextPageToken !== ''); return returnData; diff --git a/packages/nodes-base/nodes/Iterable/Iterable.node.ts b/packages/nodes-base/nodes/Iterable/Iterable.node.ts index fbb0adea09..f61998e8a2 100644 --- a/packages/nodes-base/nodes/Iterable/Iterable.node.ts +++ b/packages/nodes-base/nodes/Iterable/Iterable.node.ts @@ -7,6 +7,7 @@ import type { INodePropertyOptions, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -142,7 +143,7 @@ export class Iterable implements INodeType { responseData = await iterableApiRequest.call(this, 'POST', '/events/trackBulk', { events }); - returnData.push(responseData); + returnData.push(responseData as IDataObject); } } @@ -189,7 +190,7 @@ export class Iterable implements INodeType { } } - returnData.push(responseData); + returnData.push(responseData as IDataObject); } } @@ -213,11 +214,11 @@ export class Iterable implements INodeType { if (!this.continueOnFail()) { if (responseData.code !== 'Success') { - throw new NodeApiError(this.getNode(), responseData); + throw new NodeApiError(this.getNode(), responseData as JsonObject); } } - returnData.push(responseData); + returnData.push(responseData as IDataObject); } } @@ -241,8 +242,8 @@ export class Iterable implements INodeType { responseData = await iterableApiRequest.call(this, 'GET', endpoint, {}, qs); if (!this.continueOnFail()) { - if (Object.keys(responseData).length === 0) { - throw new NodeApiError(this.getNode(), responseData, { + if (Object.keys(responseData as IDataObject).length === 0) { + throw new NodeApiError(this.getNode(), responseData as JsonObject, { message: 'User not found', httpCode: '404', }); @@ -250,7 +251,7 @@ export class Iterable implements INodeType { } responseData = responseData.user || {}; - returnData.push(responseData); + returnData.push(responseData as IDataObject); } } } @@ -283,7 +284,7 @@ export class Iterable implements INodeType { responseData = await iterableApiRequest.call(this, 'POST', '/lists/subscribe', body); - returnData.push(responseData); + returnData.push(responseData as IDataObject); } if (operation === 'remove') { @@ -317,7 +318,7 @@ export class Iterable implements INodeType { responseData = await iterableApiRequest.call(this, 'POST', '/lists/unsubscribe', body); - returnData.push(responseData); + returnData.push(responseData as IDataObject); } } return [this.helpers.returnJsonArray(returnData)]; diff --git a/packages/nodes-base/nodes/Jenkins/GenericFunctions.ts b/packages/nodes-base/nodes/Jenkins/GenericFunctions.ts index eafe83cdd2..40ce762545 100644 --- a/packages/nodes-base/nodes/Jenkins/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Jenkins/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export function tolerateTrailingSlash(baseUrl: string) { @@ -42,6 +42,6 @@ export async function jenkinsApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Jenkins/Jenkins.node.ts b/packages/nodes-base/nodes/Jenkins/Jenkins.node.ts index 364720edd1..47bd1db76f 100644 --- a/packages/nodes-base/nodes/Jenkins/Jenkins.node.ts +++ b/packages/nodes-base/nodes/Jenkins/Jenkins.node.ts @@ -10,6 +10,7 @@ import type { INodePropertyOptions, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -538,7 +539,7 @@ export class Jenkins implements INodeType { if (error.httpCode === '302') { responseData = { success: true }; } else { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } } @@ -590,7 +591,7 @@ export class Jenkins implements INodeType { if (error.httpCode === '503') { responseData = { success: true }; } else { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } } @@ -602,7 +603,7 @@ export class Jenkins implements INodeType { if (error.httpCode === '503') { responseData = { success: true }; } else { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } } diff --git a/packages/nodes-base/nodes/Jira/GenericFunctions.ts b/packages/nodes-base/nodes/Jira/GenericFunctions.ts index c4988e44a8..ac1e5a5322 100644 --- a/packages/nodes-base/nodes/Jira/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Jira/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject, INodeListSearchItems } from 'n8n-workflow'; +import type { IDataObject, INodeListSearchItems, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function jiraSoftwareCloudApiRequest( @@ -49,7 +49,7 @@ export async function jiraSoftwareCloudApiRequest( Object.assign(options, option); } - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } @@ -63,7 +63,7 @@ export async function jiraSoftwareCloudApiRequest( error.description?.includes && error.description.includes("Field 'priority' cannot be set") ) { - throw new NodeApiError(this.getNode(), error, { + throw new NodeApiError(this.getNode(), error as JsonObject, { message: "Field 'priority' cannot be set. You need to add the Priority field to your Jira Project's Issue Types.", }); @@ -91,7 +91,7 @@ export async function jiraSoftwareCloudApiRequestAllItems( do { responseData = await jiraSoftwareCloudApiRequest.call(this, endpoint, method, body, query); - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); query.startAt = (responseData.startAt as number) + (responseData.maxResults as number); body.startAt = (responseData.startAt as number) + (responseData.maxResults as number); } while ( diff --git a/packages/nodes-base/nodes/Jira/Jira.node.ts b/packages/nodes-base/nodes/Jira/Jira.node.ts index 4336afd5f5..65393eeff5 100644 --- a/packages/nodes-base/nodes/Jira/Jira.node.ts +++ b/packages/nodes-base/nodes/Jira/Jira.node.ts @@ -327,9 +327,9 @@ export class Jira implements INodeType { .find((o: any) => o.id === projectId) .issuetypes.find((o: any) => o.id === issueTypeId).fields; - for (const key of Object.keys(fields)) { + for (const key of Object.keys(fields as IDataObject)) { const field = fields[key]; - if (field.schema && Object.keys(field.schema).includes('customId')) { + if (field.schema && Object.keys(field.schema as IDataObject).includes('customId')) { returnData.push({ name: field.name, value: field.key || field.fieldId, @@ -599,7 +599,7 @@ export class Jira implements INodeType { responseData = await jiraSoftwareCloudApiRequest.call(this, '/api/2/issue', 'POST', body); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -784,7 +784,7 @@ export class Jira implements INodeType { if ( (qs.expand as string).toLowerCase().indexOf('renderedfields') !== -1 && responseData.renderedFields && - Object.keys(responseData.renderedFields).length + Object.keys(responseData.renderedFields as IDataObject[]).length ) { responseData.fields = mergeWith( responseData.fields, @@ -793,6 +793,7 @@ export class Jira implements INodeType { ); } const executionData = this.helpers.constructExecutionMetaData( + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument this.helpers.returnJsonArray(simplifyIssueOutput(responseData)), { itemData: { item: i } }, ); @@ -800,7 +801,7 @@ export class Jira implements INodeType { returnData.push(...executionData); } else { const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -848,7 +849,7 @@ export class Jira implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -880,7 +881,7 @@ export class Jira implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -985,7 +986,7 @@ export class Jira implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -1016,7 +1017,7 @@ export class Jira implements INodeType { responseData = responseData.transitions; const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -1094,7 +1095,7 @@ export class Jira implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -1135,7 +1136,7 @@ export class Jira implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -1158,7 +1159,7 @@ export class Jira implements INodeType { (returnData[index].binary as IBinaryKeyData)[binaryPropertyName] = await this.helpers.prepareBinaryData( - buffer, + buffer as Buffer, attachment.json.filename as string, attachment.json.mimeType as string, ); @@ -1187,7 +1188,7 @@ export class Jira implements INodeType { responseData = responseData.map((data: IDataObject) => ({ json: data })); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -1208,7 +1209,7 @@ export class Jira implements INodeType { ); (returnData[index].binary as IBinaryKeyData)[binaryPropertyName] = await this.helpers.prepareBinaryData( - buffer, + buffer as Buffer, attachment.json.filename as string, attachment.json.mimeType as string, ); @@ -1277,7 +1278,7 @@ export class Jira implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -1300,7 +1301,7 @@ export class Jira implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -1338,7 +1339,7 @@ export class Jira implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -1422,7 +1423,7 @@ export class Jira implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -1456,7 +1457,7 @@ export class Jira implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -1501,7 +1502,7 @@ export class Jira implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Jira/JiraTrigger.node.ts b/packages/nodes-base/nodes/Jira/JiraTrigger.node.ts index 797bb9b0e3..c5f5b26db7 100644 --- a/packages/nodes-base/nodes/Jira/JiraTrigger.node.ts +++ b/packages/nodes-base/nodes/Jira/JiraTrigger.node.ts @@ -373,8 +373,8 @@ export class JiraTrigger implements INodeType { const webhooks = await jiraSoftwareCloudApiRequest.call(this, endpoint, 'GET', {}); for (const webhook of webhooks) { - if (webhook.url === webhookUrl && eventExists(events, webhook.events)) { - webhookData.webhookId = getId(webhook.self); + if (webhook.url === webhookUrl && eventExists(events, webhook.events as string[])) { + webhookData.webhookId = getId(webhook.self as string); return true; } } @@ -443,14 +443,14 @@ export class JiraTrigger implements INodeType { } } - if (Object.keys(parameters).length) { - const params = new URLSearchParams(parameters).toString(); + if (Object.keys(parameters as IDataObject).length) { + const params = new URLSearchParams(parameters as string).toString(); body.url = `${body.url}?${decodeURIComponent(params)}`; } const responseData = await jiraSoftwareCloudApiRequest.call(this, endpoint, 'POST', body); - webhookData.webhookId = getId(responseData.self); + webhookData.webhookId = getId(responseData.self as string); return true; }, diff --git a/packages/nodes-base/nodes/JotForm/GenericFunctions.ts b/packages/nodes-base/nodes/JotForm/GenericFunctions.ts index 5799335f83..5e02b3fee3 100644 --- a/packages/nodes-base/nodes/JotForm/GenericFunctions.ts +++ b/packages/nodes-base/nodes/JotForm/GenericFunctions.ts @@ -6,7 +6,7 @@ import type { ILoadOptionsFunctions, IWebhookFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function jotformApiRequest( @@ -36,7 +36,7 @@ export async function jotformApiRequest( uri: uri || `https://${credentials.apiDomain || 'api.jotform.com'}${resource}`, json: true, }; - if (!Object.keys(body).length) { + if (!Object.keys(body as IDataObject).length) { delete options.form; } options = Object.assign({}, options, option); @@ -44,6 +44,6 @@ export async function jotformApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/JotForm/JotFormTrigger.node.ts b/packages/nodes-base/nodes/JotForm/JotFormTrigger.node.ts index 98c99621d2..77efa6d857 100644 --- a/packages/nodes-base/nodes/JotForm/JotFormTrigger.node.ts +++ b/packages/nodes-base/nodes/JotForm/JotFormTrigger.node.ts @@ -113,13 +113,13 @@ export class JotFormTrigger implements INodeType { try { const responseData = await jotformApiRequest.call(this, 'GET', endpoint); - const webhookUrls = Object.values(responseData.content); + const webhookUrls = Object.values(responseData.content as IDataObject); const webhookUrl = this.getNodeWebhookUrl('default'); if (!webhookUrls.includes(webhookUrl)) { return false; } - const webhookIds = Object.keys(responseData.content); + const webhookIds = Object.keys(responseData.content as IDataObject); webhookData.webhookId = webhookIds[webhookUrls.indexOf(webhookUrl)]; } catch (error) { return false; @@ -136,7 +136,7 @@ export class JotFormTrigger implements INodeType { //webhookURL: 'https://en0xsizp3qyt7f.x.pipedream.net/', }; const { content } = await jotformApiRequest.call(this, 'POST', endpoint, body); - webhookData.webhookId = Object.keys(content)[0]; + webhookData.webhookId = Object.keys(content as IDataObject)[0]; return true; }, async delete(this: IHookFunctions): Promise { @@ -190,14 +190,16 @@ export class JotFormTrigger implements INodeType { // Create a dictionary to resolve the keys const questionNames: IDataObject = {}; - for (const question of Object.values(responseData.content)) { + for (const question of Object.values( + responseData.content as IQuestionData[], + )) { questionNames[question.name] = question.text; } // Resolve the keys let questionKey: string; const questionsData: IDataObject = {}; - for (const key of Object.keys(rawRequest)) { + for (const key of Object.keys(rawRequest as IDataObject)) { if (!key.includes('_')) { continue; } diff --git a/packages/nodes-base/nodes/Keap/GenericFunctions.ts b/packages/nodes-base/nodes/Keap/GenericFunctions.ts index 5086836cb3..31b0f62fbe 100644 --- a/packages/nodes-base/nodes/Keap/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Keap/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { IWebhookFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import { snakeCase } from 'change-case'; @@ -38,13 +38,13 @@ export async function keapApiRequest( if (Object.keys(headers).length !== 0) { options.headers = Object.assign({}, options.headers, headers); } - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } //@ts-ignore return await this.helpers.requestOAuth2.call(this, 'keapOAuth2Api', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -66,7 +66,7 @@ export async function keapApiRequestAllItems( do { responseData = await keapApiRequest.call(this, method, endpoint, body, query, uri); uri = responseData.next; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (returnData.length < responseData.count); return returnData; diff --git a/packages/nodes-base/nodes/Keap/Keap.node.ts b/packages/nodes-base/nodes/Keap/Keap.node.ts index 68aea197eb..d90467d44d 100644 --- a/packages/nodes-base/nodes/Keap/Keap.node.ts +++ b/packages/nodes-base/nodes/Keap/Keap.node.ts @@ -181,7 +181,7 @@ export class Keap implements INodeType { async getCountries(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const { countries } = await keapApiRequest.call(this, 'GET', '/locales/countries'); - for (const key of Object.keys(countries)) { + for (const key of Object.keys(countries as IDataObject)) { const countryName = countries[key]; const countryId = key; returnData.push({ @@ -201,7 +201,7 @@ export class Keap implements INodeType { 'GET', `/locales/countries/${countryCode}/provinces`, ); - for (const key of Object.keys(provinces)) { + for (const key of Object.keys(provinces as IDataObject)) { const provinceName = provinces[key]; const provinceId = key; returnData.push({ @@ -858,7 +858,7 @@ export class Keap implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Kitemaker/GenericFunctions.ts b/packages/nodes-base/nodes/Kitemaker/GenericFunctions.ts index 9e6d28eb25..e193d8f5ae 100644 --- a/packages/nodes-base/nodes/Kitemaker/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Kitemaker/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject, IHookFunctions } from 'n8n-workflow'; +import type { IDataObject, IHookFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function kitemakerRequest( @@ -24,7 +24,7 @@ export async function kitemakerRequest( const responseData = await this.helpers.request.call(this, options); if (responseData.errors) { - throw new NodeApiError(this.getNode(), responseData); + throw new NodeApiError(this.getNode(), responseData as JsonObject); } return responseData; @@ -56,7 +56,7 @@ export async function kitemakerRequestAllItems( do { responseData = await kitemakerRequest.call(this, body); body.variables.cursor = responseData.data[group].cursor; - returnData.push(...responseData.data[group][items]); + returnData.push(...(responseData.data[group][items] as IDataObject[])); if (!returnAll && returnData.length > limit) { return returnData.slice(0, limit); @@ -66,8 +66,9 @@ export async function kitemakerRequestAllItems( return returnData; } +export type LoadOptions = { name?: string; username?: string; title?: string; id: string }; export function createLoadOptions( - resources: Array<{ name?: string; username?: string; title?: string; id: string }>, + resources: LoadOptions[], ): Array<{ name: string; value: string }> { return resources.map((option) => { if (option.username) return { name: option.username, value: option.id }; diff --git a/packages/nodes-base/nodes/Kitemaker/Kitemaker.node.ts b/packages/nodes-base/nodes/Kitemaker/Kitemaker.node.ts index 3535c15c91..7f6a0ee0d8 100644 --- a/packages/nodes-base/nodes/Kitemaker/Kitemaker.node.ts +++ b/packages/nodes-base/nodes/Kitemaker/Kitemaker.node.ts @@ -1,6 +1,7 @@ import type { IExecuteFunctions } from 'n8n-core'; import type { + IDataObject, ILoadOptionsFunctions, INodeExecutionData, INodeType, @@ -18,6 +19,7 @@ import { workItemOperations, } from './descriptions'; +import type { LoadOptions } from './GenericFunctions'; import { createLoadOptions, kitemakerRequest, kitemakerRequestAllItems } from './GenericFunctions'; import { @@ -102,7 +104,7 @@ export class Kitemaker implements INodeType { }, } = responseData; - return createLoadOptions(spaces[0].labels); + return createLoadOptions(spaces[0].labels as LoadOptions[]); }, async getSpaces(this: ILoadOptionsFunctions) { @@ -113,7 +115,7 @@ export class Kitemaker implements INodeType { }, } = responseData; - return createLoadOptions(spaces); + return createLoadOptions(spaces as LoadOptions[]); }, async getStatuses(this: ILoadOptionsFunctions) { @@ -133,7 +135,7 @@ export class Kitemaker implements INodeType { } = responseData; const space = spaces.find((e: { [x: string]: string }) => e.id === spaceId); - return createLoadOptions(space.statuses); + return createLoadOptions(space.statuses as LoadOptions[]); }, async getUsers(this: ILoadOptionsFunctions) { @@ -144,7 +146,7 @@ export class Kitemaker implements INodeType { }, } = responseData; - return createLoadOptions(users); + return createLoadOptions(users as LoadOptions[]); }, async getWorkItems(this: ILoadOptionsFunctions) { @@ -161,7 +163,7 @@ export class Kitemaker implements INodeType { }, } = responseData; - return createLoadOptions(workItems); + return createLoadOptions(workItems as LoadOptions[]); }, }, }; @@ -320,7 +322,7 @@ export class Kitemaker implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/KoBoToolbox/GenericFunctions.ts b/packages/nodes-base/nodes/KoBoToolbox/GenericFunctions.ts index 8e41846cca..417ac88fbd 100644 --- a/packages/nodes-base/nodes/KoBoToolbox/GenericFunctions.ts +++ b/packages/nodes-base/nodes/KoBoToolbox/GenericFunctions.ts @@ -116,7 +116,7 @@ const formatValue = (value: any, format: string): any => { value = toString(value); // Parse geoPoints - const geoPoint = parseGeoPoint(value); + const geoPoint = parseGeoPoint(value as string); if (geoPoint) { return { type: 'Point', @@ -126,12 +126,13 @@ const formatValue = (value: any, format: string): any => { // Check if it's a closed polygon geo-shape: -1.954117 30.085159 0 0;-1.955005 30.084622 0 0;-1.956057 30.08506 0 0;-1.956393 30.086229 0 0;-1.955853 30.087143 0 0;-1.954609 30.08725 0 0;-1.953966 30.086735 0 0;-1.953805 30.085897 0 0;-1.954117 30.085159 0 0 const points = value.split(';'); - if (points.length >= 2 && /^[-\d\.\s;]+$/.test(value)) { + if (points.length >= 2 && /^[-\d\.\s;]+$/.test(value as string)) { // Using the GeoJSON format as per https://geojson.org/ - const coordinates = compact(points.map(parseGeoPoint)); + const coordinates = compact(points.map(parseGeoPoint) as number[]); // Only return if all values are properly parsed if (coordinates.length === points.length) { // If the shape is closed, declare it as Polygon, otherwise as LineString + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument if (first(points) === last(points)) { return { type: 'Polygon', @@ -284,8 +285,8 @@ export async function downloadAttachments( } binaryItem.binary![binaryName] = await this.helpers.prepareBinaryData( - response.body, - fileName, + response.body as Buffer, + fileName as string, ); } } diff --git a/packages/nodes-base/nodes/KoBoToolbox/KoBoToolbox.node.ts b/packages/nodes-base/nodes/KoBoToolbox/KoBoToolbox.node.ts index ac7ad4abb9..3c70469384 100644 --- a/packages/nodes-base/nodes/KoBoToolbox/KoBoToolbox.node.ts +++ b/packages/nodes-base/nodes/KoBoToolbox/KoBoToolbox.node.ts @@ -200,7 +200,11 @@ export class KoBoToolbox implements INodeType { // Download related attachments for (const submission of responseData) { binaryItems.push( - await downloadAttachments.call(this, submission, submissionQueryOptions), + await downloadAttachments.call( + this, + submission as IDataObject, + submissionQueryOptions, + ), ); } } @@ -237,7 +241,9 @@ export class KoBoToolbox implements INodeType { if (options.download) { // Download related attachments for (const submission of responseData) { - binaryItems.push(await downloadAttachments.call(this, submission, options)); + binaryItems.push( + await downloadAttachments.call(this, submission as IDataObject, options), + ); } } } @@ -415,8 +421,8 @@ export class KoBoToolbox implements INodeType { console.dir(response); binaryItem.binary![binaryPropertyName] = await this.helpers.prepareBinaryData( - response, - responseData[0].metadata.filename, + response as Buffer, + responseData[0].metadata.filename as string, ); binaryItems.push(binaryItem); diff --git a/packages/nodes-base/nodes/KoBoToolbox/KoBoToolboxTrigger.node.ts b/packages/nodes-base/nodes/KoBoToolbox/KoBoToolboxTrigger.node.ts index 2b3c59e581..6da071ff27 100644 --- a/packages/nodes-base/nodes/KoBoToolbox/KoBoToolboxTrigger.node.ts +++ b/packages/nodes-base/nodes/KoBoToolbox/KoBoToolboxTrigger.node.ts @@ -145,13 +145,15 @@ export class KoBoToolboxTrigger implements INodeType { // prettier-ignore const responseData = formatOptions.reformat - ? formatSubmission(req.body, parseStringList(formatOptions.selectMask as string), parseStringList(formatOptions.numberMask as string)) + ? formatSubmission(req.body as IDataObject, parseStringList(formatOptions.selectMask as string), parseStringList(formatOptions.numberMask as string)) : req.body; if (formatOptions.download) { // Download related attachments return { - workflowData: [[await downloadAttachments.call(this, responseData, formatOptions)]], + workflowData: [ + [await downloadAttachments.call(this, responseData as IDataObject, formatOptions)], + ], }; } else { return { diff --git a/packages/nodes-base/nodes/Lemlist/GenericFunctions.ts b/packages/nodes-base/nodes/Lemlist/GenericFunctions.ts index bcf9dbce37..7864c94a01 100644 --- a/packages/nodes-base/nodes/Lemlist/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Lemlist/GenericFunctions.ts @@ -59,7 +59,7 @@ export async function lemlistApiRequestAllItems( do { responseData = await lemlistApiRequest.call(this, method, endpoint, {}, qs); - returnData.push(...responseData); + returnData.push(...(responseData as IDataObject[])); qs.offset += qs.limit; } while (responseData.length !== 0); return returnData; diff --git a/packages/nodes-base/nodes/Lemlist/Lemlist.node.ts b/packages/nodes-base/nodes/Lemlist/Lemlist.node.ts index cd39377155..759ab50bbd 100644 --- a/packages/nodes-base/nodes/Lemlist/Lemlist.node.ts +++ b/packages/nodes-base/nodes/Lemlist/Lemlist.node.ts @@ -301,7 +301,7 @@ export class Lemlist implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Lemlist/LemlistTrigger.node.ts b/packages/nodes-base/nodes/Lemlist/LemlistTrigger.node.ts index d1843f7781..d23b3ed413 100644 --- a/packages/nodes-base/nodes/Lemlist/LemlistTrigger.node.ts +++ b/packages/nodes-base/nodes/Lemlist/LemlistTrigger.node.ts @@ -137,7 +137,7 @@ export class LemlistTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const req = this.getRequestObject(); return { - workflowData: [this.helpers.returnJsonArray(req.body)], + workflowData: [this.helpers.returnJsonArray(req.body as IDataObject)], }; } } diff --git a/packages/nodes-base/nodes/Line/GenericFunctions.ts b/packages/nodes-base/nodes/Line/GenericFunctions.ts index 36512c7a9a..1139837e36 100644 --- a/packages/nodes-base/nodes/Line/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Line/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function lineApiRequest( @@ -33,7 +33,7 @@ export async function lineApiRequest( options = Object.assign({}, options, option); try { - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } @@ -41,6 +41,6 @@ export async function lineApiRequest( tokenType: 'Bearer', }); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Line/Line.node.ts b/packages/nodes-base/nodes/Line/Line.node.ts index ab7c00e7b5..377c901366 100644 --- a/packages/nodes-base/nodes/Line/Line.node.ts +++ b/packages/nodes-base/nodes/Line/Line.node.ts @@ -143,7 +143,7 @@ export class Line implements INodeType { } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Linear/GenericFunctions.ts b/packages/nodes-base/nodes/Linear/GenericFunctions.ts index 1b3879203b..03a9bd75a2 100644 --- a/packages/nodes-base/nodes/Linear/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Linear/GenericFunctions.ts @@ -59,7 +59,7 @@ export async function linearApiRequestAllItems( do { responseData = await linearApiRequest.call(this, body); - returnData.push.apply(returnData, get(responseData, `${propertyName}.nodes`)); + returnData.push.apply(returnData, get(responseData, `${propertyName}.nodes`) as IDataObject[]); body.variables.after = get(responseData, `${propertyName}.pageInfo.endCursor`); } while (get(responseData, `${propertyName}.pageInfo.hasNextPage`)); return returnData; diff --git a/packages/nodes-base/nodes/Linear/Linear.node.ts b/packages/nodes-base/nodes/Linear/Linear.node.ts index e04b07aace..577e83074c 100644 --- a/packages/nodes-base/nodes/Linear/Linear.node.ts +++ b/packages/nodes-base/nodes/Linear/Linear.node.ts @@ -265,7 +265,7 @@ export class Linear implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/LingvaNex/GenericFunctions.ts b/packages/nodes-base/nodes/LingvaNex/GenericFunctions.ts index 640bacba01..84e6c7d2b2 100644 --- a/packages/nodes-base/nodes/LingvaNex/GenericFunctions.ts +++ b/packages/nodes-base/nodes/LingvaNex/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function lingvaNexApiRequest( @@ -38,11 +38,11 @@ export async function lingvaNexApiRequest( const response = await this.helpers.request(options); if (response.err !== null) { - throw new NodeApiError(this.getNode(), response); + throw new NodeApiError(this.getNode(), response as JsonObject); } return response; } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/LinkedIn/GenericFunctions.ts b/packages/nodes-base/nodes/LinkedIn/GenericFunctions.ts index 9ab7711ab8..7fb62b2496 100644 --- a/packages/nodes-base/nodes/LinkedIn/GenericFunctions.ts +++ b/packages/nodes-base/nodes/LinkedIn/GenericFunctions.ts @@ -1,6 +1,7 @@ import type { OptionsWithUrl } from 'request'; import type { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function linkedInApiRequest( @@ -29,7 +30,7 @@ export async function linkedInApiRequest( options.encoding = null; } - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } @@ -38,7 +39,7 @@ export async function linkedInApiRequest( tokenType: 'Bearer', }); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/LinkedIn/LinkedIn.node.ts b/packages/nodes-base/nodes/LinkedIn/LinkedIn.node.ts index c3fccf6a7b..eee851e9d5 100644 --- a/packages/nodes-base/nodes/LinkedIn/LinkedIn.node.ts +++ b/packages/nodes-base/nodes/LinkedIn/LinkedIn.node.ts @@ -1,5 +1,6 @@ import type { IExecuteFunctions } from 'n8n-core'; import type { + IDataObject, ILoadOptionsFunctions, INodeExecutionData, INodePropertyOptions, @@ -256,7 +257,7 @@ export class LinkedIn implements INodeType { } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/LocalFileTrigger/LocalFileTrigger.node.ts b/packages/nodes-base/nodes/LocalFileTrigger/LocalFileTrigger.node.ts index e16681c06f..ac2b341d89 100644 --- a/packages/nodes-base/nodes/LocalFileTrigger/LocalFileTrigger.node.ts +++ b/packages/nodes-base/nodes/LocalFileTrigger/LocalFileTrigger.node.ts @@ -197,7 +197,7 @@ export class LocalFileTrigger implements INodeType { }; for (const eventName of events) { - watcher.on(eventName, (pathString) => executeTrigger(eventName, pathString)); + watcher.on(eventName, (pathString) => executeTrigger(eventName, pathString as string)); } async function closeFunction() { diff --git a/packages/nodes-base/nodes/Magento/GenericFunctions.ts b/packages/nodes-base/nodes/Magento/GenericFunctions.ts index 6d9092060c..a0550d891f 100644 --- a/packages/nodes-base/nodes/Magento/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Magento/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { IWebhookFunctions, } from 'n8n-core'; -import type { IDataObject, INodeProperties, INodePropertyOptions } from 'n8n-workflow'; +import type { IDataObject, INodeProperties, INodePropertyOptions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import type { Address, Filter, FilterGroup, ProductAttribute, Search } from './Types'; @@ -35,13 +35,13 @@ export async function magentoApiRequest( try { options = Object.assign({}, options, option); - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } //@ts-ignore return await this.helpers.requestWithAuthentication.call(this, 'magento2Api', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -60,7 +60,7 @@ export async function magentoApiRequestAllItems( do { responseData = await magentoApiRequest.call(this, method, resource, body, query); - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); query.current_page = query.current_page ? (query.current_page as number)++ : 1; } while (returnData.length < responseData.total_count); diff --git a/packages/nodes-base/nodes/Magento/Magento2.node.ts b/packages/nodes-base/nodes/Magento/Magento2.node.ts index fadf642d55..59a7202621 100644 --- a/packages/nodes-base/nodes/Magento/Magento2.node.ts +++ b/packages/nodes-base/nodes/Magento/Magento2.node.ts @@ -793,7 +793,7 @@ export class Magento2 implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Mailcheck/GenericFunctions.ts b/packages/nodes-base/nodes/Mailcheck/GenericFunctions.ts index 8e17aff83d..af2c376024 100644 --- a/packages/nodes-base/nodes/Mailcheck/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mailcheck/GenericFunctions.ts @@ -38,7 +38,7 @@ export async function mailCheckApiRequest( if (Object.keys(headers).length !== 0) { options.headers = Object.assign({}, options.headers, headers); } - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } return await this.helpers.request.call(this, options); diff --git a/packages/nodes-base/nodes/Mailchimp/GenericFunctions.ts b/packages/nodes-base/nodes/Mailchimp/GenericFunctions.ts index a659a94d88..141d871461 100644 --- a/packages/nodes-base/nodes/Mailchimp/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mailchimp/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; async function getMetadata( @@ -51,7 +51,7 @@ export async function mailchimpApiRequest( json: true, }; - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } @@ -78,7 +78,7 @@ export async function mailchimpApiRequest( }); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -100,7 +100,7 @@ export async function mailchimpApiRequestAllItems( do { responseData = await mailchimpApiRequest.call(this, endpoint, method, body, query); - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); query.offset += query.count; } while (responseData[propertyName] && responseData[propertyName].length !== 0); diff --git a/packages/nodes-base/nodes/Mailchimp/Mailchimp.node.ts b/packages/nodes-base/nodes/Mailchimp/Mailchimp.node.ts index 8ee510ef9c..bb126b5051 100644 --- a/packages/nodes-base/nodes/Mailchimp/Mailchimp.node.ts +++ b/packages/nodes-base/nodes/Mailchimp/Mailchimp.node.ts @@ -2186,7 +2186,7 @@ export class Mailchimp implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Mailchimp/MailchimpTrigger.node.ts b/packages/nodes-base/nodes/Mailchimp/MailchimpTrigger.node.ts index 524edc6def..68ac48f1c0 100644 --- a/packages/nodes-base/nodes/Mailchimp/MailchimpTrigger.node.ts +++ b/packages/nodes-base/nodes/Mailchimp/MailchimpTrigger.node.ts @@ -1,11 +1,13 @@ import type { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import type { + IDataObject, ILoadOptionsFunctions, INodePropertyOptions, INodeType, INodeTypeDescription, IWebhookResponseData, + JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import { mailchimpApiRequest } from './GenericFunctions'; @@ -201,7 +203,7 @@ export class MailchimpTrigger implements INodeType { } throw error; } - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } return true; }, @@ -285,7 +287,7 @@ export class MailchimpTrigger implements INodeType { return {}; } return { - workflowData: [this.helpers.returnJsonArray(req.body)], + workflowData: [this.helpers.returnJsonArray(req.body as IDataObject)], }; } } diff --git a/packages/nodes-base/nodes/MailerLite/GenericFunctions.ts b/packages/nodes-base/nodes/MailerLite/GenericFunctions.ts index 140e0daa2b..6808b57be7 100644 --- a/packages/nodes-base/nodes/MailerLite/GenericFunctions.ts +++ b/packages/nodes-base/nodes/MailerLite/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function mailerliteApiRequest( @@ -32,13 +32,13 @@ export async function mailerliteApiRequest( json: true, }; try { - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } //@ts-ignore return await this.helpers.request.call(this, options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -59,7 +59,7 @@ export async function mailerliteApiRequestAllItems( do { responseData = await mailerliteApiRequest.call(this, method, endpoint, body, query); - returnData.push.apply(returnData, responseData); + returnData.push.apply(returnData, responseData as IDataObject[]); query.offset = query.offset + query.limit; } while (responseData.length !== 0); return returnData; diff --git a/packages/nodes-base/nodes/MailerLite/MailerLite.node.ts b/packages/nodes-base/nodes/MailerLite/MailerLite.node.ts index 72f4b3c0c5..407f4b7a61 100644 --- a/packages/nodes-base/nodes/MailerLite/MailerLite.node.ts +++ b/packages/nodes-base/nodes/MailerLite/MailerLite.node.ts @@ -194,7 +194,7 @@ export class MailerLite implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Mailgun/Mailgun.node.ts b/packages/nodes-base/nodes/Mailgun/Mailgun.node.ts index fc45a8ff4d..f5f70fa92a 100644 --- a/packages/nodes-base/nodes/Mailgun/Mailgun.node.ts +++ b/packages/nodes-base/nodes/Mailgun/Mailgun.node.ts @@ -4,6 +4,7 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -184,11 +185,11 @@ export class Mailgun implements INodeType { options, ); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: itemIndex } }, ); diff --git a/packages/nodes-base/nodes/Mailjet/GenericFunctions.ts b/packages/nodes-base/nodes/Mailjet/GenericFunctions.ts index afb79c9501..c474cc1f15 100644 --- a/packages/nodes-base/nodes/Mailjet/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mailjet/GenericFunctions.ts @@ -43,7 +43,7 @@ export async function mailjetApiRequest( json: true, }; options = Object.assign({}, options, option); - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } @@ -69,7 +69,7 @@ export async function mailjetApiRequestAllItems( responseData = await mailjetApiRequest.call(this, method, endpoint, body, query, undefined, { resolveWithFullResponse: true, }); - returnData.push.apply(returnData, responseData.body); + returnData.push.apply(returnData, responseData.body as IDataObject[]); query.Offset = query.Offset + query.Limit; } while (responseData.length !== 0); return returnData; diff --git a/packages/nodes-base/nodes/Mailjet/Mailjet.node.ts b/packages/nodes-base/nodes/Mailjet/Mailjet.node.ts index f4bb00d46a..be82c8372a 100644 --- a/packages/nodes-base/nodes/Mailjet/Mailjet.node.ts +++ b/packages/nodes-base/nodes/Mailjet/Mailjet.node.ts @@ -305,7 +305,7 @@ export class Mailjet implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Mailjet/MailjetTrigger.node.ts b/packages/nodes-base/nodes/Mailjet/MailjetTrigger.node.ts index 371e0942b2..dd15d13ab4 100644 --- a/packages/nodes-base/nodes/Mailjet/MailjetTrigger.node.ts +++ b/packages/nodes-base/nodes/Mailjet/MailjetTrigger.node.ts @@ -127,7 +127,7 @@ export class MailjetTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const req = this.getRequestObject(); return { - workflowData: [this.helpers.returnJsonArray(req.body)], + workflowData: [this.helpers.returnJsonArray(req.body as IDataObject[])], }; } } diff --git a/packages/nodes-base/nodes/Mandrill/GenericFunctions.ts b/packages/nodes-base/nodes/Mandrill/GenericFunctions.ts index 9fc677ca80..4a00dd9176 100644 --- a/packages/nodes-base/nodes/Mandrill/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mandrill/GenericFunctions.ts @@ -3,6 +3,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core'; import map from 'lodash.map'; +import type { JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function mandrillApiRequest( @@ -31,7 +32,7 @@ export async function mandrillApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Mandrill/Mandrill.node.ts b/packages/nodes-base/nodes/Mandrill/Mandrill.node.ts index c5b0f4a82d..3b429a14a6 100644 --- a/packages/nodes-base/nodes/Mandrill/Mandrill.node.ts +++ b/packages/nodes-base/nodes/Mandrill/Mandrill.node.ts @@ -7,6 +7,7 @@ import type { INodePropertyOptions, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -693,7 +694,7 @@ export class Mandrill implements INodeType { try { templates = await mandrillApiRequest.call(this, '/templates', 'POST', '/list'); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } for (const template of templates) { const templateName = template.name; @@ -886,7 +887,7 @@ export class Mandrill implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Marketstack/GenericFunctions.ts b/packages/nodes-base/nodes/Marketstack/GenericFunctions.ts index eec8f80e71..8281ced75b 100644 --- a/packages/nodes-base/nodes/Marketstack/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Marketstack/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; export async function marketstackApiRequest( @@ -32,7 +32,7 @@ export async function marketstackApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -53,7 +53,7 @@ export async function marketstackApiRequestAllItems( do { responseData = await marketstackApiRequest.call(this, method, endpoint, body, qs); - returnData.push(...responseData.data); + returnData.push(...(responseData.data as IDataObject[])); if (!returnAll && returnData.length > limit) { return returnData.slice(0, limit); diff --git a/packages/nodes-base/nodes/Marketstack/Marketstack.node.ts b/packages/nodes-base/nodes/Marketstack/Marketstack.node.ts index 6f553eb848..e848d36877 100644 --- a/packages/nodes-base/nodes/Marketstack/Marketstack.node.ts +++ b/packages/nodes-base/nodes/Marketstack/Marketstack.node.ts @@ -174,7 +174,7 @@ export class Marketstack implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Matrix/GenericFunctions.ts b/packages/nodes-base/nodes/Matrix/GenericFunctions.ts index a3da9e63e5..2711887537 100644 --- a/packages/nodes-base/nodes/Matrix/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Matrix/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { OptionsWithUri } from 'request'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; @@ -46,9 +46,9 @@ export async function matrixApiRequest( // When working with images, the request cannot be JSON (it's raw binary data) // But the output is JSON so we have to parse it manually. //@ts-ignore - return options.overridePrefix === 'media' ? JSON.parse(response) : response; + return options.overridePrefix === 'media' ? JSON.parse(response as string) : response; } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -148,7 +148,7 @@ export async function handleMatrixCall( {}, qs, ); - returnData.push.apply(returnData, responseData.chunk); + returnData.push.apply(returnData, responseData.chunk as IDataObject[]); from = responseData.end; } while (responseData.chunk.length > 0); } else { @@ -169,7 +169,7 @@ export async function handleMatrixCall( {}, qs, ); - returnData.push.apply(returnData, responseData.chunk); + returnData.push.apply(returnData, responseData.chunk as IDataObject[]); } return returnData; diff --git a/packages/nodes-base/nodes/Matrix/Matrix.node.ts b/packages/nodes-base/nodes/Matrix/Matrix.node.ts index 46edec80f1..9739af5c5b 100644 --- a/packages/nodes-base/nodes/Matrix/Matrix.node.ts +++ b/packages/nodes-base/nodes/Matrix/Matrix.node.ts @@ -146,7 +146,7 @@ export class Matrix implements INodeType { try { const responseData = await handleMatrixCall.call(this, items[i], i, resource, operation); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/addUser/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/addUser/execute.ts index 3c275fbc4d..700bd8e058 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/addUser/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/addUser/execute.ts @@ -19,5 +19,5 @@ export async function addUser( const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - return this.helpers.returnJsonArray(responseData); + return this.helpers.returnJsonArray(responseData as IDataObject[]); } diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/create/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/create/execute.ts index 34991a0707..1713512827 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/create/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/create/execute.ts @@ -22,5 +22,5 @@ export async function create( const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - return this.helpers.returnJsonArray(responseData); + return this.helpers.returnJsonArray(responseData as IDataObject[]); } diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/del/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/del/execute.ts index a72c7007b8..43187ef190 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/del/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/del/execute.ts @@ -14,5 +14,5 @@ export async function del(this: IExecuteFunctions, index: number): Promise 0) { responseData = await apiRequest.call(this, 'POST', 'users/ids', userIds, qs); @@ -42,5 +42,5 @@ export async function members( } } - return this.helpers.returnJsonArray(responseData); + return this.helpers.returnJsonArray(responseData as IDataObject[]); } diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/restore/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/restore/execute.ts index 4436c08908..fed5e848fd 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/restore/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/restore/execute.ts @@ -17,5 +17,5 @@ export async function restore( const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - return this.helpers.returnJsonArray(responseData); + return this.helpers.returnJsonArray(responseData as IDataObject[]); } diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/search/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/search/execute.ts index 47d1b70297..0945ea2547 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/search/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/search/execute.ts @@ -24,5 +24,5 @@ export async function search( responseData = responseData.slice(0, limit); } - return this.helpers.returnJsonArray(responseData); + return this.helpers.returnJsonArray(responseData as IDataObject[]); } diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/statistics/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/statistics/execute.ts index 6164cd36ab..5b48083a12 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/channel/statistics/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/channel/statistics/execute.ts @@ -17,5 +17,5 @@ export async function statistics( const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - return this.helpers.returnJsonArray(responseData); + return this.helpers.returnJsonArray(responseData as IDataObject[]); } diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/message/del/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/message/del/execute.ts index eb6fef7741..8fe76503e3 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/message/del/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/message/del/execute.ts @@ -14,5 +14,5 @@ export async function del(this: IExecuteFunctions, index: number): Promise 0) { responseData = responseData.slice(0, limit); } - return this.helpers.returnJsonArray(responseData); + return this.helpers.returnJsonArray(responseData as IDataObject[]); } diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/user/create/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/user/create/execute.ts index 16da1743cb..d117fb34a2 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/user/create/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/user/create/execute.ts @@ -35,5 +35,5 @@ export async function create( const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - return this.helpers.returnJsonArray(responseData); + return this.helpers.returnJsonArray(responseData as IDataObject[]); } diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/user/deactive/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/user/deactive/execute.ts index 2951d59b57..626a10ae67 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/user/deactive/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/user/deactive/execute.ts @@ -16,5 +16,5 @@ export async function deactive( const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - return this.helpers.returnJsonArray(responseData); + return this.helpers.returnJsonArray(responseData as IDataObject[]); } diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/user/getAll/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/user/getAll/execute.ts index 64563bc24e..dc83aaaa83 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/user/getAll/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/user/getAll/execute.ts @@ -110,5 +110,5 @@ export async function getAll( responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); } - return this.helpers.returnJsonArray(responseData); + return this.helpers.returnJsonArray(responseData as IDataObject[]); } diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/user/getByEmail/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/user/getByEmail/execute.ts index 3ddcfba5b0..b5f1f22a74 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/user/getByEmail/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/user/getByEmail/execute.ts @@ -17,5 +17,5 @@ export async function getByEmail( const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - return this.helpers.returnJsonArray(responseData); + return this.helpers.returnJsonArray(responseData as IDataObject[]); } diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/user/getById/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/user/getById/execute.ts index 9c7015c4b8..3bacfd7e4b 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/user/getById/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/user/getById/execute.ts @@ -21,5 +21,5 @@ export async function getById( const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - return this.helpers.returnJsonArray(responseData); + return this.helpers.returnJsonArray(responseData as IDataObject[]); } diff --git a/packages/nodes-base/nodes/Mattermost/v1/actions/user/invite/execute.ts b/packages/nodes-base/nodes/Mattermost/v1/actions/user/invite/execute.ts index bfa4e76d83..4bc861b511 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/actions/user/invite/execute.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/actions/user/invite/execute.ts @@ -19,5 +19,5 @@ export async function invite( const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - return this.helpers.returnJsonArray(responseData); + return this.helpers.returnJsonArray(responseData as IDataObject[]); } diff --git a/packages/nodes-base/nodes/Mattermost/v1/transport/index.ts b/packages/nodes-base/nodes/Mattermost/v1/transport/index.ts index 2e2919c309..2a5626edfe 100644 --- a/packages/nodes-base/nodes/Mattermost/v1/transport/index.ts +++ b/packages/nodes-base/nodes/Mattermost/v1/transport/index.ts @@ -48,7 +48,7 @@ export async function apiRequestAllItems( do { responseData = await apiRequest.call(this, method, endpoint, body, query); query.page++; - returnData.push.apply(returnData, responseData); + returnData.push.apply(returnData, responseData as IDataObject[]); } while (responseData.length !== 0); return returnData; diff --git a/packages/nodes-base/nodes/Mautic/GenericFunctions.ts b/packages/nodes-base/nodes/Mautic/GenericFunctions.ts index 88ade4287b..3afea8b387 100644 --- a/packages/nodes-base/nodes/Mautic/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mautic/GenericFunctions.ts @@ -52,7 +52,7 @@ export async function mauticApiRequest( if (returnData.errors) { // They seem to to sometimes return 200 status but still error. - throw new NodeApiError(this.getNode(), returnData); + throw new NodeApiError(this.getNode(), returnData as JsonObject); } return returnData; @@ -82,13 +82,13 @@ export async function mauticApiRequestAllItems( do { responseData = await mauticApiRequest.call(this, method, endpoint, body, query); - const values = Object.values(responseData[propertyName]); + const values = Object.values(responseData[propertyName] as IDataObject[]); //@ts-ignore returnData.push.apply(returnData, values); query.start += query.limit; } while ( responseData.total !== undefined && - returnData.length - parseInt(responseData.total, 10) < 0 + returnData.length - parseInt(responseData.total as string, 10) < 0 ); return returnData; diff --git a/packages/nodes-base/nodes/Mautic/Mautic.node.ts b/packages/nodes-base/nodes/Mautic/Mautic.node.ts index ca307e18a1..3db55530a7 100644 --- a/packages/nodes-base/nodes/Mautic/Mautic.node.ts +++ b/packages/nodes-base/nodes/Mautic/Mautic.node.ts @@ -569,10 +569,10 @@ export class Mautic implements INodeType { qs.start = 0; responseData = await mauticApiRequest.call(this, 'GET', '/companies', {}, qs); if (responseData.errors) { - throw new NodeApiError(this.getNode(), responseData); + throw new NodeApiError(this.getNode(), responseData as JsonObject); } responseData = responseData.companies; - responseData = Object.values(responseData); + responseData = Object.values(responseData as IDataObject[]); } if (simple) { //@ts-ignore @@ -856,10 +856,10 @@ export class Mautic implements INodeType { qs.start = 0; responseData = await mauticApiRequest.call(this, 'GET', '/contacts', {}, qs); if (responseData.errors) { - throw new NodeApiError(this.getNode(), responseData); + throw new NodeApiError(this.getNode(), responseData as JsonObject); } responseData = responseData.contacts; - responseData = Object.values(responseData); + responseData = Object.values(responseData as IDataObject[]); } if (options.rawData === false) { //@ts-ignore @@ -1017,7 +1017,7 @@ export class Mautic implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Mautic/MauticTrigger.node.ts b/packages/nodes-base/nodes/Mautic/MauticTrigger.node.ts index ac96509b38..e9dace1619 100644 --- a/packages/nodes-base/nodes/Mautic/MauticTrigger.node.ts +++ b/packages/nodes-base/nodes/Mautic/MauticTrigger.node.ts @@ -110,7 +110,7 @@ export class MauticTrigger implements INodeType { async getEvents(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const { triggers } = await mauticApiRequest.call(this, 'GET', '/hooks/triggers'); - for (const [key, value] of Object.entries(triggers)) { + for (const [key, value] of Object.entries(triggers as IDataObject)) { const eventId = key; const eventName = (value as IDataObject).label as string; const eventDecription = (value as IDataObject).description as string; @@ -175,7 +175,7 @@ export class MauticTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const req = this.getRequestObject(); return { - workflowData: [this.helpers.returnJsonArray(req.body)], + workflowData: [this.helpers.returnJsonArray(req.body as IDataObject)], }; } } diff --git a/packages/nodes-base/nodes/Medium/GenericFunctions.ts b/packages/nodes-base/nodes/Medium/GenericFunctions.ts index 89058098b7..9fff315afc 100644 --- a/packages/nodes-base/nodes/Medium/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Medium/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function mediumApiRequest( @@ -45,6 +45,6 @@ export async function mediumApiRequest( return await this.helpers.requestOAuth2.call(this, 'mediumOAuth2Api', options); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/MessageBird/GenericFunctions.ts b/packages/nodes-base/nodes/MessageBird/GenericFunctions.ts index 5e6cd3c757..f09bb3d9d6 100644 --- a/packages/nodes-base/nodes/MessageBird/GenericFunctions.ts +++ b/packages/nodes-base/nodes/MessageBird/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; /** @@ -35,6 +35,6 @@ export async function messageBirdApiRequest( } return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Microsoft/Dynamics/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Dynamics/GenericFunctions.ts index 8029580ea8..cf1ad138a7 100644 --- a/packages/nodes-base/nodes/Microsoft/Dynamics/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Dynamics/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject, INodeProperties, INodePropertyOptions } from 'n8n-workflow'; +import type { IDataObject, INodeProperties, INodePropertyOptions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function microsoftApiRequest( @@ -42,7 +42,7 @@ export async function microsoftApiRequest( property: 'id_token', }); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -64,7 +64,7 @@ export async function microsoftApiRequestAllItems( do { responseData = await microsoftApiRequest.call(this, method, endpoint, body, query, uri); uri = responseData['@odata.nextLink']; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData['@odata.nextLink'] !== undefined); return returnData; diff --git a/packages/nodes-base/nodes/Microsoft/Dynamics/MicrosoftDynamicsCrm.node.ts b/packages/nodes-base/nodes/Microsoft/Dynamics/MicrosoftDynamicsCrm.node.ts index f58a6360ce..07a59c8a08 100644 --- a/packages/nodes-base/nodes/Microsoft/Dynamics/MicrosoftDynamicsCrm.node.ts +++ b/packages/nodes-base/nodes/Microsoft/Dynamics/MicrosoftDynamicsCrm.node.ts @@ -276,7 +276,7 @@ export class MicrosoftDynamicsCrm implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Microsoft/Excel/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Excel/GenericFunctions.ts index b30ff95c9c..707035b716 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function microsoftApiRequest( @@ -30,7 +30,7 @@ export async function microsoftApiRequest( //@ts-ignore return await this.helpers.requestOAuth2.call(this, 'microsoftExcelOAuth2Api', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -55,7 +55,7 @@ export async function microsoftApiRequestAllItems( if (uri?.includes('$top')) { delete query.$top; } - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData['@odata.nextLink'] !== undefined); return returnData; @@ -79,7 +79,7 @@ export async function microsoftApiRequestAllItemsSkip( do { responseData = await microsoftApiRequest.call(this, method, endpoint, body, query); query.$skip += query.$top; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.value.length !== 0); return returnData; diff --git a/packages/nodes-base/nodes/Microsoft/Excel/MicrosoftExcel.node.ts b/packages/nodes-base/nodes/Microsoft/Excel/MicrosoftExcel.node.ts index 554e973fc8..99d624ec87 100644 --- a/packages/nodes-base/nodes/Microsoft/Excel/MicrosoftExcel.node.ts +++ b/packages/nodes-base/nodes/Microsoft/Excel/MicrosoftExcel.node.ts @@ -7,6 +7,7 @@ import type { INodePropertyOptions, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -235,7 +236,7 @@ export class MicrosoftExcel implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: 0 } }, ); @@ -296,7 +297,7 @@ export class MicrosoftExcel implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -432,7 +433,7 @@ export class MicrosoftExcel implements INodeType { columns = columns.map((column: IDataObject) => column.name); if (!columns.includes(lookupColumn)) { - throw new NodeApiError(this.getNode(), responseData, { + throw new NodeApiError(this.getNode(), responseData as JsonObject, { message: `Column ${lookupColumn} does not exist on the table selected`, }); } @@ -555,7 +556,7 @@ export class MicrosoftExcel implements INodeType { returnData.push(...executionData); } else if (responseData !== undefined) { const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); @@ -632,7 +633,7 @@ export class MicrosoftExcel implements INodeType { const keyRow = this.getNodeParameter('keyRow', i) as number; const dataStartRow = this.getNodeParameter('dataStartRow', i) as number; if (responseData.values === null) { - throw new NodeApiError(this.getNode(), responseData, { + throw new NodeApiError(this.getNode(), responseData as JsonObject, { message: 'Range did not return data', }); } diff --git a/packages/nodes-base/nodes/Microsoft/GraphSecurity/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/GraphSecurity/GenericFunctions.ts index 487ace6327..b3efc2004c 100644 --- a/packages/nodes-base/nodes/Microsoft/GraphSecurity/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/GraphSecurity/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { IExecuteFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; import type { OptionsWithUri } from 'request'; @@ -50,7 +50,7 @@ export async function msGraphSecurityApiRequest( const nestedMessage = error?.error?.error?.message; if (nestedMessage.startsWith('{"')) { - error = JSON.parse(nestedMessage); + error = JSON.parse(nestedMessage as string); } if (nestedMessage.startsWith('Http request failed with statusCode=BadRequest')) { @@ -58,16 +58,16 @@ export async function msGraphSecurityApiRequest( } else if (nestedMessage.startsWith('Http request failed with')) { const stringified = nestedMessage.split(': ').pop(); if (stringified) { - error = JSON.parse(stringified); + error = JSON.parse(stringified as string); } } - if (['Invalid filter clause', 'Invalid ODATA query filter'].includes(nestedMessage)) { + if (['Invalid filter clause', 'Invalid ODATA query filter'].includes(nestedMessage as string)) { error.error.error.message += ' - Please check that your query parameter syntax is correct: https://docs.microsoft.com/en-us/graph/query-parameters#filter-parameter'; } - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Microsoft/GraphSecurity/MicrosoftGraphSecurity.node.ts b/packages/nodes-base/nodes/Microsoft/GraphSecurity/MicrosoftGraphSecurity.node.ts index 87b3f5a268..c99cdb7e02 100644 --- a/packages/nodes-base/nodes/Microsoft/GraphSecurity/MicrosoftGraphSecurity.node.ts +++ b/packages/nodes-base/nodes/Microsoft/GraphSecurity/MicrosoftGraphSecurity.node.ts @@ -224,8 +224,8 @@ export class MicrosoftGraphSecurity implements INodeType { } Array.isArray(responseData) - ? returnData.push(...responseData) - : returnData.push(responseData); + ? returnData.push(...(responseData as IDataObject[])) + : returnData.push(responseData as IDataObject); } return [this.helpers.returnJsonArray(returnData)]; diff --git a/packages/nodes-base/nodes/Microsoft/OneDrive/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/OneDrive/GenericFunctions.ts index 423397ad66..8844245db3 100644 --- a/packages/nodes-base/nodes/Microsoft/OneDrive/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/OneDrive/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function microsoftApiRequest( @@ -33,13 +33,13 @@ export async function microsoftApiRequest( if (Object.keys(qs).length === 0) { delete options.qs; } - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } //@ts-ignore return await this.helpers.requestOAuth2.call(this, 'microsoftOneDriveOAuth2Api', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -64,7 +64,7 @@ export async function microsoftApiRequestAllItems( if (uri?.includes('$top')) { delete query.$top; } - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData['@odata.nextLink'] !== undefined); return returnData; @@ -88,7 +88,7 @@ export async function microsoftApiRequestAllItemsSkip( do { responseData = await microsoftApiRequest.call(this, method, endpoint, body, query); query.$skip += query.$top; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.value.length !== 0); return returnData; diff --git a/packages/nodes-base/nodes/Microsoft/OneDrive/MicrosoftOneDrive.node.ts b/packages/nodes-base/nodes/Microsoft/OneDrive/MicrosoftOneDrive.node.ts index dfd3d53858..c35b2dfc36 100644 --- a/packages/nodes-base/nodes/Microsoft/OneDrive/MicrosoftOneDrive.node.ts +++ b/packages/nodes-base/nodes/Microsoft/OneDrive/MicrosoftOneDrive.node.ts @@ -6,6 +6,7 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -109,7 +110,7 @@ export class MicrosoftOneDrive implements INodeType { const fileName = responseData.name; if (responseData.file === undefined) { - throw new NodeApiError(this.getNode(), responseData, { + throw new NodeApiError(this.getNode(), responseData as JsonObject, { message: 'The ID you provided does not belong to a file.', }); } @@ -148,11 +149,11 @@ export class MicrosoftOneDrive implements INodeType { items[i] = newItem; - const data = Buffer.from(responseData.body); + const data = Buffer.from(responseData.body as Buffer); items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData( data as unknown as Buffer, - fileName, + fileName as string, mimeType, ); } @@ -234,7 +235,7 @@ export class MicrosoftOneDrive implements INodeType { {}, ); - responseData = JSON.parse(responseData); + responseData = JSON.parse(responseData as string); } else { const body = this.getNodeParameter('fileContent', i) as string; if (fileName === '') { @@ -356,7 +357,7 @@ export class MicrosoftOneDrive implements INodeType { throw error; } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Microsoft/Outlook/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Outlook/GenericFunctions.ts index 4784cd6f3c..a8c8ace503 100644 --- a/packages/nodes-base/nodes/Microsoft/Outlook/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Outlook/GenericFunctions.ts @@ -3,7 +3,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; import { BINARY_ENCODING } from 'n8n-core'; -import type { IDataObject, INodeExecutionData } from 'n8n-workflow'; +import type { IDataObject, INodeExecutionData, JsonObject } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; export async function microsoftApiRequest( @@ -41,14 +41,13 @@ export async function microsoftApiRequest( options.headers = Object.assign({}, options.headers, headers); } - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } - //@ts-ignore return await this.helpers.requestOAuth2.call(this, 'microsoftOutlookOAuth2Api', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -79,7 +78,7 @@ export async function microsoftApiRequestAllItems( headers, ); uri = responseData['@odata.nextLink']; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData['@odata.nextLink'] !== undefined); return returnData; @@ -112,7 +111,7 @@ export async function microsoftApiRequestAllItemsSkip( headers, ); query.$skip += query.$top; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.value.length !== 0); return returnData; @@ -208,8 +207,8 @@ export async function downloadAttachments( const data = Buffer.from(response.body as string, 'utf8'); element.binary![`${prefix}${index}`] = await this.helpers.prepareBinaryData( data as unknown as Buffer, - attachment.name, - attachment.contentType, + attachment.name as string, + attachment.contentType as string, ); } } diff --git a/packages/nodes-base/nodes/Microsoft/Outlook/MicrosoftOutlook.node.ts b/packages/nodes-base/nodes/Microsoft/Outlook/MicrosoftOutlook.node.ts index 95c180cb79..c083dc1544 100644 --- a/packages/nodes-base/nodes/Microsoft/Outlook/MicrosoftOutlook.node.ts +++ b/packages/nodes-base/nodes/Microsoft/Outlook/MicrosoftOutlook.node.ts @@ -8,6 +8,7 @@ import type { INodePropertyOptions, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -188,7 +189,11 @@ export class MicrosoftOutlook implements INodeType { if (additionalFields.dataPropertyAttachmentsPrefixName) { const prefix = additionalFields.dataPropertyAttachmentsPrefixName as string; - const data = await downloadAttachments.call(this, responseData, prefix); + const data = await downloadAttachments.call( + this, + responseData as IDataObject, + prefix, + ); const executionData = this.helpers.constructExecutionMetaData( this.helpers.returnJsonArray(data), { itemData: { item: i } }, @@ -196,7 +201,7 @@ export class MicrosoftOutlook implements INodeType { returnData.push(...executionData); } else { const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -237,7 +242,7 @@ export class MicrosoftOutlook implements INodeType { {}, ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -284,7 +289,7 @@ export class MicrosoftOutlook implements INodeType { responseData = await microsoftApiRequest.call(this, 'POST', '/messages', body, {}); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -397,7 +402,7 @@ export class MicrosoftOutlook implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -501,7 +506,11 @@ export class MicrosoftOutlook implements INodeType { if (additionalFields.dataPropertyAttachmentsPrefixName) { const prefix = additionalFields.dataPropertyAttachmentsPrefixName as string; - const data = await downloadAttachments.call(this, responseData, prefix); + const data = await downloadAttachments.call( + this, + responseData as IDataObject, + prefix, + ); const executionData = this.helpers.constructExecutionMetaData( this.helpers.returnJsonArray(data), { itemData: { item: i } }, @@ -509,7 +518,7 @@ export class MicrosoftOutlook implements INodeType { returnData.push(...executionData); } else { const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -684,7 +693,7 @@ export class MicrosoftOutlook implements INodeType { const uploadUrl = responseData.uploadUrl; if (uploadUrl === undefined) { - throw new NodeApiError(this.getNode(), responseData, { + throw new NodeApiError(this.getNode(), responseData as JsonObject, { message: 'Failed to get upload session', }); } @@ -793,7 +802,7 @@ export class MicrosoftOutlook implements INodeType { const data = Buffer.from(response.body as string, 'utf8'); items[i].binary![dataPropertyNameDownload] = await this.helpers.prepareBinaryData( data as unknown as Buffer, - fileName, + fileName as string, mimeType, ); } catch (error) { @@ -827,7 +836,7 @@ export class MicrosoftOutlook implements INodeType { qs, ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -878,7 +887,7 @@ export class MicrosoftOutlook implements INodeType { responseData = responseData.value; } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -924,7 +933,7 @@ export class MicrosoftOutlook implements INodeType { responseData = await microsoftApiRequest.call(this, 'POST', endpoint, body); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -991,7 +1000,7 @@ export class MicrosoftOutlook implements INodeType { qs, ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -1038,7 +1047,7 @@ export class MicrosoftOutlook implements INodeType { responseData = responseData.value; } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -1091,7 +1100,7 @@ export class MicrosoftOutlook implements INodeType { responseData = responseData.value; } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -1126,7 +1135,7 @@ export class MicrosoftOutlook implements INodeType { body, ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -1176,7 +1185,7 @@ export class MicrosoftOutlook implements INodeType { responseData = responseData.value; } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Microsoft/Sql/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Sql/GenericFunctions.ts index 6a7360d201..1b8e532254 100644 --- a/packages/nodes-base/nodes/Microsoft/Sql/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Sql/GenericFunctions.ts @@ -88,7 +88,7 @@ export async function executeQueryQueue( * @param {IDataObject} item The item to extract */ export function extractValues(item: IDataObject): string { - return `(${Object.values(item as any) + return `(${Object.values(item) .map((val) => { //the column cannot be found in the input //so, set it to null in the sql query diff --git a/packages/nodes-base/nodes/Microsoft/Sql/MicrosoftSql.node.ts b/packages/nodes-base/nodes/Microsoft/Sql/MicrosoftSql.node.ts index 30b913473f..7593797f06 100644 --- a/packages/nodes-base/nodes/Microsoft/Sql/MicrosoftSql.node.ts +++ b/packages/nodes-base/nodes/Microsoft/Sql/MicrosoftSql.node.ts @@ -395,7 +395,7 @@ export class MicrosoftSql implements INodeType { .request() .query( `DELETE FROM ${table} WHERE "${deleteKey}" IN ${extractDeleteValues( - deleteValues, + deleteValues as IDataObject[], deleteKey, )};`, ); diff --git a/packages/nodes-base/nodes/Microsoft/Teams/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/Teams/GenericFunctions.ts index abfe976f18..79f692281b 100644 --- a/packages/nodes-base/nodes/Microsoft/Teams/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/Teams/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function microsoftApiRequest( @@ -32,7 +32,7 @@ export async function microsoftApiRequest( //@ts-ignore return await this.helpers.requestOAuth2.call(this, 'microsoftTeamsOAuth2Api', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -53,7 +53,7 @@ export async function microsoftApiRequestAllItems( do { responseData = await microsoftApiRequest.call(this, method, endpoint, body, query, uri); uri = responseData['@odata.nextLink']; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); if (query.limit && query.limit <= returnData.length) { return returnData; } @@ -80,7 +80,7 @@ export async function microsoftApiRequestAllItemsSkip( do { responseData = await microsoftApiRequest.call(this, method, endpoint, body, query); query.$skip += query.$top; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.value.length !== 0); return returnData; diff --git a/packages/nodes-base/nodes/Microsoft/Teams/MicrosoftTeams.node.ts b/packages/nodes-base/nodes/Microsoft/Teams/MicrosoftTeams.node.ts index 87778897c2..18bcaf6fd3 100644 --- a/packages/nodes-base/nodes/Microsoft/Teams/MicrosoftTeams.node.ts +++ b/packages/nodes-base/nodes/Microsoft/Teams/MicrosoftTeams.node.ts @@ -220,7 +220,7 @@ export class MicrosoftTeams implements INodeType { 'GET', `/v1.0/planner/plans/${planId}/details`, ); - for (const key of Object.keys(categoryDescriptions)) { + for (const key of Object.keys(categoryDescriptions as IDataObject)) { if (categoryDescriptions[key] !== null) { returnData.push({ name: categoryDescriptions[key], @@ -629,7 +629,7 @@ export class MicrosoftTeams implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Microsoft/ToDo/GenericFunctions.ts b/packages/nodes-base/nodes/Microsoft/ToDo/GenericFunctions.ts index 65aedc8e18..940b626c1e 100644 --- a/packages/nodes-base/nodes/Microsoft/ToDo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Microsoft/ToDo/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions } from 'n8n-core'; -import type { IDataObject, ILoadOptionsFunctions } from 'n8n-workflow'; +import type { IDataObject, ILoadOptionsFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function microsoftApiRequest( @@ -35,7 +35,7 @@ export async function microsoftApiRequest( //@ts-ignore return await this.helpers.requestOAuth2.call(this, 'microsoftToDoOAuth2Api', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -59,7 +59,7 @@ export async function microsoftApiRequestAllItems( if (uri?.includes('$top')) { delete query.$top; } - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData['@odata.nextLink'] !== undefined); return returnData; @@ -82,7 +82,7 @@ export async function microsoftApiRequestAllItemsSkip( do { responseData = await microsoftApiRequest.call(this, method, endpoint, body, query); query.$skip += query.$top; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.value.length !== 0); return returnData; diff --git a/packages/nodes-base/nodes/Microsoft/ToDo/MicrosoftToDo.node.ts b/packages/nodes-base/nodes/Microsoft/ToDo/MicrosoftToDo.node.ts index 1cf43bb811..256929753e 100644 --- a/packages/nodes-base/nodes/Microsoft/ToDo/MicrosoftToDo.node.ts +++ b/packages/nodes-base/nodes/Microsoft/ToDo/MicrosoftToDo.node.ts @@ -410,7 +410,7 @@ export class MicrosoftToDo implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Mindee/GenericFunctions.ts b/packages/nodes-base/nodes/Mindee/GenericFunctions.ts index 571a883548..3c095c4115 100644 --- a/packages/nodes-base/nodes/Mindee/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Mindee/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function mindeeApiRequest( @@ -39,7 +39,7 @@ export async function mindeeApiRequest( json: true, }; try { - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } if (Object.keys(qs).length === 0) { @@ -51,7 +51,7 @@ export async function mindeeApiRequest( return await this.helpers.requestWithAuthentication.call(this, service, options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Mindee/Mindee.node.ts b/packages/nodes-base/nodes/Mindee/Mindee.node.ts index 72cc1fbc40..30db7901f4 100644 --- a/packages/nodes-base/nodes/Mindee/Mindee.node.ts +++ b/packages/nodes-base/nodes/Mindee/Mindee.node.ts @@ -221,9 +221,11 @@ export class Mindee implements INodeType { } if (!rawData) { if (version === 1) { - responseData = cleanDataPreviousApiVersions(responseData.predictions); + responseData = cleanDataPreviousApiVersions( + responseData.predictions as IDataObject[], + ); } else if (version === 3) { - responseData = cleanData(responseData.document); + responseData = cleanData(responseData.document as IDataObject); } } } @@ -295,9 +297,11 @@ export class Mindee implements INodeType { } if (!rawData) { if (version === 1) { - responseData = cleanDataPreviousApiVersions(responseData.predictions); + responseData = cleanDataPreviousApiVersions( + responseData.predictions as IDataObject[], + ); } else if (version === 3) { - responseData = cleanData(responseData.document); + responseData = cleanData(responseData.document as IDataObject); } } } diff --git a/packages/nodes-base/nodes/Misp/GenericFunctions.ts b/packages/nodes-base/nodes/Misp/GenericFunctions.ts index c4508d10b8..5c79b7f5a4 100644 --- a/packages/nodes-base/nodes/Misp/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Misp/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { IExecuteFunctions } from 'n8n-core'; -import type { IDataObject, ILoadOptionsFunctions } from 'n8n-workflow'; +import type { IDataObject, ILoadOptionsFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; import type { OptionsWithUri } from 'request'; @@ -51,7 +51,7 @@ export async function mispApiRequest( const errors = error?.error?.errors; if (errors) { - const key = Object.keys(errors)[0]; + const key = Object.keys(errors as IDataObject)[0]; if (key !== undefined) { let message = errors[key].join(); @@ -64,7 +64,7 @@ export async function mispApiRequest( } } - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Misp/Misp.node.ts b/packages/nodes-base/nodes/Misp/Misp.node.ts index 7231ab65f0..73f6a3cdcc 100644 --- a/packages/nodes-base/nodes/Misp/Misp.node.ts +++ b/packages/nodes-base/nodes/Misp/Misp.node.ts @@ -747,7 +747,7 @@ export class Misp implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/MondayCom/GenericFunctions.ts b/packages/nodes-base/nodes/MondayCom/GenericFunctions.ts index c261a355ba..86ef8348fe 100644 --- a/packages/nodes-base/nodes/MondayCom/GenericFunctions.ts +++ b/packages/nodes-base/nodes/MondayCom/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject, IHookFunctions, IWebhookFunctions } from 'n8n-workflow'; +import type { IDataObject, IHookFunctions, IWebhookFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import get from 'lodash.get'; @@ -38,7 +38,7 @@ export async function mondayComApiRequest( return await this.helpers.requestOAuth2.call(this, 'mondayComOAuth2Api', options); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -56,7 +56,7 @@ export async function mondayComApiRequestAllItems( do { responseData = await mondayComApiRequest.call(this, body); - returnData.push.apply(returnData, get(responseData, propertyName)); + returnData.push.apply(returnData, get(responseData, propertyName) as IDataObject[]); body.variables.page++; } while (get(responseData, propertyName).length > 0); return returnData; diff --git a/packages/nodes-base/nodes/MondayCom/MondayCom.node.ts b/packages/nodes-base/nodes/MondayCom/MondayCom.node.ts index 760577fa57..cd297ae78c 100644 --- a/packages/nodes-base/nodes/MondayCom/MondayCom.node.ts +++ b/packages/nodes-base/nodes/MondayCom/MondayCom.node.ts @@ -728,7 +728,7 @@ export class MondayCom implements INodeType { } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/MongoDb/MongoDb.node.ts b/packages/nodes-base/nodes/MongoDb/MongoDb.node.ts index 78237edb2e..96d1e9f911 100644 --- a/packages/nodes-base/nodes/MongoDb/MongoDb.node.ts +++ b/packages/nodes-base/nodes/MongoDb/MongoDb.node.ts @@ -21,7 +21,12 @@ import { validateAndResolveMongoCredentials, } from './GenericFunctions'; -import type { FindOneAndReplaceOptions, FindOneAndUpdateOptions, UpdateOptions } from 'mongodb'; +import type { + FindOneAndReplaceOptions, + FindOneAndUpdateOptions, + UpdateOptions, + Sort, +} from 'mongodb'; import { MongoClient, ObjectId } from 'mongodb'; import type { IMongoParametricCredentials } from './mongoDb.types'; @@ -97,12 +102,12 @@ export class MongoDb implements INodeType { const queryParameter = JSON.parse(this.getNodeParameter('query', 0) as string); if (queryParameter._id && typeof queryParameter._id === 'string') { - queryParameter._id = new ObjectId(queryParameter._id); + queryParameter._id = new ObjectId(queryParameter._id as string); } const query = mdb .collection(this.getNodeParameter('collection', 0) as string) - .aggregate(queryParameter); + .aggregate(queryParameter as Document[]); responseData = await query.toArray(); } catch (error) { @@ -120,7 +125,7 @@ export class MongoDb implements INodeType { try { const { deletedCount } = await mdb .collection(this.getNodeParameter('collection', 0) as string) - .deleteMany(JSON.parse(this.getNodeParameter('query', 0) as string)); + .deleteMany(JSON.parse(this.getNodeParameter('query', 0) as string) as Document); responseData = [{ deletedCount }]; } catch (error) { @@ -139,17 +144,17 @@ export class MongoDb implements INodeType { const queryParameter = JSON.parse(this.getNodeParameter('query', 0) as string); if (queryParameter._id && typeof queryParameter._id === 'string') { - queryParameter._id = new ObjectId(queryParameter._id); + queryParameter._id = new ObjectId(queryParameter._id as string); } let query = mdb .collection(this.getNodeParameter('collection', 0) as string) - .find(queryParameter); + .find(queryParameter as Document); const options = this.getNodeParameter('options', 0); const limit = options.limit as number; const skip = options.skip as number; - const sort = options.sort && JSON.parse(options.sort as string); + const sort: Sort = options.sort && JSON.parse(options.sort as string); if (skip > 0) { query = query.skip(skip); } diff --git a/packages/nodes-base/nodes/MonicaCrm/GenericFunctions.ts b/packages/nodes-base/nodes/MonicaCrm/GenericFunctions.ts index 8c7ca01ebd..8693602db7 100644 --- a/packages/nodes-base/nodes/MonicaCrm/GenericFunctions.ts +++ b/packages/nodes-base/nodes/MonicaCrm/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { IExecuteFunctions } from 'n8n-core'; -import type { IDataObject, ILoadOptionsFunctions } from 'n8n-workflow'; +import type { IDataObject, ILoadOptionsFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; import type { OptionsWithUri } from 'request'; @@ -52,7 +52,7 @@ export async function monicaCrmApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -76,7 +76,7 @@ export async function monicaCrmApiRequestAllItems( do { responseData = await monicaCrmApiRequest.call(this, method, endpoint, body, qs); - returnData.push(...responseData.data); + returnData.push(...(responseData.data as IDataObject[])); if (!forLoader && !returnAll && returnData.length > limit) { return returnData.slice(0, limit); diff --git a/packages/nodes-base/nodes/MonicaCrm/MonicaCrm.node.ts b/packages/nodes-base/nodes/MonicaCrm/MonicaCrm.node.ts index 8885aa52a5..df5d5899d1 100644 --- a/packages/nodes-base/nodes/MonicaCrm/MonicaCrm.node.ts +++ b/packages/nodes-base/nodes/MonicaCrm/MonicaCrm.node.ts @@ -1166,7 +1166,7 @@ export class MonicaCrm implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/MoveBinaryData/MoveBinaryData.node.ts b/packages/nodes-base/nodes/MoveBinaryData/MoveBinaryData.node.ts index 962222c5ca..eceb14fee7 100644 --- a/packages/nodes-base/nodes/MoveBinaryData/MoveBinaryData.node.ts +++ b/packages/nodes-base/nodes/MoveBinaryData/MoveBinaryData.node.ts @@ -23,7 +23,7 @@ iconv.encodingExists('utf8'); const bomAware: string[] = []; const encodeDecodeOptions: INodePropertyOptions[] = []; const encodings = (iconv as any).encodings; -Object.keys(encodings).forEach((encoding) => { +Object.keys(encodings as IDataObject).forEach((encoding) => { if (!(encoding.startsWith('_') || typeof encodings[encoding] === 'string')) { // only encodings without direct alias or internals if (encodings[encoding].bomAware) { diff --git a/packages/nodes-base/nodes/Msg91/GenericFunctions.ts b/packages/nodes-base/nodes/Msg91/GenericFunctions.ts index 34a5992a38..f13a91da9f 100644 --- a/packages/nodes-base/nodes/Msg91/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Msg91/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; /** @@ -33,6 +33,6 @@ export async function msg91ApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/MySql/MySql.node.ts b/packages/nodes-base/nodes/MySql/MySql.node.ts index 0182a83af1..de4a90dff4 100644 --- a/packages/nodes-base/nodes/MySql/MySql.node.ts +++ b/packages/nodes-base/nodes/MySql/MySql.node.ts @@ -336,7 +336,8 @@ export class MySql implements INodeType { .map((_item) => insertPlaceholder) .join(',')};`; const queryItems = insertItems.reduce( - (collection, item) => collection.concat(Object.values(item as any)), + (collection: IDataObject[], item) => + collection.concat(Object.values(item) as IDataObject[]), [], ); diff --git a/packages/nodes-base/nodes/N8n/GenericFunctions.ts b/packages/nodes-base/nodes/N8n/GenericFunctions.ts index 48f628f064..585030ef46 100644 --- a/packages/nodes-base/nodes/N8n/GenericFunctions.ts +++ b/packages/nodes-base/nodes/N8n/GenericFunctions.ts @@ -69,7 +69,7 @@ export async function apiRequestAllItems( query.cursor = nextCursor; query.limit = 100; responseData = await apiRequest.call(this, method, endpoint, body, query); - returnData.push.apply(returnData, responseData.data); + returnData.push.apply(returnData, responseData.data as IDataObject[]); nextCursor = responseData.nextCursor as string | undefined; } while (nextCursor); return returnData; diff --git a/packages/nodes-base/nodes/Nasa/GenericFunctions.ts b/packages/nodes-base/nodes/Nasa/GenericFunctions.ts index 5d8f3b0ad5..ee90e60652 100644 --- a/packages/nodes-base/nodes/Nasa/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Nasa/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function nasaApiRequest( @@ -31,7 +31,7 @@ export async function nasaApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -53,7 +53,7 @@ export async function nasaApiRequestAllItems( do { responseData = await nasaApiRequest.call(this, method, resource, query, {}, uri); uri = responseData.links.next; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.links.next !== undefined); return returnData; diff --git a/packages/nodes-base/nodes/Nasa/Nasa.node.ts b/packages/nodes-base/nodes/Nasa/Nasa.node.ts index 09cfb1004f..4f9a01a685 100644 --- a/packages/nodes-base/nodes/Nasa/Nasa.node.ts +++ b/packages/nodes-base/nodes/Nasa/Nasa.node.ts @@ -1045,7 +1045,7 @@ export class Nasa implements INodeType { } if (resource === 'asteroidNeoFeed') { - const date = Object.keys(responseData)[0]; + const date = Object.keys(responseData as IDataObject)[0]; responseData = responseData[date]; } @@ -1065,7 +1065,7 @@ export class Nasa implements INodeType { items[i] = newItem; - items[i].binary![binaryProperty] = await this.helpers.prepareBinaryData(data); + items[i].binary![binaryProperty] = await this.helpers.prepareBinaryData(data as Buffer); } if (resource === 'astronomyPictureOfTheDay') { @@ -1080,7 +1080,7 @@ export class Nasa implements INodeType { endpoint, qs, { encoding: null }, - responseData.hdurl, + responseData.hdurl as string, ); const filename = (responseData.hdurl as string).split('/'); @@ -1099,14 +1099,14 @@ export class Nasa implements INodeType { items[i] = newItem; items[i].binary![binaryProperty] = await this.helpers.prepareBinaryData( - data, + data as Buffer, filename[filename.length - 1], ); } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Netlify/GenericFunctions.ts b/packages/nodes-base/nodes/Netlify/GenericFunctions.ts index 109429d57a..580b68d688 100644 --- a/packages/nodes-base/nodes/Netlify/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Netlify/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function netlifyApiRequest( @@ -31,7 +31,7 @@ export async function netlifyApiRequest( json: true, }; - if (!Object.keys(body).length) { + if (!Object.keys(body as IDataObject).length) { delete options.body; } @@ -46,7 +46,7 @@ export async function netlifyApiRequest( return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -69,7 +69,7 @@ export async function netlifyRequestAllItems( resolveWithFullResponse: true, }); query.page++; - returnData.push.apply(returnData, responseData.body); + returnData.push.apply(returnData, responseData.body as IDataObject[]); } while (responseData.headers.link.includes('next')); return returnData; diff --git a/packages/nodes-base/nodes/Netlify/Netlify.node.ts b/packages/nodes-base/nodes/Netlify/Netlify.node.ts index c0d7669159..6f48029e64 100644 --- a/packages/nodes-base/nodes/Netlify/Netlify.node.ts +++ b/packages/nodes-base/nodes/Netlify/Netlify.node.ts @@ -189,7 +189,7 @@ export class Netlify implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Netlify/NetlifyTrigger.node.ts b/packages/nodes-base/nodes/Netlify/NetlifyTrigger.node.ts index 16b8a36247..af54927fa9 100644 --- a/packages/nodes-base/nodes/Netlify/NetlifyTrigger.node.ts +++ b/packages/nodes-base/nodes/Netlify/NetlifyTrigger.node.ts @@ -112,7 +112,6 @@ export class NetlifyTrigger implements INodeType { ], }; - // @ts-ignore webhookMethods = { default: { async checkExists(this: IHookFunctions): Promise { @@ -207,7 +206,7 @@ export class NetlifyTrigger implements INodeType { } return { - workflowData: [this.helpers.returnJsonArray(response)], + workflowData: [this.helpers.returnJsonArray(response as IDataObject)], }; } } diff --git a/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts b/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts index 69fba75c92..25d1dd13a4 100644 --- a/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts +++ b/packages/nodes-base/nodes/NextCloud/NextCloud.node.ts @@ -6,6 +6,7 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -1146,20 +1147,23 @@ export class NextCloud implements INodeType { const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i); items[i].binary![binaryPropertyName] = await this.helpers.prepareBinaryData( - responseData, + responseData as Buffer, endpoint, ); } else if (['file', 'folder'].includes(resource) && operation === 'share') { // eslint-disable-next-line @typescript-eslint/no-loop-func const jsonResponseData: IDataObject = await new Promise((resolve, reject) => { - parseString(responseData, { explicitArray: false }, (err, data) => { + parseString(responseData as string, { explicitArray: false }, (err, data) => { if (err) { return reject(err); } if (data.ocs.meta.status !== 'ok') { return reject( - new NodeApiError(this.getNode(), data.ocs.meta.message || data.ocs.meta.status), + new NodeApiError( + this.getNode(), + (data.ocs.meta.message as JsonObject) || (data.ocs.meta.status as JsonObject), + ), ); } @@ -1172,14 +1176,17 @@ export class NextCloud implements INodeType { if (operation !== 'getAll') { // eslint-disable-next-line @typescript-eslint/no-loop-func const jsonResponseData: IDataObject = await new Promise((resolve, reject) => { - parseString(responseData, { explicitArray: false }, (err, data) => { + parseString(responseData as string, { explicitArray: false }, (err, data) => { if (err) { return reject(err); } if (data.ocs.meta.status !== 'ok') { return reject( - new NodeApiError(this.getNode(), data.ocs.meta.message || data.ocs.meta.status), + new NodeApiError( + this.getNode(), + (data.ocs.meta.message || data.ocs.meta.status) as JsonObject, + ), ); } @@ -1195,13 +1202,15 @@ export class NextCloud implements INodeType { } else { // eslint-disable-next-line @typescript-eslint/no-loop-func const jsonResponseData: IDataObject[] = await new Promise((resolve, reject) => { - parseString(responseData, { explicitArray: false }, (err, data) => { + parseString(responseData as string, { explicitArray: false }, (err, data) => { if (err) { return reject(err); } if (data.ocs.meta.status !== 'ok') { - return reject(new NodeApiError(this.getNode(), data.ocs.meta.message)); + return reject( + new NodeApiError(this.getNode(), data.ocs.meta.message as JsonObject), + ); } if (typeof data.ocs.data.users.element === 'string') { @@ -1219,7 +1228,7 @@ export class NextCloud implements INodeType { } else if (resource === 'folder' && operation === 'list') { // eslint-disable-next-line @typescript-eslint/no-loop-func const jsonResponseData: IDataObject = await new Promise((resolve, reject) => { - parseString(responseData, { explicitArray: false }, (err, data) => { + parseString(responseData as string, { explicitArray: false }, (err, data) => { if (err) { return reject(err); } diff --git a/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts b/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts index 25f3d33c0e..53bdf653ca 100644 --- a/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts +++ b/packages/nodes-base/nodes/NocoDB/GenericFunctions.ts @@ -82,7 +82,9 @@ export async function apiRequestAllItems( do { responseData = await apiRequest.call(this, method, endpoint, body, query); - version === 1 ? returnData.push(...responseData) : returnData.push(...responseData.list); + version === 1 + ? returnData.push(...(responseData as IDataObject[])) + : returnData.push(...(responseData.list as IDataObject[])); query.offset += query.limit; } while (version === 1 ? responseData.length !== 0 : responseData.pageInfo.isLastPage !== true); @@ -105,7 +107,7 @@ export async function downloadRecordAttachments( for (const [index, attachment] of jsonParse( record[fieldName] as string, ).entries()) { - const file = await apiRequest.call(this, 'GET', '', {}, {}, attachment.url, { + const file: Buffer = await apiRequest.call(this, 'GET', '', {}, {}, attachment.url, { json: false, encoding: null, }); diff --git a/packages/nodes-base/nodes/NocoDB/NocoDB.node.ts b/packages/nodes-base/nodes/NocoDB/NocoDB.node.ts index bffbefd557..24c7ccaa09 100644 --- a/packages/nodes-base/nodes/NocoDB/NocoDB.node.ts +++ b/packages/nodes-base/nodes/NocoDB/NocoDB.node.ts @@ -7,6 +7,7 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -334,7 +335,7 @@ export class NocoDB implements INodeType { if (this.continueOnFail()) { returnData.push({ error: error.toString() }); } - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -354,7 +355,13 @@ export class NocoDB implements INodeType { } try { - responseData = await apiRequest.call(this, requestMethod, endPoint, body, qs); + responseData = (await apiRequest.call( + this, + requestMethod, + endPoint, + body, + qs, + )) as number[]; if (version === 1) { returnData.push(...items.map((item) => item.json)); } else if (version === 2) { @@ -381,7 +388,7 @@ export class NocoDB implements INodeType { if (this.continueOnFail()) { returnData.push({ error: error.toString() }); } - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -426,7 +433,7 @@ export class NocoDB implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -437,7 +444,7 @@ export class NocoDB implements INodeType { ).split(','); const response = await downloadRecordAttachments.call( this, - responseData, + responseData as IDataObject[], downloadFieldNames, ); data.push(...response); @@ -475,7 +482,7 @@ export class NocoDB implements INodeType { responseData = await apiRequest.call(this, requestMethod, endPoint, {}, qs); if (version === 2) { - if (Object.keys(responseData).length === 0) { + if (Object.keys(responseData as IDataObject).length === 0) { // Get did fail const errorMessage = `The row with the ID "${id}" could not be queried. It probably doesn't exist.`; if (this.continueOnFail()) { @@ -498,7 +505,7 @@ export class NocoDB implements INodeType { ).split(','); const data = await downloadRecordAttachments.call( this, - [responseData], + [responseData as IDataObject], downloadFieldNames, ); const newItem = { @@ -514,7 +521,7 @@ export class NocoDB implements INodeType { newItems.push(...executionData); } else { const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); @@ -530,7 +537,7 @@ export class NocoDB implements INodeType { newItems.push(...executionData); continue; } - throw new NodeApiError(this.getNode(), error, { itemIndex: i }); + throw new NodeApiError(this.getNode(), error as JsonObject, { itemIndex: i }); } } return this.prepareOutputData(newItems); @@ -630,7 +637,13 @@ export class NocoDB implements INodeType { } try { - responseData = await apiRequest.call(this, requestMethod, endPoint, body, qs); + responseData = (await apiRequest.call( + this, + requestMethod, + endPoint, + body, + qs, + )) as number[]; if (version === 1) { returnData.push(...body); @@ -658,7 +671,7 @@ export class NocoDB implements INodeType { if (this.continueOnFail()) { returnData.push({ error: error.toString() }); } - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } } diff --git a/packages/nodes-base/nodes/Notion/GenericFunctions.ts b/packages/nodes-base/nodes/Notion/GenericFunctions.ts index 949c540e3b..08fbc3cd1f 100644 --- a/packages/nodes-base/nodes/Notion/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Notion/GenericFunctions.ts @@ -14,6 +14,7 @@ import type { INodeExecutionData, INodeProperties, IPollFunctions, + JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -72,7 +73,7 @@ export async function notionApiRequest( json: true, }; options = Object.assign({}, options, option); - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } if (!uri) { @@ -80,7 +81,7 @@ export async function notionApiRequest( } return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -107,7 +108,7 @@ export async function notionApiRequestAllItems( } else { body.start_cursor = next_cursor; } - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); if (query.limit && query.limit <= returnData.length) { return returnData; } @@ -192,23 +193,20 @@ function getLink(text: { textLink: string; isLink: boolean }) { return {}; } -function getTexts( - texts: [ - { - textType: string; - text: string; - isLink: boolean; - range: boolean; - textLink: string; - mentionType: string; - dateStart: string; - dateEnd: string; - date: string; - annotationUi: IDataObject; - expression: string; - }, - ], -) { +type TextData = { + textType: string; + text: string; + isLink: boolean; + range: boolean; + textLink: string; + mentionType: string; + dateStart: string; + dateEnd: string; + date: string; + annotationUi: IDataObject; + expression: string; +}; +function getTexts(texts: TextData[]) { const results = []; for (const text of texts) { if (text.textType === 'text') { @@ -261,7 +259,7 @@ function getTextBlocks(block: IDataObject) { text: block.richText === false ? formatText(block.textContent as string).text - : getTexts(((block.text as IDataObject).text as any) || []), + : getTexts(((block.text as IDataObject).text as TextData[]) || []), }; } @@ -305,7 +303,7 @@ function getPropertyKeyValue( if (value.richText === false) { result = { rich_text: [{ text: { content: value.textContent } }] }; } else { - result = { rich_text: getTexts(value.text.text) }; + result = { rich_text: getTexts(value.text.text as TextData[]) }; } break; case 'title': @@ -324,10 +322,10 @@ function getPropertyKeyValue( result = { type: 'relation', relation: value.relationValue - .filter((relation: any) => { + .filter((relation: IDataObject) => { return relation && typeof relation === 'string'; }) - .reduce((acc: [], cur: any) => { + .reduce((acc: string[], cur: string) => { return acc.concat(cur.split(',').map((relation: string) => relation.trim())); }, []) .filter((relation: string) => { @@ -384,21 +382,21 @@ function getPropertyKeyValue( }; break; case 'date': - const format = getDateFormat(value.includeTime); + const format = getDateFormat(value.includeTime as boolean); const timezoneValue = value.timezone === 'default' ? timezone : value.timezone; if (value.range === true) { result = { type: 'date', date: { - start: moment.tz(value.dateStart, timezoneValue).format(format), - end: moment.tz(value.dateEnd, timezoneValue).format(format), + start: moment.tz(value.dateStart as number, timezoneValue as string).format(format), + end: moment.tz(value.dateEnd as number, timezoneValue as string).format(format), }, }; } else { result = { type: 'date', date: { - start: moment.tz(value.date, timezoneValue).format(format), + start: moment.tz(value.date as number, timezoneValue as string).format(format), end: null, }, }; @@ -448,7 +446,13 @@ export function mapProperties( (property) => [ `${property.key.split('|')[0]}`, - getPropertyKeyValue.call(this, property, property.key.split('|')[1], timezone, version), + getPropertyKeyValue.call( + this, + property, + property.key.split('|')[1] as string, + timezone, + version, + ), ] as const, ) .filter(([, value]) => value) @@ -472,7 +476,7 @@ export function mapSorting(data: SortData[]) { export function mapFilters(filtersList: IDataObject[], timezone: string) { return filtersList.reduce((obj, value: { [key: string]: any }) => { - let key = getNameAndType(value.key).type; + let key = getNameAndType(value.key as string).type; let valuePropertyName = key === 'last_edited_time' ? value[camelCase(key)] : value[`${camelCase(key)}Value`]; @@ -500,16 +504,16 @@ export function mapFilters(filtersList: IDataObject[], timezone: string) { } if (value.type === 'formula') { - const vpropertyName = value[`${camelCase(value.returnType)}Value`]; + const vpropertyName = value[`${camelCase(value.returnType as string)}Value`]; return Object.assign(obj, { - ['property']: getNameAndType(value.key).name, + ['property']: getNameAndType(value.key as string).name, [key]: { [value.returnType]: { [`${value.condition}`]: vpropertyName } }, }); } return Object.assign(obj, { - ['property']: getNameAndType(value.key).name, + ['property']: getNameAndType(value.key as string).name, [key]: { [`${value.condition}`]: valuePropertyName }, }); }, {}); @@ -518,9 +522,9 @@ export function mapFilters(filtersList: IDataObject[], timezone: string) { function simplifyProperty(property: any) { let result: any; const type = (property as IDataObject).type as string; - if (['text'].includes(property.type)) { + if (['text'].includes(property.type as string)) { result = property.plain_text; - } else if (['rich_text', 'title'].includes(property.type)) { + } else if (['rich_text', 'title'].includes(property.type as string)) { if (Array.isArray(property[type]) && property[type].length !== 0) { result = property[type].map((text: any) => simplifyProperty(text) as string).join(''); } else { @@ -536,32 +540,32 @@ function simplifyProperty(property: any) { 'email', 'phone_number', 'date', - ].includes(property.type) + ].includes(property.type as string) ) { result = property[type]; - } else if (['created_by', 'last_edited_by', 'select'].includes(property.type)) { + } else if (['created_by', 'last_edited_by', 'select'].includes(property.type as string)) { result = property[type] ? property[type].name : null; - } else if (['people'].includes(property.type)) { + } else if (['people'].includes(property.type as string)) { if (Array.isArray(property[type])) { result = property[type].map((person: any) => person.person?.email || {}); } else { result = property[type]; } - } else if (['multi_select'].includes(property.type)) { + } else if (['multi_select'].includes(property.type as string)) { if (Array.isArray(property[type])) { result = property[type].map((e: IDataObject) => e.name || {}); } else { result = property[type].options.map((e: IDataObject) => e.name || {}); } - } else if (['relation'].includes(property.type)) { + } else if (['relation'].includes(property.type as string)) { if (Array.isArray(property[type])) { result = property[type].map((e: IDataObject) => e.id || {}); } else { result = property[type].database_id; } - } else if (['formula'].includes(property.type)) { + } else if (['formula'].includes(property.type as string)) { result = property[type][property[type].type]; - } else if (['rollup'].includes(property.type)) { + } else if (['rollup'].includes(property.type as string)) { const rollupFunction = property[type].function as string; if (rollupFunction.startsWith('count') || rollupFunction.includes('empty')) { result = property[type].number; @@ -570,13 +574,13 @@ function simplifyProperty(property: any) { } } else if (rollupFunction.startsWith('show') && property[type].type === 'array') { const elements = property[type].array.map(simplifyProperty).flat(); - result = rollupFunction === 'show_unique' ? [...new Set(elements)] : elements; + result = rollupFunction === 'show_unique' ? [...new Set(elements as string)] : elements; } - } else if (['files'].includes(property.type)) { + } else if (['files'].includes(property.type as string)) { result = property[type].map( (file: { type: string; [key: string]: any }) => file[file.type].url, ); - } else if (['status'].includes(property.type)) { + } else if (['status'].includes(property.type as string)) { result = property[type].name; } return result; @@ -584,7 +588,7 @@ function simplifyProperty(property: any) { export function simplifyProperties(properties: any) { const results: any = {}; - for (const key of Object.keys(properties)) { + for (const key of Object.keys(properties as IDataObject)) { results[`${key}`] = simplifyProperty(properties[key]); } return results; @@ -620,20 +624,20 @@ export function simplifyObjects(objects: any, download = false, version = 2) { } else if (object === 'page' && parent.type === 'database_id') { results.push({ id, - ...(version === 2 ? { name: getPropertyTitle(properties) } : {}), + ...(version === 2 ? { name: getPropertyTitle(properties as IDataObject) } : {}), ...(version === 2 ? { url } : {}), ...(version === 2 - ? { ...prepend('property', simplifyProperties(properties)) } + ? { ...prepend('property', simplifyProperties(properties) as IDataObject) } : { ...simplifyProperties(properties) }), - }); + } as IDataObject); } else if (download && json.object === 'page' && json.parent.type === 'database_id') { results.push({ json: { id: json.id, - ...(version === 2 ? { name: getPropertyTitle(json.properties) } : {}), + ...(version === 2 ? { name: getPropertyTitle(json.properties as IDataObject) } : {}), ...(version === 2 ? { url: json.url } : {}), ...(version === 2 - ? { ...prepend('property', simplifyProperties(json.properties)) } + ? { ...prepend('property', simplifyProperties(json.properties) as IDataObject) } : { ...simplifyProperties(json.properties) }), }, binary, @@ -790,8 +794,19 @@ export function getConditions() { return elements; } +export type FileRecord = { + properties: { + [key: string]: + | any + | { + id: string; + type: string; + files: [{ external: { url: string } } | { file: { url: string } }]; + }; + }; +}; // prettier-ignore -export async function downloadFiles(this: IExecuteFunctions | IPollFunctions, records: [{ properties: { [key: string]: any | { id: string; type: string; files: [{ external: { url: string } } | { file: { url: string } }] } } }]): Promise { +export async function downloadFiles(this: IExecuteFunctions | IPollFunctions, records: FileRecord[]): Promise { const elements: INodeExecutionData[] = []; for (const record of records) { @@ -807,10 +822,10 @@ export async function downloadFiles(this: IExecuteFunctions | IPollFunctions, re '', {}, {}, - file?.file?.url || file?.external?.url, + file?.file?.url as string || file?.external?.url as string, { json: false, encoding: null }, ); - element.binary![`${key}_${index}`] = await this.helpers.prepareBinaryData(data); + element.binary![`${key}_${index}`] = await this.helpers.prepareBinaryData(data as Buffer); } } } diff --git a/packages/nodes-base/nodes/Notion/NotionTrigger.node.ts b/packages/nodes-base/nodes/Notion/NotionTrigger.node.ts index a008a646cb..7fe53f7f28 100644 --- a/packages/nodes-base/nodes/Notion/NotionTrigger.node.ts +++ b/packages/nodes-base/nodes/Notion/NotionTrigger.node.ts @@ -216,7 +216,7 @@ export class NotionTrigger implements INodeType { } // if something changed after the last check - if (Array.isArray(data) && data.length && Object.keys(data[0]).length !== 0) { + if (Array.isArray(data) && data.length && Object.keys(data[0] as IDataObject).length !== 0) { do { body.page_size = 10; const { results, has_more, next_cursor } = await notionApiRequest.call( @@ -228,7 +228,7 @@ export class NotionTrigger implements INodeType { '', option, ); - records.push(...results); + records.push(...(results as IDataObject[])); hasMore = has_more; if (next_cursor !== null) { body.start_cursor = next_cursor; diff --git a/packages/nodes-base/nodes/Notion/v1/NotionV1.node.ts b/packages/nodes-base/nodes/Notion/v1/NotionV1.node.ts index 71709bbdf7..a52e16b35c 100644 --- a/packages/nodes-base/nodes/Notion/v1/NotionV1.node.ts +++ b/packages/nodes-base/nodes/Notion/v1/NotionV1.node.ts @@ -10,6 +10,7 @@ import type { INodeTypeDescription, } from 'n8n-workflow'; +import type { SortData } from '../GenericFunctions'; import { extractDatabaseId, extractDatabaseMentionRLC, @@ -51,7 +52,7 @@ export class NotionV1 implements INodeType { extractValue: true, }) as string; const { properties } = await notionApiRequest.call(this, 'GET', `/databases/${databaseId}`); - for (const key of Object.keys(properties)) { + for (const key of Object.keys(properties as IDataObject)) { //remove parameters that cannot be set from the API. if ( ![ @@ -62,7 +63,7 @@ export class NotionV1 implements INodeType { 'formula', 'files', 'rollup', - ].includes(properties[key].type) + ].includes(properties[key].type as string) ) { returnData.push({ name: `${key} - (${properties[key].type})`, @@ -87,7 +88,7 @@ export class NotionV1 implements INodeType { extractValue: true, }) as string; const { properties } = await notionApiRequest.call(this, 'GET', `/databases/${databaseId}`); - for (const key of Object.keys(properties)) { + for (const key of Object.keys(properties as IDataObject)) { returnData.push({ name: `${key} - (${properties[key].type})`, value: `${key}|${properties[key].type}`, @@ -155,7 +156,7 @@ export class NotionV1 implements INodeType { parent: { database_id: databaseId }, } = await notionApiRequest.call(this, 'GET', `/pages/${pageId}`); const { properties } = await notionApiRequest.call(this, 'GET', `/databases/${databaseId}`); - for (const key of Object.keys(properties)) { + for (const key of Object.keys(properties as IDataObject)) { //remove parameters that cannot be set from the API. if ( ![ @@ -165,7 +166,7 @@ export class NotionV1 implements INodeType { 'last_edited_by', 'formula', 'files', - ].includes(properties[key].type) + ].includes(properties[key].type as string) ) { returnData.push({ name: `${key} - (${properties[key].type})`, @@ -254,7 +255,7 @@ export class NotionV1 implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(block), + this.helpers.returnJsonArray(block as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -288,7 +289,7 @@ export class NotionV1 implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -305,7 +306,7 @@ export class NotionV1 implements INodeType { responseData = await notionApiRequest.call(this, 'GET', `/databases/${databaseId}`); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -333,7 +334,7 @@ export class NotionV1 implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -379,7 +380,7 @@ export class NotionV1 implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -394,7 +395,7 @@ export class NotionV1 implements INodeType { }) as string; const returnAll = this.getNodeParameter('returnAll', i); const filters = this.getNodeParameter('options.filter', i, {}) as IDataObject; - const sort = this.getNodeParameter('options.sort.sortValue', i, []) as IDataObject[]; + const sort = this.getNodeParameter('options.sort.sortValue', i, []) as SortData[]; const body: IDataObject = { filter: {}, }; @@ -418,7 +419,6 @@ export class NotionV1 implements INodeType { delete body.filter; } if (sort) { - //@ts-expect-error body.sorts = mapSorting(sort); } if (returnAll) { @@ -446,7 +446,7 @@ export class NotionV1 implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -477,7 +477,7 @@ export class NotionV1 implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -492,7 +492,7 @@ export class NotionV1 implements INodeType { responseData = await notionApiRequest.call(this, 'GET', `/users/${userId}`); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -510,7 +510,7 @@ export class NotionV1 implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -549,7 +549,7 @@ export class NotionV1 implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -566,7 +566,7 @@ export class NotionV1 implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -619,7 +619,7 @@ export class NotionV1 implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Notion/v2/NotionV2.node.ts b/packages/nodes-base/nodes/Notion/v2/NotionV2.node.ts index 566fab9f50..ac897f15c1 100644 --- a/packages/nodes-base/nodes/Notion/v2/NotionV2.node.ts +++ b/packages/nodes-base/nodes/Notion/v2/NotionV2.node.ts @@ -11,7 +11,7 @@ import type { } from 'n8n-workflow'; import { jsonParse, NodeApiError } from 'n8n-workflow'; -import type { SortData } from '../GenericFunctions'; +import type { SortData, FileRecord } from '../GenericFunctions'; import { downloadFiles, extractDatabaseId, @@ -55,7 +55,7 @@ export class NotionV2 implements INodeType { extractValue: true, }) as string; const { properties } = await notionApiRequest.call(this, 'GET', `/databases/${databaseId}`); - for (const key of Object.keys(properties)) { + for (const key of Object.keys(properties as IDataObject)) { //remove parameters that cannot be set from the API. if ( ![ @@ -65,7 +65,7 @@ export class NotionV2 implements INodeType { 'last_edited_by', 'formula', 'rollup', - ].includes(properties[key].type) + ].includes(properties[key].type as string) ) { returnData.push({ name: `${key}`, @@ -90,7 +90,7 @@ export class NotionV2 implements INodeType { extractValue: true, }) as string; const { properties } = await notionApiRequest.call(this, 'GET', `/databases/${databaseId}`); - for (const key of Object.keys(properties)) { + for (const key of Object.keys(properties as IDataObject)) { returnData.push({ name: `${key}`, value: `${key}|${properties[key].type}`, @@ -161,7 +161,7 @@ export class NotionV2 implements INodeType { parent: { database_id: databaseId }, } = await notionApiRequest.call(this, 'GET', `/pages/${pageId}`); const { properties } = await notionApiRequest.call(this, 'GET', `/databases/${databaseId}`); - for (const key of Object.keys(properties)) { + for (const key of Object.keys(properties as IDataObject)) { //remove parameters that cannot be set from the API. if ( ![ @@ -171,7 +171,7 @@ export class NotionV2 implements INodeType { 'last_edited_by', 'formula', 'rollup', - ].includes(properties[key].type) + ].includes(properties[key].type as string) ) { returnData.push({ name: `${key}`, @@ -261,7 +261,7 @@ export class NotionV2 implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(block), + this.helpers.returnJsonArray(block as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -302,7 +302,7 @@ export class NotionV2 implements INodeType { })); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -323,7 +323,7 @@ export class NotionV2 implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -355,7 +355,7 @@ export class NotionV2 implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -407,7 +407,7 @@ export class NotionV2 implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -422,7 +422,7 @@ export class NotionV2 implements INodeType { }) as string; const { properties } = await notionApiRequest.call(this, 'GET', `/databases/${databaseId}`); let titleKey = ''; - for (const key of Object.keys(properties)) { + for (const key of Object.keys(properties as IDataObject)) { if (properties[key].type === 'title') { titleKey = key; } @@ -479,7 +479,7 @@ export class NotionV2 implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -498,7 +498,7 @@ export class NotionV2 implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -569,14 +569,14 @@ export class NotionV2 implements INodeType { responseData = responseData.results; } if (download) { - responseData = await downloadFiles.call(this, responseData); + responseData = await downloadFiles.call(this, responseData as FileRecord[]); } if (simple) { responseData = simplifyObjects(responseData, download); } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -607,7 +607,7 @@ export class NotionV2 implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -622,7 +622,7 @@ export class NotionV2 implements INodeType { responseData = await notionApiRequest.call(this, 'GET', `/users/${userId}`); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -640,7 +640,7 @@ export class NotionV2 implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -663,7 +663,7 @@ export class NotionV2 implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -700,7 +700,7 @@ export class NotionV2 implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -751,7 +751,7 @@ export class NotionV2 implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Odoo/GenericFunctions.ts b/packages/nodes-base/nodes/Odoo/GenericFunctions.ts index a74707cd01..08fb3ab67a 100644 --- a/packages/nodes-base/nodes/Odoo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Odoo/GenericFunctions.ts @@ -125,7 +125,7 @@ export async function odooJSONRPCRequest( const responce = await this.helpers.request(options); if (responce.error) { - throw new NodeApiError(this.getNode(), responce.error.data, { + throw new NodeApiError(this.getNode(), responce.error.data as JsonObject, { message: responce.error.data.message, }); } diff --git a/packages/nodes-base/nodes/OneSimpleApi/GenericFunctions.ts b/packages/nodes-base/nodes/OneSimpleApi/GenericFunctions.ts index 352fecebac..b7e89bb44a 100644 --- a/packages/nodes-base/nodes/OneSimpleApi/GenericFunctions.ts +++ b/packages/nodes-base/nodes/OneSimpleApi/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function oneSimpleApiRequest( @@ -36,6 +36,6 @@ export async function oneSimpleApiRequest( const responseData = await this.helpers.request(options); return responseData; } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/OneSimpleApi/OneSimpleApi.node.ts b/packages/nodes-base/nodes/OneSimpleApi/OneSimpleApi.node.ts index 9fafb7619b..8bd650526b 100644 --- a/packages/nodes-base/nodes/OneSimpleApi/OneSimpleApi.node.ts +++ b/packages/nodes-base/nodes/OneSimpleApi/OneSimpleApi.node.ts @@ -692,7 +692,7 @@ export class OneSimpleApi implements INodeType { '', {}, {}, - response.url, + response.url as string, { json: false, encoding: null }, )) as Buffer; responseData = { @@ -739,7 +739,7 @@ export class OneSimpleApi implements INodeType { '', {}, {}, - response.url, + response.url as string, { json: false, encoding: null }, )) as Buffer; responseData = { @@ -844,7 +844,7 @@ export class OneSimpleApi implements INodeType { '', {}, {}, - response.url, + response.url as string, { json: false, encoding: null }, )) as Buffer; responseData = { diff --git a/packages/nodes-base/nodes/Onfleet/GenericFunctions.ts b/packages/nodes-base/nodes/Onfleet/GenericFunctions.ts index 62fb47349d..998a090cdc 100644 --- a/packages/nodes-base/nodes/Onfleet/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Onfleet/GenericFunctions.ts @@ -41,7 +41,6 @@ export async function onfleetApiRequest( json: true, }; try { - //@ts-ignore return await this.helpers.request(options); } catch (error) { throw new NodeApiError(this.getNode(), error as JsonObject); @@ -64,7 +63,7 @@ export async function onfleetApiRequestAllItems( do { responseData = await onfleetApiRequest.call(this, method, endpoint, body, query); query.lastId = responseData.lastId; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.lastId !== undefined); return returnData; diff --git a/packages/nodes-base/nodes/Onfleet/Onfleet.node.ts b/packages/nodes-base/nodes/Onfleet/Onfleet.node.ts index 7595f3b337..2e8af446e2 100644 --- a/packages/nodes-base/nodes/Onfleet/Onfleet.node.ts +++ b/packages/nodes-base/nodes/Onfleet/Onfleet.node.ts @@ -196,6 +196,6 @@ export class Onfleet implements INodeType { const responseData = await operations[resource].call(this, `${resource}s`, operation, items); // Map data to n8n data - return [this.helpers.returnJsonArray(responseData)]; + return [this.helpers.returnJsonArray(responseData as IDataObject)]; } } diff --git a/packages/nodes-base/nodes/Onfleet/Onfleet.ts b/packages/nodes-base/nodes/Onfleet/Onfleet.ts index 8ba44c9e48..26dc787379 100644 --- a/packages/nodes-base/nodes/Onfleet/Onfleet.ts +++ b/packages/nodes-base/nodes/Onfleet/Onfleet.ts @@ -853,7 +853,7 @@ export class Onfleet { tasks = tasks.tasks; tasks = tasks.splice(0, limit); } - responseData.push(...tasks); + responseData.push(...(tasks as IDataObject[])); } else if (operation === 'complete') { /* -------------------------------------------------------------------------- */ /* Force complete a task */ @@ -1061,7 +1061,7 @@ export class Onfleet { const limit = this.getNodeParameter('limit', 0); adminUsers = adminUsers.slice(0, limit); } - responseData.push(...adminUsers); + responseData.push(...(adminUsers as IDataObject[])); } else if (operation === 'create') { /* -------------------------------------------------------------------------- */ /* Create a new admin */ @@ -1123,7 +1123,7 @@ export class Onfleet { const limit = this.getNodeParameter('limit', 0); hubs = hubs.slice(0, limit); } - responseData.push(...hubs); + responseData.push(...(hubs as IDataObject[])); } else if (operation === 'create') { /* -------------------------------------------------------------------------- */ /* Create a new hub */ @@ -1203,7 +1203,7 @@ export class Onfleet { workers = workers.slice(0, limit); } - responseData.push(...workers); + responseData.push(...(workers as IDataObject[])); } else if (operation === 'get') { /* -------------------------------------------------------------------------- */ /* Get a worker */ @@ -1290,7 +1290,9 @@ export class Onfleet { /* -------------------------------------------------------------------------- */ /* Get all webhooks */ /* -------------------------------------------------------------------------- */ - responseData.push(...(await onfleetApiRequest.call(this, 'GET', resource))); + responseData.push( + ...((await onfleetApiRequest.call(this, 'GET', resource)) as IDataObject[]), + ); } else if (operation === 'create') { /* -------------------------------------------------------------------------- */ /* Create a new webhook */ @@ -1403,7 +1405,7 @@ export class Onfleet { teams = teams.slice(0, limit); } - responseData.push(...teams); + responseData.push(...(teams as IDataObject[])); } else if (operation === 'get') { /* -------------------------------------------------------------------------- */ /* Get a single team */ diff --git a/packages/nodes-base/nodes/Onfleet/OnfleetTrigger.node.ts b/packages/nodes-base/nodes/Onfleet/OnfleetTrigger.node.ts index 6eecb46eb2..ed4fb7b032 100644 --- a/packages/nodes-base/nodes/Onfleet/OnfleetTrigger.node.ts +++ b/packages/nodes-base/nodes/Onfleet/OnfleetTrigger.node.ts @@ -3,6 +3,7 @@ import type { INodeType, INodeTypeDescription, IWebhookResponseData, + JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; import type { IHookFunctions, IWebhookFunctions } from 'n8n-core'; @@ -51,7 +52,6 @@ export class OnfleetTrigger implements INodeType { properties: [eventDisplay, eventNameField], }; - // @ts-ignore (because of request) webhookMethods = { default: { async checkExists(this: IHookFunctions): Promise { @@ -101,7 +101,7 @@ export class OnfleetTrigger implements INodeType { const webhook = await onfleetApiRequest.call(this, 'POST', path, body); if (webhook.id === undefined) { - throw new NodeApiError(this.getNode(), webhook, { + throw new NodeApiError(this.getNode(), webhook as JsonObject, { message: 'Onfleet webhook creation response did not contain the expected data', }); } diff --git a/packages/nodes-base/nodes/OpenThesaurus/GenericFunctions.ts b/packages/nodes-base/nodes/OpenThesaurus/GenericFunctions.ts index 9c743d1953..52e51d52d2 100644 --- a/packages/nodes-base/nodes/OpenThesaurus/GenericFunctions.ts +++ b/packages/nodes-base/nodes/OpenThesaurus/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function openThesaurusApiRequest( @@ -37,6 +37,6 @@ export async function openThesaurusApiRequest( return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/OpenThesaurus/OpenThesaurus.node.ts b/packages/nodes-base/nodes/OpenThesaurus/OpenThesaurus.node.ts index 0f65f7da70..c46b247206 100644 --- a/packages/nodes-base/nodes/OpenThesaurus/OpenThesaurus.node.ts +++ b/packages/nodes-base/nodes/OpenThesaurus/OpenThesaurus.node.ts @@ -167,7 +167,7 @@ export class OpenThesaurus implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/OpenWeatherMap/OpenWeatherMap.node.ts b/packages/nodes-base/nodes/OpenWeatherMap/OpenWeatherMap.node.ts index f8704942ba..6497cd8b1e 100644 --- a/packages/nodes-base/nodes/OpenWeatherMap/OpenWeatherMap.node.ts +++ b/packages/nodes-base/nodes/OpenWeatherMap/OpenWeatherMap.node.ts @@ -4,6 +4,7 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -270,11 +271,11 @@ export class OpenWeatherMap implements INodeType { try { responseData = await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Orbit/GenericFunctions.ts b/packages/nodes-base/nodes/Orbit/GenericFunctions.ts index cdfb12e5fb..4e7fd71a86 100644 --- a/packages/nodes-base/nodes/Orbit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Orbit/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { JsonObject, IDataObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import type { IRelation } from './Interfaces'; @@ -39,7 +39,7 @@ export async function orbitApiRequest( return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -100,14 +100,14 @@ export async function orbitApiRequestAllItems( do { responseData = await orbitApiRequest.call(this, method, resource, body, query); - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); if (query.resolveIdentities === true) { - resolveIdentities(responseData); + resolveIdentities(responseData as IRelation); } if (query.resolveMember === true) { - resolveMember(responseData); + resolveMember(responseData as IRelation); } query.page++; diff --git a/packages/nodes-base/nodes/Orbit/Orbit.node.ts b/packages/nodes-base/nodes/Orbit/Orbit.node.ts index 85a84af03f..87244f60b0 100644 --- a/packages/nodes-base/nodes/Orbit/Orbit.node.ts +++ b/packages/nodes-base/nodes/Orbit/Orbit.node.ts @@ -20,6 +20,7 @@ import { noteFields, noteOperations } from './NoteDescription'; import { postFields, postOperations } from './PostDescription'; import moment from 'moment'; +import type { IRelation } from './Interfaces'; export class Orbit implements INodeType { description: INodeTypeDescription = { @@ -281,7 +282,7 @@ export class Orbit implements INodeType { `/${workspaceId}/members/${memberId}`, ); if (resolve) { - resolveIdentities(responseData); + resolveIdentities(responseData as IRelation); } responseData = responseData.data; } @@ -525,7 +526,7 @@ export class Orbit implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Oura/GenericFunctions.ts b/packages/nodes-base/nodes/Oura/GenericFunctions.ts index 1a6ce1e56f..e4205c299c 100644 --- a/packages/nodes-base/nodes/Oura/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Oura/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function ouraApiRequest( @@ -44,6 +44,6 @@ export async function ouraApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Oura/Oura.node.ts b/packages/nodes-base/nodes/Oura/Oura.node.ts index 4c11af67ae..1824101465 100644 --- a/packages/nodes-base/nodes/Oura/Oura.node.ts +++ b/packages/nodes-base/nodes/Oura/Oura.node.ts @@ -148,8 +148,8 @@ export class Oura implements INodeType { } Array.isArray(responseData) - ? returnData.push(...responseData) - : returnData.push(responseData); + ? returnData.push(...(responseData as IDataObject[])) + : returnData.push(responseData as IDataObject); } return [this.helpers.returnJsonArray(returnData)]; diff --git a/packages/nodes-base/nodes/Paddle/GenericFunctions.ts b/packages/nodes-base/nodes/Paddle/GenericFunctions.ts index d17fe6be98..2943d59994 100644 --- a/packages/nodes-base/nodes/Paddle/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Paddle/GenericFunctions.ts @@ -8,7 +8,7 @@ import type { IWebhookFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { JsonObject, IDataObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function paddleApiRequest( @@ -47,12 +47,12 @@ export async function paddleApiRequest( const response = await this.helpers.request(options); if (!response.success) { - throw new NodeApiError(this.getNode(), response); + throw new NodeApiError(this.getNode(), response as JsonObject); } return response; } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -74,7 +74,7 @@ export async function paddleApiRequestAllItems( do { responseData = await paddleApiRequest.call(this, endpoint, method, body, query); - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); body.page++; } while ( responseData[propertyName].length !== 0 && diff --git a/packages/nodes-base/nodes/Paddle/Paddle.node.ts b/packages/nodes-base/nodes/Paddle/Paddle.node.ts index 363d52c75a..be4cfbc7d2 100644 --- a/packages/nodes-base/nodes/Paddle/Paddle.node.ts +++ b/packages/nodes-base/nodes/Paddle/Paddle.node.ts @@ -7,6 +7,7 @@ import type { INodePropertyOptions, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -119,7 +120,7 @@ export class Paddle implements INodeType { // Alert user if there's no payments present to be loaded into payments property if (paymentResponse.response === undefined || paymentResponse.response.length === 0) { - throw new NodeApiError(this.getNode(), paymentResponse, { + throw new NodeApiError(this.getNode(), paymentResponse as JsonObject, { message: 'No payments on account.', }); } @@ -532,7 +533,7 @@ export class Paddle implements INodeType { throw error; } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/PagerDuty/GenericFunctions.ts b/packages/nodes-base/nodes/PagerDuty/GenericFunctions.ts index 04ca75fefd..80540ffa54 100644 --- a/packages/nodes-base/nodes/PagerDuty/GenericFunctions.ts +++ b/packages/nodes-base/nodes/PagerDuty/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject, IHookFunctions, IWebhookFunctions } from 'n8n-workflow'; +import type { JsonObject, IDataObject, IHookFunctions, IWebhookFunctions } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import { snakeCase } from 'change-case'; @@ -33,7 +33,7 @@ export async function pagerDutyApiRequest( }, }; - if (!Object.keys(body).length) { + if (!Object.keys(body as IDataObject).length) { delete options.form; } if (!Object.keys(query).length) { @@ -53,7 +53,7 @@ export async function pagerDutyApiRequest( return await this.helpers.requestOAuth2.call(this, 'pagerDutyOAuth2Api', options); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -75,7 +75,7 @@ export async function pagerDutyApiRequestAllItems( do { responseData = await pagerDutyApiRequest.call(this, method, endpoint, body, query); query.offset++; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.more); return returnData; diff --git a/packages/nodes-base/nodes/PagerDuty/PagerDuty.node.ts b/packages/nodes-base/nodes/PagerDuty/PagerDuty.node.ts index 6aeeb8a94b..58f123a5ce 100644 --- a/packages/nodes-base/nodes/PagerDuty/PagerDuty.node.ts +++ b/packages/nodes-base/nodes/PagerDuty/PagerDuty.node.ts @@ -456,7 +456,7 @@ export class PagerDuty implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/PayPal/GenericFunctions.ts b/packages/nodes-base/nodes/PayPal/GenericFunctions.ts index 37bb8f5218..f2d8298eb2 100644 --- a/packages/nodes-base/nodes/PayPal/GenericFunctions.ts +++ b/packages/nodes-base/nodes/PayPal/GenericFunctions.ts @@ -9,7 +9,7 @@ import type { } from 'n8n-core'; import { BINARY_ENCODING } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { JsonObject, IDataObject } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; function getEnvironment(env: string) { @@ -48,7 +48,7 @@ async function getAccessToken( try { return await this.helpers.request(options); } catch (error) { - throw new NodeOperationError(this.getNode(), error); + throw new NodeOperationError(this.getNode(), error as Error); } } @@ -84,7 +84,7 @@ export async function payPalApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -119,9 +119,9 @@ export async function payPalApiRequestAllItems( do { responseData = await payPalApiRequest.call(this, endpoint, method, body, query, uri); - uri = getNext(responseData.links); - returnData.push.apply(returnData, responseData[propertyName]); - } while (getNext(responseData.links) !== undefined); + uri = getNext(responseData.links as IDataObject[]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); + } while (getNext(responseData.links as IDataObject[]) !== undefined); return returnData; } diff --git a/packages/nodes-base/nodes/PayPal/PayPal.node.ts b/packages/nodes-base/nodes/PayPal/PayPal.node.ts index c094795382..a65d475175 100644 --- a/packages/nodes-base/nodes/PayPal/PayPal.node.ts +++ b/packages/nodes-base/nodes/PayPal/PayPal.node.ts @@ -236,7 +236,7 @@ export class PayPal implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/PayPal/PayPalTrigger.node.ts b/packages/nodes-base/nodes/PayPal/PayPalTrigger.node.ts index 1a2b5b5d00..2e97ed5f3b 100644 --- a/packages/nodes-base/nodes/PayPal/PayPalTrigger.node.ts +++ b/packages/nodes-base/nodes/PayPal/PayPalTrigger.node.ts @@ -7,6 +7,7 @@ import type { INodeType, INodeTypeDescription, IWebhookResponseData, + JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import { payPalApiRequest, upperFist } from './GenericFunctions'; @@ -72,10 +73,10 @@ export class PayPalTrigger implements INodeType { const endpoint = '/notifications/webhooks-event-types'; events = await payPalApiRequest.call(this, endpoint, 'GET'); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } for (const event of events.event_types) { - const eventName = upperFist(event.name); + const eventName = upperFist(event.name as string); const eventId = event.name; const eventDescription = event.description; @@ -90,7 +91,6 @@ export class PayPalTrigger implements INodeType { }, }; - // @ts-ignore (because of request) webhookMethods = { default: { async checkExists(this: IHookFunctions): Promise { @@ -108,7 +108,7 @@ export class PayPalTrigger implements INodeType { delete webhookData.webhookId; return false; } - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } return true; }, @@ -167,7 +167,7 @@ export class PayPalTrigger implements INodeType { // if sanbox omit verification if (env === 'sanbox') { return { - workflowData: [this.helpers.returnJsonArray(req.body)], + workflowData: [this.helpers.returnJsonArray(req.body as IDataObject)], }; } @@ -199,7 +199,7 @@ export class PayPalTrigger implements INodeType { return {}; } return { - workflowData: [this.helpers.returnJsonArray(req.body)], + workflowData: [this.helpers.returnJsonArray(req.body as IDataObject)], }; } } diff --git a/packages/nodes-base/nodes/Peekalink/GenericFunctions.ts b/packages/nodes-base/nodes/Peekalink/GenericFunctions.ts index 46d320ec24..bde7d1fd32 100644 --- a/packages/nodes-base/nodes/Peekalink/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Peekalink/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { JsonObject, IDataObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function peekalinkApiRequest( @@ -37,6 +37,6 @@ export async function peekalinkApiRequest( return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Phantombuster/GenericFunctions.ts b/packages/nodes-base/nodes/Phantombuster/GenericFunctions.ts index b22538d394..add08a50b1 100644 --- a/packages/nodes-base/nodes/Phantombuster/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Phantombuster/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { JsonObject, IDataObject } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; export async function phantombusterApiRequest( @@ -23,13 +23,12 @@ export async function phantombusterApiRequest( json: true, }; try { - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } - //@ts-ignore return await this.helpers.requestWithAuthentication.call(this, 'phantombusterApi', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Phantombuster/Phantombuster.node.ts b/packages/nodes-base/nodes/Phantombuster/Phantombuster.node.ts index 791f258f8d..1be88c0bb3 100644 --- a/packages/nodes-base/nodes/Phantombuster/Phantombuster.node.ts +++ b/packages/nodes-base/nodes/Phantombuster/Phantombuster.node.ts @@ -165,7 +165,7 @@ export class Phantombuster implements INodeType { if (resultObject === null) { responseData = {}; } else { - responseData = JSON.parse(resultObject); + responseData = JSON.parse(resultObject as string); } } } @@ -248,7 +248,7 @@ export class Phantombuster implements INodeType { } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/PhilipsHue/GenericFunctions.ts b/packages/nodes-base/nodes/PhilipsHue/GenericFunctions.ts index fb9b2736f8..2058b6e199 100644 --- a/packages/nodes-base/nodes/PhilipsHue/GenericFunctions.ts +++ b/packages/nodes-base/nodes/PhilipsHue/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { JsonObject, IDataObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function philipsHueApiRequest( @@ -30,7 +30,7 @@ export async function philipsHueApiRequest( options.headers = Object.assign({}, options.headers, headers); } - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } @@ -38,20 +38,19 @@ export async function philipsHueApiRequest( delete options.qs; } - //@ts-ignore const response = await this.helpers.requestOAuth2.call(this, 'philipsHueOAuth2Api', options, { tokenType: 'Bearer', }); return response; } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } export async function getUser(this: IExecuteFunctions | ILoadOptionsFunctions): Promise { const { whitelist } = await philipsHueApiRequest.call(this, 'GET', '/api/0/config', {}, {}); //check if there is a n8n user - for (const user of Object.keys(whitelist)) { + for (const user of Object.keys(whitelist as IDataObject)) { if (whitelist[user].name === 'n8n') { return user; } diff --git a/packages/nodes-base/nodes/PhilipsHue/PhilipsHue.node.ts b/packages/nodes-base/nodes/PhilipsHue/PhilipsHue.node.ts index 75b6a3d75d..2564309de0 100644 --- a/packages/nodes-base/nodes/PhilipsHue/PhilipsHue.node.ts +++ b/packages/nodes-base/nodes/PhilipsHue/PhilipsHue.node.ts @@ -1,6 +1,7 @@ import type { IExecuteFunctions } from 'n8n-core'; import type { + IDataObject, ILoadOptionsFunctions, INodeExecutionData, INodePropertyOptions, @@ -65,11 +66,11 @@ export class PhilipsHue implements INodeType { const groups = await philipsHueApiRequest.call(this, 'GET', `/api/${user}/groups`); - for (const light of Object.keys(lights)) { + for (const light of Object.keys(lights as IDataObject)) { let lightName = lights[light].name; const lightId = light; - for (const groupId of Object.keys(groups)) { + for (const groupId of Object.keys(groups as IDataObject)) { if (groups[groupId].type === 'Room' && groups[groupId].lights.includes(lightId)) { lightName = `${groups[groupId].name}: ${lightName}`; } @@ -156,7 +157,7 @@ export class PhilipsHue implements INodeType { const lights = await philipsHueApiRequest.call(this, 'GET', `/api/${user}/lights`); - responseData = Object.values(lights); + responseData = Object.values(lights as IDataObject); if (!returnAll) { const limit = this.getNodeParameter('limit', i); @@ -176,7 +177,7 @@ export class PhilipsHue implements INodeType { } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Pipedrive/GenericFunctions.ts b/packages/nodes-base/nodes/Pipedrive/GenericFunctions.ts index dd13224ddd..6b994b9ccd 100644 --- a/packages/nodes-base/nodes/Pipedrive/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Pipedrive/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject, INodePropertyOptions } from 'n8n-workflow'; +import type { JsonObject, IDataObject, INodePropertyOptions } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; import type { OptionsWithUri } from 'request'; @@ -77,7 +77,7 @@ export async function pipedriveApiRequest( } if (responseData.success === false) { - throw new NodeApiError(this.getNode(), responseData); + throw new NodeApiError(this.getNode(), responseData as JsonObject); } return { @@ -85,7 +85,7 @@ export async function pipedriveApiRequest( data: responseData.data === null ? [] : responseData.data, }; } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -116,9 +116,9 @@ export async function pipedriveApiRequestAllItems( responseData = await pipedriveApiRequest.call(this, method, endpoint, body, query); // the search path returns data diferently if (responseData.data.items) { - returnData.push.apply(returnData, responseData.data.items); + returnData.push.apply(returnData, responseData.data.items as IDataObject[]); } else { - returnData.push.apply(returnData, responseData.data); + returnData.push.apply(returnData, responseData.data as IDataObject[]); } query.start = responseData.additionalData.pagination.next_start; diff --git a/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts b/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts index bdcccc7a6d..5bca7f6d2f 100644 --- a/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts +++ b/packages/nodes-base/nodes/Pipedrive/Pipedrive.node.ts @@ -4850,7 +4850,7 @@ export class Pipedrive implements INodeType { const binaryPropertyName = this.getNodeParameter('binaryPropertyName', i); items[i].binary![binaryPropertyName] = await this.helpers.prepareBinaryData( - responseData.data, + responseData.data as Buffer, ); } else { if (responseData.data === null) { @@ -4878,7 +4878,7 @@ export class Pipedrive implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Pipedrive/PipedriveTrigger.node.ts b/packages/nodes-base/nodes/Pipedrive/PipedriveTrigger.node.ts index 5d5ee811fa..bf0b044916 100644 --- a/packages/nodes-base/nodes/Pipedrive/PipedriveTrigger.node.ts +++ b/packages/nodes-base/nodes/Pipedrive/PipedriveTrigger.node.ts @@ -2,6 +2,7 @@ import type { IHookFunctions, IWebhookFunctions } from 'n8n-core'; import type { ICredentialDataDecryptedObject, + IDataObject, INodeType, INodeTypeDescription, IWebhookResponseData, @@ -209,7 +210,6 @@ export class PipedriveTrigger implements INodeType { ], }; - // @ts-ignore (because of request) webhookMethods = { default: { async checkExists(this: IHookFunctions): Promise { @@ -353,7 +353,7 @@ export class PipedriveTrigger implements INodeType { } return { - workflowData: [this.helpers.returnJsonArray(req.body)], + workflowData: [this.helpers.returnJsonArray(req.body as IDataObject[])], }; } } diff --git a/packages/nodes-base/nodes/Plivo/GenericFunctions.ts b/packages/nodes-base/nodes/Plivo/GenericFunctions.ts index 138d9b2a98..c6f57e17b6 100644 --- a/packages/nodes-base/nodes/Plivo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Plivo/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import type { OptionsWithUri } from 'request'; @@ -39,6 +39,6 @@ export async function plivoApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Plivo/Plivo.node.ts b/packages/nodes-base/nodes/Plivo/Plivo.node.ts index ed57e9b5c9..1099b6942e 100644 --- a/packages/nodes-base/nodes/Plivo/Plivo.node.ts +++ b/packages/nodes-base/nodes/Plivo/Plivo.node.ts @@ -142,8 +142,8 @@ export class Plivo implements INodeType { } Array.isArray(responseData) - ? returnData.push(...responseData) - : returnData.push(responseData); + ? returnData.push(...(responseData as IDataObject[])) + : returnData.push(responseData as IDataObject); } return [this.helpers.returnJsonArray(returnData)]; diff --git a/packages/nodes-base/nodes/PostHog/GenericFunctions.ts b/packages/nodes-base/nodes/PostHog/GenericFunctions.ts index 52810b3d05..871b00ef4c 100644 --- a/packages/nodes-base/nodes/PostHog/GenericFunctions.ts +++ b/packages/nodes-base/nodes/PostHog/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUrl } from 'request'; import type { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function posthogApiRequest( @@ -32,12 +32,12 @@ export async function posthogApiRequest( }; try { - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/PostHog/PostHog.node.ts b/packages/nodes-base/nodes/PostHog/PostHog.node.ts index e61ba2f5b1..f16b6721d8 100644 --- a/packages/nodes-base/nodes/PostHog/PostHog.node.ts +++ b/packages/nodes-base/nodes/PostHog/PostHog.node.ts @@ -121,7 +121,7 @@ export class PostHog implements INodeType { responseData = await posthogApiRequest.call(this, 'POST', '/batch', event); - returnData.push(responseData); + returnData.push(responseData as IDataObject); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); @@ -173,7 +173,7 @@ export class PostHog implements INodeType { responseData = await posthogApiRequest.call(this, 'POST', '/capture', { batch: events }); - returnData.push(responseData); + returnData.push(responseData as IDataObject); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); @@ -217,7 +217,7 @@ export class PostHog implements INodeType { responseData = await posthogApiRequest.call(this, 'POST', '/batch', event); - returnData.push(responseData); + returnData.push(responseData as IDataObject); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); @@ -273,7 +273,7 @@ export class PostHog implements INodeType { responseData = await posthogApiRequest.call(this, 'POST', '/batch', event); - returnData.push(responseData); + returnData.push(responseData as IDataObject); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); diff --git a/packages/nodes-base/nodes/Postgres/Postgres.node.functions.ts b/packages/nodes-base/nodes/Postgres/Postgres.node.functions.ts index 4aa41b87a8..a13c45759a 100644 --- a/packages/nodes-base/nodes/Postgres/Postgres.node.functions.ts +++ b/packages/nodes-base/nodes/Postgres/Postgres.node.functions.ts @@ -194,7 +194,7 @@ export async function pgQueryV2( if (mode === 'multiple') { return (await db.multi(pgp.helpers.concat(allQueries))) .map((result, i) => { - return this.helpers.constructExecutionMetaData(wrapData(result), { + return this.helpers.constructExecutionMetaData(wrapData(result as IDataObject[]), { itemData: { item: i }, }); }) @@ -206,7 +206,7 @@ export async function pgQueryV2( try { const transactionResult = await t.any(allQueries[i].query, allQueries[i].values); const executionData = this.helpers.constructExecutionMetaData( - wrapData(transactionResult), + wrapData(transactionResult as IDataObject[]), { itemData: { item: i } }, ); result.push(...executionData); @@ -230,7 +230,7 @@ export async function pgQueryV2( try { const transactionResult = await t.any(allQueries[i].query, allQueries[i].values); const executionData = this.helpers.constructExecutionMetaData( - wrapData(transactionResult), + wrapData(transactionResult as IDataObject[]), { itemData: { item: i } }, ); result.push(...executionData); @@ -319,7 +319,7 @@ export async function pgInsert( try { const insertResult = await t.oneOrNone(pgp.helpers.insert(itemCopy, cs) + returning); if (insertResult !== null) { - result.push(insertResult); + result.push(insertResult as IDataObject); } } catch (err) { if (!continueOnFail) { @@ -382,7 +382,7 @@ export async function pgInsertV2( const queryResult = await db.any(query); return queryResult .map((result, i) => { - return this.helpers.constructExecutionMetaData(wrapData(result), { + return this.helpers.constructExecutionMetaData(wrapData(result as IDataObject[]), { itemData: { item: i }, }); }) @@ -395,7 +395,7 @@ export async function pgInsertV2( try { const insertResult = await t.one(pgp.helpers.insert(itemCopy, cs) + returning); result.push( - ...this.helpers.constructExecutionMetaData(wrapData(insertResult), { + ...this.helpers.constructExecutionMetaData(wrapData(insertResult as IDataObject[]), { itemData: { item: i }, }), ); @@ -420,9 +420,12 @@ export async function pgInsertV2( try { const insertResult = await t.oneOrNone(pgp.helpers.insert(itemCopy, cs) + returning); if (insertResult !== null) { - const executionData = this.helpers.constructExecutionMetaData(wrapData(insertResult), { - itemData: { item: i }, - }); + const executionData = this.helpers.constructExecutionMetaData( + wrapData(insertResult as IDataObject[]), + { + itemData: { item: i }, + }, + ); result.push(...executionData); } } catch (err) { @@ -652,7 +655,7 @@ export async function pgUpdateV2( returning, ); const executionData = this.helpers.constructExecutionMetaData( - wrapData(transactionResult), + wrapData(transactionResult as IDataObject[]), { itemData: { item: i } }, ); result.push(...executionData); @@ -680,7 +683,7 @@ export async function pgUpdateV2( returning, ); const executionData = this.helpers.constructExecutionMetaData( - wrapData(independentResult), + wrapData(independentResult as IDataObject[]), { itemData: { item: i } }, ); result.push(...executionData); diff --git a/packages/nodes-base/nodes/Postmark/GenericFunctions.ts b/packages/nodes-base/nodes/Postmark/GenericFunctions.ts index 3a1f39a5fb..3aa05b8d1d 100644 --- a/packages/nodes-base/nodes/Postmark/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Postmark/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject, IHookFunctions, IWebhookFunctions } from 'n8n-workflow'; +import type { IDataObject, IHookFunctions, IWebhookFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function postmarkApiRequest( @@ -23,7 +23,7 @@ export async function postmarkApiRequest( uri: 'https://api.postmarkapp.com' + endpoint, json: true, }; - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } options = Object.assign({}, options, option); @@ -31,7 +31,7 @@ export async function postmarkApiRequest( try { return await this.helpers.requestWithAuthentication.call(this, 'postmarkApi', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Postmark/PostmarkTrigger.node.ts b/packages/nodes-base/nodes/Postmark/PostmarkTrigger.node.ts index bf2b08cc0b..58f26c5cf9 100644 --- a/packages/nodes-base/nodes/Postmark/PostmarkTrigger.node.ts +++ b/packages/nodes-base/nodes/Postmark/PostmarkTrigger.node.ts @@ -1,6 +1,11 @@ import type { IHookFunctions, IWebhookFunctions } from 'n8n-core'; -import type { INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow'; +import type { + IDataObject, + INodeType, + INodeTypeDescription, + IWebhookResponseData, +} from 'n8n-workflow'; import { convertTriggerObjectToStringArray, @@ -105,7 +110,6 @@ export class PostmarkTrigger implements INodeType { ], }; - // @ts-ignore (because of request) webhookMethods = { default: { async checkExists(this: IHookFunctions): Promise { @@ -246,7 +250,7 @@ export class PostmarkTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const req = this.getRequestObject(); return { - workflowData: [this.helpers.returnJsonArray(req.body)], + workflowData: [this.helpers.returnJsonArray(req.body as IDataObject[])], }; } } diff --git a/packages/nodes-base/nodes/ProfitWell/GenericFunctions.ts b/packages/nodes-base/nodes/ProfitWell/GenericFunctions.ts index a63bed6e8c..8edc2dc44b 100644 --- a/packages/nodes-base/nodes/ProfitWell/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ProfitWell/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function profitWellApiRequest( @@ -37,13 +37,13 @@ export async function profitWellApiRequest( return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } - -export function simplifyDailyMetrics(responseData: { +export type Metrics = { [key: string]: [{ date: string; value: number | null }]; -}) { +}; +export function simplifyDailyMetrics(responseData: Metrics) { const data: IDataObject[] = []; const keys = Object.keys(responseData); const dates = responseData[keys[0]].map((e) => e.date); @@ -59,9 +59,7 @@ export function simplifyDailyMetrics(responseData: { return data; } -export function simplifyMontlyMetrics(responseData: { - [key: string]: [{ date: string; value: number | null }]; -}) { +export function simplifyMontlyMetrics(responseData: Metrics) { const data: IDataObject = {}; for (const key of Object.keys(responseData)) { for (const [index] of responseData[key].entries()) { diff --git a/packages/nodes-base/nodes/ProfitWell/ProfitWell.node.ts b/packages/nodes-base/nodes/ProfitWell/ProfitWell.node.ts index 2a164a489b..a70976f772 100644 --- a/packages/nodes-base/nodes/ProfitWell/ProfitWell.node.ts +++ b/packages/nodes-base/nodes/ProfitWell/ProfitWell.node.ts @@ -9,6 +9,7 @@ import type { INodeTypeDescription, } from 'n8n-workflow'; +import type { Metrics } from './GenericFunctions'; import { profitWellApiRequest, simplifyDailyMetrics, @@ -121,7 +122,7 @@ export class ProfitWell implements INodeType { } responseData = await profitWellApiRequest.call(this, 'GET', `/metrics/${type}`, {}, qs); - responseData = responseData.data; + responseData = responseData.data as Metrics; if (simple) { if (type === 'daily') { diff --git a/packages/nodes-base/nodes/Pushbullet/GenericFunctions.ts b/packages/nodes-base/nodes/Pushbullet/GenericFunctions.ts index c978899e87..6b4ace5ac9 100644 --- a/packages/nodes-base/nodes/Pushbullet/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Pushbullet/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function pushbulletApiRequest( @@ -23,16 +23,15 @@ export async function pushbulletApiRequest( json: true, }; try { - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } if (Object.keys(option).length !== 0) { Object.assign(options, option); } - //@ts-ignore return await this.helpers.requestOAuth2.call(this, 'pushbulletOAuth2Api', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -51,7 +50,7 @@ export async function pushbulletApiRequestAllItems( do { responseData = await pushbulletApiRequest.call(this, method, endpoint, body, query); - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.cursor !== undefined); return returnData; diff --git a/packages/nodes-base/nodes/Pushbullet/Pushbullet.node.ts b/packages/nodes-base/nodes/Pushbullet/Pushbullet.node.ts index 2283d98829..55f9dd5d82 100644 --- a/packages/nodes-base/nodes/Pushbullet/Pushbullet.node.ts +++ b/packages/nodes-base/nodes/Pushbullet/Pushbullet.node.ts @@ -436,7 +436,7 @@ export class Pushbullet implements INodeType { }); //upload the file - await pushbulletApiRequest.call(this, 'POST', '', {}, {}, uploadUrl, { + await pushbulletApiRequest.call(this, 'POST', '', {}, {}, uploadUrl as string, { formData: { file: { value: dataBuffer, @@ -504,7 +504,7 @@ export class Pushbullet implements INodeType { } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Pushcut/GenericFunctions.ts b/packages/nodes-base/nodes/Pushcut/GenericFunctions.ts index c0ccdcb23a..0a8117dca6 100644 --- a/packages/nodes-base/nodes/Pushcut/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Pushcut/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject, IHookFunctions } from 'n8n-workflow'; +import type { IDataObject, IHookFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function pushcutApiRequest( @@ -28,15 +28,14 @@ export async function pushcutApiRequest( json: true, }; try { - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } if (Object.keys(option).length !== 0) { Object.assign(options, option); } - //@ts-ignore return await this.helpers.request.call(this, options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Pushover/GenericFunctions.ts b/packages/nodes-base/nodes/Pushover/GenericFunctions.ts index 41193de812..03b185f790 100644 --- a/packages/nodes-base/nodes/Pushover/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Pushover/GenericFunctions.ts @@ -1,6 +1,11 @@ import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject, IHttpRequestMethods, IHttpRequestOptions } from 'n8n-workflow'; +import type { + IDataObject, + IHttpRequestMethods, + IHttpRequestOptions, + JsonObject, +} from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function pushoverApiRequest( @@ -24,12 +29,12 @@ export async function pushoverApiRequest( }; try { - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } return await this.helpers.requestWithAuthentication.call(this, 'pushoverApi', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Pushover/Pushover.node.ts b/packages/nodes-base/nodes/Pushover/Pushover.node.ts index 94bca10602..a64142e81f 100644 --- a/packages/nodes-base/nodes/Pushover/Pushover.node.ts +++ b/packages/nodes-base/nodes/Pushover/Pushover.node.ts @@ -285,7 +285,7 @@ export class Pushover implements INodeType { async getSounds(this: ILoadOptionsFunctions): Promise { const { sounds } = await pushoverApiRequest.call(this, 'GET', '/sounds.json', {}); const returnData: INodePropertyOptions[] = []; - for (const key of Object.keys(sounds)) { + for (const key of Object.keys(sounds as IDataObject)) { returnData.push({ name: sounds[key], value: key, @@ -373,7 +373,7 @@ export class Pushover implements INodeType { responseData = await pushoverApiRequest.call(this, 'POST', '/messages.json', body); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/QuickBase/GenericFunctions.ts b/packages/nodes-base/nodes/QuickBase/GenericFunctions.ts index 72bdbdbcb3..448d762c36 100644 --- a/packages/nodes-base/nodes/QuickBase/GenericFunctions.ts +++ b/packages/nodes-base/nodes/QuickBase/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { IWebhookFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; export async function quickbaseApiRequest( @@ -44,7 +44,7 @@ export async function quickbaseApiRequest( json: true, }; - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } @@ -55,16 +55,16 @@ export async function quickbaseApiRequest( if (Object.keys(option).length !== 0) { Object.assign(options, option); } - //@ts-ignore + return await this.helpers?.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } //@ts-ignore // prettier-ignore -export async function getFieldsObject(this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, tableId: string): any { +export async function getFieldsObject(this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, tableId: string): any { const fieldsLabelKey: { [key: string]: number } = {}; const fieldsIdKey: { [key: number]: string } = {}; const data = await quickbaseApiRequest.call(this, 'GET', '/fields', {}, { tableId }); @@ -116,7 +116,7 @@ export async function quickbaseApiRequestAllItems( for (const record of data) { const recordData: IDataObject = {}; - for (const [key, value] of Object.entries(record)) { + for (const [key, value] of Object.entries(record as IDataObject)) { recordData[fieldsIdKey[key]] = (value as IDataObject).value; } responseData.push(recordData); diff --git a/packages/nodes-base/nodes/QuickBase/QuickBase.node.ts b/packages/nodes-base/nodes/QuickBase/QuickBase.node.ts index 1a971d017c..d24241e693 100644 --- a/packages/nodes-base/nodes/QuickBase/QuickBase.node.ts +++ b/packages/nodes-base/nodes/QuickBase/QuickBase.node.ts @@ -149,7 +149,7 @@ export class QuickBase implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -176,7 +176,7 @@ export class QuickBase implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -220,7 +220,7 @@ export class QuickBase implements INodeType { ); //content-disposition': 'attachment; filename="dog-puppy-on-garden-royalty-free-image-1586966191.jpg"', - const contentDisposition = responseData.headers['content-disposition']; + const contentDisposition: string = responseData.headers['content-disposition']; const data = Buffer.from(responseData.body as string, 'base64'); @@ -287,7 +287,7 @@ export class QuickBase implements INodeType { for (const record of records) { const recordData: IDataObject = {}; - for (const [key, value] of Object.entries(record)) { + for (const [key, value] of Object.entries(record as IDataObject)) { recordData[key] = (value as IDataObject).value; } responseData.push(recordData); @@ -295,7 +295,7 @@ export class QuickBase implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: 0 } }, ); @@ -316,7 +316,7 @@ export class QuickBase implements INodeType { responseData = await quickbaseApiRequest.call(this, 'DELETE', '/records', body); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -374,14 +374,14 @@ export class QuickBase implements INodeType { for (const record of records) { const data: IDataObject = {}; - for (const [key, value] of Object.entries(record)) { + for (const [key, value] of Object.entries(record as IDataObject)) { data[fieldsIdKey[key]] = (value as IDataObject).value; } responseData.push(data); } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -457,7 +457,7 @@ export class QuickBase implements INodeType { for (const record of records) { const recordData: IDataObject = {}; - for (const [key, value] of Object.entries(record)) { + for (const [key, value] of Object.entries(record as IDataObject)) { recordData[fieldsIdKey[key]] = (value as IDataObject).value; } responseData.push(recordData); @@ -465,7 +465,7 @@ export class QuickBase implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: 0 } }, ); @@ -540,7 +540,7 @@ export class QuickBase implements INodeType { for (const record of records) { const recordData: IDataObject = {}; - for (const [key, value] of Object.entries(record)) { + for (const [key, value] of Object.entries(record as IDataObject)) { recordData[key] = (value as IDataObject).value; } responseData.push(recordData); @@ -548,7 +548,7 @@ export class QuickBase implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: 0 } }, ); @@ -597,7 +597,7 @@ export class QuickBase implements INodeType { for (const record of records) { const data: IDataObject = {}; - for (const [key, value] of Object.entries(record)) { + for (const [key, value] of Object.entries(record as IDataObject)) { data[fieldsIdKey[key]] = (value as IDataObject).value; } responseData.push(data); @@ -605,7 +605,7 @@ export class QuickBase implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); @@ -630,7 +630,7 @@ export class QuickBase implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/QuickBooks/GenericFunctions.ts b/packages/nodes-base/nodes/QuickBooks/GenericFunctions.ts index 781018b126..6cdce05641 100644 --- a/packages/nodes-base/nodes/QuickBooks/GenericFunctions.ts +++ b/packages/nodes-base/nodes/QuickBooks/GenericFunctions.ts @@ -5,6 +5,7 @@ import type { ILoadOptionsFunctions, INodeExecutionData, INodePropertyOptions, + JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -87,7 +88,7 @@ export async function quickBooksApiRequest( try { return await this.helpers.requestOAuth2.call(this, 'quickBooksOAuth2Api', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -132,9 +133,9 @@ export async function quickBooksApiRequestAllItems( try { const nonResource = originalQuery.split(' ')?.pop(); if (nonResource === 'CreditMemo' || nonResource === 'Term' || nonResource === 'TaxCode') { - returnData.push(...responseData.QueryResponse[nonResource]); + returnData.push(...(responseData.QueryResponse[nonResource] as IDataObject[])); } else { - returnData.push(...responseData.QueryResponse[capitalCase(resource)]); + returnData.push(...(responseData.QueryResponse[capitalCase(resource)] as IDataObject[])); } } catch (error) { return []; @@ -235,7 +236,7 @@ export async function handleBinaryData( const data = await quickBooksApiRequest.call(this, 'GET', endpoint, {}, {}, { encoding: null }); items[i].binary = items[i].binary ?? {}; - items[i].binary![binaryProperty] = await this.helpers.prepareBinaryData(data); + items[i].binary![binaryProperty] = await this.helpers.prepareBinaryData(data as Buffer); items[i].binary![binaryProperty].fileName = fileName; items[i].binary![binaryProperty].fileExtension = 'pdf'; diff --git a/packages/nodes-base/nodes/QuickBooks/QuickBooks.node.ts b/packages/nodes-base/nodes/QuickBooks/QuickBooks.node.ts index 6995be6889..71adde2baf 100644 --- a/packages/nodes-base/nodes/QuickBooks/QuickBooks.node.ts +++ b/packages/nodes-base/nodes/QuickBooks/QuickBooks.node.ts @@ -50,7 +50,7 @@ import { capitalCase } from 'change-case'; import isEmpty from 'lodash.isempty'; -import type { QuickBooksOAuth2Credentials, TransactionFields } from './types'; +import type { QuickBooksOAuth2Credentials, TransactionFields, TransactionReport } from './types'; export class QuickBooks implements INodeType { description: INodeTypeDescription = { @@ -1046,12 +1046,12 @@ export class QuickBooks implements INodeType { const simplifyResponse = this.getNodeParameter('simple', i, true) as boolean; - if (!Object.keys(responseData?.Rows).length) { + if (!Object.keys(responseData?.Rows as IDataObject).length) { responseData = []; } if (simplifyResponse && !Array.isArray(responseData)) { - responseData = simplifyTransactionReport(responseData); + responseData = simplifyTransactionReport(responseData as TransactionReport); } } } else if (resource === 'vendor') { @@ -1148,7 +1148,7 @@ export class QuickBooks implements INodeType { throw error; } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); @@ -1162,7 +1162,7 @@ export class QuickBooks implements INodeType { ['get'].includes(operation) && download ) { - return this.prepareOutputData(responseData); + return this.prepareOutputData(responseData as INodeExecutionData[]); } else { return this.prepareOutputData(returnData); } diff --git a/packages/nodes-base/nodes/Raindrop/GenericFunctions.ts b/packages/nodes-base/nodes/Raindrop/GenericFunctions.ts index 8f69a3a81b..8ac15e6131 100644 --- a/packages/nodes-base/nodes/Raindrop/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Raindrop/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import type { IDataObject, ILoadOptionsFunctions } from 'n8n-workflow'; +import type { IDataObject, ILoadOptionsFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import type { OptionsWithUri } from 'request'; @@ -45,6 +45,6 @@ export async function raindropApiRequest( includeCredentialsOnRefreshOnBody: true, }); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Raindrop/Raindrop.node.ts b/packages/nodes-base/nodes/Raindrop/Raindrop.node.ts index 1af43d719d..956ded4f7f 100644 --- a/packages/nodes-base/nodes/Raindrop/Raindrop.node.ts +++ b/packages/nodes-base/nodes/Raindrop/Raindrop.node.ts @@ -430,8 +430,8 @@ export class Raindrop implements INodeType { } Array.isArray(responseData) - ? returnData.push(...responseData) - : returnData.push(responseData); + ? returnData.push(...(responseData as IDataObject[])) + : returnData.push(responseData as IDataObject); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); diff --git a/packages/nodes-base/nodes/Reddit/GenericFunctions.ts b/packages/nodes-base/nodes/Reddit/GenericFunctions.ts index 8465f71c07..8137433b2b 100644 --- a/packages/nodes-base/nodes/Reddit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Reddit/GenericFunctions.ts @@ -76,11 +76,15 @@ export async function redditApiRequestAllItems( } if (endpoint === 'api/search_subreddits.json') { - responseData.subreddits.forEach((child: any) => returnData.push(child)); + responseData.subreddits.forEach((child: any) => returnData.push(child as IDataObject)); } else if (resource === 'postComment' && operation === 'getAll') { - responseData[1].data.children.forEach((child: any) => returnData.push(child.data)); + responseData[1].data.children.forEach((child: any) => + returnData.push(child.data as IDataObject), + ); } else { - responseData.data.children.forEach((child: any) => returnData.push(child.data)); + responseData.data.children.forEach((child: any) => + returnData.push(child.data as IDataObject), + ); } if (qs.limit && returnData.length >= qs.limit && !returnAll) { return returnData; diff --git a/packages/nodes-base/nodes/Reddit/Reddit.node.ts b/packages/nodes-base/nodes/Reddit/Reddit.node.ts index 306fa9fc20..6ca92747cf 100644 --- a/packages/nodes-base/nodes/Reddit/Reddit.node.ts +++ b/packages/nodes-base/nodes/Reddit/Reddit.node.ts @@ -5,6 +5,7 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -321,12 +322,12 @@ export class Reddit implements INodeType { } else if (details === 'friends') { responseData = responseData.data.children; if (!responseData.length) { - throw new NodeApiError(this.getNode(), responseData); + throw new NodeApiError(this.getNode(), responseData as JsonObject); } } else if (details === 'karma') { responseData = responseData.data; if (!responseData.length) { - throw new NodeApiError(this.getNode(), responseData); + throw new NodeApiError(this.getNode(), responseData as JsonObject); } } else if (details === 'trophies') { responseData = responseData.data.trophies.map((trophy: IDataObject) => trophy.data); @@ -422,7 +423,7 @@ export class Reddit implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as JsonObject), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Rocketchat/GenericFunctions.ts b/packages/nodes-base/nodes/Rocketchat/GenericFunctions.ts index 079b911b42..06b2d81842 100644 --- a/packages/nodes-base/nodes/Rocketchat/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Rocketchat/GenericFunctions.ts @@ -1,6 +1,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; +import type { IDataObject } from 'n8n-workflow'; export async function rocketchatApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, @@ -20,7 +21,7 @@ export async function rocketchatApiRequest( uri: `${credentials.domain}/api/v1${resource}.${operation}`, json: true, }; - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } return this.helpers.requestWithAuthentication.call(this, 'rocketchatApi', options); diff --git a/packages/nodes-base/nodes/Rocketchat/Rocketchat.node.ts b/packages/nodes-base/nodes/Rocketchat/Rocketchat.node.ts index 842fb92505..6a28fab700 100644 --- a/packages/nodes-base/nodes/Rocketchat/Rocketchat.node.ts +++ b/packages/nodes-base/nodes/Rocketchat/Rocketchat.node.ts @@ -479,7 +479,7 @@ export class Rocketchat implements INodeType { } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/RssFeedRead/RssFeedRead.node.ts b/packages/nodes-base/nodes/RssFeedRead/RssFeedRead.node.ts index a400369be9..5fe3cb70a7 100644 --- a/packages/nodes-base/nodes/RssFeedRead/RssFeedRead.node.ts +++ b/packages/nodes-base/nodes/RssFeedRead/RssFeedRead.node.ts @@ -72,7 +72,7 @@ export class RssFeedRead implements INodeType { ); } - throw new NodeOperationError(this.getNode(), error); + throw new NodeOperationError(this.getNode(), error as Error); } const returnData: IDataObject[] = []; @@ -80,7 +80,6 @@ export class RssFeedRead implements INodeType { // For now we just take the items and ignore everything else if (feed.items) { feed.items.forEach((item) => { - // @ts-ignore returnData.push(item); }); } diff --git a/packages/nodes-base/nodes/Rundeck/RundeckApi.ts b/packages/nodes-base/nodes/Rundeck/RundeckApi.ts index 670e2d1131..bc86f7567c 100644 --- a/packages/nodes-base/nodes/Rundeck/RundeckApi.ts +++ b/packages/nodes-base/nodes/Rundeck/RundeckApi.ts @@ -1,6 +1,6 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; export interface RundeckCredentials { @@ -36,7 +36,7 @@ export class RundeckApi { options, ); } catch (error) { - throw new NodeApiError(this.executeFunctions.getNode(), error); + throw new NodeApiError(this.executeFunctions.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/S3/GenericFunctions.ts b/packages/nodes-base/nodes/S3/GenericFunctions.ts index e08b53a580..0afe0d4b16 100644 --- a/packages/nodes-base/nodes/S3/GenericFunctions.ts +++ b/packages/nodes-base/nodes/S3/GenericFunctions.ts @@ -14,7 +14,7 @@ import type { IWebhookFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; import { URL } from 'url'; @@ -92,7 +92,7 @@ export async function s3ApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -119,7 +119,7 @@ export async function s3ApiRequestREST( region, ); try { - return JSON.parse(response); + return JSON.parse(response as string); } catch (error) { return response; } @@ -149,7 +149,7 @@ export async function s3ApiRequestSOAP( ); try { return await new Promise((resolve, reject) => { - parseString(response, { explicitArray: false }, (err, data) => { + parseString(response as string, { explicitArray: false }, (err, data) => { if (err) { return reject(err); } @@ -199,9 +199,9 @@ export async function s3ApiRequestSOAPAllItems( } if (get(responseData, propertyName)) { if (Array.isArray(get(responseData, propertyName))) { - returnData.push.apply(returnData, get(responseData, propertyName)); + returnData.push.apply(returnData, get(responseData, propertyName) as IDataObject[]); } else { - returnData.push(get(responseData, propertyName)); + returnData.push(get(responseData, propertyName) as IDataObject); } } if (query.limit && query.limit <= returnData.length) { diff --git a/packages/nodes-base/nodes/S3/S3.node.ts b/packages/nodes-base/nodes/S3/S3.node.ts index 341efa1e0d..896ac5d36a 100644 --- a/packages/nodes-base/nodes/S3/S3.node.ts +++ b/packages/nodes-base/nodes/S3/S3.node.ts @@ -12,6 +12,7 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -96,7 +97,7 @@ export class S3 implements INodeType { try { credentials = await this.getCredentials('s3'); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } const name = this.getNodeParameter('name', i) as string; @@ -186,7 +187,7 @@ export class S3 implements INodeType { responseData = responseData.slice(0, qs.limit); } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -260,7 +261,7 @@ export class S3 implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -305,7 +306,7 @@ export class S3 implements INodeType { qs, headers, {}, - region, + region as string, ); const executionData = this.helpers.constructExecutionMetaData( this.helpers.returnJsonArray({ success: true }), @@ -335,7 +336,7 @@ export class S3 implements INodeType { { 'list-type': 2, prefix: folderKey }, {}, {}, - region, + region as string, ); // folder empty then just delete it @@ -349,7 +350,7 @@ export class S3 implements INodeType { qs, {}, {}, - region, + region as string, ); responseData = { deleted: [{ Key: folderKey }] }; @@ -387,7 +388,7 @@ export class S3 implements INodeType { { delete: '' }, headers, {}, - region, + region as string, ); responseData = { deleted: responseData.DeleteResult.Deleted }; @@ -432,7 +433,7 @@ export class S3 implements INodeType { qs, {}, {}, - region, + region as string, ); } else { qs.limit = this.getNodeParameter('limit', 0); @@ -446,7 +447,7 @@ export class S3 implements INodeType { qs, {}, {}, - region, + region as string, ); } if (Array.isArray(responseData)) { @@ -460,7 +461,7 @@ export class S3 implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -568,10 +569,10 @@ export class S3 implements INodeType { qs, headers, {}, - region, + region as string, ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData.CopyObjectResult), + this.helpers.returnJsonArray(responseData.CopyObjectResult as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -607,7 +608,7 @@ export class S3 implements INodeType { qs, {}, { encoding: null, resolveWithFullResponse: true }, - region, + region as string, ); let mimeType: string | undefined; @@ -666,7 +667,7 @@ export class S3 implements INodeType { qs, {}, {}, - region, + region as string, ); const executionData = this.helpers.constructExecutionMetaData( @@ -711,7 +712,7 @@ export class S3 implements INodeType { qs, {}, {}, - region, + region as string, ); } else { qs.limit = this.getNodeParameter('limit', 0); @@ -725,7 +726,7 @@ export class S3 implements INodeType { qs, {}, {}, - region, + region as string, ); responseData = responseData.splice(0, qs.limit); } @@ -739,7 +740,7 @@ export class S3 implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -867,7 +868,7 @@ export class S3 implements INodeType { qs, headers, {}, - region, + region as string, ); } else { const fileContent = this.getNodeParameter('fileContent', i) as string; @@ -887,7 +888,7 @@ export class S3 implements INodeType { qs, headers, {}, - region, + region as string, ); } diff --git a/packages/nodes-base/nodes/Salesforce/GenericFunctions.ts b/packages/nodes-base/nodes/Salesforce/GenericFunctions.ts index aed08d1922..28741b4c00 100644 --- a/packages/nodes-base/nodes/Salesforce/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Salesforce/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject, INodePropertyOptions } from 'n8n-workflow'; +import type { IDataObject, INodePropertyOptions, JsonObject } from 'n8n-workflow'; import { LoggerProxy as Logger, NodeApiError } from 'n8n-workflow'; import moment from 'moment-timezone'; @@ -29,11 +29,10 @@ function getOptions( json: true, }; - if (!Object.keys(options.body).length) { + if (!Object.keys(options.body as IDataObject).length) { delete options.body; } - //@ts-ignore return options; } @@ -130,11 +129,11 @@ export async function salesforceApiRequest( `Authentication for "Salesforce" node is using "OAuth2". Invoking URI ${options.uri}`, ); Object.assign(options, option); - //@ts-ignore + return await this.helpers.requestOAuth2.call(this, credentialsType, options); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -155,7 +154,7 @@ export async function salesforceApiRequestAllItems( do { responseData = await salesforceApiRequest.call(this, method, endpoint, body, query, uri); uri = `${endpoint}/${responseData.nextRecordsUrl?.split('/')?.pop()}`; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.nextRecordsUrl !== undefined && responseData.nextRecordsUrl !== null); return returnData; @@ -178,7 +177,7 @@ export function sortOptions(options: INodePropertyOptions[]): void { } export function getValue(value: any) { - if (moment(value).isValid()) { + if (moment(value as string).isValid()) { return value; } else if (typeof value === 'string') { return `'${value}'`; diff --git a/packages/nodes-base/nodes/Salesforce/Salesforce.node.ts b/packages/nodes-base/nodes/Salesforce/Salesforce.node.ts index 5e647ab411..95997fcd7d 100644 --- a/packages/nodes-base/nodes/Salesforce/Salesforce.node.ts +++ b/packages/nodes-base/nodes/Salesforce/Salesforce.node.ts @@ -7,6 +7,7 @@ import type { INodePropertyOptions, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { LoggerProxy as Logger, NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -1158,8 +1159,7 @@ export class Salesforce implements INodeType { .customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { - //@ts-ignore - body[customField.fieldId] = customField.value; + body[customField.fieldId as string] = customField.value; } } } @@ -1271,8 +1271,7 @@ export class Salesforce implements INodeType { .customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { - //@ts-ignore - body[customField.fieldId] = customField.value; + body[customField.fieldId as string] = customField.value; } } } @@ -1316,7 +1315,7 @@ export class Salesforce implements INodeType { ); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } //https://developer.salesforce.com/docs/api-explorer/sobject/Lead/delete-lead-id @@ -1329,7 +1328,7 @@ export class Salesforce implements INodeType { `/sobjects/lead/${leadId}`, ); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } //https://developer.salesforce.com/docs/api-explorer/sobject/Lead/get-lead @@ -1482,8 +1481,7 @@ export class Salesforce implements INodeType { .customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { - //@ts-ignore - body[customField.fieldId] = customField.value; + body[customField.fieldId as string] = customField.value; } } } @@ -1613,8 +1611,7 @@ export class Salesforce implements INodeType { .customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { - //@ts-ignore - body[customField.fieldId] = customField.value; + body[customField.fieldId as string] = customField.value; } } } @@ -1662,7 +1659,7 @@ export class Salesforce implements INodeType { ); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } //https://developer.salesforce.com/docs/api-explorer/sobject/Contact/delete-contact-id @@ -1675,7 +1672,7 @@ export class Salesforce implements INodeType { `/sobjects/contact/${contactId}`, ); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } //https://developer.salesforce.com/docs/api-explorer/sobject/Contact/get-contact @@ -1733,8 +1730,7 @@ export class Salesforce implements INodeType { const customFields = customFieldsUi.customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { - //@ts-ignore - body[customField.fieldId] = customField.value; + body[customField.fieldId as string] = customField.value; } } } @@ -1767,8 +1763,7 @@ export class Salesforce implements INodeType { const customFields = customFieldsUi.customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { - //@ts-ignore - body[customField.fieldId] = customField.value; + body[customField.fieldId as string] = customField.value; } } } @@ -1816,7 +1811,7 @@ export class Salesforce implements INodeType { ); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } if (operation === 'delete') { @@ -1829,7 +1824,7 @@ export class Salesforce implements INodeType { `/sobjects/${customObject}/${recordId}`, ); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } } @@ -1942,8 +1937,7 @@ export class Salesforce implements INodeType { .customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { - //@ts-ignore - body[customField.fieldId] = customField.value; + body[customField.fieldId as string] = customField.value; } } } @@ -2012,8 +2006,7 @@ export class Salesforce implements INodeType { .customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { - //@ts-ignore - body[customField.fieldId] = customField.value; + body[customField.fieldId as string] = customField.value; } } } @@ -2061,7 +2054,7 @@ export class Salesforce implements INodeType { ); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } //https://developer.salesforce.com/docs/api-explorer/sobject/Opportunity/delete-opportunity-id @@ -2074,7 +2067,7 @@ export class Salesforce implements INodeType { `/sobjects/opportunity/${opportunityId}`, ); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } //https://developer.salesforce.com/docs/api-explorer/sobject/Opportunity/get-opportunity @@ -2193,8 +2186,7 @@ export class Salesforce implements INodeType { .customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { - //@ts-ignore - body[customField.fieldId] = customField.value; + body[customField.fieldId as string] = customField.value; } } } @@ -2302,8 +2294,7 @@ export class Salesforce implements INodeType { .customFieldsValues as IDataObject[]; if (customFields) { for (const customField of customFields) { - //@ts-ignore - body[customField.fieldId] = customField.value; + body[customField.fieldId as string] = customField.value; } } } @@ -2351,7 +2342,7 @@ export class Salesforce implements INodeType { ); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } //https://developer.salesforce.com/docs/api-explorer/sobject/Account/delete-account-id @@ -2364,7 +2355,7 @@ export class Salesforce implements INodeType { `/sobjects/account/${accountId}`, ); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } //https://developer.salesforce.com/docs/api-explorer/sobject/Account/get-account @@ -2454,7 +2445,7 @@ export class Salesforce implements INodeType { if (customFields) { for (const customField of customFields) { //@ts-ignore - body[customField.fieldId] = customField.value; + body[customField.fieldId as string] = customField.value; } } } @@ -2566,7 +2557,7 @@ export class Salesforce implements INodeType { ); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } //https://developer.salesforce.com/docs/api-explorer/sobject/Case/delete-case-id @@ -2579,7 +2570,7 @@ export class Salesforce implements INodeType { `/sobjects/case/${caseId}`, ); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } //https://developer.salesforce.com/docs/api-explorer/sobject/Case/get-case @@ -2829,7 +2820,7 @@ export class Salesforce implements INodeType { ); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } //https://developer.salesforce.com/docs/api-explorer/sobject/Task/delete-task-id @@ -2842,7 +2833,7 @@ export class Salesforce implements INodeType { `/sobjects/task/${taskId}`, ); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } //https://developer.salesforce.com/docs/api-explorer/sobject/Task/get-task @@ -2961,7 +2952,7 @@ export class Salesforce implements INodeType { ); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } //https://developer.salesforce.com/docs/api-explorer/sobject/Attachment/delete-attachment-id @@ -2974,7 +2965,7 @@ export class Salesforce implements INodeType { `/sobjects/attachment/${attachmentId}`, ); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } //https://developer.salesforce.com/docs/api-explorer/sobject/Attachment/get-attachment-id @@ -3016,7 +3007,7 @@ export class Salesforce implements INodeType { ); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } } @@ -3084,7 +3075,7 @@ export class Salesforce implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Salesmate/GenericFunctions.ts b/packages/nodes-base/nodes/Salesmate/GenericFunctions.ts index c650b40ac3..e1d5926f88 100644 --- a/packages/nodes-base/nodes/Salesmate/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Salesmate/GenericFunctions.ts @@ -6,7 +6,8 @@ import type { ILoadOptionsFunctions, IWebhookFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; + +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function salesmateApiRequest( @@ -38,13 +39,13 @@ export async function salesmateApiRequest( uri: uri || `https://apis.salesmate.io${resource}`, json: true, }; - if (!Object.keys(body).length) { + if (!Object.keys(body as IDataObject).length) { delete options.body; } try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -64,7 +65,7 @@ export async function salesmateApiRequestAllItems( query.rows = 25; do { responseData = await salesmateApiRequest.call(this, method, resource, body, query); - returnData.push.apply(returnData, responseData[propertyName].data); + returnData.push.apply(returnData, responseData[propertyName].data as IDataObject[]); query.pageNo++; } while ( responseData[propertyName].totalPages !== undefined && diff --git a/packages/nodes-base/nodes/Salesmate/Salesmate.node.ts b/packages/nodes-base/nodes/Salesmate/Salesmate.node.ts index e7898cd576..ed8aa56bcc 100644 --- a/packages/nodes-base/nodes/Salesmate/Salesmate.node.ts +++ b/packages/nodes-base/nodes/Salesmate/Salesmate.node.ts @@ -281,7 +281,7 @@ export class Salesmate implements INodeType { responseData = responseData.Data; if (!rawData) { - responseData = simplifySalesmateData(responseData); + responseData = simplifySalesmateData(responseData as IDataObject[]); } } if (operation === 'getAll') { @@ -473,7 +473,7 @@ export class Salesmate implements INodeType { responseData = responseData.Data; if (!rawData) { - responseData = simplifySalesmateData(responseData); + responseData = simplifySalesmateData(responseData as IDataObject[]); } } if (operation === 'getAll') { @@ -683,7 +683,7 @@ export class Salesmate implements INodeType { responseData = responseData.Data; if (!rawData) { - responseData = simplifySalesmateData(responseData); + responseData = simplifySalesmateData(responseData as IDataObject[]); } } if (operation === 'getAll') { @@ -782,7 +782,7 @@ export class Salesmate implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts b/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts index c876995c98..543c968778 100644 --- a/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SeaTable/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { IExecuteFunctions } from 'n8n-core'; import type { OptionsWithUri } from 'request'; -import type { IDataObject, ILoadOptionsFunctions, IPollFunctions } from 'n8n-workflow'; +import type { IDataObject, ILoadOptionsFunctions, IPollFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import type { TDtableMetadataColumns, TDtableViewColumns, TEndpointVariableName } from './types'; @@ -97,7 +97,7 @@ export async function seaTableApiRequest( json: true, }; - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } @@ -108,7 +108,7 @@ export async function seaTableApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -142,7 +142,7 @@ export async function setableApiRequestAllItems( query, )) as unknown as IRow[]; //@ts-ignore - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); query.start = +query.start + segment; } while (responseData && responseData.length > segment - 1); @@ -280,7 +280,7 @@ function rowFormatColumn(input: unknown): boolean | number | string | string[] | return input; } else if (Array.isArray(input) && input.every((i) => typeof i === 'object')) { const returnItems = [] as string[]; - input.every((i) => returnItems.push(i.display_value)); + input.every((i) => returnItems.push(i.display_value as string)); return returnItems; } diff --git a/packages/nodes-base/nodes/SeaTable/SeaTable.node.ts b/packages/nodes-base/nodes/SeaTable/SeaTable.node.ts index 8bcc91875e..dac8668c7b 100644 --- a/packages/nodes-base/nodes/SeaTable/SeaTable.node.ts +++ b/packages/nodes-base/nodes/SeaTable/SeaTable.node.ts @@ -200,7 +200,7 @@ export class SeaTable implements INodeType { ); } - const newRowInsertData = rowMapKeyToName(responseData, tableColumns); + const newRowInsertData = rowMapKeyToName(responseData as IRow, tableColumns); qs.table_name = tableName; qs.convert = true; @@ -208,7 +208,9 @@ export class SeaTable implements INodeType { this, ctx, 'GET', - `/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/${encodeURIComponent(insertId)}/`, + `/dtable-server/api/v1/dtables/{{dtable_uuid}}/rows/${encodeURIComponent( + insertId as string, + )}/`, body, qs, ); @@ -222,7 +224,7 @@ export class SeaTable implements INodeType { } const row = rowFormatColumns( - { ...newRowInsertData, ...newRow }, + { ...newRowInsertData, ...(newRow as IRow) }, tableColumns.map(({ name }) => name).concat(['_id', '_ctime', '_mtime']), ); @@ -322,7 +324,7 @@ export class SeaTable implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(rows), + this.helpers.returnJsonArray(rows as IDataObject[]), { itemData: { item: i } }, ); @@ -424,7 +426,7 @@ export class SeaTable implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray({ _id: rowId, ...responseData }), + this.helpers.returnJsonArray({ _id: rowId, ...(responseData as IDataObject) }), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/SecurityScorecard/GenericFunctions.ts b/packages/nodes-base/nodes/SecurityScorecard/GenericFunctions.ts index 3c5750f995..0d1e3da992 100644 --- a/packages/nodes-base/nodes/SecurityScorecard/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SecurityScorecard/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function scorecardApiRequest( @@ -32,7 +32,7 @@ export async function scorecardApiRequest( options = Object.assign({}, options, option); } - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } @@ -42,7 +42,7 @@ export async function scorecardApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/SecurityScorecard/SecurityScorecard.node.ts b/packages/nodes-base/nodes/SecurityScorecard/SecurityScorecard.node.ts index 7c17845fd6..fe339a2add 100644 --- a/packages/nodes-base/nodes/SecurityScorecard/SecurityScorecard.node.ts +++ b/packages/nodes-base/nodes/SecurityScorecard/SecurityScorecard.node.ts @@ -353,7 +353,7 @@ export class SecurityScorecard implements INodeType { } if (simple) { - responseData = simplify(responseData); + responseData = simplify(responseData as IDataObject[]); } returnData.push.apply(returnData, responseData as IDataObject[]); @@ -387,7 +387,7 @@ export class SecurityScorecard implements INodeType { } if (simple) { - responseData = simplify(responseData); + responseData = simplify(responseData as IDataObject[]); } returnData.push.apply(returnData, responseData as IDataObject[]); @@ -456,7 +456,7 @@ export class SecurityScorecard implements INodeType { } if (simple) { - responseData = simplify(responseData); + responseData = simplify(responseData as IDataObject[]); } returnData.push.apply(returnData, responseData as IDataObject[]); @@ -492,7 +492,7 @@ export class SecurityScorecard implements INodeType { } if (simple) { - responseData = simplify(responseData); + responseData = simplify(responseData as IDataObject[]); } returnData.push.apply(returnData, responseData as IDataObject[]); diff --git a/packages/nodes-base/nodes/Segment/GenericFunctions.ts b/packages/nodes-base/nodes/Segment/GenericFunctions.ts index c5b32555d5..8d977cd44d 100644 --- a/packages/nodes-base/nodes/Segment/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Segment/GenericFunctions.ts @@ -32,7 +32,7 @@ export async function segmentApiRequest( uri: uri || `https://api.segment.io/v1${resource}`, json: true, }; - if (!Object.keys(body).length) { + if (!Object.keys(body as IDataObject).length) { delete options.body; } return this.helpers.requestWithAuthentication.call(this, 'segmentApi', options); diff --git a/packages/nodes-base/nodes/SendGrid/GenericFunctions.ts b/packages/nodes-base/nodes/SendGrid/GenericFunctions.ts index c91f5e17f1..8b692dc488 100644 --- a/packages/nodes-base/nodes/SendGrid/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SendGrid/GenericFunctions.ts @@ -28,7 +28,7 @@ export async function sendGridApiRequest( json: true, }; - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } @@ -55,9 +55,10 @@ export async function sendGridApiRequestAllItems( let uri; do { - responseData = await sendGridApiRequest.call(this, endpoint, method, body, query, uri); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument + responseData = await sendGridApiRequest.call(this, endpoint, method, body, query, uri); // posible bug, as function does not have uri parameter uri = responseData._metadata.next; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); if (query.limit && returnData.length >= query.limit) { return returnData; } diff --git a/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts b/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts index e62454e2b9..09e8769da1 100644 --- a/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts +++ b/packages/nodes-base/nodes/SendGrid/SendGrid.node.ts @@ -169,7 +169,7 @@ export class SendGrid implements INodeType { responseData = responseData.splice(0, limit); } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -210,7 +210,7 @@ export class SendGrid implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -305,7 +305,7 @@ export class SendGrid implements INodeType { { list_ids: lists, contacts }, qs, ); - returnData.push(responseData); + returnData.push(responseData as INodeExecutionData); } catch (error) { if (this.continueOnFail()) { returnData.push({ json: { error: error.message } }); @@ -331,7 +331,7 @@ export class SendGrid implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -368,7 +368,7 @@ export class SendGrid implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -399,7 +399,7 @@ export class SendGrid implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -429,7 +429,7 @@ export class SendGrid implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -490,7 +490,7 @@ export class SendGrid implements INodeType { qs, ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/SendInBlue/GenericFunctions.ts b/packages/nodes-base/nodes/SendInBlue/GenericFunctions.ts index 61519aef7e..5465ff99d4 100644 --- a/packages/nodes-base/nodes/SendInBlue/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SendInBlue/GenericFunctions.ts @@ -121,7 +121,7 @@ export namespace SendInBlueNode { return requestOptions; } catch (err) { - throw new NodeOperationError(this.getNode(), err); + throw new NodeOperationError(this.getNode(), err as Error); } } @@ -367,7 +367,7 @@ export namespace SendInBlueWebhookApi { options, ); - return jsonParse(webhookId); + return jsonParse(webhookId as string); }; export const deleteWebhook = async (ref: IHookFunctions, webhookId: string) => { diff --git a/packages/nodes-base/nodes/Sendy/GenericFunctions.ts b/packages/nodes-base/nodes/Sendy/GenericFunctions.ts index 8a574ddcd0..7766ecb2ad 100644 --- a/packages/nodes-base/nodes/Sendy/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Sendy/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function sendyApiRequest( @@ -31,9 +31,8 @@ export async function sendyApiRequest( }; try { - //@ts-ignore return await this.helpers.request.call(this, options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Sendy/Sendy.node.ts b/packages/nodes-base/nodes/Sendy/Sendy.node.ts index be45e56e3c..6064b1caa5 100644 --- a/packages/nodes-base/nodes/Sendy/Sendy.node.ts +++ b/packages/nodes-base/nodes/Sendy/Sendy.node.ts @@ -5,6 +5,7 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -141,10 +142,10 @@ export class Sendy implements INodeType { const success = ['Campaign created', 'Campaign created and now sending']; - if (success.includes(responseData)) { + if (success.includes(responseData as string)) { responseData = { message: responseData }; } else { - throw new NodeApiError(this.getNode(), responseData, { httpCode: '400' }); + throw new NodeApiError(this.getNode(), responseData as JsonObject, { httpCode: '400' }); } } } @@ -199,7 +200,7 @@ export class Sendy implements INodeType { 'List does not exist', ]; - if (!errors.includes(responseData)) { + if (!errors.includes(responseData as string)) { responseData = { count: responseData }; } else { throw new NodeOperationError( @@ -287,7 +288,7 @@ export class Sendy implements INodeType { 'Complained', ]; - if (status.includes(responseData)) { + if (status.includes(responseData as string)) { responseData = { status: responseData }; } else { throw new NodeOperationError( diff --git a/packages/nodes-base/nodes/SentryIo/GenericFunctions.ts b/packages/nodes-base/nodes/SentryIo/GenericFunctions.ts index f09bf720ea..133c4ced19 100644 --- a/packages/nodes-base/nodes/SentryIo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SentryIo/GenericFunctions.ts @@ -8,7 +8,7 @@ import type { IWebhookFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function sentryIoApiRequest( @@ -38,7 +38,7 @@ export async function sentryIoApiRequest( uri: uri || `https://sentry.io${resource}`, json: true, }; - if (!Object.keys(body).length) { + if (!Object.keys(body as IDataObject).length) { delete options.body; } @@ -70,13 +70,12 @@ export async function sentryIoApiRequest( Authorization: `Bearer ${credentials?.token}`, }; - //@ts-ignore return await this.helpers.request(options); } else { return await this.helpers.requestOAuth2.call(this, 'sentryIoOAuth2Api', options); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -121,12 +120,12 @@ export async function sentryApiRequestAllItems( resolveWithFullResponse: true, }); link = responseData.headers.link; - uri = getNext(link); - returnData.push.apply(returnData, responseData.body); + uri = getNext(link as string); + returnData.push.apply(returnData, responseData.body as IDataObject[]); if (query.limit && query.limit >= returnData.length) { return; } - } while (hasMore(link)); + } while (hasMore(link as string)); return returnData; } diff --git a/packages/nodes-base/nodes/SentryIo/SentryIo.node.ts b/packages/nodes-base/nodes/SentryIo/SentryIo.node.ts index 14e724ee2d..6d7f42361b 100644 --- a/packages/nodes-base/nodes/SentryIo/SentryIo.node.ts +++ b/packages/nodes-base/nodes/SentryIo/SentryIo.node.ts @@ -727,7 +727,7 @@ export class SentryIo implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/ServiceNow/GenericFunctions.ts b/packages/nodes-base/nodes/ServiceNow/GenericFunctions.ts index 5507f919fd..c564bf1055 100644 --- a/packages/nodes-base/nodes/ServiceNow/GenericFunctions.ts +++ b/packages/nodes-base/nodes/ServiceNow/GenericFunctions.ts @@ -34,7 +34,7 @@ export async function serviceNowApiRequest( uri: uri || `https://${credentials.subdomain}.service-now.com/api${resource}`, json: true, }; - if (!Object.keys(body).length) { + if (!Object.keys(body as IDataObject).length) { delete options.body; } @@ -73,7 +73,7 @@ export async function serviceNowRequestAllItems( responseData = await serviceNowApiRequest.call(this, method, resource, body, query, undefined, { resolveWithFullResponse: true, }); - returnData.push.apply(returnData, responseData.body.result); + returnData.push.apply(returnData, responseData.body.result as IDataObject[]); const quantity = responseData.headers['x-total-count']; const iterations = Math.round(quantity / page) + (quantity % page ? 1 : 0); @@ -85,7 +85,7 @@ export async function serviceNowRequestAllItems( resolveWithFullResponse: true, }); - returnData.push.apply(returnData, responseData.body.result); + returnData.push.apply(returnData, responseData.body.result as IDataObject[]); } return returnData; diff --git a/packages/nodes-base/nodes/ServiceNow/ServiceNow.node.ts b/packages/nodes-base/nodes/ServiceNow/ServiceNow.node.ts index 0c80b68095..c1f9f11491 100644 --- a/packages/nodes-base/nodes/ServiceNow/ServiceNow.node.ts +++ b/packages/nodes-base/nodes/ServiceNow/ServiceNow.node.ts @@ -536,8 +536,8 @@ export class ServiceNow implements INodeType { [outputField]: await serviceNowDownloadAttachment.call( this, endpoint, - fileMetadata.file_name, - fileMetadata.content_type, + fileMetadata.file_name as string, + fileMetadata.content_type as string, ), }, }; diff --git a/packages/nodes-base/nodes/Shopify/GenericFunctions.ts b/packages/nodes-base/nodes/Shopify/GenericFunctions.ts index 9a7aac1400..42fe31b940 100644 --- a/packages/nodes-base/nodes/Shopify/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Shopify/GenericFunctions.ts @@ -58,7 +58,7 @@ export async function shopifyApiRequest( if (Object.keys(option).length !== 0) { Object.assign(options, option); } - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } if (Object.keys(query).length === 0) { @@ -104,7 +104,7 @@ export async function shopifyApiRequestAllItems( if (responseData.headers.link) { uri = responseData.headers.link.split(';')[0].replace('<', '').replace('>', ''); } - returnData.push.apply(returnData, responseData.body[propertyName]); + returnData.push.apply(returnData, responseData.body[propertyName] as IDataObject[]); } while (responseData.headers.link?.includes('rel="next"')); return returnData; } diff --git a/packages/nodes-base/nodes/Shopify/Shopify.node.ts b/packages/nodes-base/nodes/Shopify/Shopify.node.ts index 13c1586561..ecef6c4cb6 100644 --- a/packages/nodes-base/nodes/Shopify/Shopify.node.ts +++ b/packages/nodes-base/nodes/Shopify/Shopify.node.ts @@ -454,7 +454,7 @@ export class Shopify implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Shopify/ShopifyTrigger.node.ts b/packages/nodes-base/nodes/Shopify/ShopifyTrigger.node.ts index a99f2a796e..f07642c0c2 100644 --- a/packages/nodes-base/nodes/Shopify/ShopifyTrigger.node.ts +++ b/packages/nodes-base/nodes/Shopify/ShopifyTrigger.node.ts @@ -330,7 +330,6 @@ export class ShopifyTrigger implements INodeType { ], }; - // @ts-ignore (because of request) webhookMethods = { default: { async checkExists(this: IHookFunctions): Promise { @@ -427,7 +426,7 @@ export class ShopifyTrigger implements INodeType { return {}; } return { - workflowData: [this.helpers.returnJsonArray(req.body)], + workflowData: [this.helpers.returnJsonArray(req.body as IDataObject)], }; } } diff --git a/packages/nodes-base/nodes/Signl4/GenericFunctions.ts b/packages/nodes-base/nodes/Signl4/GenericFunctions.ts index c74b787169..b4ea190af1 100644 --- a/packages/nodes-base/nodes/Signl4/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Signl4/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { IExecuteFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import type { OptionsWithUri } from 'request'; @@ -45,6 +45,6 @@ export async function SIGNL4ApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Slack/V1/GenericFunctions.ts b/packages/nodes-base/nodes/Slack/V1/GenericFunctions.ts index 8622542355..1c7be15513 100644 --- a/packages/nodes-base/nodes/Slack/V1/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Slack/V1/GenericFunctions.ts @@ -98,10 +98,10 @@ export async function slackApiRequestAllItems( query.limit = 100; } do { - responseData = await slackApiRequest.call(this, method, endpoint, body, query); + responseData = await slackApiRequest.call(this, method, endpoint, body as IDataObject, query); query.cursor = get(responseData, 'response_metadata.next_cursor'); query.page++; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while ( (responseData.response_metadata?.next_cursor !== undefined && responseData.response_metadata.next_cursor !== '' && diff --git a/packages/nodes-base/nodes/Slack/V1/SlackV1.node.ts b/packages/nodes-base/nodes/Slack/V1/SlackV1.node.ts index fc409eb6ae..cf97def17b 100644 --- a/packages/nodes-base/nodes/Slack/V1/SlackV1.node.ts +++ b/packages/nodes-base/nodes/Slack/V1/SlackV1.node.ts @@ -490,7 +490,7 @@ export class SlackV1 implements INodeType { {}, { user: member }, ); - data.push(user); + data.push(user as IDataObject); } responseData = data; } @@ -1380,7 +1380,7 @@ export class SlackV1 implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Slack/V2/GenericFunctions.ts b/packages/nodes-base/nodes/Slack/V2/GenericFunctions.ts index e43a9a8540..00780840c3 100644 --- a/packages/nodes-base/nodes/Slack/V2/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Slack/V2/GenericFunctions.ts @@ -104,12 +104,12 @@ export async function slackApiRequestAllItems( query.limit = 100; } do { - responseData = await slackApiRequest.call(this, method, endpoint, body, query); + responseData = await slackApiRequest.call(this, method, endpoint, body as IDataObject, query); query.cursor = get(responseData, 'response_metadata.next_cursor'); query.page++; returnData.push.apply( returnData, - responseData[propertyName].matches ?? responseData[propertyName], + (responseData[propertyName].matches as IDataObject[]) ?? responseData[propertyName], ); } while ( (responseData.response_metadata?.next_cursor !== undefined && diff --git a/packages/nodes-base/nodes/Slack/V2/SlackV2.node.ts b/packages/nodes-base/nodes/Slack/V2/SlackV2.node.ts index 0d0afcc2e1..da2dedff5f 100644 --- a/packages/nodes-base/nodes/Slack/V2/SlackV2.node.ts +++ b/packages/nodes-base/nodes/Slack/V2/SlackV2.node.ts @@ -587,7 +587,7 @@ export class SlackV2 implements INodeType { {}, { user: member }, ); - data.push(user); + data.push(user as IDataObject); } responseData = data; } @@ -1325,7 +1325,7 @@ export class SlackV2 implements INodeType { } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Sms77/GenericFunctions.ts b/packages/nodes-base/nodes/Sms77/GenericFunctions.ts index 49e47c3242..fe69007a6a 100644 --- a/packages/nodes-base/nodes/Sms77/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Sms77/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import type { OptionsWithUri } from 'request'; @@ -36,7 +36,7 @@ export async function sms77ApiRequest( const response = await this.helpers.requestWithAuthentication.call(this, 'sms77Api', options); if (response.success !== '100') { - throw new NodeApiError(this.getNode(), response, { + throw new NodeApiError(this.getNode(), response as JsonObject, { message: 'Invalid sms77 credentials or API error!', }); } diff --git a/packages/nodes-base/nodes/SplitInBatches/SplitInBatches.node.ts b/packages/nodes-base/nodes/SplitInBatches/SplitInBatches.node.ts index 5616b9ddee..3dfbce35eb 100644 --- a/packages/nodes-base/nodes/SplitInBatches/SplitInBatches.node.ts +++ b/packages/nodes-base/nodes/SplitInBatches/SplitInBatches.node.ts @@ -89,7 +89,10 @@ export class SplitInBatches implements INodeType { } else { // The node has been called before. So return the next batch of items. nodeContext.currentRunIndex += 1; - returnItems.push.apply(returnItems, nodeContext.items.splice(0, batchSize)); + returnItems.push.apply( + returnItems, + (nodeContext.items as INodeExecutionData[]).splice(0, batchSize), + ); const addSourceOverwrite = (pairedItem: IPairedItemData | number): IPairedItemData => { if (typeof pairedItem === 'number') { diff --git a/packages/nodes-base/nodes/Splunk/GenericFunctions.ts b/packages/nodes-base/nodes/Splunk/GenericFunctions.ts index b24aea42a3..7e6301a5cb 100644 --- a/packages/nodes-base/nodes/Splunk/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Splunk/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { IExecuteFunctions } from 'n8n-core'; -import type { IDataObject, ILoadOptionsFunctions } from 'n8n-workflow'; +import type { IDataObject, ILoadOptionsFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import type { OptionsWithUri } from 'request'; @@ -140,17 +140,17 @@ export async function splunkApiRequest( return await this.helpers.request(options).then(parseXml); } catch (error) { if (error?.cause?.code === 'ECONNREFUSED') { - throw new NodeApiError(this.getNode(), { ...error, code: 401 }); + throw new NodeApiError(this.getNode(), { ...(error as JsonObject), code: 401 }); } - const rawError = (await parseXml(error.error)) as SplunkError; + const rawError = (await parseXml(error.error as string)) as SplunkError; error = extractErrorDescription(rawError); if ('fatal' in error) { error = { error: error.fatal }; } - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Splunk/Splunk.node.ts b/packages/nodes-base/nodes/Splunk/Splunk.node.ts index f83f8fc40f..a7fe0fa3c8 100644 --- a/packages/nodes-base/nodes/Splunk/Splunk.node.ts +++ b/packages/nodes-base/nodes/Splunk/Splunk.node.ts @@ -464,7 +464,7 @@ export class Splunk implements INodeType { } Array.isArray(responseData) - ? returnData.push(...responseData) + ? returnData.push(...(responseData as IDataObject[])) : returnData.push(responseData as IDataObject); } diff --git a/packages/nodes-base/nodes/Spontit/GenericFunctions.ts b/packages/nodes-base/nodes/Spontit/GenericFunctions.ts index 509d1d0809..ddcbe5883a 100644 --- a/packages/nodes-base/nodes/Spontit/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Spontit/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { IWebhookFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function spontitApiRequest( @@ -17,7 +17,7 @@ export async function spontitApiRequest( body: any = {}, qs: IDataObject = {}, -): Promise { +) { const credentials = await this.getCredentials('spontitApi'); try { @@ -32,12 +32,12 @@ export async function spontitApiRequest( uri: `https://api.spontit.com/v3${resource}`, json: true, }; - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } - //@ts-ignore + return await this.helpers?.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Spotify/GenericFunctions.ts b/packages/nodes-base/nodes/Spotify/GenericFunctions.ts index 7c4ccc7107..b95025cf96 100644 --- a/packages/nodes-base/nodes/Spotify/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Spotify/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import get from 'lodash.get'; @@ -37,7 +37,7 @@ export async function spotifyApiRequest( try { return await this.helpers.requestOAuth2.call(this, 'spotifyOAuth2Api', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -57,6 +57,7 @@ export async function spotifyApiRequestAllItems( do { responseData = await spotifyApiRequest.call(this, method, endpoint, body, query, uri); + // eslint-disable-next-line @typescript-eslint/no-unsafe-argument returnData.push.apply(returnData, get(responseData, propertyName)); uri = responseData.next || responseData[propertyName.split('.')[0]].next; //remove the query as the query parameters are already included in the next, else api throws error. diff --git a/packages/nodes-base/nodes/Spotify/Spotify.node.ts b/packages/nodes-base/nodes/Spotify/Spotify.node.ts index 93d6ec3226..812c28697b 100644 --- a/packages/nodes-base/nodes/Spotify/Spotify.node.ts +++ b/packages/nodes-base/nodes/Spotify/Spotify.node.ts @@ -1308,7 +1308,7 @@ export class Spotify implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/SpreadsheetFile/SpreadsheetFile.node.ts b/packages/nodes-base/nodes/SpreadsheetFile/SpreadsheetFile.node.ts index 0aa177e77b..ea08c2d698 100644 --- a/packages/nodes-base/nodes/SpreadsheetFile/SpreadsheetFile.node.ts +++ b/packages/nodes-base/nodes/SpreadsheetFile/SpreadsheetFile.node.ts @@ -456,7 +456,7 @@ export class SpreadsheetFile implements INodeType { [sheetName]: ws, }, }; - const wbout = xlsxWrite(wb, wopts); + const wbout: Buffer = xlsxWrite(wb, wopts); // Create a new item with only the binary spreadsheet data const newItem: INodeExecutionData = { diff --git a/packages/nodes-base/nodes/SseTrigger/SseTrigger.node.ts b/packages/nodes-base/nodes/SseTrigger/SseTrigger.node.ts index 3acac9ca53..99ef24dbc2 100644 --- a/packages/nodes-base/nodes/SseTrigger/SseTrigger.node.ts +++ b/packages/nodes-base/nodes/SseTrigger/SseTrigger.node.ts @@ -1,6 +1,7 @@ import EventSource from 'eventsource'; + import type { ITriggerFunctions } from 'n8n-core'; -import type { INodeType, INodeTypeDescription, ITriggerResponse } from 'n8n-workflow'; +import type { IDataObject, INodeType, INodeTypeDescription, ITriggerResponse } from 'n8n-workflow'; import { jsonParse } from 'n8n-workflow'; export class SseTrigger implements INodeType { @@ -38,7 +39,9 @@ export class SseTrigger implements INodeType { const eventSource = new EventSource(url); eventSource.onmessage = (event) => { - const eventData = jsonParse(event.data, { errorMessage: 'Invalid JSON for event data' }); + const eventData = jsonParse(event.data as string, { + errorMessage: 'Invalid JSON for event data', + }); this.emit([this.helpers.returnJsonArray([eventData])]); }; diff --git a/packages/nodes-base/nodes/Stackby/GenericFunction.ts b/packages/nodes-base/nodes/Stackby/GenericFunction.ts index ed294a6cea..1eead3da6f 100644 --- a/packages/nodes-base/nodes/Stackby/GenericFunction.ts +++ b/packages/nodes-base/nodes/Stackby/GenericFunction.ts @@ -2,7 +2,7 @@ import type { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n import type { OptionsWithUri } from 'request'; -import type { IDataObject, IPollFunctions } from 'n8n-workflow'; +import type { IDataObject, IPollFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; /** @@ -43,7 +43,7 @@ export async function apiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -59,7 +59,7 @@ export async function apiRequestAllItems( endpoint: string, body: IDataObject = {}, query: IDataObject = {}, -): Promise { +) { query.maxrecord = 100; query.offset = 0; @@ -70,7 +70,7 @@ export async function apiRequestAllItems( do { responseData = await apiRequest.call(this, method, endpoint, body, query); - returnData.push.apply(returnData, responseData); + returnData.push.apply(returnData, responseData as IDataObject[]); query.offset += query.maxrecord; } while (responseData.length !== 0); diff --git a/packages/nodes-base/nodes/Stackby/Stackby.node.ts b/packages/nodes-base/nodes/Stackby/Stackby.node.ts index 428301d29a..57faef5a97 100644 --- a/packages/nodes-base/nodes/Stackby/Stackby.node.ts +++ b/packages/nodes-base/nodes/Stackby/Stackby.node.ts @@ -189,8 +189,7 @@ export class Stackby implements INodeType { responseData = await apiRequest.call(this, 'GET', `/rowlist/${stackId}/${table}`, {}, qs); returnData.push.apply( returnData, - - responseData.map((data: any) => data.field), + responseData.map((data: any) => data.field) as INodeExecutionData[], ); } catch (error) { if (this.continueOnFail()) { @@ -223,7 +222,7 @@ export class Stackby implements INodeType { responseData = responseData.records; const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); @@ -280,8 +279,7 @@ export class Stackby implements INodeType { returnData.push.apply( returnData, - - responseData.map((data: any) => data.field), + responseData.map((data: any) => data.field) as INodeExecutionData[], ); } catch (error) { if (this.continueOnFail()) { @@ -330,8 +328,7 @@ export class Stackby implements INodeType { returnData.push.apply( returnData, - - responseData.map((data: any) => data.field), + responseData.map((data: any) => data.field) as INodeExecutionData[], ); } catch (error) { if (this.continueOnFail()) { diff --git a/packages/nodes-base/nodes/Storyblok/GenericFunctions.ts b/packages/nodes-base/nodes/Storyblok/GenericFunctions.ts index 789ec2d4ac..aaa49387fb 100644 --- a/packages/nodes-base/nodes/Storyblok/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Storyblok/GenericFunctions.ts @@ -7,18 +7,17 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function storyblokApiRequest( this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, - - body: any = {}, + body: IDataObject = {}, qs: IDataObject = {}, option: IDataObject = {}, -): Promise { +) { const authenticationMethod = this.getNodeParameter('source', 0) as string; let options: OptionsWithUri = { @@ -34,7 +33,7 @@ export async function storyblokApiRequest( options = Object.assign({}, options, option); - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } @@ -57,7 +56,7 @@ export async function storyblokApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -66,10 +65,9 @@ export async function storyblokApiRequestAllItems( propertyName: string, method: string, resource: string, - - body: any = {}, + body: IDataObject = {}, query: IDataObject = {}, -): Promise { +) { const returnData: IDataObject[] = []; let responseData; @@ -81,7 +79,7 @@ export async function storyblokApiRequestAllItems( do { responseData = await storyblokApiRequest.call(this, method, resource, body, query); query.page++; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData[propertyName].length !== 0); return returnData; diff --git a/packages/nodes-base/nodes/Storyblok/Storyblok.node.ts b/packages/nodes-base/nodes/Storyblok/Storyblok.node.ts index dcb1bbcb3c..144aaa7c0a 100644 --- a/packages/nodes-base/nodes/Storyblok/Storyblok.node.ts +++ b/packages/nodes-base/nodes/Storyblok/Storyblok.node.ts @@ -343,7 +343,7 @@ export class Storyblok implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Strapi/GenericFunctions.ts b/packages/nodes-base/nodes/Strapi/GenericFunctions.ts index 09f39b56de..4e7e7081a8 100644 --- a/packages/nodes-base/nodes/Strapi/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Strapi/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { IWebhookFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function strapiApiRequest( @@ -15,11 +15,11 @@ export async function strapiApiRequest( method: string, resource: string, - body: any = {}, + body: IDataObject = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}, -): Promise { +) { const credentials = await this.getCredentials('strapiApi'); try { @@ -44,10 +44,9 @@ export async function strapiApiRequest( delete options.body; } - //@ts-ignore return await this.helpers?.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -78,11 +77,10 @@ export async function strapiApiRequestAllItems( this: IHookFunctions | ILoadOptionsFunctions | IExecuteFunctions, method: string, resource: string, - - body: any = {}, + body: IDataObject = {}, query: IDataObject = {}, headers: IDataObject = {}, -): Promise { +) { const returnData: IDataObject[] = []; const { apiVersion } = await this.getCredentials('strapiApi'); @@ -101,7 +99,7 @@ export async function strapiApiRequestAllItems( headers, )); query['pagination[page]'] += query['pagination[pageSize]']; - returnData.push.apply(returnData, responseData); + returnData.push.apply(returnData, responseData as IDataObject[]); } while (responseData.length !== 0); } else { query._limit = 20; @@ -117,7 +115,7 @@ export async function strapiApiRequestAllItems( headers, ); query._start += query._limit; - returnData.push.apply(returnData, responseData); + returnData.push.apply(returnData, responseData as IDataObject[]); } while (responseData.length !== 0); } return returnData; diff --git a/packages/nodes-base/nodes/Strapi/Strapi.node.ts b/packages/nodes-base/nodes/Strapi/Strapi.node.ts index b674e0d12e..8497db42a3 100644 --- a/packages/nodes-base/nodes/Strapi/Strapi.node.ts +++ b/packages/nodes-base/nodes/Strapi/Strapi.node.ts @@ -146,7 +146,7 @@ export class Strapi implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); @@ -169,7 +169,7 @@ export class Strapi implements INodeType { ); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); @@ -272,7 +272,7 @@ export class Strapi implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); @@ -299,7 +299,7 @@ export class Strapi implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); @@ -342,7 +342,7 @@ export class Strapi implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Strava/GenericFunctions.ts b/packages/nodes-base/nodes/Strava/GenericFunctions.ts index df6c04ccd2..401ae71d57 100644 --- a/packages/nodes-base/nodes/Strava/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Strava/GenericFunctions.ts @@ -8,7 +8,7 @@ import type { IWebhookFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function stravaApiRequest( @@ -20,12 +20,11 @@ export async function stravaApiRequest( | IWebhookFunctions, method: string, resource: string, - - body: any = {}, + body: IDataObject = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}, -): Promise { +) { const options: OptionsWithUri = { method, form: body, @@ -50,16 +49,15 @@ export async function stravaApiRequest( body.client_id = credentials.clientId; body.client_secret = credentials.clientSecret; } - //@ts-ignore + return await this.helpers?.request(options); } else { - //@ts-ignore return await this.helpers.requestOAuth2.call(this, 'stravaOAuth2Api', options, { includeCredentialsOnRefreshOnBody: true, }); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -68,9 +66,9 @@ export async function stravaApiRequestAllItems( method: string, resource: string, - body: any = {}, + body: IDataObject = {}, query: IDataObject = {}, -): Promise { +) { const returnData: IDataObject[] = []; let responseData; @@ -82,7 +80,7 @@ export async function stravaApiRequestAllItems( do { responseData = await stravaApiRequest.call(this, method, resource, body, query); query.page++; - returnData.push.apply(returnData, responseData); + returnData.push.apply(returnData, responseData as IDataObject[]); } while (responseData.length !== 0); return returnData; diff --git a/packages/nodes-base/nodes/Strava/Strava.node.ts b/packages/nodes-base/nodes/Strava/Strava.node.ts index c9e1f9e31b..eb463da10d 100644 --- a/packages/nodes-base/nodes/Strava/Strava.node.ts +++ b/packages/nodes-base/nodes/Strava/Strava.node.ts @@ -184,7 +184,7 @@ export class Strava implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Stripe/Stripe.node.ts b/packages/nodes-base/nodes/Stripe/Stripe.node.ts index ef2279e5b2..204103a45b 100644 --- a/packages/nodes-base/nodes/Stripe/Stripe.node.ts +++ b/packages/nodes-base/nodes/Stripe/Stripe.node.ts @@ -478,7 +478,7 @@ export class Stripe implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Stripe/StripeTrigger.node.ts b/packages/nodes-base/nodes/Stripe/StripeTrigger.node.ts index 0716196c6d..6109a8a0ef 100644 --- a/packages/nodes-base/nodes/Stripe/StripeTrigger.node.ts +++ b/packages/nodes-base/nodes/Stripe/StripeTrigger.node.ts @@ -1,7 +1,13 @@ /* eslint-disable n8n-nodes-base/node-param-description-excess-final-period */ import type { IHookFunctions, IWebhookFunctions } from 'n8n-core'; -import type { INodeType, INodeTypeDescription, IWebhookResponseData } from 'n8n-workflow'; +import type { + IDataObject, + INodeType, + INodeTypeDescription, + IWebhookResponseData, + JsonObject, +} from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import { stripeApiRequest } from './helpers'; @@ -819,7 +825,6 @@ export class StripeTrigger implements INodeType { ], }; - // @ts-ignore (because of request) webhookMethods = { default: { async checkExists(this: IHookFunctions): Promise { @@ -877,7 +882,7 @@ export class StripeTrigger implements INodeType { responseData.status !== 'enabled' ) { // Required data is missing so was not successful - throw new NodeApiError(this.getNode(), responseData, { + throw new NodeApiError(this.getNode(), responseData as JsonObject, { message: 'Stripe webhook creation response did not contain the expected data.', }); } @@ -929,7 +934,7 @@ export class StripeTrigger implements INodeType { } return { - workflowData: [this.helpers.returnJsonArray(req.body)], + workflowData: [this.helpers.returnJsonArray(req.body as IDataObject)], }; } } diff --git a/packages/nodes-base/nodes/Stripe/helpers.ts b/packages/nodes-base/nodes/Stripe/helpers.ts index 09372f9474..adef1ecdf5 100644 --- a/packages/nodes-base/nodes/Stripe/helpers.ts +++ b/packages/nodes-base/nodes/Stripe/helpers.ts @@ -125,7 +125,7 @@ export async function handleListing( do { responseData = await stripeApiRequest.call(this, 'GET', `/${resource}s`, {}, qs); - returnData.push(...responseData.data); + returnData.push(...(responseData.data as IDataObject[])); if (!returnAll && returnData.length >= limit) { return returnData.slice(0, limit); diff --git a/packages/nodes-base/nodes/Supabase/GenericFunctions.ts b/packages/nodes-base/nodes/Supabase/GenericFunctions.ts index c90b775c14..9b76b07502 100644 --- a/packages/nodes-base/nodes/Supabase/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Supabase/GenericFunctions.ts @@ -14,6 +14,7 @@ import type { IDataObject, INodeProperties, IPairedItemData, + JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; @@ -26,12 +27,11 @@ export async function supabaseApiRequest( | IWebhookFunctions, method: string, resource: string, - - body: any = {}, + body: IDataObject | IDataObject[] = {}, qs: IDataObject = {}, uri?: string, headers: IDataObject = {}, -): Promise { +) { const credentials = (await this.getCredentials('supabaseApi')) as { host: string; serviceRole: string; @@ -56,7 +56,7 @@ export async function supabaseApiRequest( } return await this.helpers.requestWithAuthentication.call(this, 'supabaseApi', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Supabase/Supabase.node.ts b/packages/nodes-base/nodes/Supabase/Supabase.node.ts index 2129ead358..7b92a5b557 100644 --- a/packages/nodes-base/nodes/Supabase/Supabase.node.ts +++ b/packages/nodes-base/nodes/Supabase/Supabase.node.ts @@ -75,7 +75,7 @@ export class Supabase implements INodeType { async getTables(this: ILoadOptionsFunctions): Promise { const returnData: INodePropertyOptions[] = []; const { paths } = await supabaseApiRequest.call(this, 'GET', '/'); - for (const path of Object.keys(paths)) { + for (const path of Object.keys(paths as IDataObject)) { //omit introspection path if (path === '/') continue; returnData.push({ @@ -89,7 +89,7 @@ export class Supabase implements INodeType { const returnData: INodePropertyOptions[] = []; const tableName = this.getCurrentNodeParameter('tableId') as string; const { definitions } = await supabaseApiRequest.call(this, 'GET', '/'); - for (const column of Object.keys(definitions[tableName].properties)) { + for (const column of Object.keys(definitions[tableName].properties as IDataObject)) { returnData.push({ name: `${column} - (${definitions[tableName].properties[column].type})`, value: column, @@ -233,7 +233,7 @@ export class Supabase implements INodeType { throw error; } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(rows), + this.helpers.returnJsonArray(rows as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -273,7 +273,7 @@ export class Supabase implements INodeType { throw error; } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(rows), + this.helpers.returnJsonArray(rows as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -316,7 +316,7 @@ export class Supabase implements INodeType { try { rows = await supabaseApiRequest.call(this, 'GET', endpoint, {}, qs); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(rows), + this.helpers.returnJsonArray(rows as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -392,7 +392,7 @@ export class Supabase implements INodeType { try { updatedRow = await supabaseApiRequest.call(this, 'PATCH', endpoint, record, qs); const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(updatedRow), + this.helpers.returnJsonArray(updatedRow as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/SurveyMonkey/GenericFunctions.ts b/packages/nodes-base/nodes/SurveyMonkey/GenericFunctions.ts index 28caf5ce90..35701fe881 100644 --- a/packages/nodes-base/nodes/SurveyMonkey/GenericFunctions.ts +++ b/packages/nodes-base/nodes/SurveyMonkey/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject, IHookFunctions, IWebhookFunctions } from 'n8n-workflow'; +import type { IDataObject, IHookFunctions, IWebhookFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function surveyMonkeyApiRequest( @@ -10,11 +10,11 @@ export async function surveyMonkeyApiRequest( method: string, resource: string, - body: any = {}, + body: IDataObject = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}, -): Promise { +) { const authenticationMethod = this.getNodeParameter('authentication', 0); const endpoint = 'https://api.surveymonkey.com/v3'; @@ -41,15 +41,15 @@ export async function surveyMonkeyApiRequest( try { if (authenticationMethod === 'accessToken') { const credentials = await this.getCredentials('surveyMonkeyApi'); - // @ts-ignore - options.headers.Authorization = `bearer ${credentials.accessToken}`; + + (options.headers as IDataObject).Authorization = `bearer ${credentials.accessToken}`; return await this.helpers.request(options); } else { return await this.helpers.requestOAuth2?.call(this, 'surveyMonkeyOAuth2Api', options); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -59,7 +59,7 @@ export async function surveyMonkeyRequestAllItems( method: string, endpoint: string, - body: any = {}, + body: IDataObject = {}, query: IDataObject = {}, ): Promise { const returnData: IDataObject[] = []; @@ -72,7 +72,7 @@ export async function surveyMonkeyRequestAllItems( do { responseData = await surveyMonkeyApiRequest.call(this, method, endpoint, body, query, uri); uri = responseData.links.next; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.links.next); return returnData; diff --git a/packages/nodes-base/nodes/SurveyMonkey/SurveyMonkeyTrigger.node.ts b/packages/nodes-base/nodes/SurveyMonkey/SurveyMonkeyTrigger.node.ts index 079db59926..09f2125eaf 100644 --- a/packages/nodes-base/nodes/SurveyMonkey/SurveyMonkeyTrigger.node.ts +++ b/packages/nodes-base/nodes/SurveyMonkey/SurveyMonkeyTrigger.node.ts @@ -355,7 +355,6 @@ export class SurveyMonkeyTrigger implements INodeType { }, }; - // @ts-ignore (because of request) webhookMethods = { default: { async checkExists(this: IHookFunctions): Promise { @@ -497,7 +496,7 @@ export class SurveyMonkeyTrigger implements INodeType { const data: Buffer[] = []; req.on('data', (chunk) => { - data.push(chunk); + data.push(chunk as Buffer); }); req.on('end', async () => { @@ -542,7 +541,7 @@ export class SurveyMonkeyTrigger implements INodeType { ); for (const page of pages) { - questions.push.apply(questions, page.questions); + questions.push.apply(questions, page.questions as IQuestion[]); } for (const page of responseData.pages as IDataObject[]) { diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/create/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/create/execute.ts index 5c254251cc..d1bfc3cfe5 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/create/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/create/execute.ts @@ -34,5 +34,5 @@ export async function createContact( const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - return this.helpers.returnJsonArray(responseData); + return this.helpers.returnJsonArray(responseData as IDataObject); } diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/del/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/del/execute.ts index 4448bf711f..479b161257 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/del/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/del/execute.ts @@ -16,5 +16,5 @@ export async function deleteContact( const body = {} as IDataObject; const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - return this.helpers.returnJsonArray(responseData); + return this.helpers.returnJsonArray(responseData as IDataObject); } diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/get/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/get/execute.ts index c16601c687..8486cf109f 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/get/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/get/execute.ts @@ -16,5 +16,5 @@ export async function getContact( const body = {} as IDataObject; const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - return this.helpers.returnJsonArray(responseData); + return this.helpers.returnJsonArray(responseData as IDataObject); } diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/getAll/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/getAll/execute.ts index 999fff01d2..050ca6b0de 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/getAll/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/getAll/execute.ts @@ -22,6 +22,6 @@ export async function getAll( } else { const limit = this.getNodeParameter('limit', index); responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - return this.helpers.returnJsonArray(responseData.contacts.splice(0, limit)); + return this.helpers.returnJsonArray(responseData.contacts.splice(0, limit) as IDataObject[]); } } diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/update/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/update/execute.ts index 1f36bc4b37..09516fba10 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/update/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/contact/update/execute.ts @@ -37,5 +37,5 @@ export async function updateContact( const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - return this.helpers.returnJsonArray(responseData); + return this.helpers.returnJsonArray(responseData as IDataObject); } diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/create/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/create/execute.ts index f3ff770800..7894aeac04 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/create/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/create/execute.ts @@ -51,5 +51,5 @@ export async function addCustomer( const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - return this.helpers.returnJsonArray(responseData.customer); + return this.helpers.returnJsonArray(responseData.customer as IDataObject); } diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/del/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/del/execute.ts index 3c9f748eff..a3b125a9f8 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/del/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/del/execute.ts @@ -16,5 +16,5 @@ export async function deleteCustomer( const body = {} as IDataObject; const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - return this.helpers.returnJsonArray(responseData); + return this.helpers.returnJsonArray(responseData as IDataObject[]); } diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/get/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/get/execute.ts index 623ff1aa5e..2fcfea10d1 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/get/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/get/execute.ts @@ -16,5 +16,5 @@ export async function getCustomer( const body = {} as IDataObject; const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - return this.helpers.returnJsonArray(responseData.customer); + return this.helpers.returnJsonArray(responseData.customer as IDataObject); } diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/getAll/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/getAll/execute.ts index 5a735b3143..5e3061c0f4 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/getAll/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/getAll/execute.ts @@ -36,6 +36,6 @@ export async function getAll( return this.helpers.returnJsonArray(responseData); } else { responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - return this.helpers.returnJsonArray(responseData.customers); + return this.helpers.returnJsonArray(responseData.customers as IDataObject[]); } } diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/update/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/update/execute.ts index 2701197579..28f17846ea 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/update/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/customer/update/execute.ts @@ -1,6 +1,6 @@ import type { IExecuteFunctions } from 'n8n-core'; -import type { IDataObject, INodeExecutionData } from 'n8n-workflow'; +import type { IDataObject, INodeExecutionData, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import { apiRequest } from '../../../transport'; @@ -53,10 +53,10 @@ export async function updateCustomer( const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); if (!responseData.customer) { - throw new NodeApiError(this.getNode(), responseData, { + throw new NodeApiError(this.getNode(), responseData as JsonObject, { httpCode: '404', message: 'Customer ID not found', }); } - return this.helpers.returnJsonArray(responseData.customer); + return this.helpers.returnJsonArray(responseData.customer as IDataObject[]); } diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/create/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/create/execute.ts index 0b4f30f884..a5ece78df8 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/create/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/create/execute.ts @@ -28,5 +28,5 @@ export async function addAlert( const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - return this.helpers.returnJsonArray(responseData.alert); + return this.helpers.returnJsonArray(responseData.alert as IDataObject); } diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/del/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/del/execute.ts index 0102d1b977..310508c673 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/del/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/del/execute.ts @@ -16,5 +16,5 @@ export async function deleteAlert( const body = {} as IDataObject; const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - return this.helpers.returnJsonArray(responseData); + return this.helpers.returnJsonArray(responseData as IDataObject[]); } diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/get/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/get/execute.ts index 0fa9ebe8ce..2507aff832 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/get/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/get/execute.ts @@ -16,5 +16,5 @@ export async function getAlert( const body = {} as IDataObject; const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - return this.helpers.returnJsonArray(responseData.rmm_alert); + return this.helpers.returnJsonArray(responseData.rmm_alert as IDataObject[]); } diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/getAll/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/getAll/execute.ts index cd769b10d2..70de352c3b 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/getAll/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/getAll/execute.ts @@ -34,6 +34,6 @@ export async function getAll( return this.helpers.returnJsonArray(responseData); } else { responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - return this.helpers.returnJsonArray(responseData.rmm_alerts); + return this.helpers.returnJsonArray(responseData.rmm_alerts as IDataObject[]); } } diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/mute/execute.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/mute/execute.ts index ecac9f1264..895589e6cd 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/mute/execute.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/rmm/mute/execute.ts @@ -20,5 +20,5 @@ export async function muteAlert( body.mute_for = mute; const responseData = await apiRequest.call(this, requestMethod, endpoint, body, qs); - return this.helpers.returnJsonArray(responseData); + return this.helpers.returnJsonArray(responseData as IDataObject[]); } diff --git a/packages/nodes-base/nodes/SyncroMSP/v1/actions/router.ts b/packages/nodes-base/nodes/SyncroMSP/v1/actions/router.ts index 86832c37d5..0cf3310072 100644 --- a/packages/nodes-base/nodes/SyncroMSP/v1/actions/router.ts +++ b/packages/nodes-base/nodes/SyncroMSP/v1/actions/router.ts @@ -1,6 +1,6 @@ import type { IExecuteFunctions } from 'n8n-core'; -import type { INodeExecutionData } from 'n8n-workflow'; +import type { INodeExecutionData, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import * as customer from './customer'; @@ -51,7 +51,7 @@ export async function router(this: IExecuteFunctions): Promise { const returnData: IDataObject[] = []; @@ -112,7 +112,7 @@ export async function taigaApiRequestAllItems( responseData = await taigaApiRequest.call(this, method, resource, body, query, uri, { resolveWithFullResponse: true, }); - returnData.push.apply(returnData, responseData.body); + returnData.push.apply(returnData, responseData.body as IDataObject[]); uri = responseData.headers['x-pagination-next']; if (query.limit && returnData.length >= query.limit) { return returnData; diff --git a/packages/nodes-base/nodes/Taiga/Taiga.node.ts b/packages/nodes-base/nodes/Taiga/Taiga.node.ts index 4afe6afa4c..e1c7d4c2a5 100644 --- a/packages/nodes-base/nodes/Taiga/Taiga.node.ts +++ b/packages/nodes-base/nodes/Taiga/Taiga.node.ts @@ -575,7 +575,7 @@ export class Taiga implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Tapfiliate/GenericFunctions.ts b/packages/nodes-base/nodes/Tapfiliate/GenericFunctions.ts index b0ea4e6332..fd52d966f8 100644 --- a/packages/nodes-base/nodes/Tapfiliate/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Tapfiliate/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function tapfiliateApiRequest( @@ -15,11 +15,11 @@ export async function tapfiliateApiRequest( method: string, endpoint: string, - body: any = {}, + body: IDataObject = {}, qs: IDataObject = {}, uri?: string | undefined, option: IDataObject = {}, -): Promise { +) { const credentials = await this.getCredentials('tapfiliateApi'); const options: OptionsWithUri = { @@ -43,7 +43,7 @@ export async function tapfiliateApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -52,9 +52,9 @@ export async function tapfiliateApiRequestAllItems( method: string, endpoint: string, - body: any = {}, + body: IDataObject = {}, query: IDataObject = {}, -): Promise { +) { const returnData: IDataObject[] = []; let responseData; @@ -65,7 +65,7 @@ export async function tapfiliateApiRequestAllItems( responseData = await tapfiliateApiRequest.call(this, method, endpoint, body, query, '', { resolveWithFullResponse: true, }); - returnData.push.apply(returnData, responseData.body); + returnData.push.apply(returnData, responseData.body as IDataObject[]); query.page++; } while (responseData.headers.link.includes('next')); diff --git a/packages/nodes-base/nodes/Tapfiliate/Tapfiliate.node.ts b/packages/nodes-base/nodes/Tapfiliate/Tapfiliate.node.ts index e9b4dcad32..178eeda0c0 100644 --- a/packages/nodes-base/nodes/Tapfiliate/Tapfiliate.node.ts +++ b/packages/nodes-base/nodes/Tapfiliate/Tapfiliate.node.ts @@ -81,8 +81,8 @@ export class Tapfiliate implements INodeType { const programs = await tapfiliateApiRequestAllItems.call(this, 'GET', '/programs/'); for (const program of programs) { returnData.push({ - name: program.title, - value: program.id, + name: program.title as string, + value: program.id as string, }); } return returnData; @@ -131,7 +131,7 @@ export class Tapfiliate implements INodeType { delete body.companyName; } responseData = await tapfiliateApiRequest.call(this, 'POST', '/affiliates/', body); - returnData.push(responseData); + returnData.push(responseData as INodeExecutionData); } if (operation === 'delete') { //https://tapfiliate.com/docs/rest/#affiliates-affiliate-delete @@ -297,7 +297,7 @@ export class Tapfiliate implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Telegram/GenericFunctions.ts b/packages/nodes-base/nodes/Telegram/GenericFunctions.ts index fbe553a755..331a4136fc 100644 --- a/packages/nodes-base/nodes/Telegram/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Telegram/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { import type { OptionsWithUri } from 'request'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; // Interface in n8n @@ -176,7 +176,7 @@ export async function apiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Telegram/Telegram.node.ts b/packages/nodes-base/nodes/Telegram/Telegram.node.ts index 404ef41fcf..8a0b228214 100644 --- a/packages/nodes-base/nodes/Telegram/Telegram.node.ts +++ b/packages/nodes-base/nodes/Telegram/Telegram.node.ts @@ -2024,7 +2024,11 @@ export class Telegram implements INodeType { ); const fileName = filePath.split('/').pop(); - const data = await this.helpers.prepareBinaryData(file.body, fileName); + + const data = await this.helpers.prepareBinaryData( + file.body as Buffer, + fileName as string, + ); returnData.push({ json: responseData, @@ -2035,7 +2039,7 @@ export class Telegram implements INodeType { } } else if (resource === 'chat' && operation === 'administrators') { const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData.result), + this.helpers.returnJsonArray(responseData.result as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); @@ -2043,7 +2047,7 @@ export class Telegram implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Telegram/TelegramTrigger.node.ts b/packages/nodes-base/nodes/Telegram/TelegramTrigger.node.ts index fb8ace7740..9236918c47 100644 --- a/packages/nodes-base/nodes/Telegram/TelegramTrigger.node.ts +++ b/packages/nodes-base/nodes/Telegram/TelegramTrigger.node.ts @@ -164,7 +164,6 @@ export class TelegramTrigger implements INodeType { ], }; - // @ts-ignore (because of request) webhookMethods = { default: { async checkExists(this: IHookFunctions): Promise { @@ -281,7 +280,7 @@ export class TelegramTrigger implements INodeType { const binaryData = await this.helpers.prepareBinaryData( data as unknown as Buffer, - fileName, + fileName as string, ); return { diff --git a/packages/nodes-base/nodes/TheHive/GenericFunctions.ts b/packages/nodes-base/nodes/TheHive/GenericFunctions.ts index 01e4bc87e9..6362d93e8b 100644 --- a/packages/nodes-base/nodes/TheHive/GenericFunctions.ts +++ b/packages/nodes-base/nodes/TheHive/GenericFunctions.ts @@ -12,12 +12,11 @@ export async function theHiveApiRequest( this: IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions, method: string, resource: string, - - body: any = {}, + body: IDataObject = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}, -): Promise { +) { const credentials = await this.getCredentials('theHiveApi'); let options: OptionsWithUri = { @@ -132,7 +131,7 @@ export async function prepareCustomFields( const hiveCustomFields = version === 'v1' ? requestResult - : Object.keys(requestResult).map((key) => requestResult[key]); + : Object.keys(requestResult as IDataObject).map((key) => requestResult[key]); // Build reference to type mapping object const referenceTypeMapping = hiveCustomFields.reduce( (acc: IDataObject, curr: IDataObject) => ((acc[curr.reference as string] = curr.type), acc), diff --git a/packages/nodes-base/nodes/TheHive/TheHive.node.ts b/packages/nodes-base/nodes/TheHive/TheHive.node.ts index 8a3b2fab06..d868d23025 100644 --- a/packages/nodes-base/nodes/TheHive/TheHive.node.ts +++ b/packages/nodes-base/nodes/TheHive/TheHive.node.ts @@ -160,7 +160,7 @@ export class TheHive implements INodeType { const customFields = version === 'v1' ? requestResult - : Object.keys(requestResult).map((key) => requestResult[key]); + : Object.keys(requestResult as IDataObject).map((key) => requestResult[key]); for (const field of customFields) { returnData.push({ @@ -219,7 +219,7 @@ export class TheHive implements INodeType { }; }); } else { - returnData = Object.keys(dataTypes).map((key) => { + returnData = Object.keys(dataTypes as IDataObject).map((key) => { const dataType = dataTypes[key] as string; return { @@ -325,7 +325,7 @@ export class TheHive implements INodeType { if (resource === 'alert') { if (operation === 'count') { const filters = this.getNodeParameter('filters', i, {}) as INodeParameters; - const countQueryAttributs: any = prepareOptional(filters); + const countQueryAttributs = prepareOptional(filters); const _countSearchQuery: IQueryObject = And(); @@ -537,7 +537,7 @@ export class TheHive implements INodeType { const version = credentials.apiVersion; const filters = this.getNodeParameter('filters', i, {}) as INodeParameters; - const queryAttributs: any = prepareOptional(filters); + const queryAttributs = prepareOptional(filters); const options = this.getNodeParameter('options', i); const _searchQuery: IQueryObject = And(); @@ -741,7 +741,7 @@ export class TheHive implements INodeType { if (resource === 'observable') { if (operation === 'count') { - const countQueryAttributs: any = prepareOptional( + const countQueryAttributs = prepareOptional( this.getNodeParameter('filters', i, {}) as INodeParameters, ); const _countSearchQuery: IQueryObject = And(); @@ -759,8 +759,12 @@ export class TheHive implements INodeType { (_countSearchQuery['_and'] as IQueryObject[]).push( Between( 'startDate', - countQueryAttributs['range']['dateRange']['fromDate'], - countQueryAttributs['range']['dateRange']['toDate'], + ((countQueryAttributs['range'] as IDataObject)['dateRange'] as IDataObject)[ + 'fromDate' + ], + ((countQueryAttributs['range'] as IDataObject)['dateRange'] as IDataObject)[ + 'toDate' + ], ), ); } else { @@ -1060,7 +1064,7 @@ export class TheHive implements INodeType { const version = credentials.apiVersion; - const queryAttributs: any = prepareOptional( + const queryAttributs = prepareOptional( this.getNodeParameter('filters', i, {}) as INodeParameters, ); @@ -1081,8 +1085,12 @@ export class TheHive implements INodeType { (_searchQuery['_and'] as IQueryObject[]).push( Between( 'startDate', - queryAttributs['range']['dateRange']['fromDate'], - queryAttributs['range']['dateRange']['toDate'], + ((queryAttributs['range'] as IDataObject)['dateRange'] as IDataObject)[ + 'fromDate' + ], + ((queryAttributs['range'] as IDataObject)['dateRange'] as IDataObject)[ + 'toDate' + ], ), ); } else { @@ -1169,7 +1177,7 @@ export class TheHive implements INodeType { if (resource === 'case') { if (operation === 'count') { const filters = this.getNodeParameter('filters', i, {}) as INodeParameters; - const countQueryAttributs: any = prepareOptional(filters); + const countQueryAttributs = prepareOptional(filters); const _countSearchQuery: IQueryObject = And(); @@ -1338,7 +1346,7 @@ export class TheHive implements INodeType { const version = credentials.apiVersion; const filters = this.getNodeParameter('filters', i, {}) as INodeParameters; - const queryAttributs: any = prepareOptional(filters); + const queryAttributs = prepareOptional(filters); const _searchQuery: IQueryObject = And(); @@ -1439,7 +1447,7 @@ export class TheHive implements INodeType { if (resource === 'task') { if (operation === 'count') { - const countQueryAttributs: any = prepareOptional( + const countQueryAttributs = prepareOptional( this.getNodeParameter('filters', i, {}) as INodeParameters, ); @@ -1653,7 +1661,7 @@ export class TheHive implements INodeType { const version = credentials.apiVersion; - const queryAttributs: any = prepareOptional( + const queryAttributs = prepareOptional( this.getNodeParameter('filters', i, {}) as INodeParameters, ); @@ -1955,7 +1963,7 @@ export class TheHive implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Todoist/GenericFunctions.ts b/packages/nodes-base/nodes/Todoist/GenericFunctions.ts index cabb09e18b..0333ab5170 100644 --- a/packages/nodes-base/nodes/Todoist/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Todoist/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export type Context = IHookFunctions | IExecuteFunctions | ILoadOptionsFunctions; @@ -17,8 +17,7 @@ export async function todoistApiRequest( this: Context, method: string, resource: string, - - body: any = {}, + body: IDataObject = {}, qs: IDataObject = {}, ): Promise { const authentication = this.getNodeParameter('authentication', 0) as string; @@ -40,7 +39,7 @@ export async function todoistApiRequest( const credentialType = authentication === 'apiKey' ? 'todoistApi' : 'todoistOAuth2Api'; return await this.helpers.requestWithAuthentication.call(this, credentialType, options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -59,7 +58,7 @@ export async function todoistSyncRequest( json: true, }; - if (Object.keys(body).length !== 0) { + if (Object.keys(body as IDataObject).length !== 0) { options.body = body; } @@ -67,6 +66,6 @@ export async function todoistSyncRequest( const credentialType = authentication === 'oAuth2' ? 'todoistOAuth2Api' : 'todoistApi'; return await this.helpers.requestWithAuthentication.call(this, credentialType, options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Todoist/v1/OperationHandler.ts b/packages/nodes-base/nodes/Todoist/v1/OperationHandler.ts index bd7d6bc530..8225bad42e 100644 --- a/packages/nodes-base/nodes/Todoist/v1/OperationHandler.ts +++ b/packages/nodes-base/nodes/Todoist/v1/OperationHandler.ts @@ -104,7 +104,7 @@ export class CreateHandler implements OperationHandler { body.parent_id = options.parentId as string; } - const data = await todoistApiRequest.call(ctx, 'POST', '/tasks', body); + const data = await todoistApiRequest.call(ctx, 'POST', '/tasks', body as IDataObject); return { data, @@ -247,7 +247,7 @@ export class UpdateHandler implements OperationHandler { body.due_lang = updateFields.dueLang as string; } - await todoistApiRequest.call(ctx, 'POST', `/tasks/${id}`, body); + await todoistApiRequest.call(ctx, 'POST', `/tasks/${id}`, body as IDataObject); return { success: true }; } diff --git a/packages/nodes-base/nodes/Todoist/v2/OperationHandler.ts b/packages/nodes-base/nodes/Todoist/v2/OperationHandler.ts index 014670e0a0..179d958be7 100644 --- a/packages/nodes-base/nodes/Todoist/v2/OperationHandler.ts +++ b/packages/nodes-base/nodes/Todoist/v2/OperationHandler.ts @@ -95,7 +95,7 @@ export class CreateHandler implements OperationHandler { body.parent_id = options.parentId as string; } - const data = await todoistApiRequest.call(ctx, 'POST', '/tasks', body); + const data = await todoistApiRequest.call(ctx, 'POST', '/tasks', body as IDataObject); return { data, @@ -238,7 +238,7 @@ export class UpdateHandler implements OperationHandler { body.due_lang = updateFields.dueLang as string; } - await todoistApiRequest.call(ctx, 'POST', `/tasks/${id}`, body); + await todoistApiRequest.call(ctx, 'POST', `/tasks/${id}`, body as IDataObject); return { success: true }; } diff --git a/packages/nodes-base/nodes/Toggl/GenericFunctions.ts b/packages/nodes-base/nodes/Toggl/GenericFunctions.ts index 862ee97ade..ab2d57e586 100644 --- a/packages/nodes-base/nodes/Toggl/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Toggl/GenericFunctions.ts @@ -9,7 +9,7 @@ import type { ITriggerFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function togglApiRequest( @@ -22,11 +22,10 @@ export async function togglApiRequest( | ILoadOptionsFunctions, method: string, resource: string, - - body: any = {}, + body: IDataObject = {}, query?: IDataObject, uri?: string, -): Promise { +) { const credentials = await this.getCredentials('togglApi'); const headerWithAuthentication = Object.assign( {}, @@ -45,12 +44,12 @@ export async function togglApiRequest( body, json: true, }; - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Toggl/TogglTrigger.node.ts b/packages/nodes-base/nodes/Toggl/TogglTrigger.node.ts index c8bcdb2f51..6afbef0150 100644 --- a/packages/nodes-base/nodes/Toggl/TogglTrigger.node.ts +++ b/packages/nodes-base/nodes/Toggl/TogglTrigger.node.ts @@ -4,6 +4,7 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -68,7 +69,7 @@ export class TogglTrigger implements INodeType { timeEntries = await togglApiRequest.call(this, 'GET', endpoint, {}, qs); webhookData.lastTimeChecked = qs.end_date; } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } if (Array.isArray(timeEntries) && timeEntries.length !== 0) { return [this.helpers.returnJsonArray(timeEntries)]; diff --git a/packages/nodes-base/nodes/TravisCi/GenericFunctions.ts b/packages/nodes-base/nodes/TravisCi/GenericFunctions.ts index 081b3623b5..8cadef352a 100644 --- a/packages/nodes-base/nodes/TravisCi/GenericFunctions.ts +++ b/packages/nodes-base/nodes/TravisCi/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import get from 'lodash.get'; @@ -16,12 +16,11 @@ export async function travisciApiRequest( this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, resource: string, - - body: any = {}, + body: IDataObject | string = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}, -): Promise { +) { const credentials = await this.getCredentials('travisCiApi'); let options: OptionsWithUri = { headers: { @@ -37,13 +36,13 @@ export async function travisciApiRequest( json: true, }; options = Object.assign({}, options, option); - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -57,21 +56,21 @@ export async function travisciApiRequestAllItems( method: string, resource: string, - body: any = {}, + body: IDataObject = {}, query: IDataObject = {}, -): Promise { +) { const returnData: IDataObject[] = []; let responseData; do { responseData = await travisciApiRequest.call(this, method, resource, body, query); - const path = get(responseData, '@pagination.next.@href'); + const path = get(responseData, '@pagination.next.@href') as string; if (path !== undefined) { const parsedPath = new URLSearchParams(path); query = Object.fromEntries(parsedPath); } - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData['@pagination'].is_last !== true); return returnData; } diff --git a/packages/nodes-base/nodes/TravisCi/TravisCi.node.ts b/packages/nodes-base/nodes/TravisCi/TravisCi.node.ts index e9e14198d9..896b3f4f52 100644 --- a/packages/nodes-base/nodes/TravisCi/TravisCi.node.ts +++ b/packages/nodes-base/nodes/TravisCi/TravisCi.node.ts @@ -158,7 +158,7 @@ export class TravisCi implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); diff --git a/packages/nodes-base/nodes/Trello/GenericFunctions.ts b/packages/nodes-base/nodes/Trello/GenericFunctions.ts index b5b4405ff3..6af4306c4e 100644 --- a/packages/nodes-base/nodes/Trello/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Trello/GenericFunctions.ts @@ -45,7 +45,7 @@ export async function apiRequestAllItems( do { responseData = await apiRequest.call(this, method, endpoint, body, query); - returnData.push.apply(returnData, responseData); + returnData.push.apply(returnData, responseData as IDataObject[]); if (responseData.length !== 0) { query.before = responseData[responseData.length - 1].id; } diff --git a/packages/nodes-base/nodes/Trello/Trello.node.ts b/packages/nodes-base/nodes/Trello/Trello.node.ts index bd8ea97c47..6a02d4eee9 100644 --- a/packages/nodes-base/nodes/Trello/Trello.node.ts +++ b/packages/nodes-base/nodes/Trello/Trello.node.ts @@ -900,7 +900,7 @@ export class Trello implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Twist/GenericFunctions.ts b/packages/nodes-base/nodes/Twist/GenericFunctions.ts index 27f8f081fa..2d5af978e4 100644 --- a/packages/nodes-base/nodes/Twist/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Twist/GenericFunctions.ts @@ -2,18 +2,17 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function twistApiRequest( this: IExecuteFunctions | ILoadOptionsFunctions, method: string, endpoint: string, - - body: any = {}, + body: IDataObject = {}, qs: IDataObject = {}, option: IDataObject = {}, -): Promise { +) { const options: OptionsWithUri = { method, body, @@ -33,9 +32,8 @@ export async function twistApiRequest( Object.assign(options, option); try { - //@ts-ignore return await this.helpers.requestOAuth2.call(this, 'twistOAuth2Api', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Twist/Twist.node.ts b/packages/nodes-base/nodes/Twist/Twist.node.ts index 6992ac7b0c..0262339160 100644 --- a/packages/nodes-base/nodes/Twist/Twist.node.ts +++ b/packages/nodes-base/nodes/Twist/Twist.node.ts @@ -269,7 +269,7 @@ export class Twist implements INodeType { const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryProperty); attachments.push( - await twistApiRequest.call( + (await twistApiRequest.call( this, 'POST', '/attachments/upload', @@ -286,7 +286,7 @@ export class Twist implements INodeType { attachment_id: uuid(), }, }, - ), + )) as IDataObject, ); } @@ -378,7 +378,7 @@ export class Twist implements INodeType { const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryProperty); attachments.push( - await twistApiRequest.call( + (await twistApiRequest.call( this, 'POST', '/attachments/upload', @@ -395,7 +395,7 @@ export class Twist implements INodeType { attachment_id: uuid(), }, }, - ), + )) as IDataObject, ); } @@ -457,7 +457,7 @@ export class Twist implements INodeType { const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryProperty); attachments.push( - await twistApiRequest.call( + (await twistApiRequest.call( this, 'POST', '/attachments/upload', @@ -474,7 +474,7 @@ export class Twist implements INodeType { attachment_id: uuid(), }, }, - ), + )) as IDataObject, ); } @@ -582,7 +582,7 @@ export class Twist implements INodeType { const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryProperty); attachments.push( - await twistApiRequest.call( + (await twistApiRequest.call( this, 'POST', '/attachments/upload', @@ -599,7 +599,7 @@ export class Twist implements INodeType { attachment_id: uuid(), }, }, - ), + )) as IDataObject, ); } @@ -666,7 +666,7 @@ export class Twist implements INodeType { const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryProperty); attachments.push( - await twistApiRequest.call( + (await twistApiRequest.call( this, 'POST', '/attachments/upload', @@ -683,7 +683,7 @@ export class Twist implements INodeType { attachment_id: uuid(), }, }, - ), + )) as IDataObject, ); } @@ -774,7 +774,7 @@ export class Twist implements INodeType { const dataBuffer = await this.helpers.getBinaryDataBuffer(i, binaryProperty); attachments.push( - await twistApiRequest.call( + (await twistApiRequest.call( this, 'POST', '/attachments/upload', @@ -791,7 +791,7 @@ export class Twist implements INodeType { attachment_id: uuid(), }, }, - ), + )) as IDataObject, ); } diff --git a/packages/nodes-base/nodes/Twitter/GenericFunctions.ts b/packages/nodes-base/nodes/Twitter/GenericFunctions.ts index 794a3d3229..32481f2344 100644 --- a/packages/nodes-base/nodes/Twitter/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Twitter/GenericFunctions.ts @@ -7,19 +7,18 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IBinaryKeyData, IDataObject, INodeExecutionData } from 'n8n-workflow'; +import type { IBinaryKeyData, IDataObject, INodeExecutionData, JsonObject } from 'n8n-workflow'; import { NodeApiError, NodeOperationError, sleep } from 'n8n-workflow'; export async function twitterApiRequest( this: IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions | IHookFunctions, method: string, resource: string, - - body: any = {}, + body: IDataObject = {}, qs: IDataObject = {}, uri?: string, option: IDataObject = {}, -): Promise { +) { let options: OptionsWithUrl = { method, body, @@ -37,10 +36,9 @@ export async function twitterApiRequest( if (Object.keys(qs).length === 0) { delete options.qs; } - //@ts-ignore return await this.helpers.requestOAuth1.call(this, 'twitterOAuth1Api', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -49,10 +47,9 @@ export async function twitterApiRequestAllItems( propertyName: string, method: string, endpoint: string, - - body: any = {}, + body: IDataObject = {}, query: IDataObject = {}, -): Promise { +) { const returnData: IDataObject[] = []; let responseData; @@ -62,7 +59,7 @@ export async function twitterApiRequestAllItems( do { responseData = await twitterApiRequest.call(this, method, endpoint, body, query); query.since_id = responseData.search_metadata.max_id; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData.search_metadata?.next_results); return returnData; diff --git a/packages/nodes-base/nodes/Twitter/TweetInterface.ts b/packages/nodes-base/nodes/Twitter/TweetInterface.ts index fee604601b..05fb67e260 100644 --- a/packages/nodes-base/nodes/Twitter/TweetInterface.ts +++ b/packages/nodes-base/nodes/Twitter/TweetInterface.ts @@ -1,3 +1,5 @@ +import type { IDataObject } from 'n8n-workflow'; + export interface ITweet { auto_populate_reply_metadata?: boolean; display_coordinates?: boolean; @@ -8,3 +10,16 @@ export interface ITweet { status: string; in_reply_to_status_id?: string; } + +export interface ITweetCreate { + type: 'message_create'; + message_create: { + target: { + recipient_id: string; + }; + message_data: { + text: string; + attachment?: IDataObject; + }; + }; +} diff --git a/packages/nodes-base/nodes/Twitter/Twitter.node.ts b/packages/nodes-base/nodes/Twitter/Twitter.node.ts index b96e9c2183..37945c9033 100644 --- a/packages/nodes-base/nodes/Twitter/Twitter.node.ts +++ b/packages/nodes-base/nodes/Twitter/Twitter.node.ts @@ -19,7 +19,7 @@ import { uploadAttachments, } from './GenericFunctions'; -import type { ITweet } from './TweetInterface'; +import type { ITweet, ITweetCreate } from './TweetInterface'; import ISO6391 from 'iso-639-1'; @@ -105,7 +105,7 @@ export class Twitter implements INodeType { const userId = this.getNodeParameter('userId', i) as string; const text = this.getNodeParameter('text', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i); - const body: IDataObject = { + const body: ITweetCreate = { type: 'message_create', message_create: { target: { @@ -126,14 +126,12 @@ export class Twitter implements INodeType { }); const medias = await uploadAttachments.call(this, attachmentProperties, items, i); - //@ts-ignore body.message_create.message_data.attachment = { type: 'media', //@ts-ignore media: { id: medias[0].media_id_string }, }; } else { - //@ts-ignore delete body.message_create.message_data.attachment; } @@ -314,7 +312,7 @@ export class Twitter implements INodeType { } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Typeform/GenericFunctions.ts b/packages/nodes-base/nodes/Typeform/GenericFunctions.ts index 520d1182f9..825f63d275 100644 --- a/packages/nodes-base/nodes/Typeform/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Typeform/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { IExecuteFunctions, IHookFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject, INodePropertyOptions } from 'n8n-workflow'; +import type { IDataObject, INodePropertyOptions, JsonObject } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; import type { OptionsWithUri } from 'request'; @@ -59,7 +59,7 @@ export async function apiRequest( return await this.helpers.requestOAuth2.call(this, 'typeformOAuth2Api', options); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -95,7 +95,7 @@ export async function apiRequestAllItems( responseData = await apiRequest.call(this, method, endpoint, body, query); - returnData.items.push.apply(returnData.items, responseData.items); + returnData.items.push.apply(returnData.items, responseData.items as IDataObject[]); } while (responseData.page_count !== undefined && responseData.page_count > query.page); return returnData; diff --git a/packages/nodes-base/nodes/UProc/GenericFunctions.ts b/packages/nodes-base/nodes/UProc/GenericFunctions.ts index ee55454aa0..2c7b2b4ec7 100644 --- a/packages/nodes-base/nodes/UProc/GenericFunctions.ts +++ b/packages/nodes-base/nodes/UProc/GenericFunctions.ts @@ -5,7 +5,12 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject, IHttpRequestMethods, IHttpRequestOptions } from 'n8n-workflow'; +import type { + IDataObject, + IHttpRequestMethods, + IHttpRequestOptions, + JsonObject, +} from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function uprocApiRequest( @@ -27,6 +32,6 @@ export async function uprocApiRequest( try { return await this.helpers.httpRequestWithAuthentication.call(this, 'uprocApi', options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/UnleashedSoftware/GenericFunctions.ts b/packages/nodes-base/nodes/UnleashedSoftware/GenericFunctions.ts index de4f055b40..a2f508dd6b 100644 --- a/packages/nodes-base/nodes/UnleashedSoftware/GenericFunctions.ts +++ b/packages/nodes-base/nodes/UnleashedSoftware/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import { createHmac } from 'crypto'; @@ -18,12 +18,11 @@ export async function unleashedApiRequest( this: IHookFunctions | IExecuteFunctions | IExecuteSingleFunctions | ILoadOptionsFunctions, method: string, path: string, - - body: any = {}, + body: IDataObject = {}, query: IDataObject = {}, pageNumber?: number, headers?: object, -): Promise { +) { const paginatedPath = pageNumber ? `/${path}/${pageNumber}` : `/${path}`; const options: OptionsWithUrl = { @@ -56,7 +55,7 @@ export async function unleashedApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -65,10 +64,9 @@ export async function unleashedApiRequestAllItems( propertyName: string, method: string, endpoint: string, - - body: any = {}, + body: IDataObject = {}, query: IDataObject = {}, -): Promise { +) { const returnData: IDataObject[] = []; let responseData; let pageNumber = 1; @@ -77,7 +75,7 @@ export async function unleashedApiRequestAllItems( do { responseData = await unleashedApiRequest.call(this, method, endpoint, body, query, pageNumber); - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); pageNumber++; } while ( (responseData.Pagination.PageNumber as number) < @@ -101,7 +99,7 @@ export function convertNETDates(item: { [key: string]: any }) { } } if (type === 'object' && item[path]) { - convertNETDates(item[path]); + convertNETDates(item[path] as IDataObject); } }); } diff --git a/packages/nodes-base/nodes/UnleashedSoftware/UnleashedSoftware.node.ts b/packages/nodes-base/nodes/UnleashedSoftware/UnleashedSoftware.node.ts index 3d14fc4b6c..f09ae141f5 100644 --- a/packages/nodes-base/nodes/UnleashedSoftware/UnleashedSoftware.node.ts +++ b/packages/nodes-base/nodes/UnleashedSoftware/UnleashedSoftware.node.ts @@ -71,7 +71,7 @@ export class UnleashedSoftware implements INodeType { const returnData: INodeExecutionData[] = []; const length = items.length; const qs: IDataObject = {}; - let responseData; + let responseData: IDataObject | IDataObject[] = []; for (let i = 0; i < length; i++) { const resource = this.getNodeParameter('resource', 0); @@ -113,8 +113,15 @@ export class UnleashedSoftware implements INodeType { } else { const limit = this.getNodeParameter('limit', i); qs.pageSize = limit; - responseData = await unleashedApiRequest.call(this, 'GET', '/SalesOrders', {}, qs, 1); - responseData = responseData.Items; + responseData = (await unleashedApiRequest.call( + this, + 'GET', + '/SalesOrders', + {}, + qs, + 1, + )) as IDataObject; + responseData = responseData.Items as IDataObject[]; } convertNETDates(responseData); responseData = this.helpers.constructExecutionMetaData( @@ -157,8 +164,15 @@ export class UnleashedSoftware implements INodeType { } else { const limit = this.getNodeParameter('limit', i); qs.pageSize = limit; - responseData = await unleashedApiRequest.call(this, 'GET', '/StockOnHand', {}, qs, 1); - responseData = responseData.Items; + responseData = (await unleashedApiRequest.call( + this, + 'GET', + '/StockOnHand', + {}, + qs, + 1, + )) as IDataObject; + responseData = responseData.Items as IDataObject[]; } convertNETDates(responseData); diff --git a/packages/nodes-base/nodes/Uplead/GenericFunctions.ts b/packages/nodes-base/nodes/Uplead/GenericFunctions.ts index bb67b59861..e91947e214 100644 --- a/packages/nodes-base/nodes/Uplead/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Uplead/GenericFunctions.ts @@ -5,7 +5,8 @@ import type { IHookFunctions, ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; + +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function upleadApiRequest( @@ -28,12 +29,12 @@ export async function upleadApiRequest( json: true, }; options = Object.assign({}, options, option); - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/UptimeRobot/GenericFunctions.ts b/packages/nodes-base/nodes/UptimeRobot/GenericFunctions.ts index c7edce491f..d378c7f55a 100644 --- a/packages/nodes-base/nodes/UptimeRobot/GenericFunctions.ts +++ b/packages/nodes-base/nodes/UptimeRobot/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; export async function uptimeRobotApiRequest( @@ -30,10 +30,10 @@ export async function uptimeRobotApiRequest( try { const responseData = await this.helpers.request(options); if (responseData.stat !== 'ok') { - throw new NodeOperationError(this.getNode(), responseData); + throw new NodeOperationError(this.getNode(), responseData as Error); } return responseData; } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/UptimeRobot/UptimeRobot.node.ts b/packages/nodes-base/nodes/UptimeRobot/UptimeRobot.node.ts index d2b632a2fc..b8eff069f2 100644 --- a/packages/nodes-base/nodes/UptimeRobot/UptimeRobot.node.ts +++ b/packages/nodes-base/nodes/UptimeRobot/UptimeRobot.node.ts @@ -419,8 +419,8 @@ export class UptimeRobot implements INodeType { } } Array.isArray(responseData) - ? returnData.push(...responseData) - : returnData.push(responseData); + ? returnData.push(...(responseData as IDataObject[])) + : returnData.push(responseData as IDataObject); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); diff --git a/packages/nodes-base/nodes/UrlScanIo/GenericFunctions.ts b/packages/nodes-base/nodes/UrlScanIo/GenericFunctions.ts index dfd679219d..49e116bf29 100644 --- a/packages/nodes-base/nodes/UrlScanIo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/UrlScanIo/GenericFunctions.ts @@ -45,7 +45,7 @@ export async function handleListing( do { responseData = await urlScanIoApiRequest.call(this, 'GET', endpoint, {}, qs); - returnData.push(...responseData.results); + returnData.push(...(responseData.results as IDataObject[])); if (!returnAll && returnData.length > limit) { return returnData.slice(0, limit); diff --git a/packages/nodes-base/nodes/UrlScanIo/UrlScanIo.node.ts b/packages/nodes-base/nodes/UrlScanIo/UrlScanIo.node.ts index 8a59430b4a..398b79b043 100644 --- a/packages/nodes-base/nodes/UrlScanIo/UrlScanIo.node.ts +++ b/packages/nodes-base/nodes/UrlScanIo/UrlScanIo.node.ts @@ -125,13 +125,13 @@ export class UrlScanIo implements INodeType { } responseData = await urlScanIoApiRequest.call(this, 'POST', '/scan', body); - responseData = normalizeId(responseData); + responseData = normalizeId(responseData as IDataObject); } } Array.isArray(responseData) - ? returnData.push(...responseData) - : returnData.push(responseData); + ? returnData.push(...(responseData as IDataObject[])) + : returnData.push(responseData as IDataObject); } catch (error) { if (this.continueOnFail()) { returnData.push({ error: error.message }); diff --git a/packages/nodes-base/nodes/Venafi/Datacenter/GenericFunctions.ts b/packages/nodes-base/nodes/Venafi/Datacenter/GenericFunctions.ts index 67db0efe00..26f9060a2a 100644 --- a/packages/nodes-base/nodes/Venafi/Datacenter/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Venafi/Datacenter/GenericFunctions.ts @@ -73,7 +73,7 @@ export async function venafiApiRequestAllItems( do { responseData = await venafiApiRequest.call(this, method, endpoint, body, query); endpoint = get(responseData, '_links[0].Next'); - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData._links?.[0].Next); return returnData; diff --git a/packages/nodes-base/nodes/Venafi/Datacenter/VenafiTlsProtectDatacenter.node.ts b/packages/nodes-base/nodes/Venafi/Datacenter/VenafiTlsProtectDatacenter.node.ts index 6eb5b4fd0e..9d498b8d6a 100644 --- a/packages/nodes-base/nodes/Venafi/Datacenter/VenafiTlsProtectDatacenter.node.ts +++ b/packages/nodes-base/nodes/Venafi/Datacenter/VenafiTlsProtectDatacenter.node.ts @@ -138,8 +138,8 @@ export class VenafiTlsProtectDatacenter implements INodeType { ); const binaryData = await this.helpers.prepareBinaryData( - Buffer.from(responseData.CertificateData, 'base64'), - responseData.Filename, + Buffer.from(responseData.CertificateData as BufferEncoding, 'base64'), + responseData.Filename as string, ); responseData = { @@ -238,9 +238,12 @@ export class VenafiTlsProtectDatacenter implements INodeType { } returnData.push( - ...this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { - itemData: { item: i }, - }), + ...this.helpers.constructExecutionMetaData( + this.helpers.returnJsonArray(responseData as IDataObject[]), + { + itemData: { item: i }, + }, + ), ); } catch (error) { if (this.continueOnFail()) { diff --git a/packages/nodes-base/nodes/Venafi/ProtectCloud/GenericFunctions.ts b/packages/nodes-base/nodes/Venafi/ProtectCloud/GenericFunctions.ts index c11e511d3e..792f0626ce 100644 --- a/packages/nodes-base/nodes/Venafi/ProtectCloud/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Venafi/ProtectCloud/GenericFunctions.ts @@ -66,9 +66,9 @@ export async function venafiApiRequestAllItems( method: string, endpoint: string, - body: any = {}, + body: IDataObject = {}, query: IDataObject = {}, -): Promise { +) { const returnData: IDataObject[] = []; let responseData; @@ -76,7 +76,7 @@ export async function venafiApiRequestAllItems( do { responseData = await venafiApiRequest.call(this, method, endpoint, body, query); endpoint = get(responseData, '_links[0].Next'); - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData._links?.[0].Next); return returnData; @@ -119,14 +119,14 @@ export async function encryptPassphrase( try { const passphraseUTF8 = nacl.encode_utf8(passphrase) as string; const keyPassBuffer = nacl.crypto_box_seal(passphraseUTF8, Buffer.from(pubKey, 'base64')); - encryptedKeyPass = Buffer.from(keyPassBuffer).toString('base64'); + encryptedKeyPass = Buffer.from(keyPassBuffer as Buffer).toString('base64'); const storePassphraseUTF8 = nacl.encode_utf8(storePassphrase) as string; const keyStorePassBuffer = nacl.crypto_box_seal( storePassphraseUTF8, Buffer.from(pubKey, 'base64'), ); - encryptedKeyStorePass = Buffer.from(keyStorePassBuffer).toString('base64'); + encryptedKeyStorePass = Buffer.from(keyStorePassBuffer as Buffer).toString('base64'); return resolve([encryptedKeyPass, encryptedKeyStorePass]); } catch (error) { diff --git a/packages/nodes-base/nodes/Venafi/ProtectCloud/VenafiTlsProtectCloud.node.ts b/packages/nodes-base/nodes/Venafi/ProtectCloud/VenafiTlsProtectCloud.node.ts index 7c717069c7..2a34b0d672 100644 --- a/packages/nodes-base/nodes/Venafi/ProtectCloud/VenafiTlsProtectCloud.node.ts +++ b/packages/nodes-base/nodes/Venafi/ProtectCloud/VenafiTlsProtectCloud.node.ts @@ -370,7 +370,7 @@ export class VenafiTlsProtectCloud implements INodeType { ); } - const contentDisposition = responseData.headers['content-disposition']; + const contentDisposition: string = responseData.headers['content-disposition']; const fileNameRegex = /(?<=filename=").*\b/; const match = fileNameRegex.exec(contentDisposition); let fileName = ''; @@ -380,7 +380,7 @@ export class VenafiTlsProtectCloud implements INodeType { } const binaryData = await this.helpers.prepareBinaryData( - Buffer.from(responseData.body), + Buffer.from(responseData.body as Buffer), fileName, ); @@ -474,9 +474,12 @@ export class VenafiTlsProtectCloud implements INodeType { } returnData.push( - ...this.helpers.constructExecutionMetaData(this.helpers.returnJsonArray(responseData), { - itemData: { item: i }, - }), + ...this.helpers.constructExecutionMetaData( + this.helpers.returnJsonArray(responseData as IDataObject[]), + { + itemData: { item: i }, + }, + ), ); } catch (error) { if (this.continueOnFail()) { diff --git a/packages/nodes-base/nodes/Vero/GenericFunctions.ts b/packages/nodes-base/nodes/Vero/GenericFunctions.ts index 6654964d2c..2557c5b34f 100644 --- a/packages/nodes-base/nodes/Vero/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Vero/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function veroApiRequest( @@ -27,13 +27,13 @@ export async function veroApiRequest( json: true, }; options = Object.assign({}, options, option); - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Vero/Vero.node.ts b/packages/nodes-base/nodes/Vero/Vero.node.ts index d0ae43aaa6..38d2c67f61 100644 --- a/packages/nodes-base/nodes/Vero/Vero.node.ts +++ b/packages/nodes-base/nodes/Vero/Vero.node.ts @@ -4,6 +4,7 @@ import type { INodeExecutionData, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; import { validateJSON, veroApiRequest } from './GenericFunctions'; @@ -73,11 +74,10 @@ export class Vero implements INodeType { const id = this.getNodeParameter('id', i) as string; const additionalFields = this.getNodeParameter('additionalFields', i); const jsonActive = this.getNodeParameter('jsonParameters', i); - const body = { + const body: IDataObject = { id, }; if (additionalFields.email) { - // @ts-ignore body.email = additionalFields.email as string; } if (!jsonActive) { @@ -85,12 +85,10 @@ export class Vero implements INodeType { this.getNodeParameter('dataAttributesUi', i) as IDataObject ).dataAttributesValues as IDataObject[]; if (dataAttributesValues) { - const dataAttributes = {}; + const dataAttributes: IDataObject = {}; for (let index = 0; index < dataAttributesValues.length; index++) { - // @ts-ignore - dataAttributes[dataAttributesValues[index].key] = + dataAttributes[dataAttributesValues[index].key as string] = dataAttributesValues[index].value; - // @ts-ignore body.data = dataAttributes; } } @@ -99,14 +97,13 @@ export class Vero implements INodeType { this.getNodeParameter('dataAttributesJson', i) as string, ); if (dataAttributesJson) { - // @ts-ignore body.data = dataAttributesJson; } } try { responseData = await veroApiRequest.call(this, 'POST', '/users/track', body); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } //https://developers.getvero.com/?bash#users-alias @@ -120,7 +117,7 @@ export class Vero implements INodeType { try { responseData = await veroApiRequest.call(this, 'PUT', '/users/reidentify', body); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } //https://developers.getvero.com/?bash#users-unsubscribe @@ -138,7 +135,7 @@ export class Vero implements INodeType { try { responseData = await veroApiRequest.call(this, 'POST', `/users/${operation}`, body); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } //https://developers.getvero.com/?bash#tags-add @@ -146,21 +143,19 @@ export class Vero implements INodeType { if (operation === 'addTags' || operation === 'removeTags') { const id = this.getNodeParameter('id', i) as string; const tags = (this.getNodeParameter('tags', i) as string).split(','); - const body = { + const body: IDataObject = { id, }; if (operation === 'addTags') { - // @ts-ignore body.add = JSON.stringify(tags); } if (operation === 'removeTags') { - // @ts-ignore body.remove = JSON.stringify(tags); } try { responseData = await veroApiRequest.call(this, 'PUT', '/users/tags/edit', body); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } } @@ -172,7 +167,7 @@ export class Vero implements INodeType { const email = this.getNodeParameter('email', i) as string; const eventName = this.getNodeParameter('eventName', i) as string; const jsonActive = this.getNodeParameter('jsonParameters', i); - const body = { + const body: IDataObject = { identity: { id, email }, event_name: eventName, email, @@ -182,12 +177,10 @@ export class Vero implements INodeType { this.getNodeParameter('dataAttributesUi', i) as IDataObject ).dataAttributesValues as IDataObject[]; if (dataAttributesValues) { - const dataAttributes = {}; + const dataAttributes: IDataObject = {}; for (let index = 0; index < dataAttributesValues.length; index++) { - // @ts-ignore - dataAttributes[dataAttributesValues[index].key] = + dataAttributes[dataAttributesValues[index].key as string] = dataAttributesValues[index].value; - // @ts-ignore body.data = JSON.stringify(dataAttributes); } } @@ -195,12 +188,10 @@ export class Vero implements INodeType { this.getNodeParameter('extraAttributesUi', i) as IDataObject ).extraAttributesValues as IDataObject[]; if (extraAttributesValues) { - const extraAttributes = {}; + const extraAttributes: IDataObject = {}; for (let index = 0; index < extraAttributesValues.length; index++) { - // @ts-ignore - extraAttributes[extraAttributesValues[index].key] = + extraAttributes[extraAttributesValues[index].key as string] = extraAttributesValues[index].value; - // @ts-ignore body.extras = JSON.stringify(extraAttributes); } } @@ -209,21 +200,19 @@ export class Vero implements INodeType { this.getNodeParameter('dataAttributesJson', i) as string, ); if (dataAttributesJson) { - // @ts-ignore body.data = JSON.stringify(dataAttributesJson); } const extraAttributesJson = validateJSON( this.getNodeParameter('extraAttributesJson', i) as string, ); if (extraAttributesJson) { - // @ts-ignore body.extras = JSON.stringify(extraAttributesJson); } } try { responseData = await veroApiRequest.call(this, 'POST', '/events/track', body); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } } diff --git a/packages/nodes-base/nodes/Vonage/GenericFunctions.ts b/packages/nodes-base/nodes/Vonage/GenericFunctions.ts index 8330cea740..376bde7a2e 100644 --- a/packages/nodes-base/nodes/Vonage/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Vonage/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function vonageApiRequest( @@ -29,12 +29,11 @@ export async function vonageApiRequest( }; try { - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } - //@ts-ignore return await this.helpers.request.call(this, options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Wait/Wait.node.ts b/packages/nodes-base/nodes/Wait/Wait.node.ts index f8527fd4f5..5fe8e46153 100644 --- a/packages/nodes-base/nodes/Wait/Wait.node.ts +++ b/packages/nodes-base/nodes/Wait/Wait.node.ts @@ -758,7 +758,7 @@ export class Wait implements INodeType { workflowData: [[returnItem]], }; } catch (error) { - throw new NodeOperationError(this.getNode(), error); + throw new NodeOperationError(this.getNode(), error as Error); } finally { await binaryFile.cleanup(); } diff --git a/packages/nodes-base/nodes/Webflow/GenericFunctions.ts b/packages/nodes-base/nodes/Webflow/GenericFunctions.ts index 1a49358f91..485054a482 100644 --- a/packages/nodes-base/nodes/Webflow/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Webflow/GenericFunctions.ts @@ -41,11 +41,11 @@ export async function webflowApiRequest( }; options = Object.assign({}, options, option); - if (Object.keys(options.qs).length === 0) { + if (Object.keys(options.qs as IDataObject).length === 0) { delete options.qs; } - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } return this.helpers.requestWithAuthentication.call(this, credentialsType, options); @@ -70,7 +70,7 @@ export async function webflowApiRequestAllItems( if (responseData.offset !== undefined) { query.offset += query.limit; } - returnData.push.apply(returnData, responseData.items); + returnData.push.apply(returnData, responseData.items as IDataObject[]); } while (returnData.length < responseData.total); return returnData; diff --git a/packages/nodes-base/nodes/Webflow/Webflow.node.ts b/packages/nodes-base/nodes/Webflow/Webflow.node.ts index 5c7036f57c..bc6019e1fb 100644 --- a/packages/nodes-base/nodes/Webflow/Webflow.node.ts +++ b/packages/nodes-base/nodes/Webflow/Webflow.node.ts @@ -275,7 +275,7 @@ export class Webflow implements INodeType { } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Webflow/WebflowTrigger.node.ts b/packages/nodes-base/nodes/Webflow/WebflowTrigger.node.ts index 580db4d532..0fc80f5d01 100644 --- a/packages/nodes-base/nodes/Webflow/WebflowTrigger.node.ts +++ b/packages/nodes-base/nodes/Webflow/WebflowTrigger.node.ts @@ -195,7 +195,6 @@ export class WebflowTrigger implements INodeType { }, }; - // @ts-ignore webhookMethods = { default: { async checkExists(this: IHookFunctions): Promise { @@ -268,7 +267,7 @@ export class WebflowTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const req = this.getRequestObject(); return { - workflowData: [this.helpers.returnJsonArray(req.body)], + workflowData: [this.helpers.returnJsonArray(req.body as IDataObject[])], }; } } diff --git a/packages/nodes-base/nodes/Webhook/Webhook.node.ts b/packages/nodes-base/nodes/Webhook/Webhook.node.ts index c9f6f165ec..a1a9efa138 100644 --- a/packages/nodes-base/nodes/Webhook/Webhook.node.ts +++ b/packages/nodes-base/nodes/Webhook/Webhook.node.ts @@ -570,7 +570,7 @@ export class Webhook implements INodeType { workflowData: [[returnItem]], }; } catch (error) { - throw new NodeOperationError(this.getNode(), error); + throw new NodeOperationError(this.getNode(), error as Error); } finally { await binaryFile.cleanup(); } diff --git a/packages/nodes-base/nodes/Wise/GenericFunctions.ts b/packages/nodes-base/nodes/Wise/GenericFunctions.ts index 0390987710..75d2030dc4 100644 --- a/packages/nodes-base/nodes/Wise/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Wise/GenericFunctions.ts @@ -2,7 +2,12 @@ import { createSign } from 'crypto'; import type { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import type { IDataObject, IHttpRequestOptions, ILoadOptionsFunctions } from 'n8n-workflow'; +import type { + IDataObject, + IHttpRequestOptions, + ILoadOptionsFunctions, + JsonObject, +} from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; /** @@ -62,7 +67,7 @@ export async function wiseApiRequest( response = await this.helpers.httpRequest(options); } catch (error) { delete error.config; - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } if (response.statusCode >= 200 && response.statusCode < 300) { @@ -93,7 +98,7 @@ export async function wiseApiRequest( } catch (error) { throw new NodeApiError(this.getNode(), { message: 'Error signing SCA request, check your private key', - ...error, + ...(error as JsonObject), }); } // Retry the request with signed token @@ -106,7 +111,10 @@ export async function wiseApiRequest( }); } } else { - throw new NodeApiError(this.getNode(), { ...response, message: response.statusMessage }); + throw new NodeApiError(this.getNode(), { + ...(response as JsonObject), + message: response.statusMessage, + }); } } diff --git a/packages/nodes-base/nodes/Wise/Wise.node.ts b/packages/nodes-base/nodes/Wise/Wise.node.ts index ffa665bd96..f7a66d0893 100644 --- a/packages/nodes-base/nodes/Wise/Wise.node.ts +++ b/packages/nodes-base/nodes/Wise/Wise.node.ts @@ -3,6 +3,7 @@ import type { IExecuteFunctions } from 'n8n-core'; import type { IDataObject, ILoadOptionsFunctions, + INodeExecutionData, INodePropertyOptions, INodeType, INodeTypeDescription, @@ -256,7 +257,7 @@ export class Wise implements INodeType { items[i].binary = items[i].binary ?? {}; items[i].binary![binaryProperty] = await this.helpers.prepareBinaryData( - data, + data as Buffer, this.getNodeParameter('fileName', i) as string, ); @@ -484,7 +485,7 @@ export class Wise implements INodeType { items[i].binary = items[i].binary ?? {}; items[i].binary![binaryProperty] = await this.helpers.prepareBinaryData( - data, + data as Buffer, this.getNodeParameter('fileName', i) as string, ); @@ -539,12 +540,12 @@ export class Wise implements INodeType { } Array.isArray(responseData) - ? returnData.push(...responseData) - : returnData.push(responseData); + ? returnData.push(...(responseData as IDataObject[])) + : returnData.push(responseData as IDataObject); } if (binaryOutput && responseData !== undefined) { - return this.prepareOutputData(responseData); + return this.prepareOutputData(responseData as INodeExecutionData[]); } return [this.helpers.returnJsonArray(returnData)]; diff --git a/packages/nodes-base/nodes/Wise/WiseTrigger.node.ts b/packages/nodes-base/nodes/Wise/WiseTrigger.node.ts index 2245abd3f5..411973723c 100644 --- a/packages/nodes-base/nodes/Wise/WiseTrigger.node.ts +++ b/packages/nodes-base/nodes/Wise/WiseTrigger.node.ts @@ -93,7 +93,6 @@ export class WiseTrigger implements INodeType { }, }; - // @ts-ignore webhookMethods = { default: { async checkExists(this: IHookFunctions): Promise { @@ -186,7 +185,7 @@ export class WiseTrigger implements INodeType { } return { - workflowData: [this.helpers.returnJsonArray(req.body)], + workflowData: [this.helpers.returnJsonArray(req.body as IDataObject)], }; } } diff --git a/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts b/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts index e8b9345fa8..e054792a01 100644 --- a/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts +++ b/packages/nodes-base/nodes/WooCommerce/GenericFunctions.ts @@ -43,7 +43,7 @@ export async function woocommerceApiRequest( json: true, }; - if (!Object.keys(body).length) { + if (!Object.keys(body as IDataObject).length) { delete options.form; } options = Object.assign({}, options, option); @@ -72,7 +72,7 @@ export async function woocommerceApiRequestAllItems( if (nextLink) { uri = nextLink.split(';')[0].replace(/<(.*)>/, '$1'); } - returnData.push.apply(returnData, responseData.body); + returnData.push.apply(returnData, responseData.body as IDataObject[]); } while (responseData.headers.link?.includes('rel="next"')); return returnData; diff --git a/packages/nodes-base/nodes/WooCommerce/WooCommerce.node.ts b/packages/nodes-base/nodes/WooCommerce/WooCommerce.node.ts index 6702ffcc18..c048a8dd2d 100644 --- a/packages/nodes-base/nodes/WooCommerce/WooCommerce.node.ts +++ b/packages/nodes-base/nodes/WooCommerce/WooCommerce.node.ts @@ -419,7 +419,6 @@ export class WooCommerce implements INodeType { body.line_items = lineItems; setMetadata(lineItems); toSnakeCase(lineItems); - //@ts-ignore } const metadata = (this.getNodeParameter('metadataUi', i) as IDataObject) .metadataValues as IDataObject[]; @@ -579,7 +578,7 @@ export class WooCommerce implements INodeType { } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/WooCommerce/WooCommerceTrigger.node.ts b/packages/nodes-base/nodes/WooCommerce/WooCommerceTrigger.node.ts index cbc5a3b280..e95fa4fecc 100644 --- a/packages/nodes-base/nodes/WooCommerce/WooCommerceTrigger.node.ts +++ b/packages/nodes-base/nodes/WooCommerce/WooCommerceTrigger.node.ts @@ -100,7 +100,6 @@ export class WooCommerceTrigger implements INodeType { ], }; - // @ts-ignore webhookMethods = { default: { async checkExists(this: IHookFunctions): Promise { @@ -177,7 +176,7 @@ export class WooCommerceTrigger implements INodeType { return {}; } return { - workflowData: [this.helpers.returnJsonArray(req.body)], + workflowData: [this.helpers.returnJsonArray(req.body as IDataObject)], }; } } diff --git a/packages/nodes-base/nodes/Wordpress/GenericFunctions.ts b/packages/nodes-base/nodes/Wordpress/GenericFunctions.ts index de77b7c117..1188962605 100644 --- a/packages/nodes-base/nodes/Wordpress/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Wordpress/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function wordpressApiRequest( @@ -30,14 +30,14 @@ export async function wordpressApiRequest( json: true, }; options = Object.assign({}, options, option); - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } try { const credentialType = 'wordpressApi'; return await this.helpers.requestWithAuthentication.call(this, credentialType, options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -61,11 +61,11 @@ export async function wordpressApiRequestAllItems( responseData = await wordpressApiRequest.call(this, method, endpoint, body, query, undefined, { resolveWithFullResponse: true, }); - returnData.push.apply(returnData, responseData.body); + returnData.push.apply(returnData, responseData.body as IDataObject[]); } while ( responseData.headers['x-wp-totalpages'] !== undefined && responseData.headers['x-wp-totalpages'] !== '0' && - parseInt(responseData.headers['x-wp-totalpages'], 10) !== query.page + parseInt(responseData.headers['x-wp-totalpages'] as string, 10) !== query.page ); return returnData; diff --git a/packages/nodes-base/nodes/Wordpress/Wordpress.node.ts b/packages/nodes-base/nodes/Wordpress/Wordpress.node.ts index 2dcc16c19b..99aaefcb99 100644 --- a/packages/nodes-base/nodes/Wordpress/Wordpress.node.ts +++ b/packages/nodes-base/nodes/Wordpress/Wordpress.node.ts @@ -420,7 +420,7 @@ export class Wordpress implements INodeType { } } const exectutionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...exectutionData); diff --git a/packages/nodes-base/nodes/Workable/GenericFunctions.ts b/packages/nodes-base/nodes/Workable/GenericFunctions.ts index 6bb20d4320..9ebb0d4ffa 100644 --- a/packages/nodes-base/nodes/Workable/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Workable/GenericFunctions.ts @@ -7,7 +7,7 @@ import type { ILoadOptionsFunctions, } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function workableApiRequest( @@ -34,12 +34,12 @@ export async function workableApiRequest( json: true, }; options = Object.assign({}, options, option); - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Wufoo/GenericFunctions.ts b/packages/nodes-base/nodes/Wufoo/GenericFunctions.ts index d1a4173d22..cfa62b5037 100644 --- a/packages/nodes-base/nodes/Wufoo/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Wufoo/GenericFunctions.ts @@ -31,7 +31,7 @@ export async function wufooApiRequest( }; options = Object.assign({}, options, option); - if (Object.keys(options.body).length === 0 || method === 'PUT') { + if (Object.keys(options.body as IDataObject).length === 0 || method === 'PUT') { delete options.body; } diff --git a/packages/nodes-base/nodes/Wufoo/WufooTrigger.node.ts b/packages/nodes-base/nodes/Wufoo/WufooTrigger.node.ts index e427fd132b..d971ea9e4d 100644 --- a/packages/nodes-base/nodes/Wufoo/WufooTrigger.node.ts +++ b/packages/nodes-base/nodes/Wufoo/WufooTrigger.node.ts @@ -98,7 +98,6 @@ export class WufooTrigger implements INodeType { }, }; - // @ts-ignore webhookMethods = { default: { // No API endpoint to allow checking of existing webhooks. @@ -154,7 +153,7 @@ export class WufooTrigger implements INodeType { return {}; } - const fieldsObject = jsonParse(req.body.FieldStructure, { + const fieldsObject = jsonParse(req.body.FieldStructure as string, { errorMessage: "Invalid JSON in request body field 'FieldStructure'", }); @@ -209,10 +208,10 @@ export class WufooTrigger implements INodeType { entryId: req.body.EntryId as number, dateCreated: req.body.DateCreated as Date, formId: req.body.FormId as string, - formStructure: jsonParse(req.body.FormStructure, { + formStructure: jsonParse(req.body.FormStructure as string, { errorMessage: "Invalid JSON in request body field 'FormStructure'", }), - fieldStructure: jsonParse(req.body.FieldStructure, { + fieldStructure: jsonParse(req.body.FieldStructure as string, { errorMessage: "Invalid JSON in request body field 'FieldStructure'", }), entries, diff --git a/packages/nodes-base/nodes/Xero/GenericFunctions.ts b/packages/nodes-base/nodes/Xero/GenericFunctions.ts index ff6f3ab088..7aacd70000 100644 --- a/packages/nodes-base/nodes/Xero/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Xero/GenericFunctions.ts @@ -33,10 +33,9 @@ export async function xeroApiRequest( if (Object.keys(headers).length !== 0) { options.headers = Object.assign({}, options.headers, headers); } - if (Object.keys(body).length === 0) { + if (Object.keys(body as IDataObject).length === 0) { delete options.body; } - //@ts-ignore return await this.helpers.requestOAuth2.call(this, 'xeroOAuth2Api', options); } catch (error) { throw new NodeApiError(this.getNode(), error as JsonObject); @@ -60,7 +59,7 @@ export async function xeroApiRequestAllItems( do { responseData = await xeroApiRequest.call(this, method, endpoint, body, query); query.page++; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); } while (responseData[propertyName].length !== 0); return returnData; diff --git a/packages/nodes-base/nodes/Xero/Xero.node.ts b/packages/nodes-base/nodes/Xero/Xero.node.ts index cc16e033b9..3e141b4ccb 100644 --- a/packages/nodes-base/nodes/Xero/Xero.node.ts +++ b/packages/nodes-base/nodes/Xero/Xero.node.ts @@ -719,7 +719,7 @@ export class Xero implements INodeType { } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Yourls/GenericFunctions.ts b/packages/nodes-base/nodes/Yourls/GenericFunctions.ts index 71f9cfd6ae..d0a2609db7 100644 --- a/packages/nodes-base/nodes/Yourls/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Yourls/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; export async function yourlsApiRequest( @@ -25,7 +25,6 @@ export async function yourlsApiRequest( json: true, }; try { - //@ts-ignore const response = await this.helpers.request.call(this, options); if (response.status === 'fail') { @@ -37,6 +36,6 @@ export async function yourlsApiRequest( return response; } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Zammad/GenericFunctions.ts b/packages/nodes-base/nodes/Zammad/GenericFunctions.ts index 9ecd25962d..37722b1077 100644 --- a/packages/nodes-base/nodes/Zammad/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zammad/GenericFunctions.ts @@ -1,6 +1,6 @@ import type { IExecuteFunctions } from 'n8n-core'; -import type { IDataObject, ILoadOptionsFunctions } from 'n8n-workflow'; +import type { IDataObject, ILoadOptionsFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; import type { OptionsWithUri } from 'request'; @@ -76,7 +76,7 @@ export async function zammadApiRequest( error.error.error = 'An entity with this name already exists.'; } - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -98,7 +98,7 @@ export async function zammadApiRequestAllItems( do { responseData = await zammadApiRequest.call(this, method, endpoint, body, qs); - returnData.push(...responseData); + returnData.push(...(responseData as IDataObject[])); if (limit && returnData.length > limit) { return returnData.slice(0, limit); diff --git a/packages/nodes-base/nodes/Zammad/Zammad.node.ts b/packages/nodes-base/nodes/Zammad/Zammad.node.ts index 7ce7f65564..8a71a93d26 100644 --- a/packages/nodes-base/nodes/Zammad/Zammad.node.ts +++ b/packages/nodes-base/nodes/Zammad/Zammad.node.ts @@ -746,7 +746,7 @@ export class Zammad implements INodeType { } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Zendesk/GenericFunctions.ts b/packages/nodes-base/nodes/Zendesk/GenericFunctions.ts index e32b823757..6c06ab7f66 100644 --- a/packages/nodes-base/nodes/Zendesk/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zendesk/GenericFunctions.ts @@ -26,7 +26,7 @@ export async function zendeskApiRequest( qs: IDataObject = {}, uri?: string, option: IDataObject = {}, -): Promise { +) { const authenticationMethod = this.getNodeParameter('authentication', 0); let credentials; @@ -49,7 +49,7 @@ export async function zendeskApiRequest( }; options = Object.assign({}, options, option); - if (Object.keys(options.body).length === 0) { + if (Object.keys(options.body as IDataObject).length === 0) { delete options.body; } @@ -80,7 +80,7 @@ export async function zendeskApiRequestAllItems( do { responseData = await zendeskApiRequest.call(this, method, resource, body, query, uri); uri = responseData.next_page; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); if (query.limit && query.limit <= returnData.length) { return returnData; } diff --git a/packages/nodes-base/nodes/Zendesk/Zendesk.node.ts b/packages/nodes-base/nodes/Zendesk/Zendesk.node.ts index 9d0d40f3dc..084e384c36 100644 --- a/packages/nodes-base/nodes/Zendesk/Zendesk.node.ts +++ b/packages/nodes-base/nodes/Zendesk/Zendesk.node.ts @@ -7,6 +7,7 @@ import type { INodePropertyOptions, INodeType, INodeTypeDescription, + JsonObject, } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; @@ -141,7 +142,7 @@ export class Zendesk implements INodeType { '/ticket_fields', ); for (const field of fields) { - if (customFields.includes(field.type)) { + if (customFields.includes(field.type as string)) { const fieldName = field.title; const fieldId = field.id; returnData.push({ @@ -477,7 +478,7 @@ export class Zendesk implements INodeType { ); responseData = responseData.ticket; } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } } @@ -787,7 +788,7 @@ export class Zendesk implements INodeType { } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Zendesk/ZendeskTrigger.node.ts b/packages/nodes-base/nodes/Zendesk/ZendeskTrigger.node.ts index f7993da931..1525caf0cc 100644 --- a/packages/nodes-base/nodes/Zendesk/ZendeskTrigger.node.ts +++ b/packages/nodes-base/nodes/Zendesk/ZendeskTrigger.node.ts @@ -165,7 +165,7 @@ export class ZendeskTrigger implements INodeType { '/ticket_fields', ); for (const field of fields) { - if (customFields.includes(field.type) && field.removable && field.active) { + if (customFields.includes(field.type as string) && field.removable && field.active) { const fieldName = field.title; const fieldId = field.id; returnData.push({ @@ -218,7 +218,6 @@ export class ZendeskTrigger implements INodeType { }, }; - // @ts-ignore webhookMethods = { default: { async checkExists(this: IHookFunctions): Promise { @@ -316,7 +315,6 @@ export class ZendeskTrigger implements INodeType { if (options.fields) { for (const field of options.fields as string[]) { - // @ts-ignore message[field] = `{{${field}}}`; } } else { @@ -400,8 +398,10 @@ export class ZendeskTrigger implements INodeType { .webhook as IDataObject; } - // @ts-ignore - bodyTrigger.trigger.actions[0].value = [target.id, JSON.stringify(message)]; + ((bodyTrigger.trigger as IDataObject).actions as IDataObject[])[0].value = [ + target.id, + JSON.stringify(message), + ]; const { trigger } = await zendeskApiRequest.call(this, 'POST', '/triggers', bodyTrigger); webhookData.webhookId = trigger.id; @@ -427,7 +427,7 @@ export class ZendeskTrigger implements INodeType { async webhook(this: IWebhookFunctions): Promise { const req = this.getRequestObject(); return { - workflowData: [this.helpers.returnJsonArray(req.body)], + workflowData: [this.helpers.returnJsonArray(req.body as IDataObject)], }; } } diff --git a/packages/nodes-base/nodes/Zoho/GenericFunctions.ts b/packages/nodes-base/nodes/Zoho/GenericFunctions.ts index 60f9cddf44..ad94e0e0eb 100644 --- a/packages/nodes-base/nodes/Zoho/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zoho/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IHookFunctions } from 'n8n-core'; -import type { IDataObject, ILoadOptionsFunctions } from 'n8n-workflow'; +import type { IDataObject, ILoadOptionsFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError, NodeOperationError } from 'n8n-workflow'; import flow from 'lodash.flow'; @@ -68,11 +68,11 @@ export async function zohoApiRequest( if (responseData === undefined) return []; - throwOnErrorStatus.call(this, responseData); + throwOnErrorStatus.call(this, responseData as IDataObject); return responseData; } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -95,7 +95,7 @@ export async function zohoApiRequestAllItems( do { responseData = await zohoApiRequest.call(this, method, endpoint, body, qs); if (Array.isArray(responseData) && !responseData.length) return returnData; - returnData.push(...responseData.data); + returnData.push(...(responseData.data as IDataObject[])); qs.page++; } while (responseData.info.more_records !== undefined && responseData.info.more_records === true); diff --git a/packages/nodes-base/nodes/Zoho/ZohoCrm.node.ts b/packages/nodes-base/nodes/Zoho/ZohoCrm.node.ts index e4dff450d1..3dfe8016ef 100644 --- a/packages/nodes-base/nodes/Zoho/ZohoCrm.node.ts +++ b/packages/nodes-base/nodes/Zoho/ZohoCrm.node.ts @@ -1326,7 +1326,7 @@ export class ZohoCrm implements INodeType { throw error; } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Zoom/GenericFunctions.ts b/packages/nodes-base/nodes/Zoom/GenericFunctions.ts index a8484d8b6c..754779fe2b 100644 --- a/packages/nodes-base/nodes/Zoom/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zoom/GenericFunctions.ts @@ -2,7 +2,7 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, IExecuteSingleFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject } from 'n8n-workflow'; +import type { IDataObject, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function zoomApiRequest( @@ -38,11 +38,10 @@ export async function zoomApiRequest( if (authenticationMethod === 'accessToken') { return await this.helpers.requestWithAuthentication.call(this, 'zoomApi', options); } else { - //@ts-ignore return await this.helpers.requestOAuth2.call(this, 'zoomOAuth2Api', options); } } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } @@ -68,7 +67,7 @@ export async function zoomApiRequestAllItems( do { responseData = await zoomApiRequest.call(this, method, endpoint, body, query); query.page_number++; - returnData.push.apply(returnData, responseData[propertyName]); + returnData.push.apply(returnData, responseData[propertyName] as IDataObject[]); // zoom free plan rate limit is 1 request/second // TODO just wait when the plan is free await wait(); diff --git a/packages/nodes-base/nodes/Zoom/Zoom.node.ts b/packages/nodes-base/nodes/Zoom/Zoom.node.ts index 7479802a5f..72c8d79fa3 100644 --- a/packages/nodes-base/nodes/Zoom/Zoom.node.ts +++ b/packages/nodes-base/nodes/Zoom/Zoom.node.ts @@ -775,7 +775,7 @@ export class Zoom implements INodeType { // } // } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/nodes/Zulip/GenericFunctions.ts b/packages/nodes-base/nodes/Zulip/GenericFunctions.ts index 378831c6f9..59509ad757 100644 --- a/packages/nodes-base/nodes/Zulip/GenericFunctions.ts +++ b/packages/nodes-base/nodes/Zulip/GenericFunctions.ts @@ -2,7 +2,11 @@ import type { OptionsWithUri } from 'request'; import type { IExecuteFunctions, ILoadOptionsFunctions } from 'n8n-core'; -import type { IDataObject, IHookFunctions, IWebhookFunctions } from 'n8n-workflow'; +import type { IMessage } from './MessageInterface'; +import type { IStream } from './StreamInterface'; +import type { IUser } from './UserInterface'; + +import type { IDataObject, IHookFunctions, IWebhookFunctions, JsonObject } from 'n8n-workflow'; import { NodeApiError } from 'n8n-workflow'; export async function zulipApiRequest( @@ -10,11 +14,11 @@ export async function zulipApiRequest( method: string, resource: string, - body: any = {}, + body: IMessage | IStream | IUser = {}, query: IDataObject = {}, uri?: string, option: IDataObject = {}, -): Promise { +) { const credentials = await this.getCredentials('zulipApi'); const endpoint = `${credentials.url}/api/v1`; @@ -43,7 +47,7 @@ export async function zulipApiRequest( try { return await this.helpers.request(options); } catch (error) { - throw new NodeApiError(this.getNode(), error); + throw new NodeApiError(this.getNode(), error as JsonObject); } } diff --git a/packages/nodes-base/nodes/Zulip/Zulip.node.ts b/packages/nodes-base/nodes/Zulip/Zulip.node.ts index 4bed35caa8..e26be1c828 100644 --- a/packages/nodes-base/nodes/Zulip/Zulip.node.ts +++ b/packages/nodes-base/nodes/Zulip/Zulip.node.ts @@ -465,7 +465,7 @@ export class Zulip implements INodeType { } } const executionData = this.helpers.constructExecutionMetaData( - this.helpers.returnJsonArray(responseData), + this.helpers.returnJsonArray(responseData as IDataObject[]), { itemData: { item: i } }, ); returnData.push(...executionData); diff --git a/packages/nodes-base/utils/utilities.ts b/packages/nodes-base/utils/utilities.ts index 0ec385078f..28fa916896 100644 --- a/packages/nodes-base/utils/utilities.ts +++ b/packages/nodes-base/utils/utilities.ts @@ -48,7 +48,7 @@ export function chunk(array: any[], size = 1) { export function flatten(nestedArray: any[][]) { const result = []; - (function loop(array: any[]) { + (function loop(array: any[] | any) { for (let i = 0; i < array.length; i++) { if (Array.isArray(array[i])) { loop(array[i]);